@marlinjai/studio-mcp 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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 randomUUID2 } from "crypto";
5
+ import { randomUUID as randomUUID3 } from "crypto";
6
6
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
7
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
8
8
 
@@ -158,6 +158,37 @@ var StudioClient = class {
158
158
  listProjects() {
159
159
  return this.json("GET", "/api/v1/projects");
160
160
  }
161
+ createProject(name) {
162
+ return this.json("POST", "/api/v1/projects", { json: { name } });
163
+ }
164
+ renameProject(projectId, name) {
165
+ return this.json("PATCH", `/api/v1/projects/${encodeURIComponent(projectId)}`, { json: { name } });
166
+ }
167
+ /** What a project holds, which is what deleting it would remove. */
168
+ describeProject(projectId) {
169
+ return this.json("GET", `/api/v1/projects/${encodeURIComponent(projectId)}`);
170
+ }
171
+ deleteProject(projectId) {
172
+ return this.json("DELETE", `/api/v1/projects/${encodeURIComponent(projectId)}`);
173
+ }
174
+ // ── Saved workflows (listing and moving; authoring lives with the workflow tools) ──
175
+ listWorkflows(opts = {}) {
176
+ return this.json("GET", `/api/v1/workflows${projectQuery(opts.projectId)}`);
177
+ }
178
+ moveWorkflow(savedId2, body) {
179
+ return this.json("POST", `/api/v1/workflows/${encodeURIComponent(savedId2)}/move`, { json: body });
180
+ }
181
+ // ── Campaigns ──
182
+ listCampaigns() {
183
+ return this.json("GET", "/api/campaigns");
184
+ }
185
+ /** The campaign and what deleting it would remove or keep. */
186
+ describeCampaign(campaignId) {
187
+ return this.json("GET", `/api/campaigns/${encodeURIComponent(campaignId)}`);
188
+ }
189
+ deleteCampaign(campaignId) {
190
+ return this.json("DELETE", `/api/campaigns/${encodeURIComponent(campaignId)}`);
191
+ }
161
192
  // ── Generation jobs ──
162
193
  /**
163
194
  * One image job. `brandSlug` is optional: without it the image is generated
@@ -441,7 +472,7 @@ function projectQuery(projectId) {
441
472
  }
442
473
 
443
474
  // src/tools.ts
444
- import { z as z8 } from "zod";
475
+ import { z as z9 } from "zod";
445
476
 
446
477
  // ../lumitra-core/dist/models/index.js
447
478
  var veo = (tier, label) => {
@@ -5640,10 +5671,212 @@ var WORKFLOW_TOOLS = [
5640
5671
  studioWorkflowScreenshot
5641
5672
  ];
5642
5673
 
5674
+ // src/manageTools.ts
5675
+ import { randomUUID as randomUUID2 } from "crypto";
5676
+ import { z as z8 } from "zod";
5677
+ var TOKEN_TTL_MS = 10 * 60 * 1e3;
5678
+ var ConfirmationStore = class {
5679
+ #tokens = /* @__PURE__ */ new Map();
5680
+ #now;
5681
+ constructor(now = Date.now) {
5682
+ this.#now = now;
5683
+ }
5684
+ issue(subject) {
5685
+ this.#sweep();
5686
+ const token = randomUUID2();
5687
+ this.#tokens.set(token, { subject, expiresAt: this.#now() + TOKEN_TTL_MS });
5688
+ return token;
5689
+ }
5690
+ /** True once for a live token issued for exactly this subject; the token is spent either way. */
5691
+ redeem(token, subject) {
5692
+ this.#sweep();
5693
+ const entry = this.#tokens.get(token);
5694
+ if (!entry) return false;
5695
+ this.#tokens.delete(token);
5696
+ return entry.subject === subject;
5697
+ }
5698
+ #sweep() {
5699
+ const now = this.#now();
5700
+ for (const [token, entry] of this.#tokens) if (entry.expiresAt <= now) this.#tokens.delete(token);
5701
+ }
5702
+ };
5703
+ function count(n, one, many) {
5704
+ return `${n} ${n === 1 ? one : many}`;
5705
+ }
5706
+ function projectDeleteSummary(c) {
5707
+ const removed = [
5708
+ c.workflows > 0 ? count(c.workflows, "saved workflow", "saved workflows") : null,
5709
+ c.runs > 0 ? count(c.runs, "run with its results", "runs with their results") : null,
5710
+ c.assets > 0 ? count(c.assets, "image, video or other asset", "images, videos and other assets") : null,
5711
+ c.chats > 0 ? count(c.chats, "chat", "chats") : null
5712
+ ].filter((line) => line !== null);
5713
+ const parts = [
5714
+ `Delete the project "${c.project.name}" for everyone in the company?`,
5715
+ removed.length > 0 ? `This permanently removes ${removed.join(", ")}.` : "The project is empty: only the project itself is removed."
5716
+ ];
5717
+ if (c.publishedWorkflows > 0) {
5718
+ parts.push(`${count(c.publishedWorkflows, "of its workflows is", "of its workflows are")} published as a recipe; the published address stops working.`);
5719
+ }
5720
+ if (c.campaignShots > 0) {
5721
+ parts.push(`${count(c.campaignShots, "campaign shot", "campaign shots")} in ${count(c.campaigns, "campaign", "campaigns")} will lose their image (the campaigns stay).`);
5722
+ }
5723
+ parts.push("The record of what the project cost is kept. This cannot be undone.");
5724
+ return parts.join(" ");
5725
+ }
5726
+ function campaignDeleteSummary(c) {
5727
+ const kept = c.imagesKept > 0 ? ` Its ${count(c.imagesKept, "image stays", "images stay")} in the asset library.` : "";
5728
+ return `Delete the campaign "${c.name}" with its ${count(c.shots, "shot", "shots")} and every approve and reject decision?${kept} This cannot be undone.`;
5729
+ }
5730
+ function projectSubject(c) {
5731
+ return ["delete-project", c.project.id, c.project.name, c.workflows, c.publishedWorkflows, c.runs, c.assets, c.chats, c.campaignShots].join(":");
5732
+ }
5733
+ function campaignSubject(c) {
5734
+ return ["delete-campaign", c.id, c.name, c.shots, c.imagesKept].join(":");
5735
+ }
5736
+ var NOT_CONFIRMED_INSTRUCTION = "Nothing was deleted. Show `summary` to the person exactly as written and ask them to confirm in the chat. Only after they explicitly say yes, call this tool again with the same id and `confirmationToken`. Never confirm on their behalf, and never reuse a token for anything else; it expires in ten minutes.";
5737
+ async function confirmWithPerson(ctx, summary, subject, token) {
5738
+ const outcome = ctx.confirm ? await ctx.confirm(summary) : "unavailable";
5739
+ if (outcome === "confirmed") return "proceed";
5740
+ if (outcome === "declined") {
5741
+ return { deleted: false, declined: true, summary, message: "The person declined in the confirmation dialog. Nothing was deleted." };
5742
+ }
5743
+ const store = ctx.confirmations;
5744
+ if (!store) {
5745
+ return { deleted: false, summary, message: "This client cannot ask the person to confirm, so nothing was deleted. Delete it in the Studio app instead." };
5746
+ }
5747
+ if (token && store.redeem(token, subject)) return "proceed";
5748
+ return {
5749
+ deleted: false,
5750
+ confirmationRequired: true,
5751
+ summary,
5752
+ confirmationToken: store.issue(subject),
5753
+ ...token ? { note: "The token given was unknown, expired, already used, or what it confirmed has changed since. Ask the person again with this summary." } : {},
5754
+ instruction: NOT_CONFIRMED_INSTRUCTION
5755
+ };
5756
+ }
5757
+ function roleRefusal(err, sentence) {
5758
+ if (err instanceof StudioApiError && err.status === 403) {
5759
+ return { deleted: false, message: `${sentence} Nothing was deleted. Ask a person with that role to do it in the Studio app, or use a key with that role.` };
5760
+ }
5761
+ throw err;
5762
+ }
5763
+ var confirmationToken = z8.string().min(1).optional().describe(
5764
+ "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
+ );
5766
+ var studioCreateProject = defineTool({
5767
+ name: "studio_create_project",
5768
+ 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: z8.string().min(1).max(120).describe("The project name, as people in the company will see it.") },
5770
+ handler: async (args, ctx) => (await ctx.client.createProject(args.name)).project
5771
+ });
5772
+ var studioRenameProject = defineTool({
5773
+ name: "studio_rename_project",
5774
+ 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
+ inputSchema: {
5776
+ projectId: z8.string().min(1).describe("The project, from studio_list_projects."),
5777
+ name: z8.string().min(1).max(120).describe("The new name.")
5778
+ },
5779
+ annotations: { idempotentHint: true },
5780
+ handler: async (args, ctx) => (await ctx.client.renameProject(args.projectId, args.name)).project
5781
+ });
5782
+ var studioDeleteProject = defineTool({
5783
+ name: "studio_delete_project",
5784
+ 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
+ inputSchema: {
5786
+ projectId: z8.string().min(1).describe("The project to delete, from studio_list_projects."),
5787
+ confirmationToken
5788
+ },
5789
+ annotations: { destructiveHint: true },
5790
+ handler: async (args, ctx) => {
5791
+ const contents = await ctx.client.describeProject(args.projectId);
5792
+ if (contents.project.isDefault) {
5793
+ return { deleted: false, message: `"${contents.project.name}" is the company's default project: work lands there when no other project is selected, so it cannot be deleted. It can be renamed.` };
5794
+ }
5795
+ if (contents.runsInFlight > 0 || contents.jobsInFlight > 0) {
5796
+ return {
5797
+ deleted: false,
5798
+ message: `${count(contents.runsInFlight, "run is", "runs are")} still going and ${count(contents.jobsInFlight, "generation is", "generations are")} still rendering in "${contents.project.name}". Wait until they finish (or stop the runs), then delete it.`
5799
+ };
5800
+ }
5801
+ const summary = projectDeleteSummary(contents);
5802
+ const gate = await confirmWithPerson(ctx, summary, projectSubject(contents), args.confirmationToken);
5803
+ if (gate !== "proceed") return gate;
5804
+ try {
5805
+ const res = await ctx.client.deleteProject(args.projectId);
5806
+ return { deleted: true, project: res.project, fallbackProjectId: res.fallbackProjectId, summary };
5807
+ } catch (err) {
5808
+ return roleRefusal(err, "Deleting a project needs a key with the company admin role; this key does not have it.");
5809
+ }
5810
+ }
5811
+ });
5812
+ var studioListWorkflows = defineTool({
5813
+ name: "studio_list_workflows",
5814
+ 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: z8.string().min(1).optional().describe("The project, from studio_list_projects. Omit for the default project.") },
5816
+ annotations: { readOnlyHint: true },
5817
+ handler: async (args, ctx) => {
5818
+ const { workflows } = await ctx.client.listWorkflows(args.projectId ? { projectId: args.projectId } : {});
5819
+ return { workflows: workflows.map((w) => ({ savedId: w.savedId, label: w.label, ...w.version !== void 0 ? { version: w.version } : {} })) };
5820
+ }
5821
+ });
5822
+ var studioMoveWorkflow = defineTool({
5823
+ name: "studio_move_workflow",
5824
+ 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
+ inputSchema: {
5826
+ savedId: z8.string().min(1).describe('The saved workflow, from studio_list_workflows (starts with "saved:").'),
5827
+ toProjectId: z8.string().min(1).describe("The project to move it to, from studio_list_projects."),
5828
+ projectId: z8.string().min(1).optional().describe("The project the workflow is in now. Omit for the default project.")
5829
+ },
5830
+ handler: async (args, ctx) => ctx.client.moveWorkflow(args.savedId, { toProjectId: args.toProjectId, ...args.projectId ? { projectId: args.projectId } : {} })
5831
+ });
5832
+ var studioListCampaigns = defineTool({
5833
+ name: "studio_list_campaigns",
5834
+ description: "List your company's campaigns, newest first (id, name, studio, shot count, created). Campaigns are shared by every project of the company.",
5835
+ inputSchema: {},
5836
+ annotations: { readOnlyHint: true },
5837
+ handler: async (_args, ctx) => ctx.client.listCampaigns()
5838
+ });
5839
+ var studioDeleteCampaign = defineTool({
5840
+ name: "studio_delete_campaign",
5841
+ 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
+ inputSchema: {
5843
+ campaignId: z8.string().min(1).describe("The campaign, from studio_list_campaigns."),
5844
+ confirmationToken
5845
+ },
5846
+ annotations: { destructiveHint: true },
5847
+ handler: async (args, ctx) => {
5848
+ const contents = await ctx.client.describeCampaign(args.campaignId);
5849
+ if (contents.shotsRendering > 0) {
5850
+ return {
5851
+ deleted: false,
5852
+ message: `${count(contents.shotsRendering, "shot is", "shots are")} of "${contents.name}" still rendering. Wait until they finish, then delete the campaign.`
5853
+ };
5854
+ }
5855
+ const summary = campaignDeleteSummary(contents);
5856
+ const gate = await confirmWithPerson(ctx, summary, campaignSubject(contents), args.confirmationToken);
5857
+ if (gate !== "proceed") return gate;
5858
+ try {
5859
+ const res = await ctx.client.deleteCampaign(args.campaignId);
5860
+ return { deleted: true, id: res.id, shotsDeleted: res.shotsDeleted, summary };
5861
+ } catch (err) {
5862
+ return roleRefusal(err, "Deleting a campaign needs a key with at least the company member role; this key does not have it.");
5863
+ }
5864
+ }
5865
+ });
5866
+ var MANAGE_TOOLS = [
5867
+ studioCreateProject,
5868
+ studioRenameProject,
5869
+ studioDeleteProject,
5870
+ studioListWorkflows,
5871
+ studioMoveWorkflow,
5872
+ studioListCampaigns,
5873
+ studioDeleteCampaign
5874
+ ];
5875
+
5643
5876
  // src/tools.ts
5644
- var slug = z8.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
5645
- var waitSeconds = z8.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.");
5646
- var httpUrl = z8.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
5877
+ var slug = z9.string().regex(/^[a-z0-9-]+$/, "lowercase letters, numbers and hyphens only").describe("URL-safe identifier: lowercase letters, numbers, hyphens.");
5878
+ var waitSeconds = z9.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.");
5879
+ var httpUrl = z9.string().url().refine((u) => /^https?:\/\//i.test(u), "must be an http(s) URL");
5647
5880
  function pollOpts(ctx, timeoutSec) {
5648
5881
  return { ...ctx.poll, timeoutMs: timeoutSec * 1e3 };
5649
5882
  }
@@ -5719,22 +5952,22 @@ var studioGenerateImage = defineTool({
5719
5952
  brandSlug: slug.optional().describe(
5720
5953
  "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."
5721
5954
  ),
5722
- brandMode: z8.string().optional().describe('Optional brand mode (e.g. "illustration"); modes are defined per brand. Only meaningful with brandSlug.'),
5723
- prompt: z8.string().min(1).describe("What to generate. With brandSlug, the brand style prefix is prepended server-side."),
5955
+ brandMode: z9.string().optional().describe('Optional brand mode (e.g. "illustration"); modes are defined per brand. Only meaningful with brandSlug.'),
5956
+ prompt: z9.string().min(1).describe("What to generate. With brandSlug, the brand style prefix is prepended server-side."),
5724
5957
  characterSlug: slug.optional().describe(
5725
5958
  "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."
5726
5959
  ),
5727
- projectId: z8.string().min(1).optional().describe(
5960
+ projectId: z9.string().min(1).optional().describe(
5728
5961
  '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.'
5729
5962
  ),
5730
- model: z8.string().optional().describe('Image model id (e.g. "kie/nano-banana-2", "fal/nano-banana-2"). Omit for the Studio default.'),
5731
- aspectRatio: z8.string().optional().describe('Aspect ratio such as "1:1", "16:9", "3:4".'),
5732
- imageSize: z8.string().optional().describe('Provider size hint, e.g. "1K", "2K".'),
5733
- seed: z8.number().int().optional(),
5734
- candidateCount: z8.number().int().min(1).max(4).optional().describe(
5963
+ model: z9.string().optional().describe('Image model id (e.g. "kie/nano-banana-2", "fal/nano-banana-2"). Omit for the Studio default.'),
5964
+ aspectRatio: z9.string().optional().describe('Aspect ratio such as "1:1", "16:9", "3:4".'),
5965
+ imageSize: z9.string().optional().describe('Provider size hint, e.g. "1K", "2K".'),
5966
+ seed: z9.number().int().optional(),
5967
+ candidateCount: z9.number().int().min(1).max(4).optional().describe(
5735
5968
  "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."
5736
5969
  ),
5737
- wait: z8.boolean().default(true).describe("Poll until the job finishes (default true)."),
5970
+ wait: z9.boolean().default(true).describe("Poll until the job finishes (default true)."),
5738
5971
  waitSeconds
5739
5972
  },
5740
5973
  handler: async (args, ctx) => {
@@ -5770,23 +6003,23 @@ var studioGenerate3d = defineTool({
5770
6003
  name: "studio_generate_3d",
5771
6004
  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.",
5772
6005
  inputSchema: {
5773
- prompt: z8.string().min(1).max(1024).describe("What to model. With imageUrl, a short description of the object in the image."),
6006
+ prompt: z9.string().min(1).max(1024).describe("What to model. With imageUrl, a short description of the object in the image."),
5774
6007
  imageUrl: httpUrl.optional().describe("Public http(s) URL of one image to model from. Selects an image model."),
5775
- model: z8.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)."),
5776
- options: z8.object({
5777
- enableTexture: z8.boolean().optional().describe("Texture the mesh (default true). Off gives bare geometry and costs less."),
5778
- enablePbr: z8.boolean().optional().describe("Physically-based rendering (PBR) material maps. Default on for Hunyuan Pro, off elsewhere."),
5779
- textureQuality: z8.enum(["standard", "detailed"]).optional().describe("Tripo texture tier. detailed costs more."),
5780
- geometryQuality: z8.enum(["standard", "detailed"]).optional().describe("Tripo geometry tier. detailed costs more."),
5781
- quadRemesh: z8.boolean().optional().describe("Tripo: quad topology instead of triangles."),
5782
- smartLowPoly: z8.boolean().optional().describe("Tripo text-to-3D: a low-poly mesh."),
5783
- resolution: z8.enum(["512", "1024", "1536"]).optional().describe("TRELLIS.2 resolution (default 1024)."),
5784
- targetPolycount: z8.number().int().min(100).max(15e5).optional().describe("Target face count, where the model supports one."),
5785
- topology: z8.enum(["quad", "triangle"]).optional().describe("Hunyuan Pro polygon type."),
5786
- seed: z8.number().int().optional()
6008
+ model: z9.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)."),
6009
+ options: z9.object({
6010
+ enableTexture: z9.boolean().optional().describe("Texture the mesh (default true). Off gives bare geometry and costs less."),
6011
+ enablePbr: z9.boolean().optional().describe("Physically-based rendering (PBR) material maps. Default on for Hunyuan Pro, off elsewhere."),
6012
+ textureQuality: z9.enum(["standard", "detailed"]).optional().describe("Tripo texture tier. detailed costs more."),
6013
+ geometryQuality: z9.enum(["standard", "detailed"]).optional().describe("Tripo geometry tier. detailed costs more."),
6014
+ quadRemesh: z9.boolean().optional().describe("Tripo: quad topology instead of triangles."),
6015
+ smartLowPoly: z9.boolean().optional().describe("Tripo text-to-3D: a low-poly mesh."),
6016
+ resolution: z9.enum(["512", "1024", "1536"]).optional().describe("TRELLIS.2 resolution (default 1024)."),
6017
+ targetPolycount: z9.number().int().min(100).max(15e5).optional().describe("Target face count, where the model supports one."),
6018
+ topology: z9.enum(["quad", "triangle"]).optional().describe("Hunyuan Pro polygon type."),
6019
+ seed: z9.number().int().optional()
5787
6020
  }).optional().describe("Model-specific quality flags. Each changes the price; the returned costUsd is the price of the request that was sent."),
5788
- projectId: z8.string().min(1).optional().describe("Project to file the model under (from studio_list_projects). Omit for the default project."),
5789
- wait: z8.boolean().default(true).describe("Poll until the job finishes (default true)."),
6021
+ projectId: z9.string().min(1).optional().describe("Project to file the model under (from studio_list_projects). Omit for the default project."),
6022
+ wait: z9.boolean().default(true).describe("Poll until the job finishes (default true)."),
5790
6023
  waitSeconds
5791
6024
  },
5792
6025
  handler: async (args, ctx) => {
@@ -5824,8 +6057,8 @@ var studioFindAnimations = defineTool({
5824
6057
  name: "studio_find_animations",
5825
6058
  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.',
5826
6059
  inputSchema: {
5827
- query: z8.string().describe('Words to match, e.g. "sword slash". Empty returns the first presets in library order.'),
5828
- limit: z8.number().int().min(1).max(50).default(25)
6060
+ query: z9.string().describe('Words to match, e.g. "sword slash". Empty returns the first presets in library order.'),
6061
+ limit: z9.number().int().min(1).max(50).default(25)
5829
6062
  },
5830
6063
  annotations: { readOnlyHint: true },
5831
6064
  handler: async (args) => ({ animations: searchAnimations(args.query, args.limit) })
@@ -5834,12 +6067,12 @@ var studioRig3d = defineTool({
5834
6067
  name: "studio_rig_3d",
5835
6068
  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.",
5836
6069
  inputSchema: {
5837
- projectId: z8.string().min(1).describe("The project the mesh lives in (from studio_list_projects)."),
5838
- meshAssetId: z8.string().min(1).describe("The Model3D asset to rig: the assetId studio_generate_3d returned."),
5839
- animations: z8.array(z8.union([z8.string().min(1), z8.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.'),
5840
- heightMeters: z8.number().min(0.3).max(5).optional().describe("The character's approximate height in meters (default 1.7); Meshy scales the rig to it."),
5841
- visibility: z8.enum(["listed", "unlisted"]).optional(),
5842
- wait: z8.boolean().default(true).describe("Poll until the rig finishes (default true)."),
6070
+ projectId: z9.string().min(1).describe("The project the mesh lives in (from studio_list_projects)."),
6071
+ meshAssetId: z9.string().min(1).describe("The Model3D asset to rig: the assetId studio_generate_3d returned."),
6072
+ animations: z9.array(z9.union([z9.string().min(1), z9.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.'),
6073
+ heightMeters: z9.number().min(0.3).max(5).optional().describe("The character's approximate height in meters (default 1.7); Meshy scales the rig to it."),
6074
+ visibility: z9.enum(["listed", "unlisted"]).optional(),
6075
+ wait: z9.boolean().default(true).describe("Poll until the rig finishes (default true)."),
5843
6076
  waitSeconds
5844
6077
  },
5845
6078
  handler: async (args, ctx) => {
@@ -5896,8 +6129,8 @@ var studioGetJob = defineTool({
5896
6129
  name: "studio_get_job",
5897
6130
  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.",
5898
6131
  inputSchema: {
5899
- jobId: z8.string().min(1),
5900
- wait: z8.boolean().default(false).describe("Poll until terminal (default false: return the current state)."),
6132
+ jobId: z9.string().min(1),
6133
+ wait: z9.boolean().default(false).describe("Poll until terminal (default false: return the current state)."),
5901
6134
  waitSeconds
5902
6135
  },
5903
6136
  annotations: { readOnlyHint: true },
@@ -5927,7 +6160,7 @@ var studioGetCharacter = defineTool({
5927
6160
  }
5928
6161
  });
5929
6162
  var LIKENESS_REFUSAL = `${LIKENESS_CONFIRMATION_REQUIRED_CODE}: ${likenessConfirmationRequiredMessage()}`;
5930
- var likenessRightsConfirmed = z8.literal(true, { error: LIKENESS_REFUSAL }).describe(likenessConfirmationToolDescription());
6163
+ var likenessRightsConfirmed = z9.literal(true, { error: LIKENESS_REFUSAL }).describe(likenessConfirmationToolDescription());
5931
6164
  function assertLikenessRightsConfirmed(value) {
5932
6165
  if (!isLikenessRightsConfirmed(value)) throw new Error(LIKENESS_REFUSAL);
5933
6166
  }
@@ -5935,11 +6168,11 @@ var studioCreateCharacter = defineTool({
5935
6168
  name: "studio_create_character",
5936
6169
  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.",
5937
6170
  inputSchema: {
5938
- name: z8.string().min(1).describe('Display name, e.g. "Bruno Hartmann".'),
6171
+ name: z9.string().min(1).describe('Display name, e.g. "Bruno Hartmann".'),
5939
6172
  slug,
5940
- descriptorPrompt: z8.string().min(1).describe("The identity description prepended to every generation that uses this character."),
5941
- negativePrompt: z8.string().optional(),
5942
- defaultModel: z8.string().optional().describe("Default image model id for this character."),
6173
+ descriptorPrompt: z9.string().min(1).describe("The identity description prepended to every generation that uses this character."),
6174
+ negativePrompt: z9.string().optional(),
6175
+ defaultModel: z9.string().optional().describe("Default image model id for this character."),
5943
6176
  likenessRightsConfirmed
5944
6177
  },
5945
6178
  handler: async (args, ctx) => {
@@ -5959,16 +6192,16 @@ var studioMintCharacter = defineTool({
5959
6192
  name: "studio_mint_character",
5960
6193
  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.",
5961
6194
  inputSchema: {
5962
- projectId: z8.string().min(1).describe("Project id from studio_list_projects."),
5963
- name: z8.string().min(1).describe("Display name."),
6195
+ projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
6196
+ name: z9.string().min(1).describe("Display name."),
5964
6197
  slug,
5965
- description: z8.string().min(10).describe("Seed identity description (face, hair, age, build, distinguishing features)."),
5966
- descriptorPrompt: z8.string().optional().describe("Override for the character's stored descriptor prompt. Defaults to the description."),
5967
- negativePrompt: z8.string().optional(),
5968
- defaultModel: z8.string().optional(),
5969
- seedModel: z8.string().optional().describe("Override the seed text-to-image model (default fal/nano-banana-2)."),
5970
- viewModel: z8.string().optional().describe("Override the view image-edit model (default fal/nano-banana-2-edit)."),
5971
- visibility: z8.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
6198
+ description: z9.string().min(10).describe("Seed identity description (face, hair, age, build, distinguishing features)."),
6199
+ descriptorPrompt: z9.string().optional().describe("Override for the character's stored descriptor prompt. Defaults to the description."),
6200
+ negativePrompt: z9.string().optional(),
6201
+ defaultModel: z9.string().optional(),
6202
+ seedModel: z9.string().optional().describe("Override the seed text-to-image model (default fal/nano-banana-2)."),
6203
+ viewModel: z9.string().optional().describe("Override the view image-edit model (default fal/nano-banana-2-edit)."),
6204
+ visibility: z9.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
5972
6205
  likenessRightsConfirmed,
5973
6206
  waitSeconds
5974
6207
  },
@@ -6027,12 +6260,12 @@ var studioCreateBrand = defineTool({
6027
6260
  name: "studio_create_brand",
6028
6261
  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.",
6029
6262
  inputSchema: {
6030
- name: z8.string().min(1),
6263
+ name: z9.string().min(1),
6031
6264
  slug,
6032
- stylePrefix: z8.string().optional().describe("Text prepended to every prompt generated under this brand."),
6033
- context: z8.string().optional().describe("Markdown brand context (tone, palette, do/don't)."),
6034
- defaultModel: z8.string().optional(),
6035
- maxReferenceImages: z8.number().int().min(0).max(8).optional()
6265
+ stylePrefix: z9.string().optional().describe("Text prepended to every prompt generated under this brand."),
6266
+ context: z9.string().optional().describe("Markdown brand context (tone, palette, do/don't)."),
6267
+ defaultModel: z9.string().optional(),
6268
+ maxReferenceImages: z9.number().int().min(0).max(8).optional()
6036
6269
  },
6037
6270
  handler: async (args, ctx) => {
6038
6271
  const { config } = await ctx.client.createBrand({
@@ -6051,11 +6284,11 @@ var studioUploadBrandReference = defineTool({
6051
6284
  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.`,
6052
6285
  inputSchema: {
6053
6286
  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."),
6054
- source: z8.string().min(1).describe("Local file path or http(s) URL of an image."),
6055
- category: z8.string().optional().describe('Library category, default "general".'),
6056
- label: z8.string().optional().describe("Optional file name / label."),
6057
- tags: z8.array(z8.string()).optional(),
6058
- score: z8.number().int().min(1).max(10).optional()
6287
+ source: z9.string().min(1).describe("Local file path or http(s) URL of an image."),
6288
+ category: z9.string().optional().describe('Library category, default "general".'),
6289
+ label: z9.string().optional().describe("Optional file name / label."),
6290
+ tags: z9.array(z9.string()).optional(),
6291
+ score: z9.number().int().min(1).max(10).optional()
6059
6292
  },
6060
6293
  handler: async (args, ctx) => {
6061
6294
  const file = await loadImageSource(args.source, ctx.client);
@@ -6076,23 +6309,23 @@ var studioRunWorkflow = defineTool({
6076
6309
  name: "studio_run_workflow",
6077
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.`,
6078
6311
  inputSchema: {
6079
- projectId: z8.string().min(1).describe("Project id from studio_list_projects."),
6312
+ projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
6080
6313
  definition: workflowDefinitionSchema.optional(),
6081
- savedId: z8.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."),
6082
- params: z8.record(z8.string(), z8.unknown()).optional().describe("Values for the definition's params."),
6083
- nodeIds: z8.array(z8.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
6084
- upstreamGenerations: z8.record(z8.string(), z8.string()).optional().describe(
6314
+ savedId: z9.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."),
6315
+ params: z9.record(z9.string(), z9.unknown()).optional().describe("Values for the definition's params."),
6316
+ nodeIds: z9.array(z9.string()).optional().describe("Run only this subset of nodes (requires an inline `definition` or a `savedId`)."),
6317
+ upstreamGenerations: z9.record(z9.string(), z9.string()).optional().describe(
6085
6318
  '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.'
6086
6319
  ),
6087
- runs: z8.number().int().min(1).max(8).optional().describe("Repeat a node subset N times (1 to 8)."),
6088
- visibility: z8.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
6089
- budgetUsd: z8.number().nonnegative().optional().describe(
6320
+ runs: z9.number().int().min(1).max(8).optional().describe("Repeat a node subset N times (1 to 8)."),
6321
+ visibility: z9.enum(["listed", "unlisted"]).optional().describe("Whether the run shows in the Studio workflow list."),
6322
+ budgetUsd: z9.number().nonnegative().optional().describe(
6090
6323
  '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.'
6091
6324
  ),
6092
- confirm: z8.boolean().optional().describe(
6325
+ confirm: z9.boolean().optional().describe(
6093
6326
  '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 }.'
6094
6327
  ),
6095
- wait: z8.boolean().default(true),
6328
+ wait: z9.boolean().default(true),
6096
6329
  waitSeconds
6097
6330
  },
6098
6331
  handler: async (args, ctx) => {
@@ -6123,8 +6356,8 @@ var studioGetRun = defineTool({
6123
6356
  name: "studio_get_run",
6124
6357
  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.",
6125
6358
  inputSchema: {
6126
- runId: z8.string().min(1),
6127
- wait: z8.boolean().default(false),
6359
+ runId: z9.string().min(1),
6360
+ wait: z9.boolean().default(false),
6128
6361
  waitSeconds
6129
6362
  },
6130
6363
  annotations: { readOnlyHint: true },
@@ -6137,11 +6370,11 @@ var studioDecideJudge = defineTool({
6137
6370
  name: "studio_decide_judge",
6138
6371
  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.",
6139
6372
  inputSchema: {
6140
- runId: z8.string().min(1),
6141
- nodeId: z8.string().min(1),
6142
- verdict: z8.enum(["approved", "rejected"]),
6143
- candidate: z8.object({ generationId: z8.string().min(1), index: z8.number().int().min(0).optional() }).optional(),
6144
- reason: z8.string().max(500).optional()
6373
+ runId: z9.string().min(1),
6374
+ nodeId: z9.string().min(1),
6375
+ verdict: z9.enum(["approved", "rejected"]),
6376
+ candidate: z9.object({ generationId: z9.string().min(1), index: z9.number().int().min(0).optional() }).optional(),
6377
+ reason: z9.string().max(500).optional()
6145
6378
  },
6146
6379
  annotations: { destructiveHint: false, idempotentHint: false },
6147
6380
  handler: async (args, ctx) => {
@@ -6157,8 +6390,8 @@ var studioGetRunOutput = defineTool({
6157
6390
  name: "studio_get_run_output",
6158
6391
  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.",
6159
6392
  inputSchema: {
6160
- runId: z8.string().min(1),
6161
- nodeId: z8.string().min(1)
6393
+ runId: z9.string().min(1),
6394
+ nodeId: z9.string().min(1)
6162
6395
  },
6163
6396
  annotations: { readOnlyHint: true },
6164
6397
  handler: async (args, ctx) => {
@@ -6170,21 +6403,21 @@ var studioReplaceCharacterInVideo = defineTool({
6170
6403
  name: "studio_replace_character_in_video",
6171
6404
  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.',
6172
6405
  inputSchema: {
6173
- projectId: z8.string().min(1).describe("Project id from studio_list_projects."),
6406
+ projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
6174
6407
  sceneFrameUrl: httpUrl.describe("Public or signed URL of ONE frame of the target shot (png/jpg)."),
6175
6408
  characterSlug: slug.optional().describe(
6176
6409
  "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."
6177
6410
  ),
6178
6411
  characterReferenceUrl: httpUrl.optional().describe("Explicit character reference image URL (use instead of characterSlug)."),
6179
6412
  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."),
6180
- scope: z8.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."),
6181
- preserve: z8.array(z8.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.'),
6182
- swapPrompt: z8.string().optional().describe("A complete still-swap edit prompt of your own; replaces the composed one, so scope and preserve are then ignored."),
6183
- motionPrompt: z8.string().optional().describe("Override the motion description for the video node."),
6184
- videoModel: z8.string().optional().describe(`Image-to-video model id. Default ${DEFAULT_SWAP_VIDEO_MODEL}, or ${KEYFRAME_SWAP_VIDEO_MODEL} when endFrameUrl is given.`),
6185
- editModel: z8.string().default(DEFAULT_SWAP_EDIT_MODEL).describe("Image-edit model id for the still swap."),
6186
- aspectRatio: z8.string().default("16:9"),
6187
- visibility: z8.enum(["listed", "unlisted"]).optional(),
6413
+ scope: z9.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."),
6414
+ preserve: z9.array(z9.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.'),
6415
+ swapPrompt: z9.string().optional().describe("A complete still-swap edit prompt of your own; replaces the composed one, so scope and preserve are then ignored."),
6416
+ motionPrompt: z9.string().optional().describe("Override the motion description for the video node."),
6417
+ videoModel: z9.string().optional().describe(`Image-to-video model id. Default ${DEFAULT_SWAP_VIDEO_MODEL}, or ${KEYFRAME_SWAP_VIDEO_MODEL} when endFrameUrl is given.`),
6418
+ editModel: z9.string().default(DEFAULT_SWAP_EDIT_MODEL).describe("Image-edit model id for the still swap."),
6419
+ aspectRatio: z9.string().default("16:9"),
6420
+ visibility: z9.enum(["listed", "unlisted"]).optional(),
6188
6421
  waitSeconds
6189
6422
  },
6190
6423
  handler: async (args, ctx) => {
@@ -6249,7 +6482,7 @@ var studioGetSpend = defineTool({
6249
6482
  name: "studio_get_spend",
6250
6483
  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).`,
6251
6484
  inputSchema: {
6252
- tzOffsetMinutes: z8.number().int().min(-840).max(840).optional()
6485
+ tzOffsetMinutes: z9.number().int().min(-840).max(840).optional()
6253
6486
  },
6254
6487
  annotations: { readOnlyHint: true },
6255
6488
  handler: async (args, ctx) => {
@@ -6277,7 +6510,7 @@ var studioDescribePublished = defineTool({
6277
6510
  name: "studio_describe_published",
6278
6511
  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.",
6279
6512
  inputSchema: {
6280
- slug: z8.string().min(1).describe("The recipe slug, from studio_list_published.")
6513
+ slug: z9.string().min(1).describe("The recipe slug, from studio_list_published.")
6281
6514
  },
6282
6515
  annotations: { readOnlyHint: true },
6283
6516
  handler: async (args, ctx) => {
@@ -6289,17 +6522,17 @@ var studioRunPublished = defineTool({
6289
6522
  name: "studio_run_published",
6290
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.`,
6291
6524
  inputSchema: {
6292
- slug: z8.string().min(1).describe("The recipe slug, from studio_list_published."),
6293
- projectId: z8.string().min(1).describe("Project id from studio_list_projects."),
6294
- params: z8.record(z8.string(), z8.unknown()).optional().describe("Values for the recipe's params (see studio_describe_published)."),
6295
- budgetUsd: z8.number().nonnegative().optional().describe(
6525
+ slug: z9.string().min(1).describe("The recipe slug, from studio_list_published."),
6526
+ projectId: z9.string().min(1).describe("Project id from studio_list_projects."),
6527
+ params: z9.record(z9.string(), z9.unknown()).optional().describe("Values for the recipe's params (see studio_describe_published)."),
6528
+ budgetUsd: z9.number().nonnegative().optional().describe(
6296
6529
  '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 }.'
6297
6530
  ),
6298
- confirm: z8.boolean().optional().describe(
6531
+ confirm: z9.boolean().optional().describe(
6299
6532
  '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 }.'
6300
6533
  ),
6301
- likenessRightsConfirmed: z8.literal(true).optional().describe(`Required when the recipe creates a character; ignored otherwise. ${likenessConfirmationToolDescription()}`),
6302
- wait: z8.boolean().default(true),
6534
+ likenessRightsConfirmed: z9.literal(true).optional().describe(`Required when the recipe creates a character; ignored otherwise. ${likenessConfirmationToolDescription()}`),
6535
+ wait: z9.boolean().default(true),
6303
6536
  waitSeconds
6304
6537
  },
6305
6538
  handler: async (args, ctx) => {
@@ -6338,7 +6571,8 @@ var TOOLS = [
6338
6571
  studioDescribePublished,
6339
6572
  studioRunPublished,
6340
6573
  studioGetUsage,
6341
- ...WORKFLOW_TOOLS
6574
+ ...WORKFLOW_TOOLS,
6575
+ ...MANAGE_TOOLS
6342
6576
  ];
6343
6577
  var TOOL_NAMES = TOOLS.map((t) => t.name);
6344
6578
  function toolResult(value) {
@@ -6356,14 +6590,42 @@ function toolError(message) {
6356
6590
  }
6357
6591
  async function invokeTool(def, args, ctx) {
6358
6592
  try {
6359
- const parsed = z8.object(def.inputSchema).parse(args ?? {});
6593
+ const parsed = z9.object(def.inputSchema).parse(args ?? {});
6360
6594
  const value = await def.handler(parsed, ctx);
6361
6595
  return toolResult(value);
6362
6596
  } catch (err) {
6363
6597
  return toolError(ctx.client.redact(errorMessage(err)));
6364
6598
  }
6365
6599
  }
6366
- function registerTools(server, ctx) {
6600
+ function elicitConfirmation(server) {
6601
+ return async (message) => {
6602
+ if (!server.server.getClientCapabilities()?.elicitation) return "unavailable";
6603
+ try {
6604
+ const result = await server.server.elicitInput({
6605
+ message,
6606
+ requestedSchema: {
6607
+ type: "object",
6608
+ properties: {
6609
+ confirm: { type: "boolean", title: "Delete", description: "Yes, delete it. This cannot be undone." }
6610
+ },
6611
+ required: ["confirm"]
6612
+ }
6613
+ });
6614
+ return result.action === "accept" && result.content?.confirm === true ? "confirmed" : "declined";
6615
+ } catch (err) {
6616
+ const code = err?.code;
6617
+ if (code === METHOD_NOT_FOUND || /does not support/i.test(err instanceof Error ? err.message : "")) return "unavailable";
6618
+ return "declined";
6619
+ }
6620
+ };
6621
+ }
6622
+ var METHOD_NOT_FOUND = -32601;
6623
+ function registerTools(server, base) {
6624
+ const ctx = {
6625
+ ...base,
6626
+ confirm: base.confirm ?? elicitConfirmation(server),
6627
+ confirmations: base.confirmations ?? new ConfirmationStore()
6628
+ };
6367
6629
  for (const def of TOOLS) {
6368
6630
  server.registerTool(
6369
6631
  def.name,
@@ -6379,7 +6641,7 @@ function registerTools(server, ctx) {
6379
6641
 
6380
6642
  // src/server.ts
6381
6643
  var SERVER_NAME = "lumitra-studio";
6382
- var SERVER_VERSION = "0.6.0";
6644
+ var SERVER_VERSION = "0.7.0";
6383
6645
  function createStudioMcpServer(opts = {}) {
6384
6646
  const config = opts.config ?? resolveConfig(opts.env ?? process.env);
6385
6647
  const client = new StudioClient(config, {
@@ -6485,7 +6747,7 @@ async function runHttp(args) {
6485
6747
  });
6486
6748
  const addr = httpServer.address();
6487
6749
  const port = typeof addr === "object" && addr ? addr.port : args.port;
6488
- process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${randomUUID2().slice(0, 8)})
6750
+ process.stderr.write(`[${SERVER_NAME}] Streamable HTTP on http://${args.host}:${port}/mcp (${TOOL_NAMES.length} tools, instance ${randomUUID3().slice(0, 8)})
6489
6751
  `);
6490
6752
  const shutdown = () => {
6491
6753
  httpServer.close(() => process.exit(0));