@marlinjai/studio-mcp 0.7.0 → 0.8.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 +9 -1
- package/dist/cli.js +701 -123
- package/dist/index.d.ts +384 -2
- package/dist/index.js +701 -123
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -257,6 +257,45 @@ var StudioClient = class {
|
|
|
257
257
|
applyWorkflowPatch(savedId2, patch) {
|
|
258
258
|
return this.json("PATCH", `/api/v1/workflows/${encodeURIComponent(savedId2)}`, { json: patch });
|
|
259
259
|
}
|
|
260
|
+
// ── Brand kit and compositions (carousels and reels) ──
|
|
261
|
+
/** A brand's kit: colours, the two type sizes, fonts by role, logos by variant, version. */
|
|
262
|
+
getBrandKit(brandSlug) {
|
|
263
|
+
return this.json("GET", `/api/brands/${encodeURIComponent(brandSlug)}/kit`);
|
|
264
|
+
}
|
|
265
|
+
listCompositions(opts = {}) {
|
|
266
|
+
return this.json("GET", `/api/v1/compositions${projectQuery(opts.projectId)}`);
|
|
267
|
+
}
|
|
268
|
+
/** 201 created; 200 with `replayed: true` when a create with this idempotencyKey already made it. */
|
|
269
|
+
createComposition(body) {
|
|
270
|
+
return this.json("POST", "/api/v1/compositions", { json: body });
|
|
271
|
+
}
|
|
272
|
+
/** A project's assets, newest first, optionally of one subtype (Image, Video, CarouselSlide, Reel, ...). */
|
|
273
|
+
listProjectAssets(projectId, opts = {}) {
|
|
274
|
+
const q = new URLSearchParams();
|
|
275
|
+
if (opts.subtype) q.set("subtype", opts.subtype);
|
|
276
|
+
if (opts.limit) q.set("limit", String(opts.limit));
|
|
277
|
+
const qs = q.toString();
|
|
278
|
+
return this.json("GET", `/api/v1/projects/${encodeURIComponent(projectId)}/assets${qs ? `?${qs}` : ""}`);
|
|
279
|
+
}
|
|
280
|
+
getComposition(compositionId2) {
|
|
281
|
+
return this.json("GET", `/api/v1/compositions/${encodeURIComponent(compositionId2)}`);
|
|
282
|
+
}
|
|
283
|
+
/** 409 stale_revision (with the current composition) or idempotency_mismatch; 422 invalid_patch. */
|
|
284
|
+
patchComposition(compositionId2, patch) {
|
|
285
|
+
return this.json("PATCH", `/api/v1/compositions/${encodeURIComponent(compositionId2)}`, { json: patch });
|
|
286
|
+
}
|
|
287
|
+
/** The company's Lumitra Social projects (409 not_connected / link_broken until an owner connects it in Studio). */
|
|
288
|
+
listSocialProjects(brandSlug) {
|
|
289
|
+
return this.json("GET", `/api/v1/social/projects${brandSlug ? `?brandSlug=${encodeURIComponent(brandSlug)}` : ""}`);
|
|
290
|
+
}
|
|
291
|
+
/** Send the rendered post to Lumitra Social; idempotent on `idempotencyKey`. */
|
|
292
|
+
sendCompositionToSocial(compositionId2, body) {
|
|
293
|
+
return this.json("POST", `/api/v1/compositions/${encodeURIComponent(compositionId2)}/send`, { json: body });
|
|
294
|
+
}
|
|
295
|
+
/** Start (or join) a render. 422 not_ready with `reasons`; 429 render_limit or render_busy (a reel of this company is rendering). */
|
|
296
|
+
renderComposition(compositionId2) {
|
|
297
|
+
return this.json("POST", `/api/v1/compositions/${encodeURIComponent(compositionId2)}/render`);
|
|
298
|
+
}
|
|
260
299
|
/** Stateless dry-run of ops and run params against a document. No side effects. */
|
|
261
300
|
validateWorkflow(body) {
|
|
262
301
|
return this.json("POST", "/api/v1/workflows/validate", { json: body });
|
|
@@ -464,7 +503,7 @@ function resolveConfig(env = process.env) {
|
|
|
464
503
|
}
|
|
465
504
|
|
|
466
505
|
// src/tools.ts
|
|
467
|
-
import { z as
|
|
506
|
+
import { z as z11 } from "zod";
|
|
468
507
|
|
|
469
508
|
// ../lumitra-core/dist/models/index.js
|
|
470
509
|
var veo = (tier, label) => {
|
|
@@ -4095,7 +4134,7 @@ function portBinding(task, port) {
|
|
|
4095
4134
|
if (port === "video" && task === "video-enhance") {
|
|
4096
4135
|
return { key: "draftCacheUrl", path: "draftCacheUrl" };
|
|
4097
4136
|
}
|
|
4098
|
-
if (port === "image" && task === "image-edit") {
|
|
4137
|
+
if (port === "image" && (task === "image-edit" || task === "image-to-image")) {
|
|
4099
4138
|
return { key: "inputImages", path: "url", wrap: "array" };
|
|
4100
4139
|
}
|
|
4101
4140
|
if (port === "text" && taskNeedsPrompt(task)) {
|
|
@@ -4118,7 +4157,7 @@ function canConnect(sourceOut, targetTask, targetPort) {
|
|
|
4118
4157
|
}
|
|
4119
4158
|
function portCardinality(task, port, model) {
|
|
4120
4159
|
if (portBinding(task, port) === null) return "none";
|
|
4121
|
-
if (port === "image" && task === "image-edit") return "many";
|
|
4160
|
+
if (port === "image" && (task === "image-edit" || task === "image-to-image")) return "many";
|
|
4122
4161
|
if (port === "image" && task === "image-to-video") {
|
|
4123
4162
|
return modelAcceptsKeyframes(model) ? "many" : "two";
|
|
4124
4163
|
}
|
|
@@ -5666,9 +5705,535 @@ var WORKFLOW_TOOLS = [
|
|
|
5666
5705
|
studioWorkflowScreenshot
|
|
5667
5706
|
];
|
|
5668
5707
|
|
|
5669
|
-
// src/
|
|
5708
|
+
// src/compositionTools.ts
|
|
5670
5709
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5710
|
+
import { z as z9 } from "zod";
|
|
5711
|
+
|
|
5712
|
+
// ../lumitra-core/dist/composition/index.js
|
|
5713
|
+
import { z as z22 } from "zod";
|
|
5671
5714
|
import { z as z8 } from "zod";
|
|
5715
|
+
import { z as z32 } from "zod";
|
|
5716
|
+
var BRAND_KIT_MAX_COLORS = 6;
|
|
5717
|
+
var BRAND_KIT_FONT_ROLES = ["primary", "secondary"];
|
|
5718
|
+
var BRAND_KIT_TYPE_ROLES = ["headline", "body"];
|
|
5719
|
+
var BRAND_KIT_LOGO_VARIANTS = ["light", "dark"];
|
|
5720
|
+
var BRAND_KIT_TYPE_PX_MIN = 12;
|
|
5721
|
+
var BRAND_KIT_TYPE_PX_MAX = 200;
|
|
5722
|
+
var HEX = /^#[0-9a-f]{6}$/i;
|
|
5723
|
+
var COLOR_ID = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
5724
|
+
var BrandKitColorSchema = z8.object({
|
|
5725
|
+
/** Stable id an overlay refers to; survives a rename of the colour. */
|
|
5726
|
+
id: z8.string().regex(COLOR_ID, "a colour id is lowercase letters, digits and hyphens"),
|
|
5727
|
+
name: z8.string().trim().min(1, "a colour needs a name").max(40),
|
|
5728
|
+
hex: z8.string().regex(HEX, "a colour is a hex value like #1a2b3c")
|
|
5729
|
+
}).strict();
|
|
5730
|
+
var TypeSizeSchema = z8.object({
|
|
5731
|
+
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`)
|
|
5732
|
+
}).strict();
|
|
5733
|
+
var BrandKitTypeRolesSchema = z8.object({ headline: TypeSizeSchema, body: TypeSizeSchema }).strict().refine((t) => t.headline.px > t.body.px, {
|
|
5734
|
+
message: "the headline size must be larger than the body size",
|
|
5735
|
+
path: ["headline", "px"]
|
|
5736
|
+
});
|
|
5737
|
+
var BrandKitTokensSchema = z8.object({
|
|
5738
|
+
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) => {
|
|
5739
|
+
const ids = /* @__PURE__ */ new Set();
|
|
5740
|
+
const names = /* @__PURE__ */ new Set();
|
|
5741
|
+
colors.forEach((c, i) => {
|
|
5742
|
+
if (ids.has(c.id)) ctx.addIssue({ code: "custom", message: `colour id "${c.id}" is used twice`, path: [i, "id"] });
|
|
5743
|
+
const name = c.name.trim().toLowerCase();
|
|
5744
|
+
if (names.has(name)) ctx.addIssue({ code: "custom", message: `colour name "${c.name}" is used twice`, path: [i, "name"] });
|
|
5745
|
+
ids.add(c.id);
|
|
5746
|
+
names.add(name);
|
|
5747
|
+
});
|
|
5748
|
+
}),
|
|
5749
|
+
typeRoles: BrandKitTypeRolesSchema
|
|
5750
|
+
}).strict();
|
|
5751
|
+
var BrandKitFontFileMetaSchema = z8.object({
|
|
5752
|
+
weight: z8.number().int().min(100).max(900).refine((w) => w % 100 === 0, "a font weight is a multiple of 100"),
|
|
5753
|
+
style: z8.enum(["normal", "italic"])
|
|
5754
|
+
}).strict();
|
|
5755
|
+
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");
|
|
5756
|
+
var COMPOSITION_SCHEMA_VERSION = 1;
|
|
5757
|
+
var COMPOSITION_KINDS = ["carousel", "reel"];
|
|
5758
|
+
var COMPOSITION_ASPECTS = ["4:5", "1:1", "9:16"];
|
|
5759
|
+
var MAX_CAROUSEL_SLIDES = 10;
|
|
5760
|
+
var REEL_MIN_SECONDS = 3;
|
|
5761
|
+
var REEL_MAX_SECONDS = 90;
|
|
5762
|
+
var MIN_CLIP_SECONDS = 0.5;
|
|
5763
|
+
var MAX_REEL_CLIPS = 30;
|
|
5764
|
+
var MAX_OVERLAYS_PER_ITEM = 20;
|
|
5765
|
+
var MAX_REEL_OVERLAYS = 40;
|
|
5766
|
+
var MAX_OVERLAY_TEXT = 500;
|
|
5767
|
+
var MIN_BOX_SIDE = 0.02;
|
|
5768
|
+
var ID = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
|
|
5769
|
+
var CompositionIdSchema = z22.string().regex(ID, "an id is letters, digits and _ . : -");
|
|
5770
|
+
var COLOR_ROLE = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/, "a colour is named by its kit id");
|
|
5771
|
+
var unit = z22.number().min(0).max(1);
|
|
5772
|
+
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");
|
|
5773
|
+
var TimingShape = {
|
|
5774
|
+
start: z22.number().min(0).optional(),
|
|
5775
|
+
end: z22.number().positive().optional()
|
|
5776
|
+
};
|
|
5777
|
+
var TextOverlaySchema = z22.object({
|
|
5778
|
+
id: CompositionIdSchema,
|
|
5779
|
+
type: z22.literal("text"),
|
|
5780
|
+
box: BoxSchema,
|
|
5781
|
+
text: z22.string().min(1, "a text overlay needs text").max(MAX_OVERLAY_TEXT),
|
|
5782
|
+
styleRole: z22.enum(BRAND_KIT_TYPE_ROLES),
|
|
5783
|
+
fontRole: z22.enum(BRAND_KIT_FONT_ROLES),
|
|
5784
|
+
weight: z22.number().int().min(100).max(900),
|
|
5785
|
+
italic: z22.boolean(),
|
|
5786
|
+
colorRole: COLOR_ROLE,
|
|
5787
|
+
align: z22.enum(["left", "center", "right"]),
|
|
5788
|
+
/** A colour chip behind the text, for legibility on busy images. */
|
|
5789
|
+
background: z22.object({ colorRole: COLOR_ROLE, opacity: unit, padding: z22.number().min(0).max(0.1) }).strict().optional(),
|
|
5790
|
+
...TimingShape
|
|
5791
|
+
}).strict();
|
|
5792
|
+
var LogoOverlaySchema = z22.object({
|
|
5793
|
+
id: CompositionIdSchema,
|
|
5794
|
+
type: z22.literal("logo"),
|
|
5795
|
+
box: BoxSchema,
|
|
5796
|
+
variant: z22.enum(BRAND_KIT_LOGO_VARIANTS),
|
|
5797
|
+
...TimingShape
|
|
5798
|
+
}).strict();
|
|
5799
|
+
var ShapeOverlaySchema = z22.object({
|
|
5800
|
+
id: CompositionIdSchema,
|
|
5801
|
+
type: z22.literal("shape"),
|
|
5802
|
+
box: BoxSchema,
|
|
5803
|
+
shape: z22.enum(["rect", "pill"]),
|
|
5804
|
+
colorRole: COLOR_ROLE,
|
|
5805
|
+
opacity: unit,
|
|
5806
|
+
...TimingShape
|
|
5807
|
+
}).strict();
|
|
5808
|
+
var OverlaySchema = z22.discriminatedUnion("type", [TextOverlaySchema, LogoOverlaySchema, ShapeOverlaySchema]);
|
|
5809
|
+
var SlideSchema = z22.object({
|
|
5810
|
+
id: CompositionIdSchema,
|
|
5811
|
+
type: z22.literal("slide"),
|
|
5812
|
+
background: z22.object({
|
|
5813
|
+
/** A Studio image asset of the composition's project. */
|
|
5814
|
+
assetId: CompositionIdSchema.optional(),
|
|
5815
|
+
fit: z22.enum(["cover", "contain"]),
|
|
5816
|
+
/** The point of the image kept in view when `cover` crops it. */
|
|
5817
|
+
focal: z22.object({ x: unit, y: unit }).strict(),
|
|
5818
|
+
/** A kit colour behind the image (or instead of one). */
|
|
5819
|
+
fill: COLOR_ROLE.optional()
|
|
5820
|
+
}).strict().refine((b) => b.assetId !== void 0 || b.fill !== void 0, "a slide needs an image or a fill colour"),
|
|
5821
|
+
overlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
5822
|
+
}).strict();
|
|
5823
|
+
var ClipSchema = z22.object({
|
|
5824
|
+
id: CompositionIdSchema,
|
|
5825
|
+
type: z22.literal("clip"),
|
|
5826
|
+
/** A Studio video asset of the composition's project. */
|
|
5827
|
+
assetId: CompositionIdSchema,
|
|
5828
|
+
/** Seconds into the source clip. */
|
|
5829
|
+
trimIn: z22.number().min(0),
|
|
5830
|
+
trimOut: z22.number().positive(),
|
|
5831
|
+
overlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
5832
|
+
}).strict().refine((c) => c.trimOut - c.trimIn >= MIN_CLIP_SECONDS - 1e-9, `a clip is at least ${MIN_CLIP_SECONDS} s after trimming`);
|
|
5833
|
+
var ItemSchema = z22.union([SlideSchema, ClipSchema]);
|
|
5834
|
+
var CompositionDocumentSchema = z22.object({
|
|
5835
|
+
schema: z22.literal(COMPOSITION_SCHEMA_VERSION),
|
|
5836
|
+
kind: z22.enum(COMPOSITION_KINDS),
|
|
5837
|
+
aspect: z22.enum(COMPOSITION_ASPECTS),
|
|
5838
|
+
label: z22.string().max(200),
|
|
5839
|
+
/** The brand whose kit the overlays use. */
|
|
5840
|
+
brandSlug: z22.string().min(1).max(64),
|
|
5841
|
+
/** The kit version the document was last edited against; a newer kit is worth a look before rendering. */
|
|
5842
|
+
kitVersionAtEdit: z22.number().int().nonnegative(),
|
|
5843
|
+
items: z22.array(ItemSchema),
|
|
5844
|
+
/** Overlays across the whole reel (a logo bug, an end card line). Always empty on a carousel. */
|
|
5845
|
+
reelOverlays: z22.array(OverlaySchema).max(MAX_OVERLAYS_PER_ITEM)
|
|
5846
|
+
}).strict();
|
|
5847
|
+
var REEL_TARGET = "reel";
|
|
5848
|
+
var TargetSchema = z32.string().min(1).max(128);
|
|
5849
|
+
var index = z32.number().int().nonnegative();
|
|
5850
|
+
var PropsSchema = z32.record(z32.string(), z32.unknown());
|
|
5851
|
+
var SetMetaOpSchema = z32.object({
|
|
5852
|
+
type: z32.literal("setMeta"),
|
|
5853
|
+
props: z32.object({
|
|
5854
|
+
label: z32.string().max(200).optional(),
|
|
5855
|
+
aspect: z32.enum(COMPOSITION_ASPECTS).optional(),
|
|
5856
|
+
kitVersionAtEdit: z32.number().int().nonnegative().optional()
|
|
5857
|
+
}).strict()
|
|
5858
|
+
}).strict();
|
|
5859
|
+
var AddItemOpSchema = z32.object({ type: z32.literal("addItem"), item: ItemSchema, index: index.optional() }).strict();
|
|
5860
|
+
var RemoveItemOpSchema = z32.object({ type: z32.literal("removeItem"), itemId: CompositionIdSchema }).strict();
|
|
5861
|
+
var MoveItemOpSchema = z32.object({ type: z32.literal("moveItem"), itemId: CompositionIdSchema, index }).strict();
|
|
5862
|
+
var SetItemPropsOpSchema = z32.object({ type: z32.literal("setItemProps"), itemId: CompositionIdSchema, props: PropsSchema }).strict();
|
|
5863
|
+
var AddOverlayOpSchema = z32.object({ type: z32.literal("addOverlay"), target: TargetSchema, overlay: OverlaySchema, index: index.optional() }).strict();
|
|
5864
|
+
var RemoveOverlayOpSchema = z32.object({ type: z32.literal("removeOverlay"), target: TargetSchema, overlayId: CompositionIdSchema }).strict();
|
|
5865
|
+
var MoveOverlayOpSchema = z32.object({
|
|
5866
|
+
type: z32.literal("moveOverlay"),
|
|
5867
|
+
target: TargetSchema,
|
|
5868
|
+
overlayId: CompositionIdSchema,
|
|
5869
|
+
/** Another item (or the reel) to move it to; omitted keeps it where it is. */
|
|
5870
|
+
toTarget: TargetSchema.optional(),
|
|
5871
|
+
/** Stacking position in the destination: 0 is at the back. */
|
|
5872
|
+
index
|
|
5873
|
+
}).strict();
|
|
5874
|
+
var SetOverlayPropsOpSchema = z32.object({ type: z32.literal("setOverlayProps"), target: TargetSchema, overlayId: CompositionIdSchema, props: PropsSchema }).strict();
|
|
5875
|
+
var CompositionOpSchema = z32.discriminatedUnion("type", [
|
|
5876
|
+
SetMetaOpSchema,
|
|
5877
|
+
AddItemOpSchema,
|
|
5878
|
+
RemoveItemOpSchema,
|
|
5879
|
+
MoveItemOpSchema,
|
|
5880
|
+
SetItemPropsOpSchema,
|
|
5881
|
+
AddOverlayOpSchema,
|
|
5882
|
+
RemoveOverlayOpSchema,
|
|
5883
|
+
MoveOverlayOpSchema,
|
|
5884
|
+
SetOverlayPropsOpSchema
|
|
5885
|
+
]);
|
|
5886
|
+
var COMPOSITION_OP_TYPES = CompositionOpSchema.options.map((o) => o.shape.type.value);
|
|
5887
|
+
var MAX_COMPOSITION_PATCH_OPS = 200;
|
|
5888
|
+
var CompositionPatchSchema = z32.object({
|
|
5889
|
+
baseRevision: z32.number().int().nonnegative(),
|
|
5890
|
+
ops: z32.array(CompositionOpSchema).min(1).max(MAX_COMPOSITION_PATCH_OPS),
|
|
5891
|
+
idempotencyKey: z32.string().min(1).max(128).optional()
|
|
5892
|
+
}).strict();
|
|
5893
|
+
|
|
5894
|
+
// src/compositionTools.ts
|
|
5895
|
+
var compositionId = z9.string().min(1).describe("The composition id, from studio_composition_create or studio_composition_list.");
|
|
5896
|
+
var opsSchema2 = z9.array(CompositionOpSchema).min(1).max(MAX_COMPOSITION_PATCH_OPS).describe(
|
|
5897
|
+
`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.`
|
|
5898
|
+
);
|
|
5899
|
+
function isRecord2(v) {
|
|
5900
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5901
|
+
}
|
|
5902
|
+
function summarize(c) {
|
|
5903
|
+
const doc = c.document;
|
|
5904
|
+
return {
|
|
5905
|
+
id: c.id,
|
|
5906
|
+
projectId: c.projectId,
|
|
5907
|
+
kind: c.kind,
|
|
5908
|
+
label: c.label,
|
|
5909
|
+
brandSlug: c.brandSlug,
|
|
5910
|
+
revision: c.revision,
|
|
5911
|
+
aspect: doc.aspect,
|
|
5912
|
+
kitVersionAtEdit: doc.kitVersionAtEdit,
|
|
5913
|
+
items: doc.items,
|
|
5914
|
+
...doc.kind === "reel" ? { reelOverlays: doc.reelOverlays } : {}
|
|
5915
|
+
};
|
|
5916
|
+
}
|
|
5917
|
+
function mapCompositionFailure(err, ctx, idempotencyKey) {
|
|
5918
|
+
if (!(err instanceof StudioApiError)) return null;
|
|
5919
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
5920
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
5921
|
+
const message = typeof body.message === "string" ? ctx.client.redact(body.message) : null;
|
|
5922
|
+
if (err.status === 409 && code === "stale_revision" && isRecord2(body.composition)) {
|
|
5923
|
+
return {
|
|
5924
|
+
ok: false,
|
|
5925
|
+
code,
|
|
5926
|
+
revision: body.revision,
|
|
5927
|
+
composition: summarize(body.composition),
|
|
5928
|
+
hint: "Someone else changed it. Rebase your ops on the composition returned here and apply again with its revision and a NEW idempotencyKey."
|
|
5929
|
+
};
|
|
5930
|
+
}
|
|
5931
|
+
if (err.status === 409 && code === "idempotency_mismatch") {
|
|
5932
|
+
return { ok: false, code, message, hint: "That idempotencyKey belongs to a different patch: send this one with a new key." };
|
|
5933
|
+
}
|
|
5934
|
+
if (err.status === 422 && (code === "invalid_patch" || code === "not_ready")) {
|
|
5935
|
+
return {
|
|
5936
|
+
ok: false,
|
|
5937
|
+
code,
|
|
5938
|
+
...isRecord2(body.error) ? { error: body.error } : {},
|
|
5939
|
+
...Array.isArray(body.reasons) ? { reasons: body.reasons } : {},
|
|
5940
|
+
message,
|
|
5941
|
+
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)."
|
|
5942
|
+
};
|
|
5943
|
+
}
|
|
5944
|
+
if (err.status === 429 && code === "render_limit") return { ok: false, code, message };
|
|
5945
|
+
if (err.status === 429 && code === "render_busy") {
|
|
5946
|
+
return {
|
|
5947
|
+
ok: false,
|
|
5948
|
+
code,
|
|
5949
|
+
message,
|
|
5950
|
+
...typeof body.jobId === "string" ? { jobId: body.jobId } : {},
|
|
5951
|
+
hint: "One reel renders at a time per company. Wait for that render (studio_get_job with the jobId), then render this one."
|
|
5952
|
+
};
|
|
5953
|
+
}
|
|
5954
|
+
if (err.status === 404) return { ok: false, code: code ?? "not_found", message: message ?? "Not found in this company." };
|
|
5955
|
+
if (idempotencyKey && (err.status === 0 || err.status >= 500)) {
|
|
5956
|
+
return {
|
|
5957
|
+
ok: false,
|
|
5958
|
+
code: err.status === 0 ? "network_error" : "server_error",
|
|
5959
|
+
message: ctx.client.redact(err.message),
|
|
5960
|
+
idempotencyKey,
|
|
5961
|
+
hint: "The outcome is unknown. Retry with the SAME idempotencyKey: if the patch was applied, the retry replays it instead of applying twice."
|
|
5962
|
+
};
|
|
5963
|
+
}
|
|
5964
|
+
return null;
|
|
5965
|
+
}
|
|
5966
|
+
var studioListAssets = defineTool({
|
|
5967
|
+
name: "studio_list_assets",
|
|
5968
|
+
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.",
|
|
5969
|
+
inputSchema: {
|
|
5970
|
+
projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
|
|
5971
|
+
subtype: z9.enum(["Image", "Video", "CarouselSlide", "Reel"]).optional().describe("Only this kind: Image for slide backgrounds, Video for reel clips."),
|
|
5972
|
+
limit: z9.number().int().min(1).max(200).optional().describe("At most this many (default 50).")
|
|
5973
|
+
},
|
|
5974
|
+
handler: async (args, ctx) => {
|
|
5975
|
+
const { assets } = await ctx.client.listProjectAssets(args.projectId, {
|
|
5976
|
+
...args.subtype ? { subtype: args.subtype } : {},
|
|
5977
|
+
...args.limit ? { limit: args.limit } : {}
|
|
5978
|
+
});
|
|
5979
|
+
return {
|
|
5980
|
+
projectId: args.projectId,
|
|
5981
|
+
assets: assets.map((a) => {
|
|
5982
|
+
const seconds = typeof a.metadata?.durationSeconds === "number" ? a.metadata.durationSeconds : typeof a.metadata?.durationMs === "number" ? a.metadata.durationMs / 1e3 : void 0;
|
|
5983
|
+
return {
|
|
5984
|
+
id: a.id,
|
|
5985
|
+
subtype: a.subtype,
|
|
5986
|
+
url: a.url,
|
|
5987
|
+
mimeType: a.mimeType,
|
|
5988
|
+
prompt: a.prompt,
|
|
5989
|
+
...seconds !== void 0 ? { durationSeconds: seconds } : {},
|
|
5990
|
+
createdAt: a.createdAt
|
|
5991
|
+
};
|
|
5992
|
+
})
|
|
5993
|
+
};
|
|
5994
|
+
}
|
|
5995
|
+
});
|
|
5996
|
+
var studioBrandKitGet = defineTool({
|
|
5997
|
+
name: "studio_brand_kit_get",
|
|
5998
|
+
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.",
|
|
5999
|
+
inputSchema: { brandSlug: z9.string().min(1).describe("The brand slug, as studio_create_brand made it.") },
|
|
6000
|
+
handler: async (args, ctx) => {
|
|
6001
|
+
const { kit } = await ctx.client.getBrandKit(args.brandSlug);
|
|
6002
|
+
return {
|
|
6003
|
+
brandSlug: args.brandSlug,
|
|
6004
|
+
version: kit.version,
|
|
6005
|
+
colors: kit.colors,
|
|
6006
|
+
typeRoles: kit.typeRoles,
|
|
6007
|
+
fonts: kit.fonts.map((f) => ({ role: f.role, family: f.family, files: f.files.map((x) => ({ weight: x.weight, style: x.style })) })),
|
|
6008
|
+
logos: kit.logos.map((l) => ({ variant: l.variant, width: l.width, height: l.height }))
|
|
6009
|
+
};
|
|
6010
|
+
}
|
|
6011
|
+
});
|
|
6012
|
+
var studioCompositionDescribe = defineTool({
|
|
6013
|
+
name: "studio_composition_describe",
|
|
6014
|
+
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.",
|
|
6015
|
+
inputSchema: {},
|
|
6016
|
+
handler: async () => ({
|
|
6017
|
+
kinds: COMPOSITION_KINDS,
|
|
6018
|
+
aspects: COMPOSITION_ASPECTS,
|
|
6019
|
+
limits: {
|
|
6020
|
+
carouselSlides: MAX_CAROUSEL_SLIDES,
|
|
6021
|
+
reelClips: MAX_REEL_CLIPS,
|
|
6022
|
+
reelSeconds: { min: REEL_MIN_SECONDS, max: REEL_MAX_SECONDS },
|
|
6023
|
+
overlaysPerItem: MAX_OVERLAYS_PER_ITEM,
|
|
6024
|
+
overlaysPerReel: MAX_REEL_OVERLAYS,
|
|
6025
|
+
reelRendersAtOnce: 1,
|
|
6026
|
+
opsPerPatch: MAX_COMPOSITION_PATCH_OPS
|
|
6027
|
+
},
|
|
6028
|
+
opTypes: COMPOSITION_OP_TYPES,
|
|
6029
|
+
shapes: {
|
|
6030
|
+
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)',
|
|
6031
|
+
clip: '{ id, type: "clip", assetId (a video asset of the project), trimIn, trimOut (seconds), overlays: [] }',
|
|
6032
|
+
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) }',
|
|
6033
|
+
logo: '{ id, type: "logo", box, variant: "light"|"dark", start?, end? }',
|
|
6034
|
+
shape: '{ id, type: "shape", box, shape: "rect"|"pill", colorRole, opacity, start?, end? }'
|
|
6035
|
+
},
|
|
6036
|
+
targets: `addOverlay, removeOverlay, moveOverlay and setOverlayProps name a target: an item id, or "${REEL_TARGET}" for an overlay across the whole reel.`,
|
|
6037
|
+
rules: [
|
|
6038
|
+
"There is no field for a hex colour, a font family or a pixel size: overlays name kit roles (studio_brand_kit_get).",
|
|
6039
|
+
"Overlays stack in list order; the last is on top.",
|
|
6040
|
+
"A carousel is 4:5 or 1:1, at most 10 slides; a reel is 9:16, 3 to 90 s.",
|
|
6041
|
+
"Setting an optional field to null clears it.",
|
|
6042
|
+
"Rendering is free: studio_composition_render."
|
|
6043
|
+
]
|
|
6044
|
+
})
|
|
6045
|
+
});
|
|
6046
|
+
var studioCompositionList = defineTool({
|
|
6047
|
+
name: "studio_composition_list",
|
|
6048
|
+
description: "List a project's carousels and reels, newest first. Free, read-only.",
|
|
6049
|
+
inputSchema: { projectId: z9.string().min(1).optional().describe("Project id from studio_list_projects; omit for the default project.") },
|
|
6050
|
+
handler: async (args, ctx) => ctx.client.listCompositions(args.projectId !== void 0 ? { projectId: args.projectId } : {})
|
|
6051
|
+
});
|
|
6052
|
+
var studioCompositionCreate = defineTool({
|
|
6053
|
+
name: "studio_composition_create",
|
|
6054
|
+
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.",
|
|
6055
|
+
inputSchema: {
|
|
6056
|
+
kind: z9.enum(COMPOSITION_KINDS),
|
|
6057
|
+
brandSlug: z9.string().min(1).describe("The brand whose kit the overlays use."),
|
|
6058
|
+
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."),
|
|
6059
|
+
aspect: z9.enum(COMPOSITION_ASPECTS).optional().describe("4:5 (default for a carousel) or 1:1; a reel is 9:16."),
|
|
6060
|
+
label: z9.string().max(200).optional(),
|
|
6061
|
+
ops: z9.array(CompositionOpSchema).max(MAX_COMPOSITION_PATCH_OPS).optional(),
|
|
6062
|
+
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.")
|
|
6063
|
+
},
|
|
6064
|
+
handler: async (args, ctx) => {
|
|
6065
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6066
|
+
try {
|
|
6067
|
+
const { composition, replayed } = await ctx.client.createComposition({
|
|
6068
|
+
idempotencyKey,
|
|
6069
|
+
kind: args.kind,
|
|
6070
|
+
brandSlug: args.brandSlug,
|
|
6071
|
+
...args.projectId !== void 0 ? { projectId: args.projectId } : {},
|
|
6072
|
+
...args.aspect !== void 0 ? { aspect: args.aspect } : {},
|
|
6073
|
+
...args.label !== void 0 ? { label: args.label } : {},
|
|
6074
|
+
...args.ops !== void 0 ? { ops: args.ops } : {}
|
|
6075
|
+
});
|
|
6076
|
+
return { ok: true, composition: summarize(composition), ...replayed ? { replayed: true } : {} };
|
|
6077
|
+
} catch (err) {
|
|
6078
|
+
const mapped = mapCompositionFailure(err, ctx, idempotencyKey);
|
|
6079
|
+
if (mapped) return mapped;
|
|
6080
|
+
throw err;
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
});
|
|
6084
|
+
var studioCompositionGet = defineTool({
|
|
6085
|
+
name: "studio_composition_get",
|
|
6086
|
+
description: "Read one carousel or reel: its items, overlays and the revision to build the next patch on. Free, read-only.",
|
|
6087
|
+
inputSchema: { compositionId },
|
|
6088
|
+
handler: async (args, ctx) => {
|
|
6089
|
+
try {
|
|
6090
|
+
return { ok: true, composition: summarize((await ctx.client.getComposition(args.compositionId)).composition) };
|
|
6091
|
+
} catch (err) {
|
|
6092
|
+
const mapped = mapCompositionFailure(err, ctx);
|
|
6093
|
+
if (mapped) return mapped;
|
|
6094
|
+
throw err;
|
|
6095
|
+
}
|
|
6096
|
+
}
|
|
6097
|
+
});
|
|
6098
|
+
var studioCompositionApply = defineTool({
|
|
6099
|
+
name: "studio_composition_apply",
|
|
6100
|
+
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).",
|
|
6101
|
+
inputSchema: {
|
|
6102
|
+
compositionId,
|
|
6103
|
+
baseRevision: z9.number().int().nonnegative().describe("The revision the ops were written against."),
|
|
6104
|
+
ops: opsSchema2,
|
|
6105
|
+
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.")
|
|
6106
|
+
},
|
|
6107
|
+
handler: async (args, ctx) => {
|
|
6108
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6109
|
+
try {
|
|
6110
|
+
const res = await ctx.client.patchComposition(args.compositionId, { baseRevision: args.baseRevision, ops: args.ops, idempotencyKey });
|
|
6111
|
+
return { ok: true, composition: summarize(res.composition), inverse: res.inverse, idempotencyKey, replayed: res.replayed === true };
|
|
6112
|
+
} catch (err) {
|
|
6113
|
+
const mapped = mapCompositionFailure(err, ctx, idempotencyKey);
|
|
6114
|
+
if (mapped) return mapped;
|
|
6115
|
+
throw err;
|
|
6116
|
+
}
|
|
6117
|
+
}
|
|
6118
|
+
});
|
|
6119
|
+
var studioCompositionRender = defineTool({
|
|
6120
|
+
name: "studio_composition_render",
|
|
6121
|
+
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.`,
|
|
6122
|
+
inputSchema: {
|
|
6123
|
+
compositionId,
|
|
6124
|
+
wait: z9.boolean().default(true),
|
|
6125
|
+
waitSeconds: z9.number().int().min(1).max(3600).default(600)
|
|
6126
|
+
},
|
|
6127
|
+
handler: async (args, ctx) => {
|
|
6128
|
+
let started;
|
|
6129
|
+
try {
|
|
6130
|
+
started = await ctx.client.renderComposition(args.compositionId);
|
|
6131
|
+
} catch (err) {
|
|
6132
|
+
const mapped = mapCompositionFailure(err, ctx);
|
|
6133
|
+
if (mapped) return mapped;
|
|
6134
|
+
throw err;
|
|
6135
|
+
}
|
|
6136
|
+
if (!args.wait) return { ok: true, jobId: started.jobId, reused: started.reused, status: "pending" };
|
|
6137
|
+
const res = await waitForJob(ctx.client, started.jobId, { timeoutMs: args.waitSeconds * 1e3 });
|
|
6138
|
+
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));
|
|
6139
|
+
if (res.job.status !== "succeeded") {
|
|
6140
|
+
return { ok: false, code: "render_failed", jobId: started.jobId, status: res.job.status, message: res.job.errorMessage ? ctx.client.redact(res.job.errorMessage) : null };
|
|
6141
|
+
}
|
|
6142
|
+
return { ok: true, jobId: started.jobId, reused: started.reused, status: res.job.status, assets };
|
|
6143
|
+
}
|
|
6144
|
+
});
|
|
6145
|
+
var SOCIAL_HINTS = {
|
|
6146
|
+
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.",
|
|
6147
|
+
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.",
|
|
6148
|
+
not_rendered: "Render the post as it is now (studio_composition_render), then send again with a NEW idempotencyKey.",
|
|
6149
|
+
idempotency_mismatch: "That idempotencyKey belongs to a different send: use a new one.",
|
|
6150
|
+
social_refused: "Lumitra Social refused it; the message says why (an unknown project slug, for one). Fix that and send with a NEW idempotencyKey.",
|
|
6151
|
+
invalid_body: "Fix the field the message names (a time in the past, for one) and send with a NEW idempotencyKey."
|
|
6152
|
+
};
|
|
6153
|
+
var studioSocialListProjects = defineTool({
|
|
6154
|
+
name: "studio_social_list_projects",
|
|
6155
|
+
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).",
|
|
6156
|
+
inputSchema: {
|
|
6157
|
+
brandSlug: z9.string().min(1).optional().describe("The brand of the post, to learn which project it went to last.")
|
|
6158
|
+
},
|
|
6159
|
+
handler: async (args, ctx) => {
|
|
6160
|
+
try {
|
|
6161
|
+
const { projects, lastProjectSlug } = await ctx.client.listSocialProjects(args.brandSlug);
|
|
6162
|
+
return { ok: true, projects: projects.map((p) => ({ slug: p.slug, name: p.name, igHandle: p.igHandle ?? null })), lastProjectSlug };
|
|
6163
|
+
} catch (err) {
|
|
6164
|
+
if (err instanceof StudioApiError) {
|
|
6165
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
6166
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
6167
|
+
if (code && SOCIAL_HINTS[code]) return { ok: false, code, message: typeof body.message === "string" ? ctx.client.redact(body.message) : null, hint: SOCIAL_HINTS[code] };
|
|
6168
|
+
if (err.status === 503) return { ok: false, code: "social_unavailable", hint: "Lumitra Social did not answer; try again shortly." };
|
|
6169
|
+
}
|
|
6170
|
+
throw err;
|
|
6171
|
+
}
|
|
6172
|
+
}
|
|
6173
|
+
});
|
|
6174
|
+
var studioCompositionSendToSocial = defineTool({
|
|
6175
|
+
name: "studio_composition_send_to_social",
|
|
6176
|
+
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.",
|
|
6177
|
+
inputSchema: {
|
|
6178
|
+
compositionId,
|
|
6179
|
+
projectSlug: z9.string().min(1).describe("The Lumitra Social project slug, from studio_social_list_projects."),
|
|
6180
|
+
caption: z9.string().max(2200).optional(),
|
|
6181
|
+
hashtags: z9.string().max(2200).optional().describe("Space-separated, at most 30 (Instagram counts them with the caption toward 2200 characters)."),
|
|
6182
|
+
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."),
|
|
6183
|
+
idempotencyKey: z9.string().min(1).max(200).optional().describe("Omit on a first send (one is generated); pass the returned one to retry.")
|
|
6184
|
+
},
|
|
6185
|
+
handler: async (args, ctx) => {
|
|
6186
|
+
const idempotencyKey = args.idempotencyKey ?? randomUUID2();
|
|
6187
|
+
try {
|
|
6188
|
+
const { send, replayed } = await ctx.client.sendCompositionToSocial(args.compositionId, {
|
|
6189
|
+
projectSlug: args.projectSlug,
|
|
6190
|
+
...args.caption !== void 0 ? { caption: args.caption } : {},
|
|
6191
|
+
...args.hashtags !== void 0 ? { hashtags: args.hashtags } : {},
|
|
6192
|
+
scheduledAt: args.scheduledAt ?? null,
|
|
6193
|
+
idempotencyKey
|
|
6194
|
+
});
|
|
6195
|
+
return {
|
|
6196
|
+
ok: true,
|
|
6197
|
+
replayed,
|
|
6198
|
+
send: { status: send.status, format: send.format, projectSlug: send.projectSlug, scheduledAt: send.scheduledAt, plannerUrl: send.plannerUrl }
|
|
6199
|
+
};
|
|
6200
|
+
} catch (err) {
|
|
6201
|
+
if (err instanceof StudioApiError) {
|
|
6202
|
+
const body = isRecord2(err.body) ? err.body : {};
|
|
6203
|
+
const code = typeof body.code === "string" ? body.code : null;
|
|
6204
|
+
const message = typeof body.message === "string" ? ctx.client.redact(body.message) : null;
|
|
6205
|
+
if (code && SOCIAL_HINTS[code]) return { ok: false, code, message, hint: SOCIAL_HINTS[code] };
|
|
6206
|
+
if (err.status === 404) return { ok: false, code: "not_found", message: message ?? "Not found in this company." };
|
|
6207
|
+
if (err.status === 0 || err.status >= 500) {
|
|
6208
|
+
return {
|
|
6209
|
+
ok: false,
|
|
6210
|
+
code: err.status === 0 ? "network_error" : code === "social_unavailable" ? code : "server_error",
|
|
6211
|
+
message: message ?? ctx.client.redact(err.message),
|
|
6212
|
+
idempotencyKey,
|
|
6213
|
+
hint: "The outcome may be partial. Retry with the SAME idempotencyKey: the send resumes where it stopped and never posts twice."
|
|
6214
|
+
};
|
|
6215
|
+
}
|
|
6216
|
+
}
|
|
6217
|
+
throw err;
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
});
|
|
6221
|
+
var COMPOSITION_TOOLS = [
|
|
6222
|
+
studioListAssets,
|
|
6223
|
+
studioBrandKitGet,
|
|
6224
|
+
studioCompositionDescribe,
|
|
6225
|
+
studioCompositionList,
|
|
6226
|
+
studioCompositionCreate,
|
|
6227
|
+
studioCompositionGet,
|
|
6228
|
+
studioCompositionApply,
|
|
6229
|
+
studioCompositionRender,
|
|
6230
|
+
studioSocialListProjects,
|
|
6231
|
+
studioCompositionSendToSocial
|
|
6232
|
+
];
|
|
6233
|
+
|
|
6234
|
+
// src/manageTools.ts
|
|
6235
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
6236
|
+
import { z as z10 } from "zod";
|
|
5672
6237
|
var TOKEN_TTL_MS = 10 * 60 * 1e3;
|
|
5673
6238
|
var ConfirmationStore = class {
|
|
5674
6239
|
#tokens = /* @__PURE__ */ new Map();
|
|
@@ -5678,7 +6243,7 @@ var ConfirmationStore = class {
|
|
|
5678
6243
|
}
|
|
5679
6244
|
issue(subject) {
|
|
5680
6245
|
this.#sweep();
|
|
5681
|
-
const token =
|
|
6246
|
+
const token = randomUUID3();
|
|
5682
6247
|
this.#tokens.set(token, { subject, expiresAt: this.#now() + TOKEN_TTL_MS });
|
|
5683
6248
|
return token;
|
|
5684
6249
|
}
|
|
@@ -5755,21 +6320,21 @@ function roleRefusal(err, sentence) {
|
|
|
5755
6320
|
}
|
|
5756
6321
|
throw err;
|
|
5757
6322
|
}
|
|
5758
|
-
var confirmationToken =
|
|
6323
|
+
var confirmationToken = z10.string().min(1).optional().describe(
|
|
5759
6324
|
"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."
|
|
5760
6325
|
);
|
|
5761
6326
|
var studioCreateProject = defineTool({
|
|
5762
6327
|
name: "studio_create_project",
|
|
5763
6328
|
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.",
|
|
5764
|
-
inputSchema: { name:
|
|
6329
|
+
inputSchema: { name: z10.string().min(1).max(120).describe("The project name, as people in the company will see it.") },
|
|
5765
6330
|
handler: async (args, ctx) => (await ctx.client.createProject(args.name)).project
|
|
5766
6331
|
});
|
|
5767
6332
|
var studioRenameProject = defineTool({
|
|
5768
6333
|
name: "studio_rename_project",
|
|
5769
6334
|
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).`,
|
|
5770
6335
|
inputSchema: {
|
|
5771
|
-
projectId:
|
|
5772
|
-
name:
|
|
6336
|
+
projectId: z10.string().min(1).describe("The project, from studio_list_projects."),
|
|
6337
|
+
name: z10.string().min(1).max(120).describe("The new name.")
|
|
5773
6338
|
},
|
|
5774
6339
|
annotations: { idempotentHint: true },
|
|
5775
6340
|
handler: async (args, ctx) => (await ctx.client.renameProject(args.projectId, args.name)).project
|
|
@@ -5778,7 +6343,7 @@ var studioDeleteProject = defineTool({
|
|
|
5778
6343
|
name: "studio_delete_project",
|
|
5779
6344
|
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).",
|
|
5780
6345
|
inputSchema: {
|
|
5781
|
-
projectId:
|
|
6346
|
+
projectId: z10.string().min(1).describe("The project to delete, from studio_list_projects."),
|
|
5782
6347
|
confirmationToken
|
|
5783
6348
|
},
|
|
5784
6349
|
annotations: { destructiveHint: true },
|
|
@@ -5807,7 +6372,7 @@ var studioDeleteProject = defineTool({
|
|
|
5807
6372
|
var studioListWorkflows = defineTool({
|
|
5808
6373
|
name: "studio_list_workflows",
|
|
5809
6374
|
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.",
|
|
5810
|
-
inputSchema: { projectId:
|
|
6375
|
+
inputSchema: { projectId: z10.string().min(1).optional().describe("The project, from studio_list_projects. Omit for the default project.") },
|
|
5811
6376
|
annotations: { readOnlyHint: true },
|
|
5812
6377
|
handler: async (args, ctx) => {
|
|
5813
6378
|
const { workflows } = await ctx.client.listWorkflows(args.projectId ? { projectId: args.projectId } : {});
|
|
@@ -5818,9 +6383,9 @@ var studioMoveWorkflow = defineTool({
|
|
|
5818
6383
|
name: "studio_move_workflow",
|
|
5819
6384
|
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).",
|
|
5820
6385
|
inputSchema: {
|
|
5821
|
-
savedId:
|
|
5822
|
-
toProjectId:
|
|
5823
|
-
projectId:
|
|
6386
|
+
savedId: z10.string().min(1).describe('The saved workflow, from studio_list_workflows (starts with "saved:").'),
|
|
6387
|
+
toProjectId: z10.string().min(1).describe("The project to move it to, from studio_list_projects."),
|
|
6388
|
+
projectId: z10.string().min(1).optional().describe("The project the workflow is in now. Omit for the default project.")
|
|
5824
6389
|
},
|
|
5825
6390
|
handler: async (args, ctx) => ctx.client.moveWorkflow(args.savedId, { toProjectId: args.toProjectId, ...args.projectId ? { projectId: args.projectId } : {} })
|
|
5826
6391
|
});
|
|
@@ -5835,7 +6400,7 @@ var studioDeleteCampaign = defineTool({
|
|
|
5835
6400
|
name: "studio_delete_campaign",
|
|
5836
6401
|
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.",
|
|
5837
6402
|
inputSchema: {
|
|
5838
|
-
campaignId:
|
|
6403
|
+
campaignId: z10.string().min(1).describe("The campaign, from studio_list_campaigns."),
|
|
5839
6404
|
confirmationToken
|
|
5840
6405
|
},
|
|
5841
6406
|
annotations: { destructiveHint: true },
|
|
@@ -5869,9 +6434,9 @@ var MANAGE_TOOLS = [
|
|
|
5869
6434
|
];
|
|
5870
6435
|
|
|
5871
6436
|
// src/tools.ts
|
|
5872
|
-
var slug =
|
|
5873
|
-
var waitSeconds =
|
|
5874
|
-
var httpUrl =
|
|
6437
|
+
var slug = z11.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
|
|
6438
|
+
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.");
|
|
6439
|
+
var httpUrl = z11.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
|
|
5875
6440
|
function pollOpts(ctx, timeoutSec) {
|
|
5876
6441
|
return { ...ctx.poll, timeoutMs: timeoutSec * 1e3 };
|
|
5877
6442
|
}
|
|
@@ -5947,22 +6512,22 @@ var studioGenerateImage = defineTool({
|
|
|
5947
6512
|
brandSlug: slug.optional().describe(
|
|
5948
6513
|
"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."
|
|
5949
6514
|
),
|
|
5950
|
-
brandMode:
|
|
5951
|
-
prompt:
|
|
6515
|
+
brandMode: z11.string().optional().describe('Optional brand mode (e.g. "illustration"); modes are defined per brand. Only meaningful with brandSlug.'),
|
|
6516
|
+
prompt: z11.string().min(1).describe("What to generate. With brandSlug, the brand style prefix is prepended server-side."),
|
|
5952
6517
|
characterSlug: slug.optional().describe(
|
|
5953
6518
|
"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."
|
|
5954
6519
|
),
|
|
5955
|
-
projectId:
|
|
6520
|
+
projectId: z11.string().min(1).optional().describe(
|
|
5956
6521
|
'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.'
|
|
5957
6522
|
),
|
|
5958
|
-
model:
|
|
5959
|
-
aspectRatio:
|
|
5960
|
-
imageSize:
|
|
5961
|
-
seed:
|
|
5962
|
-
candidateCount:
|
|
6523
|
+
model: z11.string().optional().describe('Image model id (e.g. "kie/nano-banana-2", "fal/nano-banana-2"). Omit for the Studio default.'),
|
|
6524
|
+
aspectRatio: z11.string().optional().describe('Aspect ratio such as "1:1", "16:9", "3:4".'),
|
|
6525
|
+
imageSize: z11.string().optional().describe('Provider size hint, e.g. "1K", "2K".'),
|
|
6526
|
+
seed: z11.number().int().optional(),
|
|
6527
|
+
candidateCount: z11.number().int().min(1).max(4).optional().describe(
|
|
5963
6528
|
"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."
|
|
5964
6529
|
),
|
|
5965
|
-
wait:
|
|
6530
|
+
wait: z11.boolean().default(true).describe("Poll until the job finishes (default true)."),
|
|
5966
6531
|
waitSeconds
|
|
5967
6532
|
},
|
|
5968
6533
|
handler: async (args, ctx) => {
|
|
@@ -5998,23 +6563,23 @@ var studioGenerate3d = defineTool({
|
|
|
5998
6563
|
name: "studio_generate_3d",
|
|
5999
6564
|
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.",
|
|
6000
6565
|
inputSchema: {
|
|
6001
|
-
prompt:
|
|
6566
|
+
prompt: z11.string().min(1).max(1024).describe("What to model. With imageUrl, a short description of the object in the image."),
|
|
6002
6567
|
imageUrl: httpUrl.optional().describe("Public http(s) URL of one image to model from. Selects an image model."),
|
|
6003
|
-
model:
|
|
6004
|
-
options:
|
|
6005
|
-
enableTexture:
|
|
6006
|
-
enablePbr:
|
|
6007
|
-
textureQuality:
|
|
6008
|
-
geometryQuality:
|
|
6009
|
-
quadRemesh:
|
|
6010
|
-
smartLowPoly:
|
|
6011
|
-
resolution:
|
|
6012
|
-
targetPolycount:
|
|
6013
|
-
topology:
|
|
6014
|
-
seed:
|
|
6568
|
+
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)."),
|
|
6569
|
+
options: z11.object({
|
|
6570
|
+
enableTexture: z11.boolean().optional().describe("Texture the mesh (default true). Off gives bare geometry and costs less."),
|
|
6571
|
+
enablePbr: z11.boolean().optional().describe("Physically-based rendering (PBR) material maps. Default on for Hunyuan Pro, off elsewhere."),
|
|
6572
|
+
textureQuality: z11.enum(["standard", "detailed"]).optional().describe("Tripo texture tier. detailed costs more."),
|
|
6573
|
+
geometryQuality: z11.enum(["standard", "detailed"]).optional().describe("Tripo geometry tier. detailed costs more."),
|
|
6574
|
+
quadRemesh: z11.boolean().optional().describe("Tripo: quad topology instead of triangles."),
|
|
6575
|
+
smartLowPoly: z11.boolean().optional().describe("Tripo text-to-3D: a low-poly mesh."),
|
|
6576
|
+
resolution: z11.enum(["512", "1024", "1536"]).optional().describe("TRELLIS.2 resolution (default 1024)."),
|
|
6577
|
+
targetPolycount: z11.number().int().min(100).max(15e5).optional().describe("Target face count, where the model supports one."),
|
|
6578
|
+
topology: z11.enum(["quad", "triangle"]).optional().describe("Hunyuan Pro polygon type."),
|
|
6579
|
+
seed: z11.number().int().optional()
|
|
6015
6580
|
}).optional().describe("Model-specific quality flags. Each changes the price; the returned costUsd is the price of the request that was sent."),
|
|
6016
|
-
projectId:
|
|
6017
|
-
wait:
|
|
6581
|
+
projectId: z11.string().min(1).optional().describe("Project to file the model under (from studio_list_projects). Omit for the default project."),
|
|
6582
|
+
wait: z11.boolean().default(true).describe("Poll until the job finishes (default true)."),
|
|
6018
6583
|
waitSeconds
|
|
6019
6584
|
},
|
|
6020
6585
|
handler: async (args, ctx) => {
|
|
@@ -6052,8 +6617,8 @@ var studioFindAnimations = defineTool({
|
|
|
6052
6617
|
name: "studio_find_animations",
|
|
6053
6618
|
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.',
|
|
6054
6619
|
inputSchema: {
|
|
6055
|
-
query:
|
|
6056
|
-
limit:
|
|
6620
|
+
query: z11.string().describe('Words to match, e.g. "sword slash". Empty returns the first presets in library order.'),
|
|
6621
|
+
limit: z11.number().int().min(1).max(50).default(25)
|
|
6057
6622
|
},
|
|
6058
6623
|
annotations: { readOnlyHint: true },
|
|
6059
6624
|
handler: async (args) => ({ animations: searchAnimations(args.query, args.limit) })
|
|
@@ -6062,12 +6627,12 @@ var studioRig3d = defineTool({
|
|
|
6062
6627
|
name: "studio_rig_3d",
|
|
6063
6628
|
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.",
|
|
6064
6629
|
inputSchema: {
|
|
6065
|
-
projectId:
|
|
6066
|
-
meshAssetId:
|
|
6067
|
-
animations:
|
|
6068
|
-
heightMeters:
|
|
6069
|
-
visibility:
|
|
6070
|
-
wait:
|
|
6630
|
+
projectId: z11.string().min(1).describe("The project the mesh lives in (from studio_list_projects)."),
|
|
6631
|
+
meshAssetId: z11.string().min(1).describe("The Model3D asset to rig: the assetId studio_generate_3d returned."),
|
|
6632
|
+
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.'),
|
|
6633
|
+
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."),
|
|
6634
|
+
visibility: z11.enum(["listed", "unlisted"]).optional(),
|
|
6635
|
+
wait: z11.boolean().default(true).describe("Poll until the rig finishes (default true)."),
|
|
6071
6636
|
waitSeconds
|
|
6072
6637
|
},
|
|
6073
6638
|
handler: async (args, ctx) => {
|
|
@@ -6124,8 +6689,8 @@ var studioGetJob = defineTool({
|
|
|
6124
6689
|
name: "studio_get_job",
|
|
6125
6690
|
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.",
|
|
6126
6691
|
inputSchema: {
|
|
6127
|
-
jobId:
|
|
6128
|
-
wait:
|
|
6692
|
+
jobId: z11.string().min(1),
|
|
6693
|
+
wait: z11.boolean().default(false).describe("Poll until terminal (default false: return the current state)."),
|
|
6129
6694
|
waitSeconds
|
|
6130
6695
|
},
|
|
6131
6696
|
annotations: { readOnlyHint: true },
|
|
@@ -6155,7 +6720,7 @@ var studioGetCharacter = defineTool({
|
|
|
6155
6720
|
}
|
|
6156
6721
|
});
|
|
6157
6722
|
var LIKENESS_REFUSAL = `${LIKENESS_CONFIRMATION_REQUIRED_CODE}: ${likenessConfirmationRequiredMessage()}`;
|
|
6158
|
-
var likenessRightsConfirmed =
|
|
6723
|
+
var likenessRightsConfirmed = z11.literal(true, { error: LIKENESS_REFUSAL }).describe(likenessConfirmationToolDescription());
|
|
6159
6724
|
function assertLikenessRightsConfirmed(value) {
|
|
6160
6725
|
if (!isLikenessRightsConfirmed(value)) throw new Error(LIKENESS_REFUSAL);
|
|
6161
6726
|
}
|
|
@@ -6163,11 +6728,11 @@ var studioCreateCharacter = defineTool({
|
|
|
6163
6728
|
name: "studio_create_character",
|
|
6164
6729
|
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.",
|
|
6165
6730
|
inputSchema: {
|
|
6166
|
-
name:
|
|
6731
|
+
name: z11.string().min(1).describe('Display name, e.g. "Bruno Hartmann".'),
|
|
6167
6732
|
slug,
|
|
6168
|
-
descriptorPrompt:
|
|
6169
|
-
negativePrompt:
|
|
6170
|
-
defaultModel:
|
|
6733
|
+
descriptorPrompt: z11.string().min(1).describe("The identity description prepended to every generation that uses this character."),
|
|
6734
|
+
negativePrompt: z11.string().optional(),
|
|
6735
|
+
defaultModel: z11.string().optional().describe("Default image model id for this character."),
|
|
6171
6736
|
likenessRightsConfirmed
|
|
6172
6737
|
},
|
|
6173
6738
|
handler: async (args, ctx) => {
|
|
@@ -6187,16 +6752,16 @@ var studioMintCharacter = defineTool({
|
|
|
6187
6752
|
name: "studio_mint_character",
|
|
6188
6753
|
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.",
|
|
6189
6754
|
inputSchema: {
|
|
6190
|
-
projectId:
|
|
6191
|
-
name:
|
|
6755
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6756
|
+
name: z11.string().min(1).describe("Display name."),
|
|
6192
6757
|
slug,
|
|
6193
|
-
description:
|
|
6194
|
-
descriptorPrompt:
|
|
6195
|
-
negativePrompt:
|
|
6196
|
-
defaultModel:
|
|
6197
|
-
seedModel:
|
|
6198
|
-
viewModel:
|
|
6199
|
-
visibility:
|
|
6758
|
+
description: z11.string().min(10).describe("Seed identity description (face, hair, age, build, distinguishing features)."),
|
|
6759
|
+
descriptorPrompt: z11.string().optional().describe("Override for the character's stored descriptor prompt. Defaults to the description."),
|
|
6760
|
+
negativePrompt: z11.string().optional(),
|
|
6761
|
+
defaultModel: z11.string().optional(),
|
|
6762
|
+
seedModel: z11.string().optional().describe("Override the seed text-to-image model (default fal/nano-banana-2)."),
|
|
6763
|
+
viewModel: z11.string().optional().describe("Override the view image-edit model (default fal/nano-banana-2-edit)."),
|
|
6764
|
+
visibility: z11.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
|
|
6200
6765
|
likenessRightsConfirmed,
|
|
6201
6766
|
waitSeconds
|
|
6202
6767
|
},
|
|
@@ -6255,12 +6820,12 @@ var studioCreateBrand = defineTool({
|
|
|
6255
6820
|
name: "studio_create_brand",
|
|
6256
6821
|
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.",
|
|
6257
6822
|
inputSchema: {
|
|
6258
|
-
name:
|
|
6823
|
+
name: z11.string().min(1),
|
|
6259
6824
|
slug,
|
|
6260
|
-
stylePrefix:
|
|
6261
|
-
context:
|
|
6262
|
-
defaultModel:
|
|
6263
|
-
maxReferenceImages:
|
|
6825
|
+
stylePrefix: z11.string().optional().describe("Text prepended to every prompt generated under this brand."),
|
|
6826
|
+
context: z11.string().optional().describe("Markdown brand context (tone, palette, do/don't)."),
|
|
6827
|
+
defaultModel: z11.string().optional(),
|
|
6828
|
+
maxReferenceImages: z11.number().int().min(0).max(8).optional()
|
|
6264
6829
|
},
|
|
6265
6830
|
handler: async (args, ctx) => {
|
|
6266
6831
|
const { config } = await ctx.client.createBrand({
|
|
@@ -6279,11 +6844,11 @@ var studioUploadBrandReference = defineTool({
|
|
|
6279
6844
|
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.`,
|
|
6280
6845
|
inputSchema: {
|
|
6281
6846
|
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."),
|
|
6282
|
-
source:
|
|
6283
|
-
category:
|
|
6284
|
-
label:
|
|
6285
|
-
tags:
|
|
6286
|
-
score:
|
|
6847
|
+
source: z11.string().min(1).describe("Local file path or http(s) URL of an image."),
|
|
6848
|
+
category: z11.string().optional().describe('Library category, default "general".'),
|
|
6849
|
+
label: z11.string().optional().describe("Optional file name / label."),
|
|
6850
|
+
tags: z11.array(z11.string()).optional(),
|
|
6851
|
+
score: z11.number().int().min(1).max(10).optional()
|
|
6287
6852
|
},
|
|
6288
6853
|
handler: async (args, ctx) => {
|
|
6289
6854
|
const file = await loadImageSource(args.source, ctx.client);
|
|
@@ -6302,25 +6867,28 @@ var workflowDefinitionSchema = WorkflowDefinitionSchema.describe(
|
|
|
6302
6867
|
);
|
|
6303
6868
|
var studioRunWorkflow = defineTool({
|
|
6304
6869
|
name: "studio_run_workflow",
|
|
6305
|
-
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.`,
|
|
6870
|
+
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).`,
|
|
6306
6871
|
inputSchema: {
|
|
6307
|
-
projectId:
|
|
6872
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6308
6873
|
definition: workflowDefinitionSchema.optional(),
|
|
6309
|
-
savedId:
|
|
6310
|
-
params:
|
|
6311
|
-
nodeIds:
|
|
6312
|
-
upstreamGenerations:
|
|
6874
|
+
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."),
|
|
6875
|
+
params: z11.record(z11.string(), z11.unknown()).optional().describe("Values for the definition's params."),
|
|
6876
|
+
nodeIds: z11.array(z11.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
|
|
6877
|
+
upstreamGenerations: z11.record(z11.string(), z11.string()).optional().describe(
|
|
6313
6878
|
'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.'
|
|
6314
6879
|
),
|
|
6315
|
-
runs:
|
|
6316
|
-
visibility:
|
|
6317
|
-
budgetUsd:
|
|
6880
|
+
runs: z11.number().int().min(1).max(8).optional().describe("Repeat a node subset N times (1 to 8)."),
|
|
6881
|
+
visibility: z11.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
|
|
6882
|
+
budgetUsd: z11.number().nonnegative().optional().describe(
|
|
6318
6883
|
'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.'
|
|
6319
6884
|
),
|
|
6320
|
-
confirm:
|
|
6885
|
+
confirm: z11.boolean().optional().describe(
|
|
6321
6886
|
'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 }.'
|
|
6322
6887
|
),
|
|
6323
|
-
|
|
6888
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
6889
|
+
'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.'
|
|
6890
|
+
),
|
|
6891
|
+
wait: z11.boolean().default(true),
|
|
6324
6892
|
waitSeconds
|
|
6325
6893
|
},
|
|
6326
6894
|
handler: async (args, ctx) => {
|
|
@@ -6340,7 +6908,8 @@ var studioRunWorkflow = defineTool({
|
|
|
6340
6908
|
...args.savedId ? { savedId: args.savedId } : {},
|
|
6341
6909
|
...args.visibility ? { visibility: args.visibility } : {},
|
|
6342
6910
|
...args.budgetUsd !== void 0 ? { budgetUsd: args.budgetUsd } : {},
|
|
6343
|
-
...args.confirm !== void 0 ? { confirm: args.confirm } : {}
|
|
6911
|
+
...args.confirm !== void 0 ? { confirm: args.confirm } : {},
|
|
6912
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6344
6913
|
});
|
|
6345
6914
|
if (!args.wait) return { runId: started.runId, runIds: started.runIds, status: started.status };
|
|
6346
6915
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
@@ -6351,8 +6920,8 @@ var studioGetRun = defineTool({
|
|
|
6351
6920
|
name: "studio_get_run",
|
|
6352
6921
|
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.",
|
|
6353
6922
|
inputSchema: {
|
|
6354
|
-
runId:
|
|
6355
|
-
wait:
|
|
6923
|
+
runId: z11.string().min(1),
|
|
6924
|
+
wait: z11.boolean().default(false),
|
|
6356
6925
|
waitSeconds
|
|
6357
6926
|
},
|
|
6358
6927
|
annotations: { readOnlyHint: true },
|
|
@@ -6365,11 +6934,11 @@ var studioDecideJudge = defineTool({
|
|
|
6365
6934
|
name: "studio_decide_judge",
|
|
6366
6935
|
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.",
|
|
6367
6936
|
inputSchema: {
|
|
6368
|
-
runId:
|
|
6369
|
-
nodeId:
|
|
6370
|
-
verdict:
|
|
6371
|
-
candidate:
|
|
6372
|
-
reason:
|
|
6937
|
+
runId: z11.string().min(1),
|
|
6938
|
+
nodeId: z11.string().min(1),
|
|
6939
|
+
verdict: z11.enum(["approved", "rejected"]),
|
|
6940
|
+
candidate: z11.object({ generationId: z11.string().min(1), index: z11.number().int().min(0).optional() }).optional(),
|
|
6941
|
+
reason: z11.string().max(500).optional()
|
|
6373
6942
|
},
|
|
6374
6943
|
annotations: { destructiveHint: false, idempotentHint: false },
|
|
6375
6944
|
handler: async (args, ctx) => {
|
|
@@ -6385,8 +6954,8 @@ var studioGetRunOutput = defineTool({
|
|
|
6385
6954
|
name: "studio_get_run_output",
|
|
6386
6955
|
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.",
|
|
6387
6956
|
inputSchema: {
|
|
6388
|
-
runId:
|
|
6389
|
-
nodeId:
|
|
6957
|
+
runId: z11.string().min(1),
|
|
6958
|
+
nodeId: z11.string().min(1)
|
|
6390
6959
|
},
|
|
6391
6960
|
annotations: { readOnlyHint: true },
|
|
6392
6961
|
handler: async (args, ctx) => {
|
|
@@ -6398,21 +6967,24 @@ var studioReplaceCharacterInVideo = defineTool({
|
|
|
6398
6967
|
name: "studio_replace_character_in_video",
|
|
6399
6968
|
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.',
|
|
6400
6969
|
inputSchema: {
|
|
6401
|
-
projectId:
|
|
6970
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
6402
6971
|
sceneFrameUrl: httpUrl.describe("Public or signed URL of ONE frame of the target shot (png/jpg)."),
|
|
6403
6972
|
characterSlug: slug.optional().describe(
|
|
6404
6973
|
"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."
|
|
6405
6974
|
),
|
|
6406
6975
|
characterReferenceUrl: httpUrl.optional().describe("Explicit character reference image URL (use instead of characterSlug)."),
|
|
6407
6976
|
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."),
|
|
6408
|
-
scope:
|
|
6409
|
-
preserve:
|
|
6410
|
-
swapPrompt:
|
|
6411
|
-
motionPrompt:
|
|
6412
|
-
videoModel:
|
|
6413
|
-
editModel:
|
|
6414
|
-
aspectRatio:
|
|
6415
|
-
visibility:
|
|
6977
|
+
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."),
|
|
6978
|
+
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.'),
|
|
6979
|
+
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."),
|
|
6980
|
+
motionPrompt: z11.string().optional().describe("Override the motion description for the video node."),
|
|
6981
|
+
videoModel: z11.string().optional().describe(`Image-to-video model id. Default ${DEFAULT_SWAP_VIDEO_MODEL}, or ${KEYFRAME_SWAP_VIDEO_MODEL} when endFrameUrl is given.`),
|
|
6982
|
+
editModel: z11.string().default(DEFAULT_SWAP_EDIT_MODEL).describe("Image-edit model id for the still swap."),
|
|
6983
|
+
aspectRatio: z11.string().default("16:9"),
|
|
6984
|
+
visibility: z11.enum(["listed", "unlisted"]).optional(),
|
|
6985
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
6986
|
+
"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."
|
|
6987
|
+
),
|
|
6416
6988
|
waitSeconds
|
|
6417
6989
|
},
|
|
6418
6990
|
handler: async (args, ctx) => {
|
|
@@ -6448,7 +7020,8 @@ var studioReplaceCharacterInVideo = defineTool({
|
|
|
6448
7020
|
const started = await ctx.client.runWorkflow({
|
|
6449
7021
|
projectId: args.projectId,
|
|
6450
7022
|
definition,
|
|
6451
|
-
...args.visibility ? { visibility: args.visibility } : {}
|
|
7023
|
+
...args.visibility ? { visibility: args.visibility } : {},
|
|
7024
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6452
7025
|
});
|
|
6453
7026
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
6454
7027
|
const stillUrl = nodeUrl(run, SWAP_EDIT_NODE_ID);
|
|
@@ -6477,7 +7050,7 @@ var studioGetSpend = defineTool({
|
|
|
6477
7050
|
name: "studio_get_spend",
|
|
6478
7051
|
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).`,
|
|
6479
7052
|
inputSchema: {
|
|
6480
|
-
tzOffsetMinutes:
|
|
7053
|
+
tzOffsetMinutes: z11.number().int().min(-840).max(840).optional()
|
|
6481
7054
|
},
|
|
6482
7055
|
annotations: { readOnlyHint: true },
|
|
6483
7056
|
handler: async (args, ctx) => {
|
|
@@ -6505,7 +7078,7 @@ var studioDescribePublished = defineTool({
|
|
|
6505
7078
|
name: "studio_describe_published",
|
|
6506
7079
|
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.",
|
|
6507
7080
|
inputSchema: {
|
|
6508
|
-
slug:
|
|
7081
|
+
slug: z11.string().min(1).describe("The recipe slug, from studio_list_published.")
|
|
6509
7082
|
},
|
|
6510
7083
|
annotations: { readOnlyHint: true },
|
|
6511
7084
|
handler: async (args, ctx) => {
|
|
@@ -6515,19 +7088,22 @@ var studioDescribePublished = defineTool({
|
|
|
6515
7088
|
});
|
|
6516
7089
|
var studioRunPublished = defineTool({
|
|
6517
7090
|
name: "studio_run_published",
|
|
6518
|
-
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.`,
|
|
7091
|
+
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).`,
|
|
6519
7092
|
inputSchema: {
|
|
6520
|
-
slug:
|
|
6521
|
-
projectId:
|
|
6522
|
-
params:
|
|
6523
|
-
budgetUsd:
|
|
7093
|
+
slug: z11.string().min(1).describe("The recipe slug, from studio_list_published."),
|
|
7094
|
+
projectId: z11.string().min(1).describe("Project id from studio_list_projects."),
|
|
7095
|
+
params: z11.record(z11.string(), z11.unknown()).optional().describe("Values for the recipe's params (see studio_describe_published)."),
|
|
7096
|
+
budgetUsd: z11.number().nonnegative().optional().describe(
|
|
6524
7097
|
'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 }.'
|
|
6525
7098
|
),
|
|
6526
|
-
confirm:
|
|
7099
|
+
confirm: z11.boolean().optional().describe(
|
|
6527
7100
|
'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 }.'
|
|
6528
7101
|
),
|
|
6529
|
-
likenessRightsConfirmed:
|
|
6530
|
-
|
|
7102
|
+
likenessRightsConfirmed: z11.literal(true).optional().describe(`Required when the recipe creates a character; ignored otherwise. ${likenessConfirmationToolDescription()}`),
|
|
7103
|
+
acknowledgeContinuity: z11.boolean().optional().describe(
|
|
7104
|
+
'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.'
|
|
7105
|
+
),
|
|
7106
|
+
wait: z11.boolean().default(true),
|
|
6531
7107
|
waitSeconds
|
|
6532
7108
|
},
|
|
6533
7109
|
handler: async (args, ctx) => {
|
|
@@ -6536,7 +7112,8 @@ var studioRunPublished = defineTool({
|
|
|
6536
7112
|
...args.params ? { params: args.params } : {},
|
|
6537
7113
|
...args.budgetUsd !== void 0 ? { budgetUsd: args.budgetUsd } : {},
|
|
6538
7114
|
...args.confirm !== void 0 ? { confirm: args.confirm } : {},
|
|
6539
|
-
...args.likenessRightsConfirmed === true ? { likenessRightsConfirmed: true } : {}
|
|
7115
|
+
...args.likenessRightsConfirmed === true ? { likenessRightsConfirmed: true } : {},
|
|
7116
|
+
...args.acknowledgeContinuity !== void 0 ? { acknowledgeContinuity: args.acknowledgeContinuity } : {}
|
|
6540
7117
|
});
|
|
6541
7118
|
if (!args.wait) return { runId: started.runId, status: started.status };
|
|
6542
7119
|
const run = await waitForRun(ctx.client, started.runId, pollOpts(ctx, args.waitSeconds));
|
|
@@ -6567,7 +7144,8 @@ var TOOLS = [
|
|
|
6567
7144
|
studioRunPublished,
|
|
6568
7145
|
studioGetUsage,
|
|
6569
7146
|
...WORKFLOW_TOOLS,
|
|
6570
|
-
...MANAGE_TOOLS
|
|
7147
|
+
...MANAGE_TOOLS,
|
|
7148
|
+
...COMPOSITION_TOOLS
|
|
6571
7149
|
];
|
|
6572
7150
|
var TOOL_NAMES = TOOLS.map((t) => t.name);
|
|
6573
7151
|
function toolResult(value) {
|
|
@@ -6585,7 +7163,7 @@ function toolError(message) {
|
|
|
6585
7163
|
}
|
|
6586
7164
|
async function invokeTool(def, args, ctx) {
|
|
6587
7165
|
try {
|
|
6588
|
-
const parsed =
|
|
7166
|
+
const parsed = z11.object(def.inputSchema).parse(args ?? {});
|
|
6589
7167
|
const value = await def.handler(parsed, ctx);
|
|
6590
7168
|
return toolResult(value);
|
|
6591
7169
|
} catch (err) {
|
|
@@ -6636,7 +7214,7 @@ function registerTools(server, base) {
|
|
|
6636
7214
|
|
|
6637
7215
|
// src/server.ts
|
|
6638
7216
|
var SERVER_NAME = "lumitra-studio";
|
|
6639
|
-
var SERVER_VERSION = "0.
|
|
7217
|
+
var SERVER_VERSION = "0.8.0";
|
|
6640
7218
|
function createStudioMcpServer(opts = {}) {
|
|
6641
7219
|
const config = opts.config ?? resolveConfig(opts.env ?? process.env);
|
|
6642
7220
|
const client = new StudioClient(config, {
|
|
@@ -6661,7 +7239,7 @@ function createStudioMcpServer(opts = {}) {
|
|
|
6661
7239
|
|
|
6662
7240
|
// src/cli.ts
|
|
6663
7241
|
import { createServer as createHttpServer } from "http";
|
|
6664
|
-
import { randomUUID as
|
|
7242
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
6665
7243
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6666
7244
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
6667
7245
|
function parseArgs(argv) {
|
|
@@ -6746,7 +7324,7 @@ async function runHttp(args) {
|
|
|
6746
7324
|
});
|
|
6747
7325
|
const addr = httpServer.address();
|
|
6748
7326
|
const port = typeof addr === "object" && addr ? addr.port : args.port;
|
|
6749
|
-
process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${
|
|
7327
|
+
process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${randomUUID4().slice(0, 8)})
|
|
6750
7328
|
`);
|
|
6751
7329
|
const shutdown = () => {
|
|
6752
7330
|
httpServer.close(() => process.exit(0));
|