@marlinjai/studio-mcp 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,7 +105,7 @@ The token is held in memory only. It is never logged, never serialized into a re
105
105
  | `studio_workflow_describe` | The node vocabulary: every task type with ports, prompt policy and runnability, the input types, the op types, the patch limits. Settings and models only with `includeSettings` / `includeModels`; filter with `tasks`. |
106
106
  | `studio_workflow_get` | A saved workflow as a summary (nodes, wire counts, edge and group counts, `revision`, `readOnly`, `projection`), or the whole response with `full: true`. |
107
107
  | `studio_workflow_create` | Build a new saved workflow from ops applied to an empty document. Returns `{ ok, savedId, revision, summary }`. |
108
- | `studio_workflow_apply` | Change a saved workflow atomically on top of `baseRevision`. Returns counts, the affected nodes, the projection and `replayed`; every refusal (stale base, invalid patch, missing scope, not editable, lossy import, idempotency mismatch) comes back as a structured `{ ok: false, code, hint }` result. |
108
+ | `studio_workflow_apply` | Change a saved workflow atomically on top of `baseRevision`. Returns counts, the affected nodes, the projection and `replayed`; every refusal (stale base, invalid patch, missing scope, not editable, lossy import, idempotency mismatch) comes back as a structured `{ ok: false, code, hint }` result. Character references on an image-to-video node (models whose `studio_workflow_describe` entry carries `characterReferences`, Kling O3): `connect` each photo with `port: "reference"`, each character's frontal view first, and with more than one character `setNodeSetting` key `referenceElements`, value `{ "<sourceNodeId>": 2 }`; they never count as the start or end frame. |
109
109
  | `studio_workflow_validate` | Dry-run a document (inline or by `savedId`) with optional ops and run params: the Studio's `{ apply, document, projection, run }` verdict, no side effects, no cost. |
110
110
  | `studio_workflow_screenshot` | Render a saved workflow's document as a diagram (labelled boxes and wires, positioned by the document's own layout), the Figma `get_screenshot` equivalent for a workflow graph. Not a pixel-exact canvas preview, a diagnostic diagram for checking topology. Returns `{ url, width, height }` (a 24h signed link). Free, read-only. |
111
111
  | `studio_list_assets` | A project's assets, newest first, optionally one subtype: `Image` for slide backgrounds, `Video` for reel clips, and earlier renders. Free, read-only. |
package/dist/cli.js CHANGED
@@ -582,7 +582,10 @@ var ROUTES = [
582
582
  "720p": "fal/kling-o3-standard-image-to-video",
583
583
  "1080p": "fal/kling-o3-pro-image-to-video"
584
584
  },
585
- label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)"
585
+ label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)",
586
+ // Only the Pro tier of reference-to-video is in the catalog: a 720p job
587
+ // with references runs on KIE alone.
588
+ withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
586
589
  }
587
590
  },
588
591
  {
@@ -1172,8 +1175,15 @@ var CATALOG_ENTRIES = [
1172
1175
  modality: "video",
1173
1176
  task: "image-to-video",
1174
1177
  label: "Kling O3 (KIE)",
1175
- description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24.",
1176
- capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1178
+ description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24. Holds a character's identity through the clip from character references wired into its reference port: up to 3 characters, 2 to 4 images each (frontal view first).",
1179
+ // `characterReferences` mirrors KIE_VIDEO_SPECS['kling-3.0-omni/image-to-video']
1180
+ // (catalog.spec checks they agree).
1181
+ capabilities: {
1182
+ needsImageInput: true,
1183
+ maxInputImages: 1,
1184
+ acceptsEndFrame: true,
1185
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 }
1186
+ }
1177
1187
  },
1178
1188
  {
1179
1189
  id: "fal/grok-imagine-1-5-image-to-video",
@@ -1221,6 +1231,22 @@ var CATALOG_ENTRIES = [
1221
1231
  description: "Kuaishou Kling O3 Pro via fal, a fallback for the KIE entry. 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. Not yet tested with a minted character.",
1222
1232
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1223
1233
  },
1234
+ {
1235
+ id: "fal/kling-o3-pro-reference-to-video",
1236
+ provider: "fal",
1237
+ modality: "video",
1238
+ task: "image-to-video",
1239
+ label: "Kling O3 Pro with character references (fal)",
1240
+ description: "Kuaishou Kling O3 Pro reference-to-video via fal, the fal fallback for Kling O3 with character references. A start frame, an optional end frame and up to 3 characters wired into the reference port (2 to 4 images each, frontal view first, 7 images in all), 3 to 15 s at the Pro tier's size. Renders at a set aspect ratio (16:9, 9:16 or 1:1, 16:9 unless set), so set the ratio of the start frame. Silent unless the job sets generateAudio.",
1241
+ // `characterReferences` mirrors FAL_CHARACTER_REFERENCE_LIMITS (catalog.spec
1242
+ // checks they agree).
1243
+ capabilities: {
1244
+ needsImageInput: true,
1245
+ maxInputImages: 1,
1246
+ acceptsEndFrame: true,
1247
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1248
+ }
1249
+ },
1224
1250
  {
1225
1251
  id: "fal/ltx-2-5-fast-image-to-video",
1226
1252
  provider: "fal",
@@ -1768,12 +1794,28 @@ var KIE_VIDEO_SPECS = {
1768
1794
  defaultResolution: "720p",
1769
1795
  audioSwitch: true,
1770
1796
  defaultAudio: false,
1797
+ // KIE's "Single First Frame" and "First and Last Frames" request shapes
1798
+ // both carry `elements`: "up to 3 subjects", and "for a multi-image
1799
+ // subject, provide 2 to 4 images" (docs.kie.ai, kling-3.0-omni
1800
+ // image-to-video, read 2026-10-23). Each element needs a name the prompt
1801
+ // can mention as `@name` and a description.
1802
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 },
1803
+ maxPromptChars: 3072,
1771
1804
  build: (i) => ({
1772
1805
  prompt: i.prompt,
1773
1806
  image_urls: i.end ? [i.start, i.end] : [i.start],
1774
1807
  duration: i.seconds,
1775
1808
  resolution: i.resolution,
1776
- audio: i.audio
1809
+ audio: i.audio,
1810
+ // Named Element1, Element2, ... so one prompt convention (`@Element1`)
1811
+ // holds on KIE and on the fal twin alike.
1812
+ ...i.elements && i.elements.length > 0 ? {
1813
+ elements: i.elements.map((e, n) => ({
1814
+ name: `Element${n + 1}`,
1815
+ description: `character ${n + 1}`,
1816
+ element_input_urls: [e.frontalImageUrl, ...e.referenceImageUrls]
1817
+ }))
1818
+ } : {}
1777
1819
  })
1778
1820
  }
1779
1821
  };
@@ -1800,6 +1842,10 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
1800
1842
  var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
1801
1843
  var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
1802
1844
  var KLING_O3_I2V_ENDPOINTS = [KLING_O3_STANDARD_I2V_ENDPOINT, KLING_O3_PRO_I2V_ENDPOINT];
1845
+ var KLING_O3_PRO_R2V_ENDPOINT = "fal-ai/kling-video/o3/pro/reference-to-video";
1846
+ var FAL_CHARACTER_REFERENCE_LIMITS = {
1847
+ [KLING_O3_PRO_R2V_ENDPOINT]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1848
+ };
1803
1849
  var LTX_25_FAST_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/fast";
1804
1850
  var LTX_25_PRO_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/pro";
1805
1851
  var LTX_25_I2V_ENDPOINTS = [LTX_25_FAST_I2V_ENDPOINT, LTX_25_PRO_I2V_ENDPOINT];
@@ -1828,7 +1874,8 @@ var VIDEO_FIXED_RESOLUTION = {
1828
1874
  [KLING_26_I2V_ENDPOINT]: "1080p",
1829
1875
  // Not a resolution the caller picks: Kling O3's tier sets the size.
1830
1876
  [KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
1831
- [KLING_O3_PRO_I2V_ENDPOINT]: "fixed"
1877
+ [KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
1878
+ [KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
1832
1879
  };
1833
1880
  var VIDEO_PINNED_DEFAULT_SECONDS = {
1834
1881
  [GROK_IMAGINE_I2V_ENDPOINT]: 5,
@@ -1842,6 +1889,7 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
1842
1889
  [KLING_26_I2V_ENDPOINT]: 5,
1843
1890
  [KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
1844
1891
  [KLING_O3_PRO_I2V_ENDPOINT]: 5,
1892
+ [KLING_O3_PRO_R2V_ENDPOINT]: 5,
1845
1893
  // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
1846
1894
  // shortest clip on both tiers.
1847
1895
  [LTX_25_FAST_I2V_ENDPOINT]: 6,
@@ -1891,6 +1939,8 @@ var VIDEO_ALLOWED_VALUES = {
1891
1939
  },
1892
1940
  [KLING_26_I2V_ENDPOINT]: { durationSeconds: { values: [5, 10] } },
1893
1941
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
1942
+ // Reference-to-video renders at a set ratio (default 16:9), not the frame's.
1943
+ [KLING_O3_PRO_R2V_ENDPOINT]: { aspectRatio: ["16:9", "9:16", "1:1"], durationSeconds: { min: 3, max: 15 } },
1894
1944
  [LTX_25_FAST_I2V_ENDPOINT]: {
1895
1945
  aspectRatio: ["auto", "16:9", "9:16"],
1896
1946
  // fal also renders 1440p, which the canvas does not offer.
@@ -1949,6 +1999,8 @@ var VIDEO_UNSUPPORTED_PARAMS = {
1949
1999
  [WAN_30_I2V_ENDPOINT]: ["negativePrompt"],
1950
2000
  [KLING_26_I2V_ENDPOINT]: ["resolution", "aspectRatio", "seed"],
1951
2001
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
2002
+ // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
2003
+ [KLING_O3_PRO_R2V_ENDPOINT]: ["resolution", "seed", "negativePrompt"],
1952
2004
  ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
1953
2005
  };
1954
2006
  var ROWS = [
@@ -2661,8 +2713,10 @@ function searchMeshyAnimations(query, limit = 25) {
2661
2713
  }
2662
2714
  return out;
2663
2715
  }
2664
- var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
2665
- var INPUT_PORT_TYPES = PORT_TYPES.filter((p) => p !== "mask");
2716
+ var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2717
+ var INPUT_PORT_TYPES = PORT_TYPES.filter(
2718
+ (p) => p !== "mask" && p !== "reference"
2719
+ );
2666
2720
 
2667
2721
  // src/rig.ts
2668
2722
  var RIG_MODEL_ID = "fal/meshy-rigging";
@@ -2727,8 +2781,13 @@ var MODEL_TASKS = [
2727
2781
  "background-remove",
2728
2782
  "segmentation"
2729
2783
  ];
2730
- var PORT_TYPES2 = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
2731
- var INPUT_PORT_TYPES2 = PORT_TYPES2.filter((p) => p !== "mask");
2784
+ var PORT_TYPES2 = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2785
+ function portContent(port) {
2786
+ return port === "reference" ? "image" : port;
2787
+ }
2788
+ var INPUT_PORT_TYPES2 = PORT_TYPES2.filter(
2789
+ (p) => p !== "mask" && p !== "reference"
2790
+ );
2732
2791
  var TASK_PORTS = {
2733
2792
  // GENERATE: born from text (or a mesh prompt), no upstream asset input.
2734
2793
  "text-to-image": { inputs: ["text"], output: "image" },
@@ -2740,7 +2799,11 @@ var TASK_PORTS = {
2740
2799
  // Two image inputs (garment + person); the port type set is coarse (both are
2741
2800
  // 'image'), the two-image contract lives in the fal adapter, not the ports.
2742
2801
  "virtual-try-on": { inputs: ["image"], output: "image" },
2743
- "image-to-video": { inputs: ["image"], output: "video" },
2802
+ // The `image` port takes the start frame (and the end frame, or a keyframe
2803
+ // timeline); the `reference` port takes character reference images for the
2804
+ // models that hold identity from them (Kling elements). A model without that
2805
+ // capability gives the reference port no wires at all (`portCardinality`).
2806
+ "image-to-video": { inputs: ["image", "reference"], output: "video" },
2744
2807
  // Video-to-video (character replace): a source video plus ONE reference image
2745
2808
  // (the person to swap in). The two-input contract lives in the fal adapter.
2746
2809
  "video-to-video": { inputs: ["video", "image"], output: "video" },
@@ -3105,7 +3168,10 @@ var ROUTES2 = [
3105
3168
  "720p": "fal/kling-o3-standard-image-to-video",
3106
3169
  "1080p": "fal/kling-o3-pro-image-to-video"
3107
3170
  },
3108
- label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)"
3171
+ label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)",
3172
+ // Only the Pro tier of reference-to-video is in the catalog: a 720p job
3173
+ // with references runs on KIE alone.
3174
+ withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
3109
3175
  }
3110
3176
  },
3111
3177
  {
@@ -3695,8 +3761,15 @@ var CATALOG_ENTRIES2 = [
3695
3761
  modality: "video",
3696
3762
  task: "image-to-video",
3697
3763
  label: "Kling O3 (KIE)",
3698
- description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24.",
3699
- capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3764
+ description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24. Holds a character's identity through the clip from character references wired into its reference port: up to 3 characters, 2 to 4 images each (frontal view first).",
3765
+ // `characterReferences` mirrors KIE_VIDEO_SPECS['kling-3.0-omni/image-to-video']
3766
+ // (catalog.spec checks they agree).
3767
+ capabilities: {
3768
+ needsImageInput: true,
3769
+ maxInputImages: 1,
3770
+ acceptsEndFrame: true,
3771
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 }
3772
+ }
3700
3773
  },
3701
3774
  {
3702
3775
  id: "fal/grok-imagine-1-5-image-to-video",
@@ -3744,6 +3817,22 @@ var CATALOG_ENTRIES2 = [
3744
3817
  description: "Kuaishou Kling O3 Pro via fal, a fallback for the KIE entry. 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. Not yet tested with a minted character.",
3745
3818
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3746
3819
  },
3820
+ {
3821
+ id: "fal/kling-o3-pro-reference-to-video",
3822
+ provider: "fal",
3823
+ modality: "video",
3824
+ task: "image-to-video",
3825
+ label: "Kling O3 Pro with character references (fal)",
3826
+ description: "Kuaishou Kling O3 Pro reference-to-video via fal, the fal fallback for Kling O3 with character references. A start frame, an optional end frame and up to 3 characters wired into the reference port (2 to 4 images each, frontal view first, 7 images in all), 3 to 15 s at the Pro tier's size. Renders at a set aspect ratio (16:9, 9:16 or 1:1, 16:9 unless set), so set the ratio of the start frame. Silent unless the job sets generateAudio.",
3827
+ // `characterReferences` mirrors FAL_CHARACTER_REFERENCE_LIMITS (catalog.spec
3828
+ // checks they agree).
3829
+ capabilities: {
3830
+ needsImageInput: true,
3831
+ maxInputImages: 1,
3832
+ acceptsEndFrame: true,
3833
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
3834
+ }
3835
+ },
3747
3836
  {
3748
3837
  id: "fal/ltx-2-5-fast-image-to-video",
3749
3838
  provider: "fal",
@@ -4127,6 +4216,9 @@ function portBinding(task, port) {
4127
4216
  if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
4128
4217
  return { key: "inputImageUrl", path: "url" };
4129
4218
  }
4219
+ if (port === "reference" && task === "image-to-video") {
4220
+ return { key: "referenceImageUrls", path: "url", wrap: "array" };
4221
+ }
4130
4222
  if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
4131
4223
  return { key: "parentAssetId", path: "assetId" };
4132
4224
  }
@@ -4160,7 +4252,7 @@ function portBinding(task, port) {
4160
4252
  return null;
4161
4253
  }
4162
4254
  function canConnect(sourceOut, targetTask, targetPort) {
4163
- if (sourceOut !== targetPort) return false;
4255
+ if (sourceOut !== portContent(targetPort)) return false;
4164
4256
  return portBinding(targetTask, targetPort) !== null;
4165
4257
  }
4166
4258
  function portCardinality(task, port, model) {
@@ -4169,11 +4261,18 @@ function portCardinality(task, port, model) {
4169
4261
  if (port === "image" && task === "image-to-video") {
4170
4262
  return modelAcceptsKeyframes(model) ? "many" : "two";
4171
4263
  }
4264
+ if (port === "reference") {
4265
+ return modelCharacterReferences(model) ? "many" : "none";
4266
+ }
4172
4267
  if (port === "image" && task === "video-to-video") {
4173
4268
  return modelTakesSeveralReferences(model) ? "many" : "one";
4174
4269
  }
4175
4270
  return "one";
4176
4271
  }
4272
+ function modelCharacterReferences(model) {
4273
+ if (!model) return null;
4274
+ return tryGetModel2(model)?.capabilities?.characterReferences ?? null;
4275
+ }
4177
4276
  function modelTakesSeveralReferences(model) {
4178
4277
  if (!model) return false;
4179
4278
  const cap = tryGetModel2(model)?.capabilities?.maxInputImages;
@@ -4225,6 +4324,15 @@ function targetCardinality(node, port) {
4225
4324
  function slotRefusal(node, port, wired) {
4226
4325
  const cardinality = targetCardinality(node, port);
4227
4326
  let limit = cardinalityLimit(cardinality);
4327
+ if (port === "reference" && node.kind === "task") {
4328
+ const refs = modelCharacterReferences(node.model);
4329
+ if (refs) limit = Math.min(limit, refs.maxTotalImages);
4330
+ if (wired < limit) return null;
4331
+ if (!refs) {
4332
+ 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`;
4333
+ }
4334
+ return `node "${node.id}" (${node.model}) takes at most ${limit} character reference images in all`;
4335
+ }
4228
4336
  if (cardinality === "many" && node.kind === "task" && node.model) {
4229
4337
  const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
4230
4338
  if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
@@ -4239,7 +4347,7 @@ function slotRefusal(node, port, wired) {
4239
4347
  function wireLegality(source, target, port) {
4240
4348
  if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
4241
4349
  const produced = sourcePortOf(source);
4242
- if (produced !== port) {
4350
+ if (produced !== portContent(port)) {
4243
4351
  return { ok: false, code: "invalid_port", message: `node "${source.id}" produces ${produced}, not ${port}` };
4244
4352
  }
4245
4353
  if (target.kind !== "task") {
@@ -4248,6 +4356,13 @@ function wireLegality(source, target, port) {
4248
4356
  if (!canConnect(produced, target.task, port)) {
4249
4357
  return { ok: false, code: "invalid_port", message: `a ${port} wire into "${target.id}" (${target.task}) is not supported` };
4250
4358
  }
4359
+ if (source.kind === "input" && source.cardinality === "many" && port === "reference") {
4360
+ return {
4361
+ ok: false,
4362
+ code: "invalid_port",
4363
+ message: `list input "${source.id}" cannot feed character references; wire one image input per reference image into "${target.id}"`
4364
+ };
4365
+ }
4251
4366
  if (source.kind === "input" && source.cardinality === "many" && portBinding(target.task, port)?.wrap !== "array") {
4252
4367
  return {
4253
4368
  ok: false,
@@ -4631,6 +4746,7 @@ function taskModality(task) {
4631
4746
  return "text";
4632
4747
  case "image":
4633
4748
  case "mask":
4749
+ case "reference":
4634
4750
  return "image";
4635
4751
  }
4636
4752
  }
@@ -4716,6 +4832,60 @@ function keyframePositionsFor(sourceIds, settings) {
4716
4832
  }
4717
4833
  return { ok: true, frames };
4718
4834
  }
4835
+ var REFERENCE_ELEMENTS_SETTING = "referenceElements";
4836
+ function referenceElementsFor(sourceIds, settings, limits) {
4837
+ const raw = settings?.[REFERENCE_ELEMENTS_SETTING];
4838
+ if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
4839
+ return { ok: false, reason: `${REFERENCE_ELEMENTS_SETTING} must map a reference source to its character number` };
4840
+ }
4841
+ const explicit = raw ?? {};
4842
+ const numbers = [];
4843
+ for (const id of sourceIds) {
4844
+ const v = Object.prototype.hasOwnProperty.call(explicit, id) ? explicit[id] : 1;
4845
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 1) {
4846
+ return {
4847
+ ok: false,
4848
+ reason: `reference "${id}" is set to character ${JSON.stringify(v)}; a character number is a whole number from 1`
4849
+ };
4850
+ }
4851
+ numbers.push(v);
4852
+ }
4853
+ if (sourceIds.length > limits.maxTotalImages) {
4854
+ return {
4855
+ ok: false,
4856
+ reason: `this model takes at most ${limits.maxTotalImages} reference images in all, got ${sourceIds.length}`
4857
+ };
4858
+ }
4859
+ const distinct = [...new Set(numbers)].sort((a, b) => a - b);
4860
+ if (distinct.length > limits.maxElements) {
4861
+ return {
4862
+ ok: false,
4863
+ reason: `this model takes at most ${limits.maxElements} character${limits.maxElements === 1 ? "" : "s"} as references, got ${distinct.length}`
4864
+ };
4865
+ }
4866
+ const order = [];
4867
+ const elements = [];
4868
+ for (const [element, n] of distinct.entries()) {
4869
+ const members = numbers.flatMap((m, i) => m === n ? [i] : []);
4870
+ if (members.length > limits.maxImagesPerElement) {
4871
+ return {
4872
+ ok: false,
4873
+ reason: `character ${element + 1} has ${members.length} reference images; this model takes at most ${limits.maxImagesPerElement} per character (the first wire is the frontal view)`
4874
+ };
4875
+ }
4876
+ if (members.length < limits.minImagesPerElement) {
4877
+ return {
4878
+ ok: false,
4879
+ reason: `character ${element + 1} has ${members.length} reference image${members.length === 1 ? "" : "s"}; this model needs at least ${limits.minImagesPerElement} per character: the frontal view first, then further views such as three-quarter, back or full body`
4880
+ };
4881
+ }
4882
+ for (const i of members) {
4883
+ order.push(i);
4884
+ elements.push(element);
4885
+ }
4886
+ }
4887
+ return { ok: true, order, elements };
4888
+ }
4719
4889
  var TASK_TO_KIND = {
4720
4890
  // image
4721
4891
  "text-to-image": "generate_image",
@@ -4886,12 +5056,14 @@ function documentToDefinition(doc, opts = {}) {
4886
5056
  const b = portBinding(task, port);
4887
5057
  const cardinality = portCardinality(task, port, node.model);
4888
5058
  const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
5059
+ const references = port === "reference";
4889
5060
  const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
4890
5061
  const items = [];
5062
+ const itemSources = [];
4891
5063
  let uploading = false;
4892
5064
  for (const [ordinal, e] of portWires.entries()) {
4893
5065
  const source = byId.get(e.source);
4894
- const single = !keyframes && (cardinality !== "many" || portWires.length === 1);
5066
+ const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
4895
5067
  const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
4896
5068
  const wrap = single && b.wrap === "array";
4897
5069
  let item = null;
@@ -4926,7 +5098,38 @@ function documentToDefinition(doc, opts = {}) {
4926
5098
  }
4927
5099
  if (!item) continue;
4928
5100
  if (single) inputs[key] = item;
4929
- else items.push(item);
5101
+ else {
5102
+ items.push(item);
5103
+ itemSources.push(e.source);
5104
+ }
5105
+ }
5106
+ if (references && !uploading && items.length > 0) {
5107
+ const limits = modelCharacterReferences(node.model);
5108
+ const grouped = limits ? referenceElementsFor(
5109
+ itemSources,
5110
+ node.settings,
5111
+ limits
5112
+ ) : {
5113
+ ok: false,
5114
+ reason: `${node.model || "this model"} takes no character references`
5115
+ };
5116
+ if (grouped.ok) {
5117
+ inputs[listKey] = {
5118
+ kind: "list",
5119
+ items: grouped.order.map((i) => items[i])
5120
+ };
5121
+ inputs.referenceElementIndexes = {
5122
+ kind: "literal",
5123
+ value: grouped.elements
5124
+ };
5125
+ } else {
5126
+ issues.push({
5127
+ code: "character_references",
5128
+ nodeId: node.id,
5129
+ message: `Node "${node.id}": ${grouped.reason}`
5130
+ });
5131
+ }
5132
+ continue;
4930
5133
  }
4931
5134
  if (!uploading && items.length > 0)
4932
5135
  inputs[listKey] = { kind: "list", items };
@@ -4951,6 +5154,13 @@ function documentToDefinition(doc, opts = {}) {
4951
5154
  }
4952
5155
  for (const [key, binding] of Object.entries(node.bakedInputs))
4953
5156
  if (!(key in inputs)) inputs[key] = binding;
5157
+ if (task === "image-to-video" && "referenceImageUrls" in inputs && !("inputImageUrl" in inputs)) {
5158
+ issues.push({
5159
+ code: "character_references",
5160
+ nodeId: node.id,
5161
+ message: `Node "${node.id}": character references need a start frame; wire one into the image port.`
5162
+ });
5163
+ }
4954
5164
  if (Object.keys(inputs).length === 0 && !promptMissing) {
4955
5165
  issues.push({
4956
5166
  code: "no_inputs",
@@ -5410,7 +5620,7 @@ function affectedNodes(doc, ids) {
5410
5620
  // src/workflowTools.ts
5411
5621
  var savedId = z7.string().min(1).describe('The saved workflow id (it carries a "saved:" prefix), from studio_workflow_create or the Studio workflow list.');
5412
5622
  var opsSchema = PatchSchema.shape.ops.describe(
5413
- `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list.`
5623
+ `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5414
5624
  );
5415
5625
  var paramsSchema = z7.record(z7.string(), z7.unknown()).describe("Run parameters by input-node name, checked against the declared inputs (unknown names, missing required values and wrong shapes are issues).");
5416
5626
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -6868,7 +7078,7 @@ var studioUploadBrandReference = defineTool({
6868
7078
  }
6869
7079
  });
6870
7080
  var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
6871
- '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.'
7081
+ `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, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) 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.`
6872
7082
  );
6873
7083
  var studioRunWorkflow = defineTool({
6874
7084
  name: "studio_run_workflow",
@@ -7219,7 +7429,7 @@ function registerTools(server, base) {
7219
7429
 
7220
7430
  // src/server.ts
7221
7431
  var SERVER_NAME = "lumitra-studio";
7222
- var SERVER_VERSION = "0.8.0";
7432
+ var SERVER_VERSION = "0.9.0";
7223
7433
  function createStudioMcpServer(opts = {}) {
7224
7434
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7225
7435
  const client = new StudioClient(config, {
package/dist/index.d.ts CHANGED
@@ -199,6 +199,7 @@ declare const WorkflowDocumentSchema: z.ZodObject<{
199
199
  json: "json";
200
200
  mask: "mask";
201
201
  mesh3d: "mesh3d";
202
+ reference: "reference";
202
203
  }>;
203
204
  }, z.core.$strip>>;
204
205
  layout: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -442,6 +443,7 @@ declare const OpSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
442
443
  mask: "mask";
443
444
  mesh3d: "mesh3d";
444
445
  json: "json";
446
+ reference: "reference";
445
447
  }>;
446
448
  index: z.ZodOptional<z.ZodNumber>;
447
449
  }, z.core.$strip>, z.ZodObject<{
@@ -456,6 +458,7 @@ declare const OpSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
456
458
  mask: "mask";
457
459
  mesh3d: "mesh3d";
458
460
  json: "json";
461
+ reference: "reference";
459
462
  }>;
460
463
  }, z.core.$strip>, z.ZodObject<{
461
464
  type: z.ZodLiteral<"exposeAsInput">;
@@ -738,6 +741,7 @@ declare const PatchSchema: z.ZodObject<{
738
741
  mask: "mask";
739
742
  mesh3d: "mesh3d";
740
743
  json: "json";
744
+ reference: "reference";
741
745
  }>;
742
746
  index: z.ZodOptional<z.ZodNumber>;
743
747
  }, z.core.$strip>, z.ZodObject<{
@@ -752,6 +756,7 @@ declare const PatchSchema: z.ZodObject<{
752
756
  mask: "mask";
753
757
  mesh3d: "mesh3d";
754
758
  json: "json";
759
+ reference: "reference";
755
760
  }>;
756
761
  }, z.core.$strip>, z.ZodObject<{
757
762
  type: z.ZodLiteral<"exposeAsInput">;
@@ -859,7 +864,7 @@ interface ApplyError {
859
864
  * Pure: no database, no provider, no DOM.
860
865
  */
861
866
 
862
- type ProjectionIssueCode = "no_task_nodes" | "not_runnable" | "no_model" | "prompt_required" | "source_uploading" | "keyframe_positions" | "no_inputs" | "param_unmappable" | "param_type_conflict" | "integrity";
867
+ type ProjectionIssueCode = "no_task_nodes" | "not_runnable" | "no_model" | "prompt_required" | "source_uploading" | "keyframe_positions" | "character_references" | "no_inputs" | "param_unmappable" | "param_type_conflict" | "integrity";
863
868
  interface ProjectionIssue {
864
869
  code: ProjectionIssueCode;
865
870
  /** The node the issue is about, when it is about one. */
@@ -2038,7 +2043,7 @@ declare function registerTools(server: McpServer, base: ToolContext): void;
2038
2043
  */
2039
2044
 
2040
2045
  declare const SERVER_NAME = "lumitra-studio";
2041
- declare const SERVER_VERSION = "0.8.0";
2046
+ declare const SERVER_VERSION = "0.9.0";
2042
2047
  interface CreateServerOptions {
2043
2048
  config?: StudioConfig;
2044
2049
  env?: NodeJS.ProcessEnv;
@@ -2300,6 +2305,7 @@ declare const studioWorkflowCreate: ToolDef<{
2300
2305
  mask: "mask";
2301
2306
  mesh3d: "mesh3d";
2302
2307
  json: "json";
2308
+ reference: "reference";
2303
2309
  }>;
2304
2310
  index: z.ZodOptional<z.ZodNumber>;
2305
2311
  }, z.core.$strip>, z.ZodObject<{
@@ -2314,6 +2320,7 @@ declare const studioWorkflowCreate: ToolDef<{
2314
2320
  mask: "mask";
2315
2321
  mesh3d: "mesh3d";
2316
2322
  json: "json";
2323
+ reference: "reference";
2317
2324
  }>;
2318
2325
  }, z.core.$strip>, z.ZodObject<{
2319
2326
  type: z.ZodLiteral<"exposeAsInput">;
@@ -2598,6 +2605,7 @@ declare const studioWorkflowApply: ToolDef<{
2598
2605
  mask: "mask";
2599
2606
  mesh3d: "mesh3d";
2600
2607
  json: "json";
2608
+ reference: "reference";
2601
2609
  }>;
2602
2610
  index: z.ZodOptional<z.ZodNumber>;
2603
2611
  }, z.core.$strip>, z.ZodObject<{
@@ -2612,6 +2620,7 @@ declare const studioWorkflowApply: ToolDef<{
2612
2620
  mask: "mask";
2613
2621
  mesh3d: "mesh3d";
2614
2622
  json: "json";
2623
+ reference: "reference";
2615
2624
  }>;
2616
2625
  }, z.core.$strip>, z.ZodObject<{
2617
2626
  type: z.ZodLiteral<"exposeAsInput">;
@@ -2782,6 +2791,7 @@ declare const studioWorkflowValidate: ToolDef<{
2782
2791
  json: "json";
2783
2792
  mask: "mask";
2784
2793
  mesh3d: "mesh3d";
2794
+ reference: "reference";
2785
2795
  }>;
2786
2796
  }, z.core.$strip>>;
2787
2797
  layout: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -3025,6 +3035,7 @@ declare const studioWorkflowValidate: ToolDef<{
3025
3035
  mask: "mask";
3026
3036
  mesh3d: "mesh3d";
3027
3037
  json: "json";
3038
+ reference: "reference";
3028
3039
  }>;
3029
3040
  index: z.ZodOptional<z.ZodNumber>;
3030
3041
  }, z.core.$strip>, z.ZodObject<{
@@ -3039,6 +3050,7 @@ declare const studioWorkflowValidate: ToolDef<{
3039
3050
  mask: "mask";
3040
3051
  mesh3d: "mesh3d";
3041
3052
  json: "json";
3053
+ reference: "reference";
3042
3054
  }>;
3043
3055
  }, z.core.$strip>, z.ZodObject<{
3044
3056
  type: z.ZodLiteral<"exposeAsInput">;
package/dist/index.js CHANGED
@@ -574,7 +574,10 @@ var ROUTES = [
574
574
  "720p": "fal/kling-o3-standard-image-to-video",
575
575
  "1080p": "fal/kling-o3-pro-image-to-video"
576
576
  },
577
- label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)"
577
+ label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)",
578
+ // Only the Pro tier of reference-to-video is in the catalog: a 720p job
579
+ // with references runs on KIE alone.
580
+ withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
578
581
  }
579
582
  },
580
583
  {
@@ -1164,8 +1167,15 @@ var CATALOG_ENTRIES = [
1164
1167
  modality: "video",
1165
1168
  task: "image-to-video",
1166
1169
  label: "Kling O3 (KIE)",
1167
- description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24.",
1168
- capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1170
+ description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24. Holds a character's identity through the clip from character references wired into its reference port: up to 3 characters, 2 to 4 images each (frontal view first).",
1171
+ // `characterReferences` mirrors KIE_VIDEO_SPECS['kling-3.0-omni/image-to-video']
1172
+ // (catalog.spec checks they agree).
1173
+ capabilities: {
1174
+ needsImageInput: true,
1175
+ maxInputImages: 1,
1176
+ acceptsEndFrame: true,
1177
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 }
1178
+ }
1169
1179
  },
1170
1180
  {
1171
1181
  id: "fal/grok-imagine-1-5-image-to-video",
@@ -1213,6 +1223,22 @@ var CATALOG_ENTRIES = [
1213
1223
  description: "Kuaishou Kling O3 Pro via fal, a fallback for the KIE entry. 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. Not yet tested with a minted character.",
1214
1224
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
1215
1225
  },
1226
+ {
1227
+ id: "fal/kling-o3-pro-reference-to-video",
1228
+ provider: "fal",
1229
+ modality: "video",
1230
+ task: "image-to-video",
1231
+ label: "Kling O3 Pro with character references (fal)",
1232
+ description: "Kuaishou Kling O3 Pro reference-to-video via fal, the fal fallback for Kling O3 with character references. A start frame, an optional end frame and up to 3 characters wired into the reference port (2 to 4 images each, frontal view first, 7 images in all), 3 to 15 s at the Pro tier's size. Renders at a set aspect ratio (16:9, 9:16 or 1:1, 16:9 unless set), so set the ratio of the start frame. Silent unless the job sets generateAudio.",
1233
+ // `characterReferences` mirrors FAL_CHARACTER_REFERENCE_LIMITS (catalog.spec
1234
+ // checks they agree).
1235
+ capabilities: {
1236
+ needsImageInput: true,
1237
+ maxInputImages: 1,
1238
+ acceptsEndFrame: true,
1239
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1240
+ }
1241
+ },
1216
1242
  {
1217
1243
  id: "fal/ltx-2-5-fast-image-to-video",
1218
1244
  provider: "fal",
@@ -1760,12 +1786,28 @@ var KIE_VIDEO_SPECS = {
1760
1786
  defaultResolution: "720p",
1761
1787
  audioSwitch: true,
1762
1788
  defaultAudio: false,
1789
+ // KIE's "Single First Frame" and "First and Last Frames" request shapes
1790
+ // both carry `elements`: "up to 3 subjects", and "for a multi-image
1791
+ // subject, provide 2 to 4 images" (docs.kie.ai, kling-3.0-omni
1792
+ // image-to-video, read 2026-10-23). Each element needs a name the prompt
1793
+ // can mention as `@name` and a description.
1794
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 },
1795
+ maxPromptChars: 3072,
1763
1796
  build: (i) => ({
1764
1797
  prompt: i.prompt,
1765
1798
  image_urls: i.end ? [i.start, i.end] : [i.start],
1766
1799
  duration: i.seconds,
1767
1800
  resolution: i.resolution,
1768
- audio: i.audio
1801
+ audio: i.audio,
1802
+ // Named Element1, Element2, ... so one prompt convention (`@Element1`)
1803
+ // holds on KIE and on the fal twin alike.
1804
+ ...i.elements && i.elements.length > 0 ? {
1805
+ elements: i.elements.map((e, n) => ({
1806
+ name: `Element${n + 1}`,
1807
+ description: `character ${n + 1}`,
1808
+ element_input_urls: [e.frontalImageUrl, ...e.referenceImageUrls]
1809
+ }))
1810
+ } : {}
1769
1811
  })
1770
1812
  }
1771
1813
  };
@@ -1792,6 +1834,10 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
1792
1834
  var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
1793
1835
  var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
1794
1836
  var KLING_O3_I2V_ENDPOINTS = [KLING_O3_STANDARD_I2V_ENDPOINT, KLING_O3_PRO_I2V_ENDPOINT];
1837
+ var KLING_O3_PRO_R2V_ENDPOINT = "fal-ai/kling-video/o3/pro/reference-to-video";
1838
+ var FAL_CHARACTER_REFERENCE_LIMITS = {
1839
+ [KLING_O3_PRO_R2V_ENDPOINT]: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
1840
+ };
1795
1841
  var LTX_25_FAST_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/fast";
1796
1842
  var LTX_25_PRO_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/pro";
1797
1843
  var LTX_25_I2V_ENDPOINTS = [LTX_25_FAST_I2V_ENDPOINT, LTX_25_PRO_I2V_ENDPOINT];
@@ -1820,7 +1866,8 @@ var VIDEO_FIXED_RESOLUTION = {
1820
1866
  [KLING_26_I2V_ENDPOINT]: "1080p",
1821
1867
  // Not a resolution the caller picks: Kling O3's tier sets the size.
1822
1868
  [KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
1823
- [KLING_O3_PRO_I2V_ENDPOINT]: "fixed"
1869
+ [KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
1870
+ [KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
1824
1871
  };
1825
1872
  var VIDEO_PINNED_DEFAULT_SECONDS = {
1826
1873
  [GROK_IMAGINE_I2V_ENDPOINT]: 5,
@@ -1834,6 +1881,7 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
1834
1881
  [KLING_26_I2V_ENDPOINT]: 5,
1835
1882
  [KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
1836
1883
  [KLING_O3_PRO_I2V_ENDPOINT]: 5,
1884
+ [KLING_O3_PRO_R2V_ENDPOINT]: 5,
1837
1885
  // LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
1838
1886
  // shortest clip on both tiers.
1839
1887
  [LTX_25_FAST_I2V_ENDPOINT]: 6,
@@ -1883,6 +1931,8 @@ var VIDEO_ALLOWED_VALUES = {
1883
1931
  },
1884
1932
  [KLING_26_I2V_ENDPOINT]: { durationSeconds: { values: [5, 10] } },
1885
1933
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, { durationSeconds: { min: 3, max: 15 } }])),
1934
+ // Reference-to-video renders at a set ratio (default 16:9), not the frame's.
1935
+ [KLING_O3_PRO_R2V_ENDPOINT]: { aspectRatio: ["16:9", "9:16", "1:1"], durationSeconds: { min: 3, max: 15 } },
1886
1936
  [LTX_25_FAST_I2V_ENDPOINT]: {
1887
1937
  aspectRatio: ["auto", "16:9", "9:16"],
1888
1938
  // fal also renders 1440p, which the canvas does not offer.
@@ -1941,6 +1991,8 @@ var VIDEO_UNSUPPORTED_PARAMS = {
1941
1991
  [WAN_30_I2V_ENDPOINT]: ["negativePrompt"],
1942
1992
  [KLING_26_I2V_ENDPOINT]: ["resolution", "aspectRatio", "seed"],
1943
1993
  ...Object.fromEntries(KLING_O3_I2V_ENDPOINTS.map((e) => [e, ["resolution", "aspectRatio", "seed", "negativePrompt"]])),
1994
+ // Its tier sets the size; it takes an aspect ratio, but no seed or negative prompt.
1995
+ [KLING_O3_PRO_R2V_ENDPOINT]: ["resolution", "seed", "negativePrompt"],
1944
1996
  ...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
1945
1997
  };
1946
1998
  var ROWS = [
@@ -2653,8 +2705,10 @@ function searchMeshyAnimations(query, limit = 25) {
2653
2705
  }
2654
2706
  return out;
2655
2707
  }
2656
- var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
2657
- var INPUT_PORT_TYPES = PORT_TYPES.filter((p) => p !== "mask");
2708
+ var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2709
+ var INPUT_PORT_TYPES = PORT_TYPES.filter(
2710
+ (p) => p !== "mask" && p !== "reference"
2711
+ );
2658
2712
 
2659
2713
  // src/rig.ts
2660
2714
  var RIG_MODEL_ID = "fal/meshy-rigging";
@@ -2719,8 +2773,13 @@ var MODEL_TASKS = [
2719
2773
  "background-remove",
2720
2774
  "segmentation"
2721
2775
  ];
2722
- var PORT_TYPES2 = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
2723
- var INPUT_PORT_TYPES2 = PORT_TYPES2.filter((p) => p !== "mask");
2776
+ var PORT_TYPES2 = ["text", "image", "video", "mask", "mesh3d", "audio", "json", "reference"];
2777
+ function portContent(port) {
2778
+ return port === "reference" ? "image" : port;
2779
+ }
2780
+ var INPUT_PORT_TYPES2 = PORT_TYPES2.filter(
2781
+ (p) => p !== "mask" && p !== "reference"
2782
+ );
2724
2783
  var TASK_PORTS = {
2725
2784
  // GENERATE: born from text (or a mesh prompt), no upstream asset input.
2726
2785
  "text-to-image": { inputs: ["text"], output: "image" },
@@ -2732,7 +2791,11 @@ var TASK_PORTS = {
2732
2791
  // Two image inputs (garment + person); the port type set is coarse (both are
2733
2792
  // 'image'), the two-image contract lives in the fal adapter, not the ports.
2734
2793
  "virtual-try-on": { inputs: ["image"], output: "image" },
2735
- "image-to-video": { inputs: ["image"], output: "video" },
2794
+ // The `image` port takes the start frame (and the end frame, or a keyframe
2795
+ // timeline); the `reference` port takes character reference images for the
2796
+ // models that hold identity from them (Kling elements). A model without that
2797
+ // capability gives the reference port no wires at all (`portCardinality`).
2798
+ "image-to-video": { inputs: ["image", "reference"], output: "video" },
2736
2799
  // Video-to-video (character replace): a source video plus ONE reference image
2737
2800
  // (the person to swap in). The two-input contract lives in the fal adapter.
2738
2801
  "video-to-video": { inputs: ["video", "image"], output: "video" },
@@ -3097,7 +3160,10 @@ var ROUTES2 = [
3097
3160
  "720p": "fal/kling-o3-standard-image-to-video",
3098
3161
  "1080p": "fal/kling-o3-pro-image-to-video"
3099
3162
  },
3100
- label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)"
3163
+ label: "fal renders Kling O3 at 720p (Standard) or 1080p (Pro)",
3164
+ // Only the Pro tier of reference-to-video is in the catalog: a 720p job
3165
+ // with references runs on KIE alone.
3166
+ withReferences: { "1080p": "fal/kling-o3-pro-reference-to-video" }
3101
3167
  }
3102
3168
  },
3103
3169
  {
@@ -3687,8 +3753,15 @@ var CATALOG_ENTRIES2 = [
3687
3753
  modality: "video",
3688
3754
  task: "image-to-video",
3689
3755
  label: "Kling O3 (KIE)",
3690
- description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24.",
3691
- capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3756
+ description: "Kuaishou Kling O3 (KIE calls it Kling 3.0 Omni) via KIE. A start frame and an optional end frame, 3 to 15 s, 720p to 4K in the start frame's shape, silent unless the job sets generateAudio. Accepted a minted character's photoreal stills on 2026-09-24. Holds a character's identity through the clip from character references wired into its reference port: up to 3 characters, 2 to 4 images each (frontal view first).",
3757
+ // `characterReferences` mirrors KIE_VIDEO_SPECS['kling-3.0-omni/image-to-video']
3758
+ // (catalog.spec checks they agree).
3759
+ capabilities: {
3760
+ needsImageInput: true,
3761
+ maxInputImages: 1,
3762
+ acceptsEndFrame: true,
3763
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 12 }
3764
+ }
3692
3765
  },
3693
3766
  {
3694
3767
  id: "fal/grok-imagine-1-5-image-to-video",
@@ -3736,6 +3809,22 @@ var CATALOG_ENTRIES2 = [
3736
3809
  description: "Kuaishou Kling O3 Pro via fal, a fallback for the KIE entry. 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. Not yet tested with a minted character.",
3737
3810
  capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
3738
3811
  },
3812
+ {
3813
+ id: "fal/kling-o3-pro-reference-to-video",
3814
+ provider: "fal",
3815
+ modality: "video",
3816
+ task: "image-to-video",
3817
+ label: "Kling O3 Pro with character references (fal)",
3818
+ description: "Kuaishou Kling O3 Pro reference-to-video via fal, the fal fallback for Kling O3 with character references. A start frame, an optional end frame and up to 3 characters wired into the reference port (2 to 4 images each, frontal view first, 7 images in all), 3 to 15 s at the Pro tier's size. Renders at a set aspect ratio (16:9, 9:16 or 1:1, 16:9 unless set), so set the ratio of the start frame. Silent unless the job sets generateAudio.",
3819
+ // `characterReferences` mirrors FAL_CHARACTER_REFERENCE_LIMITS (catalog.spec
3820
+ // checks they agree).
3821
+ capabilities: {
3822
+ needsImageInput: true,
3823
+ maxInputImages: 1,
3824
+ acceptsEndFrame: true,
3825
+ characterReferences: { maxElements: 3, minImagesPerElement: 2, maxImagesPerElement: 4, maxTotalImages: 7 }
3826
+ }
3827
+ },
3739
3828
  {
3740
3829
  id: "fal/ltx-2-5-fast-image-to-video",
3741
3830
  provider: "fal",
@@ -4119,6 +4208,9 @@ function portBinding(task, port) {
4119
4208
  if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
4120
4209
  return { key: "inputImageUrl", path: "url" };
4121
4210
  }
4211
+ if (port === "reference" && task === "image-to-video") {
4212
+ return { key: "referenceImageUrls", path: "url", wrap: "array" };
4213
+ }
4122
4214
  if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
4123
4215
  return { key: "parentAssetId", path: "assetId" };
4124
4216
  }
@@ -4152,7 +4244,7 @@ function portBinding(task, port) {
4152
4244
  return null;
4153
4245
  }
4154
4246
  function canConnect(sourceOut, targetTask, targetPort) {
4155
- if (sourceOut !== targetPort) return false;
4247
+ if (sourceOut !== portContent(targetPort)) return false;
4156
4248
  return portBinding(targetTask, targetPort) !== null;
4157
4249
  }
4158
4250
  function portCardinality(task, port, model) {
@@ -4161,11 +4253,18 @@ function portCardinality(task, port, model) {
4161
4253
  if (port === "image" && task === "image-to-video") {
4162
4254
  return modelAcceptsKeyframes(model) ? "many" : "two";
4163
4255
  }
4256
+ if (port === "reference") {
4257
+ return modelCharacterReferences(model) ? "many" : "none";
4258
+ }
4164
4259
  if (port === "image" && task === "video-to-video") {
4165
4260
  return modelTakesSeveralReferences(model) ? "many" : "one";
4166
4261
  }
4167
4262
  return "one";
4168
4263
  }
4264
+ function modelCharacterReferences(model) {
4265
+ if (!model) return null;
4266
+ return tryGetModel2(model)?.capabilities?.characterReferences ?? null;
4267
+ }
4169
4268
  function modelTakesSeveralReferences(model) {
4170
4269
  if (!model) return false;
4171
4270
  const cap = tryGetModel2(model)?.capabilities?.maxInputImages;
@@ -4217,6 +4316,15 @@ function targetCardinality(node, port) {
4217
4316
  function slotRefusal(node, port, wired) {
4218
4317
  const cardinality = targetCardinality(node, port);
4219
4318
  let limit = cardinalityLimit(cardinality);
4319
+ if (port === "reference" && node.kind === "task") {
4320
+ const refs = modelCharacterReferences(node.model);
4321
+ if (refs) limit = Math.min(limit, refs.maxTotalImages);
4322
+ if (wired < limit) return null;
4323
+ if (!refs) {
4324
+ 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`;
4325
+ }
4326
+ return `node "${node.id}" (${node.model}) takes at most ${limit} character reference images in all`;
4327
+ }
4220
4328
  if (cardinality === "many" && node.kind === "task" && node.model) {
4221
4329
  const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
4222
4330
  if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
@@ -4231,7 +4339,7 @@ function slotRefusal(node, port, wired) {
4231
4339
  function wireLegality(source, target, port) {
4232
4340
  if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
4233
4341
  const produced = sourcePortOf(source);
4234
- if (produced !== port) {
4342
+ if (produced !== portContent(port)) {
4235
4343
  return { ok: false, code: "invalid_port", message: `node "${source.id}" produces ${produced}, not ${port}` };
4236
4344
  }
4237
4345
  if (target.kind !== "task") {
@@ -4240,6 +4348,13 @@ function wireLegality(source, target, port) {
4240
4348
  if (!canConnect(produced, target.task, port)) {
4241
4349
  return { ok: false, code: "invalid_port", message: `a ${port} wire into "${target.id}" (${target.task}) is not supported` };
4242
4350
  }
4351
+ if (source.kind === "input" && source.cardinality === "many" && port === "reference") {
4352
+ return {
4353
+ ok: false,
4354
+ code: "invalid_port",
4355
+ message: `list input "${source.id}" cannot feed character references; wire one image input per reference image into "${target.id}"`
4356
+ };
4357
+ }
4243
4358
  if (source.kind === "input" && source.cardinality === "many" && portBinding(target.task, port)?.wrap !== "array") {
4244
4359
  return {
4245
4360
  ok: false,
@@ -4623,6 +4738,7 @@ function taskModality(task) {
4623
4738
  return "text";
4624
4739
  case "image":
4625
4740
  case "mask":
4741
+ case "reference":
4626
4742
  return "image";
4627
4743
  }
4628
4744
  }
@@ -4708,6 +4824,60 @@ function keyframePositionsFor(sourceIds, settings) {
4708
4824
  }
4709
4825
  return { ok: true, frames };
4710
4826
  }
4827
+ var REFERENCE_ELEMENTS_SETTING = "referenceElements";
4828
+ function referenceElementsFor(sourceIds, settings, limits) {
4829
+ const raw = settings?.[REFERENCE_ELEMENTS_SETTING];
4830
+ if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) {
4831
+ return { ok: false, reason: `${REFERENCE_ELEMENTS_SETTING} must map a reference source to its character number` };
4832
+ }
4833
+ const explicit = raw ?? {};
4834
+ const numbers = [];
4835
+ for (const id of sourceIds) {
4836
+ const v = Object.prototype.hasOwnProperty.call(explicit, id) ? explicit[id] : 1;
4837
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 1) {
4838
+ return {
4839
+ ok: false,
4840
+ reason: `reference "${id}" is set to character ${JSON.stringify(v)}; a character number is a whole number from 1`
4841
+ };
4842
+ }
4843
+ numbers.push(v);
4844
+ }
4845
+ if (sourceIds.length > limits.maxTotalImages) {
4846
+ return {
4847
+ ok: false,
4848
+ reason: `this model takes at most ${limits.maxTotalImages} reference images in all, got ${sourceIds.length}`
4849
+ };
4850
+ }
4851
+ const distinct = [...new Set(numbers)].sort((a, b) => a - b);
4852
+ if (distinct.length > limits.maxElements) {
4853
+ return {
4854
+ ok: false,
4855
+ reason: `this model takes at most ${limits.maxElements} character${limits.maxElements === 1 ? "" : "s"} as references, got ${distinct.length}`
4856
+ };
4857
+ }
4858
+ const order = [];
4859
+ const elements = [];
4860
+ for (const [element, n] of distinct.entries()) {
4861
+ const members = numbers.flatMap((m, i) => m === n ? [i] : []);
4862
+ if (members.length > limits.maxImagesPerElement) {
4863
+ return {
4864
+ ok: false,
4865
+ reason: `character ${element + 1} has ${members.length} reference images; this model takes at most ${limits.maxImagesPerElement} per character (the first wire is the frontal view)`
4866
+ };
4867
+ }
4868
+ if (members.length < limits.minImagesPerElement) {
4869
+ return {
4870
+ ok: false,
4871
+ reason: `character ${element + 1} has ${members.length} reference image${members.length === 1 ? "" : "s"}; this model needs at least ${limits.minImagesPerElement} per character: the frontal view first, then further views such as three-quarter, back or full body`
4872
+ };
4873
+ }
4874
+ for (const i of members) {
4875
+ order.push(i);
4876
+ elements.push(element);
4877
+ }
4878
+ }
4879
+ return { ok: true, order, elements };
4880
+ }
4711
4881
  var TASK_TO_KIND = {
4712
4882
  // image
4713
4883
  "text-to-image": "generate_image",
@@ -4878,12 +5048,14 @@ function documentToDefinition(doc, opts = {}) {
4878
5048
  const b = portBinding(task, port);
4879
5049
  const cardinality = portCardinality(task, port, node.model);
4880
5050
  const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
5051
+ const references = port === "reference";
4881
5052
  const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
4882
5053
  const items = [];
5054
+ const itemSources = [];
4883
5055
  let uploading = false;
4884
5056
  for (const [ordinal, e] of portWires.entries()) {
4885
5057
  const source = byId.get(e.source);
4886
- const single = !keyframes && (cardinality !== "many" || portWires.length === 1);
5058
+ const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
4887
5059
  const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
4888
5060
  const wrap = single && b.wrap === "array";
4889
5061
  let item = null;
@@ -4918,7 +5090,38 @@ function documentToDefinition(doc, opts = {}) {
4918
5090
  }
4919
5091
  if (!item) continue;
4920
5092
  if (single) inputs[key] = item;
4921
- else items.push(item);
5093
+ else {
5094
+ items.push(item);
5095
+ itemSources.push(e.source);
5096
+ }
5097
+ }
5098
+ if (references && !uploading && items.length > 0) {
5099
+ const limits = modelCharacterReferences(node.model);
5100
+ const grouped = limits ? referenceElementsFor(
5101
+ itemSources,
5102
+ node.settings,
5103
+ limits
5104
+ ) : {
5105
+ ok: false,
5106
+ reason: `${node.model || "this model"} takes no character references`
5107
+ };
5108
+ if (grouped.ok) {
5109
+ inputs[listKey] = {
5110
+ kind: "list",
5111
+ items: grouped.order.map((i) => items[i])
5112
+ };
5113
+ inputs.referenceElementIndexes = {
5114
+ kind: "literal",
5115
+ value: grouped.elements
5116
+ };
5117
+ } else {
5118
+ issues.push({
5119
+ code: "character_references",
5120
+ nodeId: node.id,
5121
+ message: `Node "${node.id}": ${grouped.reason}`
5122
+ });
5123
+ }
5124
+ continue;
4922
5125
  }
4923
5126
  if (!uploading && items.length > 0)
4924
5127
  inputs[listKey] = { kind: "list", items };
@@ -4943,6 +5146,13 @@ function documentToDefinition(doc, opts = {}) {
4943
5146
  }
4944
5147
  for (const [key, binding] of Object.entries(node.bakedInputs))
4945
5148
  if (!(key in inputs)) inputs[key] = binding;
5149
+ if (task === "image-to-video" && "referenceImageUrls" in inputs && !("inputImageUrl" in inputs)) {
5150
+ issues.push({
5151
+ code: "character_references",
5152
+ nodeId: node.id,
5153
+ message: `Node "${node.id}": character references need a start frame; wire one into the image port.`
5154
+ });
5155
+ }
4946
5156
  if (Object.keys(inputs).length === 0 && !promptMissing) {
4947
5157
  issues.push({
4948
5158
  code: "no_inputs",
@@ -5405,7 +5615,7 @@ function affectedNodes(doc, ids) {
5405
5615
  // src/workflowTools.ts
5406
5616
  var savedId = z7.string().min(1).describe('The saved workflow id (it carries a "saved:" prefix), from studio_workflow_create or the Studio workflow list.');
5407
5617
  var opsSchema = PatchSchema.shape.ops.describe(
5408
- `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list.`
5618
+ `The ops to apply in order, 1 to ${MAX_PATCH_OPS}: addNode, removeNode, setNodeProps, setNodeSetting, setBakedInput, connect, disconnect, exposeAsInput, freezeInput, setActiveGeneration, setLayout, group, ungroup, setGroupProps, setDocumentProps. Node ids are yours to choose (UUIDv7 recommended); a later op may reference an id added earlier in the same list. Character references on an image-to-video node: connect each image (an image-source, an image input or an image-producing node) with port "reference", in order, each character's frontal view first; they never count as the start or end frame (those are the "image" port). Only a model whose studio_workflow_describe entry carries characterReferences takes them (Kling O3). With more than one character, set which one each image shows with setNodeSetting key "referenceElements", value { "<sourceNodeId>": 2 } (an unnamed source is character 1).`
5409
5619
  );
5410
5620
  var paramsSchema = z7.record(z7.string(), z7.unknown()).describe("Run parameters by input-node name, checked against the declared inputs (unknown names, missing required values and wrong shapes are issues).");
5411
5621
  var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
@@ -6863,7 +7073,7 @@ var studioUploadBrandReference = defineTool({
6863
7073
  }
6864
7074
  });
6865
7075
  var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
6866
- '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.'
7076
+ `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, kie/kling-o3-image-to-video, fal/kling-o3-pro-reference-to-video) 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.`
6867
7077
  );
6868
7078
  var studioRunWorkflow = defineTool({
6869
7079
  name: "studio_run_workflow",
@@ -7214,7 +7424,7 @@ function registerTools(server, base) {
7214
7424
 
7215
7425
  // src/server.ts
7216
7426
  var SERVER_NAME = "lumitra-studio";
7217
- var SERVER_VERSION = "0.8.0";
7427
+ var SERVER_VERSION = "0.9.0";
7218
7428
  function createStudioMcpServer(opts = {}) {
7219
7429
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
7220
7430
  const client = new StudioClient(config, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marlinjai/studio-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "Model Context Protocol (MCP) server over the Lumitra Studio HTTP API: generate images, mint characters, run workflows, swap characters into video.",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "engines": {
51
- "node": ">=20"
51
+ "node": ">=22"
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsup",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "devDependencies": {
65
65
  "@marlinjai/studio-core": "workspace:*",
66
- "@types/node": "^20",
66
+ "@types/node": "^22",
67
67
  "tsup": "^8.5.0",
68
68
  "typescript": "^5",
69
69
  "vitest": "^4.1.5"