@marlinjai/studio-mcp 0.10.0 → 0.12.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 +2 -1
- package/dist/cli.js +76 -6
- package/dist/index.d.ts +32 -3
- package/dist/index.js +76 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -118,13 +118,14 @@ The token is held in memory only. It is never logged, never serialized into a re
|
|
|
118
118
|
| `studio_composition_send_to_social` | Send the rendered post to Lumitra Social as a draft or scheduled post (a reel, an image, or a carousel of 2 to 10 slides). Idempotent: a retry with the same key resumes and never posts twice. |
|
|
119
119
|
| `studio_create_project` / `studio_rename_project` | Create a project by name, or rename one. Any member's key may. |
|
|
120
120
|
| `studio_delete_project` | Delete a project for everyone with its workflows, runs, assets and chats. Needs an admin key, and the PERSON's yes: the tool asks them through the client's confirmation dialog (Model Context Protocol elicitation), or, for a client without one, returns `confirmationRequired` with a `summary` and a one-time `confirmationToken` the agent may only send back after the person said yes in the chat. Refused for the default project and while work is running. |
|
|
121
|
+
| `studio_delete_asset` | Delete one asset (an image, a video, a rendered slide or reel) for everyone with its stored file. Needs an admin key, and the PERSON's yes, confirmed the same way as a project delete. Refused while a post, a saved workflow, a published recipe or work in flight still uses it: the result then carries `usedIn` with each place and nothing is deleted. Records of what happened (campaign shots, sent posts, past runs, the job and its cost) survive without it. |
|
|
121
122
|
| `studio_list_workflows` / `studio_move_workflow` | List a project's saved workflows; move one to another project with its runs and results (reversible, not confirmed). |
|
|
122
123
|
| `studio_list_campaigns` / `studio_delete_campaign` | List the company's campaigns; delete one with its shot list (its images stay), confirmed by the person exactly like a project delete. |
|
|
123
124
|
| `studio_list_published` | List every published recipe: `{ recipes: [{ slug, label, publishedRevision, updatedAt, hasEffects }] }`. `hasEffects` tells you whether running it creates/attaches an entity record (a character, a brand reference) on success, versus a pure generation recipe. Free, read-only. |
|
|
124
125
|
| `studio_describe_published` | 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. Read this before `studio_run_published` to know what params it needs. Free, read-only. |
|
|
125
126
|
| `studio_run_published` | Run a published recipe by slug against its frozen definition; `params` fill the definition's own param bindings. On success, the recipe's declared post-run effects fire automatically (e.g. minting creates the character and attaches its reference views); effects never fire on a failed, partial or cancelled run. Each node is a paid job. A recipe that creates a character requires `likenessRightsConfirmed: true`, refused before any spend otherwise. |
|
|
126
127
|
|
|
127
|
-
All waiting tools accept `waitSeconds` (default 600) and back off between polls (2s doubling up to 15s). A timeout never cancels anything server-side: the tool error carries the id so the agent can poll again.
|
|
128
|
+
All waiting tools accept `waitSeconds` (default 600) and back off between polls (2s doubling up to 15s). A timeout never cancels anything server-side: the tool error carries the id so the agent can poll again. A poll that gets a 503 (Studio could not reach its sign-in service, `auth_unavailable`) or no answer at all is waited out within the same budget instead of ending the wait, because the job keeps running either way.
|
|
128
129
|
|
|
129
130
|
### Tool signatures (the contract shared with the `lumitra-studio` plugin)
|
|
130
131
|
|
package/dist/cli.js
CHANGED
|
@@ -171,6 +171,12 @@ var StudioClient = class {
|
|
|
171
171
|
deleteProject(projectId) {
|
|
172
172
|
return this.json("DELETE", `/api/v1/projects/${encodeURIComponent(projectId)}`);
|
|
173
173
|
}
|
|
174
|
+
describeAssetUsage(projectId, assetId) {
|
|
175
|
+
return this.json("GET", `/api/v1/projects/${encodeURIComponent(projectId)}/assets/${encodeURIComponent(assetId)}`);
|
|
176
|
+
}
|
|
177
|
+
deleteAsset(projectId, assetId) {
|
|
178
|
+
return this.json("DELETE", `/api/v1/projects/${encodeURIComponent(projectId)}/assets/${encodeURIComponent(assetId)}`);
|
|
179
|
+
}
|
|
174
180
|
// ── Saved workflows (listing and moving; authoring lives with the workflow tools) ──
|
|
175
181
|
listWorkflows(opts = {}) {
|
|
176
182
|
return this.json("GET", `/api/v1/workflows${projectQuery(opts.projectId)}`);
|
|
@@ -5460,6 +5466,9 @@ function assertImage(file, source) {
|
|
|
5460
5466
|
// src/poll.ts
|
|
5461
5467
|
var DEFAULT_TIMEOUT_MS = 6e5;
|
|
5462
5468
|
var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
5469
|
+
function isTransientPollError(err) {
|
|
5470
|
+
return err instanceof StudioApiError && (err.status === 503 || err.status === 0);
|
|
5471
|
+
}
|
|
5463
5472
|
async function pollUntil(what, fetchState, isDone, opts = {}) {
|
|
5464
5473
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
5465
5474
|
const factor = opts.factor ?? 1.5;
|
|
@@ -5468,15 +5477,30 @@ async function pollUntil(what, fetchState, isDone, opts = {}) {
|
|
|
5468
5477
|
const now = opts.now ?? Date.now;
|
|
5469
5478
|
const start = now();
|
|
5470
5479
|
let delay = opts.initialDelayMs ?? 2e3;
|
|
5471
|
-
let
|
|
5472
|
-
|
|
5480
|
+
let observed = false;
|
|
5481
|
+
let last;
|
|
5482
|
+
let lastTransient;
|
|
5483
|
+
const poll = async () => {
|
|
5484
|
+
try {
|
|
5485
|
+
last = await fetchState();
|
|
5486
|
+
observed = true;
|
|
5487
|
+
return isDone(last);
|
|
5488
|
+
} catch (err) {
|
|
5489
|
+
if (!isTransientPollError(err)) throw err;
|
|
5490
|
+
lastTransient = err;
|
|
5491
|
+
return false;
|
|
5492
|
+
}
|
|
5493
|
+
};
|
|
5494
|
+
if (await poll()) return last;
|
|
5473
5495
|
for (; ; ) {
|
|
5474
5496
|
const elapsed = now() - start;
|
|
5475
5497
|
const remaining = timeoutMs - elapsed;
|
|
5476
|
-
if (remaining <= 0)
|
|
5498
|
+
if (remaining <= 0) {
|
|
5499
|
+
if (!observed) throw lastTransient;
|
|
5500
|
+
throw new PollTimeoutError(what, timeoutMs, last);
|
|
5501
|
+
}
|
|
5477
5502
|
await sleep(Math.min(delay, remaining));
|
|
5478
|
-
|
|
5479
|
-
if (isDone(last)) return last;
|
|
5503
|
+
if (await poll()) return last;
|
|
5480
5504
|
delay = Math.min(maxDelay, Math.round(delay * factor));
|
|
5481
5505
|
}
|
|
5482
5506
|
}
|
|
@@ -6615,6 +6639,15 @@ function campaignDeleteSummary(c) {
|
|
|
6615
6639
|
const kept = c.imagesKept > 0 ? ` Its ${count(c.imagesKept, "image stays", "images stay")} in the asset library.` : "";
|
|
6616
6640
|
return `Delete the campaign "${c.name}" with its ${count(c.shots, "shot", "shots")} and every approve and reject decision?${kept} This cannot be undone.`;
|
|
6617
6641
|
}
|
|
6642
|
+
function assetReferenceLines(refs) {
|
|
6643
|
+
return refs.map((r) => `- ${r.label}: ${r.detail}`).join("\n");
|
|
6644
|
+
}
|
|
6645
|
+
function assetDeleteSummary(u) {
|
|
6646
|
+
const kind = u.subtype === "Image" ? "image" : u.subtype === "Video" ? "video" : u.subtype === "CarouselSlide" ? "rendered slide" : u.subtype === "Reel" ? "rendered reel" : `${u.subtype} asset`;
|
|
6647
|
+
const prompt = u.prompt?.trim();
|
|
6648
|
+
const named = prompt ? ` "${prompt.length > 120 ? `${prompt.slice(0, 117)}...` : prompt}"` : "";
|
|
6649
|
+
return `Delete the ${kind}${named} made ${u.createdAt.slice(0, 10)} (id ${u.assetId}) for everyone in the company, with its stored file? Campaign shots, sent posts and past runs keep their record without it. This cannot be undone.`;
|
|
6650
|
+
}
|
|
6618
6651
|
function projectSubject(c) {
|
|
6619
6652
|
return ["delete-project", c.project.id, c.project.name, c.workflows, c.publishedWorkflows, c.runs, c.assets, c.chats, c.campaignShots].join(":");
|
|
6620
6653
|
}
|
|
@@ -6697,6 +6730,42 @@ var studioDeleteProject = defineTool({
|
|
|
6697
6730
|
}
|
|
6698
6731
|
}
|
|
6699
6732
|
});
|
|
6733
|
+
var IN_USE_INSTRUCTION = "Nothing was deleted. Tell the person where the asset is still used (`usedIn`). Removing it from a post or a workflow is their edit to make (or yours with the composition or workflow tools, if they ask); work in flight has to finish first. Then call this tool again.";
|
|
6734
|
+
var studioDeleteAsset = defineTool({
|
|
6735
|
+
name: "studio_delete_asset",
|
|
6736
|
+
description: "Delete one asset (an image, a video, a rendered slide or reel) of your company for everyone, with its stored file. Needs a key with the company admin role. Refused while a post (a carousel slide or reel clip), a saved workflow or published recipe (a source node, a baked reference, a node pinned to the generation that made it) or work in flight (a generation, a run, a send to Lumitra Social) still uses it: the tool then returns `usedIn` with each place, and nothing is deleted. Records of what happened survive without it (campaign shots, product links, derived assets, the job and its cost, sent posts). The PERSON confirms every delete in the chat: this tool 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.",
|
|
6737
|
+
inputSchema: {
|
|
6738
|
+
projectId: z10.string().min(1).describe("The project the asset is in, from studio_list_projects."),
|
|
6739
|
+
assetId: z10.string().min(1).describe("The asset, from studio_list_assets."),
|
|
6740
|
+
confirmationToken
|
|
6741
|
+
},
|
|
6742
|
+
annotations: { destructiveHint: true },
|
|
6743
|
+
handler: async (args, ctx) => {
|
|
6744
|
+
const inUse = (references) => ({
|
|
6745
|
+
deleted: false,
|
|
6746
|
+
inUse: true,
|
|
6747
|
+
usedIn: references,
|
|
6748
|
+
message: `The asset is still used:
|
|
6749
|
+
${assetReferenceLines(references)}`,
|
|
6750
|
+
instruction: IN_USE_INSTRUCTION
|
|
6751
|
+
});
|
|
6752
|
+
const usage = await ctx.client.describeAssetUsage(args.projectId, args.assetId);
|
|
6753
|
+
if (usage.references.length > 0) return inUse(usage.references);
|
|
6754
|
+
const summary = assetDeleteSummary(usage);
|
|
6755
|
+
const gate = await confirmWithPerson(ctx, summary, ["delete-asset", args.projectId, args.assetId].join(":"), args.confirmationToken);
|
|
6756
|
+
if (gate !== "proceed") return gate;
|
|
6757
|
+
try {
|
|
6758
|
+
const res = await ctx.client.deleteAsset(args.projectId, args.assetId);
|
|
6759
|
+
return { deleted: true, assetId: res.assetId, filesDeleted: res.filesDeleted, filesKept: res.filesKept, summary };
|
|
6760
|
+
} catch (err) {
|
|
6761
|
+
if (err instanceof StudioApiError && err.status === 409) {
|
|
6762
|
+
const refs = err.body?.references ?? [];
|
|
6763
|
+
return inUse(refs);
|
|
6764
|
+
}
|
|
6765
|
+
return roleRefusal(err, "Deleting an asset needs a key with the company admin role; this key does not have it.");
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6768
|
+
});
|
|
6700
6769
|
var studioListWorkflows = defineTool({
|
|
6701
6770
|
name: "studio_list_workflows",
|
|
6702
6771
|
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.",
|
|
@@ -6755,6 +6824,7 @@ var MANAGE_TOOLS = [
|
|
|
6755
6824
|
studioCreateProject,
|
|
6756
6825
|
studioRenameProject,
|
|
6757
6826
|
studioDeleteProject,
|
|
6827
|
+
studioDeleteAsset,
|
|
6758
6828
|
studioListWorkflows,
|
|
6759
6829
|
studioMoveWorkflow,
|
|
6760
6830
|
studioListCampaigns,
|
|
@@ -7542,7 +7612,7 @@ function registerTools(server, base) {
|
|
|
7542
7612
|
|
|
7543
7613
|
// src/server.ts
|
|
7544
7614
|
var SERVER_NAME = "lumitra-studio";
|
|
7545
|
-
var SERVER_VERSION = "0.
|
|
7615
|
+
var SERVER_VERSION = "0.12.0";
|
|
7546
7616
|
function createStudioMcpServer(opts = {}) {
|
|
7547
7617
|
const config = opts.config ?? resolveConfig(opts.env ?? process.env);
|
|
7548
7618
|
const client = new StudioClient(config, {
|
package/dist/index.d.ts
CHANGED
|
@@ -1149,6 +1149,24 @@ interface ProjectSummary {
|
|
|
1149
1149
|
slug: string;
|
|
1150
1150
|
name: string;
|
|
1151
1151
|
}
|
|
1152
|
+
/** A place that still uses an asset, as `GET /api/v1/projects/:id/assets/:assetId` lists it. */
|
|
1153
|
+
interface AssetReference {
|
|
1154
|
+
kind: 'post' | 'workflow' | 'recipe' | 'generation' | 'run' | 'social-send';
|
|
1155
|
+
id: string;
|
|
1156
|
+
label: string;
|
|
1157
|
+
detail: string;
|
|
1158
|
+
href: string | null;
|
|
1159
|
+
}
|
|
1160
|
+
/** `GET /api/v1/projects/:id/assets/:assetId`: the asset as a confirmation names it, and where it is used. */
|
|
1161
|
+
interface AssetUsage {
|
|
1162
|
+
assetId: string;
|
|
1163
|
+
projectId: string;
|
|
1164
|
+
subtype: string;
|
|
1165
|
+
prompt: string | null;
|
|
1166
|
+
mimeType: string | null;
|
|
1167
|
+
createdAt: string;
|
|
1168
|
+
references: AssetReference[];
|
|
1169
|
+
}
|
|
1152
1170
|
/** `GET /api/v1/projects/:id`: the project and what deleting it would remove. */
|
|
1153
1171
|
interface ProjectContents {
|
|
1154
1172
|
project: ProjectSummary & {
|
|
@@ -1623,6 +1641,14 @@ declare class StudioClient {
|
|
|
1623
1641
|
project: ProjectSummary;
|
|
1624
1642
|
fallbackProjectId: string;
|
|
1625
1643
|
}>;
|
|
1644
|
+
describeAssetUsage(projectId: string, assetId: string): Promise<AssetUsage>;
|
|
1645
|
+
deleteAsset(projectId: string, assetId: string): Promise<{
|
|
1646
|
+
deleted: true;
|
|
1647
|
+
assetId: string;
|
|
1648
|
+
filesDeleted: number;
|
|
1649
|
+
filesKept: number;
|
|
1650
|
+
generationsDetached: number;
|
|
1651
|
+
}>;
|
|
1626
1652
|
listWorkflows(opts?: {
|
|
1627
1653
|
projectId?: string;
|
|
1628
1654
|
}): Promise<{
|
|
@@ -1963,7 +1989,10 @@ interface PollOptions {
|
|
|
1963
1989
|
declare const DEFAULT_TIMEOUT_MS = 600000;
|
|
1964
1990
|
/**
|
|
1965
1991
|
* Call `fetchState` until `isDone(state)` is true or the budget is exhausted.
|
|
1966
|
-
*
|
|
1992
|
+
* A transient failure (`isTransientPollError`) is waited out like a not-done
|
|
1993
|
+
* state; any other error ends the wait. Throws PollTimeoutError (carrying the
|
|
1994
|
+
* last observed state) on timeout, or the last transient error when no state
|
|
1995
|
+
* was ever observed.
|
|
1967
1996
|
*/
|
|
1968
1997
|
declare function pollUntil<T>(what: string, fetchState: () => Promise<T>, isDone: (state: T) => boolean, opts?: PollOptions): Promise<T>;
|
|
1969
1998
|
declare function waitForJob(client: StudioClient, jobId: string, opts?: PollOptions): Promise<JobResponse>;
|
|
@@ -2051,7 +2080,7 @@ declare function registerTools(server: McpServer, base: ToolContext): void;
|
|
|
2051
2080
|
*/
|
|
2052
2081
|
|
|
2053
2082
|
declare const SERVER_NAME = "lumitra-studio";
|
|
2054
|
-
declare const SERVER_VERSION = "0.
|
|
2083
|
+
declare const SERVER_VERSION = "0.12.0";
|
|
2055
2084
|
interface CreateServerOptions {
|
|
2056
2085
|
config?: StudioConfig;
|
|
2057
2086
|
env?: NodeJS.ProcessEnv;
|
|
@@ -3419,4 +3448,4 @@ declare function parseArgs(argv: string[]): CliArgs;
|
|
|
3419
3448
|
declare function createHttpHandler(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
3420
3449
|
declare function main(argv?: string[]): Promise<void>;
|
|
3421
3450
|
|
|
3422
|
-
export { type AllTenantsUsageResponse, type Binding, type BrandKitResponse, CHARACTER_SHEET_DEFINITION, CHARACTER_SHEET_NODES, type CampaignContents, type CampaignListing, type CandidatePlan, type CharacterReference, type CharacterSummary, type CharacterSwapInput, type CompositionRecord, type CompositionSummary, ConfigError, ContractError, type CreateServerOptions, DEFAULT_BASE_URL, DEFAULT_MOTION_PROMPT, DEFAULT_SWAP_EDIT_MODEL, DEFAULT_SWAP_PROMPT, DEFAULT_SWAP_VIDEO_MODEL, DEFAULT_TIMEOUT_MS, type DocumentSummary, type FetchLike, type GenerateImageResponse, type JobResponse, type JobStatus, type JudgeCandidate, MINT_REFERENCE_CATEGORIES, type NodeResultResponse, type NodeRun, type NodeStatus, type NodeSummary, type NodeTypesResponse, type PollOptions, PollTimeoutError, type ProjectAsset, type ProjectContents, type ProjectSummary, type Projection, type RemovedNode, type RunResponse, type RunStartResponse, type RunStatus, SERVER_NAME, SERVER_VERSION, SUMMARY_TEXT_CHARS, SWAP_SCOPES, type SavedWorkflowListing, type SocialProjectSummary, type SocialSendView, type SpendLedger, StudioApiError, StudioClient, type StudioClientOptions, type StudioConfig, type StudioMcp, type SummaryMeta, type SwapPromptOptions, type SwapScope, TOOLS, TOOL_NAMES, type TaskDescriptor, type TenantSpendSummary, type TenantUsageResponse, type ToolContext, type ToolDef, ToolInputError, type ToolResult, type TurnaroundView, type UploadFile, type UsageByModel, type UsageResponse, WORKFLOW_TOOLS, type WorkflowApplyResponse, type WorkflowCreateResponse, type WorkflowDefinition, type WorkflowDocumentResponse, type WorkflowNode, type WorkflowValidateResponse, affectedNodes, buildCharacterSheetParams, buildCharacterSwapDefinition, categoryForNode, characterSheetDefinition, composeSwapPrompt, createHttpHandler, createStudioMcpServer, extensionForMime, filenameFromUrl, invokeTool, main, mimeForFilename, parseArgs, parseDocument, parseOps, pollUntil, projectionOf, redactSecret, registerTools, resolveConfig, seedFacePrompt, studioWorkflowApply, studioWorkflowCreate, studioWorkflowDescribe, studioWorkflowGet, studioWorkflowScreenshot, studioWorkflowValidate, summarizeDocument, summarizeNode, touchedNodeIds, turnaroundViewPrompt, waitForJob, waitForRun };
|
|
3451
|
+
export { type AllTenantsUsageResponse, type AssetReference, type AssetUsage, type Binding, type BrandKitResponse, CHARACTER_SHEET_DEFINITION, CHARACTER_SHEET_NODES, type CampaignContents, type CampaignListing, type CandidatePlan, type CharacterReference, type CharacterSummary, type CharacterSwapInput, type CompositionRecord, type CompositionSummary, ConfigError, ContractError, type CreateServerOptions, DEFAULT_BASE_URL, DEFAULT_MOTION_PROMPT, DEFAULT_SWAP_EDIT_MODEL, DEFAULT_SWAP_PROMPT, DEFAULT_SWAP_VIDEO_MODEL, DEFAULT_TIMEOUT_MS, type DocumentSummary, type FetchLike, type GenerateImageResponse, type JobResponse, type JobStatus, type JudgeCandidate, MINT_REFERENCE_CATEGORIES, type NodeResultResponse, type NodeRun, type NodeStatus, type NodeSummary, type NodeTypesResponse, type PollOptions, PollTimeoutError, type ProjectAsset, type ProjectContents, type ProjectSummary, type Projection, type RemovedNode, type RunResponse, type RunStartResponse, type RunStatus, SERVER_NAME, SERVER_VERSION, SUMMARY_TEXT_CHARS, SWAP_SCOPES, type SavedWorkflowListing, type SocialProjectSummary, type SocialSendView, type SpendLedger, StudioApiError, StudioClient, type StudioClientOptions, type StudioConfig, type StudioMcp, type SummaryMeta, type SwapPromptOptions, type SwapScope, TOOLS, TOOL_NAMES, type TaskDescriptor, type TenantSpendSummary, type TenantUsageResponse, type ToolContext, type ToolDef, ToolInputError, type ToolResult, type TurnaroundView, type UploadFile, type UsageByModel, type UsageResponse, WORKFLOW_TOOLS, type WorkflowApplyResponse, type WorkflowCreateResponse, type WorkflowDefinition, type WorkflowDocumentResponse, type WorkflowNode, type WorkflowValidateResponse, affectedNodes, buildCharacterSheetParams, buildCharacterSwapDefinition, categoryForNode, characterSheetDefinition, composeSwapPrompt, createHttpHandler, createStudioMcpServer, extensionForMime, filenameFromUrl, invokeTool, main, mimeForFilename, parseArgs, parseDocument, parseOps, pollUntil, projectionOf, redactSecret, registerTools, resolveConfig, seedFacePrompt, studioWorkflowApply, studioWorkflowCreate, studioWorkflowDescribe, studioWorkflowGet, studioWorkflowScreenshot, studioWorkflowValidate, summarizeDocument, summarizeNode, touchedNodeIds, turnaroundViewPrompt, waitForJob, waitForRun };
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,12 @@ var StudioClient = class {
|
|
|
118
118
|
deleteProject(projectId) {
|
|
119
119
|
return this.json("DELETE", `/api/v1/projects/${encodeURIComponent(projectId)}`);
|
|
120
120
|
}
|
|
121
|
+
describeAssetUsage(projectId, assetId) {
|
|
122
|
+
return this.json("GET", `/api/v1/projects/${encodeURIComponent(projectId)}/assets/${encodeURIComponent(assetId)}`);
|
|
123
|
+
}
|
|
124
|
+
deleteAsset(projectId, assetId) {
|
|
125
|
+
return this.json("DELETE", `/api/v1/projects/${encodeURIComponent(projectId)}/assets/${encodeURIComponent(assetId)}`);
|
|
126
|
+
}
|
|
121
127
|
// ── Saved workflows (listing and moving; authoring lives with the workflow tools) ──
|
|
122
128
|
listWorkflows(opts = {}) {
|
|
123
129
|
return this.json("GET", `/api/v1/workflows${projectQuery(opts.projectId)}`);
|
|
@@ -5455,6 +5461,9 @@ function assertImage(file, source) {
|
|
|
5455
5461
|
// src/poll.ts
|
|
5456
5462
|
var DEFAULT_TIMEOUT_MS = 6e5;
|
|
5457
5463
|
var defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
5464
|
+
function isTransientPollError(err) {
|
|
5465
|
+
return err instanceof StudioApiError && (err.status === 503 || err.status === 0);
|
|
5466
|
+
}
|
|
5458
5467
|
async function pollUntil(what, fetchState, isDone, opts = {}) {
|
|
5459
5468
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
5460
5469
|
const factor = opts.factor ?? 1.5;
|
|
@@ -5463,15 +5472,30 @@ async function pollUntil(what, fetchState, isDone, opts = {}) {
|
|
|
5463
5472
|
const now = opts.now ?? Date.now;
|
|
5464
5473
|
const start = now();
|
|
5465
5474
|
let delay = opts.initialDelayMs ?? 2e3;
|
|
5466
|
-
let
|
|
5467
|
-
|
|
5475
|
+
let observed = false;
|
|
5476
|
+
let last;
|
|
5477
|
+
let lastTransient;
|
|
5478
|
+
const poll = async () => {
|
|
5479
|
+
try {
|
|
5480
|
+
last = await fetchState();
|
|
5481
|
+
observed = true;
|
|
5482
|
+
return isDone(last);
|
|
5483
|
+
} catch (err) {
|
|
5484
|
+
if (!isTransientPollError(err)) throw err;
|
|
5485
|
+
lastTransient = err;
|
|
5486
|
+
return false;
|
|
5487
|
+
}
|
|
5488
|
+
};
|
|
5489
|
+
if (await poll()) return last;
|
|
5468
5490
|
for (; ; ) {
|
|
5469
5491
|
const elapsed = now() - start;
|
|
5470
5492
|
const remaining = timeoutMs - elapsed;
|
|
5471
|
-
if (remaining <= 0)
|
|
5493
|
+
if (remaining <= 0) {
|
|
5494
|
+
if (!observed) throw lastTransient;
|
|
5495
|
+
throw new PollTimeoutError(what, timeoutMs, last);
|
|
5496
|
+
}
|
|
5472
5497
|
await sleep(Math.min(delay, remaining));
|
|
5473
|
-
|
|
5474
|
-
if (isDone(last)) return last;
|
|
5498
|
+
if (await poll()) return last;
|
|
5475
5499
|
delay = Math.min(maxDelay, Math.round(delay * factor));
|
|
5476
5500
|
}
|
|
5477
5501
|
}
|
|
@@ -6610,6 +6634,15 @@ function campaignDeleteSummary(c) {
|
|
|
6610
6634
|
const kept = c.imagesKept > 0 ? ` Its ${count(c.imagesKept, "image stays", "images stay")} in the asset library.` : "";
|
|
6611
6635
|
return `Delete the campaign "${c.name}" with its ${count(c.shots, "shot", "shots")} and every approve and reject decision?${kept} This cannot be undone.`;
|
|
6612
6636
|
}
|
|
6637
|
+
function assetReferenceLines(refs) {
|
|
6638
|
+
return refs.map((r) => `- ${r.label}: ${r.detail}`).join("\n");
|
|
6639
|
+
}
|
|
6640
|
+
function assetDeleteSummary(u) {
|
|
6641
|
+
const kind = u.subtype === "Image" ? "image" : u.subtype === "Video" ? "video" : u.subtype === "CarouselSlide" ? "rendered slide" : u.subtype === "Reel" ? "rendered reel" : `${u.subtype} asset`;
|
|
6642
|
+
const prompt = u.prompt?.trim();
|
|
6643
|
+
const named = prompt ? ` "${prompt.length > 120 ? `${prompt.slice(0, 117)}...` : prompt}"` : "";
|
|
6644
|
+
return `Delete the ${kind}${named} made ${u.createdAt.slice(0, 10)} (id ${u.assetId}) for everyone in the company, with its stored file? Campaign shots, sent posts and past runs keep their record without it. This cannot be undone.`;
|
|
6645
|
+
}
|
|
6613
6646
|
function projectSubject(c) {
|
|
6614
6647
|
return ["delete-project", c.project.id, c.project.name, c.workflows, c.publishedWorkflows, c.runs, c.assets, c.chats, c.campaignShots].join(":");
|
|
6615
6648
|
}
|
|
@@ -6692,6 +6725,42 @@ var studioDeleteProject = defineTool({
|
|
|
6692
6725
|
}
|
|
6693
6726
|
}
|
|
6694
6727
|
});
|
|
6728
|
+
var IN_USE_INSTRUCTION = "Nothing was deleted. Tell the person where the asset is still used (`usedIn`). Removing it from a post or a workflow is their edit to make (or yours with the composition or workflow tools, if they ask); work in flight has to finish first. Then call this tool again.";
|
|
6729
|
+
var studioDeleteAsset = defineTool({
|
|
6730
|
+
name: "studio_delete_asset",
|
|
6731
|
+
description: "Delete one asset (an image, a video, a rendered slide or reel) of your company for everyone, with its stored file. Needs a key with the company admin role. Refused while a post (a carousel slide or reel clip), a saved workflow or published recipe (a source node, a baked reference, a node pinned to the generation that made it) or work in flight (a generation, a run, a send to Lumitra Social) still uses it: the tool then returns `usedIn` with each place, and nothing is deleted. Records of what happened survive without it (campaign shots, product links, derived assets, the job and its cost, sent posts). The PERSON confirms every delete in the chat: this tool 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.",
|
|
6732
|
+
inputSchema: {
|
|
6733
|
+
projectId: z10.string().min(1).describe("The project the asset is in, from studio_list_projects."),
|
|
6734
|
+
assetId: z10.string().min(1).describe("The asset, from studio_list_assets."),
|
|
6735
|
+
confirmationToken
|
|
6736
|
+
},
|
|
6737
|
+
annotations: { destructiveHint: true },
|
|
6738
|
+
handler: async (args, ctx) => {
|
|
6739
|
+
const inUse = (references) => ({
|
|
6740
|
+
deleted: false,
|
|
6741
|
+
inUse: true,
|
|
6742
|
+
usedIn: references,
|
|
6743
|
+
message: `The asset is still used:
|
|
6744
|
+
${assetReferenceLines(references)}`,
|
|
6745
|
+
instruction: IN_USE_INSTRUCTION
|
|
6746
|
+
});
|
|
6747
|
+
const usage = await ctx.client.describeAssetUsage(args.projectId, args.assetId);
|
|
6748
|
+
if (usage.references.length > 0) return inUse(usage.references);
|
|
6749
|
+
const summary = assetDeleteSummary(usage);
|
|
6750
|
+
const gate = await confirmWithPerson(ctx, summary, ["delete-asset", args.projectId, args.assetId].join(":"), args.confirmationToken);
|
|
6751
|
+
if (gate !== "proceed") return gate;
|
|
6752
|
+
try {
|
|
6753
|
+
const res = await ctx.client.deleteAsset(args.projectId, args.assetId);
|
|
6754
|
+
return { deleted: true, assetId: res.assetId, filesDeleted: res.filesDeleted, filesKept: res.filesKept, summary };
|
|
6755
|
+
} catch (err) {
|
|
6756
|
+
if (err instanceof StudioApiError && err.status === 409) {
|
|
6757
|
+
const refs = err.body?.references ?? [];
|
|
6758
|
+
return inUse(refs);
|
|
6759
|
+
}
|
|
6760
|
+
return roleRefusal(err, "Deleting an asset needs a key with the company admin role; this key does not have it.");
|
|
6761
|
+
}
|
|
6762
|
+
}
|
|
6763
|
+
});
|
|
6695
6764
|
var studioListWorkflows = defineTool({
|
|
6696
6765
|
name: "studio_list_workflows",
|
|
6697
6766
|
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.",
|
|
@@ -6750,6 +6819,7 @@ var MANAGE_TOOLS = [
|
|
|
6750
6819
|
studioCreateProject,
|
|
6751
6820
|
studioRenameProject,
|
|
6752
6821
|
studioDeleteProject,
|
|
6822
|
+
studioDeleteAsset,
|
|
6753
6823
|
studioListWorkflows,
|
|
6754
6824
|
studioMoveWorkflow,
|
|
6755
6825
|
studioListCampaigns,
|
|
@@ -7537,7 +7607,7 @@ function registerTools(server, base) {
|
|
|
7537
7607
|
|
|
7538
7608
|
// src/server.ts
|
|
7539
7609
|
var SERVER_NAME = "lumitra-studio";
|
|
7540
|
-
var SERVER_VERSION = "0.
|
|
7610
|
+
var SERVER_VERSION = "0.12.0";
|
|
7541
7611
|
function createStudioMcpServer(opts = {}) {
|
|
7542
7612
|
const config = opts.config ?? resolveConfig(opts.env ?? process.env);
|
|
7543
7613
|
const client = new StudioClient(config, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marlinjai/studio-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Model Context Protocol (MCP) server over the Lumitra Studio HTTP API: generate images, mint characters, run workflows, swap characters into video.",
|
|
6
6
|
"license": "MIT",
|