@slatesvideo/shared 0.7.22 → 0.7.23

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.
@@ -84,6 +84,13 @@ const OMNI_FLASH_ASPECT_RATIOS = ['16:9', '9:16'];
84
84
  * the H3 rows make.
85
85
  */
86
86
  const WAN_3_ASPECT_RATIOS = ['16:9', '4:3', '1:1', '3:4', '9:16'];
87
+ /**
88
+ * MAGI-2: six, on the text-to-video and reference-to-video requests (Kie's
89
+ * `magi-2/*` schemas, ripped 2026-11-25 to second-brain
90
+ * business/projects/slates/provider-docs/kie-magi-2-docs.md). Image-to-video
91
+ * has no ratio field: the start frame decides the shape.
92
+ */
93
+ const MAGI_2_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
87
94
  /** Seedance (both seats, and the edit row): six — notably NO `4:5`. */
88
95
  const SEEDANCE_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
89
96
  /**
@@ -316,6 +323,8 @@ export const FLUX_3_RESOLUTIONS = {
316
323
  '2k': '1.5k',
317
324
  '4k': '2k',
318
325
  };
326
+ /** Largest conditioned video the direct reference upload must carry. */
327
+ export const VIDEO_REFERENCE_UPLOAD_BYTES = 200 * 1024 * 1024;
319
328
  /**
320
329
  * The provider every AGENT generation actually lands on for Kling.
321
330
  *
@@ -455,6 +464,8 @@ export const MODEL_CAPABILITIES = {
455
464
  // with reference images lands, takes the three-ratio enum (fal OpenAPI, read
456
465
  // 2026-11-24).
457
466
  'kling-v3.0-std': {
467
+ soundCanBeDisabled: true,
468
+ maxPromptLength: 2500,
458
469
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
459
470
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
460
471
  videoResolution: { options: ['720p', '4k'] },
@@ -464,6 +475,8 @@ export const MODEL_CAPABILITIES = {
464
475
  noReferenceImagesAt: ['4k'],
465
476
  },
466
477
  'kling-v3.0-pro': {
478
+ soundCanBeDisabled: true,
479
+ maxPromptLength: 2500,
467
480
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
468
481
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
469
482
  videoResolution: { options: ['1080p', '4k'] },
@@ -472,6 +485,8 @@ export const MODEL_CAPABILITIES = {
472
485
  noReferenceImagesAt: ['4k'],
473
486
  },
474
487
  'kling-v3.0-omni': {
488
+ soundCanBeDisabled: true,
489
+ maxPromptLength: 2500,
475
490
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
476
491
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
477
492
  // O3 Standard: 720p, as Standard above. Omni Pro is the 1080p tier.
@@ -482,6 +497,8 @@ export const MODEL_CAPABILITIES = {
482
497
  aspectRatioWithFirstFrame: 'with-references',
483
498
  },
484
499
  'kling-v3.0-omni-pro': {
500
+ soundCanBeDisabled: true,
501
+ maxPromptLength: 2500,
485
502
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
486
503
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
487
504
  videoResolution: { options: ['1080p', '4k'] },
@@ -493,12 +510,14 @@ export const MODEL_CAPABILITIES = {
493
510
  // Kling O3 video-to-video edit (fal-only; the source clip is the canvas, so
494
511
  // aspect/resolution/duration all follow it).
495
512
  'kling-v3.0-omni-edit': {
513
+ maxPromptLength: 2500,
496
514
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
497
515
  videoResolution: { options: ['1080p'], fixed: '1080p' },
498
516
  duration: { min: 3, max: 15, mode: 'continuous' },
499
517
  maxIngredientImages: 4, // elements + style refs combined (fal cap)
500
518
  },
501
519
  'kling-v3.0-omni-pro-edit': {
520
+ maxPromptLength: 2500,
502
521
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
503
522
  videoResolution: { options: ['1080p'], fixed: '1080p' },
504
523
  duration: { min: 3, max: 15, mode: 'continuous' },
@@ -513,6 +532,7 @@ export const MODEL_CAPABILITIES = {
513
532
  // (Kling O3, Seedance 2.5 and Omni Flash hold the reference seat), so there is
514
533
  // no transport for an ingredient. Frames are frame slots, not references.
515
534
  'kling-v4.0': {
535
+ maxPromptLength: 26000,
516
536
  aspectRatios: KLING_V4_ASPECT_RATIOS,
517
537
  videoResolution: { options: ['720p', '1080p'], default: '720p' },
518
538
  duration: { min: 3, max: 30, mode: 'continuous' },
@@ -533,6 +553,7 @@ export const MODEL_CAPABILITIES = {
533
553
  // 360p is NOT offered: it sits below every other row's floor and would need
534
554
  // a new resolution token in every exhaustive map.
535
555
  'omni-flash-1-2': {
556
+ maxPromptLength: 5000,
536
557
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
537
558
  videoResolution: { options: ['720p', '1080p', '4k'], default: '720p' },
538
559
  // fal: `duration` integer, minimum 3, maximum 15. Google: "any whole second
@@ -567,6 +588,7 @@ export const MODEL_CAPABILITIES = {
567
588
  firstFrameRidesAsReference: true,
568
589
  },
569
590
  'omni-flash-1-2-edit': {
591
+ maxPromptLength: 5000,
570
592
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
571
593
  // fal's v1.2 edit takes `resolution`, same enum and default; no duration
572
594
  // parameter, so the output follows the source clip.
@@ -588,6 +610,8 @@ export const MODEL_CAPABILITIES = {
588
610
  // ride reference-to-video; Alibaba: "First-and-last-frame mode and
589
611
  // all-reference mode are mutually exclusive."
590
612
  'wan-3.0': {
613
+ soundCanBeDisabled: true,
614
+ maxPromptLength: 20000,
591
615
  aspectRatios: WAN_3_ASPECT_RATIOS,
592
616
  // fal enum 480p / 720p / 1080p, schema default 1080p. Our default is 720p
593
617
  // for the Seedance 2.5 reason: a 30s take at 1080p is 300 credits, and
@@ -608,8 +632,38 @@ export const MODEL_CAPABILITIES = {
608
632
  maxReferenceVideoSeconds: 15,
609
633
  maxReferenceAudioSeconds: 15,
610
634
  },
635
+ // ── MAGI-2 (added 2026-11-26) ─────────────────────────────────────────────
636
+ //
637
+ // Every value READ OFF Kie's schemas for magi-2/{text,image,reference}-to-video,
638
+ // ripped 2026-11-25 (second-brain business/projects/slates/provider-docs/
639
+ // kie-magi-2-docs.md). Frames ride image-to-video and references ride
640
+ // reference-to-video; the two never travel together. No aspectRatioWithFirstFrame:
641
+ // the image-to-video request has no ratio field.
642
+ 'magi-2': {
643
+ soundCanBeDisabled: true,
644
+ promptOptionalWithFirstFrame: true,
645
+ referenceSecondsTolerance: 0,
646
+ maxPromptLength: 15000,
647
+ aspectRatios: MAGI_2_ASPECT_RATIOS,
648
+ // resolution enum is `1080p` alone on all three endpoints.
649
+ videoResolution: { options: ['1080p'], fixed: '1080p' },
650
+ // duration: integer 4-30 on all three endpoints.
651
+ duration: { min: 4, max: 30, mode: 'continuous' },
652
+ // reference_image_urls maxItems 10, reference_video_urls maxItems 5 and
653
+ // reference_audio_urls maxItems 5; each clip 2-30 s and 30 s per type.
654
+ // References are not billed, so the combined seconds count 'actual'.
655
+ maxIngredientImages: 10,
656
+ maxReferenceVideos: 5,
657
+ maxReferenceAudio: 5,
658
+ maxReferenceFilesTotal: 20,
659
+ referenceVideoDuration: { min: 2, max: 30 },
660
+ referenceAudioDuration: { min: 2, max: 30 },
661
+ maxReferenceVideoSeconds: 30,
662
+ maxReferenceAudioSeconds: 30,
663
+ },
611
664
  // ── Seedance ───────────────────────────────────────────────────────────────
612
665
  'seedance-2': {
666
+ maxPromptLength: 4000,
613
667
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
614
668
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '1080p' },
615
669
  duration: { min: 4, max: 15, mode: 'continuous' },
@@ -654,6 +708,7 @@ export const MODEL_CAPABILITIES = {
654
708
  aspectRatioWithFirstFrame: 'always',
655
709
  },
656
710
  'seedance-2.5': {
711
+ maxPromptLength: 4000,
657
712
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
658
713
  // Keep 720p as the default: a 30s take at 1080p is ~853 credits.
659
714
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
@@ -669,6 +724,7 @@ export const MODEL_CAPABILITIES = {
669
724
  minReferenceVideoSeconds: 2,
670
725
  },
671
726
  'seedance-2.5-edit': {
727
+ maxPromptLength: 4000,
672
728
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
673
729
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
674
730
  duration: { min: 4, max: 30, mode: 'continuous' },
@@ -700,6 +756,7 @@ export const MODEL_CAPABILITIES = {
700
756
  // different price at the tiers they share. Every lookup downstream is an
701
757
  // exact-id map, not a prefix.
702
758
  'minimax-h3': {
759
+ maxPromptLength: 7000,
703
760
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
704
761
  referenceAudioDuration: { min: 2, max: 15 },
705
762
  referenceVideoDuration: { min: 2, max: 15 },
@@ -734,6 +791,7 @@ export const MODEL_CAPABILITIES = {
734
791
  maxReferenceAudioSeconds: 15,
735
792
  },
736
793
  'minimax-h3-max': {
794
+ maxPromptLength: 7000,
737
795
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
738
796
  referenceAudioDuration: { min: 2, max: 15 },
739
797
  referenceVideoDuration: { min: 2, max: 15 },
@@ -770,6 +828,7 @@ export const MODEL_CAPABILITIES = {
770
828
  duration: { min: 5, max: 15, mode: 'continuous' },
771
829
  },
772
830
  'minimax-h3-max-turbo': {
831
+ maxPromptLength: 7000,
773
832
  aspectRatios: MINIMAX_H3_ASPECT_RATIOS,
774
833
  // fal schema for both Turbo endpoints, 2026-09-29: enum
775
834
  // ["480P","768P","1080P"], default "768P", the same 1080P "latent
@@ -792,12 +851,14 @@ export const MODEL_CAPABILITIES = {
792
851
  // are mirrored in three repos and locked by `pricing-consistency-check.mjs` §4
793
852
  // — moving them here would split one clamp across two files.
794
853
  'seed-audio': {
854
+ maxPromptLength: 2048,
795
855
  aspectRatios: [],
796
856
  // ONE image XOR up to 3 audio clips; the XOR is enforced by
797
857
  // `validateComposition`, this is only the image arm.
798
858
  maxRefImages: 1,
799
859
  },
800
860
  'eleven-sfx': {
861
+ maxPromptLength: 450,
801
862
  aspectRatios: [],
802
863
  },
803
864
  // ── Text-to-speech ─────────────────────────────────────────────────────────
@@ -1050,7 +1111,8 @@ export function referenceClipInBounds(model, kind, seconds) {
1050
1111
  if (!Number.isFinite(seconds) || seconds <= 0)
1051
1112
  return false;
1052
1113
  const { clip } = referenceSecondsBounds(model, kind);
1053
- return !clip || (seconds >= clip.min && seconds <= clip.max + REFERENCE_SECONDS_TOLERANCE);
1114
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1115
+ return !clip || (seconds >= clip.min && seconds <= clip.max + tolerance);
1054
1116
  }
1055
1117
  /**
1056
1118
  * THE verdict on a request's reference clips of one kind, from each clip's
@@ -1077,7 +1139,8 @@ export function checkReferenceSeconds(model, kind, clips, opts = {}) {
1077
1139
  return verdict(null);
1078
1140
  const total = basis === 'billed' ? billed : actual;
1079
1141
  const shown = basis === 'billed' ? `${billed}s, each clip rounded up to a whole second` : `${actual.toFixed(1)}s`;
1080
- if (max > 0 && total > max + (basis === 'billed' ? 0 : REFERENCE_SECONDS_TOLERANCE)) {
1142
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1143
+ if (max > 0 && total > max + (basis === 'billed' ? 0 : tolerance)) {
1081
1144
  return verdict(`${name} takes at most ${max}s of reference ${kind} in total, and this has ${shown}. Trim a clip first.`);
1082
1145
  }
1083
1146
  if (total < min) {
@@ -1094,6 +1157,28 @@ export function maxIngredientImagesFor(model, videoResolution) {
1094
1157
  return 0;
1095
1158
  return cap?.maxIngredientImages ?? 0;
1096
1159
  }
1160
+ export function requestSoundFor(model, requested) {
1161
+ return !MODEL_CAPABILITIES[model]?.soundCanBeDisabled || requested !== false;
1162
+ }
1163
+ export function promptLengthFor(_model, prompt) {
1164
+ return Array.from(prompt).length;
1165
+ }
1166
+ const maxLivePromptLength = Math.max(...Object.values(MODEL_CAPABILITIES).map(cap => cap.maxPromptLength ?? cap.maxCharacters ?? 0));
1167
+ export function promptLengthError(model, prompt) {
1168
+ const cap = model ? MODEL_CAPABILITIES[model] : undefined;
1169
+ const limit = cap?.maxPromptLength ?? cap?.maxCharacters ?? (cap?.imageResolutions ? 4000 : maxLivePromptLength);
1170
+ if (prompt && promptLengthFor(model ?? '', prompt) > limit) {
1171
+ return `${model || 'A Shot'} takes at most ${limit} prompt characters.`;
1172
+ }
1173
+ }
1174
+ export function videoPromptError(model, prompt, firstFrame, hasCuts = false) {
1175
+ const cap = MODEL_CAPABILITIES[model];
1176
+ if (prompt != null && typeof prompt !== 'string')
1177
+ return 'The prompt must be text.';
1178
+ if (!prompt?.trim() && !hasCuts && !(firstFrame && cap?.promptOptionalWithFirstFrame))
1179
+ return 'A prompt is required.';
1180
+ return promptLengthError(model, prompt ?? undefined);
1181
+ }
1097
1182
  /** Whether the aspect ratio shapes this request. With a start frame the frame
1098
1183
  * decides, unless the row's frame request carries a ratio
1099
1184
  * (`aspectRatioWithFirstFrame`). */
@@ -356,6 +356,17 @@ export const MODEL_FACTS = [
356
356
  ...caps('wan-3.0'),
357
357
  notes: 'Alibaba\'s video model, added 2026-10-17: first on Artificial Analysis text-to-video that day, at about a third of Seedance 2.5\'s price per second at 1080p. Long single takes, multi-shot sequences with timestamps, sound on or off. Start frame with an optional last frame, or references across images, videos and audio cited as Image N / Video N / Audio N (audio-only allowed); frames and references never mix. Reference video seconds bill on top of the output. Route here for long takes, timed multi-shot scenes and reference-driven shots on a budget; Seedance 2.5 stays the default. VIDEO-ONLY.',
358
358
  },
359
+ {
360
+ id: 'magi-2',
361
+ tipsKey: 'magi-2',
362
+ route: 'generate',
363
+ tier: 'specialist',
364
+ label: 'MAGI-2',
365
+ kind: 'video',
366
+ // 1080p only; 10 images + 5 videos + 5 audio, each clip 2-30s, 30s per type.
367
+ ...caps('magi-2'),
368
+ notes: "First on Artificial Analysis image-to-video that day, level with Seedance 2.5 inside the confidence interval, at a small fraction of its price per second. 1080p only, sound on or off. Start frame with an optional end frame, or references across images, videos and audio, each named in the prompt by what it shows; frames and references never mix, and references add nothing to the bill. Route here for small, cheap image-to-video jobs. Seedance 2.5 stays the default and runs the main workflow (draft, edit, upscale), and a Blender previs blocking always goes to Seedance 2.5 (MAGI-2 ignored one in our 2026-11-26 test). VIDEO-ONLY.",
369
+ },
359
370
  {
360
371
  id: 'seed-audio',
361
372
  tipsKey: 'seed-audio',
@@ -16,7 +16,7 @@ export interface PromptingTipsEntry {
16
16
  /** Footer callout paragraphs. */
17
17
  footer?: string[];
18
18
  }
19
- export type PromptingTipsKey = 'seedance' | 'seedance-2-5' | 'seedance-2-5-edit' | 'kling' | 'kling-edit' | 'omni-flash' | 'omni-flash-edit' | 'minimax-h3' | 'wan-3' | 'nano-banana' | 'gpt-image-2-6' | 'seed-audio' | 'eleven-sfx' | 'inworld-tts-2';
19
+ export type PromptingTipsKey = 'seedance' | 'seedance-2-5' | 'seedance-2-5-edit' | 'kling' | 'kling-edit' | 'omni-flash' | 'omni-flash-edit' | 'minimax-h3' | 'wan-3' | 'magi-2' | 'nano-banana' | 'gpt-image-2-6' | 'seed-audio' | 'eleven-sfx' | 'inworld-tts-2';
20
20
  export declare const PROMPTING_TIPS: Record<PromptingTipsKey, PromptingTipsEntry>;
21
21
  /** Null when no tips exist for the key — callers render an honest fallback. */
22
22
  export declare function getPromptingTips(key: string): PromptingTipsEntry | null;
@@ -756,6 +756,53 @@ const WAN_3 = {
756
756
  'Slates turns off the provider\'s prompt rewriter, so what you write is what the model reads. End with a short list of what must not appear (No subtitles, No watermark), never padded with what the prompt already says.',
757
757
  ],
758
758
  };
759
+ const MAGI_2 = {
760
+ label: 'MAGI-2',
761
+ intro: [
762
+ 'MAGI-2 makes 1080p video with its own soundtrack (dialogue, effects, ambience, music), sound on or off. Text-to-video, a start frame with an optional end frame, or references across images, video clips and audio clips. Frames and references never mix, and references add nothing to the price.',
763
+ ],
764
+ columns: [
765
+ [
766
+ {
767
+ heading: "Write the whole shot as a director's caption",
768
+ example: 'Subject and setting · the action beat by beat · camera · light · Sound: line',
769
+ note: 'The Preview model trained on structured captions. Try that format for a shot with several beats. Plain, direct English, heavy on verbs and on how things change over time.',
770
+ },
771
+ {
772
+ heading: 'From a start frame, spend the words on motion',
773
+ example: 'Open on the frame as it is; she turns to the window, lifts the cup and sets it down while the camera eases closer',
774
+ note: 'The frame already fixes the look. Describe the start, the movement and where it ends, and how bodies and objects keep their shape through fast motion.',
775
+ critical: true,
776
+ },
777
+ {
778
+ heading: 'Name each reference by what it shows',
779
+ example: 'The woman in the first reference image, the red-haired runner, leads; keep her face, hair and outfit the same',
780
+ note: 'Say which reference and what it is, every time. Never a bare tag, never an @ sign, and give every image a role: character, product, wardrobe, location or style.',
781
+ critical: true,
782
+ },
783
+ ],
784
+ [
785
+ {
786
+ heading: 'Numbered shots for longer takes',
787
+ example: 'Shot 1: wide, rain over the harbour. Shot 2: close-up, her hands on the rope.',
788
+ note: 'One event per shot, starting just before the action and ending on its result. Repeat key appearance details in every shot.',
789
+ },
790
+ {
791
+ heading: 'A Sound: line, and dialogue in quotes',
792
+ example: 'Sound: gravel under the tyres, gulls, low wind, continuing to the very last frame · She says: "Not here."',
793
+ note: 'Name the sources you want to hear. Write dialogue yourself, in the language it should be spoken.',
794
+ },
795
+ {
796
+ heading: 'Describe visible targets',
797
+ example: 'static camera · an empty street · clear daylight',
798
+ note: 'Try naming what should appear in the frame. A readable sign or label: the exact words, facing the camera, held still for a second.',
799
+ },
800
+ ],
801
+ ],
802
+ footer: [
803
+ 'Draft at a short length, then render the full take once the shot works. The provider may rewrite prompts on its side and offers no switch to turn that off on this model.',
804
+ ],
805
+ };
759
806
  export const PROMPTING_TIPS = {
760
807
  seedance: SEEDANCE,
761
808
  'seedance-2-5': SEEDANCE_25,
@@ -766,6 +813,7 @@ export const PROMPTING_TIPS = {
766
813
  'omni-flash-edit': OMNI_FLASH_EDIT,
767
814
  'minimax-h3': MINIMAX_H3,
768
815
  'wan-3': WAN_3,
816
+ 'magi-2': MAGI_2,
769
817
  'nano-banana': NANO_BANANA,
770
818
  'gpt-image-2-6': GPT_IMAGE_26,
771
819
  'seed-audio': SEED_AUDIO,
@@ -64,7 +64,8 @@ export const BRAIN_SHAPE = {
64
64
  "slates-prompting-seedance",
65
65
  "slates-prompting-seedance-2-5",
66
66
  "slates-prompting-seedream-5-5",
67
- "slates-prompting-wan-3"
67
+ "slates-prompting-wan-3",
68
+ "slates-prompting-magi-2"
68
69
  ]
69
70
  },
70
71
  "caps": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slatesvideo/shared",
3
- "version": "0.7.22",
3
+ "version": "0.7.23",
4
4
  "description": "Shared operations layer for the Slates MCP server and CLI: auth, cloud/desktop clients, and the single tool surface both consume. Most users want @slatesvideo/mcp-server or @slatesvideo/cli instead.",
5
5
  "license": "MIT",
6
6
  "type": "module",