@marlinjai/studio-mcp 0.7.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 +10 -2
- package/dist/cli.js +930 -142
- package/dist/index.d.ts +397 -3
- package/dist/index.js +930 -142
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { createServer as createHttpServer } from "http";
|
|
5
|
-
import { randomUUID as
|
|
5
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
7
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
8
8
|
|
|
@@ -310,6 +310,45 @@ var StudioClient = class {
|
|
|
310
310
|
applyWorkflowPatch(savedId2, patch) {
|
|
311
311
|
return this.json("PATCH", `/api/v1/workflows/${encodeURIComponent(savedId2)}`, { json: patch });
|
|
312
312
|
}
|
|
313
|
+
// ── Brand kit and compositions (carousels and reels) ──
|
|
314
|
+
/** A brand's kit: colours, the two type sizes, fonts by role, logos by variant, version. */
|
|
315
|
+
getBrandKit(brandSlug) {
|
|
316
|
+
return this.json("GET", `/api/brands/${encodeURIComponent(brandSlug)}/kit`);
|
|
317
|
+
}
|
|
318
|
+
listCompositions(opts = {}) {
|
|
319
|
+
return this.json("GET", `/api/v1/compositions${projectQuery(opts.projectId)}`);
|
|
320
|
+
}
|
|
321
|
+
/** 201 created; 200 with `replayed: true` when a create with this idempotencyKey already made it. */
|
|
322
|
+
createComposition(body) {
|
|
323
|
+
return this.json("POST", "/api/v1/compositions", { json: body });
|
|
324
|
+
}
|
|
325
|
+
/** A project's assets, newest first, optionally of one subtype (Image, Video, CarouselSlide, Reel, ...). */
|
|
326
|
+
listProjectAssets(projectId, opts = {}) {
|
|
327
|
+
const q = new URLSearchParams();
|
|
328
|
+
if (opts.subtype) q.set("subtype", opts.subtype);
|
|
329
|
+
if (opts.limit) q.set("limit", String(opts.limit));
|
|
330
|
+
const qs = q.toString();
|
|
331
|
+
return this.json("GET", `/api/v1/projects/${encodeURIComponent(projectId)}/assets${qs ? `?${qs}` : ""}`);
|
|
332
|
+
}
|
|
333
|
+
getComposition(compositionId2) {
|
|
334
|
+
return this.json("GET", `/api/v1/compositions/${encodeURIComponent(compositionId2)}`);
|
|
335
|
+
}
|
|
336
|
+
/** 409 stale_revision (with the current composition) or idempotency_mismatch; 422 invalid_patch. */
|
|
337
|
+
patchComposition(compositionId2, patch) {
|
|
338
|
+
return this.json("PATCH", `/api/v1/compositions/${encodeURIComponent(compositionId2)}`, { json: patch });
|
|
339
|
+
}
|
|
340
|
+
/** The company's Lumitra Social projects (409 not_connected / link_broken until an owner connects it in Studio). */
|
|
341
|
+
listSocialProjects(brandSlug) {
|
|
342
|
+
return this.json("GET", `/api/v1/social/projects${brandSlug ? `?brandSlug=${encodeURIComponent(brandSlug)}` : ""}`);
|
|
343
|
+
}
|
|
344
|
+
/** Send the rendered post to Lumitra Social; idempotent on `idempotencyKey`. */
|
|
345
|
+
sendCompositionToSocial(compositionId2, body) {
|
|
346
|
+
return this.json("POST", `/api/v1/compositions/${encodeURIComponent(compositionId2)}/send`, { json: body });
|
|
347
|
+
}
|
|
348
|
+
/** Start (or join) a render. 422 not_ready with `reasons`; 429 render_limit or render_busy (a reel of this company is rendering). */
|
|
349
|
+
renderComposition(compositionId2) {
|
|
350
|
+
return this.json("POST", `/api/v1/compositions/${encodeURIComponent(compositionId2)}/render`);
|
|
351
|
+
}
|
|
313
352
|
/** Stateless dry-run of ops and run params against a document. No side effects. */
|
|
314
353
|
validateWorkflow(body) {
|
|
315
354
|
return this.json("POST", "/api/v1/workflows/validate", { json: body });
|
|
@@ -472,7 +511,7 @@ function projectQuery(projectId) {
|
|
|
472
511
|
}
|
|
473
512
|
|
|
474
513
|
// src/tools.ts
|
|
475
|
-
import { z as
|
|
514
|
+
import { z as z11 } from "zod";
|
|
476
515
|
|
|
477
516
|
// ../lumitra-core/dist/models/index.js
|
|
478
517
|
var veo = (tier, label) => {
|
|
@@ -543,7 +582,10 @@ var ROUTES = [
|
|
|
543
582
|
"720p": "fal/kling-o3-standard-image-to-video",
|
|
544
583
|
"1080p": "fal/kling-o3-pro-image-to-video"
|
|
545
584
|
},
|
|
546
|
-
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" }
|
|
547
589
|
}
|
|
548
590
|
},
|
|
549
591
|
{
|
|
@@ -1133,8 +1175,15 @@ var CATALOG_ENTRIES = [
|
|
|
1133
1175
|
modality: "video",
|
|
1134
1176
|
task: "image-to-video",
|
|
1135
1177
|
label: "Kling O3 (KIE)",
|
|
1136
|
-
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.",
|
|
1137
|
-
|
|
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
|
+
}
|
|
1138
1187
|
},
|
|
1139
1188
|
{
|
|
1140
1189
|
id: "fal/grok-imagine-1-5-image-to-video",
|
|
@@ -1182,6 +1231,22 @@ var CATALOG_ENTRIES = [
|
|
|
1182
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.",
|
|
1183
1232
|
capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
|
|
1184
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
|
+
},
|
|
1185
1250
|
{
|
|
1186
1251
|
id: "fal/ltx-2-5-fast-image-to-video",
|
|
1187
1252
|
provider: "fal",
|
|
@@ -1729,12 +1794,28 @@ var KIE_VIDEO_SPECS = {
|
|
|
1729
1794
|
defaultResolution: "720p",
|
|
1730
1795
|
audioSwitch: true,
|
|
1731
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,
|
|
1732
1804
|
build: (i) => ({
|
|
1733
1805
|
prompt: i.prompt,
|
|
1734
1806
|
image_urls: i.end ? [i.start, i.end] : [i.start],
|
|
1735
1807
|
duration: i.seconds,
|
|
1736
1808
|
resolution: i.resolution,
|
|
1737
|
-
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
|
+
} : {}
|
|
1738
1819
|
})
|
|
1739
1820
|
}
|
|
1740
1821
|
};
|
|
@@ -1761,6 +1842,10 @@ var KLING_26_I2V_ENDPOINT = "fal-ai/kling-video/v2.6/pro/image-to-video";
|
|
|
1761
1842
|
var KLING_O3_STANDARD_I2V_ENDPOINT = "fal-ai/kling-video/o3/standard/image-to-video";
|
|
1762
1843
|
var KLING_O3_PRO_I2V_ENDPOINT = "fal-ai/kling-video/o3/pro/image-to-video";
|
|
1763
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
|
+
};
|
|
1764
1849
|
var LTX_25_FAST_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/fast";
|
|
1765
1850
|
var LTX_25_PRO_I2V_ENDPOINT = "lightricks/ltx-2.5/image-to-video/pro";
|
|
1766
1851
|
var LTX_25_I2V_ENDPOINTS = [LTX_25_FAST_I2V_ENDPOINT, LTX_25_PRO_I2V_ENDPOINT];
|
|
@@ -1789,7 +1874,8 @@ var VIDEO_FIXED_RESOLUTION = {
|
|
|
1789
1874
|
[KLING_26_I2V_ENDPOINT]: "1080p",
|
|
1790
1875
|
// Not a resolution the caller picks: Kling O3's tier sets the size.
|
|
1791
1876
|
[KLING_O3_STANDARD_I2V_ENDPOINT]: "fixed",
|
|
1792
|
-
[KLING_O3_PRO_I2V_ENDPOINT]: "fixed"
|
|
1877
|
+
[KLING_O3_PRO_I2V_ENDPOINT]: "fixed",
|
|
1878
|
+
[KLING_O3_PRO_R2V_ENDPOINT]: "fixed"
|
|
1793
1879
|
};
|
|
1794
1880
|
var VIDEO_PINNED_DEFAULT_SECONDS = {
|
|
1795
1881
|
[GROK_IMAGINE_I2V_ENDPOINT]: 5,
|
|
@@ -1803,6 +1889,7 @@ var VIDEO_PINNED_DEFAULT_SECONDS = {
|
|
|
1803
1889
|
[KLING_26_I2V_ENDPOINT]: 5,
|
|
1804
1890
|
[KLING_O3_STANDARD_I2V_ENDPOINT]: 5,
|
|
1805
1891
|
[KLING_O3_PRO_I2V_ENDPOINT]: 5,
|
|
1892
|
+
[KLING_O3_PRO_R2V_ENDPOINT]: 5,
|
|
1806
1893
|
// LTX-2.5 defaults to "auto", a length nobody can price up front; 6 s is its
|
|
1807
1894
|
// shortest clip on both tiers.
|
|
1808
1895
|
[LTX_25_FAST_I2V_ENDPOINT]: 6,
|
|
@@ -1852,6 +1939,8 @@ var VIDEO_ALLOWED_VALUES = {
|
|
|
1852
1939
|
},
|
|
1853
1940
|
[KLING_26_I2V_ENDPOINT]: { durationSeconds: { values: [5, 10] } },
|
|
1854
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 } },
|
|
1855
1944
|
[LTX_25_FAST_I2V_ENDPOINT]: {
|
|
1856
1945
|
aspectRatio: ["auto", "16:9", "9:16"],
|
|
1857
1946
|
// fal also renders 1440p, which the canvas does not offer.
|
|
@@ -1910,6 +1999,8 @@ var VIDEO_UNSUPPORTED_PARAMS = {
|
|
|
1910
1999
|
[WAN_30_I2V_ENDPOINT]: ["negativePrompt"],
|
|
1911
2000
|
[KLING_26_I2V_ENDPOINT]: ["resolution", "aspectRatio", "seed"],
|
|
1912
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"],
|
|
1913
2004
|
...Object.fromEntries(LTX_25_I2V_ENDPOINTS.map((e) => [e, ["seed", "negativePrompt"]]))
|
|
1914
2005
|
};
|
|
1915
2006
|
var ROWS = [
|
|
@@ -2622,8 +2713,10 @@ function searchMeshyAnimations(query, limit = 25) {
|
|
|
2622
2713
|
}
|
|
2623
2714
|
return out;
|
|
2624
2715
|
}
|
|
2625
|
-
var PORT_TYPES = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
|
|
2626
|
-
var INPUT_PORT_TYPES = PORT_TYPES.filter(
|
|
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
|
+
);
|
|
2627
2720
|
|
|
2628
2721
|
// src/rig.ts
|
|
2629
2722
|
var RIG_MODEL_ID = "fal/meshy-rigging";
|
|
@@ -2688,8 +2781,13 @@ var MODEL_TASKS = [
|
|
|
2688
2781
|
"background-remove",
|
|
2689
2782
|
"segmentation"
|
|
2690
2783
|
];
|
|
2691
|
-
var PORT_TYPES2 = ["text", "image", "video", "mask", "mesh3d", "audio", "json"];
|
|
2692
|
-
|
|
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
|
+
);
|
|
2693
2791
|
var TASK_PORTS = {
|
|
2694
2792
|
// GENERATE: born from text (or a mesh prompt), no upstream asset input.
|
|
2695
2793
|
"text-to-image": { inputs: ["text"], output: "image" },
|
|
@@ -2701,7 +2799,11 @@ var TASK_PORTS = {
|
|
|
2701
2799
|
// Two image inputs (garment + person); the port type set is coarse (both are
|
|
2702
2800
|
// 'image'), the two-image contract lives in the fal adapter, not the ports.
|
|
2703
2801
|
"virtual-try-on": { inputs: ["image"], output: "image" },
|
|
2704
|
-
|
|
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" },
|
|
2705
2807
|
// Video-to-video (character replace): a source video plus ONE reference image
|
|
2706
2808
|
// (the person to swap in). The two-input contract lives in the fal adapter.
|
|
2707
2809
|
"video-to-video": { inputs: ["video", "image"], output: "video" },
|
|
@@ -3066,7 +3168,10 @@ var ROUTES2 = [
|
|
|
3066
3168
|
"720p": "fal/kling-o3-standard-image-to-video",
|
|
3067
3169
|
"1080p": "fal/kling-o3-pro-image-to-video"
|
|
3068
3170
|
},
|
|
3069
|
-
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" }
|
|
3070
3175
|
}
|
|
3071
3176
|
},
|
|
3072
3177
|
{
|
|
@@ -3656,8 +3761,15 @@ var CATALOG_ENTRIES2 = [
|
|
|
3656
3761
|
modality: "video",
|
|
3657
3762
|
task: "image-to-video",
|
|
3658
3763
|
label: "Kling O3 (KIE)",
|
|
3659
|
-
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.",
|
|
3660
|
-
|
|
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
|
+
}
|
|
3661
3773
|
},
|
|
3662
3774
|
{
|
|
3663
3775
|
id: "fal/grok-imagine-1-5-image-to-video",
|
|
@@ -3705,6 +3817,22 @@ var CATALOG_ENTRIES2 = [
|
|
|
3705
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.",
|
|
3706
3818
|
capabilities: { needsImageInput: true, maxInputImages: 1, acceptsEndFrame: true }
|
|
3707
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
|
+
},
|
|
3708
3836
|
{
|
|
3709
3837
|
id: "fal/ltx-2-5-fast-image-to-video",
|
|
3710
3838
|
provider: "fal",
|
|
@@ -4088,6 +4216,9 @@ function portBinding(task, port) {
|
|
|
4088
4216
|
if (port === "image" && (task === "image-to-3d" || task === "multiview-to-3d" || task === "image-to-video" || task === "image-to-text" || task === "image-to-json")) {
|
|
4089
4217
|
return { key: "inputImageUrl", path: "url" };
|
|
4090
4218
|
}
|
|
4219
|
+
if (port === "reference" && task === "image-to-video") {
|
|
4220
|
+
return { key: "referenceImageUrls", path: "url", wrap: "array" };
|
|
4221
|
+
}
|
|
4091
4222
|
if (port === "mesh3d" && (task === "remesh" || task === "texture" || task === "rig")) {
|
|
4092
4223
|
return { key: "parentAssetId", path: "assetId" };
|
|
4093
4224
|
}
|
|
@@ -4103,7 +4234,7 @@ function portBinding(task, port) {
|
|
|
4103
4234
|
if (port === "video" && task === "video-enhance") {
|
|
4104
4235
|
return { key: "draftCacheUrl", path: "draftCacheUrl" };
|
|
4105
4236
|
}
|
|
4106
|
-
if (port === "image" && task === "image-edit") {
|
|
4237
|
+
if (port === "image" && (task === "image-edit" || task === "image-to-image")) {
|
|
4107
4238
|
return { key: "inputImages", path: "url", wrap: "array" };
|
|
4108
4239
|
}
|
|
4109
4240
|
if (port === "text" && taskNeedsPrompt(task)) {
|
|
@@ -4121,20 +4252,27 @@ function portBinding(task, port) {
|
|
|
4121
4252
|
return null;
|
|
4122
4253
|
}
|
|
4123
4254
|
function canConnect(sourceOut, targetTask, targetPort) {
|
|
4124
|
-
if (sourceOut !== targetPort) return false;
|
|
4255
|
+
if (sourceOut !== portContent(targetPort)) return false;
|
|
4125
4256
|
return portBinding(targetTask, targetPort) !== null;
|
|
4126
4257
|
}
|
|
4127
4258
|
function portCardinality(task, port, model) {
|
|
4128
4259
|
if (portBinding(task, port) === null) return "none";
|
|
4129
|
-
if (port === "image" && task === "image-edit") return "many";
|
|
4260
|
+
if (port === "image" && (task === "image-edit" || task === "image-to-image")) return "many";
|
|
4130
4261
|
if (port === "image" && task === "image-to-video") {
|
|
4131
4262
|
return modelAcceptsKeyframes(model) ? "many" : "two";
|
|
4132
4263
|
}
|
|
4264
|
+
if (port === "reference") {
|
|
4265
|
+
return modelCharacterReferences(model) ? "many" : "none";
|
|
4266
|
+
}
|
|
4133
4267
|
if (port === "image" && task === "video-to-video") {
|
|
4134
4268
|
return modelTakesSeveralReferences(model) ? "many" : "one";
|
|
4135
4269
|
}
|
|
4136
4270
|
return "one";
|
|
4137
4271
|
}
|
|
4272
|
+
function modelCharacterReferences(model) {
|
|
4273
|
+
if (!model) return null;
|
|
4274
|
+
return tryGetModel2(model)?.capabilities?.characterReferences ?? null;
|
|
4275
|
+
}
|
|
4138
4276
|
function modelTakesSeveralReferences(model) {
|
|
4139
4277
|
if (!model) return false;
|
|
4140
4278
|
const cap = tryGetModel2(model)?.capabilities?.maxInputImages;
|
|
@@ -4186,6 +4324,15 @@ function targetCardinality(node, port) {
|
|
|
4186
4324
|
function slotRefusal(node, port, wired) {
|
|
4187
4325
|
const cardinality = targetCardinality(node, port);
|
|
4188
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
|
+
}
|
|
4189
4336
|
if (cardinality === "many" && node.kind === "task" && node.model) {
|
|
4190
4337
|
const cap = tryGetModel2(node.model)?.capabilities?.maxInputImages;
|
|
4191
4338
|
if (typeof cap === "number" && cap > 0) limit = Math.min(limit, cap);
|
|
@@ -4200,7 +4347,7 @@ function slotRefusal(node, port, wired) {
|
|
|
4200
4347
|
function wireLegality(source, target, port) {
|
|
4201
4348
|
if (source.id === target.id) return { ok: false, code: "cycle", message: `node "${source.id}" cannot wire into itself` };
|
|
4202
4349
|
const produced = sourcePortOf(source);
|
|
4203
|
-
if (produced !== port) {
|
|
4350
|
+
if (produced !== portContent(port)) {
|
|
4204
4351
|
return { ok: false, code: "invalid_port", message: `node "${source.id}" produces ${produced}, not ${port}` };
|
|
4205
4352
|
}
|
|
4206
4353
|
if (target.kind !== "task") {
|
|
@@ -4209,6 +4356,13 @@ function wireLegality(source, target, port) {
|
|
|
4209
4356
|
if (!canConnect(produced, target.task, port)) {
|
|
4210
4357
|
return { ok: false, code: "invalid_port", message: `a ${port} wire into "${target.id}" (${target.task}) is not supported` };
|
|
4211
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
|
+
}
|
|
4212
4366
|
if (source.kind === "input" && source.cardinality === "many" && portBinding(target.task, port)?.wrap !== "array") {
|
|
4213
4367
|
return {
|
|
4214
4368
|
ok: false,
|
|
@@ -4592,6 +4746,7 @@ function taskModality(task) {
|
|
|
4592
4746
|
return "text";
|
|
4593
4747
|
case "image":
|
|
4594
4748
|
case "mask":
|
|
4749
|
+
case "reference":
|
|
4595
4750
|
return "image";
|
|
4596
4751
|
}
|
|
4597
4752
|
}
|
|
@@ -4677,6 +4832,60 @@ function keyframePositionsFor(sourceIds, settings) {
|
|
|
4677
4832
|
}
|
|
4678
4833
|
return { ok: true, frames };
|
|
4679
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
|
+
}
|
|
4680
4889
|
var TASK_TO_KIND = {
|
|
4681
4890
|
// image
|
|
4682
4891
|
"text-to-image": "generate_image",
|
|
@@ -4847,12 +5056,14 @@ function documentToDefinition(doc, opts = {}) {
|
|
|
4847
5056
|
const b = portBinding(task, port);
|
|
4848
5057
|
const cardinality = portCardinality(task, port, node.model);
|
|
4849
5058
|
const keyframes = port === "image" && task === "image-to-video" && modelAcceptsKeyframes(node.model);
|
|
5059
|
+
const references = port === "reference";
|
|
4850
5060
|
const listKey = orderedPortKey(task, port, 0, node.model) ?? b.key;
|
|
4851
5061
|
const items = [];
|
|
5062
|
+
const itemSources = [];
|
|
4852
5063
|
let uploading = false;
|
|
4853
5064
|
for (const [ordinal, e] of portWires.entries()) {
|
|
4854
5065
|
const source = byId.get(e.source);
|
|
4855
|
-
const single = !keyframes && (cardinality !== "many" || portWires.length === 1);
|
|
5066
|
+
const single = !keyframes && !references && (cardinality !== "many" || portWires.length === 1);
|
|
4856
5067
|
const key = orderedPortKey(task, port, ordinal, node.model) ?? b.key;
|
|
4857
5068
|
const wrap = single && b.wrap === "array";
|
|
4858
5069
|
let item = null;
|
|
@@ -4887,7 +5098,38 @@ function documentToDefinition(doc, opts = {}) {
|
|
|
4887
5098
|
}
|
|
4888
5099
|
if (!item) continue;
|
|
4889
5100
|
if (single) inputs[key] = item;
|
|
4890
|
-
else
|
|
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;
|
|
4891
5133
|
}
|
|
4892
5134
|
if (!uploading && items.length > 0)
|
|
4893
5135
|
inputs[listKey] = { kind: "list", items };
|
|
@@ -4912,6 +5154,13 @@ function documentToDefinition(doc, opts = {}) {
|
|
|
4912
5154
|
}
|
|
4913
5155
|
for (const [key, binding] of Object.entries(node.bakedInputs))
|
|
4914
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
|
+
}
|
|
4915
5164
|
if (Object.keys(inputs).length === 0 && !promptMissing) {
|
|
4916
5165
|
issues.push({
|
|
4917
5166
|
code: "no_inputs",
|
|
@@ -5371,7 +5620,7 @@ function affectedNodes(doc, ids) {
|
|
|
5371
5620
|
// src/workflowTools.ts
|
|
5372
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.');
|
|
5373
5622
|
var opsSchema = PatchSchema.shape.ops.describe(
|
|
5374
|
-
`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).`
|
|
5375
5624
|
);
|
|
5376
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).");
|
|
5377
5626
|
var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -5671,9 +5920,535 @@ var WORKFLOW_TOOLS = [
|
|
|
5671
5920
|
studioWorkflowScreenshot
|
|
5672
5921
|
];
|
|
5673
5922
|
|
|
5674
|
-
// src/
|
|
5923
|
+
// src/compositionTools.ts
|
|
5675
5924
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5925
|
+
import { z as z9 } from "zod";
|
|
5926
|
+
|
|
5927
|
+
// ../lumitra-core/dist/composition/index.js
|
|
5928
|
+
import { z as z22 } from "zod";
|
|
5676
5929
|
import { z as z8 } from "zod";
|
|
5930
|
+
import { z as z32 } from "zod";
|
|
5931
|
+
var BRAND_KIT_MAX_COLORS = 6;
|
|
5932
|
+
var BRAND_KIT_FONT_ROLES = ["primary", "secondary"];
|
|
5933
|
+
var BRAND_KIT_TYPE_ROLES = ["headline", "body"];
|
|
5934
|
+
var BRAND_KIT_LOGO_VARIANTS = ["light", "dark"];
|
|
5935
|
+
var BRAND_KIT_TYPE_PX_MIN = 12;
|
|
5936
|
+
var BRAND_KIT_TYPE_PX_MAX = 200;
|
|
5937
|
+
var HEX = /^#[0-9a-f]{6}$/i;
|
|
5938
|
+
var COLOR_ID = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
5939
|
+
var BrandKitColorSchema = z8.object({
|
|
5940
|
+
/** Stable id an overlay refers to; survives a rename of the colour. */
|
|
5941
|
+
id: z8.string().regex(COLOR_ID, "a colour id is lowercase letters, digits and hyphens"),
|
|
5942
|
+
name: z8.string().trim().min(1, "a colour needs a name").max(40),
|
|
5943
|
+
hex: z8.string().regex(HEX, "a colour is a hex value like #1a2b3c")
|
|
5944
|
+
}).strict();
|
|
5945
|
+
var TypeSizeSchema = z8.object({
|
|
5946
|
+
px: z8.number().int("a type size is a whole number of pixels").min(BRAND_KIT_TYPE_PX_MIN, `a type size is at least ${BRAND_KIT_TYPE_PX_MIN} px`).max(BRAND_KIT_TYPE_PX_MAX, `a type size is at most ${BRAND_KIT_TYPE_PX_MAX} px`)
|
|
5947
|
+
}).strict();
|
|
5948
|
+
var BrandKitTypeRolesSchema = z8.object({ headline: TypeSizeSchema, body: TypeSizeSchema }).strict().refine((t) => t.headline.px > t.body.px, {
|
|
5949
|
+
message: "the headline size must be larger than the body size",
|
|
5950
|
+
path: ["headline", "px"]
|
|
5951
|
+
});
|
|
5952
|
+
var BrandKitTokensSchema = z8.object({
|
|
5953
|
+
colors: z8.array(BrandKitColorSchema).min(1, "a kit needs at least one colour").max(BRAND_KIT_MAX_COLORS, `a kit holds at most ${BRAND_KIT_MAX_COLORS} colours`).superRefine((colors, ctx) => {
|
|
5954
|
+
const ids = /* @__PURE__ */ new Set();
|
|
5955
|
+
const names = /* @__PURE__ */ new Set();
|
|
5956
|
+
colors.forEach((c, i) => {
|
|
5957
|
+
if (ids.has(c.id)) ctx.addIssue({ code: "custom", message: `colour id "${c.id}" is used twice`, path: [i, "id"] });
|
|
5958
|
+
const name = c.name.trim().toLowerCase();
|
|
5959
|
+
if (names.has(name)) ctx.addIssue({ code: "custom", message: `colour name "${c.name}" is used twice`, path: [i, "name"] });
|
|
5960
|
+
ids.add(c.id);
|
|
5961
|
+
names.add(name);
|
|
5962
|
+
});
|
|
5963
|
+
}),
|
|
5964
|
+
typeRoles: BrandKitTypeRolesSchema
|
|
5965
|
+
}).strict();
|
|
5966
|
+
var BrandKitFontFileMetaSchema = z8.object({
|
|
5967
|
+
weight: z8.number().int().min(100).max(900).refine((w) => w % 100 === 0, "a font weight is a multiple of 100"),
|
|
5968
|
+
style: z8.enum(["normal", "italic"])
|
|
5969
|
+
}).strict();
|
|
5970
|
+
var BrandKitFamilySchema = z8.string().trim().min(1, "a font needs a family name").max(64).regex(/^[\p{L}\p{N} .'-]+$/u, "a font family name holds letters, digits, spaces, dots, apostrophes and hyphens");
|
|
5971
|
+
var COMPOSITION_SCHEMA_VERSION = 1;
|
|
5972
|
+
var COMPOSITION_KINDS = ["carousel", "reel"];
|
|
5973
|
+
var COMPOSITION_ASPECTS = ["4:5", "1:1", "9:16"];
|
|
5974
|
+
var MAX_CAROUSEL_SLIDES = 10;
|
|
5975
|
+
var REEL_MIN_SECONDS = 3;
|
|
5976
|
+
var REEL_MAX_SECONDS = 90;
|
|
5977
|
+
var MIN_CLIP_SECONDS = 0.5;
|
|
5978
|
+
var MAX_REEL_CLIPS = 30;
|
|
5979
|
+
var MAX_OVERLAYS_PER_ITEM = 20;
|
|
5980
|
+
var MAX_REEL_OVERLAYS = 40;
|
|
5981
|
+
var MAX_OVERLAY_TEXT = 500;
|
|
5982
|
+
var MIN_BOX_SIDE = 0.02;
|
|
5983
|
+
var ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
|
|
5984
|
+
var CompositionIdSchema = z22.string().regex(ID, "an id is letters, digits and _ . : -");
|
|
5985
|
+
var COLOR_ROLE = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/, "a colour is named by its kit id");
|
|
5986
|
+
var unit = z22.number().min(0).max(1);
|
|
5987
|
+
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");
|
|
5988
|
+
var TimingShape = {
|
|
5989
|
+
start: z22.number().min(0).optional(),
|
|
5990
|
+
end: z22.number().positive().optional()
|
|
5991
|
+
};
|
|
5992
|
+
var TextOverlaySchema = z22.object({
|
|
5993
|
+
id: CompositionIdSchema,
|
|
5994
|
+
type: z22.literal("text"),
|
|
5995
|
+
box: BoxSchema,
|
|
5996
|
+
text: z22.string().min(1, "a text overlay needs text").max(MAX_OVERLAY_TEXT),
|
|
5997
|
+
styleRole: z22.enum(BRAND_KIT_TYPE_ROLES),
|
|
5998
|
+
fontRole: z22.enum(BRAND_KIT_FONT_ROLES),
|
|
5999
|
+
weight: z22.number().int().min(100).max(900),
|
|
6000
|
+
italic: z22.boolean(),
|
|
6001
|
+
colorRole: COLOR_ROLE,
|
|
6002
|
+
align: z22.enum(["left", "center", "right"]),
|
|
6003
|
+
/** A colour chip behind the text, for legibility on busy images. */
|
|
6004
|
+
background: z22.object({ colorRole: COLOR_ROLE, opacity: unit, padding: z22.number().min(0).max(0.1) }).strict().optional(),
|
|
6005
|
+
...TimingShape
|
|
6006
|
+
}).strict();
|
|
6007
|
+
var LogoOverlaySchema = z22.object({
|
|
6008
|
+
id: CompositionIdSchema,
|
|
6009
|
+
type: z22.literal("logo"),
|
|
6010
|
+
box: BoxSchema,
|
|
6011
|
+
variant: z22.enum(BRAND_KIT_LOGO_VARIANTS),
|
|
6012
|
+
...TimingShape
|
|
6013
|
+
}).strict();
|
|
6014
|
+
var ShapeOverlaySchema = z22.object({
|
|
6015
|
+
id: CompositionIdSchema,
|
|
6016
|
+
type: z22.literal("shape"),
|
|
6017
|
+
box: BoxSchema,
|
|
6018
|
+
shape: z22.enum(["rect", "pill"]),
|
|
6019
|
+
colorRole: COLOR_ROLE,
|
|
6020
|
+
opacity: unit,
|
|
6021
|
+
...TimingShape
|
|
6022
|
+
}).strict();
|
|
6023
|
+
var OverlaySchema = z22.discriminatedUnion("type", [TextOverlaySchema, LogoOverlaySchema, ShapeOverlaySchema]);
|
|
6024
|
+
var SlideSchema = z22.object({
|
|
6025
|
+
id: CompositionIdSchema,
|
|
6026
|
+
type: z22.literal("slide"),
|
|
6027
|
+
background: z22.object({
|
|
6028
|
+
/** A Studio image asset of the composition's project. */
|
|
6029
|
+
assetId: CompositionIdSchema.optional(),
|
|
6030
|
+
fit: z22.enum(["cover", "contain"]),
|
|
6031
|
+
/** The point of the image kept in view when `cover` crops it. */
|
|
6032
|
+
focal: z22.object({ x: unit, y: unit }).strict(),
|
|
6033
|
+
/** A kit colour behind the image (or instead of one). */
|
|
6034
|
+
fill: COLOR_ROLE.optional()
|
|
6035
|
+
}).strict().refine((b) => b.assetId !== void 0 || b.fill !== void 0, "a slide needs an image or a fill colour"),
|
|
6036
|
+
overlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
6037
|
+
}).strict();
|
|
6038
|
+
var ClipSchema = z22.object({
|
|
6039
|
+
id: CompositionIdSchema,
|
|
6040
|
+
type: z22.literal("clip"),
|
|
6041
|
+
/** A Studio video asset of the composition's project. */
|
|
6042
|
+
assetId: CompositionIdSchema,
|
|
6043
|
+
/** Seconds into the source clip. */
|
|
6044
|
+
trimIn: z22.number().min(0),
|
|
6045
|
+
trimOut: z22.number().positive(),
|
|
6046
|
+
overlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
6047
|
+
}).strict().refine((c) => c.trimOut - c.trimIn >= MIN_CLIP_SECONDS - 1e-9, `a clip is at least ${MIN_CLIP_SECONDS} s after trimming`);
|
|
6048
|
+
var ItemSchema = z22.union([SlideSchema, ClipSchema]);
|
|
6049
|
+
var CompositionDocumentSchema = z22.object({
|
|
6050
|
+
schema: z22.literal(COMPOSITION_SCHEMA_VERSION),
|
|
6051
|
+
kind: z22.enum(COMPOSITION_KINDS),
|
|
6052
|
+
aspect: z22.enum(COMPOSITION_ASPECTS),
|
|
6053
|
+
label: z22.string().max(200),
|
|
6054
|
+
/** The brand whose kit the overlays use. */
|
|
6055
|
+
brandSlug: z22.string().min(1).max(64),
|
|
6056
|
+
/** The kit version the document was last edited against; a newer kit is worth a look before rendering. */
|
|
6057
|
+
kitVersionAtEdit: z22.number().int().nonnegative(),
|
|
6058
|
+
items: z22.array(ItemSchema),
|
|
6059
|
+
/** Overlays across the whole reel (a logo bug, an end card line). Always empty on a carousel. */
|
|
6060
|
+
reelOverlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
6061
|
+
}).strict();
|
|
6062
|
+
var REEL_TARGET = "reel";
|
|
6063
|
+
var TargetSchema = z32.string().min(1).max(128);
|
|
6064
|
+
var index = z32.number().int().nonnegative();
|
|
6065
|
+
var PropsSchema = z32.record(z32.string(), z32.unknown());
|
|
6066
|
+
var SetMetaOpSchema = z32.object({
|
|
6067
|
+
type: z32.literal("setMeta"),
|
|
6068
|
+
props: z32.object({
|
|
6069
|
+
label: z32.string().max(200).optional(),
|
|
6070
|
+
aspect: z32.enum(COMPOSITION_ASPECTS).optional(),
|
|
6071
|
+
kitVersionAtEdit: z32.number().int().nonnegative().optional()
|
|
6072
|
+
}).strict()
|
|
6073
|
+
}).strict();
|
|
6074
|
+
var AddItemOpSchema = z32.object({ type: z32.literal("addItem"), item: ItemSchema, index: index.optional() }).strict();
|
|
6075
|
+
var RemoveItemOpSchema = z32.object({ type: z32.literal("removeItem"), itemId: CompositionIdSchema }).strict();
|
|
6076
|
+
var MoveItemOpSchema = z32.object({ type: z32.literal("moveItem"), itemId: CompositionIdSchema, index }).strict();
|
|
6077
|
+
var SetItemPropsOpSchema = z32.object({ type: z32.literal("setItemProps"), itemId: CompositionIdSchema, props: PropsSchema }).strict();
|
|
6078
|
+
var AddOverlayOpSchema = z32.object({ type: z32.literal("addOverlay"), target: TargetSchema, overlay: OverlaySchema, index: index.optional() }).strict();
|
|
6079
|
+
var RemoveOverlayOpSchema = z32.object({ type: z32.literal("removeOverlay"), target: TargetSchema, overlayId: CompositionIdSchema }).strict();
|
|
6080
|
+
var MoveOverlayOpSchema = z32.object({
|
|
6081
|
+
type: z32.literal("moveOverlay"),
|
|
6082
|
+
target: TargetSchema,
|
|
6083
|
+
overlayId: CompositionIdSchema,
|
|
6084
|
+
/** Another item (or the reel) to move it to; omitted keeps it where it is. */
|
|
6085
|
+
toTarget: TargetSchema.optional(),
|
|
6086
|
+
/** Stacking position in the destination: 0 is at the back. */
|
|
6087
|
+
index
|
|
6088
|
+
}).strict();
|
|
6089
|
+
var SetOverlayPropsOpSchema = z32.object({ type: z32.literal("setOverlayProps"), target: TargetSchema, overlayId: CompositionIdSchema, props: PropsSchema }).strict();
|
|
6090
|
+
var CompositionOpSchema = z32.discriminatedUnion("type", [
|
|
6091
|
+
SetMetaOpSchema,
|
|
6092
|
+
AddItemOpSchema,
|
|
6093
|
+
RemoveItemOpSchema,
|
|
6094
|
+
MoveItemOpSchema,
|
|
6095
|
+
SetItemPropsOpSchema,
|
|
6096
|
+
AddOverlayOpSchema,
|
|
6097
|
+
RemoveOverlayOpSchema,
|
|
6098
|
+
MoveOverlayOpSchema,
|
|
6099
|
+
SetOverlayPropsOpSchema
|
|
6100
|
+
]);
|
|
6101
|
+
var COMPOSITION_OP_TYPES = CompositionOpSchema.options.map((o) => o.shape.type.value);
|
|
6102
|
+
var MAX_COMPOSITION_PATCH_OPS = 200;
|
|
6103
|
+
var CompositionPatchSchema = z32.object({
|
|
6104
|
+
baseRevision: z32.number().int().nonnegative(),
|
|
6105
|
+
ops: z32.array(CompositionOpSchema).min(1).max(MAX_COMPOSITION_PATCH_OPS),
|
|
6106
|
+
idempotencyKey: z32.string().min(1).max(128).optional()
|
|
6107
|
+
}).strict();
|
|
6108
|
+
|
|
6109
|
+
// src/compositionTools.ts
|
|
6110
|
+
var compositionId = z9.string().min(1).describe("The composition id, from studio_composition_create or studio_composition_list.");
|
|
6111
|
+
var opsSchema2 = z9.array(CompositionOpSchema).min(1).max(MAX_COMPOSITION_PATCH_OPS).describe(
|
|
6112
|
+
`The ops to apply in order (1 to ${MAX_COMPOSITION_PATCH_OPS}): ${COMPOSITION_OP_TYPES.join(", ")}. Ids are yours to choose; a later op may reference an id added earlier. Call studio_composition_describe for the overlay shapes and limits.`
|
|
6113
|
+
);
|
|
6114
|
+
function isRecord2(v) {
|
|
6115
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
6116
|
+
}
|
|
6117
|
+
function summarize(c) {
|
|
6118
|
+
const doc = c.document;
|
|
6119
|
+
return {
|
|
6120
|
+
id: c.id,
|
|
6121
|
+
projectId: c.projectId,
|
|
6122
|
+
kind: c.kind,
|
|
6123
|
+
label: c.label,
|
|
6124
|
+
brandSlug: c.brandSlug,
|
|
6125
|
+
revision: c.revision,
|
|
6126
|
+
aspect: doc.aspect,
|
|
6127
|
+
kitVersionAtEdit: doc.kitVersionAtEdit,
|
|
6128
|
+
items: doc.items,
|
|
6129
|
+
...doc.kind === "reel" ? { reelOverlays: doc.reelOverlays } : {}
|
|
6130
|
+
};
|
|
6131
|
+
}
|
|
6132
|
+
function mapCompositionFailure(err, ctx, idempotencyKey) {
|
|
6133
|
+
if (!(err instanceof StudioApiError)) return null;
|
|
6134
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
6135
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
6136
|
+
const message = typeof body.message === "string" ? ctx.client.redact(body.message) : null;
|
|
6137
|
+
if (err.status === 409 && code === "stale_revision" && isRecord2(body.composition)) {
|
|
6138
|
+
return {
|
|
6139
|
+
ok: false,
|
|
6140
|
+
code,
|
|
6141
|
+
revision: body.revision,
|
|
6142
|
+
composition: summarize(body.composition),
|
|
6143
|
+
hint: "Someone else changed it. Rebase your ops on the composition returned here and apply again with its revision and a NEW idempotencyKey."
|
|
6144
|
+
};
|
|
6145
|
+
}
|
|
6146
|
+
if (err.status === 409 && code === "idempotency_mismatch") {
|
|
6147
|
+
return { ok: false, code, message, hint: "That idempotencyKey belongs to a different patch: send this one with a new key." };
|
|
6148
|
+
}
|
|
6149
|
+
if (err.status === 422 && (code === "invalid_patch" || code === "not_ready")) {
|
|
6150
|
+
return {
|
|
6151
|
+
ok: false,
|
|
6152
|
+
code,
|
|
6153
|
+
...isRecord2(body.error) ? { error: body.error } : {},
|
|
6154
|
+
...Array.isArray(body.reasons) ? { reasons: body.reasons } : {},
|
|
6155
|
+
message,
|
|
6156
|
+
hint: code === "not_ready" ? "Fix every reason (studio_composition_apply), then render again." : "Nothing was applied. error.opIndex names the op to fix; a not_in_kit code means a colour, font, weight or logo the brand kit does not hold (studio_brand_kit_get lists what it does)."
|
|
6157
|
+
};
|
|
6158
|
+
}
|
|
6159
|
+
if (err.status === 429 && code === "render_limit") return { ok: false, code, message };
|
|
6160
|
+
if (err.status === 429 && code === "render_busy") {
|
|
6161
|
+
return {
|
|
6162
|
+
ok: false,
|
|
6163
|
+
code,
|
|
6164
|
+
message,
|
|
6165
|
+
...typeof body.jobId === "string" ? { jobId: body.jobId } : {},
|
|
6166
|
+
hint: "One reel renders at a time per company. Wait for that render (studio_get_job with the jobId), then render this one."
|
|
6167
|
+
};
|
|
6168
|
+
}
|
|
6169
|
+
if (err.status === 404) return { ok: false, code: code ?? "not_found", message: message ?? "Not found in this company." };
|
|
6170
|
+
if (idempotencyKey && (err.status === 0 || err.status >= 500)) {
|
|
6171
|
+
return {
|
|
6172
|
+
ok: false,
|
|
6173
|
+
code: err.status === 0 ? "network_error" : "server_error",
|
|
6174
|
+
message: ctx.client.redact(err.message),
|
|
6175
|
+
idempotencyKey,
|
|
6176
|
+
hint: "The outcome is unknown. Retry with the SAME idempotencyKey: if the patch was applied, the retry replays it instead of applying twice."
|
|
6177
|
+
};
|
|
6178
|
+
}
|
|
6179
|
+
return null;
|
|
6180
|
+
}
|
|
6181
|
+
var studioListAssets = defineTool({
|
|
6182
|
+
name: "studio_list_assets",
|
|
6183
|
+
description: "List a project's assets, newest first: images (subtype Image) a carousel slide can use as its background, videos (Video) a reel can use as clips, and earlier renders (CarouselSlide, Reel). Free, read-only. Returns { assets: [{ id, subtype, url, mimeType, prompt, durationSeconds?, createdAt }] }; use the ids in studio_composition_create or _apply ops.",
|
|
6184
|
+
inputSchema: {
|
|
6185
|
+
projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
|
|
6186
|
+
subtype: z9.enum(["Image", "Video", "CarouselSlide", "Reel"]).optional().describe("Only this kind: Image for slide backgrounds, Video for reel clips."),
|
|
6187
|
+
limit: z9.number().int().min(1).max(200).optional().describe("At most this many (default 50).")
|
|
6188
|
+
},
|
|
6189
|
+
handler: async (args, ctx) => {
|
|
6190
|
+
const { assets } = await ctx.client.listProjectAssets(args.projectId, {
|
|
6191
|
+
...args.subtype ? { subtype: args.subtype } : {},
|
|
6192
|
+
...args.limit ? { limit: args.limit } : {}
|
|
6193
|
+
});
|
|
6194
|
+
return {
|
|
6195
|
+
projectId: args.projectId,
|
|
6196
|
+
assets: assets.map((a) => {
|
|
6197
|
+
const seconds = typeof a.metadata?.durationSeconds === "number" ? a.metadata.durationSeconds : typeof a.metadata?.durationMs === "number" ? a.metadata.durationMs / 1e3 : void 0;
|
|
6198
|
+
return {
|
|
6199
|
+
id: a.id,
|
|
6200
|
+
subtype: a.subtype,
|
|
6201
|
+
url: a.url,
|
|
6202
|
+
mimeType: a.mimeType,
|
|
6203
|
+
prompt: a.prompt,
|
|
6204
|
+
...seconds !== void 0 ? { durationSeconds: seconds } : {},
|
|
6205
|
+
createdAt: a.createdAt
|
|
6206
|
+
};
|
|
6207
|
+
})
|
|
6208
|
+
};
|
|
6209
|
+
}
|
|
6210
|
+
});
|
|
6211
|
+
var studioBrandKitGet = defineTool({
|
|
6212
|
+
name: "studio_brand_kit_get",
|
|
6213
|
+
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.",
|
|
6214
|
+
inputSchema: { brandSlug: z9.string().min(1).describe("The brand slug, as studio_create_brand made it.") },
|
|
6215
|
+
handler: async (args, ctx) => {
|
|
6216
|
+
const { kit } = await ctx.client.getBrandKit(args.brandSlug);
|
|
6217
|
+
return {
|
|
6218
|
+
brandSlug: args.brandSlug,
|
|
6219
|
+
version: kit.version,
|
|
6220
|
+
colors: kit.colors,
|
|
6221
|
+
typeRoles: kit.typeRoles,
|
|
6222
|
+
fonts: kit.fonts.map((f) => ({ role: f.role, family: f.family, files: f.files.map((x) => ({ weight: x.weight, style: x.style })) })),
|
|
6223
|
+
logos: kit.logos.map((l) => ({ variant: l.variant, width: l.width, height: l.height }))
|
|
6224
|
+
};
|
|
6225
|
+
}
|
|
6226
|
+
});
|
|
6227
|
+
var studioCompositionDescribe = defineTool({
|
|
6228
|
+
name: "studio_composition_describe",
|
|
6229
|
+
description: "Describe the composition vocabulary before building a carousel or reel: the op types, the item and overlay shapes, the aspects and Instagram limits. Free, read-only, no request.",
|
|
6230
|
+
inputSchema: {},
|
|
6231
|
+
handler: async () => ({
|
|
6232
|
+
kinds: COMPOSITION_KINDS,
|
|
6233
|
+
aspects: COMPOSITION_ASPECTS,
|
|
6234
|
+
limits: {
|
|
6235
|
+
carouselSlides: MAX_CAROUSEL_SLIDES,
|
|
6236
|
+
reelClips: MAX_REEL_CLIPS,
|
|
6237
|
+
reelSeconds: { min: REEL_MIN_SECONDS, max: REEL_MAX_SECONDS },
|
|
6238
|
+
overlaysPerItem: MAX_OVERLAYS_PER_ITEM,
|
|
6239
|
+
overlaysPerReel: MAX_REEL_OVERLAYS,
|
|
6240
|
+
reelRendersAtOnce: 1,
|
|
6241
|
+
opsPerPatch: MAX_COMPOSITION_PATCH_OPS
|
|
6242
|
+
},
|
|
6243
|
+
opTypes: COMPOSITION_OP_TYPES,
|
|
6244
|
+
shapes: {
|
|
6245
|
+
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)',
|
|
6246
|
+
clip: '{ id, type: "clip", assetId (a video asset of the project), trimIn, trimOut (seconds), overlays: [] }',
|
|
6247
|
+
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) }',
|
|
6248
|
+
logo: '{ id, type: "logo", box, variant: "light"|"dark", start?, end? }',
|
|
6249
|
+
shape: '{ id, type: "shape", box, shape: "rect"|"pill", colorRole, opacity, start?, end? }'
|
|
6250
|
+
},
|
|
6251
|
+
targets: `addOverlay, removeOverlay, moveOverlay and setOverlayProps name a target: an item id, or "${REEL_TARGET}" for an overlay across the whole reel.`,
|
|
6252
|
+
rules: [
|
|
6253
|
+
"There is no field for a hex colour, a font family or a pixel size: overlays name kit roles (studio_brand_kit_get).",
|
|
6254
|
+
"Overlays stack in list order; the last is on top.",
|
|
6255
|
+
"A carousel is 4:5 or 1:1, at most 10 slides; a reel is 9:16, 3 to 90 s.",
|
|
6256
|
+
"Setting an optional field to null clears it.",
|
|
6257
|
+
"Rendering is free: studio_composition_render."
|
|
6258
|
+
]
|
|
6259
|
+
})
|
|
6260
|
+
});
|
|
6261
|
+
var studioCompositionList = defineTool({
|
|
6262
|
+
name: "studio_composition_list",
|
|
6263
|
+
description: "List a project's carousels and reels, newest first. Free, read-only.",
|
|
6264
|
+
inputSchema: { projectId: z9.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project.") },
|
|
6265
|
+
handler: async (args, ctx) => ctx.client.listCompositions(args.projectId !== void 0 ? { projectId: args.projectId } : {})
|
|
6266
|
+
});
|
|
6267
|
+
var studioCompositionCreate = defineTool({
|
|
6268
|
+
name: "studio_composition_create",
|
|
6269
|
+
description: "Create a carousel or reel for a brand, optionally with its first ops (so one call can build a whole carousel). Returns { ok: true, composition } at revision 1, or a refusal { ok: false, code, ... } (invalid_patch names the op; not_in_kit and invalid_asset codes say what to change). Creating and editing are free.",
|
|
6270
|
+
inputSchema: {
|
|
6271
|
+
kind: z9.enum(COMPOSITION_KINDS),
|
|
6272
|
+
brandSlug: z9.string().min(1).describe("The brand whose kit the overlays use."),
|
|
6273
|
+
projectId: z9.string().min(1).optional().describe("Project id from studio_list_projects; its images and clips are what slides and clips may use. Omit for the default project."),
|
|
6274
|
+
aspect: z9.enum(COMPOSITION_ASPECTS).optional().describe("4:5 (default for a carousel) or 1:1; a reel is 9:16."),
|
|
6275
|
+
label: z9.string().max(200).optional(),
|
|
6276
|
+
ops: z9.array(CompositionOpSchema).max(MAX_COMPOSITION_PATCH_OPS).optional(),
|
|
6277
|
+
idempotencyKey: z9.string().min(1).max(200).optional().describe("Omit on a first call (one is generated). After a network_error or server_error, retry with the idempotencyKey that result returned: the first post comes back instead of a second one.")
|
|
6278
|
+
},
|
|
6279
|
+
handler: async (args, ctx) => {
|
|
6280
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6281
|
+
try {
|
|
6282
|
+
const { composition, replayed } = await ctx.client.createComposition({
|
|
6283
|
+
idempotencyKey,
|
|
6284
|
+
kind: args.kind,
|
|
6285
|
+
brandSlug: args.brandSlug,
|
|
6286
|
+
...args.projectId !== void 0 ? { projectId: args.projectId } : {},
|
|
6287
|
+
...args.aspect !== void 0 ? { aspect: args.aspect } : {},
|
|
6288
|
+
...args.label !== void 0 ? { label: args.label } : {},
|
|
6289
|
+
...args.ops !== void 0 ? { ops: args.ops } : {}
|
|
6290
|
+
});
|
|
6291
|
+
return { ok: true, composition: summarize(composition), ...replayed ? { replayed: true } : {} };
|
|
6292
|
+
} catch (err) {
|
|
6293
|
+
const mapped = mapCompositionFailure(err, ctx, idempotencyKey);
|
|
6294
|
+
if (mapped) return mapped;
|
|
6295
|
+
throw err;
|
|
6296
|
+
}
|
|
6297
|
+
}
|
|
6298
|
+
});
|
|
6299
|
+
var studioCompositionGet = defineTool({
|
|
6300
|
+
name: "studio_composition_get",
|
|
6301
|
+
description: "Read one carousel or reel: its items, overlays and the revision to build the next patch on. Free, read-only.",
|
|
6302
|
+
inputSchema: { compositionId },
|
|
6303
|
+
handler: async (args, ctx) => {
|
|
6304
|
+
try {
|
|
6305
|
+
return { ok: true, composition: summarize((await ctx.client.getComposition(args.compositionId)).composition) };
|
|
6306
|
+
} catch (err) {
|
|
6307
|
+
const mapped = mapCompositionFailure(err, ctx);
|
|
6308
|
+
if (mapped) return mapped;
|
|
6309
|
+
throw err;
|
|
6310
|
+
}
|
|
6311
|
+
}
|
|
6312
|
+
});
|
|
6313
|
+
var studioCompositionApply = defineTool({
|
|
6314
|
+
name: "studio_composition_apply",
|
|
6315
|
+
description: "Change a carousel or reel atomically on top of baseRevision. Success: { ok: true, composition, inverse (ops that undo this), idempotencyKey, replayed }. Refusals are results to act on: stale_revision (rebase on the composition returned), invalid_patch (error.opIndex; codes not_in_kit and invalid_asset say what to change), idempotency_mismatch (new key), network_error and server_error (retry with the SAME idempotencyKey).",
|
|
6316
|
+
inputSchema: {
|
|
6317
|
+
compositionId,
|
|
6318
|
+
baseRevision: z9.number().int().nonnegative().describe("The revision the ops were written against."),
|
|
6319
|
+
ops: opsSchema2,
|
|
6320
|
+
idempotencyKey: z9.string().min(1).max(128).optional().describe("Generated when omitted. Pass the same key only to retry the SAME patch after a network or server failure.")
|
|
6321
|
+
},
|
|
6322
|
+
handler: async (args, ctx) => {
|
|
6323
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6324
|
+
try {
|
|
6325
|
+
const res = await ctx.client.patchComposition(args.compositionId, { baseRevision: args.baseRevision, ops: args.ops, idempotencyKey });
|
|
6326
|
+
return { ok: true, composition: summarize(res.composition), inverse: res.inverse, idempotencyKey, replayed: res.replayed === true };
|
|
6327
|
+
} catch (err) {
|
|
6328
|
+
const mapped = mapCompositionFailure(err, ctx, idempotencyKey);
|
|
6329
|
+
if (mapped) return mapped;
|
|
6330
|
+
throw err;
|
|
6331
|
+
}
|
|
6332
|
+
}
|
|
6333
|
+
});
|
|
6334
|
+
var studioCompositionRender = defineTool({
|
|
6335
|
+
name: "studio_composition_render",
|
|
6336
|
+
description: `Render a carousel to JPEG slides (1080 x 1350 or 1080 x 1080) or a reel to an H.264 MP4 (1080 x 1920), free, on Studio's own server. Waits by default and returns { ok: true, status, assets: [{ id, url }] } (slides in order; a reel is one asset), or { ok: false, code: "not_ready", reasons } listing everything to fix first. An identical render (same post, kit and renderer) is reused rather than redone.`,
|
|
6337
|
+
inputSchema: {
|
|
6338
|
+
compositionId,
|
|
6339
|
+
wait: z9.boolean().default(true),
|
|
6340
|
+
waitSeconds: z9.number().int().min(1).max(3600).default(600)
|
|
6341
|
+
},
|
|
6342
|
+
handler: async (args, ctx) => {
|
|
6343
|
+
let started;
|
|
6344
|
+
try {
|
|
6345
|
+
started = await ctx.client.renderComposition(args.compositionId);
|
|
6346
|
+
} catch (err) {
|
|
6347
|
+
const mapped = mapCompositionFailure(err, ctx);
|
|
6348
|
+
if (mapped) return mapped;
|
|
6349
|
+
throw err;
|
|
6350
|
+
}
|
|
6351
|
+
if (!args.wait) return { ok: true, jobId: started.jobId, reused: started.reused, status: "pending" };
|
|
6352
|
+
const res = await waitForJob(ctx.client, started.jobId, { timeoutMs: args.waitSeconds * 1e3 });
|
|
6353
|
+
const assets = [...res.resultAssets ?? (res.resultAsset ? [res.resultAsset] : [])].map((a) => ({ id: a.id, url: a.url, slideIndex: isRecord2(a.metadata) ? a.metadata.slideIndex : void 0 })).sort((a, b) => Number(a.slideIndex ?? 0) - Number(b.slideIndex ?? 0));
|
|
6354
|
+
if (res.job.status !== "succeeded") {
|
|
6355
|
+
return { ok: false, code: "render_failed", jobId: started.jobId, status: res.job.status, message: res.job.errorMessage ? ctx.client.redact(res.job.errorMessage) : null };
|
|
6356
|
+
}
|
|
6357
|
+
return { ok: true, jobId: started.jobId, reused: started.reused, status: res.job.status, assets };
|
|
6358
|
+
}
|
|
6359
|
+
});
|
|
6360
|
+
var SOCIAL_HINTS = {
|
|
6361
|
+
not_connected: "This company is not connected to Lumitra Social. A company owner or admin connects it once in Studio (Posts editor, Send to Social) with a company API key; ask the user to do that.",
|
|
6362
|
+
link_broken: "Lumitra Social no longer accepts the company key. A company owner or admin must connect again in Studio with a new key; ask the user.",
|
|
6363
|
+
not_rendered: "Render the post as it is now (studio_composition_render), then send again with a NEW idempotencyKey.",
|
|
6364
|
+
idempotency_mismatch: "That idempotencyKey belongs to a different send: use a new one.",
|
|
6365
|
+
social_refused: "Lumitra Social refused it; the message says why (an unknown project slug, for one). Fix that and send with a NEW idempotencyKey.",
|
|
6366
|
+
invalid_body: "Fix the field the message names (a time in the past, for one) and send with a NEW idempotencyKey."
|
|
6367
|
+
};
|
|
6368
|
+
var studioSocialListProjects = defineTool({
|
|
6369
|
+
name: "studio_social_list_projects",
|
|
6370
|
+
description: "List the company's Lumitra Social projects (each is one Instagram account in the planner) to send a post to, and the one this brand last went to. Free, read-only. Returns { ok: true, projects: [{ slug, name, igHandle }], lastProjectSlug }, or { ok: false, code } when the company is not connected (an owner connects it in Studio).",
|
|
6371
|
+
inputSchema: {
|
|
6372
|
+
brandSlug: z9.string().min(1).optional().describe("The brand of the post, to learn which project it went to last.")
|
|
6373
|
+
},
|
|
6374
|
+
handler: async (args, ctx) => {
|
|
6375
|
+
try {
|
|
6376
|
+
const { projects, lastProjectSlug } = await ctx.client.listSocialProjects(args.brandSlug);
|
|
6377
|
+
return { ok: true, projects: projects.map((p) => ({ slug: p.slug, name: p.name, igHandle: p.igHandle ?? null })), lastProjectSlug };
|
|
6378
|
+
} catch (err) {
|
|
6379
|
+
if (err instanceof StudioApiError) {
|
|
6380
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
6381
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
6382
|
+
if (code && SOCIAL_HINTS[code]) return { ok: false, code, message: typeof body.message === "string" ? ctx.client.redact(body.message) : null, hint: SOCIAL_HINTS[code] };
|
|
6383
|
+
if (err.status === 503) return { ok: false, code: "social_unavailable", hint: "Lumitra Social did not answer; try again shortly." };
|
|
6384
|
+
}
|
|
6385
|
+
throw err;
|
|
6386
|
+
}
|
|
6387
|
+
}
|
|
6388
|
+
});
|
|
6389
|
+
var studioCompositionSendToSocial = defineTool({
|
|
6390
|
+
name: "studio_composition_send_to_social",
|
|
6391
|
+
description: "Send a rendered post to Lumitra Social as a draft or scheduled post. The post must be rendered at its current revision (studio_composition_render); a reel goes as a reel, a single-slide carousel as a feed image, and a carousel of 2 to 10 slides as an Instagram carousel in the same order as the editor. This creates a post in the company planner, which publishes it to Instagram at scheduledAt: confirm the project, caption and time with the user before sending. Returns { ok: true, send: { status, format, projectSlug, scheduledAt, plannerUrl }, replayed } or a refusal { ok: false, code, hint }. On social_unavailable, network_error or server_error, retry with the SAME idempotencyKey: the send resumes and never posts twice.",
|
|
6392
|
+
inputSchema: {
|
|
6393
|
+
compositionId,
|
|
6394
|
+
projectSlug: z9.string().min(1).describe("The Lumitra Social project slug, from studio_social_list_projects."),
|
|
6395
|
+
caption: z9.string().max(2200).optional(),
|
|
6396
|
+
hashtags: z9.string().max(2200).optional().describe("Space-separated, at most 30 (Instagram counts them with the caption toward 2200 characters)."),
|
|
6397
|
+
scheduledAt: z9.string().datetime({ offset: true }).nullable().optional().describe("ISO date-time with an offset; omit or null for a draft the user schedules in the planner."),
|
|
6398
|
+
idempotencyKey: z9.string().min(1).max(200).optional().describe("Omit on a first send (one is generated); pass the returned one to retry.")
|
|
6399
|
+
},
|
|
6400
|
+
handler: async (args, ctx) => {
|
|
6401
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6402
|
+
try {
|
|
6403
|
+
const { send, replayed } = await ctx.client.sendCompositionToSocial(args.compositionId, {
|
|
6404
|
+
projectSlug: args.projectSlug,
|
|
6405
|
+
...args.caption !== void 0 ? { caption: args.caption } : {},
|
|
6406
|
+
...args.hashtags !== void 0 ? { hashtags: args.hashtags } : {},
|
|
6407
|
+
scheduledAt: args.scheduledAt ?? null,
|
|
6408
|
+
idempotencyKey
|
|
6409
|
+
});
|
|
6410
|
+
return {
|
|
6411
|
+
ok: true,
|
|
6412
|
+
replayed,
|
|
6413
|
+
send: { status: send.status, format: send.format, projectSlug: send.projectSlug, scheduledAt: send.scheduledAt, plannerUrl: send.plannerUrl }
|
|
6414
|
+
};
|
|
6415
|
+
} catch (err) {
|
|
6416
|
+
if (err instanceof StudioApiError) {
|
|
6417
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
6418
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
6419
|
+
const message = typeof body.message === "string" ? ctx.client.redact(body.message) : null;
|
|
6420
|
+
if (code && SOCIAL_HINTS[code]) return { ok: false, code, message, hint: SOCIAL_HINTS[code] };
|
|
6421
|
+
if (err.status === 404) return { ok: false, code: "not_found", message: message ?? "Not found in this company." };
|
|
6422
|
+
if (err.status === 0 || err.status >= 500) {
|
|
6423
|
+
return {
|
|
6424
|
+
ok: false,
|
|
6425
|
+
code: err.status === 0 ? "network_error" : code === "social_unavailable" ? code : "server_error",
|
|
6426
|
+
message: message ?? ctx.client.redact(err.message),
|
|
6427
|
+
idempotencyKey,
|
|
6428
|
+
hint: "The outcome may be partial. Retry with the SAME idempotencyKey: the send resumes where it stopped and never posts twice."
|
|
6429
|
+
};
|
|
6430
|
+
}
|
|
6431
|
+
}
|
|
6432
|
+
throw err;
|
|
6433
|
+
}
|
|
6434
|
+
}
|
|
6435
|
+
});
|
|
6436
|
+
var COMPOSITION_TOOLS = [
|
|
6437
|
+
studioListAssets,
|
|
6438
|
+
studioBrandKitGet,
|
|
6439
|
+
studioCompositionDescribe,
|
|
6440
|
+
studioCompositionList,
|
|
6441
|
+
studioCompositionCreate,
|
|
6442
|
+
studioCompositionGet,
|
|
6443
|
+
studioCompositionApply,
|
|
6444
|
+
studioCompositionRender,
|
|
6445
|
+
studioSocialListProjects,
|
|
6446
|
+
studioCompositionSendToSocial
|
|
6447
|
+
];
|
|
6448
|
+
|
|
6449
|
+
// src/manageTools.ts
|
|
6450
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
6451
|
+
import { z as z10 } from "zod";
|
|
5677
6452
|
var TOKEN_TTL_MS = 10 * 60 * 1e3;
|
|
5678
6453
|
var ConfirmationStore = class {
|
|
5679
6454
|
#tokens = /* @__PURE__ */ new Map();
|
|
@@ -5683,7 +6458,7 @@ var ConfirmationStore = class {
|
|
|
5683
6458
|
}
|
|
5684
6459
|
issue(subject) {
|
|
5685
6460
|
this.#sweep();
|
|
5686
|
-
const token =
|
|
6461
|
+
const token = randomUUID3();
|
|
5687
6462
|
this.#tokens.set(token, { subject, expiresAt: this.#now() + TOKEN_TTL_MS });
|
|
5688
6463
|
return token;
|
|
5689
6464
|
}
|
|
@@ -5760,21 +6535,21 @@ function roleRefusal(err, sentence) {
|
|
|
5760
6535
|
}
|
|
5761
6536
|
throw err;
|
|
5762
6537
|
}
|
|
5763
|
-
var confirmationToken =
|
|
6538
|
+
var confirmationToken = z10.string().min(1).optional().describe(
|
|
5764
6539
|
"Only for a client that cannot show a confirmation dialog: the confirmationToken a previous call returned, sent after the person said yes in the chat to the summary it came with."
|
|
5765
6540
|
);
|
|
5766
6541
|
var studioCreateProject = defineTool({
|
|
5767
6542
|
name: "studio_create_project",
|
|
5768
6543
|
description: "Create a project in your company: a workspace that keeps saved workflows, runs, assets and chats together (characters, products, locations, brands and campaigns are shared by every project). Only a name is needed; its slug is derived. A name the company already uses is refused (409 name_taken). Returns the project with its id, for projectId on the other tools.",
|
|
5769
|
-
inputSchema: { name:
|
|
6544
|
+
inputSchema: { name: z10.string().min(1).max(120).describe("The project name, as people in the company will see it.") },
|
|
5770
6545
|
handler: async (args, ctx) => (await ctx.client.createProject(args.name)).project
|
|
5771
6546
|
});
|
|
5772
6547
|
var studioRenameProject = defineTool({
|
|
5773
6548
|
name: "studio_rename_project",
|
|
5774
6549
|
description: `Rename a project of your company (any member may). The slug follows the new name, except for the company's default project, which keeps the slug "default". A name another project of the company uses is refused (409 name_taken).`,
|
|
5775
6550
|
inputSchema: {
|
|
5776
|
-
projectId:
|
|
5777
|
-
name:
|
|
6551
|
+
projectId: z10.string().min(1).describe("The project, from studio_list_projects."),
|
|
6552
|
+
name: z10.string().min(1).max(120).describe("The new name.")
|
|
5778
6553
|
},
|
|
5779
6554
|
annotations: { idempotentHint: true },
|
|
5780
6555
|
handler: async (args, ctx) => (await ctx.client.renameProject(args.projectId, args.name)).project
|
|
@@ -5783,7 +6558,7 @@ var studioDeleteProject = defineTool({
|
|
|
5783
6558
|
name: "studio_delete_project",
|
|
5784
6559
|
description: "Delete a project of your company for everyone, with its saved workflows, runs, assets (and their stored files) and chats. Needs a key with the company admin role. The PERSON confirms every delete in the chat: this tool reads what would be removed and asks them through the client's confirmation dialog before anything happens. If the client has no such dialog, the tool returns `confirmationRequired` with a `summary` and a `confirmationToken`: show the summary to the person exactly as written, and only after they explicitly say yes call again with the token. Never confirm on their behalf. The company's default project cannot be deleted, nor a project with a run or generation still going; the tool says so instead. The record of what the project cost is kept (it moves to the default project).",
|
|
5785
6560
|
inputSchema: {
|
|
5786
|
-
projectId:
|
|
6561
|
+
projectId: z10.string().min(1).describe("The project to delete, from studio_list_projects."),
|
|
5787
6562
|
confirmationToken
|
|
5788
6563
|
},
|
|
5789
6564
|
annotations: { destructiveHint: true },
|
|
@@ -5812,7 +6587,7 @@ var studioDeleteProject = defineTool({
|
|
|
5812
6587
|
var studioListWorkflows = defineTool({
|
|
5813
6588
|
name: "studio_list_workflows",
|
|
5814
6589
|
description: "List the saved workflows of one project (savedId, label, version). Omit projectId for the company's default project. Use the savedId with studio_workflow_get, studio_run_workflow or studio_move_workflow.",
|
|
5815
|
-
inputSchema: { projectId:
|
|
6590
|
+
inputSchema: { projectId: z10.string().min(1).optional().describe("The project, from studio_list_projects. Omit for the default project.") },
|
|
5816
6591
|
annotations: { readOnlyHint: true },
|
|
5817
6592
|
handler: async (args, ctx) => {
|
|
5818
6593
|
const { workflows } = await ctx.client.listWorkflows(args.projectId ? { projectId: args.projectId } : {});
|
|
@@ -5823,9 +6598,9 @@ var studioMoveWorkflow = defineTool({
|
|
|
5823
6598
|
name: "studio_move_workflow",
|
|
5824
6599
|
description: "Move a saved workflow to another project of your company, together with its runs, their jobs and the assets they produced, so every node keeps its results and nothing has to be generated again. Reversible: move it back the same way. projectId is the project it is in now (omit for the default project); toProjectId is required. Refused while a run of the workflow is still going (409 run_in_flight), and for a project of another company (404).",
|
|
5825
6600
|
inputSchema: {
|
|
5826
|
-
savedId:
|
|
5827
|
-
toProjectId:
|
|
5828
|
-
projectId:
|
|
6601
|
+
savedId: z10.string().min(1).describe('The saved workflow, from studio_list_workflows (starts with "saved:").'),
|
|
6602
|
+
toProjectId: z10.string().min(1).describe("The project to move it to, from studio_list_projects."),
|
|
6603
|
+
projectId: z10.string().min(1).optional().describe("The project the workflow is in now. Omit for the default project.")
|
|
5829
6604
|
},
|
|
5830
6605
|
handler: async (args, ctx) => ctx.client.moveWorkflow(args.savedId, { toProjectId: args.toProjectId, ...args.projectId ? { projectId: args.projectId } : {} })
|
|
5831
6606
|
});
|
|
@@ -5840,7 +6615,7 @@ var studioDeleteCampaign = defineTool({
|
|
|
5840
6615
|
name: "studio_delete_campaign",
|
|
5841
6616
|
description: "Delete a campaign of your company with its shot list and every approve and reject decision. Its images stay in the asset library. The PERSON confirms every delete in the chat: this tool shows them what goes and what stays through the client's confirmation dialog before anything happens. If the client has no such dialog, the tool returns `confirmationRequired` with a `summary` and a `confirmationToken`: show the summary to the person exactly as written, and only after they explicitly say yes call again with the token. Never confirm on their behalf. Refused while a shot is still rendering; the tool says so instead.",
|
|
5842
6617
|
inputSchema: {
|
|
5843
|
-
campaignId:
|
|
6618
|
+
campaignId: z10.string().min(1).describe("The campaign, from studio_list_campaigns."),
|
|
5844
6619
|
confirmationToken
|
|
5845
6620
|
},
|
|
5846
6621
|
annotations: { destructiveHint: true },
|
|
@@ -5874,9 +6649,9 @@ var MANAGE_TOOLS = [
|
|
|
5874
6649
|
];
|
|
5875
6650
|
|
|
5876
6651
|
// src/tools.ts
|
|
5877
|
-
var slug =
|
|
5878
|
-
var waitSeconds =
|
|
5879
|
-
var httpUrl =
|
|
6652
|
+
var slug = z11.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
|
|
6653
|
+
var waitSeconds = z11.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.");
|
|
6654
|
+
var httpUrl = z11.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
|
|
5880
6655
|
function pollOpts(ctx, timeoutSec) {
|
|
5881
6656
|
return { ...ctx.poll, timeoutMs: timeoutSec * 1e3 };
|
|
5882
6657
|
}
|
|
@@ -5952,22 +6727,22 @@ var studioGenerateImage = defineTool({
|
|
|
5952
6727
|
brandSlug: slug.optional().describe(
|
|
5953
6728
|
"Optional. The slug of a brand of your company (create one with studio_create_brand). Omit it to generate without a brand. A slug that names no brand of your company is refused with 404 input_not_found; it is never used as a project name."
|
|
5954
6729
|
),
|
|
5955
|
-
brandMode:
|
|
5956
|
-
prompt:
|
|
6730
|
+
brandMode: z11.string().optional().describe('Optional brand mode (e.g. "illustration"); modes are defined per brand. Only meaningful with brandSlug.'),
|
|
6731
|
+
prompt: z11.string().min(1).describe("What to generate. With brandSlug, the brand style prefix is prepended server-side."),
|
|
5957
6732
|
characterSlug: slug.optional().describe(
|
|
5958
6733
|
"Optional character whose identity references are injected: one of your company's, or one another company shared (see studio_list_characters). A slug your company cannot use is refused with 404 input_not_found."
|
|
5959
6734
|
),
|
|
5960
|
-
projectId:
|
|
6735
|
+
projectId: z11.string().min(1).optional().describe(
|
|
5961
6736
|
'Optional project to file the image under (an id from studio_list_projects; it must be a project of your company, anything else is a 404). Omit it to use the project named after brandSlug, or "default" when there is no brand.'
|
|
5962
6737
|
),
|
|
5963
|
-
model:
|
|
5964
|
-
aspectRatio:
|
|
5965
|
-
imageSize:
|
|
5966
|
-
seed:
|
|
5967
|
-
candidateCount:
|
|
6738
|
+
model: z11.string().optional().describe('Image model id (e.g. "kie/nano-banana-2", "fal/nano-banana-2"). Omit for the Studio default.'),
|
|
6739
|
+
aspectRatio: z11.string().optional().describe('Aspect ratio such as "1:1", "16:9", "3:4".'),
|
|
6740
|
+
imageSize: z11.string().optional().describe('Provider size hint, e.g. "1K", "2K".'),
|
|
6741
|
+
seed: z11.number().int().optional(),
|
|
6742
|
+
candidateCount: z11.number().int().min(1).max(4).optional().describe(
|
|
5968
6743
|
"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."
|
|
5969
6744
|
),
|
|
5970
|
-
wait:
|
|
6745
|
+
wait: z11.boolean().default(true).describe("Poll until the job finishes (default true)."),
|
|
5971
6746
|
waitSeconds
|
|
5972
6747
|
},
|
|
5973
6748
|
handler: async (args, ctx) => {
|
|
@@ -6003,23 +6778,23 @@ var studioGenerate3d = defineTool({
|
|
|
6003
6778
|
name: "studio_generate_3d",
|
|
6004
6779
|
description: "Generate one 3D model (a textured GLB mesh) through 3D AI Studio, from a text prompt or from one image (imageUrl). Text models: studio3d/tripo-3-1-text-to-3d (the default), studio3d/hunyuan-3-1-rapid, studio3d/hunyuan-3-1-pro. Image models: studio3d/trellis-2 (the default when imageUrl is given), studio3d/tripo-3-1-image-to-3d. Submits a job and, when wait=true (default), polls until it finishes (usually one to five minutes) and returns the signed GLB URL and its cost in USD (Studio prices the request it sent, since 3D AI Studio reports no per-job charge). With wait=false it returns the jobId for studio_get_job. The price follows the model and the quality flags; the returned costUsd is the exact amount.",
|
|
6005
6780
|
inputSchema: {
|
|
6006
|
-
prompt:
|
|
6781
|
+
prompt: z11.string().min(1).max(1024).describe("What to model. With imageUrl, a short description of the object in the image."),
|
|
6007
6782
|
imageUrl: httpUrl.optional().describe("Public http(s) URL of one image to model from. Selects an image model."),
|
|
6008
|
-
model:
|
|
6009
|
-
options:
|
|
6010
|
-
enableTexture:
|
|
6011
|
-
enablePbr:
|
|
6012
|
-
textureQuality:
|
|
6013
|
-
geometryQuality:
|
|
6014
|
-
quadRemesh:
|
|
6015
|
-
smartLowPoly:
|
|
6016
|
-
resolution:
|
|
6017
|
-
targetPolycount:
|
|
6018
|
-
topology:
|
|
6019
|
-
seed:
|
|
6783
|
+
model: z11.string().min(1).optional().describe("3D model id from the list in the description. Omit for the default (text or image, by whether imageUrl is given)."),
|
|
6784
|
+
options: z11.object({
|
|
6785
|
+
enableTexture: z11.boolean().optional().describe("Texture the mesh (default true). Off gives bare geometry and costs less."),
|
|
6786
|
+
enablePbr: z11.boolean().optional().describe("Physically-based rendering (PBR) material maps. Default on for Hunyuan Pro, off elsewhere."),
|
|
6787
|
+
textureQuality: z11.enum(["standard", "detailed"]).optional().describe("Tripo texture tier. detailed costs more."),
|
|
6788
|
+
geometryQuality: z11.enum(["standard", "detailed"]).optional().describe("Tripo geometry tier. detailed costs more."),
|
|
6789
|
+
quadRemesh: z11.boolean().optional().describe("Tripo: quad topology instead of triangles."),
|
|
6790
|
+
smartLowPoly: z11.boolean().optional().describe("Tripo text-to-3D: a low-poly mesh."),
|
|
6791
|
+
resolution: z11.enum(["512", "1024", "1536"]).optional().describe("TRELLIS.2 resolution (default 1024)."),
|
|
6792
|
+
targetPolycount: z11.number().int().min(100).max(15e5).optional().describe("Target face count, where the model supports one."),
|
|
6793
|
+
topology: z11.enum(["quad", "triangle"]).optional().describe("Hunyuan Pro polygon type."),
|
|
6794
|
+
seed: z11.number().int().optional()
|
|
6020
6795
|
}).optional().describe("Model-specific quality flags. Each changes the price; the returned costUsd is the price of the request that was sent."),
|
|
6021
|
-
projectId:
|
|
6022
|
-
wait:
|
|
6796
|
+
projectId: z11.string().min(1).optional().describe("Project to file the model under (from studio_list_projects). Omit for the default project."),
|
|
6797
|
+
wait: z11.boolean().default(true).describe("Poll until the job finishes (default true)."),
|
|
6023
6798
|
waitSeconds
|
|
6024
6799
|
},
|
|
6025
6800
|
handler: async (args, ctx) => {
|
|
@@ -6057,8 +6832,8 @@ var studioFindAnimations = defineTool({
|
|
|
6057
6832
|
name: "studio_find_animations",
|
|
6058
6833
|
description: 'Search Meshy\'s animation library (678 presets in five categories: WalkAndRun, BodyMovements, DailyActions, Fighting, Dancing) for the presets studio_rig_3d can apply. Every word of the query must match a preset\'s name, category or subcategory (e.g. "sword", "walking woman", "dance"). Free and local: no request, no cost. Returns id, name and category for up to `limit` matches.',
|
|
6059
6834
|
inputSchema: {
|
|
6060
|
-
query:
|
|
6061
|
-
limit:
|
|
6835
|
+
query: z11.string().describe('Words to match, e.g. "sword slash". Empty returns the first presets in library order.'),
|
|
6836
|
+
limit: z11.number().int().min(1).max(50).default(25)
|
|
6062
6837
|
},
|
|
6063
6838
|
annotations: { readOnlyHint: true },
|
|
6064
6839
|
handler: async (args) => ({ animations: searchAnimations(args.query, args.limit) })
|
|
@@ -6067,12 +6842,12 @@ var studioRig3d = defineTool({
|
|
|
6067
6842
|
name: "studio_rig_3d",
|
|
6068
6843
|
description: "Rig a humanoid 3D model and animate it (Meshy on fal): adds a skeleton and skin weights to a Model3D asset and applies up to 10 animation presets from Meshy's library; walk and run clips always come with the rig. Pass the mesh's assetId (studio_generate_3d returns it as assetId) and presets as names or ids (find them with studio_find_animations). Runs as a one-node workflow, so the cost gate and quota apply. Waits by default (usually one to three minutes) and returns the rigged GLB url, each clip's name and url, and costUsd (what it cost your company: a price per rig plus a price per preset). Humanoid characters only: an animal or an object will fail at the provider.",
|
|
6069
6844
|
inputSchema: {
|
|
6070
|
-
projectId:
|
|
6071
|
-
meshAssetId:
|
|
6072
|
-
animations:
|
|
6073
|
-
heightMeters:
|
|
6074
|
-
visibility:
|
|
6075
|
-
wait:
|
|
6845
|
+
projectId: z11.string().min(1).describe("The project the mesh lives in (from studio_list_projects)."),
|
|
6846
|
+
meshAssetId: z11.string().min(1).describe("The Model3D asset to rig: the assetId studio_generate_3d returned."),
|
|
6847
|
+
animations: z11.array(z11.union([z11.string().min(1), z11.number().int()])).max(RIG_MAX_CLIPS).default([]).describe('Up to 10 presets, each a name ("Double_Combo_Attack", or loosely "double combo attack") or an id. Empty rigs with only the included walk and run.'),
|
|
6848
|
+
heightMeters: z11.number().min(0.3).max(5).optional().describe("The character's approximate height in meters (default 1.7); Meshy scales the rig to it."),
|
|
6849
|
+
visibility: z11.enum(["listed", "unlisted"]).optional(),
|
|
6850
|
+
wait: z11.boolean().default(true).describe("Poll until the rig finishes (default true)."),
|
|
6076
6851
|
waitSeconds
|
|
6077
6852
|
},
|
|
6078
6853
|
handler: async (args, ctx) => {
|
|
@@ -6129,8 +6904,8 @@ var studioGetJob = defineTool({
|
|
|
6129
6904
|
name: "studio_get_job",
|
|
6130
6905
|
description: "Fetch the status of a generation job by jobId: status (queued, running, succeeded, failed, canceled), cost, model, error message and a freshly signed result URL once it succeeded. Set wait=true to block until the job reaches a terminal state.",
|
|
6131
6906
|
inputSchema: {
|
|
6132
|
-
jobId:
|
|
6133
|
-
wait:
|
|
6907
|
+
jobId: z11.string().min(1),
|
|
6908
|
+
wait: z11.boolean().default(false).describe("Poll until terminal (default false: return the current state)."),
|
|
6134
6909
|
waitSeconds
|
|
6135
6910
|
},
|
|
6136
6911
|
annotations: { readOnlyHint: true },
|
|
@@ -6160,7 +6935,7 @@ var studioGetCharacter = defineTool({
|
|
|
6160
6935
|
}
|
|
6161
6936
|
});
|
|
6162
6937
|
var LIKENESS_REFUSAL = `${LIKENESS_CONFIRMATION_REQUIRED_CODE}: ${likenessConfirmationRequiredMessage()}`;
|
|
6163
|
-
var likenessRightsConfirmed =
|
|
6938
|
+
var likenessRightsConfirmed = z11.literal(true, { error: LIKENESS_REFUSAL }).describe(likenessConfirmationToolDescription());
|
|
6164
6939
|
function assertLikenessRightsConfirmed(value) {
|
|
6165
6940
|
if (!isLikenessRightsConfirmed(value)) throw new Error(LIKENESS_REFUSAL);
|
|
6166
6941
|
}
|
|
@@ -6168,11 +6943,11 @@ var studioCreateCharacter = defineTool({
|
|
|
6168
6943
|
name: "studio_create_character",
|
|
6169
6944
|
description: "Create an empty character record (no reference images yet). Prefer studio_mint_character, which generates the 7-view identity sheet and freezes it as references in one call. Use this only when you will upload your own reference images. Requires likenessRightsConfirmed: true, which you may only pass after the human you act for confirmed it for this character. Fails with 409 (code slug_taken) only if your own company already has a character with this slug; a slug another company uses is free to take.",
|
|
6170
6945
|
inputSchema: {
|
|
6171
|
-
name:
|
|
6946
|
+
name: z11.string().min(1).describe('Display name, e.g. "Bruno Hartmann".'),
|
|
6172
6947
|
slug,
|
|
6173
|
-
descriptorPrompt:
|
|
6174
|
-
negativePrompt:
|
|
6175
|
-
defaultModel:
|
|
6948
|
+
descriptorPrompt: z11.string().min(1).describe("The identity description prepended to every generation that uses this character."),
|
|
6949
|
+
negativePrompt: z11.string().optional(),
|
|
6950
|
+
defaultModel: z11.string().optional().describe("Default image model id for this character."),
|
|
6176
6951
|
likenessRightsConfirmed
|
|
6177
6952
|
},
|
|
6178
6953
|
handler: async (args, ctx) => {
|
|
@@ -6192,16 +6967,16 @@ var studioMintCharacter = defineTool({
|
|
|
6192
6967
|
name: "studio_mint_character",
|
|
6193
6968
|
description: "Mint a consistent character from a text description: runs the curated character-sheet workflow (seed 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.",
|
|
6194
6969
|
inputSchema: {
|
|
6195
|
-
projectId:
|
|
6196
|
-
name:
|
|
6970
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6971
|
+
name: z11.string().min(1).describe("Display name."),
|
|
6197
6972
|
slug,
|
|
6198
|
-
description:
|
|
6199
|
-
descriptorPrompt:
|
|
6200
|
-
negativePrompt:
|
|
6201
|
-
defaultModel:
|
|
6202
|
-
seedModel:
|
|
6203
|
-
viewModel:
|
|
6204
|
-
visibility:
|
|
6973
|
+
description: z11.string().min(10).describe("Seed identity description (face, hair, age, build, distinguishing features)."),
|
|
6974
|
+
descriptorPrompt: z11.string().optional().describe("Override for the character's stored descriptor prompt. Defaults to the description."),
|
|
6975
|
+
negativePrompt: z11.string().optional(),
|
|
6976
|
+
defaultModel: z11.string().optional(),
|
|
6977
|
+
seedModel: z11.string().optional().describe("Override the seed text-to-image model (default fal/nano-banana-2)."),
|
|
6978
|
+
viewModel: z11.string().optional().describe("Override the view image-edit model (default fal/nano-banana-2-edit)."),
|
|
6979
|
+
visibility: z11.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
|
|
6205
6980
|
likenessRightsConfirmed,
|
|
6206
6981
|
waitSeconds
|
|
6207
6982
|
},
|
|
@@ -6260,12 +7035,12 @@ var studioCreateBrand = defineTool({
|
|
|
6260
7035
|
name: "studio_create_brand",
|
|
6261
7036
|
description: "Create a brand (a style preset: name, slug, optional style prefix prepended to every prompt, optional free-text context). Upload reference images afterwards with studio_upload_brand_reference. Fails with 409 (code slug_taken) only if your own company already has a brand with this slug; a slug another company uses is free to take.",
|
|
6262
7037
|
inputSchema: {
|
|
6263
|
-
name:
|
|
7038
|
+
name: z11.string().min(1),
|
|
6264
7039
|
slug,
|
|
6265
|
-
stylePrefix:
|
|
6266
|
-
context:
|
|
6267
|
-
defaultModel:
|
|
6268
|
-
maxReferenceImages:
|
|
7040
|
+
stylePrefix: z11.string().optional().describe("Text prepended to every prompt generated under this brand."),
|
|
7041
|
+
context: z11.string().optional().describe("Markdown brand context (tone, palette, do/don't)."),
|
|
7042
|
+
defaultModel: z11.string().optional(),
|
|
7043
|
+
maxReferenceImages: z11.number().int().min(0).max(8).optional()
|
|
6269
7044
|
},
|
|
6270
7045
|
handler: async (args, ctx) => {
|
|
6271
7046
|
const { config } = await ctx.client.createBrand({
|
|
@@ -6284,11 +7059,11 @@ var studioUploadBrandReference = defineTool({
|
|
|
6284
7059
|
description: `Upload one reference image to a brand's library from a local file path or an http(s) URL. The Studio converts it to a 512px WebP and injects it into generations under that brand (up to the brand's maxReferenceImages). Category groups references (default "general"); tags and a 1 to 10 quality score are optional.`,
|
|
6285
7060
|
inputSchema: {
|
|
6286
7061
|
brandSlug: slug.describe("The slug of a brand of your company (from studio_create_brand). A slug that names no brand of your company is a 404, and nothing is uploaded."),
|
|
6287
|
-
source:
|
|
6288
|
-
category:
|
|
6289
|
-
label:
|
|
6290
|
-
tags:
|
|
6291
|
-
score:
|
|
7062
|
+
source: z11.string().min(1).describe("Local file path or http(s) URL of an image."),
|
|
7063
|
+
category: z11.string().optional().describe('Library category, default "general".'),
|
|
7064
|
+
label: z11.string().optional().describe("Optional file name / label."),
|
|
7065
|
+
tags: z11.array(z11.string()).optional(),
|
|
7066
|
+
score: z11.number().int().min(1).max(10).optional()
|
|
6292
7067
|
},
|
|
6293
7068
|
handler: async (args, ctx) => {
|
|
6294
7069
|
const file = await loadImageSource(args.source, ctx.client);
|
|
@@ -6303,29 +7078,32 @@ var studioUploadBrandReference = defineTool({
|
|
|
6303
7078
|
}
|
|
6304
7079
|
});
|
|
6305
7080
|
var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
|
|
6306
|
-
|
|
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.`
|
|
6307
7082
|
);
|
|
6308
7083
|
var studioRunWorkflow = defineTool({
|
|
6309
7084
|
name: "studio_run_workflow",
|
|
6310
|
-
description: `Run a generation workflow DAG. Pass an inline definition (nodes of provider calls wired by ref bindings; this is what the hosted Studio accepts) or the savedId of a workflow saved in the Studio (the Studio runs that workflow's current document, exactly what the canvas would run). Params fill {kind:"param"} bindings. Returns the runId plus per-node status, URLs and cost; with wait=true (default) it blocks until the run is terminal (succeeded, failed, partial, cancelled). Each node becomes a paid job. Use an inline definition ONLY for the first batch of a new deliverable (one workflow, a node per item, a stable label); a follow-up on an existing item belongs in that saved workflow as a new node (studio_workflow_apply: addNode plus connect from the node it refines) run here with savedId and nodeIds, because every listed inline run is saved as its own workflow.`,
|
|
7085
|
+
description: `Run a generation workflow DAG. Pass an inline definition (nodes of provider calls wired by ref bindings; this is what the hosted Studio accepts) or the savedId of a workflow saved in the Studio (the Studio runs that workflow's current document, exactly what the canvas would run). Params fill {kind:"param"} bindings. Returns the runId plus per-node status, URLs and cost; with wait=true (default) it blocks until the run is terminal (succeeded, failed, partial, cancelled). Each node becomes a paid job. Use an inline definition ONLY for the first batch of a new deliverable (one workflow, a node per item, a stable label); a follow-up on an existing item belongs in that saved workflow as a new node (studio_workflow_apply: addNode plus connect from the node it refines) run here with savedId and nodeIds, because every listed inline run is saved as its own workflow. A clip with both a start and an end frame is checked for continuity before it is paid for (see acknowledgeContinuity).`,
|
|
6311
7086
|
inputSchema: {
|
|
6312
|
-
projectId:
|
|
7087
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6313
7088
|
definition: workflowDefinitionSchema.optional(),
|
|
6314
|
-
savedId:
|
|
6315
|
-
params:
|
|
6316
|
-
nodeIds:
|
|
6317
|
-
upstreamGenerations:
|
|
7089
|
+
savedId: z11.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."),
|
|
7090
|
+
params: z11.record(z11.string(), z11.unknown()).optional().describe("Values for the definition's params."),
|
|
7091
|
+
nodeIds: z11.array(z11.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
|
|
7092
|
+
upstreamGenerations: z11.record(z11.string(), z11.string()).optional().describe(
|
|
6318
7093
|
'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.'
|
|
6319
7094
|
),
|
|
6320
|
-
runs:
|
|
6321
|
-
visibility:
|
|
6322
|
-
budgetUsd:
|
|
7095
|
+
runs: z11.number().int().min(1).max(8).optional().describe("Repeat a node subset N times (1 to 8)."),
|
|
7096
|
+
visibility: z11.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
|
|
7097
|
+
budgetUsd: z11.number().nonnegative().optional().describe(
|
|
6323
7098
|
'S6b: hard cap on the estimated cost, verified server-side before anything is created. An unverifiable estimate (a credits-only or unpriced executing node) refuses too, never proceeds silently. Refusal: { code: "budget_exceeded", estimate }. For `runs`>1 this is the AGGREGATE cap across every iteration.'
|
|
6324
7099
|
),
|
|
6325
|
-
confirm:
|
|
7100
|
+
confirm: z11.boolean().optional().describe(
|
|
6326
7101
|
'S6b: bypasses the confirmation threshold for this one request (a flat $10 today) when the estimate meets or exceeds it. Without this, such a run refuses with { code: "confirmation_required", estimate }.'
|
|
6327
7102
|
),
|
|
6328
|
-
|
|
7103
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
7104
|
+
'Run despite the continuity check. Before a run executes an image-to-video node with BOTH a start frame (inputImageUrl) and an end frame (endImageUrl), the Studio compares the two frames with a vision model (one small paid check per new pair of frames, remembered for your company, so an unchanged pair is never charged twice): a person or a held object in one frame and not the other makes the video model invent or erase it mid-clip. Frames that disagree refuse with { code: "continuity_mismatch", nodes: [{ nodeId, differences }] }; a check that could not run refuses with { code: "continuity_unchecked", nodes: [{ nodeId, reason }] }. Nothing is spent on either. Show the differences to the person you act for and fix the frames; pass true only when they decide to run anyway.'
|
|
7105
|
+
),
|
|
7106
|
+
wait: z11.boolean().default(true),
|
|
6329
7107
|
waitSeconds
|
|
6330
7108
|
},
|
|
6331
7109
|
handler: async (args, ctx) => {
|
|
@@ -6345,7 +7123,8 @@ var studioRunWorkflow = defineTool({
|
|
|
6345
7123
|
...args.savedId ? { savedId: args.savedId } : {},
|
|
6346
7124
|
...args.visibility ? { visibility: args.visibility } : {},
|
|
6347
7125
|
...args.budgetUsd !== void 0 ? { budgetUsd: args.budgetUsd } : {},
|
|
6348
|
-
...args.confirm !== void 0 ? { confirm: args.confirm } : {}
|
|
7126
|
+
...args.confirm !== void 0 ? { confirm: args.confirm } : {},
|
|
7127
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6349
7128
|
});
|
|
6350
7129
|
if (!args.wait) return { runId: started.runId, runIds: started.runIds, status: started.status };
|
|
6351
7130
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
@@ -6356,8 +7135,8 @@ var studioGetRun = defineTool({
|
|
|
6356
7135
|
name: "studio_get_run",
|
|
6357
7136
|
description: "Fetch a workflow run by runId: overall status (pending, running, succeeded, failed, partial, awaiting_decision, cancelled; cancelled means somebody stopped it), total cost, and per-node status, result URL, cost and error message. Set wait=true to block until the run settles. A run at awaiting_decision is parked on a person at a judge node: waiting returns immediately with a `waiting` block naming the node and its candidates, because polling can never clear it; ask the user to choose and submit their answer with studio_decide_judge.",
|
|
6358
7137
|
inputSchema: {
|
|
6359
|
-
runId:
|
|
6360
|
-
wait:
|
|
7138
|
+
runId: z11.string().min(1),
|
|
7139
|
+
wait: z11.boolean().default(false),
|
|
6361
7140
|
waitSeconds
|
|
6362
7141
|
},
|
|
6363
7142
|
annotations: { readOnlyHint: true },
|
|
@@ -6370,11 +7149,11 @@ var studioDecideJudge = defineTool({
|
|
|
6370
7149
|
name: "studio_decide_judge",
|
|
6371
7150
|
description: "Submit a PERSON'S decision on a parked judge node (a run whose status is awaiting_decision). Approving that candidate resumes the run from that node; rejecting fails the node and stops the branch. Never call this on your own judgement: a judge node exists precisely because a human is meant to look, so show them the candidates from studio_get_run's `waiting` block and pass on the answer they give. `candidate.generationId` comes from that same block, and may be omitted only when the node has exactly one candidate.",
|
|
6372
7151
|
inputSchema: {
|
|
6373
|
-
runId:
|
|
6374
|
-
nodeId:
|
|
6375
|
-
verdict:
|
|
6376
|
-
candidate:
|
|
6377
|
-
reason:
|
|
7152
|
+
runId: z11.string().min(1),
|
|
7153
|
+
nodeId: z11.string().min(1),
|
|
7154
|
+
verdict: z11.enum(["approved", "rejected"]),
|
|
7155
|
+
candidate: z11.object({ generationId: z11.string().min(1), index: z11.number().int().min(0).optional() }).optional(),
|
|
7156
|
+
reason: z11.string().max(500).optional()
|
|
6378
7157
|
},
|
|
6379
7158
|
annotations: { destructiveHint: false, idempotentHint: false },
|
|
6380
7159
|
handler: async (args, ctx) => {
|
|
@@ -6390,8 +7169,8 @@ var studioGetRunOutput = defineTool({
|
|
|
6390
7169
|
name: "studio_get_run_output",
|
|
6391
7170
|
description: "Get a FRESH signed URL for one node's output of a workflow run (signed URLs expire; call this when an earlier URL stopped working). Returns url, kind (image, video, model3d) and mime.",
|
|
6392
7171
|
inputSchema: {
|
|
6393
|
-
runId:
|
|
6394
|
-
nodeId:
|
|
7172
|
+
runId: z11.string().min(1),
|
|
7173
|
+
nodeId: z11.string().min(1)
|
|
6395
7174
|
},
|
|
6396
7175
|
annotations: { readOnlyHint: true },
|
|
6397
7176
|
handler: async (args, ctx) => {
|
|
@@ -6403,21 +7182,24 @@ var studioReplaceCharacterInVideo = defineTool({
|
|
|
6403
7182
|
name: "studio_replace_character_in_video",
|
|
6404
7183
|
description: 'Put a minted character into a video shot through the still-swap route: (1) an image-edit node (fal/nano-banana-2-edit) replaces the person in a scene FRAME with the character; (2) an image-to-video node animates that still (default fal/seedance-pro-image-to-video; with endFrameUrl it switches to fal/kling-v2-5-image-to-video and binds the end keyframe so the clip lands on it). Be honest with the user about what this route is: the video step REGENERATES the motion from the stills, so the original performance, timing and background are recreated rather than preserved; when the original motion must survive exactly, say so before spending. Declare scope: identity (default) takes face, head and hair and keeps the footage body; full_body also takes the character body proportions, which changes the silhouette. Pass preserve with the two or three shot-specific constraints most likely to fail, from looking at the frame (e.g. "keep the open door in front of his body", "match the face soft focus"), or a complete swapPrompt of your own. Never add a realism suffix like "photorealistic" or a promise that every pixel stays identical; the model cannot keep either and the suffix sharpens deliberately soft subjects. Give the character as characterSlug (its full-body reference is used, falling back to three-quarter then face) or as an explicit characterReferenceUrl. Requires a frame URL: extract a representative frame from the video yourself first (this tool does not decode video). Waits for both nodes and returns stillUrl, videoUrl, runId and costUsd (what the take cost your company; about $1.05 with the default models on prepaid credits without a subscription). Inspect the still before paying for more takes, keep generated cuts under 5 seconds, and budget one take plus two retries per shot. Do not use video-to-video swap models on dark or handheld footage.',
|
|
6405
7184
|
inputSchema: {
|
|
6406
|
-
projectId:
|
|
7185
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6407
7186
|
sceneFrameUrl: httpUrl.describe("Public or signed URL of ONE frame of the target shot (png/jpg)."),
|
|
6408
7187
|
characterSlug: slug.optional().describe(
|
|
6409
7188
|
"Character to insert: one of your company's, or one another company shared. Its full-body reference (fallback three-quarter, face) is resolved automatically. A slug your company cannot use is a 404 before the run starts, so nothing is spent."
|
|
6410
7189
|
),
|
|
6411
7190
|
characterReferenceUrl: httpUrl.optional().describe("Explicit character reference image URL (use instead of characterSlug)."),
|
|
6412
7191
|
endFrameUrl: httpUrl.optional().describe("Optional second approved keyframe for the END of the clip. Switches the video model to Kling (start + end frame) unless videoModel is set explicitly."),
|
|
6413
|
-
scope:
|
|
6414
|
-
preserve:
|
|
6415
|
-
swapPrompt:
|
|
6416
|
-
motionPrompt:
|
|
6417
|
-
videoModel:
|
|
6418
|
-
editModel:
|
|
6419
|
-
aspectRatio:
|
|
6420
|
-
visibility:
|
|
7192
|
+
scope: z11.enum(SWAP_SCOPES).optional().describe("How much of the person to replace. identity (default): face, head and hair from the character, the footage keeps its body. full_body: also the character body proportions; the silhouette changes, so the background behind the old body and every contact point must be re-derived."),
|
|
7193
|
+
preserve: z11.array(z11.string().min(1).max(200)).max(6).optional().describe('Shot-specific constraints most likely to fail, as concrete relationships seen in the frame, one per entry (e.g. "keep the open door in front of his body"). Appended to the composed prompt.'),
|
|
7194
|
+
swapPrompt: z11.string().optional().describe("A complete still-swap edit prompt of your own; replaces the composed one, so scope and preserve are then ignored."),
|
|
7195
|
+
motionPrompt: z11.string().optional().describe("Override the motion description for the video node."),
|
|
7196
|
+
videoModel: z11.string().optional().describe(`Image-to-video model id. Default ${DEFAULT_SWAP_VIDEO_MODEL}, or ${KEYFRAME_SWAP_VIDEO_MODEL} when endFrameUrl is given.`),
|
|
7197
|
+
editModel: z11.string().default(DEFAULT_SWAP_EDIT_MODEL).describe("Image-edit model id for the still swap."),
|
|
7198
|
+
aspectRatio: z11.string().default("16:9"),
|
|
7199
|
+
visibility: z11.enum(["listed", "unlisted"]).optional(),
|
|
7200
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
7201
|
+
"With endFrameUrl only. The swapped still (the clip's start frame) is compared with the end frame before the clip is paid for; when they do not show the same people and the same objects in their hands, the video node fails with continuity_mismatch and the differences, and nothing is spent on the clip (the still was already made). Fix the end frame, or call again with true when the person you act for decides to run anyway."
|
|
7202
|
+
),
|
|
6421
7203
|
waitSeconds
|
|
6422
7204
|
},
|
|
6423
7205
|
handler: async (args, ctx) => {
|
|
@@ -6453,7 +7235,8 @@ var studioReplaceCharacterInVideo = defineTool({
|
|
|
6453
7235
|
const started = await ctx.client.runWorkflow({
|
|
6454
7236
|
projectId: args.projectId,
|
|
6455
7237
|
definition,
|
|
6456
|
-
...args.visibility ? { visibility: args.visibility } : {}
|
|
7238
|
+
...args.visibility ? { visibility: args.visibility } : {},
|
|
7239
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6457
7240
|
});
|
|
6458
7241
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
6459
7242
|
const stillUrl = nodeUrl(run, SWAP_EDIT_NODE_ID);
|
|
@@ -6482,7 +7265,7 @@ var studioGetSpend = defineTool({
|
|
|
6482
7265
|
name: "studio_get_spend",
|
|
6483
7266
|
description: `Read the spend ledger: total USD and job counts for today, the last 7 days and the last 30 days, plus the most recent paid actions. The amounts are what the company paid (each job's costUsd): for a company on prepaid credits, what left its balance for those jobs. tzOffsetMinutes is the viewer's Date.getTimezoneOffset() so "today" rolls at local midnight (default UTC).`,
|
|
6484
7267
|
inputSchema: {
|
|
6485
|
-
tzOffsetMinutes:
|
|
7268
|
+
tzOffsetMinutes: z11.number().int().min(-840).max(840).optional()
|
|
6486
7269
|
},
|
|
6487
7270
|
annotations: { readOnlyHint: true },
|
|
6488
7271
|
handler: async (args, ctx) => {
|
|
@@ -6510,7 +7293,7 @@ var studioDescribePublished = defineTool({
|
|
|
6510
7293
|
name: "studio_describe_published",
|
|
6511
7294
|
description: "Describe one published recipe by slug: { slug, definition, hasEffects }. definition is the FROZEN workflow (params, node shapes) exactly as it was at publish time, never the live authoring document, which may have moved on since. Read this before studio_run_published to know what params it needs. Free, read-only.",
|
|
6512
7295
|
inputSchema: {
|
|
6513
|
-
slug:
|
|
7296
|
+
slug: z11.string().min(1).describe("The recipe slug, from studio_list_published.")
|
|
6514
7297
|
},
|
|
6515
7298
|
annotations: { readOnlyHint: true },
|
|
6516
7299
|
handler: async (args, ctx) => {
|
|
@@ -6520,19 +7303,22 @@ var studioDescribePublished = defineTool({
|
|
|
6520
7303
|
});
|
|
6521
7304
|
var studioRunPublished = defineTool({
|
|
6522
7305
|
name: "studio_run_published",
|
|
6523
|
-
description: `Run a published recipe by slug. Runs its FROZEN definition (studio_describe_published shows exactly what it needs); params fill the definition's own {kind:"param"} bindings. On success, the recipe's declared post-run effects fire automatically (e.g. character minting creates the character and attaches its reference views); effects never fire on a failed or partial run, by design. A recipe that creates a character (hasEffects, see studio_describe_published) requires likenessRightsConfirmed: true and refuses with { code: "likeness_rights_confirmation_required" } before anything is spent when it is missing. Returns the runId plus per-node status, URLs and cost; with wait=true (default) it blocks until the run is terminal. Each node becomes a paid job. The same $10 confirm-gate as studio_run_workflow applies: an estimate at or over the threshold refuses with { code: "confirmation_required", estimate } unless confirm: true is set.`,
|
|
7306
|
+
description: `Run a published recipe by slug. Runs its FROZEN definition (studio_describe_published shows exactly what it needs); params fill the definition's own {kind:"param"} bindings. On success, the recipe's declared post-run effects fire automatically (e.g. character minting creates the character and attaches its reference views); effects never fire on a failed or partial run, by design. A recipe that creates a character (hasEffects, see studio_describe_published) requires likenessRightsConfirmed: true and refuses with { code: "likeness_rights_confirmation_required" } before anything is spent when it is missing. Returns the runId plus per-node status, URLs and cost; with wait=true (default) it blocks until the run is terminal. Each node becomes a paid job. The same $10 confirm-gate as studio_run_workflow applies: an estimate at or over the threshold refuses with { code: "confirmation_required", estimate } unless confirm: true is set. So does its continuity check before a clip with a start and an end frame (see acknowledgeContinuity).`,
|
|
6524
7307
|
inputSchema: {
|
|
6525
|
-
slug:
|
|
6526
|
-
projectId:
|
|
6527
|
-
params:
|
|
6528
|
-
budgetUsd:
|
|
7308
|
+
slug: z11.string().min(1).describe("The recipe slug, from studio_list_published."),
|
|
7309
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
7310
|
+
params: z11.record(z11.string(), z11.unknown()).optional().describe("Values for the recipe's params (see studio_describe_published)."),
|
|
7311
|
+
budgetUsd: z11.number().nonnegative().optional().describe(
|
|
6529
7312
|
'Hard cap on the estimated cost, verified server-side before anything is created. An unverifiable estimate (a credits-only or unpriced executing node) refuses too. Refusal: { code: "budget_exceeded", estimate }.'
|
|
6530
7313
|
),
|
|
6531
|
-
confirm:
|
|
7314
|
+
confirm: z11.boolean().optional().describe(
|
|
6532
7315
|
'Bypasses the confirmation threshold for this one request (a flat $10 today) when the estimate meets or exceeds it. Without this, such a run refuses with { code: "confirmation_required", estimate }.'
|
|
6533
7316
|
),
|
|
6534
|
-
likenessRightsConfirmed:
|
|
6535
|
-
|
|
7317
|
+
likenessRightsConfirmed: z11.literal(true).optional().describe(`Required when the recipe creates a character; ignored otherwise. ${likenessConfirmationToolDescription()}`),
|
|
7318
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
7319
|
+
'Run despite the continuity check, exactly as on studio_run_workflow: a recipe with an image-to-video node that has both a start and an end frame refuses with { code: "continuity_mismatch", nodes: [{ nodeId, differences }] } or { code: "continuity_unchecked", nodes: [{ nodeId, reason }] } before anything is spent. Pass true only when the person you act for decides to run anyway.'
|
|
7320
|
+
),
|
|
7321
|
+
wait: z11.boolean().default(true),
|
|
6536
7322
|
waitSeconds
|
|
6537
7323
|
},
|
|
6538
7324
|
handler: async (args, ctx) => {
|
|
@@ -6541,7 +7327,8 @@ var studioRunPublished = defineTool({
|
|
|
6541
7327
|
...args.params ? { params: args.params } : {},
|
|
6542
7328
|
...args.budgetUsd !== void 0 ? { budgetUsd: args.budgetUsd } : {},
|
|
6543
7329
|
...args.confirm !== void 0 ? { confirm: args.confirm } : {},
|
|
6544
|
-
...args.likenessRightsConfirmed === true ? { likenessRightsConfirmed: true } : {}
|
|
7330
|
+
...args.likenessRightsConfirmed === true ? { likenessRightsConfirmed: true } : {},
|
|
7331
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6545
7332
|
});
|
|
6546
7333
|
if (!args.wait) return { runId: started.runId, status: started.status };
|
|
6547
7334
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
@@ -6572,7 +7359,8 @@ var TOOLS = [
|
|
|
6572
7359
|
studioRunPublished,
|
|
6573
7360
|
studioGetUsage,
|
|
6574
7361
|
...WORKFLOW_TOOLS,
|
|
6575
|
-
...MANAGE_TOOLS
|
|
7362
|
+
...MANAGE_TOOLS,
|
|
7363
|
+
...COMPOSITION_TOOLS
|
|
6576
7364
|
];
|
|
6577
7365
|
var TOOL_NAMES = TOOLS.map((t) => t.name);
|
|
6578
7366
|
function toolResult(value) {
|
|
@@ -6590,7 +7378,7 @@ function toolError(message) {
|
|
|
6590
7378
|
}
|
|
6591
7379
|
async function invokeTool(def, args, ctx) {
|
|
6592
7380
|
try {
|
|
6593
|
-
const parsed =
|
|
7381
|
+
const parsed = z11.object(def.inputSchema).parse(args ?? {});
|
|
6594
7382
|
const value = await def.handler(parsed, ctx);
|
|
6595
7383
|
return toolResult(value);
|
|
6596
7384
|
} catch (err) {
|
|
@@ -6641,7 +7429,7 @@ function registerTools(server, base) {
|
|
|
6641
7429
|
|
|
6642
7430
|
// src/server.ts
|
|
6643
7431
|
var SERVER_NAME = "lumitra-studio";
|
|
6644
|
-
var SERVER_VERSION = "0.
|
|
7432
|
+
var SERVER_VERSION = "0.9.0";
|
|
6645
7433
|
function createStudioMcpServer(opts = {}) {
|
|
6646
7434
|
const config = opts.config ?? resolveConfig(opts.env ?? process.env);
|
|
6647
7435
|
const client = new StudioClient(config, {
|
|
@@ -6747,7 +7535,7 @@ async function runHttp(args) {
|
|
|
6747
7535
|
});
|
|
6748
7536
|
const addr = httpServer.address();
|
|
6749
7537
|
const port = typeof addr === "object" && addr ? addr.port : args.port;
|
|
6750
|
-
process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${
|
|
7538
|
+
process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${randomUUID4().slice(0, 8)})
|
|
6751
7539
|
`);
|
|
6752
7540
|
const shutdown = () => {
|
|
6753
7541
|
httpServer.close(() => process.exit(0));
|