@simpligen/mcp 0.5.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/README.md CHANGED
@@ -20,9 +20,13 @@ The easiest path is in the SimpliGen app: **Settings -> Connect an agent**, pick
20
20
 
21
21
  ## Tools
22
22
 
23
- `list_capabilities`, `get_status`, `list_projects`, `create_project`, `upload_file`, `generate`, `get_job`, `wait_for_result`, `list_jobs`, `cancel_job`, `prepare_preset`, `get_result_image`.
23
+ `list_capabilities`, `get_status`, `list_projects`, `create_project`, `upload_file`, `generate`, `get_job`, `wait_for_result`, `list_jobs`, `cancel_job`, `prepare_preset`, `get_result_image`, `wait_for_approval`, `get_app_context`, `fill_generate_form`, `open_screen`, `accept_character_base`.
24
24
 
25
- **Video Studio** (connector 0.5.0 or newer): `list_films`, `create_film`, `get_film`, `update_film_settings`, `add_track`, `move_track`, `detect_tempo`, `add_clip`, `update_clip`, `move_clip`, `trim_clip`, `remove_clip`, `apply_film_plan`, `set_fades`, `add_marker`, `set_export_range`, `render_clips`, `wait_for_renders`, `list_takes`, `use_take`, `export_film`, `list_locations`, `create_location`. An agent can build a whole music video: a song, its tempo, clips on the bars, shots, renders and the export. With the film open in the Video Studio every change shows live and undoes with Ctrl+Z.
25
+ **Approval flow (SimpliGen's in-app Assistant).** A token the app issues for its own Assistant panel is flagged `approvalRequired`. With it, any call that queues a generation, renders or exports a film, runs a recipe, or deletes a character or product does not run. It returns `awaiting_approval` with a `proposalId`, and the user sees an approval card in the app. Call `wait_for_approval(proposalId)` (it long-polls in short rounds, like `wait_for_result`). It returns the real result once the user clicks Approve, or `declined` with the user's optional reason so you can adjust and propose again. For `regenerate_character_base`, the approved result carries a base job id: wait on it with `wait_for_result`, then call `accept_character_base`. Normal pairing tokens (Claude Desktop and other clients) never see this flow.
26
+
27
+ **Screen tools.** `get_app_context` returns what the user is looking at. `fill_generate_form` fills the visible Generate form and never presses Generate. `open_screen` navigates the app. They work for outside MCP clients too.
28
+
29
+ **Video Studio** (connector 0.5.0 or newer): `list_films`, `create_film`, `get_film`, `update_film_settings`, `add_track`, `move_track`, `detect_tempo`, `add_clip`, `update_clip`, `move_clip`, `trim_clip`, `remove_clip`, `apply_film_plan`, `set_fades`, `add_marker`, `set_export_range`, `render_clips`, `wait_for_renders`, `list_takes`, `use_take`, `export_film`, `list_locations`, `create_location`. An agent can build a whole music video: a song, its tempo, clips on the bars, shots, renders and the export. With the film open in the Video Studio every change shows live and undoes with Ctrl+Z. These tools are listed only when your SimpliGen has the Video Studio (connector 0.5.1 or newer, SimpliGen 1.75 or newer). If the agent starts before SimpliGen is running, they appear within a minute of SimpliGen starting; an agent app that does not refresh its tool list shows them after a restart.
26
30
 
27
31
  `get_result_image` returns a completed job's result image inline (a viewable image block) so the agent can display it in chat. Claude clients cap a tool result at ~1MB and only render base64 image blocks, so large renders are re-encoded to a **full-resolution WebP** preview (same dimensions; quality steps down, and only very large images are resized) that fits the cap. The uncompressed original file path is always included in the caption, so the agent keeps the full-quality artifact. Video results return the file path instead.
28
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpligen/mcp",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server for SimpliGen -- drive local/cloud AI image & video generation from an agent.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@modelcontextprotocol/sdk": "^1",
34
- "sharp": "^0.35.1",
34
+ "sharp": ">=0.34.5 <0.36",
35
35
  "zod": "^3"
36
36
  }
37
37
  }
package/src/bin.js CHANGED
@@ -7,6 +7,9 @@ import { createMcpServer } from './server.js';
7
7
  async function main() {
8
8
  const client = new ControlApiClient(); // resolves port (discovery file) + token (SIMPLIGEN_TOKEN)
9
9
  const server = createMcpServer(client);
10
+ // Whether the app holds the Video Studio decides which tools the client first sees.
11
+ // A closed app answers at once; a stuck one gets 3 s, then the poll takes over.
12
+ await Promise.race([server.studioGate.refresh(), new Promise((r) => setTimeout(r, 3000).unref())]);
10
13
  await server.connect(new StdioServerTransport());
11
14
  }
12
15
 
package/src/client.js CHANGED
@@ -91,7 +91,12 @@ export class ControlApiClient {
91
91
  listProjects() { return this.#req('GET', '/projects'); }
92
92
  createProject(name) { return this.#req('POST', '/projects', { name }); }
93
93
  listLoras() { return this.#req('GET', '/loras'); }
94
+ getPromptGuide(presetId) { return this.#req('GET', `/prompt-guide/${encodeURIComponent(presetId)}`); }
94
95
  generate(args) { return this.#req('POST', '/generate', args); }
96
+ waitForApproval(id, timeoutSeconds) { return this.#req('GET', `/approvals/${encodeURIComponent(id)}/wait?timeoutSeconds=${timeoutSeconds}`); }
97
+ getAppContext() { return this.#req('GET', '/app/context'); }
98
+ fillGenerateForm(body) { return this.#req('POST', '/app/generate-form', body); }
99
+ openScreen(body) { return this.#req('POST', '/app/screen', body); }
95
100
  getJob(id) { return this.#req('GET', `/jobs/${encodeURIComponent(id)}`); }
96
101
  listJobs() { return this.#req('GET', '/jobs'); }
97
102
  cancelJob(id) { return this.#req('POST', `/jobs/${encodeURIComponent(id)}/cancel`, {}); }
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // packages/mcp-server/src/index.js
2
2
  export { ControlApiClient, ControlApiError } from './client.js';
3
3
  export { createMcpServer } from './server.js';
4
- export { registerTools, TOOL_NAMES } from './tools.js';
4
+ export { registerTools, TOOL_NAMES, STUDIO_TOOL_NAMES } from './tools.js';
5
+ export { createStudioGate } from './studioGate.js';
5
6
  export { buildResultImageContent } from './resultImage.js';
6
7
  export { resolveUserDataDir, readDiscoveryPort } from './userdata.js';
package/src/server.js CHANGED
@@ -2,11 +2,23 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
4
  import { registerTools } from './tools.js';
5
+ import { createStudioGate } from './studioGate.js';
5
6
 
6
7
  const { version } = createRequire(import.meta.url)('../package.json');
7
8
 
8
- export function createMcpServer(client) {
9
+ /**
10
+ * @param {object} client a ControlApiClient
11
+ * @param {{ studioPollMs?: number }} [options] how often to ask the app whether it holds the Video Studio
12
+ */
13
+ export function createMcpServer(client, { studioPollMs } = {}) {
9
14
  const server = new McpServer({ name: 'simpligen', version });
10
- registerTools(server, client);
15
+ let gate = null;
16
+ const { studioTools } = registerTools(server, client, { onStatus: (status) => gate?.observe(status) });
17
+ gate = createStudioGate({ client, tools: studioTools, notify: () => server.sendToolListChanged(), pollMs: studioPollMs });
18
+ // The gate asks the app once a client is connected, and stops when it goes.
19
+ server.server.oninitialized = () => gate.start();
20
+ server.server.onclose = () => gate.stop();
21
+ // bin.js reads the status once before connecting, so the first tool list is already right.
22
+ server.studioGate = gate;
11
23
  return server;
12
24
  }
@@ -0,0 +1,51 @@
1
+ // packages/mcp-server/src/studioGate.js
2
+ // The Video Studio tools are listed only to an agent whose SimpliGen holds the studio.
3
+ // Without it every film call is refused (studio_not_installed), so listing them only
4
+ // invites calls that cannot work. The app answers whether it holds the studio in
5
+ // /status (videoStudio.held, App 1.75.0 and newer); the gate reads that on start, every
6
+ // pollMs, and whenever the agent asks get_status, and tells the client when the set changes.
7
+
8
+ /**
9
+ * @param {{ client: { getStatus: () => Promise<object> },
10
+ * tools: Array<{ enabled: boolean }>,
11
+ * notify: () => void,
12
+ * pollMs?: number }} deps
13
+ */
14
+ export function createStudioGate({ client, tools, notify, pollMs = 60_000 }) {
15
+ let held = false;
16
+ let timer = null;
17
+ // Hidden until the app says otherwise. Set directly so a client that is not connected
18
+ // yet is not told, and a whole switch is one notification, not one per tool.
19
+ for (const t of tools) t.enabled = false;
20
+
21
+ const apply = (next) => {
22
+ if (next === held) return;
23
+ held = next;
24
+ for (const t of tools) t.enabled = next;
25
+ notify();
26
+ };
27
+
28
+ /** Read one /status answer. An app that does not report the studio does not hold it. */
29
+ const observe = (status) => apply(status?.videoStudio?.held === true);
30
+
31
+ /** Ask the app. A failed read (the app closed for a moment) changes nothing. */
32
+ const refresh = async () => {
33
+ try { observe(await client.getStatus()); } catch { /* keep what we had */ }
34
+ };
35
+
36
+ return {
37
+ observe,
38
+ refresh,
39
+ start() {
40
+ if (timer) return;
41
+ refresh();
42
+ timer = setInterval(refresh, pollMs);
43
+ timer.unref?.();
44
+ },
45
+ stop() {
46
+ clearInterval(timer);
47
+ timer = null;
48
+ },
49
+ get held() { return held; },
50
+ };
51
+ }
package/src/tools.js CHANGED
@@ -8,12 +8,13 @@ import { buildResultImageContent } from './resultImage.js';
8
8
  export const TOOL_NAMES = [
9
9
  'list_capabilities', 'get_status', 'start_engine', 'stop_engine', 'restart_engine',
10
10
  'list_projects', 'create_project',
11
- 'upload_file', 'generate', 'list_loras', 'get_job', 'wait_for_result', 'list_jobs',
11
+ 'wait_for_approval', 'get_app_context', 'fill_generate_form', 'open_screen',
12
+ 'upload_file', 'generate', 'list_loras', 'get_prompt_guide', 'get_job', 'wait_for_result', 'list_jobs',
12
13
  'cancel_job', 'prepare_preset', 'get_result_image',
13
14
  'list_characters', 'get_character', 'list_character_features', 'list_character_presets',
14
15
  'remove_character', 'create_character', 'generate_character_image', 'generate_character_video',
15
16
  'generate_character_frame', 'animate_character', 'set_character_preset',
16
- 'enhance_character_media', 'regenerate_character_base',
17
+ 'enhance_character_media', 'regenerate_character_base', 'accept_character_base',
17
18
  'list_recipe_blocks', 'compose_recipe', 'validate_recipe', 'list_recipes', 'get_recipe', 'publish_recipe',
18
19
  'run_recipe', 'get_recipe_run', 'wait_for_recipe_run', 'list_recipe_runs', 'cancel_recipe_run',
19
20
  'list_subjects', 'list_products', 'create_product', 'remove_product',
@@ -22,18 +23,40 @@ export const TOOL_NAMES = [
22
23
  'set_export_range', 'render_clips', 'wait_for_renders', 'list_takes', 'use_take', 'export_film', 'list_locations', 'create_location',
23
24
  ];
24
25
 
26
+ // The tools that need the Video Studio. Listed only while the app holds it (studioGate.js).
27
+ export const STUDIO_TOOL_NAMES = TOOL_NAMES.slice(TOOL_NAMES.indexOf('list_films'));
28
+
25
29
  const ok = (data) => ({ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] });
26
30
  const fail = (err) => ({ isError: true, content: [{ type: 'text', text: `${err.errorCode ? err.errorCode + ': ' : ''}${err.message || String(err)}` }] });
27
31
  const wrap = (fn) => async (args) => { try { return ok(await fn(args)); } catch (e) { return fail(e); } };
28
32
 
29
- export function registerTools(server, client) {
33
+ // In the in-app Assistant the user approves spending and deletions on a card first.
34
+ const APPROVAL_NOTE = ' If the result is awaiting_approval, call wait_for_approval with its proposalId and tell the user an approval card is waiting.';
35
+
36
+ // generate_character_video chains two gated steps; when one waits for the user it stops
37
+ // and tells the agent how to carry on.
38
+ const RESUME_ANIMATE = {
39
+ tool: 'animate_character',
40
+ note: 'The chain stopped at an approval. After wait_for_approval reports done, wait_for_result on the frame job, then call animate_character with that jobId.',
41
+ };
42
+
43
+ const RESUME_CREATE = { tool: 'get_character', note: 'The base portrait is generated after approval. wait_for_approval returns the new characterId; then poll get_character (or wait_for_result on the base job id, if the create response carries one) until base_image_url is set.' };
44
+ const RESUME_REGEN = { tool: 'wait_for_result', note: 'After approval, wait_for_approval returns the base jobId; call wait_for_result on it, then accept_character_base.' };
45
+
46
+ const NO_PROMPT_GUIDES = 'This SimpliGen version has no prompt guides yet. Update the app, or write the prompt without a guide.';
47
+
48
+ export function registerTools(host, client, { onStatus, now = Date.now, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) {
49
+ // Every tool's handle by name, so the studio's can be shown and hidden later.
50
+ const registered = {};
51
+ const server = { registerTool: (name, ...rest) => (registered[name] = host.registerTool(name, ...rest)) };
52
+
30
53
  server.registerTool('list_capabilities',
31
54
  { title: 'List capabilities', description: 'List every SimpliGen preset the agent can generate with (image/video), its inputs/options, whether it is installed locally (localReady) and cloud-eligible + credit cost. Local presets also carry onThisMachine: how likely a run is to finish on this machine (rating, finish %, p90Min: the slow end in minutes on similar cards), the typical minutes on this exact GPU (or notEnoughRunsOnGpu when there is too little data), and what size still fits.', inputSchema: {} },
32
55
  wrap(() => client.getCapabilities()));
33
56
 
34
57
  server.registerTool('get_status',
35
58
  { title: 'Get status', description: 'Engine running state, whether cloud is connected, credit balance, and the active project.', inputSchema: {} },
36
- wrap(() => client.getStatus()));
59
+ wrap(async () => { const status = await client.getStatus(); onStatus?.(status); return status; }));
37
60
 
38
61
  // The engine's lifecycle. get_status could always report it was down and
39
62
  // there was nothing an agent could do about it but ask the human to click
@@ -66,11 +89,12 @@ export function registerTools(server, client) {
66
89
 
67
90
  server.registerTool('generate',
68
91
  {
69
- title: 'Generate', description: 'Start an image or video generation. Inputs (image/referenceImages/video) are handles from upload_file. backend: local | cloud | auto. Returns a jobId (and, for local runs, an expectation with the same fields as onThisMachine for the requested settings); poll with wait_for_result or get_job.',
92
+ title: 'Generate', description: 'Start an image or video generation. Before writing the prompt, call get_prompt_guide for the preset and follow it. Inputs (image/referenceImages/video) are handles from upload_file. backend: local | cloud | auto. Returns a jobId (and, for local runs, an expectation with the same fields as onThisMachine for the requested settings); poll with wait_for_result or get_job.' + APPROVAL_NOTE,
70
93
  inputSchema: {
71
94
  presetId: z.string(), mediaType: z.enum(['image', 'video']), prompt: z.string(),
72
95
  packId: z.string().optional(), backend: z.enum(['local', 'cloud', 'auto']).optional(),
73
- negativePrompt: z.string().optional(), project: z.string().optional(),
96
+ negativePrompt: z.string().optional().describe('Extra terms added to the preset default negative prompt (local runs only); the default is always applied.'),
97
+ project: z.string().optional(),
74
98
  image: z.string().optional().describe('upload_file handle'),
75
99
  // A bare handle still works, so every agent written against the old
76
100
  // schema keeps working. The object form carries the per-image label,
@@ -142,6 +166,24 @@ export function registerTools(server, client) {
142
166
  { title: 'List LoRAs', description: 'List the installed user LoRAs (name, base model, trigger words) so you can pass them in generate -> loras.', inputSchema: {} },
143
167
  wrap(() => client.listLoras()));
144
168
 
169
+ server.registerTool('get_prompt_guide',
170
+ {
171
+ title: 'Get prompt guide',
172
+ description: 'Read the prompting guide for a preset before writing its prompt: how its model reads a prompt, structure, length, camera and motion wording, negatives, character wording and examples. Follow it when you write the prompt for generate.',
173
+ inputSchema: { presetId: z.string() },
174
+ },
175
+ async ({ presetId }) => {
176
+ try {
177
+ return ok(await client.getPromptGuide(presetId));
178
+ } catch (e) {
179
+ // Any other 404 means the app predates the route.
180
+ if (e && e.status === 404 && e.errorCode !== 'unknown_preset') {
181
+ return { isError: true, content: [{ type: 'text', text: NO_PROMPT_GUIDES }] };
182
+ }
183
+ return fail(e);
184
+ }
185
+ });
186
+
145
187
  server.registerTool('get_job',
146
188
  { title: 'Get job', description: 'Status + result of a generation job. resultPath is the local file when completed.', inputSchema: { jobId: z.string() } },
147
189
  wrap(({ jobId }) => client.getJob(jobId)));
@@ -185,6 +227,48 @@ export function registerTools(server, client) {
185
227
  }
186
228
  });
187
229
 
230
+ // The user's Approve click on an approval card can take minutes: poll in rounds the
231
+ // control API can hold open (25 s max), until the proposal settles or the timeout passes.
232
+ server.registerTool('wait_for_approval',
233
+ { title: 'Wait for approval', description: 'Block until the user approves or declines an approval card (proposalId from an awaiting_approval result), or the timeout passes. Returns { status: done | declined | expired, ... }: done carries the result of the approved call (for example the jobId), declined carries a reason. On timeout returns { status: pending, note: still_waiting }: call it again.', inputSchema: { proposalId: z.string(), timeoutSeconds: z.number().optional().describe('Total seconds to wait (default 600)') } },
234
+ wrap(async ({ proposalId, timeoutSeconds = 600 }) => {
235
+ const deadline = now() + timeoutSeconds * 1000;
236
+ for (;;) {
237
+ const remaining = Math.ceil((deadline - now()) / 1000);
238
+ if (remaining <= 0) return { status: 'pending', note: 'still_waiting', proposalId };
239
+ const started = now();
240
+ const r = await client.waitForApproval(proposalId, Math.min(25, remaining));
241
+ if (r.status === 'done') {
242
+ const httpStatus = r.result?.status;
243
+ return { status: 'done', ok: httpStatus >= 200 && httpStatus < 300, result: r.result?.json, httpStatus };
244
+ }
245
+ if (r.status !== 'pending' && r.status !== 'running') return r;
246
+ // A server that answers at once instead of holding the call must not be hammered.
247
+ const spent = now() - started;
248
+ if (spent < 1000) await sleep(1000 - spent);
249
+ }
250
+ }));
251
+
252
+ // ---- The app's own screen: what the user sees, and moving it for them ----
253
+
254
+ server.registerTool('get_app_context',
255
+ { title: 'Get app context', description: 'What the user is looking at in SimpliGen right now: the open screen, the selected preset, character or film, and the current Generate form values.', inputSchema: {} },
256
+ wrap(() => client.getAppContext()));
257
+
258
+ server.registerTool('fill_generate_form',
259
+ { title: 'Fill the Generate form', description: 'Fill in the Generate screen for the user (preset, prompt and settings) without generating, so they can review it and click Generate themselves.', inputSchema: {
260
+ presetId: z.string(), prompt: z.string(), negativePrompt: z.string().optional(), characterId: z.string().optional(),
261
+ settings: z.record(z.any()).optional().describe('Preset settings keyed by setting id (see list_capabilities).'),
262
+ } },
263
+ wrap((a) => client.fillGenerateForm(a)));
264
+
265
+ server.registerTool('open_screen',
266
+ { title: 'Open a screen', description: 'Take the user to a screen in SimpliGen. id selects a character when screen is "character".', inputSchema: {
267
+ screen: z.enum(['generate', 'gallery', 'characters', 'character', 'video-studio', 'prompt-library', 'settings']),
268
+ id: z.string().optional(),
269
+ } },
270
+ wrap((a) => client.openScreen(a)));
271
+
188
272
  // ---- Character Studio tools ----
189
273
 
190
274
  server.registerTool('list_characters',
@@ -204,13 +288,13 @@ export function registerTools(server, client) {
204
288
  wrap(() => client.listCharacterPresets()));
205
289
 
206
290
  server.registerTool('remove_character',
207
- { title: 'Remove character', description: 'Permanently delete a character and its associated data.', inputSchema: { characterId: z.string() } },
291
+ { title: 'Remove character', description: 'Permanently delete a character and its associated data.' + APPROVAL_NOTE, inputSchema: { characterId: z.string() } },
208
292
  wrap(({ characterId }) => client.removeCharacter(characterId)));
209
293
 
210
294
  server.registerTool('create_character',
211
295
  {
212
296
  title: 'Create character',
213
- description: 'Create a new character. Three paths: (1) describe -- pass gender and identity features from list_character_features with mode "generate"; the server builds a base portrait automatically and this tool waits until ready. (2) upload as base -- pass baseFilePath pointing to a local image with mode "upload"; the image becomes the base portrait immediately. (3) vision recreate -- describe path but fill identity by having the agent analyse a reference photo first; the agent extracts features and passes them as identity.',
297
+ description: 'Create a new character. Three paths: (1) describe -- pass gender and identity features from list_character_features with mode "generate"; the server builds a base portrait automatically and this tool waits until ready. (2) upload as base -- pass baseFilePath pointing to a local image with mode "upload"; the image becomes the base portrait immediately. (3) vision recreate -- describe path but fill identity by having the agent analyse a reference photo first; the agent extracts features and passes them as identity.' + APPROVAL_NOTE,
214
298
  inputSchema: {
215
299
  name: z.string().describe('Display name for the character'),
216
300
  gender: z.enum(['woman', 'man', 'nonbinary']),
@@ -226,10 +310,12 @@ export function registerTools(server, client) {
226
310
  if (mode === 'upload') {
227
311
  const up = await client.uploadFile(baseFilePath);
228
312
  const char = await client.createCharacter({ name, gender, mode: 'upload', identity, baseHandle: up.handle });
313
+ if (char?.status === 'awaiting_approval') return ok({ ...char, resume: RESUME_CREATE });
229
314
  return ok({ ...char, ready: true });
230
315
  }
231
316
  // mode === 'generate': create then poll until base_image_url is set
232
317
  const c = await client.createCharacter({ name, gender, mode: 'generate', identity });
318
+ if (c?.status === 'awaiting_approval') return ok({ ...c, resume: RESUME_CREATE });
233
319
  const { characterId } = c;
234
320
  const deadline = Date.now() + (timeoutSeconds ?? 300) * 1000;
235
321
  while (true) {
@@ -246,7 +332,7 @@ export function registerTools(server, client) {
246
332
  server.registerTool('generate_character_image',
247
333
  {
248
334
  title: 'Generate character image',
249
- description: 'Generate one or more images of a character in a scene. Returns jobIds; use wait_for_result then get_result_image for each. Pass presetId to override the default image preset (ids from list_character_presets).',
335
+ description: 'Generate one or more images of a character in a scene. Returns jobIds; use wait_for_result then get_result_image for each. Pass presetId to override the default image preset (ids from list_character_presets).' + APPROVAL_NOTE,
250
336
  inputSchema: {
251
337
  characterId: z.string(),
252
338
  prompt: z.string(),
@@ -264,7 +350,7 @@ export function registerTools(server, client) {
264
350
  server.registerTool('generate_character_video',
265
351
  {
266
352
  title: 'Generate character video',
267
- description: 'Generate a short video of a character in a scene. Internally generates a frame then animates it (I2V). Returns frameJobId and videoJobId; use wait_for_result then get_result_image on videoJobId. Use framePresetId to override the image-frame preset and videoPresetId to override the video/animate preset (ids from list_character_presets).',
353
+ description: 'Generate a short video of a character in a scene. Internally generates a frame then animates it (I2V). Returns frameJobId and videoJobId; use wait_for_result then get_result_image on videoJobId. Use framePresetId to override the image-frame preset and videoPresetId to override the video/animate preset (ids from list_character_presets).' + APPROVAL_NOTE,
268
354
  inputSchema: {
269
355
  characterId: z.string(),
270
356
  prompt: z.string(),
@@ -279,7 +365,9 @@ export function registerTools(server, client) {
279
365
  async ({ characterId, prompt, motion, aspect, timeoutSeconds = 300, pollMs = 2000, framePresetId, videoPresetId }) => {
280
366
  try {
281
367
  // 1. Generate a frame (still image for I2V)
282
- const { jobIds: [frameJobId] } = await client.generateCharacterFrame(characterId, { prompt, aspect, presetId: framePresetId });
368
+ const frame = await client.generateCharacterFrame(characterId, { prompt, aspect, presetId: framePresetId });
369
+ if (frame?.status === 'awaiting_approval') return ok({ ...frame, resume: RESUME_ANIMATE });
370
+ const { jobIds: [frameJobId] } = frame;
283
371
  // 2. Wait for frame to complete
284
372
  const deadline = Date.now() + timeoutSeconds * 1000;
285
373
  while (true) {
@@ -290,7 +378,9 @@ export function registerTools(server, client) {
290
378
  await new Promise((r) => setTimeout(r, pollMs));
291
379
  }
292
380
  // 3. Animate from the completed frame
293
- const { jobIds: [videoJobId] } = await client.animateCharacter(characterId, { frameJobId, motion, aspect, presetId: videoPresetId });
381
+ const video = await client.animateCharacter(characterId, { frameJobId, motion, aspect, presetId: videoPresetId });
382
+ if (video?.status === 'awaiting_approval') return ok({ ...video, resume: RESUME_ANIMATE });
383
+ const { jobIds: [videoJobId] } = video;
294
384
  return ok({ frameJobId, videoJobId });
295
385
  } catch (e) { return fail(e); }
296
386
  });
@@ -300,7 +390,7 @@ export function registerTools(server, client) {
300
390
  server.registerTool('generate_character_frame',
301
391
  {
302
392
  title: 'Generate character frame',
303
- description: 'Generate a start-frame image for a character that you can review or enhance before animating. Returns jobIds; use wait_for_result then get_result_image. Pass presetId to override the frame-image preset (ids from list_character_presets).',
393
+ description: 'Generate a start-frame image for a character that you can review or enhance before animating. Returns jobIds; use wait_for_result then get_result_image. Pass presetId to override the frame-image preset (ids from list_character_presets).' + APPROVAL_NOTE,
304
394
  inputSchema: {
305
395
  characterId: z.string(),
306
396
  prompt: z.string(),
@@ -317,7 +407,7 @@ export function registerTools(server, client) {
317
407
  server.registerTool('animate_character',
318
408
  {
319
409
  title: 'Animate character',
320
- description: 'Animate a character from a completed image/frame job or a local file path (I2V). jobId may be any completed character image, frame, or upscale job. Returns jobIds; use wait_for_result then get_result_image. Pass videoPresetId to override the video preset (ids from list_character_presets).',
410
+ description: 'Animate a character from a completed image/frame job or a local file path (I2V). jobId may be any completed character image, frame, or upscale job. Returns jobIds; use wait_for_result then get_result_image. Pass videoPresetId to override the video preset (ids from list_character_presets).' + APPROVAL_NOTE,
321
411
  inputSchema: {
322
412
  characterId: z.string(),
323
413
  jobId: z.string().optional().describe('Any completed character image/frame/upscale jobId to use as the source frame'),
@@ -345,7 +435,7 @@ export function registerTools(server, client) {
345
435
  server.registerTool('enhance_character_media',
346
436
  {
347
437
  title: 'Enhance character media',
348
- description: 'Upscale a generated image/video, a local file, or the character base portrait (target: "base"). Returns a jobId; use wait_for_result then get_result_image. scale sets the upscale factor; keepResolution upscales then resizes back to source size for a sharper same-size result; applyAsBase replaces the character base portrait with the upscaled result. Enhance presets come from list_character_presets (enhanceImage/enhanceVideo, each with supportedScales).',
438
+ description: 'Upscale a generated image/video, a local file, or the character base portrait (target: "base"). Returns a jobId; use wait_for_result then get_result_image. scale sets the upscale factor; keepResolution upscales then resizes back to source size for a sharper same-size result; applyAsBase replaces the character base portrait with the upscaled result. Enhance presets come from list_character_presets (enhanceImage/enhanceVideo, each with supportedScales).' + APPROVAL_NOTE,
349
439
  inputSchema: {
350
440
  characterId: z.string(),
351
441
  jobId: z.string().optional().describe('Completed job whose result to enhance'),
@@ -364,7 +454,7 @@ export function registerTools(server, client) {
364
454
  server.registerTool('regenerate_character_base',
365
455
  {
366
456
  title: 'Regenerate character base',
367
- description: 'Switch the base model and regenerate the base portrait IN PLACE (no new character created). Replaces the current base when completed. Uses basePresetId from list_character_presets. Optionally update identity features at the same time. Polls until completed, then auto-accepts the new base.',
457
+ description: 'Switch the base model and regenerate the base portrait IN PLACE (no new character created). Replaces the current base when completed. Uses basePresetId from list_character_presets. Optionally update identity features at the same time. Polls until completed, then auto-accepts the new base.' + APPROVAL_NOTE,
368
458
  inputSchema: {
369
459
  characterId: z.string(),
370
460
  basePresetId: z.string().optional().describe('Base-generation preset id from list_character_presets'),
@@ -375,7 +465,9 @@ export function registerTools(server, client) {
375
465
  },
376
466
  async ({ characterId, basePresetId, identity, timeoutSeconds = 300, pollMs = 2000 }) => {
377
467
  try {
378
- const { baseJobId } = await client.regenerateCharacterBase(characterId, { basePresetId, identity });
468
+ const regen = await client.regenerateCharacterBase(characterId, { basePresetId, identity });
469
+ if (regen?.status === 'awaiting_approval') return ok({ ...regen, resume: RESUME_REGEN });
470
+ const { baseJobId } = regen;
379
471
  const deadline = Date.now() + timeoutSeconds * 1000;
380
472
  while (true) {
381
473
  const { job } = await client.getJob(baseJobId);
@@ -390,6 +482,14 @@ export function registerTools(server, client) {
390
482
  } catch (e) { return fail(e); }
391
483
  });
392
484
 
485
+ server.registerTool('accept_character_base',
486
+ {
487
+ title: 'Accept character base',
488
+ description: 'Make a finished base-portrait job the base of the character. Use it after an approved regenerate_character_base job finishes (wait_for_result completed).',
489
+ inputSchema: { characterId: z.string(), jobId: z.string().describe('The completed base job id') },
490
+ },
491
+ wrap(({ characterId, jobId }) => client.acceptBase(characterId, { altImageId: jobId })));
492
+
393
493
  // --- Recipe authoring: compose multi-step recipes out of packs/presets ---
394
494
 
395
495
  const recipeStep = z.object({
@@ -443,7 +543,7 @@ export function registerTools(server, client) {
443
543
  server.registerTool('run_recipe',
444
544
  {
445
545
  title: 'Run a recipe',
446
- description: 'Run an installed recipe (from list_recipes) with its inputs filled: the same multi-step pipeline UGC Studio / Product Studio runs when a person clicks Generate, so results land in the Gallery grouped the same way. `inputs` is keyed by input key; a subject input takes a character/product id, media inputs take upload_file handles. engine: local (default when every step is installed) | cloud | auto. Returns a runId; poll with wait_for_recipe_run or get_recipe_run. Cloud runs are priced up front and count against this agent\'s spend cap.',
546
+ description: 'Run an installed recipe (from list_recipes) with its inputs filled: the same multi-step pipeline UGC Studio / Product Studio runs when a person clicks Generate, so results land in the Gallery grouped the same way. `inputs` is keyed by input key; a subject input takes a character/product id, media inputs take upload_file handles. engine: local (default when every step is installed) | cloud | auto. Returns a runId; poll with wait_for_recipe_run or get_recipe_run. Cloud runs are priced up front and count against this agent\'s spend cap.' + APPROVAL_NOTE,
447
547
  inputSchema: {
448
548
  id: z.string().describe('Recipe id from list_recipes'),
449
549
  inputs: z.record(z.any()).describe('Input values keyed by the recipe\'s input keys (see list_recipes -> inputs).'),
@@ -497,7 +597,7 @@ export function registerTools(server, client) {
497
597
  wrap(({ name, image, description, category }) => client.createProduct({ name, image, description, category })));
498
598
 
499
599
  server.registerTool('remove_product',
500
- { title: 'Remove a product', description: 'Delete a product and its photo from this device.', inputSchema: { id: z.string() } },
600
+ { title: 'Remove a product', description: 'Delete a product and its photo from this device.' + APPROVAL_NOTE, inputSchema: { id: z.string() } },
501
601
  wrap(({ id }) => client.removeProduct(id)));
502
602
 
503
603
  // ---- The Video Studio (TASK-1310) ---------------------------------------------
@@ -622,7 +722,7 @@ export function registerTools(server, client) {
622
722
  wrap(({ filmId: id, ...rest }) => client.setExportRange(id, rest)));
623
723
 
624
724
  server.registerTool('render_clips',
625
- { title: 'Render clips', description: 'Render the clips that need it (default) or the clips named. Clips that continue from the clip before render one at a time, each after the take it starts from. Answers once the batch is under way (for clips that do not continue from each other, after queueing them all) with what started, what is held and why, and the cost in the cloud (counted against this agent\'s spend cap). Refused, with nothing started, as exceeds_balance (the cloud balance does not cover it), exceeds_spend_cap (over this agent\'s spend cap) or cost_unknown (the cloud cost is not known yet; try again in a minute). Follow progress with wait_for_renders or get_film.', inputSchema: {
725
+ { title: 'Render clips', description: 'Render the clips that need it (default) or the clips named. Clips that continue from the clip before render one at a time, each after the take it starts from. Answers once the batch is under way (for clips that do not continue from each other, after queueing them all) with what started, what is held and why, and the cost in the cloud (counted against this agent\'s spend cap). Refused, with nothing started, as exceeds_balance (the cloud balance does not cover it), exceeds_spend_cap (over this agent\'s spend cap) or cost_unknown (the cloud cost is not known yet; try again in a minute). Follow progress with wait_for_renders or get_film.' + APPROVAL_NOTE, inputSchema: {
626
726
  filmId, clips: z.union([z.literal('stale'), z.array(clipRef)]).optional().describe('"stale" (default): every clip whose take is missing or out of date; or a list of clips.'),
627
727
  } },
628
728
  wrap(({ filmId: id, clips }) => client.renderClips(id, clips === undefined ? {} : { clips })));
@@ -652,7 +752,7 @@ export function registerTools(server, client) {
652
752
  wrap(({ filmId: id, clip, generationId }) => client.useTake(id, clip, generationId)));
653
753
 
654
754
  server.registerTool('export_film',
655
- { title: 'Export a film', description: 'Stitch the film (or its export range) into one video with its music, and answer the file path. A long film can take several minutes. Refused with clips_not_ready while clips still need a render; a clip that cannot render at all comes out black and is named in `blanks`.', inputSchema: { filmId } },
755
+ { title: 'Export a film', description: 'Stitch the film (or its export range) into one video with its music, and answer the file path. A long film can take several minutes. Refused with clips_not_ready while clips still need a render; a clip that cannot render at all comes out black and is named in `blanks`.' + APPROVAL_NOTE, inputSchema: { filmId } },
656
756
  wrap(({ filmId: id }) => client.exportFilm(id)));
657
757
 
658
758
  server.registerTool('list_locations',
@@ -674,6 +774,8 @@ export function registerTools(server, client) {
674
774
  wrap(({ id }) => client.getRecipe(id)));
675
775
 
676
776
  server.registerTool('publish_recipe',
677
- { title: 'Publish a recipe', description: 'Submit a saved recipe to the SimpliGen Creator Marketplace (queued for human review). Requires a connected account: if none, returns not_connected and the user connects once in Settings, then this succeeds on the same recipe. priceTokens sets an optional one-time price (0 or omitted = free). Every preset the recipe uses must be a distributable first-party pack.', inputSchema: { id: z.string().describe('Recipe id to publish'), changelog: z.string().optional(), priceTokens: z.number().optional().describe('One-time price in tokens (0/omitted = free).') } },
777
+ { title: 'Publish a recipe', description: 'Submit a saved recipe to the SimpliGen Creator Marketplace (queued for human review). Requires a connected account: if none, returns not_connected and the user connects once in Settings, then this succeeds on the same recipe. priceTokens sets an optional one-time price (0 or omitted = free). Every preset the recipe uses must be a distributable first-party pack.' + APPROVAL_NOTE, inputSchema: { id: z.string().describe('Recipe id to publish'), changelog: z.string().optional(), priceTokens: z.number().optional().describe('One-time price in tokens (0/omitted = free).') } },
678
778
  wrap(({ id, changelog, priceTokens }) => client.publishRecipe(id, { changelog, priceTokens })));
779
+
780
+ return { studioTools: STUDIO_TOOL_NAMES.map((name) => registered[name]) };
679
781
  }