@clipform/mcp-server 5.0.0 → 5.2.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.
@@ -1,4 +1,6 @@
1
1
  import {
2
+ EXPOSED_COMPOSITIONS,
3
+ FORM_CLIP_RULES,
2
4
  NEVER,
3
5
  WORKFLOW_TYPES,
4
6
  ZodIssueCode,
@@ -29,7 +31,7 @@ import {
29
31
  union,
30
32
  unknown,
31
33
  url
32
- } from "./chunk-DEVQTVXL.js";
34
+ } from "./chunk-NXNCAGMO.js";
33
35
  import {
34
36
  GUIDE_TYPES,
35
37
  QUIZ_VARIANTS,
@@ -38,7 +40,7 @@ import {
38
40
  getGuideUri,
39
41
  guideFallbackText,
40
42
  registerResources
41
- } from "./chunk-LTLKJKNR.js";
43
+ } from "./chunk-4KXP67SR.js";
42
44
  import {
43
45
  ANON_PREVIEW_LINK_LABEL,
44
46
  ANON_PREVIEW_NOTICE,
@@ -52,7 +54,7 @@ import {
52
54
  isPreviewViewerUrl,
53
55
  previewOnlyNotice,
54
56
  withAdoptedNotice
55
- } from "./chunk-RFKLWZJV.js";
57
+ } from "./chunk-SH53TD4L.js";
56
58
  import {
57
59
  ACTIVE_NODE_TYPES,
58
60
  ANON_MCP_BLOCKED_NODE_TYPES,
@@ -62,6 +64,8 @@ import {
62
64
  FEATURE_FLAGS,
63
65
  FORM_TYPES_LIST,
64
66
  FORM_TYPE_ALIASES,
67
+ MAX_CLIP_SECONDS,
68
+ MAX_NARRATION_CHARS,
65
69
  MCP_TOOL_SECURITY,
66
70
  MCP_TOOL_TIERS,
67
71
  MCP_TOOL_TOOLSETS,
@@ -74,8 +78,8 @@ import {
74
78
  contactFieldNotes,
75
79
  defaultTarget,
76
80
  errorResult,
77
- exposedCompositionIds,
78
81
  gatedConfigKeys,
82
+ gatedEnumValues,
79
83
  isAnonMcpLockedNode,
80
84
  isAnonymousAccountRequired,
81
85
  lettersCapError,
@@ -84,7 +88,7 @@ import {
84
88
  stripGatedConfigKeys,
85
89
  structuredResult,
86
90
  textResult
87
- } from "./chunk-ZZYBRWG3.js";
91
+ } from "./chunk-5D3UEINC.js";
88
92
  import {
89
93
  getMcpAuth,
90
94
  runWithMcpAuth,
@@ -13087,7 +13091,7 @@ var AjvJsonSchemaValidator = class {
13087
13091
  var Ajv = import_ajv.Ajv;
13088
13092
 
13089
13093
  // ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
13090
- import process2 from "process";
13094
+ import process from "process";
13091
13095
 
13092
13096
  // ../../node_modules/.pnpm/@modelcontextprotocol+server@2.3.1/node_modules/@modelcontextprotocol/server/dist/mcp-DIH4cS6P.mjs
13093
13097
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
@@ -16125,14 +16129,6 @@ function buildOnboardingOffer(variant = ONBOARDING_OFFER_CONTROL_VARIANT) {
16125
16129
  }
16126
16130
  var ONBOARDING_OFFER_TOOL_CUE = `If the user hasn't said what to build yet, offer to build their first form and suggest starting points: ${STARTERS}, or something else.`;
16127
16131
 
16128
- // src/lib/config.ts
16129
- var _endScreen = NODE_TYPES.end_screen.config_schema.properties;
16130
- var END_SCREEN_ICONS = _endScreen.icon.enum;
16131
- var END_SCREEN_CTA_TYPES = _endScreen.cta_type.enum;
16132
- var EXPOSED_COMPOSITIONS = exposedCompositionIds(
16133
- process.env.NODE_ENV !== "production"
16134
- );
16135
-
16136
16132
  // src/lib/schemas.ts
16137
16133
  var CUSTOM_SCORES_GATED_KEYS = /* @__PURE__ */ new Set(["show_score", "score_ranges", "scoring_results"]);
16138
16134
  var ACTIVE_NODE_TYPES2 = ACTIVE_NODE_TYPES;
@@ -16148,7 +16144,8 @@ function generateConfigSummary(configSchema, typeKey) {
16148
16144
  if (gated.has(key)) continue;
16149
16145
  if (!FEATURE_FLAGS.ENABLE_CUSTOM_SCORES && CUSTOM_SCORES_GATED_KEYS.has(key)) continue;
16150
16146
  if (prop.enum) {
16151
- const vals = prop.enum.map((v) => `"${v}"`).join("|");
16147
+ const hiddenVals = typeKey ? gatedEnumValues(typeKey, key) : /* @__PURE__ */ new Set();
16148
+ const vals = prop.enum.filter((v) => !hiddenVals.has(v)).map((v) => `"${v}"`).join("|");
16152
16149
  let s = `${key} (${vals}`;
16153
16150
  if (prop.default !== void 0) s += `, default: "${prop.default}"`;
16154
16151
  s += ")";
@@ -16300,6 +16297,24 @@ function gatedConfigKeysOnEveryType() {
16300
16297
  }
16301
16298
  return new Set([...gatedBy].filter(([, g]) => g).map(([k]) => k));
16302
16299
  }
16300
+ function gatedEnumValuesOnEveryType() {
16301
+ const gatedBy = /* @__PURE__ */ new Map();
16302
+ for (const [type, def] of Object.entries(NODE_TYPES)) {
16303
+ for (const [key, prop] of Object.entries(def.config_schema?.properties ?? {})) {
16304
+ if (!Array.isArray(prop?.enum)) continue;
16305
+ const gated = gatedEnumValues(type, key);
16306
+ const byValue = gatedBy.get(key) ?? /* @__PURE__ */ new Map();
16307
+ for (const value of prop.enum) byValue.set(value, (byValue.get(value) ?? true) && gated.has(value));
16308
+ gatedBy.set(key, byValue);
16309
+ }
16310
+ }
16311
+ const out = /* @__PURE__ */ new Map();
16312
+ for (const [key, byValue] of gatedBy) {
16313
+ const values = [...byValue].filter(([, g]) => g).map(([v]) => v);
16314
+ if (values.length > 0) out.set(key, new Set(values));
16315
+ }
16316
+ return out;
16317
+ }
16303
16318
  function ignoredConfigNote(keys) {
16304
16319
  return `Ignored unsupported config key(s): ${keys.join(", ")}.`;
16305
16320
  }
@@ -17051,12 +17066,15 @@ function allowedConfigKeys(nodeType) {
17051
17066
  }
17052
17067
  return /* @__PURE__ */ new Set();
17053
17068
  }
17069
+ var HIDDEN_CONFIG_KEYS = /* @__PURE__ */ new Set(["workspace_integration_id"]);
17054
17070
  function projectConfig(nodeType, config) {
17055
17071
  if (!config) return void 0;
17056
17072
  const allowed = allowedConfigKeys(nodeType);
17057
17073
  const projected = {};
17058
17074
  for (const [key, value] of Object.entries(config)) {
17059
- if (allowed.has(key)) projected[key] = value;
17075
+ if (!allowed.has(key) || HIDDEN_CONFIG_KEYS.has(key)) continue;
17076
+ if (typeof value === "string" && gatedEnumValues(nodeType, key).has(value)) continue;
17077
+ projected[key] = value;
17060
17078
  }
17061
17079
  return projected;
17062
17080
  }
@@ -18044,8 +18062,10 @@ function registerUpdateNodeTool(server) {
18044
18062
  ({ config, dropped: droppedKeys } = stripGatedConfigKeys(type, rawConfig));
18045
18063
  } else {
18046
18064
  const gated = gatedConfigKeysOnEveryType();
18047
- droppedKeys = Object.keys(rawConfig).filter((k) => gated.has(k));
18048
- if (droppedKeys.length > 0) config = Object.fromEntries(Object.entries(rawConfig).filter(([k]) => !gated.has(k)));
18065
+ const gatedValues = gatedEnumValuesOnEveryType();
18066
+ const isGated = ([k, v]) => gated.has(k) || typeof v === "string" && (gatedValues.get(k)?.has(v) ?? false);
18067
+ droppedKeys = Object.entries(rawConfig).filter(isGated).map(([k]) => k);
18068
+ if (droppedKeys.length > 0) config = Object.fromEntries(Object.entries(rawConfig).filter((e) => !isGated(e)));
18049
18069
  }
18050
18070
  }
18051
18071
  const body = {};
@@ -18810,7 +18830,8 @@ var CaptionSchema2 = external_exports.object({
18810
18830
  words: external_exports.array(external_exports.object({ word: external_exports.string(), start: external_exports.number(), end: external_exports.number() })).min(1)
18811
18831
  });
18812
18832
  var TtsItemSchema = external_exports.object({
18813
- text: external_exports.string().min(1).max(5e3).describe("Narration text"),
18833
+ text: external_exports.string().min(1).max(FORM_CLIP_RULES ? MAX_NARRATION_CHARS : 5e3).describe(FORM_CLIP_RULES ? `Narration text for one question (max ${MAX_NARRATION_CHARS} characters)` : "Narration text"),
18834
+ ...FORM_CLIP_RULES ? { node_id: external_exports.string().describe("The form node (question) this narration is for. Required: a voiceover is for one question in a Clipform form.") } : {},
18814
18835
  voice: external_exports.enum(["ryan", "sonia", "andrew", "ava", "guy"]).optional().default("ryan").describe("Voice: ryan (British male, clear/articulate), sonia (British female, warm/bright), andrew (American male, smooth/neutral), ava (American female, vibrant/friendly), guy (American male, deep/authoritative). Pick ONE voice for the whole form based on its topic and audience, then reuse that same voice on every item and every call - never mix voices within a form unless the user explicitly asks for more than one."),
18815
18836
  tone: external_exports.string().max(500).optional().describe("Style instructions for how the voice should sound. E.g. 'Speak like an energetic quiz show host, playful and teasing' or 'Warm and conversational, like chatting with a friend'. Infer from context if not specified by the user.")
18816
18837
  });
@@ -18819,7 +18840,7 @@ function registerGenerateTtsTool(server) {
18819
18840
  "clipform_generate_tts",
18820
18841
  {
18821
18842
  title: "Generate Text-to-Speech",
18822
- description: `Generate narration audio from text with word-level captions. Use this for quiz question narration, survey introductions, form instructions, or any node that benefits from a human voice. Proactively suggest narration for quizzes and content-rich forms - it significantly improves engagement.
18843
+ description: `Generate narration audio from text with word-level captions${FORM_CLIP_RULES ? ` for one question in a Clipform form (max ${MAX_NARRATION_CHARS} characters). It does not make standalone voiceover files. Pass form_id and a node_id per item` : ""}. Use this for quiz question narration, survey introductions, form instructions, or any node that benefits from a human voice. Proactively suggest narration for quizzes and content-rich forms - it significantly improves engagement.
18823
18844
 
18824
18845
  Available voices: ryan (British male, clear), sonia (British female, warm), andrew (American male, smooth), ava (American female, vibrant), guy (American male, deep). Pick ONE voice that fits the topic - e.g. a London quiz gets ryan or sonia, a US sports quiz gets andrew or guy - and reuse that SAME voice for every item and every call across the whole form. Never mix voices within one form unless the user explicitly asks for multiple voices.
18825
18846
 
@@ -18828,7 +18849,7 @@ Use the tone parameter to direct HOW the voice speaks. Always set a tone that ma
18828
18849
  Pass one item or many (max 10) - multiple items run in parallel. Returns audio_url and caption_ref per item - pass caption_ref downstream to clipform_render_composition / clipform_render_video_template / clipform_upload_media_asset to attach this run's word-level captions instead of hand-copying the captions array.`,
18829
18850
  inputSchema: external_exports.object({
18830
18851
  workspace_id: workspaceIdInput,
18831
- form_id: formIdTargetInput,
18852
+ form_id: FORM_CLIP_RULES ? external_exports.string().uuid().describe("The form this narration is for (from clipform_create_form). Required.") : formIdTargetInput,
18832
18853
  items: external_exports.array(TtsItemSchema).min(1).max(10).describe("One or more TTS items to generate")
18833
18854
  }),
18834
18855
  outputSchema: external_exports.object({
@@ -18844,16 +18865,27 @@ Pass one item or many (max 10) - multiple items run in parallel. Returns audio_u
18844
18865
  }),
18845
18866
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
18846
18867
  },
18847
- // `form_id` (#4621) is a routing hint only, consumed centrally by
18868
+ // `form_id` (#4621) is also a routing hint, consumed centrally by
18848
18869
  // `runWithWorkspaceTarget` (server.ts) before this handler runs - it
18849
- // swaps the auth context's workspace_id read below, but is never
18850
- // forwarded to the API itself (the /internal/tts route takes no form_id).
18851
- async ({ items, form_id: _form_id }) => {
18870
+ // swaps the auth context's workspace_id read below. Under the form-clip
18871
+ // rules (#4622) it and each item's node_id are ALSO forwarded: the API
18872
+ // checks the node belongs to the form in the caller's workspace.
18873
+ async ({ items, form_id }) => {
18874
+ if (FORM_CLIP_RULES && (!form_id || items.some((i) => !i.node_id))) {
18875
+ return errorResult("form_id and a node_id per item are required: a voiceover is for one question in a Clipform form.");
18876
+ }
18852
18877
  const workspace_id = getMcpAuth()?.workspace_id;
18853
18878
  const results = await Promise.allSettled(
18854
18879
  items.map(
18855
18880
  (item) => callApi("/internal/tts", {
18856
- body: { text: item.text, voice: item.voice, tone: item.tone, workspace_id },
18881
+ body: {
18882
+ text: item.text,
18883
+ voice: item.voice,
18884
+ tone: item.tone,
18885
+ workspace_id,
18886
+ ...FORM_CLIP_RULES && form_id ? { form_id } : {},
18887
+ ...FORM_CLIP_RULES && item.node_id ? { node_id: item.node_id } : {}
18888
+ },
18857
18889
  // Synthesize + audio upload + caption store (#4070) occasionally
18858
18890
  // exceeds 45s; 90s clears the real tail with margin.
18859
18891
  timeoutMs: 9e4
@@ -19008,7 +19040,7 @@ Example: { queries: [{ query: "saturn rings" }, { query: "mars surface", count:
19008
19040
 
19009
19041
  // src/lib/render-routing.ts
19010
19042
  var RENDER_ROUTING_RULE = `Choosing a render tool: for a recognisable form/quiz beat (guess-the-city, this-or-that, mystery reveal, multiple choice, photo montage...) reach for a video template first (clipform_list_video_templates + clipform_render_video_template) - it is a one-call recipe. For a photo/clip montage, narrated or silent, use the slideshow template (pass audio_url to sync it to a voice track). Use clipform_render_composition only when neither fits and you need a custom layer stack.`;
19011
- var RENDER_ATTACH_RULE = `A render for a form node is not done until it is attached to that node. Pass node_id (and form_id) so the completed render attaches itself automatically - do not poll clipform_check_render to completion or manually chain clipform_upload_media_asset + clipform_attach_node_media; fire the render and move on.`;
19043
+ var RENDER_ATTACH_RULE = FORM_CLIP_RULES ? `A render is a short clip (max ${MAX_CLIP_SECONDS}s) for one question in a Clipform form, and it is not done until it is attached to that question. Pass form_id and node_id so the completed render attaches itself automatically and returns the node and media_asset_id - do not poll clipform_check_render to completion; fire the render and move on. It does not clip or edit existing footage, animate photos, lip-sync, or make standalone or long videos.` : `A render for a form node is not done until it is attached to that node. Pass node_id (and form_id) so the completed render attaches itself automatically - do not poll clipform_check_render to completion or manually chain clipform_upload_media_asset + clipform_attach_node_media; fire the render and move on.`;
19012
19044
 
19013
19045
  // ../../node_modules/.pnpm/uuid@11.1.1/node_modules/uuid/dist/esm/stringify.js
19014
19046
  var byteToHex = [];
@@ -19261,16 +19293,21 @@ function attachStructuredFields(attach) {
19261
19293
  ...attach.error ? { attach_error: attach.error } : {}
19262
19294
  };
19263
19295
  }
19296
+ function visiblePublicUrl(publicUrl, attach) {
19297
+ return FORM_CLIP_RULES && attach?.attached ? void 0 : publicUrl;
19298
+ }
19264
19299
  function attachSummaryLine(nodeId, attach) {
19265
- return attach.attached ? `Attached to node ${nodeId}${attach.republished ? " and republished." : "."}` : `Auto-attach to node ${nodeId} failed: ${attach.error}. Attach manually via clipform_upload_media_asset then clipform_attach_node_media.`;
19300
+ return attach.attached ? `Attached to node ${nodeId}${attach.media_asset_id && FORM_CLIP_RULES ? ` (media_asset_id ${attach.media_asset_id})` : ""}${attach.republished ? " and republished." : "."}` : `Auto-attach to node ${nodeId} failed: ${attach.error}. Attach manually via clipform_upload_media_asset then clipform_attach_node_media.`;
19266
19301
  }
19267
19302
 
19268
19303
  // src/tools/render-composition.ts
19304
+ var nodeIdField = FORM_CLIP_RULES ? external_exports.string() : external_exports.string().optional();
19305
+ var formIdField = FORM_CLIP_RULES ? external_exports.string().uuid() : external_exports.string().uuid().optional();
19269
19306
  var RenderItemSchema = external_exports.object({
19270
19307
  compositionId: external_exports.string().describe("The composition ID (see clipform_list_compositions)"),
19271
19308
  outputFormat: external_exports.enum(["mp4", "png"]).default("mp4").describe("Output format (default: mp4)"),
19272
19309
  inputProps: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Props matching the composition's schema - validated strictly"),
19273
- node_id: external_exports.string().optional().describe("Form node to attach this item's render to automatically once it completes. Requires the batch's top-level form_id."),
19310
+ node_id: nodeIdField.describe("Form node to attach this item's render to automatically once it completes. Requires the batch's top-level form_id."),
19274
19311
  captions: external_exports.array(CaptionSchema).optional().describe("Word-level captions from clipform_generate_tts - carried onto the attached media asset. Only used when node_id is set."),
19275
19312
  caption_ref: external_exports.string().optional().describe("caption_ref from clipform_generate_tts - an opaque handle that attaches that TTS run's word-level captions to the media asset, resolved server-side. Preferred over captions. Only used when node_id is set.")
19276
19313
  });
@@ -19286,7 +19323,9 @@ function fireRender(item, formId) {
19286
19323
  body: {
19287
19324
  compositionId: item.compositionId,
19288
19325
  outputFormat: item.outputFormat,
19289
- inputProps: item.inputProps ?? {}
19326
+ inputProps: item.inputProps ?? {},
19327
+ ...formId ? { form_id: formId } : {},
19328
+ ...item.node_id ? { node_id: item.node_id } : {}
19290
19329
  }
19291
19330
  }).then(async (r) => {
19292
19331
  if (!r.ok) {
@@ -19330,11 +19369,11 @@ function registerRenderCompositionTool(server) {
19330
19369
  "clipform_render_composition",
19331
19370
  {
19332
19371
  title: "Render Composition",
19333
- description: `Render a specialised video composition to MP4 or PNG - custom animated visuals that a video template can't provide, such as geography animations or designed motion graphics. Available composition names and their required input props schemas come from clipform_list_compositions.
19372
+ description: `Render a specialised video composition to MP4 or PNG${FORM_CLIP_RULES ? ` for one question in a Clipform form (max ${MAX_CLIP_SECONDS}s, attached to that question)` : ""} - custom animated visuals that a video template can't provide, such as geography animations or designed motion graphics. Available composition names and their required input props schemas come from clipform_list_compositions.
19334
19373
 
19335
- Output formats: mp4 (H.264, best for social media) or png (single frame). Returns a public URL when complete.
19374
+ Output formats: mp4 (H.264) or png (single frame). ${FORM_CLIP_RULES ? "The completed render attaches itself to the node and returns the node and media_asset_id." : "Returns a public URL when complete."}
19336
19375
 
19337
- For multi-render builds (e.g. one clip per quiz question), pass everything in ONE call via items (max 10): all renders fire in parallel and you get one job ID each - then collect the URLs in a single clipform_check_render call with job_ids. Single render: pass compositionId/inputProps at the top level (wait: true blocks and returns the URL; wait: false returns a job ID).
19376
+ For multi-render builds (e.g. one clip per quiz question), pass everything in ONE call via items (max 10): all renders fire in parallel and you get one job ID each - then collect the results in a single clipform_check_render call with job_ids. Single render: pass compositionId/inputProps at the top level (wait: true blocks until the render is ready; wait: false returns a job ID).
19338
19377
 
19339
19378
  ${RENDER_ROUTING_RULE}
19340
19379
  ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_id once at the top level.`,
@@ -19342,10 +19381,10 @@ ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_i
19342
19381
  compositionId: external_exports.string().optional().describe(`Single render: the composition ID. Call clipform_list_compositions to see available options (e.g. ${EXPOSED_COMPOSITIONS.map((id) => `'${id}'`).join(", ")}). Use items instead for multiple renders.`),
19343
19382
  outputFormat: external_exports.enum(["mp4", "png"]).default("mp4").describe("Single render: output format (default: mp4)"),
19344
19383
  inputProps: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Single render: props object matching the composition's schema from clipform_list_compositions. Validated STRICTLY - unknown or missing props fail with the schema in the error, nothing renders silently with defaults. For map compositions (Map), wide shots (camera.zoom < 9) may round lat/lng to 1 decimal place to improve cache hit rates; close shots and pin drops should keep full precision \u2014 the pin lands exactly on `target`."),
19345
- wait: external_exports.boolean().optional().default(true).describe("Single render only: true (default) blocks until the render is ready and returns its URL; false returns a job ID for clipform_check_render. Batch items always run fire-and-poll."),
19384
+ wait: external_exports.boolean().optional().default(true).describe(FORM_CLIP_RULES ? "Single render only: true (default) blocks until the render is ready and attached to the node; false returns a job ID for clipform_check_render. Batch items always run fire-and-poll." : "Single render only: true (default) blocks until the render is ready and returns its URL; false returns a job ID for clipform_check_render. Batch items always run fire-and-poll."),
19346
19385
  items: external_exports.array(RenderItemSchema).min(1).max(10).optional().describe("Batch mode: multiple renders in one call. All fire in parallel; returns one job ID per item - collect with clipform_check_render (job_ids). Use this whenever rendering more than one clip."),
19347
- node_id: external_exports.string().optional().describe("Single render only: form node to attach this render to automatically once it completes. Requires form_id. For batch mode, set node_id per item instead."),
19348
- form_id: external_exports.string().uuid().optional().describe("The form UUID - required when node_id is set (single render) or any item sets node_id (batch)."),
19386
+ node_id: external_exports.string().optional().describe(FORM_CLIP_RULES ? "Single render only (required for a single render): form node to attach this render to automatically once it completes. Requires form_id. For batch mode, set node_id per item instead." : "Single render only: form node to attach this render to automatically once it completes. Requires form_id. For batch mode, set node_id per item instead."),
19387
+ form_id: formIdField.describe(`The form UUID${FORM_CLIP_RULES ? " - required" : " - required when node_id is set (single render) or any item sets node_id (batch)"}.`),
19349
19388
  captions: external_exports.array(CaptionSchema).optional().describe("Single render only: word-level captions from clipform_generate_tts, carried onto the attached media asset. Only used when node_id is set. For batch mode, set captions per item instead."),
19350
19389
  caption_ref: external_exports.string().optional().describe("Single render only: caption_ref from clipform_generate_tts - an opaque handle that attaches that TTS run's word-level captions to the media asset, resolved server-side. Preferred over captions. Only used when node_id is set. For batch mode, set caption_ref per item instead.")
19351
19390
  }),
@@ -19354,7 +19393,7 @@ ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_i
19354
19393
  external_exports.object({
19355
19394
  status: external_exports.enum(["rendering", "complete"]),
19356
19395
  job_id: external_exports.string().optional().describe("Present when status is 'rendering' - pass to check_render"),
19357
- public_url: external_exports.string().optional().describe("Present when status is 'complete' - attach via upload_media_asset then attach_node_media (fit_media: true), unless node_id was set (auto-attached)"),
19396
+ public_url: external_exports.string().optional().describe(FORM_CLIP_RULES ? "Present when status is 'complete' and the render was not attached to a node, or alongside attach_error so the attach can be retried." : "Present when status is 'complete' - attach via upload_media_asset then attach_node_media (fit_media: true), unless node_id was set (auto-attached)"),
19358
19397
  composition_id: external_exports.string().optional(),
19359
19398
  output_format: external_exports.string().optional(),
19360
19399
  attached: external_exports.boolean().optional().describe("True when node_id was provided and the render was attached to the node automatically (present once the attach outcome is known)."),
@@ -19371,6 +19410,11 @@ ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_i
19371
19410
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }
19372
19411
  },
19373
19412
  async ({ compositionId, outputFormat, inputProps, wait, items, node_id, form_id, captions, caption_ref }) => {
19413
+ if (FORM_CLIP_RULES) {
19414
+ if (!form_id) return errorResult("form_id is required: a render is for one question in a Clipform form.");
19415
+ const missing = items?.length ? items.some((i) => !i.node_id) : !node_id;
19416
+ if (missing) return errorResult("node_id is required: a render is for one question in a Clipform form, so every render needs the node it attaches to.");
19417
+ }
19374
19418
  if (items?.length && compositionId) {
19375
19419
  return errorResult("Pass EITHER items (batch) OR compositionId (single render), not both.");
19376
19420
  }
@@ -19425,7 +19469,13 @@ ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_i
19425
19469
  const placeholderPromise = node_id && form_id ? createRenderPlaceholder({ formId: form_id, nodeId: node_id, mediaType: mediaTypeSingle, narrated }) : Promise.resolve(void 0);
19426
19470
  const result = await callApi("/internal/render", {
19427
19471
  timeoutMs: 3e5,
19428
- body: { compositionId, outputFormat, inputProps: inputProps ?? {} }
19472
+ body: {
19473
+ compositionId,
19474
+ outputFormat,
19475
+ inputProps: inputProps ?? {},
19476
+ ...form_id ? { form_id } : {},
19477
+ ...node_id ? { node_id } : {}
19478
+ }
19429
19479
  });
19430
19480
  if (!result.ok) {
19431
19481
  const placeholder = await placeholderPromise;
@@ -19451,16 +19501,17 @@ ${RENDER_ATTACH_RULE} In batch mode, set node_id per item (see items) and form_i
19451
19501
  await failPlaceholder(placeholder, "Render completed without a public_url; nothing to attach.");
19452
19502
  }
19453
19503
  }
19504
+ const shownUrl = visiblePublicUrl(data.public_url, attach);
19454
19505
  return structuredResult(
19455
19506
  [
19456
- `Render complete. Public URL: ${data.public_url}`,
19507
+ shownUrl ? `Render complete. Public URL: ${shownUrl}` : `Render complete.`,
19457
19508
  attach ? attachSummaryLine(node_id, attach) : `Attach via clipform_upload_media_asset then clipform_attach_node_media with fit_media: true (composed 9:16 frame - contain, never crop).`
19458
19509
  ].join("\n"),
19459
19510
  {
19460
19511
  jobs: [
19461
19512
  {
19462
19513
  status: "complete",
19463
- ...data.public_url ? { public_url: data.public_url } : {},
19514
+ ...shownUrl ? { public_url: shownUrl } : {},
19464
19515
  composition_id: compositionId,
19465
19516
  output_format: outputFormat,
19466
19517
  ...attachStructuredFields(attach)
@@ -19689,7 +19740,7 @@ function registerRenderVideoTemplateTool(server) {
19689
19740
  "clipform_render_video_template",
19690
19741
  {
19691
19742
  title: "Render Video Template",
19692
- description: `Render a curated video template (a pre-arranged Scene: bed + overlay + sane defaults) to MP4 or PNG from a small controls object, instead of hand-assembling Scene layers. Call clipform_list_video_templates first for available template names and their controls. Renders through the Scene composition under the hood.
19743
+ description: `Render a curated video template (a pre-arranged Scene: bed + overlay + sane defaults) to MP4 or PNG${FORM_CLIP_RULES ? ` for one question in a Clipform form (max ${MAX_CLIP_SECONDS}s, attached to that question)` : ""} from a small controls object, instead of hand-assembling Scene layers. Call clipform_list_video_templates first for available template names and their controls. Renders through the Scene composition under the hood.
19693
19744
 
19694
19745
  ${RENDER_ROUTING_RULE}
19695
19746
  ${RENDER_ATTACH_RULE}`,
@@ -19697,16 +19748,16 @@ ${RENDER_ATTACH_RULE}`,
19697
19748
  template: external_exports.string().describe("Video template name (see clipform_list_video_templates)."),
19698
19749
  controls: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Template-specific controls (see clipform_list_video_templates for the exposed control surface)."),
19699
19750
  outputFormat: external_exports.enum(["mp4", "png"]).default("mp4").describe("Output format (default: mp4)"),
19700
- wait: external_exports.boolean().optional().default(true).describe("true (default) blocks until the render is ready and returns its URL; false returns a job ID for clipform_check_render."),
19701
- node_id: external_exports.string().optional().describe("Form node to attach this render to automatically once it completes - skips the manual clipform_upload_media_asset + clipform_attach_node_media steps and republishes the form if it's currently live. Requires form_id."),
19702
- form_id: external_exports.string().uuid().optional().describe("The form UUID (required when node_id is set)."),
19751
+ wait: external_exports.boolean().optional().default(true).describe(FORM_CLIP_RULES ? "true (default) blocks until the render is ready and attached to the node; false returns a job ID for clipform_check_render." : "true (default) blocks until the render is ready and returns its URL; false returns a job ID for clipform_check_render."),
19752
+ node_id: (FORM_CLIP_RULES ? external_exports.string() : external_exports.string().optional()).describe(FORM_CLIP_RULES ? "The form node (question) this clip is for - the render attaches to it automatically once it completes and the form is republished if it's currently live. Requires form_id." : "Form node to attach this render to automatically once it completes - skips the manual clipform_upload_media_asset + clipform_attach_node_media steps and republishes the form if it's currently live. Requires form_id."),
19753
+ form_id: (FORM_CLIP_RULES ? external_exports.string().uuid() : external_exports.string().uuid().optional()).describe(FORM_CLIP_RULES ? "The form UUID." : "The form UUID (required when node_id is set)."),
19703
19754
  captions: external_exports.array(CaptionSchema).optional().describe("Word-level captions from clipform_generate_tts - carried onto the attached media asset. Only used when node_id is set."),
19704
19755
  caption_ref: external_exports.string().optional().describe("caption_ref from clipform_generate_tts - an opaque handle that attaches that TTS run's word-level captions to the media asset, resolved server-side. Preferred over captions. Only used when node_id is set. Defaults to controls.audio_url when that is a clipform_generate_tts track (slideshow narration), so narrated montages keep their captions.")
19705
19756
  }),
19706
19757
  outputSchema: external_exports.object({
19707
19758
  status: external_exports.enum(["rendering", "complete"]),
19708
19759
  job_id: external_exports.string().optional().describe("Present when status is 'rendering' - pass to clipform_check_render"),
19709
- public_url: external_exports.string().optional().describe("Present when status is 'complete' - attach via upload_media_asset then attach_node_media (fit_media: true), unless node_id was set (auto-attached)"),
19760
+ public_url: external_exports.string().optional().describe(FORM_CLIP_RULES ? "Present when status is 'complete' and the render was not attached to a node, or alongside attach_error so the attach can be retried." : "Present when status is 'complete' - attach via upload_media_asset then attach_node_media (fit_media: true), unless node_id was set (auto-attached)"),
19710
19761
  template: external_exports.string().optional(),
19711
19762
  duration_seconds: external_exports.number().optional().describe("Final video length in seconds - the narration's real length when audio_url drove it."),
19712
19763
  output_format: external_exports.string().optional(),
@@ -19722,12 +19773,21 @@ ${RENDER_ATTACH_RULE}`,
19722
19773
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }
19723
19774
  },
19724
19775
  async ({ template, controls, outputFormat, wait, node_id, form_id, captions, caption_ref }) => {
19776
+ if (FORM_CLIP_RULES && (!form_id || !node_id)) {
19777
+ return errorResult("form_id and node_id are required: a render is for one question in a Clipform form, so it needs the node it attaches to.");
19778
+ }
19725
19779
  if (node_id && !form_id) {
19726
19780
  return errorResult("form_id is required when node_id is set.");
19727
19781
  }
19728
19782
  const captionRef = resolveCaptionRef(caption_ref, controls?.audio_url);
19729
19783
  const narrated = renderHasNarration({ captions, captionRef, controls });
19730
- const renderBody = { template, controls: controls ?? {}, outputFormat };
19784
+ const renderBody = {
19785
+ template,
19786
+ controls: controls ?? {},
19787
+ outputFormat,
19788
+ ...form_id ? { form_id } : {},
19789
+ ...node_id ? { node_id } : {}
19790
+ };
19731
19791
  const mediaType = outputFormat === "png" ? "still" : "video";
19732
19792
  if (wait === false) {
19733
19793
  const job = createJob("clipform_render_video_template");
@@ -19790,15 +19850,16 @@ ${RENDER_ATTACH_RULE}`,
19790
19850
  await failPlaceholder(placeholder, "Render completed without a public_url; nothing to attach.");
19791
19851
  }
19792
19852
  }
19853
+ const shownUrl = visiblePublicUrl(data.public_url, attach);
19793
19854
  return structuredResult(
19794
19855
  [
19795
- `Render complete. Public URL: ${data.public_url}`,
19856
+ shownUrl ? `Render complete. Public URL: ${shownUrl}` : `Render complete.`,
19796
19857
  typeof data.duration_seconds === "number" ? `Duration: ${data.duration_seconds}s` : "",
19797
19858
  attach ? attachSummaryLine(node_id, attach) : `Attach via clipform_upload_media_asset then clipform_attach_node_media with fit_media: true (composed 9:16 frame - contain, never crop).`
19798
19859
  ].filter(Boolean).join("\n"),
19799
19860
  {
19800
19861
  status: "complete",
19801
- ...data.public_url ? { public_url: data.public_url } : {},
19862
+ ...shownUrl ? { public_url: shownUrl } : {},
19802
19863
  ...typeof data.duration_seconds === "number" ? { duration_seconds: data.duration_seconds } : {},
19803
19864
  template,
19804
19865
  output_format: outputFormat,
@@ -19887,7 +19948,7 @@ function projectJob(id, job) {
19887
19948
  return {
19888
19949
  job_id: id,
19889
19950
  status: "complete",
19890
- ...data?.public_url ? { public_url: data.public_url } : {},
19951
+ ...visiblePublicUrl(data?.public_url, job.attach) ? { public_url: visiblePublicUrl(data.public_url, job.attach) } : {},
19891
19952
  ...typeof data?.duration_seconds === "number" ? { duration_seconds: data.duration_seconds } : {},
19892
19953
  ...attachStructuredFields(job.attach)
19893
19954
  };
@@ -19911,7 +19972,7 @@ function describeJob(id, job) {
19911
19972
  }
19912
19973
  const data = job.result;
19913
19974
  const extras = [
19914
- ...data.public_url ? [data.public_url] : [],
19975
+ ...visiblePublicUrl(data.public_url, job.attach) ? [visiblePublicUrl(data.public_url, job.attach)] : [],
19915
19976
  ...data.duration_seconds ? [`${data.duration_seconds}s`] : []
19916
19977
  ].join(" | ");
19917
19978
  const attachNote = job.attach ? job.attach.attached ? ` (attached${job.attach.republished ? " + republished" : ""})` : ` (attach FAILED: ${job.attach.error})` : "";
@@ -19943,7 +20004,7 @@ Pass job_ids to check a whole batch in ONE call - one line of status per job. Pa
19943
20004
  republished: external_exports.boolean().optional().describe("True when the form was live and was republished to include this media."),
19944
20005
  attach_error: external_exports.string().optional().describe("Present when node_id was set but auto-attach failed - the render itself still succeeded.")
19945
20006
  })
19946
- ).describe("One entry per queried job; attach completed public_urls via upload_media_asset then attach_node_media unless already auto-attached")
20007
+ ).describe(FORM_CLIP_RULES ? "One entry per queried job. A render that attached to its node carries the attach outcome and media_asset_id; public_url appears only when it was not attached or alongside attach_error." : "One entry per queried job; attach completed public_urls via upload_media_asset then attach_node_media unless already auto-attached")
19947
20008
  }),
19948
20009
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
19949
20010
  },
@@ -19979,7 +20040,7 @@ Pass job_ids to check a whole batch in ONE call - one line of status per job. Pa
19979
20040
  return structuredResult(
19980
20041
  [
19981
20042
  `Render complete.`,
19982
- ...data.public_url ? [`Public URL: ${data.public_url}`] : [],
20043
+ ...visiblePublicUrl(data.public_url, job.attach) ? [`Public URL: ${visiblePublicUrl(data.public_url, job.attach)}`] : [],
19983
20044
  ...data.duration_seconds ? [`Duration: ${data.duration_seconds}s`] : [],
19984
20045
  ...attachLines
19985
20046
  ].join("\n"),
@@ -20276,6 +20337,7 @@ function buildInstructions(caps, signedIn) {
20276
20337
  "When the brief is clear, build the form directly; when it's vague, ask one or two short questions first.",
20277
20338
  caps.media && "Prefer rich media: video over images over plain text.",
20278
20339
  caps.media ? "Before building, derive a register from the topic and audience (e.g. hype, playful, warm, considered, elegant, sombre); if the user states a mood explicitly, that wins. State the register once, then apply it to every rendering choice - narration tone, motion preset, music, pacing. Never mix registers in one form." : "Before building, derive a register from the topic and audience (e.g. hype, playful, warm, considered, elegant, sombre); if the user states a mood explicitly, that wins. State the register once, then apply it to every question, option, and end-screen line. Never mix registers in one form.",
20340
+ caps.media && "Clipform's video tools make short clips for questions in a form. For clipping or editing existing video, animating a photo, lip-sync, or standalone or long videos, tell the user plainly that Clipform does not do that.",
20279
20341
  "At the start of a build, call clipform_get_workflow to load the recipe for the form type, and clipform_get_guide for craft detail.",
20280
20342
  "Every *_id argument is a UUID returned by the tools - not the short share_id from a form URL.",
20281
20343
  "Use clipform_whoami when the request is about the account itself (the active workspace, plan, or limits); building a form does not need it first.",
@@ -20437,7 +20499,7 @@ export {
20437
20499
  MissingRequiredClientCapabilityError,
20438
20500
  ReadBuffer,
20439
20501
  serializeMessage,
20440
- process2 as process,
20502
+ process,
20441
20503
  isLegacyRequest,
20442
20504
  createMcpHandler,
20443
20505
  RENDER_TIMING,
@@ -20455,4 +20517,4 @@ export {
20455
20517
  * MIT Licensed
20456
20518
  *)
20457
20519
  */
20458
- //# sourceMappingURL=chunk-VERNZWHH.js.map
20520
+ //# sourceMappingURL=chunk-H7MHP72Z.js.map