@instavar/mcp-server 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +42 -23
  2. package/dist/index.js +2969 -626
  3. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -236,14 +236,21 @@ function prepareAnnouncement(raw) {
236
236
  instructions: "Save these files in a new directory. Install and setup download pinned dependencies and Instavar fonts; setup embeds fonts locally before rendering. Review preview frames before rendering. Keep announcement.project.json as the copy source of truth. This tool has not written files, saved a hosted project or rendered video. Regenerating source preserves only the three copy fields, not custom source edits."
237
237
  };
238
238
  }
239
- function registerPairedAnnouncement(server) {
239
+ function pairedAnnouncementInstructions(pairedCatalogue = false) {
240
+ return pairedCatalogue ? PAIRED_ANNOUNCEMENT_INSTRUCTIONS.replace(
241
+ "The existing VideoSpec catalogue remains Remotion-only.",
242
+ "VideoSpec templates use prepare_video_template in either framework."
243
+ ) : PAIRED_ANNOUNCEMENT_INSTRUCTIONS;
244
+ }
245
+ function registerPairedAnnouncement(server, options = {}) {
240
246
  server.registerTool(
241
247
  "prepare_announcement",
242
248
  {
243
249
  title: "Prepare an announcement in Remotion or HyperFrames",
244
- description: "Prepare one paired announcement-card-v1 template, continue its caller-held project, edit copy or switch frameworks. Returns source files for local rendering. " + PAIRED_ANNOUNCEMENT_INSTRUCTIONS,
250
+ description: "Prepare one paired announcement-card-v1 template, continue its caller-held project, edit copy or switch frameworks. Returns source files for local rendering. " + pairedAnnouncementInstructions(options.pairedCatalogue),
245
251
  inputSchema: pairedAnnouncementInput,
246
252
  annotations: {
253
+ title: "Prepare announcement",
247
254
  readOnlyHint: true,
248
255
  destructiveHint: false,
249
256
  openWorldHint: false
@@ -252,10 +259,10 @@ function registerPairedAnnouncement(server) {
252
259
  },
253
260
  async (args) => {
254
261
  try {
255
- const result2 = prepareAnnouncement(args);
262
+ const result3 = prepareAnnouncement(args);
256
263
  return {
257
- structuredContent: result2,
258
- content: [{ type: "text", text: JSON.stringify(result2) }]
264
+ structuredContent: result3,
265
+ content: [{ type: "text", text: JSON.stringify(result3) }]
259
266
  };
260
267
  } catch (error) {
261
268
  return {
@@ -272,12 +279,1241 @@ function registerPairedAnnouncement(server) {
272
279
  );
273
280
  }
274
281
 
282
+ // src/paired-templates/prepare-video-template.ts
283
+ import { z as z3 } from "zod";
284
+
285
+ // src/paired-templates/media-preflight.ts
286
+ function mediaRequirements(spec, timeline) {
287
+ const requirements = [];
288
+ for (const scene of timeline.scenes) {
289
+ const source = spec.scenes[scene.index];
290
+ if (source.kind !== "video-window") continue;
291
+ requirements.push({
292
+ path: String(source.content.src),
293
+ role: `scene ${scene.index + 1} video`,
294
+ kind: "video",
295
+ minSeconds: scene.visibleFrames / timeline.fps
296
+ });
297
+ }
298
+ if (spec.audio.narrationSrc)
299
+ requirements.push({
300
+ path: spec.audio.narrationSrc,
301
+ role: "narration",
302
+ kind: "audio"
303
+ });
304
+ if (spec.audio.musicSrc)
305
+ requirements.push({
306
+ path: spec.audio.musicSrc,
307
+ role: "music",
308
+ kind: "audio",
309
+ minSeconds: timeline.durationInFrames / timeline.fps
310
+ });
311
+ return requirements;
312
+ }
313
+ function preflightScript(requirements, fps) {
314
+ return `// Paired template media preflight. Run before rendering in either framework.
315
+ import { access } from "node:fs/promises";
316
+ import { execFileSync } from "node:child_process";
317
+
318
+ const requirements = ${JSON.stringify(requirements, null, 2)};
319
+ const tolerance = ${0.5 / fps};
320
+ function probe(file) {
321
+ try {
322
+ return JSON.parse(
323
+ execFileSync("ffprobe", ["-v", "error", "-show_streams", "-show_format", "-of", "json", file], { encoding: "utf8" })
324
+ );
325
+ } catch {
326
+ throw new Error("ffprobe could not read " + file + ". Install FFmpeg and check the file.");
327
+ }
328
+ }
329
+ for (const item of requirements) {
330
+ try {
331
+ await access(item.path);
332
+ } catch {
333
+ throw new Error("Missing " + item.role + " file " + item.path + ". Copy it to that path first.");
334
+ }
335
+ const info = probe(item.path);
336
+ const duration = Number(info.format?.duration ?? 0);
337
+ const stream = info.streams.find((entry) => entry.codec_type === item.kind);
338
+ if (!stream) throw new Error(item.role + " file " + item.path + " has no " + item.kind + " stream.");
339
+ if (item.kind === "audio" && stream.channels !== 2)
340
+ throw new Error(item.role + " file " + item.path + " must be stereo. Convert it first, for example: ffmpeg -i input -ac 2 output.wav");
341
+ // Untagged video is read as BT.709 by Remotion and BT.601 by HyperFrames,
342
+ // so saturated colours differ. Only tagged BT.709 SDR video renders alike.
343
+ if (item.kind === "video" && [stream.color_space, stream.color_primaries, stream.color_transfer].some((tag) => tag !== "bt709"))
344
+ throw new Error(item.role + " file " + item.path + " must be tagged BT.709 SDR (colour space " + stream.color_space + ", primaries " + stream.color_primaries + ", transfer " + stream.color_transfer + "). Convert it first, for example: ffmpeg -i input -vf scale=out_color_matrix=bt709:out_range=tv,format=yuv420p,setparams=range=tv:color_primaries=bt709:color_trc=bt709:colorspace=bt709 -c:v libx264 -crf 16 output.mp4");
345
+ if (item.minSeconds !== undefined && duration + tolerance < item.minSeconds)
346
+ throw new Error(item.role + " file " + item.path + " lasts " + duration + " s but must cover " + item.minSeconds + " s.");
347
+ }
348
+ console.log("Media preflight passed for " + requirements.length + " file(s).");
349
+ `;
350
+ }
351
+
352
+ // src/paired-templates/spring.ts
353
+ var CONFIG = { damping: 200, mass: 1, stiffness: 100 };
354
+ var REST_THRESHOLD = 5e-3;
355
+ function advance(animation, now) {
356
+ const { toValue, lastTimestamp, current, velocity } = animation;
357
+ const deltaTime = Math.min(now - lastTimestamp, 64);
358
+ const c = CONFIG.damping;
359
+ const m = CONFIG.mass;
360
+ const k = CONFIG.stiffness;
361
+ const v0 = -velocity;
362
+ const x0 = toValue - current;
363
+ const zeta = c / (2 * Math.sqrt(k * m));
364
+ const omega0 = Math.sqrt(k / m);
365
+ const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);
366
+ const t = deltaTime / 1e3;
367
+ const sin1 = Math.sin(omega1 * t);
368
+ const cos1 = Math.cos(omega1 * t);
369
+ const underDampedEnvelope = Math.exp(-zeta * omega0 * t);
370
+ const underDampedFrag1 = underDampedEnvelope * (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);
371
+ const underDampedPosition = toValue - underDampedFrag1;
372
+ const underDampedVelocity = zeta * omega0 * underDampedFrag1 - underDampedEnvelope * (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);
373
+ const criticallyDampedEnvelope = Math.exp(-omega0 * t);
374
+ const criticallyDampedPosition = toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);
375
+ const criticallyDampedVelocity = criticallyDampedEnvelope * (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);
376
+ return {
377
+ toValue,
378
+ lastTimestamp: now,
379
+ current: zeta < 1 ? underDampedPosition : criticallyDampedPosition,
380
+ velocity: zeta < 1 ? underDampedVelocity : criticallyDampedVelocity
381
+ };
382
+ }
383
+ function springCalculation(frame2, fps) {
384
+ let animation = {
385
+ lastTimestamp: 0,
386
+ current: 0,
387
+ toValue: 1,
388
+ velocity: 0
389
+ };
390
+ const frameClamped = Math.max(0, frame2);
391
+ const unevenRest = frameClamped % 1;
392
+ for (let f = 0; f <= Math.floor(frameClamped); f++) {
393
+ if (f === Math.floor(frameClamped)) f += unevenRest;
394
+ animation = advance(animation, f / fps * 1e3);
395
+ }
396
+ return animation;
397
+ }
398
+ function measureSpring(fps) {
399
+ let frame2 = 0;
400
+ let animation = springCalculation(frame2, fps);
401
+ let difference = Math.abs(animation.current - animation.toValue);
402
+ while (difference >= REST_THRESHOLD) {
403
+ frame2++;
404
+ animation = springCalculation(frame2, fps);
405
+ difference = Math.abs(animation.current - animation.toValue);
406
+ }
407
+ let finishedFrame = frame2;
408
+ for (let i = 0; i < 20; i++) {
409
+ frame2++;
410
+ animation = springCalculation(frame2, fps);
411
+ difference = Math.abs(animation.current - animation.toValue);
412
+ if (difference >= REST_THRESHOLD) {
413
+ i = 0;
414
+ finishedFrame = frame2 + 1;
415
+ }
416
+ }
417
+ return finishedFrame;
418
+ }
419
+ function springSamples(fps) {
420
+ const durationInFrames = Math.round(fps * 0.7);
421
+ const naturalDuration = measureSpring(fps);
422
+ return Array.from(
423
+ { length: durationInFrames + 2 },
424
+ (_, frame2) => frame2 > durationInFrames ? 1 : springCalculation(frame2 / (durationInFrames / naturalDuration), fps).current
425
+ );
426
+ }
427
+
428
+ // src/paired-templates/hyperframes-videospec.ts
429
+ var HYPERFRAMES_RUNTIME = { hyperframes: "0.8.143", gsap: "3.14.2" };
430
+ var LATIN_RANGE = "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD";
431
+ var PAIRED_FONTS = [
432
+ {
433
+ family: "Fraunces",
434
+ file: "Fraunces.woff2",
435
+ url: "https://fonts.gstatic.com/s/fraunces/v38/6NUu8FyLNQOQZAnv9bYEvDiIdE9Ea92uemAk_WBq8U_9v0c2Wa0K7iN7hzFUPJH58nib14c7qv8.woff2",
436
+ sha256: "7f9d191d999336d3b9790afa72e1358e50a13b06d4f289341e92a311967a80f9"
437
+ },
438
+ {
439
+ family: "Inter",
440
+ file: "Inter.woff2",
441
+ url: "https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa1ZL7.woff2",
442
+ sha256: "3100e775e8616cd2611beecfa23a4263d7037586789b43f035236a2e6fbd4c62"
443
+ }
444
+ ];
445
+ var NO_LOOK = {
446
+ scale: false,
447
+ fill: false,
448
+ surface: false,
449
+ background: false,
450
+ motion: false,
451
+ transition: false
452
+ };
453
+ var FIT_EXPONENT = 0.5;
454
+ var DEFAULT_LOOK = {
455
+ ...NO_LOOK,
456
+ scale: true,
457
+ fill: true,
458
+ surface: true
459
+ };
460
+ var fillScale = (width, height) => height * 9 === width * 16 ? 4 / 3 : height * 4 === width * 5 ? 9 / 8 : 1;
461
+ var palettes = {
462
+ "editorial-light": {
463
+ background: "#f4efe5",
464
+ surface: "#fffaf0",
465
+ ink: "#18241f",
466
+ muted: "#667169",
467
+ accent: "#2f6d5a",
468
+ accentSoft: "#cfe0d5",
469
+ signal: "#c96f58"
470
+ },
471
+ "editorial-dark": {
472
+ background: "#171c1a",
473
+ surface: "#222a27",
474
+ ink: "#f5efe3",
475
+ muted: "#abb7ae",
476
+ accent: "#a8cfb8",
477
+ accentSoft: "#30483e",
478
+ signal: "#ec967d"
479
+ },
480
+ clinical: {
481
+ background: "#f2f1e9",
482
+ surface: "#fbfaf5",
483
+ ink: "#14283a",
484
+ muted: "#60727c",
485
+ accent: "#3d796d",
486
+ accentSoft: "#d6e5df",
487
+ signal: "#d2705d"
488
+ }
489
+ };
490
+ function paletteFor(spec) {
491
+ if (spec.style.theme !== "default") return palettes[spec.style.theme];
492
+ return spec.templateFamily === "announcement-brief" ? palettes["editorial-light"] : palettes["editorial-dark"];
493
+ }
494
+ var escapeHtml = (value) => value.replace(
495
+ /[&<>"']/g,
496
+ (character) => ({
497
+ "&": "&amp;",
498
+ "<": "&lt;",
499
+ ">": "&gt;",
500
+ '"': "&quot;",
501
+ "'": "&#39;"
502
+ })[character]
503
+ );
504
+ var str = (value) => typeof value === "string" ? value : "";
505
+ var div = (className, value, attributes = "") => `<div class="${className}"${attributes}>${escapeHtml(value)}</div>`;
506
+ function sceneCss(palette, look, k, width, height) {
507
+ const p = palette;
508
+ const fonts = PAIRED_FONTS.map(
509
+ (font) => `@font-face{font-family:${font.family};src:url(${font.file}) format('woff2');font-weight:100 900;font-style:normal;unicode-range:${LATIN_RANGE}}`
510
+ ).join("");
511
+ return `${fonts}
512
+ *{box-sizing:border-box}
513
+ .fill{position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex;flex-direction:column}
514
+ .background{background:${p.background}}
515
+ .orb{position:absolute;width:760px;height:760px;border-radius:50%;background:${p.accentSoft};opacity:.42;right:-280px;top:-300px}
516
+ .ring{position:absolute;width:420px;height:420px;border-radius:50%;border:2px solid ${p.accent};opacity:.16;left:-220px;bottom:80px}
517
+ .layout{justify-content:center;padding:11% 9%}
518
+ .layout.hero{justify-content:space-between}
519
+ .layout.mechanism,.layout.points,.layout.equation{padding:10% 8.5%}
520
+ .layout.video-window{padding:8%}
521
+ .title{color:${p.ink};font-family:Fraunces;font-weight:600}
522
+ .subtitle{color:${p.muted};font-family:Inter}
523
+ .label{color:${p.muted};font-family:Inter;font-size:26px;font-weight:600;letter-spacing:.2px;margin-bottom:32px}
524
+ .accent-bar{width:116px;height:12px;border-radius:12px;background:${p.accent};transform-origin:left}
525
+ .hero-title{line-height:.98;letter-spacing:-2.6px;max-width:94%}
526
+ .hero-sub{font-size:38px;line-height:1.35;margin-top:44px;max-width:82%}
527
+ .footer{color:${p.accent};font-family:Inter;font-size:25px;font-weight:600}
528
+ .statement-card{width:88%;padding:70px 64px;border-radius:44px;background:${p.surface};box-shadow:0 32px 90px rgba(20,40,58,.10)}
529
+ .statement-title{font-size:88px;line-height:1.02}
530
+ .statement-sub{font-size:34px;line-height:1.4;margin-top:34px}
531
+ .mechanism-title{font-size:88px;line-height:1;letter-spacing:-1.5px}
532
+ .mechanism-sub{font-size:32px;line-height:1.35;margin-top:24px}
533
+ .states{display:grid;grid-template-columns:1fr 112px 1fr;align-items:center;gap:20px;margin-top:84px}
534
+ .state-card{height:520px;border-radius:220px;background:${p.surface};box-shadow:0 28px 70px rgba(20,40,58,.10);display:flex;flex-direction:column;align-items:center;justify-content:center;padding:28px}
535
+ .capsule{width:180px;height:290px;border-radius:90px;border:18px solid ${p.accent};opacity:.9}
536
+ .capsule.before{border-color:${p.signal}}
537
+ .state-label{color:${p.ink};font-family:Inter;font-size:29px;font-weight:600;margin-top:34px;text-align:center}
538
+ .arrow{color:${p.accent};font-family:Inter;font-size:64px;text-align:center}
539
+ .points-head{max-width:860px}
540
+ .points-title{line-height:1.02;letter-spacing:-1.7px}
541
+ .points-sub{font-size:32px;line-height:1.4;margin-top:24px}
542
+ .point-list{display:grid;gap:22px;margin-top:70px}
543
+ .point{display:grid;grid-template-columns:70px 1fr;align-items:center;gap:28px;background:${p.surface};border-radius:28px;padding:30px 34px;box-shadow:0 18px 52px rgba(20,40,58,.07)}
544
+ .number{width:58px;height:58px;border-radius:50%;background:${p.accentSoft};color:${p.accent};display:flex;align-items:center;justify-content:center;font-family:Inter;font-size:27px;font-weight:700}
545
+ .point-text{color:${p.ink};font-family:Inter;font-size:35px;font-weight:500;line-height:1.25}
546
+ .check{width:124px;height:124px;border-radius:50%;background:${p.accent};color:${p.background};font-family:Inter;font-size:58px;display:flex;align-items:center;justify-content:center;margin-bottom:58px}
547
+ .cta-title{font-size:104px;line-height:.98;letter-spacing:-2px}
548
+ .cta-sub{font-size:34px;line-height:1.4;margin-top:38px}
549
+ .equation-title{font-size:84px;line-height:1.02}
550
+ .equations{display:grid;gap:24px;margin-top:58px}
551
+ .equation-block{color:${p.ink};background:${p.surface};font-size:40px;padding:30px;border-radius:24px}
552
+ .window-title{font-size:72px;line-height:1.04;margin-bottom:42px}
553
+ .window{position:relative;height:66%;overflow:hidden;border-radius:36px;background:${p.surface};box-shadow:0 28px 80px rgba(20,40,58,.14)}
554
+ .window video{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}
555
+ .scene-label{position:absolute;left:54px;bottom:40px;color:${p.muted};font-family:Inter;font-size:18px}${lookCss(p, look, k, width, height)}`;
556
+ }
557
+ function lookCss(p, look, k, width, height) {
558
+ let css = "";
559
+ if (look.scale)
560
+ css += `
561
+ .hero-sub{font-size:46px}
562
+ .statement-sub,.cta-sub{font-size:42px}
563
+ .mechanism-sub,.points-sub{font-size:40px}
564
+ .point-text{font-size:42px}
565
+ .label,.footer{font-size:32px}
566
+ .state-label{font-size:36px}`;
567
+ if (look.fill && k !== 1)
568
+ css += `
569
+ .fill-box{position:absolute;top:0;left:0;width:${width / k}px;height:${height / k}px;transform:scale(${k});transform-origin:0 0}`;
570
+ if (look.surface)
571
+ css += `
572
+ .statement-card{width:100%;padding:8px 0 8px 52px;border-radius:0;background:none;box-shadow:none;border-left:12px solid ${p.accent}}
573
+ .statement-title{font-size:108px;line-height:1;letter-spacing:-2px}
574
+ .point-list{gap:0;margin-top:58px;border-bottom:2px solid ${p.muted}55}
575
+ .point{background:none;box-shadow:none;border-radius:0;padding:30px 0;border-top:2px solid ${p.muted}55;grid-template-columns:84px 1fr;gap:20px;align-items:baseline}
576
+ .number{width:auto;height:auto;border-radius:0;background:none;justify-content:flex-start;font-family:Fraunces;font-size:64px;font-weight:600;line-height:1}`;
577
+ if (look.background)
578
+ css += `
579
+ .background{background:linear-gradient(158deg,color-mix(in srgb,${p.background} 90%,${p.accentSoft}) 0%,${p.background} 46%,color-mix(in srgb,${p.background} 93%,${p.ink}) 100%)}
580
+ .orb{width:1100px;height:1100px;opacity:.5;background:radial-gradient(closest-side,${p.accentSoft} 0%,${p.accentSoft}00 100%);right:-420px;top:-420px}
581
+ .ring{display:none}
582
+ .bg-v1 .orb{right:auto;left:-460px;top:auto;bottom:-380px}
583
+ .bg-v2 .orb{right:-520px;top:30%}
584
+ .bg-v3 .orb{right:auto;left:-420px;top:-360px}
585
+ .grain{position:absolute;inset:0;opacity:.07;mix-blend-mode:overlay;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.4 -.2'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>")}`;
586
+ return css;
587
+ }
588
+ function title(content, className, fit = "") {
589
+ return div(
590
+ `title ${className}`,
591
+ str(content.title) || str(content.line1),
592
+ fit
593
+ );
594
+ }
595
+ function subtitle(content, className) {
596
+ const value = str(content.subtitle) || str(content.line2);
597
+ return value ? div(`subtitle ${className}`, value) : "";
598
+ }
599
+ function pointsSubtitle(content) {
600
+ const value = str(content.subtitle);
601
+ return value ? div("subtitle points-sub", value) : "";
602
+ }
603
+ function label(content) {
604
+ const value = str(content.label);
605
+ return value ? div("label", value) : "";
606
+ }
607
+ function sceneBody(scene, id2, seconds, look, k) {
608
+ const fit = (width, cap) => ` data-fit="${k === 1 ? width : Math.round(width / k ** FIT_EXPONENT * 10) / 10},${cap}"`;
609
+ const c = scene.content;
610
+ switch (scene.kind) {
611
+ case "hero":
612
+ if (look.motion)
613
+ return `<div class="accent-bar" data-motion="bar"></div><div><div data-motion="rise" data-rise="42">${title(
614
+ c,
615
+ "hero-title",
616
+ fit(885.6, 126)
617
+ )}</div><div data-motion="rise" data-rise="18" data-delay="5">${subtitle(
618
+ c,
619
+ "hero-sub"
620
+ )}</div></div><div data-motion="fade" data-delay="10">${div(
621
+ "footer",
622
+ str(c.footer)
623
+ )}</div>`;
624
+ return `<div class="accent-bar" data-motion="bar"></div><div data-motion="rise" data-rise="42">${title(
625
+ c,
626
+ "hero-title",
627
+ fit(885.6, 126)
628
+ )}${subtitle(c, "hero-sub")}</div>${div("footer", str(c.footer))}`;
629
+ case "statement":
630
+ case "custom":
631
+ return `<div class="statement-card" data-motion="rise" data-rise="36">${label(
632
+ c
633
+ )}${title(c, "statement-title")}${subtitle(c, "statement-sub")}</div>`;
634
+ case "mechanism": {
635
+ const state = (value, side) => `<div class="state-card"><div class="capsule ${side}" data-motion="${side}"></div>${div(
636
+ "state-label",
637
+ value
638
+ )}</div>`;
639
+ return `<div data-motion="fade">${label(c)}${title(
640
+ c,
641
+ "mechanism-title"
642
+ )}${str(c.subtitle) ? div("subtitle mechanism-sub", str(c.subtitle)) : ""}</div><div class="states">${state(
643
+ str(c.before),
644
+ "before"
645
+ )}<div class="arrow" data-motion="arrow">\u2192</div>${state(
646
+ str(c.after),
647
+ "after"
648
+ )}</div>`;
649
+ }
650
+ case "points": {
651
+ const points = c.points ?? [];
652
+ return `<div class="points-head">${label(c)}${title(
653
+ c,
654
+ "points-title",
655
+ fit(850, 98)
656
+ )}${pointsSubtitle(c)}</div><div class="point-list">${points.map(
657
+ (point2, index) => look.motion ? `<div class="point" data-motion="fade" data-delay="${index * 6}"><div data-motion="pop" data-delay="${index * 6}">${div(
658
+ "number",
659
+ String(index + 1)
660
+ )}</div><div data-motion="slide" data-delay="${index * 6 + 2}">${div("point-text", point2)}</div></div>` : `<div class="point" data-motion="rise" data-rise="28" data-delay="${index * 6}">${div("number", String(index + 1))}${div(
661
+ "point-text",
662
+ point2
663
+ )}</div>`
664
+ ).join("")}</div>`;
665
+ }
666
+ case "equation":
667
+ return `${div(
668
+ "title equation-title",
669
+ str(c.title)
670
+ )}<div class="equations">${c.latexBlocks.map(
671
+ (block) => `<code class="equation-block">${escapeHtml(block)}</code>`
672
+ ).join("")}</div>`;
673
+ case "video-window":
674
+ return `${div(
675
+ "title window-title",
676
+ str(c.title)
677
+ )}<div class="window"><video id="${id2}-video" class="clip" src="${escapeHtml(
678
+ str(c.src)
679
+ )}" data-start="0" data-duration="${seconds}" data-track-index="1" muted playsinline></video></div>`;
680
+ case "cta":
681
+ return `<div class="check" data-motion="pop">\u2713</div>${title(
682
+ c,
683
+ "cta-title"
684
+ )}${subtitle(c, "cta-sub")}`;
685
+ }
686
+ }
687
+ function sceneScript(id2, seconds, fps, look, exit) {
688
+ const samples = springSamples(fps);
689
+ const span = samples.length - 1;
690
+ return `(async()=>{
691
+ const root=document.getElementById(${JSON.stringify(id2)});
692
+ await Promise.all(['600 100px Fraunces','400 38px Inter','500 35px Inter','600 29px Inter','700 27px Inter'].map(f=>document.fonts.load(f)));
693
+ root.querySelectorAll('[data-fit]').forEach(e=>{const [width,cap]=e.dataset.fit.split(',').map(Number);const span=document.createElement('span');Object.assign(span.style,{fontFamily:'Fraunces',fontWeight:'600',fontSize:'100px',display:'inline-block',position:'absolute',top:'-10000px',whiteSpace:'pre',textRendering:'auto'});span.innerText=e.textContent;document.body.append(span);const size=Math.max(58,Math.min(cap,width/span.getBoundingClientRect().width*100*2.25));span.remove();e.style.fontSize=size+'px';});
694
+ const samples=${JSON.stringify(samples)};
695
+ const enter=f=>{if(f<=0)return samples[0];if(f>=${span})return 1;const i=Math.floor(f);return samples[i]+(samples[i+1]-samples[i])*(f-i);};
696
+ const tl=gsap.timeline({paused:true});
697
+ tl.to({},{duration:${seconds}},0);
698
+ const spring={duration:${span / fps},ease:t=>enter(t*${span}),force3D:false};
699
+ root.querySelectorAll('[data-motion="rise"]').forEach(e=>tl.fromTo(e,{opacity:0,y:Number(e.dataset.rise)},{opacity:1,y:0,...spring},Number(e.dataset.delay||0)/${fps}));
700
+ root.querySelectorAll('[data-motion="fade"]').forEach(e=>tl.fromTo(e,{opacity:0},{opacity:1,...spring},${look.motion ? "Number(e.dataset.delay||0)/" + fps : "0"}));
701
+ root.querySelectorAll('[data-motion="bar"]').forEach(e=>tl.fromTo(e,{scaleX:0},{scaleX:1,...spring},0));
702
+ root.querySelectorAll('[data-motion="pop"]').forEach(e=>tl.fromTo(e,{scale:0},{scale:1,...spring},${look.motion ? "Number(e.dataset.delay||0)/" + fps : "0"}));
703
+ const calm={duration:1.95,ease:'power1.inOut',force3D:false};
704
+ root.querySelectorAll('[data-motion="before"]').forEach(e=>tl.fromTo(e,{scaleX:1},{scaleX:0.66,...calm},0.45));
705
+ root.querySelectorAll('[data-motion="after"]').forEach(e=>tl.fromTo(e,{scaleX:0.45},{scaleX:0.25,...calm},0.45));
706
+ root.querySelectorAll('[data-motion="arrow"]').forEach(e=>tl.fromTo(e,{x:-14},{x:14,...calm},0.45));
707
+ ${look.motion ? `const at=e=>Number(e.dataset.delay||0)/${fps};
708
+ root.querySelectorAll('[data-motion="slide"]').forEach(e=>tl.fromTo(e,{opacity:0,x:36},{opacity:1,x:0,...spring},at(e)));
709
+ root.querySelectorAll('.orb').forEach(e=>tl.fromTo(e,{x:0,y:0},{x:-40,y:28,duration:${seconds},ease:'none',force3D:false},0));` : ""}${exit ? `tl.fromTo(root.querySelector('.layout'),{opacity:1},{opacity:0,duration:${6 / fps},ease:'power2.in',immediateRender:false},${seconds - 6 / fps});` : ""}window.__timelines=window.__timelines||{};window.__timelines[${JSON.stringify(
710
+ id2
711
+ )}]=tl;window.__hfForceTimelineRebind?.();
712
+ })();`;
713
+ }
714
+ function hyperframesVideoSpecFiles(spec, timeline, look = DEFAULT_LOOK) {
715
+ const palette = paletteFor(spec);
716
+ const { fps, width, height } = timeline;
717
+ const k = look.fill ? fillScale(width, height) : 1;
718
+ const css = sceneCss(palette, look, k, width, height);
719
+ const visible = timeline.scenes.filter((entry) => entry.visibleFrames > 0);
720
+ const total = timeline.durationInFrames / fps;
721
+ const files = {};
722
+ const hosts = [];
723
+ for (const entry of timeline.scenes) {
724
+ if (entry.visibleFrames === 0) continue;
725
+ const scene = spec.scenes[entry.index];
726
+ const id2 = `scene-${entry.index + 1}`;
727
+ const seconds = entry.visibleFrames / fps;
728
+ const boxed = look.fill && k !== 1;
729
+ const body = `<div class="fill background${look.background ? ` bg-v${entry.index % 4}` : ""}"><div class="orb" data-layout-allow-overflow></div><div class="ring" data-layout-allow-overflow></div>${look.background ? '<div class="grain"></div>' : ""}</div>${boxed ? '<div class="fill-box">' : ""}<div class="fill layout ${scene.kind}">${sceneBody(scene, id2, seconds, look, k)}</div>${boxed ? "</div>" : ""}${spec.style.showSceneLabels ? div("scene-label", scene.kind) : ""}`;
730
+ files[`compositions/${id2}.html`] = `<template><style>${css}
731
+ #${id2}{position:absolute;inset:0;width:100%;height:100%;overflow:hidden}
732
+ #${id2},#${id2} *{text-rendering:auto}</style><div id="${id2}" data-composition-id="${id2}" data-scene-id="${escapeHtml(
733
+ scene.id
734
+ )}" data-start="0" data-duration="${seconds}" data-width="${width}" data-height="${height}">${body}</div><script>${sceneScript(
735
+ id2,
736
+ seconds,
737
+ fps,
738
+ look,
739
+ look.transition && entry !== visible[visible.length - 1]
740
+ )}</script></template>
741
+ `;
742
+ hosts.push(
743
+ `<div id="${id2}" class="clip" data-composition-id="${id2}" data-composition-src="compositions/${id2}.html" data-start="${entry.startFrame / fps}" data-duration="${seconds}" data-track-index="0"></div>`
744
+ );
745
+ }
746
+ const audio = spec.audio;
747
+ if (audio.musicSrc)
748
+ hosts.push(
749
+ `<audio id="music" src="${escapeHtml(
750
+ audio.musicSrc
751
+ )}" data-start="0" data-duration="${total}" data-track-index="10" data-volume="${audio.ducking && audio.narrationSrc ? audio.musicVolume * 0.32 : audio.musicVolume}"></audio>`
752
+ );
753
+ if (audio.narrationSrc)
754
+ hosts.push(
755
+ `<audio id="narration" src="${escapeHtml(
756
+ audio.narrationSrc
757
+ )}" data-start="0" data-duration="${total}" data-track-index="11" data-volume="${audio.narrationVolume}"></audio>`
758
+ );
759
+ files["index.html"] = `<!doctype html>
760
+ <html lang="en"><head><meta charset="utf-8"><title>${escapeHtml(
761
+ spec.meta.title
762
+ )}</title><style>html,body{margin:0;width:100%;height:100%;background:${palette.background}}#video{position:absolute;inset:0;overflow:hidden;background:${palette.background}}.clip{position:absolute;inset:0}</style><script src="gsap.min.js"></script></head><body>
763
+ <div id="video" data-composition-id="video" data-start="0" data-width="${width}" data-height="${height}" data-duration="${total}">
764
+ ${hosts.join("\n")}
765
+ </div>
766
+ <script>const tl=gsap.timeline({paused:true});tl.to({},{duration:${total}});window.__timelines=window.__timelines||{};window.__timelines.video=tl;window.__hfForceTimelineRebind?.();</script>
767
+ </body></html>
768
+ `;
769
+ files["video.json"] = JSON.stringify(spec, null, 2) + "\n";
770
+ files["hyperframes.json"] = // A usage-attribution label only. HyperFrames 0.9.19 lists "general-video"
771
+ // as retired in favour of "hyperframes"; change it with the version.
772
+ JSON.stringify({ authoringSkill: "general-video" }, null, 2) + "\n";
773
+ files["package.json"] = JSON.stringify(
774
+ {
775
+ private: true,
776
+ type: "module",
777
+ scripts: {
778
+ setup: "node setup.mjs",
779
+ check: "hyperframes check",
780
+ preview: "hyperframes preview",
781
+ // Extract source video frames as PNG. The default JPEG extraction
782
+ // re-subsamples chroma and leaves 1:1 windows of saturated footage
783
+ // just under the similarity floor; since HyperFrames 0.8.143 PNG
784
+ // extraction no longer darkens BT.709 footage.
785
+ render: `hyperframes render --fps ${fps} --video-frame-format png --output video.mp4`
786
+ },
787
+ dependencies: HYPERFRAMES_RUNTIME
788
+ },
789
+ null,
790
+ 2
791
+ ) + "\n";
792
+ files["preflight.mjs"] = preflightScript(
793
+ mediaRequirements(spec, timeline),
794
+ fps
795
+ );
796
+ files["setup.mjs"] = `// Fetch the pinned fonts, copy the local GSAP runtime, then check media.
797
+ import { createHash } from "node:crypto";
798
+ import { copyFile, writeFile } from "node:fs/promises";
799
+
800
+ const fonts = ${JSON.stringify(
801
+ PAIRED_FONTS.map(({ file, url, sha256 }) => ({ file, url, sha256 })),
802
+ null,
803
+ 2
804
+ )};
805
+ for (const font of fonts) {
806
+ const response = await fetch(font.url);
807
+ if (!response.ok) throw new Error("Font download failed: " + font.url);
808
+ const bytes = Buffer.from(await response.arrayBuffer());
809
+ const digest = createHash("sha256").update(bytes).digest("hex");
810
+ if (digest !== font.sha256)
811
+ throw new Error("Font " + font.file + " changed upstream; expected sha-256 " + font.sha256);
812
+ await writeFile(font.file, bytes);
813
+ }
814
+ await copyFile("node_modules/gsap/dist/gsap.min.js", "gsap.min.js");
815
+ await import("./preflight.mjs");
816
+ `;
817
+ return files;
818
+ }
819
+
820
+ // src/paired-templates/remotion-videospec.ts
821
+ var REMOTION_TEMPLATES = {
822
+ repository: "https://github.com/instavar/remotion-templates",
823
+ commit: "d50166d84a75bdc0585897dc78316d6c6f6588ff",
824
+ remotion: "4.0.502"
825
+ };
826
+ function remotionVideoSpecFiles(spec, timeline) {
827
+ return {
828
+ "video.json": JSON.stringify(spec, null, 2) + "\n",
829
+ "preflight.mjs": preflightScript(
830
+ mediaRequirements(spec, timeline),
831
+ timeline.fps
832
+ )
833
+ };
834
+ }
835
+ function remotionVideoSpecCommands(spec) {
836
+ return [
837
+ `git clone ${REMOTION_TEMPLATES.repository}.git`,
838
+ "cd remotion-templates",
839
+ `git checkout ${REMOTION_TEMPLATES.commit}`,
840
+ "npm ci",
841
+ "# Save video.json and preflight.mjs here and place each referenced media file at its public/ path.",
842
+ "node preflight.mjs",
843
+ "npm run video:validate -- video.json",
844
+ "npm run video:preview -- video.json",
845
+ `npm run video:render -- video.json out/${spec.id}.mp4`
846
+ ];
847
+ }
848
+
849
+ // src/paired-templates/videospec-contract.ts
850
+ import { z as z2 } from "zod";
851
+ var PAIRED_VIDEOSPEC_CONTRACT = "paired-videospec/v1";
852
+ var PAIRED_TEMPLATE_FAMILIES = [
853
+ "qa-ad",
854
+ "proof-walkthrough",
855
+ "announcement-brief",
856
+ "social-remix",
857
+ "finance-brief"
858
+ ];
859
+ var PAIRED_SCENE_KINDS = [
860
+ "hero",
861
+ "statement",
862
+ // The public renderer draws custom as a statement card; so does HyperFrames.
863
+ "custom",
864
+ "mechanism",
865
+ "points",
866
+ "equation",
867
+ "video-window",
868
+ "cta"
869
+ ];
870
+ var PAIRED_FPS = { min: 1, max: 240 };
871
+ var PAIRED_LIMITS = {
872
+ scenes: 24,
873
+ sceneDurationMs: 3e5,
874
+ totalDurationMs: 20 * 60 * 1e3
875
+ };
876
+ var text2 = (max) => z2.string().max(max).refine((value) => value.trim().length > 0, "Must not be blank.");
877
+ var mediaPath = (extensions) => z2.string().max(200).refine(
878
+ (value) => /^public\/(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*$/.test(
879
+ value
880
+ ) && !value.split("/").includes("..") && extensions.some((extension) => value.toLowerCase().endsWith(extension)),
881
+ `Use a local file under public/ ending in ${extensions.join(
882
+ ", "
883
+ )}. Remote URLs and other paths are not supported by the paired templates.`
884
+ );
885
+ var videoPath = mediaPath([".mp4"]);
886
+ var audioPath = mediaPath([".wav", ".mp3", ".m4a"]);
887
+ var contentSchemas = {
888
+ hero: z2.object({
889
+ title: text2(160).optional(),
890
+ line1: text2(160).optional(),
891
+ subtitle: text2(400).optional(),
892
+ line2: text2(400).optional(),
893
+ footer: text2(120).optional()
894
+ }).strict(),
895
+ statement: z2.object({
896
+ title: text2(160).optional(),
897
+ line1: text2(160).optional(),
898
+ subtitle: text2(400).optional(),
899
+ line2: text2(400).optional(),
900
+ label: text2(60).optional()
901
+ }).strict(),
902
+ custom: z2.object({
903
+ title: text2(160).optional(),
904
+ line1: text2(160).optional(),
905
+ subtitle: text2(400).optional(),
906
+ line2: text2(400).optional(),
907
+ label: text2(60).optional()
908
+ }).strict(),
909
+ // The public renderer reads only title here and invents copy for missing
910
+ // before/after states, so all three are required.
911
+ mechanism: z2.object({
912
+ title: text2(160),
913
+ subtitle: text2(400).optional(),
914
+ label: text2(60).optional(),
915
+ before: text2(80),
916
+ after: text2(80)
917
+ }).strict(),
918
+ points: z2.object({
919
+ title: text2(160).optional(),
920
+ line1: text2(160).optional(),
921
+ subtitle: text2(400).optional(),
922
+ label: text2(60).optional(),
923
+ points: z2.array(text2(160)).max(8).default([])
924
+ }).strict(),
925
+ equation: z2.object({
926
+ title: text2(160),
927
+ latexBlocks: z2.array(text2(400)).min(1).max(6)
928
+ }).strict(),
929
+ "video-window": z2.object({
930
+ title: text2(160),
931
+ src: videoPath
932
+ }).strict(),
933
+ cta: z2.object({
934
+ title: text2(160).optional(),
935
+ line1: text2(160).optional(),
936
+ subtitle: text2(400).optional(),
937
+ line2: text2(400).optional()
938
+ }).strict()
939
+ };
940
+ var narrationTimingSchema = z2.object({
941
+ schemaVersion: z2.literal("1.0"),
942
+ source: z2.literal("segmented-synthesis"),
943
+ durationMs: z2.number().int().positive().max(PAIRED_LIMITS.totalDurationMs),
944
+ segments: z2.array(
945
+ z2.object({
946
+ sceneId: z2.string().min(1).max(80),
947
+ startMs: z2.number().int().nonnegative(),
948
+ endMs: z2.number().int().positive(),
949
+ durationMs: z2.number().int().positive()
950
+ }).strict()
951
+ ).min(1).max(PAIRED_LIMITS.scenes)
952
+ }).strict();
953
+ var sceneSchema = z2.object({
954
+ id: z2.string().min(1).max(80),
955
+ kind: z2.string(),
956
+ content: z2.record(z2.unknown()),
957
+ timing: z2.object({
958
+ durationMs: z2.number().int().positive().max(PAIRED_LIMITS.sceneDurationMs).optional()
959
+ }).strict().optional()
960
+ }).strict();
961
+ var specShape = z2.object({
962
+ schemaVersion: z2.literal("1.0"),
963
+ id: z2.string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
964
+ templateFamily: z2.enum(PAIRED_TEMPLATE_FAMILIES),
965
+ meta: z2.object({
966
+ title: z2.string().min(1).max(160),
967
+ description: z2.string().max(500).optional(),
968
+ tags: z2.array(z2.string().max(40)).max(20).default([])
969
+ }).strict(),
970
+ target: z2.object({
971
+ aspect: z2.enum(["9:16", "4:5", "1:1"]),
972
+ fps: z2.number().int().positive().default(30),
973
+ durationMode: z2.enum(["auto", "fixed"]).default("auto"),
974
+ fixedDurationSec: z2.number().positive().max(PAIRED_LIMITS.totalDurationMs / 1e3).optional()
975
+ }).strict(),
976
+ style: z2.object({
977
+ theme: z2.enum(["default", "editorial-light", "editorial-dark", "clinical"]).default("default"),
978
+ variant: z2.string().default("default"),
979
+ safeAreaProfile: z2.enum(["baseline", "metaSafe"]).default("baseline"),
980
+ showSceneLabels: z2.boolean().default(false)
981
+ }).strict().default({}),
982
+ audio: z2.object({
983
+ mode: z2.enum(["auto", "narration", "music", "silent"]).default("auto"),
984
+ narrationText: z2.string().max(1e4).optional(),
985
+ narrationSrc: audioPath.optional(),
986
+ narrationTiming: narrationTimingSchema.optional(),
987
+ narrationVolume: z2.number().min(0).max(1).default(1),
988
+ musicSrc: audioPath.optional(),
989
+ musicVolume: z2.number().min(0).max(1).default(0.16),
990
+ ducking: z2.boolean().default(true)
991
+ }).strict().default({}),
992
+ assets: z2.object({
993
+ logoSrc: z2.string().optional(),
994
+ posterSrc: z2.string().optional()
995
+ }).strict().default({}),
996
+ scenes: z2.array(sceneSchema).min(1).max(PAIRED_LIMITS.scenes)
997
+ }).strict();
998
+ var DIMENSIONS = {
999
+ "9:16": { width: 1080, height: 1920 },
1000
+ "4:5": { width: 1080, height: 1350 },
1001
+ "1:1": { width: 1080, height: 1080 }
1002
+ };
1003
+ function pairedTimeline(spec) {
1004
+ const fps = spec.target.fps;
1005
+ const sceneMs = (scene) => spec.audio.narrationTiming?.segments.find(
1006
+ (segment) => segment.sceneId === scene.id
1007
+ )?.durationMs ?? scene.timing?.durationMs ?? 3e3;
1008
+ const totalMs = spec.scenes.reduce((sum, scene) => sum + sceneMs(scene), 0);
1009
+ const durationInFrames = spec.target.durationMode === "fixed" && spec.target.fixedDurationSec ? Math.max(1, Math.round(spec.target.fixedDurationSec * fps)) : Math.max(1, Math.round(totalMs / 1e3 * fps));
1010
+ let cursor = 0;
1011
+ const scenes = spec.scenes.map((scene, index) => {
1012
+ const frames = Math.max(1, Math.round(sceneMs(scene) / 1e3 * fps));
1013
+ const startFrame = cursor;
1014
+ cursor += frames;
1015
+ return {
1016
+ index,
1017
+ id: scene.id,
1018
+ kind: scene.kind,
1019
+ startFrame,
1020
+ durationInFrames: frames,
1021
+ visibleFrames: Math.max(
1022
+ 0,
1023
+ Math.min(frames, durationInFrames - startFrame)
1024
+ )
1025
+ };
1026
+ });
1027
+ return { fps, ...DIMENSIONS[spec.target.aspect], durationInFrames, scenes };
1028
+ }
1029
+ function stringValue(value) {
1030
+ return typeof value === "string" ? value.trim() : "";
1031
+ }
1032
+ function qualityReview(spec) {
1033
+ const errors = [];
1034
+ const notes = [];
1035
+ spec.scenes.forEach((scene, index) => {
1036
+ if (scene.kind === "custom")
1037
+ notes.push({
1038
+ level: "warning",
1039
+ code: "custom-renders-as-statement",
1040
+ message: `Scene ${index + 1} is custom. Both frameworks draw it as a statement card; no custom code runs.`
1041
+ });
1042
+ });
1043
+ const audio = spec.audio;
1044
+ const audible = audio.mode === "narration" || audio.mode === "music" || audio.mode === "auto" && Boolean(audio.narrationSrc || audio.musicSrc);
1045
+ if (audio.mode === "narration" && !audio.narrationSrc)
1046
+ errors.push({
1047
+ path: "audio.narrationSrc",
1048
+ code: "narration-source-missing",
1049
+ message: "audio.mode is narration, but audio.narrationSrc is missing. Add an existing audio file."
1050
+ });
1051
+ if (audio.mode === "music" && !audio.musicSrc)
1052
+ errors.push({
1053
+ path: "audio.musicSrc",
1054
+ code: "music-source-missing",
1055
+ message: "audio.mode is music, but audio.musicSrc is missing."
1056
+ });
1057
+ if (audio.narrationText && !audio.narrationSrc) {
1058
+ if (audio.mode === "silent")
1059
+ notes.push({
1060
+ level: "warning",
1061
+ code: "narration-text-not-rendered",
1062
+ message: "Narration text exists without narrationSrc. Written narration is not audible until audio is generated or attached."
1063
+ });
1064
+ else
1065
+ errors.push({
1066
+ path: "audio.narrationText",
1067
+ code: "narration-text-not-rendered",
1068
+ message: "Narration text exists without narrationSrc. Written narration is not audible until audio is generated or attached."
1069
+ });
1070
+ }
1071
+ if (audio.narrationTiming) {
1072
+ const ids = spec.scenes.map((scene) => scene.id);
1073
+ const timed = audio.narrationTiming.segments.map((item) => item.sceneId);
1074
+ if (ids.length !== timed.length || ids.some((id2, index) => timed[index] !== id2))
1075
+ errors.push({
1076
+ path: "audio.narrationTiming.segments",
1077
+ code: "narration-timing-scene-mismatch",
1078
+ message: "Narration timing must contain exactly one ordered segment for every scene."
1079
+ });
1080
+ }
1081
+ if (!audible)
1082
+ notes.push({
1083
+ level: "info",
1084
+ code: "intentional-silence",
1085
+ message: "No audible audio is configured. Set audio.mode to silent only when this is intentional."
1086
+ });
1087
+ if (spec.style.showSceneLabels)
1088
+ notes.push({
1089
+ level: "warning",
1090
+ code: "debug-labels-visible",
1091
+ message: "Scene-kind labels are visible. Keep showSceneLabels false for audience-facing renders."
1092
+ });
1093
+ spec.scenes.forEach((scene, index) => {
1094
+ const title2 = stringValue(scene.content.title) || stringValue(scene.content.line1);
1095
+ const label2 = stringValue(scene.content.label);
1096
+ const at = `scenes.${index}`;
1097
+ if (!title2)
1098
+ errors.push({
1099
+ path: `${at}.content.title`,
1100
+ code: "scene-title-missing",
1101
+ message: `Scene ${index + 1} (${scene.id}) has no title or line1.`
1102
+ });
1103
+ if (title2.length > 82)
1104
+ notes.push({
1105
+ level: "warning",
1106
+ code: "headline-too-long",
1107
+ message: `Scene ${index + 1} headline has ${title2.length} characters. Prefer 82 or fewer.`
1108
+ });
1109
+ if (title2.length >= 12 && title2 === title2.toUpperCase())
1110
+ notes.push({
1111
+ level: "warning",
1112
+ code: "all-caps-headline",
1113
+ message: `Scene ${index + 1} uses an all-caps headline. Use sentence case for editorial hierarchy.`
1114
+ });
1115
+ if (label2 && label2 === label2.toUpperCase())
1116
+ notes.push({
1117
+ level: "warning",
1118
+ code: "all-caps-label",
1119
+ message: `Scene ${index + 1} uses an all-caps label. Remove it or use sentence case only when it adds meaning.`
1120
+ });
1121
+ if (label2 && ["hero", "custom", "points", "cta"].includes(label2.toLowerCase()))
1122
+ errors.push({
1123
+ path: `${at}.content.label`,
1124
+ code: "implementation-label",
1125
+ message: `Scene ${index + 1} exposes the implementation label "${label2}". Remove it from audience-facing copy.`
1126
+ });
1127
+ const points = Array.isArray(scene.content.points) ? scene.content.points : [];
1128
+ if (points.length > 4)
1129
+ notes.push({
1130
+ level: "warning",
1131
+ code: "too-many-points",
1132
+ message: `Scene ${index + 1} has ${points.length} points. Prefer four or fewer.`
1133
+ });
1134
+ if (points.some((point2) => point2.length > 58))
1135
+ notes.push({
1136
+ level: "warning",
1137
+ code: "point-too-long",
1138
+ message: `Scene ${index + 1} contains a point longer than 58 characters.`
1139
+ });
1140
+ });
1141
+ const kinds = new Set(spec.scenes.map((scene) => scene.kind));
1142
+ if (spec.scenes.length >= 4 && kinds.size < 3)
1143
+ notes.push({
1144
+ level: "warning",
1145
+ code: "weak-scene-differentiation",
1146
+ message: "Four or more scenes use fewer than three layout kinds. Add visual structure instead of repeating text slides."
1147
+ });
1148
+ return { errors, notes };
1149
+ }
1150
+ function zodIssues(error, prefix = "") {
1151
+ return error.issues.map((issue) => ({
1152
+ path: [prefix, ...issue.path.map(String)].filter(Boolean).join("."),
1153
+ code: issue.code === "unrecognized_keys" ? "unsupported-field" : "invalid-videospec",
1154
+ message: issue.code === "unrecognized_keys" ? `${issue.message}. Neither paired renderer reads these fields; remove them rather than expecting them to render.` : issue.message
1155
+ }));
1156
+ }
1157
+ function validatePairedVideoSpec(raw) {
1158
+ const parsed = specShape.safeParse(raw);
1159
+ if (!parsed.success) return { ok: false, issues: zodIssues(parsed.error) };
1160
+ const shape2 = parsed.data;
1161
+ const issues = [];
1162
+ const reject = (path, code, message) => issues.push({ path, code, message });
1163
+ if (shape2.target.fps > PAIRED_FPS.max)
1164
+ reject(
1165
+ "target.fps",
1166
+ "unsupported-fps",
1167
+ `Paired templates render at whole frame rates from ${PAIRED_FPS.min} to ${PAIRED_FPS.max} fps, the range the HyperFrames renderer accepts.`
1168
+ );
1169
+ if (shape2.target.durationMode === "fixed" && !shape2.target.fixedDurationSec)
1170
+ reject(
1171
+ "target.fixedDurationSec",
1172
+ "fixed-duration-missing",
1173
+ "durationMode fixed needs fixedDurationSec; the public renderer would otherwise fall back to automatic duration."
1174
+ );
1175
+ if (shape2.target.durationMode === "auto" && shape2.target.fixedDurationSec)
1176
+ reject(
1177
+ "target.fixedDurationSec",
1178
+ "fixed-duration-unused",
1179
+ "fixedDurationSec is ignored unless durationMode is fixed. Remove it or set durationMode to fixed."
1180
+ );
1181
+ if (shape2.style.variant !== "default")
1182
+ reject(
1183
+ "style.variant",
1184
+ "unsupported-style-variant",
1185
+ "Only the default variant exists. The public renderer ignores other variant values."
1186
+ );
1187
+ if (shape2.style.safeAreaProfile !== "baseline")
1188
+ reject(
1189
+ "style.safeAreaProfile",
1190
+ "unsupported-safe-area",
1191
+ "Neither renderer applies a metaSafe layout; it renders exactly like baseline. Set baseline so the document does not promise safe-area handling."
1192
+ );
1193
+ for (const key of ["logoSrc", "posterSrc"])
1194
+ if (shape2.assets[key] !== void 0)
1195
+ reject(
1196
+ `assets.${key}`,
1197
+ "unsupported-asset",
1198
+ `assets.${key} is not rendered by either framework. Remove it.`
1199
+ );
1200
+ const narrationTiming = shape2.audio.narrationTiming;
1201
+ if (narrationTiming) {
1202
+ let previousEnd = 0;
1203
+ const timedIds = /* @__PURE__ */ new Set();
1204
+ narrationTiming.segments.forEach((segment, index) => {
1205
+ const at = `audio.narrationTiming.segments.${index}`;
1206
+ if (timedIds.has(segment.sceneId))
1207
+ reject(
1208
+ `${at}.sceneId`,
1209
+ "invalid-videospec",
1210
+ "Narration timing scene IDs must be unique."
1211
+ );
1212
+ timedIds.add(segment.sceneId);
1213
+ if (segment.startMs !== previousEnd)
1214
+ reject(
1215
+ `${at}.startMs`,
1216
+ "invalid-videospec",
1217
+ "Narration timing segments must be contiguous."
1218
+ );
1219
+ if (segment.durationMs !== segment.endMs - segment.startMs)
1220
+ reject(
1221
+ `${at}.durationMs`,
1222
+ "invalid-videospec",
1223
+ "Narration timing duration must equal endMs minus startMs."
1224
+ );
1225
+ previousEnd = segment.endMs;
1226
+ });
1227
+ if (previousEnd !== narrationTiming.durationMs)
1228
+ reject(
1229
+ "audio.narrationTiming.durationMs",
1230
+ "invalid-videospec",
1231
+ "Narration timing duration must end with the final segment."
1232
+ );
1233
+ }
1234
+ if (shape2.audio.mode === "silent" && (shape2.audio.narrationSrc || shape2.audio.musicSrc))
1235
+ reject(
1236
+ "audio.mode",
1237
+ "audio-mode-conflict",
1238
+ "audio.mode is silent, but an audio source is set and would still play. Remove the source or change the mode."
1239
+ );
1240
+ const ids = /* @__PURE__ */ new Set();
1241
+ const scenes = [];
1242
+ shape2.scenes.forEach((scene, index) => {
1243
+ const at = `scenes.${index}`;
1244
+ if (ids.has(scene.id))
1245
+ reject(`${at}.id`, "duplicate-scene-id", "Scene IDs must be unique.");
1246
+ ids.add(scene.id);
1247
+ if (!PAIRED_SCENE_KINDS.includes(scene.kind)) {
1248
+ reject(
1249
+ `${at}.kind`,
1250
+ "invalid-videospec",
1251
+ `Unknown scene kind ${JSON.stringify(scene.kind)}.`
1252
+ );
1253
+ return;
1254
+ }
1255
+ const kind = scene.kind;
1256
+ const content = contentSchemas[kind].safeParse(scene.content);
1257
+ if (!content.success) {
1258
+ issues.push(...zodIssues(content.error, `${at}.content`));
1259
+ return;
1260
+ }
1261
+ const value = content.data;
1262
+ for (const [first, second] of [
1263
+ ["title", "line1"],
1264
+ ["subtitle", "line2"]
1265
+ ])
1266
+ if (value[first] !== void 0 && value[second] !== void 0)
1267
+ reject(
1268
+ `${at}.content.${second}`,
1269
+ "ambiguous-copy-field",
1270
+ `Supply ${first} or ${second}, not both; the renderer shows only ${first}.`
1271
+ );
1272
+ if (kind === "equation") {
1273
+ const blocks = value.latexBlocks;
1274
+ if (new Set(blocks).size !== blocks.length)
1275
+ reject(
1276
+ `${at}.content.latexBlocks`,
1277
+ "duplicate-equation",
1278
+ "Equation blocks must be unique."
1279
+ );
1280
+ }
1281
+ scenes.push({ ...scene, kind, content: value });
1282
+ });
1283
+ if (issues.length) return { ok: false, issues };
1284
+ const spec = { ...shape2, scenes };
1285
+ const quality = qualityReview(spec);
1286
+ issues.push(...quality.errors);
1287
+ const timeline = pairedTimeline(spec);
1288
+ const sceneFrames = timeline.scenes.reduce(
1289
+ (sum, scene) => sum + scene.durationInFrames,
1290
+ 0
1291
+ );
1292
+ if (timeline.durationInFrames / timeline.fps > PAIRED_LIMITS.totalDurationMs / 1e3)
1293
+ reject(
1294
+ "scenes",
1295
+ "duration-too-long",
1296
+ "Paired templates are limited to 20 minutes."
1297
+ );
1298
+ if (spec.target.durationMode === "fixed" && timeline.durationInFrames < sceneFrames)
1299
+ reject(
1300
+ "target.fixedDurationSec",
1301
+ "fixed-duration-truncates",
1302
+ `fixedDurationSec gives ${timeline.durationInFrames} frames but the scenes need ${sceneFrames}; later scenes would be cut off.`
1303
+ );
1304
+ const hidden = timeline.scenes.find((scene) => scene.visibleFrames === 0);
1305
+ if (hidden)
1306
+ reject(
1307
+ `scenes.${hidden.index}.timing`,
1308
+ "scene-not-visible",
1309
+ "Frame rounding leaves this scene no visible frames. Lengthen the scene durations."
1310
+ );
1311
+ if (issues.length) return { ok: false, issues };
1312
+ return { ok: true, spec, timeline, qualityNotes: quality.notes };
1313
+ }
1314
+
1315
+ // src/paired-templates/catalogue.ts
1316
+ var FRAMEWORKS = ["remotion", "hyperframes"];
1317
+ var videoSpecContract = {
1318
+ id: PAIRED_VIDEOSPEC_CONTRACT,
1319
+ validate(raw) {
1320
+ const result3 = validatePairedVideoSpec(raw);
1321
+ if (!result3.ok) return result3;
1322
+ const { spec, timeline, qualityNotes } = result3;
1323
+ return {
1324
+ ok: true,
1325
+ document: spec,
1326
+ timeline,
1327
+ qualityNotes,
1328
+ realise: (framework3) => framework3 === "remotion" ? {
1329
+ files: remotionVideoSpecFiles(spec, timeline),
1330
+ commands: remotionVideoSpecCommands(spec),
1331
+ runtime: { ...REMOTION_TEMPLATES }
1332
+ } : {
1333
+ files: hyperframesVideoSpecFiles(spec, timeline),
1334
+ commands: [
1335
+ "npm install",
1336
+ "npm run setup",
1337
+ "npm run check",
1338
+ "npm run preview",
1339
+ "npm run render"
1340
+ ],
1341
+ runtime: { ...HYPERFRAMES_RUNTIME }
1342
+ }
1343
+ };
1344
+ }
1345
+ };
1346
+ var familyNames = {
1347
+ "qa-ad": "Question and answer ad",
1348
+ "proof-walkthrough": "Proof walkthrough",
1349
+ "announcement-brief": "Announcement brief",
1350
+ "social-remix": "Social remix",
1351
+ "finance-brief": "Data and finance brief"
1352
+ };
1353
+ var PAIRED_CONTRACTS = {
1354
+ [videoSpecContract.id]: videoSpecContract
1355
+ };
1356
+ var PAIRED_FAMILIES = PAIRED_TEMPLATE_FAMILIES.map((id2) => ({
1357
+ id: id2,
1358
+ name: familyNames[id2],
1359
+ contract: PAIRED_VIDEOSPEC_CONTRACT,
1360
+ frameworks: FRAMEWORKS
1361
+ }));
1362
+ function contractForFamily(templateFamily) {
1363
+ const family = PAIRED_FAMILIES.find((item) => item.id === templateFamily);
1364
+ return family ? PAIRED_CONTRACTS[family.contract] : void 0;
1365
+ }
1366
+
1367
+ // src/paired-templates/prepare-video-template.ts
1368
+ function pairedTemplatesEnabled(env = process.env) {
1369
+ return env.INSTAVAR_PAIRED_TEMPLATES !== "0";
1370
+ }
1371
+ var PAIRED_TEMPLATE_CAPABILITY = {
1372
+ tool: "prepare_video_template",
1373
+ contract: PAIRED_VIDEOSPEC_CONTRACT,
1374
+ frameworks: FRAMEWORKS,
1375
+ families: PAIRED_FAMILIES.map((family) => family.id),
1376
+ fps: PAIRED_FPS,
1377
+ aspects: ["9:16", "4:5", "1:1"],
1378
+ realisations: {
1379
+ remotion: `${REMOTION_TEMPLATES.repository} at ${REMOTION_TEMPLATES.commit}`,
1380
+ hyperframes: `hyperframes ${HYPERFRAMES_RUNTIME.hyperframes} source generated from the same VideoSpec`
1381
+ },
1382
+ scope: "One VideoSpec document, realised in either framework. Returns local source and commands; does not save, upload or render. Fields neither renderer honours are rejected, not dropped."
1383
+ };
1384
+ var PAIRED_TEMPLATE_INSTRUCTIONS = "For a VideoSpec template in Remotion or HyperFrames, use prepare_video_template with the VideoSpec. Never infer a framework from creative wording; omit framework unless the user chose one or said no preference, and ask the user on needs-selection. Continue with the returned project: edit project.spec, then call again to regenerate or to switch frameworks. A rejected field is unsupported in both frameworks; fix it rather than dropping it. The tool returns local source and commands; it does not render, save or upload.";
1385
+ var framework2 = z3.enum(["remotion", "hyperframes"]);
1386
+ var prepareVideoTemplateInput = {
1387
+ framework: z3.enum(["remotion", "hyperframes", "no-preference"]).optional().describe(
1388
+ "Only supply an explicit user choice. Omit for an ambiguous request or to inherit the existing project framework."
1389
+ ),
1390
+ spec: z3.record(z3.unknown()).optional().describe("A VideoSpec 1.0 document for a new project."),
1391
+ project: z3.object({
1392
+ contract: z3.literal(PAIRED_VIDEOSPEC_CONTRACT),
1393
+ framework: framework2,
1394
+ spec: z3.record(z3.unknown())
1395
+ }).strict().optional().describe(
1396
+ "The latest project returned by this tool, with any edits made to project.spec. Caller-held, not a saved hosted project."
1397
+ )
1398
+ };
1399
+ var inputSchema2 = z3.object(prepareVideoTemplateInput).strict();
1400
+ function prepareVideoTemplate(raw) {
1401
+ const input = inputSchema2.parse(raw);
1402
+ if (input.spec && input.project)
1403
+ throw new Error(
1404
+ "Supply spec for a new project or project to continue one, not both."
1405
+ );
1406
+ const spec = input.project?.spec ?? input.spec;
1407
+ if (!spec)
1408
+ return {
1409
+ isError: false,
1410
+ result: {
1411
+ status: "needs-spec",
1412
+ message: "Supply a VideoSpec 1.0 document. Use scaffold_video_spec for a starting point."
1413
+ }
1414
+ };
1415
+ const contract = contractForFamily(spec.templateFamily);
1416
+ if (!contract)
1417
+ return {
1418
+ isError: true,
1419
+ result: {
1420
+ status: "rejected",
1421
+ issues: [
1422
+ {
1423
+ path: "templateFamily",
1424
+ code: "unsupported-family",
1425
+ message: `Paired templates cover ${PAIRED_FAMILIES.map(
1426
+ (family) => family.id
1427
+ ).join(", ")}.`
1428
+ }
1429
+ ]
1430
+ }
1431
+ };
1432
+ const validated = contract.validate(spec);
1433
+ if (!validated.ok)
1434
+ return {
1435
+ isError: true,
1436
+ result: {
1437
+ status: "rejected",
1438
+ contract: contract.id,
1439
+ issues: validated.issues,
1440
+ message: "No source was generated. These fields are unsupported in both frameworks; change them and call again."
1441
+ }
1442
+ };
1443
+ const selected = input.framework === "remotion" || input.framework === "hyperframes" ? input.framework : input.project?.framework ?? (input.framework === "no-preference" ? "remotion" : void 0);
1444
+ if (!selected)
1445
+ return {
1446
+ isError: false,
1447
+ result: {
1448
+ status: "needs-selection",
1449
+ options: ["remotion", "hyperframes", "no-preference"],
1450
+ message: "Which framework would you like: Remotion, HyperFrames, or no preference? No source was generated."
1451
+ }
1452
+ };
1453
+ const realisation = validated.realise(selected);
1454
+ return {
1455
+ isError: false,
1456
+ result: {
1457
+ status: "ready",
1458
+ reason: input.framework && input.framework !== "no-preference" ? "explicit" : input.project ? "existing-project" : "visible-default",
1459
+ project: {
1460
+ contract: contract.id,
1461
+ framework: selected,
1462
+ spec: validated.document
1463
+ },
1464
+ timeline: validated.timeline,
1465
+ qualityNotes: validated.qualityNotes,
1466
+ runtime: realisation.runtime,
1467
+ files: realisation.files,
1468
+ commands: realisation.commands,
1469
+ instructions: "Save these files in a new directory and place each media file at the public/ path the spec names. The same preflight checks media for both frameworks. Equation blocks are shown as source text, not typeset. Keep project.spec as the content source of truth: regenerating or switching frameworks keeps only what the spec holds, not edits made to generated files. This tool has not written files, saved a hosted project or rendered video."
1470
+ }
1471
+ };
1472
+ }
1473
+ function registerPairedTemplates(server) {
1474
+ server.registerTool(
1475
+ "prepare_video_template",
1476
+ {
1477
+ title: "Prepare a template video in Remotion or HyperFrames",
1478
+ description: "Validate one VideoSpec against the paired template contract and return local source for the chosen framework, or switch an existing project's framework. " + PAIRED_TEMPLATE_INSTRUCTIONS,
1479
+ inputSchema: prepareVideoTemplateInput,
1480
+ annotations: {
1481
+ title: "Prepare video template",
1482
+ readOnlyHint: true,
1483
+ destructiveHint: false,
1484
+ openWorldHint: false
1485
+ },
1486
+ _meta: { securitySchemes: [{ type: "noauth" }] }
1487
+ },
1488
+ async (args) => {
1489
+ try {
1490
+ const { isError, result: result3 } = prepareVideoTemplate(args);
1491
+ return {
1492
+ ...isError ? { isError: true } : {},
1493
+ structuredContent: result3,
1494
+ content: [{ type: "text", text: JSON.stringify(result3) }]
1495
+ };
1496
+ } catch (error) {
1497
+ return {
1498
+ isError: true,
1499
+ content: [
1500
+ {
1501
+ type: "text",
1502
+ text: error instanceof Error ? error.message : "Invalid template input"
1503
+ }
1504
+ ]
1505
+ };
1506
+ }
1507
+ }
1508
+ );
1509
+ }
1510
+
275
1511
  // src/index.ts
276
1512
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
277
1513
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
278
1514
 
279
1515
  // src/creative-guides.ts
280
- import { z as z2 } from "zod";
1516
+ import { z as z4 } from "zod";
281
1517
 
282
1518
  // src/creative-guides.generated.ts
283
1519
  var CREATIVE_GUIDES = [
@@ -308,16 +1544,16 @@ var CREATIVE_GUIDES = [
308
1544
  ];
309
1545
 
310
1546
  // src/creative-guides.ts
311
- var creativeGuideIdSchema = z2.enum([
1547
+ var creativeGuideIdSchema = z4.enum([
312
1548
  "visual-copy",
313
1549
  "carousel-stories",
314
1550
  "visual-design",
315
1551
  "human-review"
316
1552
  ]);
317
1553
  var CREATIVE_GUIDE_INDEX = CREATIVE_GUIDES.map(
318
- ({ id: id2, title, uri }) => ({
1554
+ ({ id: id2, title: title2, uri }) => ({
319
1555
  id: id2,
320
- title,
1556
+ title: title2,
321
1557
  uri
322
1558
  })
323
1559
  );
@@ -338,83 +1574,514 @@ function registerCreativeGuides(server) {
338
1574
  })
339
1575
  );
340
1576
  }
341
- server.registerTool(
342
- "get_creative_guide",
343
- {
344
- title: "Get a visual communication guide",
345
- description: "Read practical guidance before drafting concise plain or poetic copy, choosing carousel stories, designing visuals or recording human feedback. Returns guidance for the calling assistant to apply, not generated copy or saved feedback. Omit guideId to list guides.",
346
- inputSchema: { guideId: creativeGuideIdSchema.optional() },
347
- annotations: {
348
- readOnlyHint: true,
349
- destructiveHint: false,
350
- openWorldHint: false
351
- },
352
- _meta: { securitySchemes: [{ type: "noauth" }] }
353
- },
354
- async ({ guideId }) => {
355
- const guide = CREATIVE_GUIDES.find((entry) => entry.id === guideId);
356
- return {
357
- structuredContent: guide ? { guide } : { guides: CREATIVE_GUIDE_INDEX },
358
- content: [
359
- {
360
- type: "text",
361
- text: guide ? guide.text : CREATIVE_GUIDE_INDEX.map(
362
- (entry) => `${entry.id}: ${entry.title} (${entry.uri})`
363
- ).join("\n")
1577
+ server.registerTool(
1578
+ "get_creative_guide",
1579
+ {
1580
+ title: "Get a visual communication guide",
1581
+ description: "Read practical guidance before drafting concise plain or poetic copy, choosing carousel stories, designing visuals or recording human feedback. Returns guidance for the calling assistant to apply, not generated copy or saved feedback. Omit guideId to list guides.",
1582
+ inputSchema: {
1583
+ guideId: creativeGuideIdSchema.optional().describe("Guide to read. Omit to list the guides.")
1584
+ },
1585
+ annotations: {
1586
+ title: "Get creative guide",
1587
+ readOnlyHint: true,
1588
+ destructiveHint: false,
1589
+ openWorldHint: false
1590
+ },
1591
+ _meta: { securitySchemes: [{ type: "noauth" }] }
1592
+ },
1593
+ async ({ guideId }) => {
1594
+ const guide = CREATIVE_GUIDES.find((entry) => entry.id === guideId);
1595
+ return {
1596
+ structuredContent: guide ? { guide } : { guides: CREATIVE_GUIDE_INDEX },
1597
+ content: [
1598
+ {
1599
+ type: "text",
1600
+ text: guide ? guide.text : CREATIVE_GUIDE_INDEX.map(
1601
+ (entry) => `${entry.id}: ${entry.title} (${entry.uri})`
1602
+ ).join("\n")
1603
+ }
1604
+ ]
1605
+ };
1606
+ }
1607
+ );
1608
+ }
1609
+
1610
+ // src/public-catalogue.ts
1611
+ import { z as z5 } from "zod";
1612
+
1613
+ // src/carousel/archetypes.ts
1614
+ function frame(slides, content, visualStyle = "editorial") {
1615
+ return {
1616
+ slides: slides.map((slide, index) => ({
1617
+ ...slide,
1618
+ image: content.images?.[index],
1619
+ visualRequest: content.visualRequests?.[index]
1620
+ })),
1621
+ handle: content.handle,
1622
+ showPageNumber: true,
1623
+ visualStyle
1624
+ };
1625
+ }
1626
+ var listicle = {
1627
+ id: "listicle",
1628
+ label: "Listicle",
1629
+ blurb: "Hook, a numbered rundown on one slide, then the payoff.",
1630
+ build: (c) => frame(
1631
+ [
1632
+ {
1633
+ kind: "cover",
1634
+ title: c.hook,
1635
+ accent: c.accent,
1636
+ subtitle: c.subtitle
1637
+ },
1638
+ {
1639
+ kind: "list",
1640
+ title: c.listTitle ?? "The rundown",
1641
+ items: c.points
1642
+ },
1643
+ { kind: "takeaway", title: c.payoff, accent: c.accent, cta: c.cta }
1644
+ ],
1645
+ c
1646
+ )
1647
+ };
1648
+ var manifesto = {
1649
+ id: "manifesto",
1650
+ label: "Manifesto",
1651
+ blurb: "Hook, then one punchy idea per slide, building to the payoff.",
1652
+ build: (c) => frame(
1653
+ [
1654
+ {
1655
+ kind: "cover",
1656
+ title: c.hook,
1657
+ accent: c.accent,
1658
+ subtitle: c.subtitle
1659
+ },
1660
+ ...c.points.map(
1661
+ (p) => ({
1662
+ kind: "statement",
1663
+ statement: p
1664
+ })
1665
+ ),
1666
+ { kind: "takeaway", title: c.payoff, cta: c.cta }
1667
+ ],
1668
+ c
1669
+ )
1670
+ };
1671
+ var beforeAfter = {
1672
+ id: "before-after",
1673
+ label: "Before / After",
1674
+ blurb: "Hook, the problem, the contrast, then the payoff.",
1675
+ build: (c) => {
1676
+ const problem = c.points[0] ?? "";
1677
+ const contrast = c.points[c.points.length - 1] ?? problem;
1678
+ return frame(
1679
+ [
1680
+ {
1681
+ kind: "cover",
1682
+ title: c.hook,
1683
+ accent: c.accent,
1684
+ subtitle: c.subtitle
1685
+ },
1686
+ { kind: "statement", statement: problem, footnote: "The status quo" },
1687
+ { kind: "statement", statement: contrast, footnote: "The shift" },
1688
+ { kind: "takeaway", title: c.payoff, accent: c.accent, cta: c.cta }
1689
+ ],
1690
+ c
1691
+ );
1692
+ }
1693
+ };
1694
+ var valueFirstReveal = {
1695
+ id: "value-first-reveal",
1696
+ label: "Value-First Reveal",
1697
+ blurb: "Three useful beats first, then proof and a restrained product reveal.",
1698
+ build: (c) => {
1699
+ const beats = [0, 1, 2].map(
1700
+ (index) => c.points[index] ?? c.points.at(-1) ?? c.payoff
1701
+ );
1702
+ const bridge = c.bridge ?? "Here is what makes this repeatable.";
1703
+ const proof = c.productProof ?? c.payoff;
1704
+ return frame(
1705
+ [
1706
+ {
1707
+ kind: "cover",
1708
+ title: c.hook,
1709
+ accent: c.accent,
1710
+ subtitle: c.subtitle
1711
+ },
1712
+ { kind: "statement", statement: beats[0], footnote: "01 \xB7 The value" },
1713
+ { kind: "statement", statement: beats[1], footnote: "02 \xB7 The value" },
1714
+ { kind: "statement", statement: beats[2], footnote: "03 \xB7 The value" },
1715
+ {
1716
+ kind: "statement",
1717
+ statement: bridge,
1718
+ footnote: `Proof \xB7 ${proof}`
1719
+ },
1720
+ {
1721
+ kind: "takeaway",
1722
+ title: c.productReveal ?? c.payoff,
1723
+ cta: [c.cta, c.disclosure].filter(Boolean).join(" \xB7 ") || void 0
1724
+ }
1725
+ ],
1726
+ c
1727
+ );
1728
+ }
1729
+ };
1730
+ var CAROUSEL_ARCHETYPES = [
1731
+ listicle,
1732
+ manifesto,
1733
+ beforeAfter,
1734
+ valueFirstReveal
1735
+ ];
1736
+ function getArchetype(id2) {
1737
+ return CAROUSEL_ARCHETYPES.find((a) => a.id === id2);
1738
+ }
1739
+ var DEFAULT_CAROUSEL_CONTENT = {
1740
+ hook: "Just say the word.",
1741
+ accent: "the word",
1742
+ subtitle: "How one sentence becomes a finished video.",
1743
+ listTitle: "What you skip",
1744
+ points: [
1745
+ "Storyboarding every shot by hand",
1746
+ "Re-recording voiceover for one wording change",
1747
+ "Fighting a timeline editor for an hour"
1748
+ ],
1749
+ payoff: "Describe it. We render it.",
1750
+ bridge: "The workflow gets easier when one brief drives every production step.",
1751
+ productProof: "One approved brief, one repeatable render pipeline.",
1752
+ productReveal: "Instavar turns the brief into the first draft.",
1753
+ images: [
1754
+ "2025_video_hooks_hero.v20250811.avif",
1755
+ "ai_content_ops_system.v20250811.avif",
1756
+ "short_form_funnel_blueprint.v20250811.avif",
1757
+ "server_side_tracking_playbook.v20250811.avif",
1758
+ "retention_loops_post_purchase_funnel.v20250811.avif",
1759
+ "true_roas_incrementality_first.v20250811.avif"
1760
+ ].map((file, index) => ({
1761
+ src: `https://thumbnails.instavar.com/${file}`,
1762
+ alt: `Instavar AI-generated carousel sample image ${index + 1}`,
1763
+ provenance: "ai-generated"
1764
+ })),
1765
+ cta: "Start at instavar.com. Your first draft is one sentence away.",
1766
+ handle: "@instavar"
1767
+ };
1768
+
1769
+ // src/carousel/aspect-contract.ts
1770
+ var CAROUSEL_ASPECTS = ["4:5", "3:4", "1:1", "9:16"];
1771
+ function isCarouselAspect(value) {
1772
+ return CAROUSEL_ASPECTS.some((aspect) => aspect === value);
1773
+ }
1774
+
1775
+ // src/carousel/deck-contract.ts
1776
+ var IMAGE_PROVENANCE = /* @__PURE__ */ new Set([
1777
+ "user-owned",
1778
+ "licensed-stock",
1779
+ "ai-generated"
1780
+ ]);
1781
+ var VISUAL_KINDS = /* @__PURE__ */ new Set([
1782
+ "photography",
1783
+ "illustration",
1784
+ "diagram",
1785
+ "background",
1786
+ "visual-metaphor"
1787
+ ]);
1788
+ var EVIDENCE_LABELS = /* @__PURE__ */ new Set([
1789
+ "AI-generated visual",
1790
+ "Concept illustration"
1791
+ ]);
1792
+ var INPUT_IMAGE_PROVENANCE = /* @__PURE__ */ new Set(["user-owned", "licensed-stock"]);
1793
+ var CAROUSEL_DECK_LIMITS = {
1794
+ slides: 12,
1795
+ handle: 40,
1796
+ imageSrc: 2048,
1797
+ imageAlt: 240,
1798
+ visualRequest: { id: 120, prompt: 1200, direction: 500, inputs: 4 },
1799
+ cover: { title: 100, accent: 100, subtitle: 160 },
1800
+ statement: { statement: 220, accent: 220, footnote: 100 },
1801
+ list: { title: 80, accent: 80, items: 5, item: 120 },
1802
+ takeaway: { title: 120, accent: 120, cta: 140 }
1803
+ };
1804
+ function isNonEmptyString(value) {
1805
+ return typeof value === "string" && value.trim().length > 0;
1806
+ }
1807
+ function textLength(value) {
1808
+ return Array.from(value.trim()).length;
1809
+ }
1810
+ function validateText(value, path, maxLength, issues, options = {}) {
1811
+ if (value === void 0 && options.optional) return;
1812
+ if (!isNonEmptyString(value)) {
1813
+ issues.push(`${path} is required`);
1814
+ return;
1815
+ }
1816
+ if (textLength(value) > maxLength) {
1817
+ issues.push(`${path} must be at most ${maxLength} characters`);
1818
+ }
1819
+ }
1820
+ function validateOptionalImage(value, path, issues) {
1821
+ if (value === void 0) return;
1822
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1823
+ issues.push(`${path} must be an object`);
1824
+ return;
1825
+ }
1826
+ const image = value;
1827
+ validateText(image.src, `${path}.src`, CAROUSEL_DECK_LIMITS.imageSrc, issues);
1828
+ validateText(image.alt, `${path}.alt`, CAROUSEL_DECK_LIMITS.imageAlt, issues);
1829
+ if (!isNonEmptyString(image.provenance) || !IMAGE_PROVENANCE.has(image.provenance)) {
1830
+ issues.push(`${path}.provenance is invalid`);
1831
+ }
1832
+ if (image.generation !== void 0) {
1833
+ const generation = image.generation;
1834
+ if (!generation || typeof generation !== "object" || Array.isArray(generation)) {
1835
+ issues.push(`${path}.generation must be an object`);
1836
+ } else {
1837
+ const record2 = generation;
1838
+ for (const field of ["provider", "model", "generatedAt", "promptHash"])
1839
+ validateText(record2[field], `${path}.generation.${field}`, 200, issues);
1840
+ if (isNonEmptyString(record2.generatedAt) && Number.isNaN(Date.parse(record2.generatedAt))) {
1841
+ issues.push(`${path}.generation.generatedAt must be an ISO timestamp`);
1842
+ }
1843
+ validateText(
1844
+ record2.outputHash,
1845
+ `${path}.generation.outputHash`,
1846
+ 200,
1847
+ issues,
1848
+ {
1849
+ optional: true
1850
+ }
1851
+ );
1852
+ }
1853
+ }
1854
+ }
1855
+ function validateOptionalVisualRequest(value, path, issues) {
1856
+ if (value === void 0) return;
1857
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1858
+ issues.push(`${path} must be an object`);
1859
+ return;
1860
+ }
1861
+ const request = value;
1862
+ validateText(
1863
+ request.id,
1864
+ `${path}.id`,
1865
+ CAROUSEL_DECK_LIMITS.visualRequest.id,
1866
+ issues
1867
+ );
1868
+ validateText(
1869
+ request.prompt,
1870
+ `${path}.prompt`,
1871
+ CAROUSEL_DECK_LIMITS.visualRequest.prompt,
1872
+ issues
1873
+ );
1874
+ validateText(
1875
+ request.direction,
1876
+ `${path}.direction`,
1877
+ CAROUSEL_DECK_LIMITS.visualRequest.direction,
1878
+ issues
1879
+ );
1880
+ validateText(
1881
+ request.alt,
1882
+ `${path}.alt`,
1883
+ CAROUSEL_DECK_LIMITS.imageAlt,
1884
+ issues
1885
+ );
1886
+ if (!isNonEmptyString(request.kind) || !VISUAL_KINDS.has(request.kind)) {
1887
+ issues.push(`${path}.kind is invalid`);
1888
+ }
1889
+ if (!isNonEmptyString(request.evidenceLabel) || !EVIDENCE_LABELS.has(request.evidenceLabel)) {
1890
+ issues.push(`${path}.evidenceLabel is invalid`);
1891
+ }
1892
+ if (request.inputImages !== void 0) {
1893
+ if (!Array.isArray(request.inputImages)) {
1894
+ issues.push(`${path}.inputImages must be an array`);
1895
+ } else {
1896
+ if (request.inputImages.length > CAROUSEL_DECK_LIMITS.visualRequest.inputs) {
1897
+ issues.push(
1898
+ `${path}.inputImages must contain at most ${CAROUSEL_DECK_LIMITS.visualRequest.inputs} items`
1899
+ );
1900
+ }
1901
+ request.inputImages.forEach((candidate, index) => {
1902
+ const inputPath = `${path}.inputImages[${index}]`;
1903
+ if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
1904
+ issues.push(`${inputPath} must be an object`);
1905
+ return;
1906
+ }
1907
+ const input = candidate;
1908
+ validateText(
1909
+ input.src,
1910
+ `${inputPath}.src`,
1911
+ CAROUSEL_DECK_LIMITS.imageSrc,
1912
+ issues
1913
+ );
1914
+ if (!isNonEmptyString(input.provenance) || !INPUT_IMAGE_PROVENANCE.has(input.provenance)) {
1915
+ issues.push(`${inputPath}.provenance is invalid`);
1916
+ }
1917
+ });
1918
+ }
1919
+ }
1920
+ }
1921
+ function validateCarouselDeck(value) {
1922
+ const issues = [];
1923
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
1924
+ return { ok: false, issues: ["deck must be an object"] };
1925
+ }
1926
+ const deck = value;
1927
+ if (deck.aspect !== void 0 && !isCarouselAspect(deck.aspect)) {
1928
+ issues.push("deck.aspect is invalid");
1929
+ }
1930
+ if (!Array.isArray(deck.slides) || deck.slides.length === 0) {
1931
+ issues.push("deck.slides must contain at least one slide");
1932
+ return { ok: false, issues };
1933
+ }
1934
+ if (deck.slides.length > CAROUSEL_DECK_LIMITS.slides) {
1935
+ issues.push(
1936
+ `deck.slides must contain at most ${CAROUSEL_DECK_LIMITS.slides} slides`
1937
+ );
1938
+ }
1939
+ validateText(
1940
+ deck.handle,
1941
+ "deck.handle",
1942
+ CAROUSEL_DECK_LIMITS.handle,
1943
+ issues,
1944
+ { optional: true }
1945
+ );
1946
+ if (deck.showPageNumber !== void 0 && typeof deck.showPageNumber !== "boolean") {
1947
+ issues.push("deck.showPageNumber must be a boolean");
1948
+ }
1949
+ if (deck.visualStyle !== void 0 && deck.visualStyle !== "editorial" && deck.visualStyle !== "native-photo") {
1950
+ issues.push("deck.visualStyle is invalid");
1951
+ }
1952
+ const visualRequestIds = /* @__PURE__ */ new Set();
1953
+ deck.slides.forEach((value2, index) => {
1954
+ const path = `deck.slides[${index}]`;
1955
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) {
1956
+ issues.push(`${path} must be an object`);
1957
+ return;
1958
+ }
1959
+ const slide = value2;
1960
+ switch (slide.kind) {
1961
+ case "cover":
1962
+ validateText(
1963
+ slide.title,
1964
+ `${path}.title`,
1965
+ CAROUSEL_DECK_LIMITS.cover.title,
1966
+ issues
1967
+ );
1968
+ validateText(
1969
+ slide.accent,
1970
+ `${path}.accent`,
1971
+ CAROUSEL_DECK_LIMITS.cover.accent,
1972
+ issues,
1973
+ { optional: true }
1974
+ );
1975
+ validateText(
1976
+ slide.subtitle,
1977
+ `${path}.subtitle`,
1978
+ CAROUSEL_DECK_LIMITS.cover.subtitle,
1979
+ issues,
1980
+ { optional: true }
1981
+ );
1982
+ break;
1983
+ case "statement":
1984
+ validateText(
1985
+ slide.statement,
1986
+ `${path}.statement`,
1987
+ CAROUSEL_DECK_LIMITS.statement.statement,
1988
+ issues
1989
+ );
1990
+ validateText(
1991
+ slide.accent,
1992
+ `${path}.accent`,
1993
+ CAROUSEL_DECK_LIMITS.statement.accent,
1994
+ issues,
1995
+ { optional: true }
1996
+ );
1997
+ validateText(
1998
+ slide.footnote,
1999
+ `${path}.footnote`,
2000
+ CAROUSEL_DECK_LIMITS.statement.footnote,
2001
+ issues,
2002
+ { optional: true }
2003
+ );
2004
+ break;
2005
+ case "list":
2006
+ validateText(
2007
+ slide.title,
2008
+ `${path}.title`,
2009
+ CAROUSEL_DECK_LIMITS.list.title,
2010
+ issues
2011
+ );
2012
+ validateText(
2013
+ slide.accent,
2014
+ `${path}.accent`,
2015
+ CAROUSEL_DECK_LIMITS.list.accent,
2016
+ issues,
2017
+ { optional: true }
2018
+ );
2019
+ if (!Array.isArray(slide.items) || slide.items.length === 0 || slide.items.some((item) => !isNonEmptyString(item))) {
2020
+ issues.push(`${path}.items must contain non-empty strings`);
2021
+ } else {
2022
+ if (slide.items.length > CAROUSEL_DECK_LIMITS.list.items) {
2023
+ issues.push(
2024
+ `${path}.items must contain at most ${CAROUSEL_DECK_LIMITS.list.items} items`
2025
+ );
364
2026
  }
365
- ]
366
- };
2027
+ slide.items.forEach(
2028
+ (item, itemIndex) => validateText(
2029
+ item,
2030
+ `${path}.items[${itemIndex}]`,
2031
+ CAROUSEL_DECK_LIMITS.list.item,
2032
+ issues
2033
+ )
2034
+ );
2035
+ }
2036
+ break;
2037
+ case "takeaway":
2038
+ validateText(
2039
+ slide.title,
2040
+ `${path}.title`,
2041
+ CAROUSEL_DECK_LIMITS.takeaway.title,
2042
+ issues
2043
+ );
2044
+ validateText(
2045
+ slide.accent,
2046
+ `${path}.accent`,
2047
+ CAROUSEL_DECK_LIMITS.takeaway.accent,
2048
+ issues,
2049
+ { optional: true }
2050
+ );
2051
+ validateText(
2052
+ slide.cta,
2053
+ `${path}.cta`,
2054
+ CAROUSEL_DECK_LIMITS.takeaway.cta,
2055
+ issues,
2056
+ { optional: true }
2057
+ );
2058
+ break;
2059
+ default:
2060
+ issues.push(`${path}.kind is invalid`);
367
2061
  }
368
- );
2062
+ validateOptionalImage(slide.image, `${path}.image`, issues);
2063
+ validateOptionalVisualRequest(
2064
+ slide.visualRequest,
2065
+ `${path}.visualRequest`,
2066
+ issues
2067
+ );
2068
+ if (slide.visualRequest && typeof slide.visualRequest === "object" && !Array.isArray(slide.visualRequest)) {
2069
+ const id2 = slide.visualRequest.id;
2070
+ if (isNonEmptyString(id2)) {
2071
+ if (visualRequestIds.has(id2)) {
2072
+ issues.push(
2073
+ `${path}.visualRequest.id must be unique within the deck`
2074
+ );
2075
+ }
2076
+ visualRequestIds.add(id2);
2077
+ }
2078
+ }
2079
+ });
2080
+ return issues.length === 0 ? { ok: true, slideCount: deck.slides.length } : { ok: false, issues };
369
2081
  }
370
2082
 
371
- // src/public-templates.ts
372
- import { z as z3 } from "zod";
373
- var TEMPLATE_REPOSITORY = "https://github.com/instavar/remotion-templates";
374
- var TEMPLATE_ENDPOINT = "https://instavar.com/api/mcp/templates";
375
- var VOICE_STUDIO_URL = "https://instavar.com/voice";
376
- var templateIds = [
377
- "qa-ad",
378
- "proof-walkthrough",
379
- "announcement-brief",
380
- "social-remix",
381
- "finance-brief"
382
- ];
383
- var templateIdSchema = z3.enum(templateIds);
384
- var aspectSchema = z3.enum(["9:16", "4:5", "1:1"]);
385
- var templates = [
386
- {
387
- id: "qa-ad",
388
- name: "Question and answer ad",
389
- description: "A short video with a hook, source-video window, explanation points, and call to action.",
390
- aspects: ["9:16", "4:5", "1:1"]
391
- },
392
- {
393
- id: "proof-walkthrough",
394
- name: "Proof walkthrough",
395
- description: "A paced explanation for equations, worked reasoning, and a final takeaway.",
396
- aspects: ["9:16", "4:5", "1:1"]
397
- },
398
- {
399
- id: "announcement-brief",
400
- name: "Announcement brief",
401
- description: "A concise announcement with a headline, supporting points, optional media, and next action.",
402
- aspects: ["9:16", "4:5", "1:1"]
403
- },
404
- {
405
- id: "social-remix",
406
- name: "Social remix",
407
- description: "A caption-forward treatment that frames an existing clip with a hook, context, and call to action.",
408
- aspects: ["9:16", "4:5", "1:1"]
409
- },
410
- {
411
- id: "finance-brief",
412
- name: "Data and finance brief",
413
- description: "An editorial brief for comparisons, numeric highlights, evidence, caveats, and a recommendation.",
414
- aspects: ["9:16", "4:5", "1:1"]
415
- }
416
- ];
417
- var videoSpecSchema = {
2083
+ // src/videospec-json-schema.ts
2084
+ var VIDEO_SPEC_JSON_SCHEMA = {
418
2085
  $schema: "https://json-schema.org/draft/2020-12/schema",
419
2086
  $id: "https://instavar.com/schemas/video-spec-1.0.json",
420
2087
  title: "Instavar VideoSpec",
@@ -431,52 +2098,94 @@ var videoSpecSchema = {
431
2098
  properties: {
432
2099
  schemaVersion: { const: "1.0" },
433
2100
  id: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{2,80}$" },
434
- templateFamily: { enum: templateIds },
2101
+ templateFamily: {
2102
+ enum: [
2103
+ "qa-ad",
2104
+ "proof-walkthrough",
2105
+ "announcement-brief",
2106
+ "social-remix",
2107
+ "finance-brief"
2108
+ ]
2109
+ },
435
2110
  meta: {
436
2111
  type: "object",
2112
+ additionalProperties: false,
437
2113
  required: ["title"],
438
2114
  properties: {
439
2115
  title: { type: "string", minLength: 1 },
440
2116
  description: { type: "string" },
441
- tags: { type: "array", items: { type: "string" } }
2117
+ tags: { type: "array", items: { type: "string" }, default: [] }
442
2118
  }
443
2119
  },
444
2120
  target: {
445
2121
  type: "object",
446
- required: ["aspect", "fps", "durationMode"],
2122
+ additionalProperties: false,
2123
+ required: ["aspect"],
447
2124
  properties: {
448
2125
  aspect: { enum: ["9:16", "4:5", "1:1"] },
449
- fps: { type: "integer", minimum: 1 },
450
- durationMode: { enum: ["auto", "fixed"] },
2126
+ fps: { type: "integer", minimum: 1, default: 30 },
2127
+ durationMode: { enum: ["auto", "fixed"], default: "auto" },
451
2128
  fixedDurationSec: { type: "number", exclusiveMinimum: 0 }
452
2129
  }
453
2130
  },
2131
+ style: {
2132
+ type: "object",
2133
+ additionalProperties: false,
2134
+ properties: {
2135
+ theme: {
2136
+ enum: ["default", "editorial-light", "editorial-dark", "clinical"],
2137
+ default: "default"
2138
+ },
2139
+ variant: { type: "string", default: "default" },
2140
+ safeAreaProfile: {
2141
+ enum: ["baseline", "metaSafe"],
2142
+ default: "baseline"
2143
+ },
2144
+ showSceneLabels: { type: "boolean", default: false }
2145
+ }
2146
+ },
454
2147
  audio: {
455
2148
  type: "object",
2149
+ additionalProperties: false,
456
2150
  properties: {
457
- mode: { enum: ["auto", "narration", "music", "silent"] },
2151
+ mode: {
2152
+ enum: ["auto", "narration", "music", "silent"],
2153
+ default: "auto"
2154
+ },
458
2155
  narrationText: { type: "string" },
459
2156
  narrationSrc: { type: "string" },
460
- narrationVolume: { type: "number", minimum: 0, maximum: 1 },
2157
+ narrationVolume: {
2158
+ type: "number",
2159
+ minimum: 0,
2160
+ maximum: 1,
2161
+ default: 1
2162
+ },
461
2163
  musicSrc: { type: "string" },
462
- musicVolume: { type: "number", minimum: 0, maximum: 1 },
463
- ducking: { type: "boolean" },
2164
+ musicVolume: {
2165
+ type: "number",
2166
+ minimum: 0,
2167
+ maximum: 1,
2168
+ default: 0.16
2169
+ },
2170
+ ducking: { type: "boolean", default: true },
464
2171
  narrationTiming: {
465
2172
  type: "object",
2173
+ additionalProperties: false,
466
2174
  required: ["schemaVersion", "source", "durationMs", "segments"],
467
2175
  properties: {
468
2176
  schemaVersion: { const: "1.0" },
469
2177
  source: { const: "segmented-synthesis" },
470
- durationMs: { type: "integer", minimum: 1 },
2178
+ durationMs: { type: "integer", minimum: 1, maximum: 12e5 },
471
2179
  segments: {
472
2180
  type: "array",
473
2181
  minItems: 1,
474
2182
  maxItems: 24,
475
2183
  items: {
476
2184
  type: "object",
2185
+ additionalProperties: false,
477
2186
  required: ["sceneId", "startMs", "endMs", "durationMs"],
478
2187
  properties: {
479
- sceneId: { type: "string", minLength: 1 },
2188
+ sceneId: { type: "string", minLength: 1, maxLength: 80 },
480
2189
  startMs: { type: "integer", minimum: 0 },
481
2190
  endMs: { type: "integer", minimum: 1 },
482
2191
  durationMs: { type: "integer", minimum: 1 }
@@ -487,11 +2196,20 @@ var videoSpecSchema = {
487
2196
  }
488
2197
  }
489
2198
  },
2199
+ assets: {
2200
+ type: "object",
2201
+ additionalProperties: false,
2202
+ properties: {
2203
+ logoSrc: { type: "string" },
2204
+ posterSrc: { type: "string" }
2205
+ }
2206
+ },
490
2207
  scenes: {
491
2208
  type: "array",
492
2209
  minItems: 1,
493
2210
  items: {
494
2211
  type: "object",
2212
+ additionalProperties: false,
495
2213
  required: ["id", "kind", "content"],
496
2214
  properties: {
497
2215
  id: { type: "string", minLength: 1 },
@@ -508,27 +2226,136 @@ var videoSpecSchema = {
508
2226
  ]
509
2227
  },
510
2228
  content: { type: "object" },
511
- timing: { type: "object" }
2229
+ timing: {
2230
+ type: "object",
2231
+ additionalProperties: false,
2232
+ properties: {
2233
+ durationMs: { type: "integer", exclusiveMinimum: 0 }
2234
+ }
2235
+ }
512
2236
  }
513
2237
  }
514
- },
515
- style: {
516
- type: "object",
517
- properties: {
518
- theme: {
519
- enum: ["default", "editorial-light", "editorial-dark", "clinical"]
520
- },
521
- variant: { type: "string" },
522
- safeAreaProfile: { enum: ["baseline", "metaSafe"] },
523
- showSceneLabels: { type: "boolean", default: false }
524
- }
525
2238
  }
526
2239
  }
527
2240
  };
528
- var annotations = {
529
- readOnlyHint: true,
530
- openWorldHint: false,
531
- destructiveHint: false
2241
+
2242
+ // src/public-catalogue.ts
2243
+ var TEMPLATE_REPOSITORY = "https://github.com/instavar/remotion-templates";
2244
+ var VOICE_STUDIO_URL = "https://instavar.com/voice";
2245
+ var PUBLIC_VIDEO_TEMPLATES = [
2246
+ {
2247
+ id: "qa-ad",
2248
+ name: "Question and answer ad",
2249
+ description: "Start with a question, then answer it with a clip and clear points.",
2250
+ aspects: ["9:16", "4:5", "1:1"],
2251
+ requiredSceneKinds: ["hero", "video-window", "cta"],
2252
+ optionalSceneKinds: ["points"],
2253
+ exampleId: "qa-ad-starter"
2254
+ },
2255
+ {
2256
+ id: "proof-walkthrough",
2257
+ name: "Proof walkthrough",
2258
+ description: "Explain a calculation or claim step by step, then end with the takeaway.",
2259
+ aspects: ["9:16", "4:5", "1:1"],
2260
+ requiredSceneKinds: ["hero", "equation"],
2261
+ optionalSceneKinds: ["points", "cta"],
2262
+ exampleId: "proof-walkthrough-starter"
2263
+ },
2264
+ {
2265
+ id: "announcement-brief",
2266
+ name: "Announcement brief",
2267
+ description: "Announce something new with a headline, proof, and next step.",
2268
+ aspects: ["9:16", "4:5", "1:1"],
2269
+ requiredSceneKinds: ["hero", "points"],
2270
+ optionalSceneKinds: ["statement", "mechanism", "video-window", "cta"],
2271
+ exampleId: "announcement-brief-starter"
2272
+ },
2273
+ {
2274
+ id: "social-remix",
2275
+ name: "Social remix",
2276
+ description: "Turn an existing clip into a caption-led social post.",
2277
+ aspects: ["9:16", "4:5", "1:1"],
2278
+ requiredSceneKinds: ["hero", "video-window", "cta"],
2279
+ optionalSceneKinds: ["points"],
2280
+ exampleId: "social-remix-starter"
2281
+ },
2282
+ {
2283
+ id: "finance-brief",
2284
+ name: "Data and finance brief",
2285
+ description: "Compare key numbers, show the evidence, and give a recommendation.",
2286
+ aspects: ["9:16", "4:5", "1:1"],
2287
+ requiredSceneKinds: ["hero", "points"],
2288
+ optionalSceneKinds: ["equation", "cta"],
2289
+ exampleId: "finance-brief-starter"
2290
+ }
2291
+ ];
2292
+ function findPublicTemplate(id2) {
2293
+ return PUBLIC_VIDEO_TEMPLATES.find((template) => template.id === id2);
2294
+ }
2295
+ var aspectSchema = z5.enum(["9:16", "4:5", "1:1"]);
2296
+ var storyboardBriefSchema = z5.string().min(8).max(600);
2297
+ var templateIdSchema = z5.enum([
2298
+ "qa-ad",
2299
+ "proof-walkthrough",
2300
+ "announcement-brief",
2301
+ "social-remix",
2302
+ "finance-brief"
2303
+ ]);
2304
+ var acceptedDesignSchema = z5.object({
2305
+ style: z5.string().min(1).max(600),
2306
+ durationSeconds: z5.number().positive().max(300),
2307
+ audio: z5.enum(["silent", "narration", "music"]),
2308
+ illustration: z5.string().min(1).max(600),
2309
+ exclusions: z5.array(z5.string().min(1).max(200)).max(20),
2310
+ preview: z5.literal("dark-cafe").optional()
2311
+ });
2312
+ var carouselTemplateIdSchema = z5.enum([
2313
+ "listicle",
2314
+ "manifesto",
2315
+ "before-after",
2316
+ "value-first-reveal"
2317
+ ]);
2318
+ var PUBLIC_CAROUSEL_DECK_JSON_SCHEMA = {
2319
+ $schema: "https://json-schema.org/draft/2020-12/schema",
2320
+ title: "Instavar CarouselDeck",
2321
+ type: "object",
2322
+ required: ["slides"],
2323
+ properties: {
2324
+ aspect: { enum: ["4:5", "1:1", "9:16"] },
2325
+ visualStyle: { enum: ["editorial", "native-photo"] },
2326
+ handle: { type: "string", maxLength: 40 },
2327
+ showPageNumber: { type: "boolean" },
2328
+ slides: {
2329
+ type: "array",
2330
+ minItems: 1,
2331
+ maxItems: 12,
2332
+ items: {
2333
+ type: "object",
2334
+ required: ["kind"],
2335
+ properties: {
2336
+ kind: { enum: ["cover", "statement", "list", "takeaway"] },
2337
+ title: { type: "string" },
2338
+ statement: { type: "string" },
2339
+ subtitle: { type: "string" },
2340
+ accent: { type: "string" },
2341
+ footnote: { type: "string" },
2342
+ cta: { type: "string" },
2343
+ items: { type: "array", items: { type: "string" }, maxItems: 5 },
2344
+ image: {
2345
+ type: "object",
2346
+ required: ["src", "alt", "provenance"],
2347
+ properties: {
2348
+ src: { type: "string" },
2349
+ alt: { type: "string" },
2350
+ provenance: {
2351
+ enum: ["user-owned", "licensed-stock", "ai-generated"]
2352
+ }
2353
+ }
2354
+ }
2355
+ }
2356
+ }
2357
+ }
2358
+ }
532
2359
  };
533
2360
  function result(value, summary) {
534
2361
  return {
@@ -536,18 +2363,32 @@ function result(value, summary) {
536
2363
  content: [{ type: "text", text: summary }]
537
2364
  };
538
2365
  }
2366
+ function withStructuredContentText(value) {
2367
+ if (value.isError || value.structuredContent === void 0) return value;
2368
+ return {
2369
+ ...value,
2370
+ content: [
2371
+ ...value.content,
2372
+ { type: "text", text: JSON.stringify(value.structuredContent) }
2373
+ ]
2374
+ };
2375
+ }
539
2376
  function slugify(value) {
540
2377
  const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 72);
541
2378
  return slug.length >= 3 ? slug : "new-video";
542
2379
  }
543
- function scaffoldVideoSpec(args) {
2380
+ function withFrameworks(template, paired) {
2381
+ return paired ? { ...template, frameworks: ["remotion", "hyperframes"] } : template;
2382
+ }
2383
+ function scaffoldVideoSpec(args, options = {}) {
2384
+ const announcement = args.templateId === "announcement-brief";
544
2385
  const scenes = [
545
2386
  {
546
2387
  id: "hero",
547
2388
  kind: "hero",
548
2389
  content: {
549
2390
  title: args.title,
550
- subtitle: "Replace with a concise promise"
2391
+ ...announcement && args.body ? {} : { subtitle: args.body ?? "Replace with a concise promise" }
551
2392
  },
552
2393
  timing: { durationMs: 4e3 }
553
2394
  }
@@ -563,7 +2404,14 @@ function scaffoldVideoSpec(args) {
563
2404
  timing: { durationMs: 7e3 }
564
2405
  });
565
2406
  }
566
- if (args.templateId === "announcement-brief") {
2407
+ if (announcement && args.body) {
2408
+ scenes.push({
2409
+ id: "key-points",
2410
+ kind: "points",
2411
+ content: { title: args.body, points: [] },
2412
+ timing: { durationMs: 7e3 }
2413
+ });
2414
+ } else if (announcement) {
567
2415
  scenes.push(
568
2416
  {
569
2417
  id: "context",
@@ -594,14 +2442,21 @@ function scaffoldVideoSpec(args) {
594
2442
  timing: { durationMs: 7e3 }
595
2443
  }
596
2444
  );
597
- } else {
2445
+ } else if (args.templateId === "proof-walkthrough") {
598
2446
  scenes.push({
599
- id: args.templateId === "proof-walkthrough" ? "working" : "key-points",
600
- kind: args.templateId === "proof-walkthrough" ? "equation" : "points",
601
- content: args.templateId === "proof-walkthrough" ? {
2447
+ id: "working",
2448
+ kind: "equation",
2449
+ content: {
602
2450
  title: "Work through the idea",
603
2451
  latexBlocks: ["x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}"]
604
- } : {
2452
+ },
2453
+ timing: { durationMs: 8e3 }
2454
+ });
2455
+ } else {
2456
+ scenes.push({
2457
+ id: "key-points",
2458
+ kind: "points",
2459
+ content: args.body ? { title: args.body, points: [args.body] } : {
605
2460
  title: "Key points",
606
2461
  points: [
607
2462
  "Replace with evidence",
@@ -612,220 +2467,668 @@ function scaffoldVideoSpec(args) {
612
2467
  timing: { durationMs: 8e3 }
613
2468
  });
614
2469
  }
615
- scenes.push({
616
- id: "cta",
617
- kind: "cta",
618
- content: { line1: "Replace with the next action" },
619
- timing: {
620
- durationMs: args.templateId === "announcement-brief" ? 6e3 : 5e3
621
- }
622
- });
623
- return {
624
- schemaVersion: "1.0",
625
- id: slugify(args.title),
626
- templateFamily: args.templateId,
627
- meta: { title: args.title, tags: [] },
628
- target: { aspect: args.aspect, fps: 30, durationMode: "auto" },
629
- style: {
630
- theme: args.templateId === "announcement-brief" ? "editorial-light" : "default",
631
- variant: "default",
632
- safeAreaProfile: "metaSafe",
633
- showSceneLabels: false
2470
+ scenes.push({
2471
+ id: "cta",
2472
+ kind: "cta",
2473
+ content: { line1: args.cta ?? "Replace with the next action" },
2474
+ timing: { durationMs: announcement ? 6e3 : 5e3 }
2475
+ });
2476
+ return {
2477
+ schemaVersion: "1.0",
2478
+ id: slugify(args.title),
2479
+ templateFamily: args.templateId,
2480
+ meta: { title: args.title, tags: [] },
2481
+ target: { aspect: args.aspect, fps: 30, durationMode: "auto" },
2482
+ style: {
2483
+ theme: announcement ? "editorial-light" : "default",
2484
+ variant: "default",
2485
+ // Neither renderer applies metaSafe; the paired contract rejects it.
2486
+ safeAreaProfile: options.pairedTemplates ? "baseline" : "metaSafe",
2487
+ showSceneLabels: false
2488
+ },
2489
+ audio: {
2490
+ mode: "silent",
2491
+ narrationText: "",
2492
+ narrationVolume: 1,
2493
+ musicVolume: 0.16,
2494
+ ducking: true
2495
+ },
2496
+ assets: {},
2497
+ scenes
2498
+ };
2499
+ }
2500
+ var HEALTH_OR_SAFETY_PATTERN = /\b(cpr|first aid|medical|medicine|medication|symptom|emergency|safety)\b/i;
2501
+ function titleFromBrief(brief) {
2502
+ const concise = brief.trim().replace(
2503
+ /^(?:please\s+)?(?:make|create|show|teach|explain)\s+(?:me\s+)?(?:a\s+)?(?:video\s+)?(?:about\s+)?/i,
2504
+ ""
2505
+ ).replace(/^tell me\s+/i, "").replace(/\s+/g, " ").replace(/[.?!]+$/, "");
2506
+ if (!concise) return "A clear video";
2507
+ return concise.charAt(0).toUpperCase() + concise.slice(1);
2508
+ }
2509
+ function recommendStoryboardStructure(brief) {
2510
+ const mediaIntent = brief.replace(
2511
+ /\b(?:no|without|avoid)\s+(?:(?:any|source|stock|automatic|supplied)\s+)?(?:clips?|footage|b-?roll)\b/gi,
2512
+ ""
2513
+ );
2514
+ if (/\b(clip|footage|reel|remix|repurpose)\b/i.test(mediaIntent)) {
2515
+ return { templateId: "social-remix", kind: "source-remix" };
2516
+ }
2517
+ if (/\b(data|numbers?|metric|finance|financial|compare|comparison)\b/i.test(
2518
+ brief
2519
+ )) {
2520
+ return { templateId: "finance-brief", kind: "data-brief" };
2521
+ }
2522
+ if (/\b(announce(?:ment)?|launch|new|opening|release)\b/i.test(brief)) {
2523
+ return { templateId: "announcement-brief", kind: "announcement" };
2524
+ }
2525
+ if (/\b(how\s+to|how\s+do\s+(?:i|you|we)|steps?|step-by-step|recipe|cook|slice|chop|dice|peel|prepare|assemble|install|set\s+up|fold|tie)\b/i.test(
2526
+ brief
2527
+ )) {
2528
+ return { templateId: "qa-ad", kind: "procedure" };
2529
+ }
2530
+ return { templateId: "qa-ad", kind: "question-answer" };
2531
+ }
2532
+ function storyboardFrames(args) {
2533
+ if (args.kind === "procedure" && args.templateId === "qa-ad") {
2534
+ return [
2535
+ [
2536
+ "Prepare the setup",
2537
+ "Show the tools, ingredients, and safe starting position."
2538
+ ],
2539
+ [
2540
+ "Show the key action",
2541
+ "Use a close, readable view of the movement the viewer must copy."
2542
+ ],
2543
+ [
2544
+ "Show the result",
2545
+ "End on the finished outcome and the one safety point to remember."
2546
+ ]
2547
+ ].map(([title2, purpose], index) => ({
2548
+ id: `beat-${index + 1}`,
2549
+ title: title2,
2550
+ purpose,
2551
+ visualBrief: `${title2} for ${args.title}. Editorial composition, one clear subject, generous negative space, no words, numbers, logos, or interface elements.`,
2552
+ alt: `${title2}: a proposed visual beat for ${args.title}.`,
2553
+ asset: { kind: "image", state: "proposed" }
2554
+ }));
2555
+ }
2556
+ const frameCopy = {
2557
+ "qa-ad": [
2558
+ [
2559
+ "Open with the question",
2560
+ "Make the viewer recognise the problem or curiosity."
2561
+ ],
2562
+ ["Show the answer", "Show the one idea that resolves it."],
2563
+ ["Leave one next step", "End with the takeaway the viewer can use."]
2564
+ ],
2565
+ "proof-walkthrough": [
2566
+ [
2567
+ "Set the scene",
2568
+ "Establish the ingredients, tools, or starting condition."
2569
+ ],
2570
+ [
2571
+ "Show the essential move",
2572
+ "Show the central action in a close, readable moment."
2573
+ ],
2574
+ [
2575
+ "Land the outcome",
2576
+ "Show the finished result and the one idea to remember."
2577
+ ]
2578
+ ],
2579
+ "announcement-brief": [
2580
+ [
2581
+ "Lead with the news",
2582
+ "Make the new thing unmistakable at first glance."
2583
+ ],
2584
+ ["Show the proof", "Show the detail that makes the announcement matter."],
2585
+ ["Give the next step", "End with a simple, concrete invitation."]
2586
+ ],
2587
+ "social-remix": [
2588
+ [
2589
+ "Find the strongest moment",
2590
+ "Open on the most recognisable moment in the supplied clip."
2591
+ ],
2592
+ [
2593
+ "Add the context",
2594
+ "Use a second visual beat to make the point clear without stopping the clip."
2595
+ ],
2596
+ [
2597
+ "End before it drags",
2598
+ "Leave one memorable line or image as the viewer scrolls on."
2599
+ ]
2600
+ ],
2601
+ "finance-brief": [
2602
+ ["Name the decision", "Establish the question behind the numbers."],
2603
+ [
2604
+ "Make the evidence visible",
2605
+ "Show the comparison or trend as a simple visual fact."
2606
+ ],
2607
+ [
2608
+ "State the recommendation",
2609
+ "End with the decision the evidence supports."
2610
+ ]
2611
+ ]
2612
+ };
2613
+ return frameCopy[args.templateId].map(([title2, purpose], index) => ({
2614
+ id: `beat-${index + 1}`,
2615
+ title: title2,
2616
+ purpose,
2617
+ visualBrief: `${title2} for ${args.title}. Editorial composition, one clear subject, generous negative space, no words, numbers, logos, or interface elements.`,
2618
+ alt: `${title2}: a proposed visual beat for ${args.title}.`,
2619
+ asset: { kind: "image", state: "proposed" }
2620
+ }));
2621
+ }
2622
+ function proposeVideoStoryboard(args, acceptedPreview) {
2623
+ const title2 = args.title ?? titleFromBrief(args.brief);
2624
+ const recommendation = recommendStoryboardStructure(args.brief);
2625
+ const templateId = args.templateId ?? recommendation.templateId;
2626
+ const kind = recommendation.kind;
2627
+ const template = findPublicTemplate(templateId);
2628
+ const reviewRequired = HEALTH_OR_SAFETY_PATTERN.test(args.brief);
2629
+ const isProcedure = kind === "procedure" && templateId === "qa-ad";
2630
+ return {
2631
+ version: "1.0",
2632
+ brief: args.brief.trim(),
2633
+ title: title2,
2634
+ ...args.body ? { body: args.body } : {},
2635
+ ...args.cta ? { cta: args.cta } : {},
2636
+ aspect: args.aspect,
2637
+ ...args.acceptedDesign ? {
2638
+ acceptedDesign: args.acceptedDesign,
2639
+ acceptedPreview: acceptedPreview?.({ ...args, title: title2 })
2640
+ } : {},
2641
+ template: {
2642
+ id: template.id,
2643
+ name: isProcedure ? "Visual how-to" : template.name,
2644
+ reason: isProcedure ? "Show a physical process as clear visual steps, then the usable outcome." : template.description,
2645
+ variant: isProcedure ? "procedural" : "default"
2646
+ },
2647
+ visualDirection: {
2648
+ communicationJob: "Make the subject and sequence clear at a glance.",
2649
+ style: args.acceptedDesign?.style ?? "Editorial, minimal, and scene-led rather than text-led.",
2650
+ factualReviewRequired: reviewRequired
2651
+ },
2652
+ frames: storyboardFrames({ title: title2, templateId, kind }),
2653
+ imageGeneration: {
2654
+ state: "not-generated",
2655
+ notice: "These are visual briefs, not generated images. GPT-Image-2 drafts require an explicit, signed-in Studio generation step with cost and provenance controls."
2656
+ }
2657
+ };
2658
+ }
2659
+ function runProposeVideoStoryboardTool(args, acceptedPreview) {
2660
+ const storyboard = proposeVideoStoryboard(args, acceptedPreview);
2661
+ return result(
2662
+ { storyboard },
2663
+ "A three-beat visual storyboard is ready. It is a proposal only: no images were generated, no project was saved, and no render was started."
2664
+ );
2665
+ }
2666
+ function runListCarouselTemplatesTool() {
2667
+ const templates = CAROUSEL_ARCHETYPES.map(({ id: id2, label: label2, blurb }) => ({
2668
+ id: id2,
2669
+ name: label2,
2670
+ description: blurb,
2671
+ defaultAspect: "4:5",
2672
+ visualStyle: "editorial"
2673
+ }));
2674
+ return result(
2675
+ { templates, creativeGuides: CREATIVE_GUIDE_INDEX },
2676
+ templates.map((template) => `${template.id}: ${template.description}`).join("\n")
2677
+ );
2678
+ }
2679
+ function runGetCarouselSchemaTool() {
2680
+ return result(
2681
+ { schemaVersion: "1.0", jsonSchema: PUBLIC_CAROUSEL_DECK_JSON_SCHEMA },
2682
+ "CarouselDeck schema version 1.0. Text, branding, numbering, and layout remain deterministic."
2683
+ );
2684
+ }
2685
+ function runScaffoldCarouselDeckTool(args) {
2686
+ const archetype = getArchetype(args.templateId);
2687
+ if (!archetype) {
2688
+ return {
2689
+ isError: true,
2690
+ content: [{ type: "text", text: "Unknown carousel template." }]
2691
+ };
2692
+ }
2693
+ const deck = archetype.build({
2694
+ hook: args.hook,
2695
+ subtitle: args.subtitle,
2696
+ points: args.points,
2697
+ payoff: args.payoff,
2698
+ cta: args.cta,
2699
+ handle: args.handle
2700
+ });
2701
+ deck.aspect = args.aspect;
2702
+ const validation = validateCarouselDeck(deck);
2703
+ if (!validation.ok) {
2704
+ return {
2705
+ isError: true,
2706
+ structuredContent: { issues: validation.issues },
2707
+ content: [
2708
+ {
2709
+ type: "text",
2710
+ text: `Carousel deck is invalid: ${validation.issues.join("; ")}`
2711
+ }
2712
+ ]
2713
+ };
2714
+ }
2715
+ return result(
2716
+ {
2717
+ schemaVersion: "1.0",
2718
+ templateId: args.templateId,
2719
+ deck,
2720
+ validation
2721
+ },
2722
+ `A ${validation.slideCount}-slide ${args.templateId} deck is ready for local rendering. Review every claim and add only rights-cleared images.`
2723
+ );
2724
+ }
2725
+ function runListTemplatesTool(args, paired) {
2726
+ const templates = args.aspect ? PUBLIC_VIDEO_TEMPLATES.filter(
2727
+ (template) => template.aspects.includes(args.aspect)
2728
+ ) : PUBLIC_VIDEO_TEMPLATES;
2729
+ return result(
2730
+ {
2731
+ templates: templates.map(
2732
+ (template) => withFrameworks({ ...template }, paired)
2733
+ )
2734
+ },
2735
+ templates.map((template) => `${template.id}: ${template.description}`).join("\n")
2736
+ );
2737
+ }
2738
+ function runGetTemplateTool(args, paired) {
2739
+ const template = findPublicTemplate(args.templateId);
2740
+ if (!template) {
2741
+ return {
2742
+ isError: true,
2743
+ content: [{ type: "text", text: "Unknown template." }]
2744
+ };
2745
+ }
2746
+ return result(
2747
+ { template: withFrameworks({ ...template }, paired) },
2748
+ `${template.name}
2749
+ ${template.description}`
2750
+ );
2751
+ }
2752
+ function runGetVideoSchemaTool() {
2753
+ return result(
2754
+ { schemaVersion: "1.0", jsonSchema: VIDEO_SPEC_JSON_SCHEMA },
2755
+ "VideoSpec schema version 1.0. Use only published template and scene identifiers."
2756
+ );
2757
+ }
2758
+ function runScaffoldVideoSpecTool(args, paired, acceptedPreview) {
2759
+ const spec = scaffoldVideoSpec(args, { pairedTemplates: paired });
2760
+ return result(
2761
+ {
2762
+ spec,
2763
+ filename: `${String(spec.id)}.video.json`,
2764
+ planningContext: {
2765
+ brief: args.brief,
2766
+ title: args.title,
2767
+ body: args.body,
2768
+ cta: args.cta,
2769
+ aspect: args.aspect,
2770
+ templateId: args.templateId,
2771
+ acceptedDesign: args.acceptedDesign,
2772
+ acceptedPreview: acceptedPreview?.(args)
2773
+ }
634
2774
  },
635
- audio: {
636
- mode: "silent",
637
- narrationText: "",
638
- narrationVolume: 1,
639
- musicVolume: 0.16,
640
- ducking: true
2775
+ `Starter VideoSpec created for ${args.templateId}. Replace placeholder copy and media before rendering.`
2776
+ );
2777
+ }
2778
+ function runGetExampleTool(args, paired) {
2779
+ const spec = scaffoldVideoSpec(
2780
+ {
2781
+ templateId: args.templateId,
2782
+ title: `Example ${args.templateId}`,
2783
+ aspect: "9:16"
641
2784
  },
642
- assets: {},
643
- scenes
644
- };
2785
+ { pairedTemplates: paired }
2786
+ );
2787
+ return result(
2788
+ { templateId: args.templateId, spec },
2789
+ `Example VideoSpec for ${args.templateId}.`
2790
+ );
645
2791
  }
646
- function registerPublicTemplateTools(server) {
647
- registerCreativeGuides(server);
648
- registerPairedAnnouncement(server);
2792
+ function runGetRenderInstructionsTool(args, options = {}) {
2793
+ const commands = [
2794
+ `git clone ${TEMPLATE_REPOSITORY}.git`,
2795
+ "cd remotion-templates",
2796
+ "npm install",
2797
+ options.voiceStudio === false ? "# Optional: save your own narration recording as public/generated/narration.wav, with one paragraph per scene" : `# Generate narration at ${VOICE_STUDIO_URL}, with one paragraph per scene`,
2798
+ "npm run video:timing -- path/to/video.video.json --audio public/generated/narration.wav --manifest path/to/narration.timing.json",
2799
+ "npm run video:validate -- path/to/video.video.json",
2800
+ "npm run video:preview -- path/to/video.video.json",
2801
+ "npm run video:render -- path/to/video.video.json",
2802
+ "npm run video:qa -- path/to/video.video.json path/to/video.mp4"
2803
+ ];
2804
+ const guidance = args.client === "codex" ? "Ask Codex to clone the repository, read AGENTS.md and the make-video skill, author a VideoSpec, validate it, preview representative frames, and render only after validation passes." : args.client === "claude-code" ? "Ask Claude Code to clone the repository, read CLAUDE.md and the make-video skill, author a VideoSpec, validate it, preview representative frames, and render only after validation passes." : "Follow the repository README and run the commands in order.";
2805
+ return result(
2806
+ {
2807
+ repository: TEMPLATE_REPOSITORY,
2808
+ client: args.client,
2809
+ guidance,
2810
+ commands
2811
+ },
2812
+ `${guidance}
2813
+
2814
+ ${commands.join("\n")}`
2815
+ );
2816
+ }
2817
+ function runDiagnoseRenderErrorTool(args) {
2818
+ const text3 = args.errorText.toLowerCase();
2819
+ let diagnosis = "Run validation first, confirm Node 22 or newer, and retry with the smallest included example.";
2820
+ let code = "unknown-render-error";
2821
+ if (text3.includes("enoent") || text3.includes("not found")) {
2822
+ code = "missing-file";
2823
+ diagnosis = "A referenced spec, media, font, or asset path is missing. Resolve paths relative to the repository and confirm exact filename case.";
2824
+ } else if (text3.includes("ffmpeg") || text3.includes("codec")) {
2825
+ code = "media-codec";
2826
+ diagnosis = "The source media or local ffmpeg setup is incompatible. Probe the file, then transcode to H.264 video with AAC audio.";
2827
+ } else if (text3.includes("schema") || text3.includes("invalid") || text3.includes("zod")) {
2828
+ code = "invalid-video-spec";
2829
+ diagnosis = "The VideoSpec does not match schema version 1.0. Fetch get_video_schema and correct the reported field before rendering.";
2830
+ } else if (text3.includes("chrome") || text3.includes("browser")) {
2831
+ code = "browser-runtime";
2832
+ diagnosis = "Remotion could not start its browser runtime. Reinstall dependencies and follow the platform-specific browser setup in the repository README.";
2833
+ }
2834
+ return result(
2835
+ {
2836
+ code,
2837
+ diagnosis,
2838
+ nextStep: "Use get_render_instructions for the canonical local workflow."
2839
+ },
2840
+ `${code}: ${diagnosis}`
2841
+ );
2842
+ }
2843
+ var READ_ONLY_ANNOTATIONS = {
2844
+ readOnlyHint: true,
2845
+ openWorldHint: false,
2846
+ destructiveHint: false
2847
+ };
2848
+ function registerSharedTemplateTools(server, options) {
2849
+ const paired = options.pairedTemplates;
2850
+ const meta = (name) => options.toolMeta ? { _meta: options.toolMeta(name) } : {};
2851
+ const send = (name, value) => options.jsonTextTools?.has(name) ? withStructuredContentText(value) : value;
2852
+ const catalogue = paired ? "video" : "Remotion";
649
2853
  server.registerTool(
650
- "get_capabilities",
2854
+ "list_carousel_templates",
651
2855
  {
652
- title: "Get video capabilities",
653
- description: "Call first. Reports free local features and optional account features.",
2856
+ title: "List carousel templates",
2857
+ description: "List the account-free editorial carousel story structures.",
654
2858
  inputSchema: {},
655
- annotations
2859
+ annotations: {
2860
+ title: "List carousel templates",
2861
+ ...READ_ONLY_ANNOTATIONS
2862
+ },
2863
+ ...meta("list_carousel_templates")
656
2864
  },
657
- async () => result(
658
- {
659
- authentication: "optional",
660
- apiKeyConfigured: Boolean(process.env.INSTAVAR_API_KEY?.trim()),
661
- repository: TEMPLATE_REPOSITORY,
662
- endpoint: TEMPLATE_ENDPOINT,
663
- creativeGuides: CREATIVE_GUIDE_INDEX,
664
- pairedAnnouncement: PAIRED_ANNOUNCEMENT_CAPABILITY,
665
- localFeatures: [
666
- "template discovery",
667
- "VideoSpec schema and examples",
668
- "deterministic scaffolding",
669
- "local render instructions",
670
- "render error diagnosis",
671
- "keyless on-device narration with scene timing",
672
- "every-scene preview frames",
673
- "post-render audible-audio verification"
674
- ],
675
- narration: {
676
- url: VOICE_STUDIO_URL,
677
- cost: "free",
678
- apiKeyRequired: false,
679
- guidance: "Write one paragraph per scene. Download the WAV and timing manifest, then apply both before rendering."
680
- },
681
- accountFeatures: [
682
- "managed rendering and storage",
683
- "workflow review and approval",
684
- "social publishing and metrics"
685
- ]
2865
+ async () => send("list_carousel_templates", runListCarouselTemplatesTool())
2866
+ );
2867
+ server.registerTool(
2868
+ "get_carousel_schema",
2869
+ {
2870
+ title: "Get CarouselDeck schema",
2871
+ description: "Return the JSON Schema for deterministic Instavar carousel decks.",
2872
+ inputSchema: {},
2873
+ annotations: { title: "Get carousel schema", ...READ_ONLY_ANNOTATIONS },
2874
+ ...meta("get_carousel_schema")
2875
+ },
2876
+ async () => send("get_carousel_schema", runGetCarouselSchemaTool())
2877
+ );
2878
+ server.registerTool(
2879
+ "scaffold_carousel_deck",
2880
+ {
2881
+ title: "Scaffold carousel deck",
2882
+ description: "Build a deterministic editorial carousel deck from accepted copy. This does not render, save, or publish it.",
2883
+ inputSchema: {
2884
+ templateId: carouselTemplateIdSchema.describe(
2885
+ "Story structure from list_carousel_templates."
2886
+ ),
2887
+ hook: z5.string().min(1).max(100).describe("Cover line on the first slide."),
2888
+ subtitle: z5.string().min(1).max(160).optional().describe("Optional cover subtitle under the hook."),
2889
+ points: z5.array(z5.string().min(1).max(120)).min(1).max(5).describe(
2890
+ "Body beats in order. listicle lists them on one slide, manifesto gives each its own slide, before-after uses the first as the problem and the last as the contrast, and value-first-reveal uses the first three."
2891
+ ),
2892
+ payoff: z5.string().min(1).max(120).describe("Closing takeaway on the final slide."),
2893
+ cta: z5.string().min(1).max(140).optional().describe("Optional call to action on the final slide."),
2894
+ handle: z5.string().min(1).max(40).optional().describe("Optional brand handle shown in the slide footer."),
2895
+ aspect: z5.enum(["4:5", "1:1", "9:16"]).default("4:5").describe("Slide aspect ratio. Defaults to 4:5.")
686
2896
  },
687
- process.env.INSTAVAR_API_KEY?.trim() ? "Free local tools and authenticated Instavar Studio tools are available." : "Free local tools are available. Add INSTAVAR_API_KEY to unlock hosted Studio tools."
688
- )
2897
+ annotations: {
2898
+ title: "Scaffold carousel deck",
2899
+ ...READ_ONLY_ANNOTATIONS
2900
+ },
2901
+ ...meta("scaffold_carousel_deck")
2902
+ },
2903
+ async (args) => send("scaffold_carousel_deck", runScaffoldCarouselDeckTool(args))
689
2904
  );
690
2905
  server.registerTool(
691
2906
  "list_templates",
692
2907
  {
693
- title: "List Remotion templates",
694
- description: "List public templates, optionally filtered by aspect ratio.",
695
- inputSchema: { aspect: aspectSchema.optional() },
696
- annotations
2908
+ title: `List ${catalogue} templates`,
2909
+ description: paired ? "List the published video template families, each available in Remotion and HyperFrames, and optionally filter by output aspect ratio." : "List the published Remotion template families and optionally filter by output aspect ratio.",
2910
+ inputSchema: {
2911
+ aspect: aspectSchema.optional().describe(
2912
+ "Only list templates that support this aspect ratio. Omit to list them all."
2913
+ )
2914
+ },
2915
+ annotations: { title: "List templates", ...READ_ONLY_ANNOTATIONS },
2916
+ ...meta("list_templates")
697
2917
  },
698
- async ({ aspect }) => {
699
- const filtered = aspect ? templates.filter((template) => template.aspects.includes(aspect)) : templates;
700
- return result(
701
- { templates: filtered },
702
- filtered.map((template) => `${template.id}: ${template.description}`).join("\n")
703
- );
704
- }
2918
+ async (args) => send("list_templates", runListTemplatesTool(args, paired))
705
2919
  );
706
2920
  server.registerTool(
707
2921
  "get_template",
708
2922
  {
709
- title: "Get Remotion template",
710
- description: "Get one public template contract.",
711
- inputSchema: { templateId: templateIdSchema },
712
- annotations
2923
+ title: `Get ${catalogue} template`,
2924
+ description: "Get one template's purpose, aspect ratios, scene kinds, and example identifier.",
2925
+ inputSchema: {
2926
+ templateId: templateIdSchema.describe(
2927
+ "Template family from list_templates."
2928
+ )
2929
+ },
2930
+ annotations: { title: "Get template", ...READ_ONLY_ANNOTATIONS },
2931
+ ...meta("get_template")
713
2932
  },
714
- async ({ templateId }) => {
715
- const template = templates.find((item) => item.id === templateId);
716
- return result(
717
- { template },
718
- `${template?.name ?? templateId}
719
- ${template?.description ?? ""}`
720
- );
721
- }
2933
+ async (args) => send("get_template", runGetTemplateTool(args, paired))
722
2934
  );
723
2935
  server.registerTool(
724
2936
  "get_video_schema",
725
2937
  {
726
2938
  title: "Get VideoSpec schema",
727
- description: "Return the public VideoSpec JSON Schema.",
2939
+ description: "Return the published JSON Schema for VideoSpec version 1.0.",
728
2940
  inputSchema: {},
729
- annotations
2941
+ annotations: { title: "Get video schema", ...READ_ONLY_ANNOTATIONS },
2942
+ ...meta("get_video_schema")
730
2943
  },
731
- async () => result(
732
- { schemaVersion: "1.0", jsonSchema: videoSpecSchema },
733
- "VideoSpec schema version 1.0."
734
- )
2944
+ async () => send("get_video_schema", runGetVideoSchemaTool())
735
2945
  );
736
2946
  server.registerTool(
737
2947
  "get_example",
738
2948
  {
739
2949
  title: "Get VideoSpec example",
740
- description: "Return a starter example for one template.",
741
- inputSchema: { templateId: templateIdSchema },
742
- annotations
2950
+ description: "Return a valid starter example for one template family.",
2951
+ inputSchema: {
2952
+ templateId: templateIdSchema.describe(
2953
+ "Template family whose starter VideoSpec to return."
2954
+ )
2955
+ },
2956
+ annotations: { title: "Get example", ...READ_ONLY_ANNOTATIONS },
2957
+ ...meta("get_example")
743
2958
  },
744
- async ({ templateId }) => result(
745
- {
746
- templateId,
747
- spec: scaffoldVideoSpec({
748
- templateId,
749
- title: `Example ${templateId}`,
750
- aspect: "9:16"
751
- })
2959
+ async (args) => send("get_example", runGetExampleTool(args, paired))
2960
+ );
2961
+ server.registerTool(
2962
+ "propose_video_storyboard",
2963
+ {
2964
+ title: "Propose a video storyboard",
2965
+ description: "Turn an ordinary video request into a three-beat visual proposal and recommended template. Pass templateId to preserve an accepted template when changing only the aspect; omit it for a new direction. This tool does not generate images, save a project, render, or publish.",
2966
+ inputSchema: {
2967
+ brief: storyboardBriefSchema.describe(
2968
+ "The user's video request in their own words. It picks the recommended template and, without a title, the working title."
2969
+ ),
2970
+ templateId: templateIdSchema.optional().describe(
2971
+ "Accepted template family to keep, for example when only the aspect changes. Omit for a new direction."
2972
+ ),
2973
+ title: z5.string().min(1).max(160).optional().describe(
2974
+ "Accepted title, if the user supplied one. Omit to derive one from the brief."
2975
+ ),
2976
+ body: z5.string().min(1).max(2e3).optional().describe("Accepted body copy, kept exactly as supplied."),
2977
+ cta: z5.string().min(1).max(500).optional().describe("Accepted call to action, kept exactly as supplied."),
2978
+ acceptedDesign: acceptedDesignSchema.optional().describe(
2979
+ "The design the user accepted: style, duration in seconds, audio, illustration and exclusions. Pass it on to scaffold_video_spec and later steps."
2980
+ ),
2981
+ aspect: aspectSchema.default("9:16").describe("Output aspect ratio. Defaults to 9:16.")
2982
+ },
2983
+ annotations: {
2984
+ title: "Propose video storyboard",
2985
+ ...READ_ONLY_ANNOTATIONS
752
2986
  },
753
- `Example VideoSpec for ${templateId}.`
2987
+ ...meta("propose_video_storyboard")
2988
+ },
2989
+ async (args) => send(
2990
+ "propose_video_storyboard",
2991
+ runProposeVideoStoryboardTool(args, options.acceptedPreview)
754
2992
  )
755
2993
  );
756
2994
  server.registerTool(
757
2995
  "scaffold_video_spec",
758
2996
  {
759
2997
  title: "Scaffold VideoSpec",
760
- description: "Return a deterministic VideoSpec skeleton without writing files.",
2998
+ description: "Return a deterministic VideoSpec skeleton. This tool does not generate creative copy or write files.",
761
2999
  inputSchema: {
762
- templateId: templateIdSchema,
763
- title: z3.string().min(1).max(160),
764
- aspect: aspectSchema.default("9:16"),
765
- mediaSrc: z3.string().min(1).max(500).optional()
3000
+ templateId: templateIdSchema.describe(
3001
+ "Template family from list_templates."
3002
+ ),
3003
+ title: z5.string().min(1).max(160).describe(
3004
+ "Video title, shown in the opening scene and used for the spec ID."
3005
+ ),
3006
+ brief: z5.string().min(1).max(600).optional().describe(
3007
+ "Original intent and constraints to preserve through planning and handoff. This is not generated video copy."
3008
+ ),
3009
+ aspect: aspectSchema.default("9:16").describe("Output aspect ratio. Defaults to 9:16."),
3010
+ mediaSrc: z5.string().min(1).max(500).optional().describe(
3011
+ "Source video path for the video window in qa-ad and social-remix. Other templates ignore it; without it the spec holds a placeholder path."
3012
+ ),
3013
+ body: z5.string().min(1).max(2e3).optional().describe(
3014
+ "Accepted body copy. It replaces the placeholder copy and appears once."
3015
+ ),
3016
+ cta: z5.string().min(1).max(500).optional().describe("Accepted call to action for the closing scene."),
3017
+ acceptedDesign: acceptedDesignSchema.optional().describe(
3018
+ "The design the user accepted. Returned in planningContext for later steps; it does not change the VideoSpec."
3019
+ )
766
3020
  },
767
- annotations
3021
+ annotations: { title: "Scaffold video spec", ...READ_ONLY_ANNOTATIONS },
3022
+ ...meta("scaffold_video_spec")
768
3023
  },
769
- async (args) => {
770
- const spec = scaffoldVideoSpec(args);
771
- return result(
772
- { spec, filename: `${String(spec.id)}.video.json` },
773
- "Starter VideoSpec created. Replace placeholder copy and media."
774
- );
775
- }
3024
+ async (args) => send(
3025
+ "scaffold_video_spec",
3026
+ runScaffoldVideoSpecTool(args, paired, options.acceptedPreview)
3027
+ )
776
3028
  );
777
3029
  server.registerTool(
778
3030
  "get_render_instructions",
779
3031
  {
780
3032
  title: "Get local render instructions",
781
- description: "Return clone, install, validate, preview, and render commands.",
3033
+ description: "Return the clone, install, validate, preview, render, and QA workflow.",
782
3034
  inputSchema: {
783
- client: z3.enum(["codex", "claude-code", "manual"]).default("manual")
3035
+ client: z5.enum(["codex", "claude-code", "manual"]).default("manual").describe(
3036
+ "Who will run the workflow. It changes only the guidance text. Defaults to manual."
3037
+ )
784
3038
  },
785
- annotations
3039
+ annotations: {
3040
+ title: "Get render instructions",
3041
+ ...READ_ONLY_ANNOTATIONS
3042
+ },
3043
+ ...meta("get_render_instructions")
786
3044
  },
787
- async ({ client }) => {
788
- const commands = [
789
- `git clone ${TEMPLATE_REPOSITORY}.git`,
790
- "cd remotion-templates",
791
- "npm install",
792
- `# Generate one narration paragraph per scene at ${VOICE_STUDIO_URL}`,
793
- "npm run video:timing -- path/to/video.video.json --audio public/generated/narration.wav --manifest path/to/narration.timing.json",
794
- "npm run video:validate -- path/to/video.video.json",
795
- "npm run video:preview -- path/to/video.video.json",
796
- "npm run video:render -- path/to/video.video.json",
797
- "npm run video:qa -- path/to/video.video.json path/to/video.mp4"
798
- ];
799
- return result(
800
- { repository: TEMPLATE_REPOSITORY, client, commands },
801
- commands.join("\n")
802
- );
803
- }
3045
+ async (args) => send(
3046
+ "get_render_instructions",
3047
+ runGetRenderInstructionsTool(args, { voiceStudio: options.voiceStudio })
3048
+ )
804
3049
  );
805
3050
  server.registerTool(
806
3051
  "diagnose_render_error",
807
3052
  {
808
3053
  title: "Diagnose render error",
809
- description: "Classify a local validation or render error.",
810
- inputSchema: { errorText: z3.string().min(1).max(1e4) },
3054
+ description: "Classify a local validation or render error and return a safe next step.",
3055
+ inputSchema: {
3056
+ errorText: z5.string().min(1).max(1e4).describe("The validation or render error output to classify.")
3057
+ },
3058
+ annotations: { title: "Diagnose render error", ...READ_ONLY_ANNOTATIONS },
3059
+ ...meta("diagnose_render_error")
3060
+ },
3061
+ async (args) => send("diagnose_render_error", runDiagnoseRenderErrorTool(args))
3062
+ );
3063
+ }
3064
+
3065
+ // src/public-templates.ts
3066
+ var TEMPLATE_ENDPOINT = "https://instavar.com/api/mcp/templates";
3067
+ var annotations = {
3068
+ readOnlyHint: true,
3069
+ openWorldHint: false,
3070
+ destructiveHint: false
3071
+ };
3072
+ function result2(value, summary) {
3073
+ return {
3074
+ structuredContent: value,
3075
+ content: [{ type: "text", text: summary }]
3076
+ };
3077
+ }
3078
+ function registerPublicTemplateTools(server, options = {}) {
3079
+ const paired = options.pairedTemplates ?? pairedTemplatesEnabled();
3080
+ registerCreativeGuides(server);
3081
+ registerPairedAnnouncement(server, { pairedCatalogue: paired });
3082
+ if (paired) registerPairedTemplates(server);
3083
+ server.registerTool(
3084
+ "get_capabilities",
3085
+ {
3086
+ title: "Get video capabilities",
3087
+ description: "Call first. Reports free local features and optional account features.",
3088
+ inputSchema: {},
811
3089
  annotations
812
3090
  },
813
- async ({ errorText }) => {
814
- const text2 = errorText.toLowerCase();
815
- const code = text2.includes("enoent") || text2.includes("not found") ? "missing-file" : text2.includes("ffmpeg") || text2.includes("codec") ? "media-codec" : text2.includes("schema") || text2.includes("invalid") || text2.includes("zod") ? "invalid-video-spec" : text2.includes("chrome") || text2.includes("browser") ? "browser-runtime" : "unknown-render-error";
816
- return result(
817
- {
818
- code,
819
- nextStep: "Run validation first, confirm Node 22 or newer, and retry with the smallest included example."
3091
+ async () => result2(
3092
+ {
3093
+ authentication: "optional",
3094
+ apiKeyConfigured: Boolean(process.env.INSTAVAR_API_KEY?.trim()),
3095
+ repository: TEMPLATE_REPOSITORY,
3096
+ endpoint: TEMPLATE_ENDPOINT,
3097
+ creativeGuides: CREATIVE_GUIDE_INDEX,
3098
+ pairedAnnouncement: PAIRED_ANNOUNCEMENT_CAPABILITY,
3099
+ ...paired ? { pairedTemplates: PAIRED_TEMPLATE_CAPABILITY } : {},
3100
+ localFeatures: [
3101
+ "template discovery",
3102
+ "three-beat storyboard proposals",
3103
+ "VideoSpec schema and examples",
3104
+ "deterministic scaffolding",
3105
+ "editorial carousel discovery and deterministic deck scaffolding",
3106
+ "local render instructions",
3107
+ "render error diagnosis",
3108
+ "keyless on-device narration with scene timing",
3109
+ "every-scene preview frames",
3110
+ "post-render audible-audio verification"
3111
+ ],
3112
+ narration: {
3113
+ url: VOICE_STUDIO_URL,
3114
+ cost: "free",
3115
+ apiKeyRequired: false,
3116
+ guidance: "Write one paragraph per scene. Download the WAV and timing manifest, then apply both before rendering."
820
3117
  },
821
- `Diagnosis: ${code}.`
822
- );
823
- }
3118
+ accountFeatures: [
3119
+ "managed rendering and storage",
3120
+ "workflow review and approval",
3121
+ "social publishing and metrics"
3122
+ ]
3123
+ },
3124
+ process.env.INSTAVAR_API_KEY?.trim() ? "Free local tools and authenticated Instavar Studio tools are available." : "Free local tools are available. Add INSTAVAR_API_KEY to unlock hosted Studio tools."
3125
+ )
824
3126
  );
3127
+ registerSharedTemplateTools(server, { pairedTemplates: paired });
825
3128
  }
826
3129
 
827
3130
  // src/tools.ts
828
- import { z as z6 } from "zod";
3131
+ import { z as z8 } from "zod";
829
3132
 
830
3133
  // src/http.ts
831
3134
  import { randomUUID } from "crypto";
@@ -871,11 +3174,11 @@ function requestFailure(error) {
871
3174
  return error instanceof Error ? error.message : String(error);
872
3175
  }
873
3176
  async function parse(res) {
874
- const text2 = await res.text();
3177
+ const text3 = await res.text();
875
3178
  try {
876
- return JSON.parse(text2);
3179
+ return JSON.parse(text3);
877
3180
  } catch {
878
- return text2;
3181
+ return text3;
879
3182
  }
880
3183
  }
881
3184
  async function apiGet(path) {
@@ -923,15 +3226,15 @@ ${open}
923
3226
  ${json}
924
3227
  ${close}`;
925
3228
  }
926
- function toToolResult(result2) {
3229
+ function toToolResult(result3) {
927
3230
  return {
928
3231
  content: [
929
3232
  {
930
3233
  type: "text",
931
- text: fenceForModel(JSON.stringify(result2.body, null, 2))
3234
+ text: fenceForModel(JSON.stringify(result3.body, null, 2))
932
3235
  }
933
3236
  ],
934
- isError: !result2.ok
3237
+ isError: !result3.ok
935
3238
  };
936
3239
  }
937
3240
  async function runTool(fn) {
@@ -951,7 +3254,7 @@ async function runTool(fn) {
951
3254
  }
952
3255
 
953
3256
  // src/brief-schema.ts
954
- import { z as z4 } from "zod";
3257
+ import { z as z6 } from "zod";
955
3258
  var PUBLISH_TARGETS = [
956
3259
  "linkedin",
957
3260
  "x",
@@ -983,16 +3286,16 @@ var REFERENCE_ROLES = [
983
3286
  "environment",
984
3287
  "style"
985
3288
  ];
986
- var optionalDirectionText = z4.string().trim().min(1).max(500).optional();
987
- var visualDirectionSchema = z4.object({
3289
+ var optionalDirectionText = z6.string().trim().min(1).max(500).optional();
3290
+ var visualDirectionSchema = z6.object({
988
3291
  communicationJob: optionalDirectionText,
989
3292
  emotionalTarget: optionalDirectionText,
990
- attentionPath: z4.object({
3293
+ attentionPath: z6.object({
991
3294
  first: optionalDirectionText,
992
3295
  next: optionalDirectionText,
993
3296
  proof: optionalDirectionText
994
3297
  }).optional(),
995
- visualLanguage: z4.object({
3298
+ visualLanguage: z6.object({
996
3299
  space: optionalDirectionText,
997
3300
  line: optionalDirectionText,
998
3301
  shape: optionalDirectionText,
@@ -1001,24 +3304,24 @@ var visualDirectionSchema = z4.object({
1001
3304
  movement: optionalDirectionText,
1002
3305
  rhythm: optionalDirectionText
1003
3306
  }).optional(),
1004
- camera: z4.object({
3307
+ camera: z6.object({
1005
3308
  shotSize: optionalDirectionText,
1006
3309
  angle: optionalDirectionText,
1007
3310
  movement: optionalDirectionText,
1008
3311
  lens: optionalDirectionText
1009
3312
  }).optional()
1010
3313
  });
1011
- var generationContractSchema = z4.object({
1012
- globalInvariants: z4.array(z4.string().trim().min(1).max(300)).max(20).optional(),
1013
- shotDelta: z4.string().trim().min(1).max(500).optional(),
1014
- referenceBindings: z4.array(
1015
- z4.object({
1016
- assetId: z4.string().trim().min(1).max(200),
1017
- roles: z4.array(z4.enum(REFERENCE_ROLES)).min(1).max(7)
3314
+ var generationContractSchema = z6.object({
3315
+ globalInvariants: z6.array(z6.string().trim().min(1).max(300)).max(20).optional(),
3316
+ shotDelta: z6.string().trim().min(1).max(500).optional(),
3317
+ referenceBindings: z6.array(
3318
+ z6.object({
3319
+ assetId: z6.string().trim().min(1).max(200),
3320
+ roles: z6.array(z6.enum(REFERENCE_ROLES)).min(1).max(7)
1018
3321
  })
1019
3322
  ).max(20).optional(),
1020
- prohibitedChanges: z4.array(z4.string().trim().min(1).max(300)).max(20).optional(),
1021
- reviewCriteria: z4.array(z4.string().trim().min(1).max(300)).max(20).optional()
3323
+ prohibitedChanges: z6.array(z6.string().trim().min(1).max(300)).max(20).optional(),
3324
+ reviewCriteria: z6.array(z6.string().trim().min(1).max(300)).max(20).optional()
1022
3325
  });
1023
3326
  var REGION_NAMES = [
1024
3327
  "background",
@@ -1035,55 +3338,55 @@ var ASSET_ROLES = [
1035
3338
  "lower-third",
1036
3339
  "diagram-node"
1037
3340
  ];
1038
- var assetSlotStyleSchema = z4.object({
1039
- opacity: z4.number().min(0).max(1).optional(),
1040
- fit: z4.enum(["cover", "contain"]).optional(),
1041
- z: z4.number().optional()
3341
+ var assetSlotStyleSchema = z6.object({
3342
+ opacity: z6.number().min(0).max(1).optional(),
3343
+ fit: z6.enum(["cover", "contain"]).optional(),
3344
+ z: z6.number().optional()
1042
3345
  }).strict();
1043
- var assetSlotSchema = z4.object({
1044
- id: z4.string().min(1),
1045
- sceneId: z4.string().min(1).optional(),
1046
- region: z4.enum(REGION_NAMES),
1047
- role: z4.enum(ASSET_ROLES),
1048
- kind: z4.enum(["image", "video"]),
1049
- source: z4.enum(["auto", "stock", "generate"]),
1050
- intent: z4.string(),
3346
+ var assetSlotSchema = z6.object({
3347
+ id: z6.string().min(1),
3348
+ sceneId: z6.string().min(1).optional(),
3349
+ region: z6.enum(REGION_NAMES),
3350
+ role: z6.enum(ASSET_ROLES),
3351
+ kind: z6.enum(["image", "video"]),
3352
+ source: z6.enum(["auto", "stock", "generate"]),
3353
+ intent: z6.string(),
1051
3354
  style: assetSlotStyleSchema.optional(),
1052
- timing: z4.object({
1053
- fromPct: z4.number().min(0).max(1).optional(),
1054
- toPct: z4.number().min(0).max(1).optional()
3355
+ timing: z6.object({
3356
+ fromPct: z6.number().min(0).max(1).optional(),
3357
+ toPct: z6.number().min(0).max(1).optional()
1055
3358
  }).strict().optional(),
1056
- url: z4.string().url().optional()
3359
+ url: z6.string().url().optional()
1057
3360
  }).strict();
1058
- var briefStepSchema = z4.object({
1059
- label: z4.string(),
1060
- latex: z4.string().optional(),
1061
- explanation: z4.string().optional()
3361
+ var briefStepSchema = z6.object({
3362
+ label: z6.string(),
3363
+ latex: z6.string().optional(),
3364
+ explanation: z6.string().optional()
1062
3365
  });
1063
- var briefAudioLayerSchema = z4.object({
1064
- id: z4.string().min(1),
1065
- src: z4.string().url(),
1066
- startFrame: z4.number().int().nonnegative().default(0),
1067
- durationInFrames: z4.number().int().positive().optional(),
1068
- volume: z4.number().min(0).max(1).default(1),
1069
- fadeFrames: z4.number().int().nonnegative().default(0),
1070
- role: z4.enum(["music", "foley", "transition", "effect"])
3366
+ var briefAudioLayerSchema = z6.object({
3367
+ id: z6.string().min(1),
3368
+ src: z6.string().url(),
3369
+ startFrame: z6.number().int().nonnegative().default(0),
3370
+ durationInFrames: z6.number().int().positive().optional(),
3371
+ volume: z6.number().min(0).max(1).default(1),
3372
+ fadeFrames: z6.number().int().nonnegative().default(0),
3373
+ role: z6.enum(["music", "foley", "transition", "effect"])
1071
3374
  });
1072
- var protectedRegionEffectSchema = z4.object({
1073
- id: z4.string().min(1).max(80),
1074
- kind: z4.literal("border-glint"),
1075
- coordinateSpace: z4.literal("output-frame-v1").default("output-frame-v1"),
1076
- region: z4.object({
1077
- leftPercent: z4.number().min(0).max(100),
1078
- topPercent: z4.number().min(0).max(100),
1079
- widthPercent: z4.number().positive().max(100),
1080
- heightPercent: z4.number().positive().max(100)
3375
+ var protectedRegionEffectSchema = z6.object({
3376
+ id: z6.string().min(1).max(80),
3377
+ kind: z6.literal("border-glint"),
3378
+ coordinateSpace: z6.literal("output-frame-v1").default("output-frame-v1"),
3379
+ region: z6.object({
3380
+ leftPercent: z6.number().min(0).max(100),
3381
+ topPercent: z6.number().min(0).max(100),
3382
+ widthPercent: z6.number().positive().max(100),
3383
+ heightPercent: z6.number().positive().max(100)
1081
3384
  }),
1082
- startFrame: z4.number().int().nonnegative().default(0),
1083
- endFrame: z4.number().int().positive(),
1084
- speedUpFrame: z4.number().int().nonnegative().optional(),
1085
- color: z4.string().max(64).default("#ffffff"),
1086
- thicknessPercent: z4.number().positive().max(20).default(3)
3385
+ startFrame: z6.number().int().nonnegative().default(0),
3386
+ endFrame: z6.number().int().positive(),
3387
+ speedUpFrame: z6.number().int().nonnegative().optional(),
3388
+ color: z6.string().max(64).default("#ffffff"),
3389
+ thicknessPercent: z6.number().positive().max(20).default(3)
1087
3390
  }).superRefine((effect2, context) => {
1088
3391
  if (effect2.region.leftPercent + effect2.region.widthPercent > 100) {
1089
3392
  context.addIssue({
@@ -1114,13 +3417,13 @@ var protectedRegionEffectSchema = z4.object({
1114
3417
  });
1115
3418
  }
1116
3419
  });
1117
- var beatVisualRequestSchema = z4.object({
1118
- intent: z4.string().trim().min(1).optional(),
1119
- media: z4.enum(["still", "motion"]).default("still"),
1120
- source: z4.enum(["auto", "stock", "generate"]).default("auto")
3420
+ var beatVisualRequestSchema = z6.object({
3421
+ intent: z6.string().trim().min(1).optional(),
3422
+ media: z6.enum(["still", "motion"]).default("still"),
3423
+ source: z6.enum(["auto", "stock", "generate"]).default("auto")
1121
3424
  }).strict();
1122
- var briefSceneSchema = z4.object({
1123
- type: z4.enum([
3425
+ var briefSceneSchema = z6.object({
3426
+ type: z6.enum([
1124
3427
  "hero",
1125
3428
  "points",
1126
3429
  "equation",
@@ -1143,106 +3446,106 @@ var briefSceneSchema = z4.object({
1143
3446
  "image-window",
1144
3447
  "custom"
1145
3448
  ]),
1146
- layoutPreset: z4.literal("dark-cafe-announcement").optional().describe(
3449
+ layoutPreset: z6.literal("dark-cafe-announcement").optional().describe(
1147
3450
  "Built-in portrait coffee illustration with title, subtitle body and text CTA. Use only on a custom scene after the user selects this design. No generated assets."
1148
3451
  ),
1149
- durationInFrames: z4.number().optional(),
1150
- narrationText: z4.string().optional(),
3452
+ durationInFrames: z6.number().optional(),
3453
+ narrationText: z6.string().optional(),
1151
3454
  visualResolution: beatVisualRequestSchema.optional(),
1152
- title: z4.string().optional(),
1153
- subtitle: z4.string().optional(),
1154
- text: z4.string().optional(),
1155
- points: z4.array(z4.string()).optional(),
1156
- latex: z4.string().optional(),
1157
- value: z4.union([z4.string(), z4.number()]).optional(),
1158
- max: z4.number().optional(),
1159
- label: z4.string().optional(),
1160
- unit: z4.string().optional(),
1161
- prefix: z4.string().optional(),
1162
- suffix: z4.string().optional(),
1163
- decimals: z4.number().optional(),
1164
- color: z4.string().optional(),
1165
- tone: z4.string().optional(),
1166
- iconKey: z4.string().optional(),
1167
- stepNumber: z4.number().optional(),
1168
- totalSteps: z4.number().optional(),
1169
- items: z4.array(z4.object({ label: z4.string(), value: z4.number() })).optional(),
1170
- src: z4.string().optional(),
1171
- caption: z4.string().optional(),
3455
+ title: z6.string().optional(),
3456
+ subtitle: z6.string().optional(),
3457
+ text: z6.string().optional(),
3458
+ points: z6.array(z6.string()).optional(),
3459
+ latex: z6.string().optional(),
3460
+ value: z6.union([z6.string(), z6.number()]).optional(),
3461
+ max: z6.number().optional(),
3462
+ label: z6.string().optional(),
3463
+ unit: z6.string().optional(),
3464
+ prefix: z6.string().optional(),
3465
+ suffix: z6.string().optional(),
3466
+ decimals: z6.number().optional(),
3467
+ color: z6.string().optional(),
3468
+ tone: z6.string().optional(),
3469
+ iconKey: z6.string().optional(),
3470
+ stepNumber: z6.number().optional(),
3471
+ totalSteps: z6.number().optional(),
3472
+ items: z6.array(z6.object({ label: z6.string(), value: z6.number() })).optional(),
3473
+ src: z6.string().optional(),
3474
+ caption: z6.string().optional(),
1172
3475
  // A-roll generation (video-window scenes): source "generate" triggers
1173
3476
  // flag-gated WaveSpeed image/video gen server-side from generatePrompt;
1174
3477
  // "url" (default) uses src as-is. Kept in sync with the app's
1175
3478
  // briefSceneSchema - see the parity test in the app suite.
1176
- source: z4.enum(["url", "generate"]).optional(),
1177
- generatePrompt: z4.string().optional(),
3479
+ source: z6.enum(["url", "generate"]).optional(),
3480
+ generatePrompt: z6.string().optional(),
1178
3481
  generationContract: generationContractSchema.optional(),
1179
- trimStartSeconds: z4.number().nonnegative().optional(),
1180
- trimEndSeconds: z4.number().positive().optional(),
1181
- playbackRate: z4.number().min(0.25).max(8).optional(),
1182
- objectFit: z4.enum(["cover", "contain"]).optional(),
1183
- objectPosition: z4.string().optional(),
1184
- scaleFrom: z4.number().min(0.5).max(2).optional(),
1185
- scaleTo: z4.number().min(0.5).max(2).optional(),
1186
- panFromX: z4.number().min(-50).max(50).optional(),
1187
- panToX: z4.number().min(-50).max(50).optional(),
1188
- panFromY: z4.number().min(-50).max(50).optional(),
1189
- panToY: z4.number().min(-50).max(50).optional(),
1190
- routeFrom: z4.string().optional(),
1191
- routeTo: z4.string().optional(),
1192
- routeLabel: z4.string().optional(),
1193
- overlayKind: z4.enum(["none", "hook", "stage", "end-card"]).optional(),
1194
- overlayPosition: z4.enum(["center", "top", "bottom"]).optional(),
1195
- accentColor: z4.string().optional(),
1196
- overlayBackgroundColor: z4.string().optional(),
1197
- cutFlash: z4.boolean().optional(),
1198
- muted: z4.boolean().optional(),
1199
- protectedRegionEffects: z4.array(protectedRegionEffectSchema).max(4).optional(),
1200
- flashAtFrame: z4.number().int().nonnegative().optional(),
1201
- flashDurationFrames: z4.number().int().positive().max(15).optional()
3482
+ trimStartSeconds: z6.number().nonnegative().optional(),
3483
+ trimEndSeconds: z6.number().positive().optional(),
3484
+ playbackRate: z6.number().min(0.25).max(8).optional(),
3485
+ objectFit: z6.enum(["cover", "contain"]).optional(),
3486
+ objectPosition: z6.string().optional(),
3487
+ scaleFrom: z6.number().min(0.5).max(2).optional(),
3488
+ scaleTo: z6.number().min(0.5).max(2).optional(),
3489
+ panFromX: z6.number().min(-50).max(50).optional(),
3490
+ panToX: z6.number().min(-50).max(50).optional(),
3491
+ panFromY: z6.number().min(-50).max(50).optional(),
3492
+ panToY: z6.number().min(-50).max(50).optional(),
3493
+ routeFrom: z6.string().optional(),
3494
+ routeTo: z6.string().optional(),
3495
+ routeLabel: z6.string().optional(),
3496
+ overlayKind: z6.enum(["none", "hook", "stage", "end-card"]).optional(),
3497
+ overlayPosition: z6.enum(["center", "top", "bottom"]).optional(),
3498
+ accentColor: z6.string().optional(),
3499
+ overlayBackgroundColor: z6.string().optional(),
3500
+ cutFlash: z6.boolean().optional(),
3501
+ muted: z6.boolean().optional(),
3502
+ protectedRegionEffects: z6.array(protectedRegionEffectSchema).max(4).optional(),
3503
+ flashAtFrame: z6.number().int().nonnegative().optional(),
3504
+ flashDurationFrames: z6.number().int().positive().max(15).optional()
1202
3505
  });
1203
- var directionsBriefSchema = z4.object({
1204
- subtitle: z4.string().optional(),
1205
- unitLabel: z4.string().optional(),
1206
- distanceTimeChip: z4.string().optional(),
1207
- clips: z4.array(
1208
- z4.object({
1209
- src: z4.string(),
1210
- trimStartSeconds: z4.number().optional(),
1211
- trimEndSeconds: z4.number(),
1212
- speed: z4.number().optional(),
1213
- mirrorFlip: z4.boolean().optional()
3506
+ var directionsBriefSchema = z6.object({
3507
+ subtitle: z6.string().optional(),
3508
+ unitLabel: z6.string().optional(),
3509
+ distanceTimeChip: z6.string().optional(),
3510
+ clips: z6.array(
3511
+ z6.object({
3512
+ src: z6.string(),
3513
+ trimStartSeconds: z6.number().optional(),
3514
+ trimEndSeconds: z6.number(),
3515
+ speed: z6.number().optional(),
3516
+ mirrorFlip: z6.boolean().optional()
1214
3517
  })
1215
3518
  ).min(1),
1216
- cues: z4.array(
1217
- z4.object({
1218
- atSeconds: z4.number(),
1219
- text: z4.string(),
1220
- arrow: z4.enum(["left", "right", "forward"]).optional(),
1221
- step: z4.number().optional()
3519
+ cues: z6.array(
3520
+ z6.object({
3521
+ atSeconds: z6.number(),
3522
+ text: z6.string(),
3523
+ arrow: z6.enum(["left", "right", "forward"]).optional(),
3524
+ step: z6.number().optional()
1222
3525
  })
1223
3526
  ),
1224
- outro: z4.object({
1225
- heading: z4.string().optional(),
1226
- body: z4.array(z4.string()).optional(),
1227
- seconds: z4.number().optional()
3527
+ outro: z6.object({
3528
+ heading: z6.string().optional(),
3529
+ body: z6.array(z6.string()).optional(),
3530
+ seconds: z6.number().optional()
1228
3531
  }).optional(),
1229
- music: z4.object({
1230
- perSegment: z4.array(
1231
- z4.object({
1232
- src: z4.string(),
1233
- clipIndexStart: z4.number().optional(),
1234
- hotOffsetSeconds: z4.number().optional(),
1235
- volume: z4.number().optional()
3532
+ music: z6.object({
3533
+ perSegment: z6.array(
3534
+ z6.object({
3535
+ src: z6.string(),
3536
+ clipIndexStart: z6.number().optional(),
3537
+ hotOffsetSeconds: z6.number().optional(),
3538
+ volume: z6.number().optional()
1236
3539
  })
1237
3540
  ).optional(),
1238
- crossfadeSeconds: z4.number().optional()
3541
+ crossfadeSeconds: z6.number().optional()
1239
3542
  }).optional()
1240
3543
  });
1241
3544
  var PERSON_CONSENT_WORDING_VERSION = "2026-10-19.1";
1242
3545
  var PERSON_CONSENT_WORDING = "I have permission from everyone shown, and no one shown is under 18 unless I am their parent or guardian.";
1243
- var personConsentSchema = z4.object({
1244
- confirmed: z4.literal(true).describe("Must be true: the caller confirms the declaration below."),
1245
- wordingVersion: z4.string().describe(
3546
+ var personConsentSchema = z6.object({
3547
+ confirmed: z6.literal(true).describe("Must be true: the caller confirms the declaration below."),
3548
+ wordingVersion: z6.string().describe(
1246
3549
  `Version of the declaration the caller confirmed. Current: ${PERSON_CONSENT_WORDING_VERSION}.`
1247
3550
  )
1248
3551
  }).strict().describe(
@@ -1252,79 +3555,79 @@ var LIKENESS_WARNING_WORDING_VERSION = "2026-10-19.1";
1252
3555
  var LIKENESS_WARNING_WORDING = "This photo seems to show someone other than you. Only continue if you have their permission.";
1253
3556
  var LIKENESS_MINOR_WARNING_WORDING_VERSION = "2026-10-19.1";
1254
3557
  var LIKENESS_MINOR_WARNING_WORDING = "This may show someone under 18. Continue only if you are their parent or guardian, or have their parent or guardian's permission.";
1255
- var likenessAcknowledgementSchema = z4.object({
1256
- confirmed: z4.literal(true).describe("Must be true: the user accepted the warning below."),
1257
- kind: z4.enum(["other_person", "guardian"]).optional().describe(
3558
+ var likenessAcknowledgementSchema = z6.object({
3559
+ confirmed: z6.literal(true).describe("Must be true: the user accepted the warning below."),
3560
+ kind: z6.enum(["other_person", "guardian"]).optional().describe(
1258
3561
  `Which warning was accepted. "other_person" (default): "${LIKENESS_WARNING_WORDING}" "guardian": "${LIKENESS_MINOR_WARNING_WORDING}"`
1259
3562
  ),
1260
- wordingVersion: z4.string().describe(
3563
+ wordingVersion: z6.string().describe(
1261
3564
  `Version of the warning accepted. Current: other_person ${LIKENESS_WARNING_WORDING_VERSION}, guardian ${LIKENESS_MINOR_WARNING_WORDING_VERSION}.`
1262
3565
  )
1263
3566
  }).strict().describe(
1264
3567
  "Optional. Send only after the user has seen and accepted the warning. Without it, a job that animates an uploaded photo of someone other than the account holder stops with likeness_acknowledgement_required, or likeness_guardian_confirmation_required when the person may be under 18."
1265
3568
  );
1266
3569
  var createBriefShape = {
1267
- title: z4.string().min(1).max(120).describe("Short title (max 120 chars)"),
1268
- script: z4.string().min(1).describe("Full narration script (sent to TTS)"),
1269
- caption: z4.string().min(1).describe("Social caption with hooks, hashtags, CTA"),
1270
- publishTarget: z4.enum(PUBLISH_TARGETS).describe("Target social platform"),
1271
- publishTargets: z4.array(z4.enum(PUBLISH_TARGETS)).max(9).optional().describe("All allowed social destinations for this video"),
1272
- objective: z4.enum(BRIEF_OBJECTIVES).describe("Content objective (drives composition routing)"),
1273
- targetDurationSeconds: z4.number().int().min(5).max(600).optional().describe("Requested final video duration in seconds"),
1274
- narrationMode: z4.enum(["tts", "off"]).optional().describe("Disable synthesized narration for source-audio or silent work"),
1275
- lessonTitle: z4.string().optional().describe("Display title rendered inside the video"),
3570
+ title: z6.string().min(1).max(120).describe("Short title (max 120 chars)"),
3571
+ script: z6.string().min(1).describe("Full narration script (sent to TTS)"),
3572
+ caption: z6.string().min(1).describe("Social caption with hooks, hashtags, CTA"),
3573
+ publishTarget: z6.enum(PUBLISH_TARGETS).describe("Target social platform"),
3574
+ publishTargets: z6.array(z6.enum(PUBLISH_TARGETS)).max(9).optional().describe("All allowed social destinations for this video"),
3575
+ objective: z6.enum(BRIEF_OBJECTIVES).describe("Content objective (drives composition routing)"),
3576
+ targetDurationSeconds: z6.number().int().min(5).max(600).optional().describe("Requested final video duration in seconds"),
3577
+ narrationMode: z6.enum(["tts", "off"]).optional().describe("Disable synthesized narration for source-audio or silent work"),
3578
+ lessonTitle: z6.string().optional().describe("Display title rendered inside the video"),
1276
3579
  visualDirection: visualDirectionSchema.optional().describe(
1277
3580
  "Whole-video communication, attention, visual-language, and camera direction."
1278
3581
  ),
1279
- steps: z4.array(briefStepSchema).optional().describe("Structured steps for educational content (LaTeX)"),
1280
- scenes: z4.array(briefSceneSchema).optional().describe("Scene graph for the UniversalVideo composition"),
3582
+ steps: z6.array(briefStepSchema).optional().describe("Structured steps for educational content (LaTeX)"),
3583
+ scenes: z6.array(briefSceneSchema).optional().describe("Scene graph for the UniversalVideo composition"),
1281
3584
  // No zod .default() here: a default would materialize into the parsed tool
1282
3585
  // arguments and relay to /api/v1/jobs as if the caller stated it, corrupting
1283
3586
  // the resolution provenance the API echoes back. Unset must stay absent;
1284
3587
  // the API re-applies 9:16 server-side.
1285
- aspectRatio: z4.enum(ASPECT_RATIOS).optional().describe("Aspect ratio (defaults to 9:16 when omitted)"),
1286
- compositionId: z4.string().optional().describe("Remotion composition ID override (advanced)"),
1287
- voiceId: z4.string().optional().describe(
3588
+ aspectRatio: z6.enum(ASPECT_RATIOS).optional().describe("Aspect ratio (defaults to 9:16 when omitted)"),
3589
+ compositionId: z6.string().optional().describe("Remotion composition ID override (advanced)"),
3590
+ voiceId: z6.string().optional().describe(
1288
3591
  "TTS narrator voice ID. Unknown IDs are rejected before rendering; when omitted, the org's saved voice preference or the system default is used and reported in the response's resolution block."
1289
3592
  ),
1290
3593
  directions: directionsBriefSchema.optional().describe(
1291
3594
  "DirectionsWalkthrough 'find-us' payload: source clips (legs), decision-point cues on the realtime walk timeline, outro, and optional music. Set compositionId 'DirectionsWalkthrough' (or objective 'directions')."
1292
3595
  ),
1293
- assetSlots: z4.array(assetSlotSchema).optional().describe(
3596
+ assetSlots: z6.array(assetSlotSchema).optional().describe(
1294
3597
  "Optional storyboard asset slots: region-placed image/video assets or placeholders attached to the whole video or a specific scene."
1295
3598
  ),
1296
- audioLayers: z4.array(briefAudioLayerSchema).optional().describe("Optional typed music, Foley, transition, and effect layers."),
3599
+ audioLayers: z6.array(briefAudioLayerSchema).optional().describe("Optional typed music, Foley, transition, and effect layers."),
1297
3600
  personConsent: personConsentSchema.optional(),
1298
3601
  likenessAcknowledgement: likenessAcknowledgementSchema.optional()
1299
3602
  };
1300
3603
  var editBriefShape = {
1301
- jobId: z4.string().uuid().describe("The job to edit"),
3604
+ jobId: z6.string().uuid().describe("The job to edit"),
1302
3605
  personConsent: personConsentSchema.optional(),
1303
3606
  likenessAcknowledgement: likenessAcknowledgementSchema.optional(),
1304
- title: z4.string().optional().describe("Updated title"),
1305
- script: z4.string().optional().describe("Updated narration script"),
1306
- caption: z4.string().optional().describe("Updated social caption"),
1307
- lessonTitle: z4.string().optional().describe("Updated lesson title"),
1308
- narrationMode: z4.enum(["tts", "off"]).optional().describe("Updated synthesized narration mode"),
3607
+ title: z6.string().optional().describe("Updated title"),
3608
+ script: z6.string().optional().describe("Updated narration script"),
3609
+ caption: z6.string().optional().describe("Updated social caption"),
3610
+ lessonTitle: z6.string().optional().describe("Updated lesson title"),
3611
+ narrationMode: z6.enum(["tts", "off"]).optional().describe("Updated synthesized narration mode"),
1309
3612
  visualDirection: visualDirectionSchema.optional().describe("Updated whole-video visual direction"),
1310
- steps: z4.array(briefStepSchema).optional().describe("Updated steps (replaces the array)"),
1311
- scenes: z4.array(briefSceneSchema).optional().describe("Updated scenes (replaces the array)"),
1312
- aspectRatio: z4.enum(ASPECT_RATIOS).optional().describe("Updated aspect ratio"),
1313
- objective: z4.enum(BRIEF_OBJECTIVES).optional().describe(
3613
+ steps: z6.array(briefStepSchema).optional().describe("Updated steps (replaces the array)"),
3614
+ scenes: z6.array(briefSceneSchema).optional().describe("Updated scenes (replaces the array)"),
3615
+ aspectRatio: z6.enum(ASPECT_RATIOS).optional().describe("Updated aspect ratio"),
3616
+ objective: z6.enum(BRIEF_OBJECTIVES).optional().describe(
1314
3617
  "Updated content objective. Re-routes the composition and triggers a re-render."
1315
3618
  ),
1316
- publishTarget: z4.enum(PUBLISH_TARGETS).optional().describe(
3619
+ publishTarget: z6.enum(PUBLISH_TARGETS).optional().describe(
1317
3620
  "Updated target social platform. Distribution metadata only - does not trigger a re-render."
1318
3621
  ),
1319
- publishTargets: z4.array(z4.enum(PUBLISH_TARGETS)).max(9).optional().describe("Replacement allowed social destination list"),
1320
- targetDurationSeconds: z4.number().int().min(5).max(600).optional().describe("Updated final video duration in seconds"),
1321
- voiceId: z4.string().optional().describe(
3622
+ publishTargets: z6.array(z6.enum(PUBLISH_TARGETS)).max(9).optional().describe("Replacement allowed social destination list"),
3623
+ targetDurationSeconds: z6.number().int().min(5).max(600).optional().describe("Updated final video duration in seconds"),
3624
+ voiceId: z6.string().optional().describe(
1322
3625
  "Updated TTS narrator voice ID. Triggers a re-render with the new voice."
1323
3626
  ),
1324
- assetSlots: z4.array(assetSlotSchema).optional().describe(
3627
+ assetSlots: z6.array(assetSlotSchema).optional().describe(
1325
3628
  "Replacement storyboard asset slots. Omit to preserve existing slots; pass [] to clear them."
1326
3629
  ),
1327
- audioLayers: z4.array(briefAudioLayerSchema).optional().describe(
3630
+ audioLayers: z6.array(briefAudioLayerSchema).optional().describe(
1328
3631
  "Replacement typed audio layers. Omit to preserve existing layers; pass [] to clear them."
1329
3632
  )
1330
3633
  };
@@ -1361,7 +3664,7 @@ function verificationMatches(verifications, pattern) {
1361
3664
  }
1362
3665
  function buildRenderDiagnosticSnapshot(params) {
1363
3666
  const failed = [params.jobStatus, params.videoState].find(
1364
- (result2) => !result2.ok
3667
+ (result3) => !result3.ok
1365
3668
  );
1366
3669
  if (failed) return failed;
1367
3670
  const status = record(params.jobStatus.body);
@@ -1432,165 +3735,165 @@ function buildRenderDiagnosticSnapshot(params) {
1432
3735
  }
1433
3736
 
1434
3737
  // src/design-action-schema.ts
1435
- import { z as z5 } from "zod";
1436
- var id = z5.string().min(1).max(120);
1437
- var point = z5.object({ x: z5.number().min(0).max(1), y: z5.number().min(0).max(1) }).strict();
1438
- var polygonShape = z5.object({
1439
- kind: z5.literal("polygon"),
1440
- points: z5.array(point).min(3).max(512)
3738
+ import { z as z7 } from "zod";
3739
+ var id = z7.string().min(1).max(120);
3740
+ var point = z7.object({ x: z7.number().min(0).max(1), y: z7.number().min(0).max(1) }).strict();
3741
+ var polygonShape = z7.object({
3742
+ kind: z7.literal("polygon"),
3743
+ points: z7.array(point).min(3).max(512)
1441
3744
  }).strict();
1442
- var rasterShape = z5.object({
1443
- kind: z5.literal("raster"),
1444
- source: z5.object({
3745
+ var rasterShape = z7.object({
3746
+ kind: z7.literal("raster"),
3747
+ source: z7.object({
1445
3748
  assetId: id,
1446
- expectedSha256: z5.string().regex(/^[a-f0-9]{64}$/),
1447
- sourceRange: z5.object({
1448
- startFrame: z5.number().int().nonnegative(),
1449
- endFrame: z5.number().int().positive()
3749
+ expectedSha256: z7.string().regex(/^[a-f0-9]{64}$/),
3750
+ sourceRange: z7.object({
3751
+ startFrame: z7.number().int().nonnegative(),
3752
+ endFrame: z7.number().int().positive()
1450
3753
  }).strict().optional()
1451
3754
  }).strict(),
1452
- widthPx: z5.number().int().positive().max(8192),
1453
- heightPx: z5.number().int().positive().max(8192)
3755
+ widthPx: z7.number().int().positive().max(8192),
3756
+ heightPx: z7.number().int().positive().max(8192)
1454
3757
  }).strict();
1455
- var shape = z5.discriminatedUnion("kind", [polygonShape, rasterShape]);
1456
- var mask = z5.object({
3758
+ var shape = z7.discriminatedUnion("kind", [polygonShape, rasterShape]);
3759
+ var mask = z7.object({
1457
3760
  id,
1458
3761
  shape,
1459
- operation: z5.enum(["add", "subtract"]),
1460
- inverted: z5.boolean().default(false),
1461
- feather: z5.number().finite().nonnegative().max(0.25).default(0),
1462
- allowedSupportMargin: z5.number().finite().nonnegative().max(0.25).default(0),
1463
- reviewState: z5.enum(["draft", "approved", "rejected"]),
1464
- provenance: z5.object({
1465
- kind: z5.enum(["manual", "imported", "model-proposed"]),
3762
+ operation: z7.enum(["add", "subtract"]),
3763
+ inverted: z7.boolean().default(false),
3764
+ feather: z7.number().finite().nonnegative().max(0.25).default(0),
3765
+ allowedSupportMargin: z7.number().finite().nonnegative().max(0.25).default(0),
3766
+ reviewState: z7.enum(["draft", "approved", "rejected"]),
3767
+ provenance: z7.object({
3768
+ kind: z7.enum(["manual", "imported", "model-proposed"]),
1466
3769
  sourceAssetId: id.optional(),
1467
- modelId: z5.string().min(1).max(160).optional()
3770
+ modelId: z7.string().min(1).max(160).optional()
1468
3771
  }).strict()
1469
3772
  }).strict();
1470
- var transform = z5.object({
1471
- x: z5.number().min(0).max(1),
1472
- y: z5.number().min(0).max(1),
1473
- width: z5.number().positive().max(1),
1474
- height: z5.number().positive().max(1),
1475
- rotationDegrees: z5.number().min(-360).max(360),
1476
- opacity: z5.number().min(0).max(1)
3773
+ var transform = z7.object({
3774
+ x: z7.number().min(0).max(1),
3775
+ y: z7.number().min(0).max(1),
3776
+ width: z7.number().positive().max(1),
3777
+ height: z7.number().positive().max(1),
3778
+ rotationDegrees: z7.number().min(-360).max(360),
3779
+ opacity: z7.number().min(0).max(1)
1477
3780
  }).strict();
1478
3781
  var colourParameters = {
1479
- exposure: z5.number().finite().min(-2).max(2).default(0),
1480
- contrast: z5.number().finite().min(0.5).max(2).default(1),
1481
- saturation: z5.number().finite().min(0).max(2).default(1),
1482
- temperature: z5.number().finite().min(-1).max(1).default(0),
1483
- tint: z5.number().finite().min(-1).max(1).default(0)
3782
+ exposure: z7.number().finite().min(-2).max(2).default(0),
3783
+ contrast: z7.number().finite().min(0.5).max(2).default(1),
3784
+ saturation: z7.number().finite().min(0).max(2).default(1),
3785
+ temperature: z7.number().finite().min(-1).max(1).default(0),
3786
+ tint: z7.number().finite().min(-1).max(1).default(0)
1484
3787
  };
1485
- var effect = z5.object({
3788
+ var effect = z7.object({
1486
3789
  id,
1487
- kind: z5.literal("local-colour"),
1488
- version: z5.literal(1),
3790
+ kind: z7.literal("local-colour"),
3791
+ version: z7.literal(1),
1489
3792
  maskId: id,
1490
3793
  ...colourParameters
1491
3794
  }).strict();
1492
- var motionPath = z5.object({
3795
+ var motionPath = z7.object({
1493
3796
  id,
1494
- kind: z5.literal("cubic-bezier"),
1495
- startFrame: z5.number().int().nonnegative(),
1496
- endFrame: z5.number().int().positive(),
3797
+ kind: z7.literal("cubic-bezier"),
3798
+ startFrame: z7.number().int().nonnegative(),
3799
+ endFrame: z7.number().int().positive(),
1497
3800
  start: point,
1498
3801
  control1: point,
1499
3802
  control2: point,
1500
3803
  end: point,
1501
- easing: z5.enum(["linear", "ease-in", "ease-out", "ease-in-out"]),
1502
- orientToPath: z5.boolean().default(false)
3804
+ easing: z7.enum(["linear", "ease-in", "ease-out", "ease-in-out"]),
3805
+ orientToPath: z7.boolean().default(false)
1503
3806
  }).strict();
1504
- var region = z5.object({ id, shape, label: z5.string().min(1).max(160) }).strict();
3807
+ var region = z7.object({ id, shape, label: z7.string().min(1).max(160) }).strict();
1505
3808
  var base = { actionId: id, sceneId: id };
1506
- var vendoredDesignActionSchema = z5.discriminatedUnion("kind", [
1507
- z5.object({
3809
+ var vendoredDesignActionSchema = z7.discriminatedUnion("kind", [
3810
+ z7.object({
1508
3811
  ...base,
1509
- kind: z5.literal("set-layer-transform"),
3812
+ kind: z7.literal("set-layer-transform"),
1510
3813
  layerId: id,
1511
3814
  transform
1512
3815
  }).strict(),
1513
- z5.object({
3816
+ z7.object({
1514
3817
  ...base,
1515
- kind: z5.literal("set-local-colour-effect"),
3818
+ kind: z7.literal("set-local-colour-effect"),
1516
3819
  effectId: id,
1517
- parameters: z5.object(colourParameters).strict()
3820
+ parameters: z7.object(colourParameters).strict()
1518
3821
  }).strict(),
1519
- z5.object({ ...base, kind: z5.literal("create-mask"), mask }).strict(),
1520
- z5.object({ ...base, kind: z5.literal("set-mask"), maskId: id, mask }).strict(),
1521
- z5.object({
3822
+ z7.object({ ...base, kind: z7.literal("create-mask"), mask }).strict(),
3823
+ z7.object({ ...base, kind: z7.literal("set-mask"), maskId: id, mask }).strict(),
3824
+ z7.object({
1522
3825
  ...base,
1523
- kind: z5.literal("set-mask-review-state"),
3826
+ kind: z7.literal("set-mask-review-state"),
1524
3827
  maskId: id,
1525
- reviewState: z5.enum(["draft", "approved", "rejected"])
3828
+ reviewState: z7.enum(["draft", "approved", "rejected"])
1526
3829
  }).strict(),
1527
- z5.object({ ...base, kind: z5.literal("delete-mask"), maskId: id }).strict(),
1528
- z5.object({
3830
+ z7.object({ ...base, kind: z7.literal("delete-mask"), maskId: id }).strict(),
3831
+ z7.object({
1529
3832
  ...base,
1530
- kind: z5.literal("attach-effect"),
3833
+ kind: z7.literal("attach-effect"),
1531
3834
  effect,
1532
- layerIds: z5.array(id).min(1).max(50)
3835
+ layerIds: z7.array(id).min(1).max(50)
1533
3836
  }).strict(),
1534
- z5.object({ ...base, kind: z5.literal("remove-effect"), effectId: id }).strict(),
1535
- z5.object({
3837
+ z7.object({ ...base, kind: z7.literal("remove-effect"), effectId: id }).strict(),
3838
+ z7.object({
1536
3839
  ...base,
1537
- kind: z5.literal("set-layer-text"),
3840
+ kind: z7.literal("set-layer-text"),
1538
3841
  layerId: id,
1539
- text: z5.string().max(1e4)
3842
+ text: z7.string().max(1e4)
1540
3843
  }).strict(),
1541
- z5.object({
3844
+ z7.object({
1542
3845
  ...base,
1543
- kind: z5.literal("set-layer-visibility"),
3846
+ kind: z7.literal("set-layer-visibility"),
1544
3847
  layerId: id,
1545
- visible: z5.boolean()
3848
+ visible: z7.boolean()
1546
3849
  }).strict(),
1547
- z5.object({
3850
+ z7.object({
1548
3851
  ...base,
1549
- kind: z5.literal("set-layer-locked"),
3852
+ kind: z7.literal("set-layer-locked"),
1550
3853
  layerId: id,
1551
- locked: z5.boolean()
3854
+ locked: z7.boolean()
1552
3855
  }).strict(),
1553
- z5.object({
3856
+ z7.object({
1554
3857
  ...base,
1555
- kind: z5.literal("set-layer-mask-ids"),
3858
+ kind: z7.literal("set-layer-mask-ids"),
1556
3859
  layerId: id,
1557
- maskIds: z5.array(id).max(16)
3860
+ maskIds: z7.array(id).max(16)
1558
3861
  }).strict(),
1559
- z5.object({
3862
+ z7.object({
1560
3863
  ...base,
1561
- kind: z5.literal("set-layer-order"),
1562
- orderedLayerIds: z5.array(id).min(1).max(500)
3864
+ kind: z7.literal("set-layer-order"),
3865
+ orderedLayerIds: z7.array(id).min(1).max(500)
1563
3866
  }).strict(),
1564
- z5.object({
3867
+ z7.object({
1565
3868
  ...base,
1566
- kind: z5.literal("set-motion-path"),
3869
+ kind: z7.literal("set-motion-path"),
1567
3870
  path: motionPath,
1568
- layerIds: z5.array(id).max(50).default([])
3871
+ layerIds: z7.array(id).max(50).default([])
1569
3872
  }).strict(),
1570
- z5.object({ ...base, kind: z5.literal("remove-motion-path"), pathId: id }).strict(),
1571
- z5.object({ ...base, kind: z5.literal("set-protected-region"), region }).strict(),
1572
- z5.object({
3873
+ z7.object({ ...base, kind: z7.literal("remove-motion-path"), pathId: id }).strict(),
3874
+ z7.object({ ...base, kind: z7.literal("set-protected-region"), region }).strict(),
3875
+ z7.object({
1573
3876
  ...base,
1574
- kind: z5.literal("remove-protected-region"),
3877
+ kind: z7.literal("remove-protected-region"),
1575
3878
  regionId: id
1576
3879
  }).strict()
1577
3880
  ]);
1578
- var inspectDesignDocumentToolSchema = z5.object({
1579
- projectId: z5.string().uuid(),
1580
- documentId: z5.string().uuid(),
1581
- includeVersions: z5.boolean().default(true)
3881
+ var inspectDesignDocumentToolSchema = z7.object({
3882
+ projectId: z7.string().uuid(),
3883
+ documentId: z7.string().uuid(),
3884
+ includeVersions: z7.boolean().default(true)
1582
3885
  }).strict();
1583
- var applyDesignActionsToolSchema = z5.object({
1584
- projectId: z5.string().uuid(),
1585
- documentId: z5.string().uuid(),
1586
- actionGroupId: z5.string().min(1).max(120),
1587
- expectedVersion: z5.number().int().positive(),
1588
- actions: z5.array(vendoredDesignActionSchema).min(1).max(50),
1589
- clientCreatedAt: z5.string().datetime()
3886
+ var applyDesignActionsToolSchema = z7.object({
3887
+ projectId: z7.string().uuid(),
3888
+ documentId: z7.string().uuid(),
3889
+ actionGroupId: z7.string().min(1).max(120),
3890
+ expectedVersion: z7.number().int().positive(),
3891
+ actions: z7.array(vendoredDesignActionSchema).min(1).max(50),
3892
+ clientCreatedAt: z7.string().datetime()
1590
3893
  }).strict();
1591
3894
 
1592
3895
  // src/tools.ts
1593
- var uuid = (desc) => z6.string().uuid().describe(desc);
3896
+ var uuid = (desc) => z8.string().uuid().describe(desc);
1594
3897
  var READ_ONLY = {
1595
3898
  readOnlyHint: true,
1596
3899
  destructiveHint: false,
@@ -1609,9 +3912,9 @@ function registerTools(server) {
1609
3912
  {
1610
3913
  title: "List jobs",
1611
3914
  description: "List recent video jobs for the current organization (newest first). Start here to discover job IDs; for one job's full detail use get_job_status.",
1612
- inputSchema: {
1613
- limit: z6.number().int().min(1).max(50).default(10).describe("Number of jobs to return (default 10, max 50)"),
1614
- status: z6.enum([
3915
+ inputSchema: z8.object({
3916
+ limit: z8.number().int().min(1).max(50).default(10).describe("Number of jobs to return (default 10, max 50)"),
3917
+ status: z8.enum([
1615
3918
  "queued",
1616
3919
  "rendering",
1617
3920
  "draft_ready",
@@ -1621,7 +3924,7 @@ function registerTools(server) {
1621
3924
  "published",
1622
3925
  "failed"
1623
3926
  ]).optional().describe("Filter by job status")
1624
- },
3927
+ }).strict(),
1625
3928
  annotations: READ_ONLY
1626
3929
  },
1627
3930
  async ({ limit, status }) => {
@@ -1635,7 +3938,7 @@ function registerTools(server) {
1635
3938
  {
1636
3939
  title: "Get job status",
1637
3940
  description: "Get detailed status for a job: runs, artifacts, verifications, plus the current video and thumbnail URLs. The main polling target after create_video_brief or edit_video_brief; for post-publish engagement numbers use get_job_metrics instead.",
1638
- inputSchema: { jobId: uuid("The job ID to check") },
3941
+ inputSchema: z8.object({ jobId: uuid("The job ID to check") }).strict(),
1639
3942
  annotations: READ_ONLY
1640
3943
  },
1641
3944
  async ({ jobId }) => runTool(() => apiGet(`/api/v1/jobs/${encodeURIComponent(jobId)}`))
@@ -1645,7 +3948,7 @@ function registerTools(server) {
1645
3948
  {
1646
3949
  title: "Get video state",
1647
3950
  description: "Get the materialized video state for a job (composition decisions: scenes, duration, aspect ratio, etc.). Use it to inspect what the video contains; for pipeline progress and video URLs use get_job_status.",
1648
- inputSchema: { jobId: uuid("The job ID") },
3951
+ inputSchema: z8.object({ jobId: uuid("The job ID") }).strict(),
1649
3952
  annotations: READ_ONLY
1650
3953
  },
1651
3954
  async ({ jobId }) => runTool(
@@ -1657,7 +3960,7 @@ function registerTools(server) {
1657
3960
  {
1658
3961
  title: "Diagnose render",
1659
3962
  description: "Build one read-only troubleshooting snapshot from the current job status and video state. Reports run failures, artifact binding, duration evidence, retry recommendations, rights checks, and whether blank-frame or placeholder verification evidence exists. It does not visually inspect the video.",
1660
- inputSchema: { jobId: uuid("The job ID to diagnose") },
3963
+ inputSchema: z8.object({ jobId: uuid("The job ID to diagnose") }).strict(),
1661
3964
  annotations: READ_ONLY
1662
3965
  },
1663
3966
  async ({ jobId }) => runTool(async () => {
@@ -1674,10 +3977,10 @@ function registerTools(server) {
1674
3977
  {
1675
3978
  title: "Get job metrics",
1676
3979
  description: "Get the latest platform engagement metric snapshots for a published job (newest first). Read-only. Only meaningful after publish_job; for render progress use get_job_status.",
1677
- inputSchema: {
3980
+ inputSchema: z8.object({
1678
3981
  jobId: uuid("The job ID"),
1679
- limit: z6.number().int().min(1).max(20).default(10).describe("Max metric snapshots (default 10, max 20)")
1680
- },
3982
+ limit: z8.number().int().min(1).max(20).default(10).describe("Max metric snapshots (default 10, max 20)")
3983
+ }).strict(),
1681
3984
  annotations: READ_ONLY
1682
3985
  },
1683
3986
  async ({ jobId, limit }) => runTool(
@@ -1691,12 +3994,12 @@ function registerTools(server) {
1691
3994
  {
1692
3995
  title: "Get cost summary",
1693
3996
  description: "Query production infrastructure costs (Lambda, RunPod, R2, WaveSpeed, PoYo), optionally with reconciliation drift. This is spend data, not engagement \u2014 for a published job's audience numbers use get_job_metrics.",
1694
- inputSchema: {
1695
- since: z6.string().optional().describe("ISO date \u2014 only include events after this date"),
1696
- provider: z6.enum(["runpod", "lambda", "r2", "wavespeed", "poyo", "all"]).default("all").describe("Filter by provider"),
1697
- groupBy: z6.enum(["provider", "job", "day"]).default("provider").describe("How to aggregate the summary"),
1698
- includeReconciliation: z6.boolean().default(false).describe("Include account-wide reconciliation events")
1699
- },
3997
+ inputSchema: z8.object({
3998
+ since: z8.string().optional().describe("ISO date \u2014 only include events after this date"),
3999
+ provider: z8.enum(["runpod", "lambda", "r2", "wavespeed", "poyo", "all"]).default("all").describe("Filter by provider"),
4000
+ groupBy: z8.enum(["provider", "job", "day"]).default("provider").describe("How to aggregate the summary"),
4001
+ includeReconciliation: z8.boolean().default(false).describe("Include account-wide reconciliation events")
4002
+ }).strict(),
1700
4003
  annotations: READ_ONLY
1701
4004
  },
1702
4005
  async ({ since, provider, groupBy, includeReconciliation }) => {
@@ -1711,7 +4014,7 @@ function registerTools(server) {
1711
4014
  {
1712
4015
  title: "Inspect workflow",
1713
4016
  description: "Inspect the current Studio workflow and its version history for a job.",
1714
- inputSchema: z6.object({ jobId: uuid("The job ID") }).strict(),
4017
+ inputSchema: z8.object({ jobId: uuid("The job ID") }).strict(),
1715
4018
  annotations: READ_ONLY
1716
4019
  },
1717
4020
  async ({ jobId }) => runTool(
@@ -1760,7 +4063,10 @@ function registerTools(server) {
1760
4063
  {
1761
4064
  title: "Create video brief",
1762
4065
  description: "Create a new video job from a structured brief and trigger the render pipeline. Returns the job and run IDs immediately; rendering continues asynchronously (typically a few minutes) \u2014 poll get_job_status until draft_ready. Requires a key with write scope. To change an existing job, use edit_video_brief instead of creating a duplicate.",
1763
- inputSchema: createBriefShape,
4066
+ // Strict like the remote Studio tool: an unsupported field such as a
4067
+ // framework choice is rejected instead of being stripped and rendered
4068
+ // with the default renderer.
4069
+ inputSchema: z8.object(createBriefShape).strict(),
1764
4070
  annotations: SAFE_WRITE
1765
4071
  },
1766
4072
  async (input) => runTool(() => apiPost(`/api/v1/jobs`, input))
@@ -1770,7 +4076,7 @@ function registerTools(server) {
1770
4076
  {
1771
4077
  title: "Edit video brief",
1772
4078
  description: "Edit an existing job's brief (only provided fields change). Changing the script, caption, title, lessonTitle, objective, steps, scenes, aspectRatio or voiceId triggers a re-render and returns the new run ID; objective also re-routes the composition. Changing only publishTarget updates the job's target platform without re-rendering. For a brand-new video use create_video_brief.",
1773
- inputSchema: editBriefShape,
4079
+ inputSchema: z8.object(editBriefShape).strict(),
1774
4080
  annotations: SAFE_WRITE
1775
4081
  },
1776
4082
  async (input) => {
@@ -1791,10 +4097,10 @@ function registerTools(server) {
1791
4097
  {
1792
4098
  title: "Draft workflow",
1793
4099
  description: "Create a durable Documentary Journey or Transformation Montage workflow version. Inspect first and pass its current version, or 0 only when no workflow exists.",
1794
- inputSchema: z6.object({
4100
+ inputSchema: z8.object({
1795
4101
  jobId: uuid("The job ID"),
1796
- expectedVersion: z6.number().int().nonnegative().describe("Use 0 when no workflow exists yet"),
1797
- document: z6.unknown().describe("The complete Studio workflow document")
4102
+ expectedVersion: z8.number().int().nonnegative().describe("Use 0 when no workflow exists yet"),
4103
+ document: z8.unknown().describe("The complete Studio workflow document")
1798
4104
  }).strict(),
1799
4105
  annotations: SAFE_WRITE
1800
4106
  },
@@ -1805,10 +4111,10 @@ function registerTools(server) {
1805
4111
  {
1806
4112
  title: "Patch workflow",
1807
4113
  description: "Create a new workflow version by recursively merging a patch into the current version.",
1808
- inputSchema: z6.object({
4114
+ inputSchema: z8.object({
1809
4115
  jobId: uuid("The job ID"),
1810
- expectedVersion: z6.number().int().positive(),
1811
- patch: z6.record(z6.string(), z6.unknown())
4116
+ expectedVersion: z8.number().int().positive(),
4117
+ patch: z8.record(z8.string(), z8.unknown())
1812
4118
  }).strict(),
1813
4119
  annotations: SAFE_WRITE
1814
4120
  },
@@ -1819,9 +4125,9 @@ function registerTools(server) {
1819
4125
  {
1820
4126
  title: "Validate workflow",
1821
4127
  description: "Validate and compile the inspected workflow version without rendering or publishing it.",
1822
- inputSchema: z6.object({
4128
+ inputSchema: z8.object({
1823
4129
  jobId: uuid("The job ID"),
1824
- expectedVersion: z6.number().int().positive()
4130
+ expectedVersion: z8.number().int().positive()
1825
4131
  }).strict(),
1826
4132
  annotations: SAFE_WRITE
1827
4133
  },
@@ -1832,7 +4138,7 @@ function registerTools(server) {
1832
4138
  {
1833
4139
  title: "Preview workflow",
1834
4140
  description: "Return the current workflow's compiled UniversalVideo brief for a safe pre-render preview.",
1835
- inputSchema: z6.object({ jobId: uuid("The job ID") }).strict(),
4141
+ inputSchema: z8.object({ jobId: uuid("The job ID") }).strict(),
1836
4142
  annotations: READ_ONLY
1837
4143
  },
1838
4144
  async ({ jobId }) => runTool(
@@ -1846,10 +4152,10 @@ function registerTools(server) {
1846
4152
  {
1847
4153
  title: "Compare workflow versions",
1848
4154
  description: "Compare two durable workflow versions field by field.",
1849
- inputSchema: z6.object({
4155
+ inputSchema: z8.object({
1850
4156
  jobId: uuid("The job ID"),
1851
- fromVersion: z6.number().int().positive(),
1852
- toVersion: z6.number().int().positive()
4157
+ fromVersion: z8.number().int().positive(),
4158
+ toVersion: z8.number().int().positive()
1853
4159
  }).strict(),
1854
4160
  annotations: READ_ONLY
1855
4161
  },
@@ -1873,9 +4179,9 @@ function registerTools(server) {
1873
4179
  {
1874
4180
  title: "Approve workflow",
1875
4181
  description: "Validate and approve the inspected workflow version. This does not approve or publish the video job.",
1876
- inputSchema: z6.object({
4182
+ inputSchema: z8.object({
1877
4183
  jobId: uuid("The job ID"),
1878
- expectedVersion: z6.number().int().positive()
4184
+ expectedVersion: z8.number().int().positive()
1879
4185
  }).strict(),
1880
4186
  annotations: {
1881
4187
  readOnlyHint: false,
@@ -1891,11 +4197,11 @@ function registerTools(server) {
1891
4197
  {
1892
4198
  title: "Retry video QA",
1893
4199
  description: "Retry the default QA evaluator against the same current frozen video. Use only when get_job_status recommends retryTarget qa_only, or when QA is missing, unavailable, or parse-degraded. This does not regenerate media and cannot clear publish gates by itself.",
1894
- inputSchema: {
4200
+ inputSchema: z8.object({
1895
4201
  jobId: uuid("The current job ID"),
1896
4202
  runId: uuid("The current render run ID"),
1897
4203
  videoArtifactId: uuid("The current frozen video artifact ID")
1898
- },
4204
+ }).strict(),
1899
4205
  annotations: SAFE_WRITE
1900
4206
  },
1901
4207
  async ({ jobId, runId, videoArtifactId }) => runTool(
@@ -1910,11 +4216,11 @@ function registerTools(server) {
1910
4216
  {
1911
4217
  title: "Audit video QA",
1912
4218
  description: "Run Qwen3.6-Plus as an advisory second evaluator against the same current frozen video. Use only on an explicit request for another model, second opinion, or evaluator escalation. The result is separate from default QA and has no publish-gate effect.",
1913
- inputSchema: {
4219
+ inputSchema: z8.object({
1914
4220
  jobId: uuid("The current job ID"),
1915
4221
  runId: uuid("The current render run ID"),
1916
4222
  videoArtifactId: uuid("The current frozen video artifact ID")
1917
- },
4223
+ }).strict(),
1918
4224
  annotations: SAFE_WRITE
1919
4225
  },
1920
4226
  async ({ jobId, runId, videoArtifactId }) => runTool(
@@ -1929,11 +4235,11 @@ function registerTools(server) {
1929
4235
  {
1930
4236
  title: "Regenerate narration",
1931
4237
  description: "Regenerate narration from the unchanged durable brief and then regenerate its dependent video in a paid adaptation run. Use only on an explicit user request or when get_job_status recommends retryTarget tts. This is an audio_and_video cascade, consumes rerender quota, and requires fresh QA.",
1932
- inputSchema: {
4238
+ inputSchema: z8.object({
1933
4239
  jobId: uuid("The current job ID"),
1934
4240
  sourceRunId: uuid("The current run ID"),
1935
- trigger: z6.enum(["user_requested", "verifier_recommendation"])
1936
- },
4241
+ trigger: z8.enum(["user_requested", "verifier_recommendation"])
4242
+ }).strict(),
1937
4243
  annotations: SAFE_WRITE
1938
4244
  },
1939
4245
  async ({ jobId, sourceRunId, trigger }) => runTool(
@@ -1948,7 +4254,7 @@ function registerTools(server) {
1948
4254
  {
1949
4255
  title: "Approve job",
1950
4256
  description: "Approve a rendered job so it becomes publishable (draft_ready/awaiting_review/needs_changes -> approved) and revoke active review links. Required before publish_job will accept the job.",
1951
- inputSchema: { jobId: uuid("The job ID to approve") },
4257
+ inputSchema: z8.object({ jobId: uuid("The job ID to approve") }).strict(),
1952
4258
  annotations: {
1953
4259
  readOnlyHint: false,
1954
4260
  // Approval revokes active review links, so this is not purely additive.
@@ -1966,29 +4272,21 @@ function registerTools(server) {
1966
4272
  "publish_job",
1967
4273
  {
1968
4274
  title: "Publish job",
1969
- description: "Publish an APPROVED job to its connected social destination via the gated publish API. All production gates run (paid plan, ownership, abuse, QA, disclosure, destination, rights, moderation). Requires a key with publish scope; the post goes live on the external platform and cannot be recalled by the API. For YouTube pass youtubePrivacyStatus:'private' for safe runs.",
1970
- inputSchema: {
4275
+ description: "Publish an APPROVED job to one connected social account. The user must approve each post in Instavar Studio: the first call returns a link and code that show them the exact account, text, video and visibility. Show the link to the user, wait for them to approve, then call again with the returned confirmationId. Nothing is posted until the user approves, and only the user can approve. All production gates still run; the post goes live and cannot be recalled by the API. LinkedIn, X, YouTube, Facebook, Instagram and Threads; TikTok posts are made in Instavar Studio. Requires a key with publish scope.",
4276
+ inputSchema: z8.object({
1971
4277
  jobId: uuid("The approved job to publish"),
1972
- xPreviewArtifactId: z6.string().min(1).optional().describe("X only. Exact reviewed video artifact ID."),
1973
- xCaption: z6.string().trim().min(1).max(2e3).optional().describe("X only. Exact post text approved by the user."),
1974
- xMadeWithAi: z6.boolean().optional().describe("X only. Enable the Made with AI disclosure."),
1975
- confirmXPublicPost: z6.boolean().optional().describe("True only after the user authorizes this public X post."),
1976
- confirmXAutomationPolicy: z6.boolean().optional().describe(
1977
- "True only after the user confirms the X automation policy."
1978
- ),
1979
- confirmXOriginalContent: z6.boolean().optional().describe(
1980
- "True only after the user confirms ownership or publishing rights."
4278
+ confirmationId: z8.string().uuid().optional().describe(
4279
+ "The confirmationId from an earlier publish_job reply, after the user approved in Instavar Studio."
1981
4280
  ),
1982
- youtubePrivacyStatus: z6.enum(["private", "unlisted", "public"]).optional().describe("YouTube only. Use 'private' for safe dogfood runs."),
1983
- tiktokPostMode: z6.enum(["direct_publish", "draft_upload"]).optional().describe("TikTok only. Use 'draft_upload' for safe dogfood runs."),
1984
- connectedAccountDestinationId: z6.string().uuid().optional().describe(
4281
+ connectedAccountDestinationId: z8.string().uuid().optional().describe(
1985
4282
  "Specific destination when the org has multiple accounts for the provider."
1986
4283
  ),
1987
- confirmSyntheticDisclosure: z6.boolean().optional().describe(
1988
- "Set true when the job requires an AI synthetic-media disclosure."
1989
- ),
1990
- confirmQaOverride: z6.boolean().optional().describe("Set true to override a non-passing QA gate.")
1991
- },
4284
+ xCaption: z8.string().trim().min(1).max(2e3).optional().describe("X only. The post text to show the user for approval."),
4285
+ xMadeWithAi: z8.boolean().optional().describe("X only. Turn on the Made with AI label."),
4286
+ youtubePrivacyStatus: z8.enum(["private", "unlisted", "public"]).optional().describe(
4287
+ "YouTube only. Must match the channel's saved privacy setting; use 'private' for safe dogfood runs."
4288
+ )
4289
+ }).strict(),
1992
4290
  annotations: {
1993
4291
  readOnlyHint: false,
1994
4292
  // A live post on an external platform cannot be recalled by the API.
@@ -1997,11 +4295,54 @@ function registerTools(server) {
1997
4295
  openWorldHint: true
1998
4296
  }
1999
4297
  },
2000
- async ({ jobId, ...rest }) => (
2001
- // NOTE: publish is NOT under /api/v1 — it is the gated /api/jobs route.
2002
- runTool(
2003
- () => apiPost(`/api/jobs/${encodeURIComponent(jobId)}/publish`, rest)
2004
- )
4298
+ async ({ jobId, confirmationId, youtubePrivacyStatus, ...target }) => (
4299
+ // This package runs on the user's machine, so it never records an
4300
+ // approval itself: the user approves on the signed-in Studio page and
4301
+ // the publish route consumes that server-side confirmation.
4302
+ runTool(async () => {
4303
+ const loaded = confirmationId ? await apiGet(
4304
+ `/api/v1/publish-confirmations/${encodeURIComponent(
4305
+ confirmationId
4306
+ )}`
4307
+ ) : await apiPost(
4308
+ `/api/v1/jobs/${encodeURIComponent(jobId)}/publish-confirmations`,
4309
+ target
4310
+ );
4311
+ const view = loaded.body;
4312
+ if (!loaded.ok || !view?.confirmationId || !view.content) return loaded;
4313
+ if (view.content.jobId !== jobId) {
4314
+ return {
4315
+ ok: false,
4316
+ status: 409,
4317
+ body: {
4318
+ posted: false,
4319
+ error: "That confirmation is for a different video. Call publish_job again without confirmationId."
4320
+ }
4321
+ };
4322
+ }
4323
+ if (view.status === "approved") {
4324
+ return apiPost(`/api/jobs/${encodeURIComponent(jobId)}/publish`, {
4325
+ publishConfirmationId: view.confirmationId,
4326
+ provider: view.content.platform,
4327
+ connectedAccountDestinationId: view.content.destinationId,
4328
+ expectedVideoArtifactId: view.content.videoArtifactId,
4329
+ youtubePrivacyStatus: view.content.platform === "youtube" ? youtubePrivacyStatus : void 0
4330
+ });
4331
+ }
4332
+ const message = view.status === "pending" ? `Nothing was posted yet. Ask the user to open ${view.approveUrl} in a browser signed in to Instavar, check the code ${view.userCode} matches, and approve the post to ${view.content.platformName} account ${view.content.accountName}. Then call publish_job again with confirmationId ${view.confirmationId}. Only the user can approve; do not approve on their behalf. The request expires at ${view.expiresAt}.` : view.status === "used" ? "Nothing new was posted: this approval was already used for one post." : view.status === "expired" ? "Nothing was posted: the approval request expired. Call publish_job again without confirmationId." : "Nothing was posted: the user declined this post.";
4333
+ return {
4334
+ ok: true,
4335
+ status: 200,
4336
+ body: {
4337
+ posted: false,
4338
+ status: view.status,
4339
+ confirmationId: view.confirmationId,
4340
+ approveUrl: view.approveUrl,
4341
+ userCode: view.userCode,
4342
+ message
4343
+ }
4344
+ };
4345
+ })
2005
4346
  )
2006
4347
  );
2007
4348
  server.registerTool(
@@ -2009,8 +4350,8 @@ function registerTools(server) {
2009
4350
  {
2010
4351
  title: "Connect social account",
2011
4352
  description: "Start connecting a social account headlessly (no local browser needed). Returns an approve URL + a short confirm code: open the URL in a browser signed in to Instavar, check the code matches THIS terminal, and approve. Then poll connect_account_status with the returned pairingId until it reports 'connected'.",
2012
- inputSchema: {
2013
- provider: z6.enum([
4353
+ inputSchema: z8.object({
4354
+ provider: z8.enum([
2014
4355
  "youtube",
2015
4356
  "x",
2016
4357
  "tiktok",
@@ -2019,7 +4360,7 @@ function registerTools(server) {
2019
4360
  "instagram",
2020
4361
  "threads"
2021
4362
  ]).describe("The social platform to connect")
2022
- },
4363
+ }).strict(),
2023
4364
  annotations: {
2024
4365
  readOnlyHint: false,
2025
4366
  destructiveHint: false,
@@ -2035,9 +4376,9 @@ function registerTools(server) {
2035
4376
  {
2036
4377
  title: "Check account connection",
2037
4378
  description: "Poll a pending account connection started by connect_account. Returns status 'pending' | 'connected' | 'expired', plus the connected account label once connected.",
2038
- inputSchema: {
4379
+ inputSchema: z8.object({
2039
4380
  pairingId: uuid("The pairingId returned by connect_account")
2040
- },
4381
+ }).strict(),
2041
4382
  annotations: READ_ONLY
2042
4383
  },
2043
4384
  async ({ pairingId }) => runTool(
@@ -2059,9 +4400,9 @@ function registerConfiguredTools(server, apiKey = process.env.INSTAVAR_API_KEY)
2059
4400
  // package.json
2060
4401
  var package_default = {
2061
4402
  name: "@instavar/mcp-server",
2062
- version: "0.6.0",
4403
+ version: "0.8.0",
2063
4404
  mcpName: "com.instavar/mcp-server",
2064
- description: "Make local videos with Instavar Remotion templates for free, then add an API key for hosted Studio workflows.",
4405
+ description: "Make local videos with Instavar templates for Remotion or HyperFrames for free, then add an API key for hosted Studio workflows.",
2065
4406
  type: "module",
2066
4407
  license: "MIT",
2067
4408
  homepage: "https://instavar.com",
@@ -2077,6 +4418,8 @@ var package_default = {
2077
4418
  "model-context-protocol",
2078
4419
  "instavar",
2079
4420
  "video",
4421
+ "remotion",
4422
+ "hyperframes",
2080
4423
  "claude",
2081
4424
  "codex"
2082
4425
  ],
@@ -2136,7 +4479,7 @@ async function main() {
2136
4479
  const server = new McpServer(
2137
4480
  { name: "instavar", version: VERSION },
2138
4481
  {
2139
- instructions: PAIRED_ANNOUNCEMENT_INSTRUCTIONS + " Before drafting concise carousel or video copy, call get_creative_guide for visual-copy. Use the carousel-stories, visual-design and human-review guides as relevant. Apply them to the user brief; the guides do not generate, render, save or publish media."
4482
+ instructions: pairedAnnouncementInstructions(pairedTemplatesEnabled()) + (pairedTemplatesEnabled() ? " " + PAIRED_TEMPLATE_INSTRUCTIONS : "") + " Before drafting concise carousel or video copy, call get_creative_guide for visual-copy. Use the carousel-stories, visual-design and human-review guides as relevant. Apply them to the user brief; the guides do not generate, render, save or publish media. For an ordinary video request, call propose_video_storyboard with the user's words and an aspect, passing accepted title, body and CTA as separate fields, and show the three beats before scaffolding. The storyboard contains visual briefs, not generated images. Use scaffold_video_spec only after the user accepts or refines the direction, preserving supplied body and CTA. For a carousel, choose a structure with list_carousel_templates and build it with scaffold_carousel_deck from accepted copy."
2140
4483
  }
2141
4484
  );
2142
4485
  registerConfiguredTools(server);