@slatesvideo/shared 0.7.21 → 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.
@@ -37,7 +37,7 @@
37
37
  // `@slatesvideo/shared`). Rates, credit costs and cost-key builders deliberately
38
38
  // did NOT move — billing stays in slate with its existing checkers.
39
39
  //
40
- // ⚠️ LEAF MODULE — no imports, no Node built-ins. The desktop RENDERER reaches
40
+ // ⚠️ LEAF MODULE — no imports but its sibling leaf `retired-models.ts`, no Node built-ins. The desktop RENDERER reaches
41
41
  // this through `@slatesvideo/shared/prompts`, so anything pulled in here has to
42
42
  // bundle for the browser.
43
43
  //
@@ -47,6 +47,7 @@
47
47
  // `reference-caps-lockstep-check.mjs`, `pricing-consistency-check.mjs`. If a
48
48
  // value moved, they go red.
49
49
  // ─────────────────────────────────────────────────────────────────────────────
50
+ import { RETIRED_MODELS } from './retired-models.js';
50
51
  /**
51
52
  * The full ten, in display order. `9:21` was in the MCP op's enum and in NO
52
53
  * model — it was invented downstream. Do not add a ratio here that no model
@@ -83,6 +84,13 @@ const OMNI_FLASH_ASPECT_RATIOS = ['16:9', '9:16'];
83
84
  * the H3 rows make.
84
85
  */
85
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'];
86
94
  /** Seedance (both seats, and the edit row): six — notably NO `4:5`. */
87
95
  const SEEDANCE_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
88
96
  /**
@@ -100,18 +108,6 @@ const SEEDANCE_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
100
108
  * is not an AspectRatio in this vocabulary.
101
109
  */
102
110
  const MINIMAX_H3_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
103
- /**
104
- * LTX-2.5, all four integrated endpoints: TWO. Read off fal's live OpenAPI
105
- * 2026-08-29 — `text-to-video/{fast,pro}` declare exactly `['16:9','9:16']`,
106
- * the narrowest video set in the roster.
107
- *
108
- * `image-to-video/{fast,pro}` additionally offer `auto` (follow the start
109
- * frame). We never send it and it is not an `AspectRatio` in this vocabulary —
110
- * identical treatment to H3's `adaptive`, and for the identical reason: the
111
- * composer always holds an explicit ratio, so `auto` would only ever be a way
112
- * to lose track of what was actually generated.
113
- */
114
- const LTX_2_5_ASPECT_RATIOS = ['16:9', '9:16'];
115
111
  export const GPT_QUALITY_TIERS = ['low', 'medium', 'high', 'xhigh', 'max'];
116
112
  export const DEFAULT_GPT_QUALITY = 'high';
117
113
  export const GPT_BACKGROUNDS = ['auto', 'transparent', 'opaque'];
@@ -327,6 +323,8 @@ export const FLUX_3_RESOLUTIONS = {
327
323
  '2k': '1.5k',
328
324
  '4k': '2k',
329
325
  };
326
+ /** Largest conditioned video the direct reference upload must carry. */
327
+ export const VIDEO_REFERENCE_UPLOAD_BYTES = 200 * 1024 * 1024;
330
328
  /**
331
329
  * The provider every AGENT generation actually lands on for Kling.
332
330
  *
@@ -458,45 +456,68 @@ export const MODEL_CAPABILITIES = {
458
456
  // pro: ... The output video resolution is 1080P." The fal Standard endpoint
459
457
  // takes no resolution parameter, and every Standard and Omni render we
460
458
  // measured came back 1280x720 (2026-09-29). This row said 1080p until then.
459
+ //
460
+ // `noReferenceImagesAt: ['4k']` on all four: the 4K seats are sold as
461
+ // text-to-video and image-to-video only (fal has no 4K reference-to-video).
462
+ // `aspectRatioWithFirstFrame`: fal's v3 and O3 image-to-video schemas have no
463
+ // `aspect_ratio` (the frame decides); O3 reference-to-video, where a frame
464
+ // with reference images lands, takes the three-ratio enum (fal OpenAPI, read
465
+ // 2026-11-24).
461
466
  'kling-v3.0-std': {
467
+ soundCanBeDisabled: true,
468
+ maxPromptLength: 2500,
462
469
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
463
470
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
464
471
  videoResolution: { options: ['720p', '4k'] },
465
472
  // 3, not 5. The op claimed "Kling: 5-15" and refused legal 3-4s takes.
466
473
  duration: { min: 3, max: 15, mode: 'continuous' },
467
474
  maxIngredientImages: 4,
475
+ noReferenceImagesAt: ['4k'],
468
476
  },
469
477
  'kling-v3.0-pro': {
478
+ soundCanBeDisabled: true,
479
+ maxPromptLength: 2500,
470
480
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
471
481
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
472
482
  videoResolution: { options: ['1080p', '4k'] },
473
483
  duration: { min: 3, max: 15, mode: 'continuous' },
474
484
  maxIngredientImages: 4,
485
+ noReferenceImagesAt: ['4k'],
475
486
  },
476
487
  'kling-v3.0-omni': {
488
+ soundCanBeDisabled: true,
489
+ maxPromptLength: 2500,
477
490
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
478
491
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
479
492
  // O3 Standard: 720p, as Standard above. Omni Pro is the 1080p tier.
480
493
  videoResolution: { options: ['720p', '4k'] },
481
494
  duration: { min: 3, max: 15, mode: 'continuous' },
482
495
  maxIngredientImages: 4,
496
+ noReferenceImagesAt: ['4k'],
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'] },
488
505
  duration: { min: 3, max: 15, mode: 'continuous' },
489
506
  maxIngredientImages: 4,
507
+ noReferenceImagesAt: ['4k'],
508
+ aspectRatioWithFirstFrame: 'with-references',
490
509
  },
491
510
  // Kling O3 video-to-video edit (fal-only; the source clip is the canvas, so
492
511
  // aspect/resolution/duration all follow it).
493
512
  'kling-v3.0-omni-edit': {
513
+ maxPromptLength: 2500,
494
514
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
495
515
  videoResolution: { options: ['1080p'], fixed: '1080p' },
496
516
  duration: { min: 3, max: 15, mode: 'continuous' },
497
517
  maxIngredientImages: 4, // elements + style refs combined (fal cap)
498
518
  },
499
519
  'kling-v3.0-omni-pro-edit': {
520
+ maxPromptLength: 2500,
500
521
  aspectRatios: KLING_FAL_ASPECT_RATIOS,
501
522
  videoResolution: { options: ['1080p'], fixed: '1080p' },
502
523
  duration: { min: 3, max: 15, mode: 'continuous' },
@@ -511,6 +532,7 @@ export const MODEL_CAPABILITIES = {
511
532
  // (Kling O3, Seedance 2.5 and Omni Flash hold the reference seat), so there is
512
533
  // no transport for an ingredient. Frames are frame slots, not references.
513
534
  'kling-v4.0': {
535
+ maxPromptLength: 26000,
514
536
  aspectRatios: KLING_V4_ASPECT_RATIOS,
515
537
  videoResolution: { options: ['720p', '1080p'], default: '720p' },
516
538
  duration: { min: 3, max: 30, mode: 'continuous' },
@@ -531,6 +553,7 @@ export const MODEL_CAPABILITIES = {
531
553
  // 360p is NOT offered: it sits below every other row's floor and would need
532
554
  // a new resolution token in every exhaustive map.
533
555
  'omni-flash-1-2': {
556
+ maxPromptLength: 5000,
534
557
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
535
558
  videoResolution: { options: ['720p', '1080p', '4k'], default: '720p' },
536
559
  // fal: `duration` integer, minimum 3, maximum 15. Google: "any whole second
@@ -556,8 +579,16 @@ export const MODEL_CAPABILITIES = {
556
579
  // No combined ceiling is published, so the total is the two arms summed.
557
580
  // Google: "Uploading audio inputs or audio references is unsupported".
558
581
  maxReferenceFilesTotal: 9,
582
+ // fal's v1.2 image-to-video takes `aspect_ratio` (16:9 / 9:16, default
583
+ // 16:9), so the ratio is a real parameter beside a start frame.
584
+ aspectRatioWithFirstFrame: 'always',
585
+ // fal's v1.2 reference-to-video takes `image_urls` and `reference_video_urls`
586
+ // together and has no frame slot: a start frame is sent as reference image 1
587
+ // beside reference images or reference videos, and a last frame is refused.
588
+ firstFrameRidesAsReference: true,
559
589
  },
560
590
  'omni-flash-1-2-edit': {
591
+ maxPromptLength: 5000,
561
592
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
562
593
  // fal's v1.2 edit takes `resolution`, same enum and default; no duration
563
594
  // parameter, so the output follows the source clip.
@@ -579,6 +610,8 @@ export const MODEL_CAPABILITIES = {
579
610
  // ride reference-to-video; Alibaba: "First-and-last-frame mode and
580
611
  // all-reference mode are mutually exclusive."
581
612
  'wan-3.0': {
613
+ soundCanBeDisabled: true,
614
+ maxPromptLength: 20000,
582
615
  aspectRatios: WAN_3_ASPECT_RATIOS,
583
616
  // fal enum 480p / 720p / 1080p, schema default 1080p. Our default is 720p
584
617
  // for the Seedance 2.5 reason: a 30s take at 1080p is 300 credits, and
@@ -599,8 +632,38 @@ export const MODEL_CAPABILITIES = {
599
632
  maxReferenceVideoSeconds: 15,
600
633
  maxReferenceAudioSeconds: 15,
601
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
+ },
602
664
  // ── Seedance ───────────────────────────────────────────────────────────────
603
665
  'seedance-2': {
666
+ maxPromptLength: 4000,
604
667
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
605
668
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '1080p' },
606
669
  duration: { min: 4, max: 15, mode: 'continuous' },
@@ -637,8 +700,15 @@ export const MODEL_CAPABILITIES = {
637
700
  maxReferenceFilesTotal: 12,
638
701
  maxReferenceVideoSeconds: 15,
639
702
  maxReferenceAudioSeconds: 15,
703
+ // The vref key bills each clip rounded up, and its ladder ends at the cap
704
+ // plus the longest output. Providers state "video refs combined 2-15s".
705
+ referenceVideoSecondsBasis: 'billed',
706
+ minReferenceVideoSeconds: 2,
707
+ // The frames task sends the chosen ratio (2.5 sends `adaptive` instead).
708
+ aspectRatioWithFirstFrame: 'always',
640
709
  },
641
710
  'seedance-2.5': {
711
+ maxPromptLength: 4000,
642
712
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
643
713
  // Keep 720p as the default: a 30s take at 1080p is ~853 credits.
644
714
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
@@ -650,24 +720,19 @@ export const MODEL_CAPABILITIES = {
650
720
  maxReferenceFilesTotal: 50,
651
721
  maxReferenceVideoSeconds: 30,
652
722
  maxReferenceAudioSeconds: 30,
723
+ referenceVideoSecondsBasis: 'billed',
724
+ minReferenceVideoSeconds: 2,
653
725
  },
654
726
  'seedance-2.5-edit': {
727
+ maxPromptLength: 4000,
655
728
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
656
729
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
657
730
  duration: { min: 4, max: 30, mode: 'continuous' },
658
- // 🚨 ZERO, AND IT MUST MATCH WHAT THE HANDLER SENDS. The model's edit task
659
- // type does accept reference images, but slate's
660
- // `generation/handlers/edit-video.ts` sends the prompt and the source clip
661
- // and NOTHING ELSE on this row — no `image_urls` on the EvoLink call, no
662
- // `image_url` items in the BytePlus content array. This declared 30 while
663
- // the handler sent 0, so attaching references produced no error, no
664
- // warning, and no images in the request: a silent drop, which is the one
665
- // outcome `validateComposition` exists to prevent. Both sibling edit rows
666
- // already model this correctly (Omni Flash Edit is 0 and warns "takes the
667
- // prompt + source clip only"; Kling O3 Edit is 4 and actually sends them).
668
- //
669
- // Raising it is a HANDLER change first: wire the refs, then move the cap.
670
- maxIngredientImages: 0,
731
+ // ByteDance recommends 1–5 reference images on video edits ("replace the man
732
+ // in dark clothing in @Video 1 with @Image 2"). Wired in slate's
733
+ // `generation/handlers/edit-video.ts` (BytePlus `role: 'reference_image'`
734
+ // items + EvoLink `image_urls`) and V2V Video Brush / Swap Person / Location.
735
+ maxIngredientImages: 5,
671
736
  // NO multimodal reference caps, deliberately: on an edit row the clip IS the
672
737
  // canvas and arrives through `sourceVideo`, not as a reference.
673
738
  },
@@ -691,6 +756,7 @@ export const MODEL_CAPABILITIES = {
691
756
  // different price at the tiers they share. Every lookup downstream is an
692
757
  // exact-id map, not a prefix.
693
758
  'minimax-h3': {
759
+ maxPromptLength: 7000,
694
760
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
695
761
  referenceAudioDuration: { min: 2, max: 15 },
696
762
  referenceVideoDuration: { min: 2, max: 15 },
@@ -725,6 +791,7 @@ export const MODEL_CAPABILITIES = {
725
791
  maxReferenceAudioSeconds: 15,
726
792
  },
727
793
  'minimax-h3-max': {
794
+ maxPromptLength: 7000,
728
795
  // fal reference-to-video schema, 2026-09-09: each audio clip is 2-15s.
729
796
  referenceAudioDuration: { min: 2, max: 15 },
730
797
  referenceVideoDuration: { min: 2, max: 15 },
@@ -761,6 +828,7 @@ export const MODEL_CAPABILITIES = {
761
828
  duration: { min: 5, max: 15, mode: 'continuous' },
762
829
  },
763
830
  'minimax-h3-max-turbo': {
831
+ maxPromptLength: 7000,
764
832
  aspectRatios: MINIMAX_H3_ASPECT_RATIOS,
765
833
  // fal schema for both Turbo endpoints, 2026-09-29: enum
766
834
  // ["480P","768P","1080P"], default "768P", the same 1080P "latent
@@ -774,87 +842,6 @@ export const MODEL_CAPABILITIES = {
774
842
  // image-to-video and live in MODEL_REGISTRY.features.lastFrame.
775
843
  maxIngredientImages: 0,
776
844
  },
777
- // ── LTX-2.5 (both seats on fal — added 2026-08-29) ─────────────────────────
778
- //
779
- // Every value below is READ OFF fal's live OpenAPI, fetched 2026-08-29:
780
- // lightricks/ltx-2.5/{text-to-video,image-to-video}/{fast,pro}
781
- // Note the owner namespace — no `fal-ai/` prefix, exactly like `minimax/h3/`.
782
- //
783
- // 🚨 SAME PREFIX COLLISION AS THE MINIMAX PAIR, AND IT IS WORSE HERE.
784
- // `ltx-2-5-pro` starts with `ltx-2-5`, so ANY `startsWith('ltx-2-5')` swallows
785
- // the Pro row into the Fast row's branch — a shorter ladder, a shorter
786
- // duration list AND a 31-33% higher price at both tiers they share. Every
787
- // lookup downstream is an exact-id map, never a prefix test.
788
- //
789
- // 🚨 THE CHEAP ROW IS THE ONE WITH THE LONGER REACH. Counter to how every
790
- // other Fast/Pro pair in this file behaves, `ltx-2-5` (the distilled 8-step
791
- // build) reaches 1440p, 4K and 20s while `ltx-2-5-pro` (full diffusion) stops
792
- // at 1080p and 10s. Pro buys fidelity on a NARROWER ladder. Do not "fix" this
793
- // by assuming Pro is a superset — it is not, on either axis.
794
- //
795
- // ⛔ `audio-to-video/{fast,pro}` EXIST AND ARE DELIBERATELY ABSENT from this
796
- // file. They carry no `resolution` and no `duration` parameter at all: output
797
- // length is dictated by the uploaded audio, so they bill per second of INPUT
798
- // while every credit key we own bills OUTPUT. That is a billing-SHAPE change,
799
- // not a missing row. See slates-api/PRICING.md.
800
- 'ltx-2-5': {
801
- aspectRatios: LTX_2_5_ASPECT_RATIOS,
802
- // Full ladder, all four tiers NATIVELY generated (no upscale pass anywhere
803
- // — the contrast with H3's 2K/4K is the whole reason `1440p` is its own
804
- // token). DEFAULT 1080p, which is also fal's own schema default: unusually
805
- // for this file the default tier is not the floor. It is the cheapest
806
- // native 1080p second in the roster at $0.130/s.
807
- videoResolution: { options: ['720p', '1080p', '1440p', '4k'], default: '1080p' },
808
- // 🚨 DISCRETE AND EVEN-ONLY. There is NO 5s LTX clip and no odd duration of
809
- // any length — fal's enum is literally [6,8,10,12,14,16,18,20]. A
810
- // `{ min: 6, max: 20, mode: 'continuous' }` here would offer 7s in the
811
- // composer, quote a `ltx-2-5-1080p-7s` key that exists on no server, and
812
- // fail at the proxy after the user had already chosen it.
813
- //
814
- // The evenness is also what makes all 28 cost keys round exactly (every
815
- // basis is a multiple of CENTS_PER_CREDIT=3) — see PRICING.md. If fal ever
816
- // admits odd seconds, the rounding proof must be re-verified.
817
- duration: {
818
- min: 6,
819
- max: 20,
820
- mode: 'discrete',
821
- values: [6, 8, 10, 12, 14, 16, 18, 20],
822
- // fal: "At 720p and 1080p, 24 or 25 FPS supports up to 20 seconds […] At
823
- // 1440p and 2160p, all frame rates support up to 10 seconds."
824
- //
825
- // ⚠️ THE REAL CEILING IS A FUNCTION OF RESOLUTION *AND* FPS, and this
826
- // field can only express the resolution half. It is correct ONLY because
827
- // we pin fps to fal's default of 25 and never expose the control. If fps
828
- // is ever exposed, 48/50 drops the 720p/1080p ceiling to 10s too, and
829
- // that needs a second override axis — not a wider window here.
830
- resolutionOverrides: {
831
- '1440p': { min: 6, max: 10, mode: 'discrete', values: [6, 8, 10] },
832
- '4k': { min: 6, max: 10, mode: 'discrete', values: [6, 8, 10] },
833
- },
834
- },
835
- // NO reference caps of any kind, deliberately. fal publishes text-to-video
836
- // and image-to-video for LTX and NOTHING else — there is no
837
- // `reference-to-video` endpoint, so there is no transport for an ingredient
838
- // or a multimodal reference, and a cap declared above what the handler
839
- // sends is a SILENT DROP (the failure `seedance-2.5-edit` shipped with).
840
- // The start/end frames i2v does carry are FRAME SLOTS, not references, and
841
- // live in MODEL_REGISTRY.features.lastFrame — not here.
842
- },
843
- 'ltx-2-5-pro': {
844
- aspectRatios: LTX_2_5_ASPECT_RATIOS,
845
- // 720p/1080p ONLY. Declaring the shorter ladder here IS the whole Pro-seat
846
- // mechanism: `assertVideoCapabilities` refuses 1440p/4K on this id, the
847
- // desktop picker renders only what this entry declares, and the agent's Zod
848
- // enum stays the union while the per-model guard narrows. Anything shaped
849
- // like "hide the top tiers when Pro is selected" re-implements a guard that
850
- // already exists.
851
- videoResolution: { options: ['720p', '1080p'], default: '1080p' },
852
- // Three values, full stop — fal's enum is [6,8,10] on both Pro endpoints,
853
- // with no resolution override needed because the ceiling is already 10s at
854
- // both tiers this row reaches.
855
- duration: { min: 6, max: 10, mode: 'discrete', values: [6, 8, 10] },
856
- // No reference caps — same reasoning as the Fast row above.
857
- },
858
845
  // ── Audio ──────────────────────────────────────────────────────────────────
859
846
  //
860
847
  // `aspectRatios: []` is deliberate, not an oversight: audio has no frame, and
@@ -864,12 +851,14 @@ export const MODEL_CAPABILITIES = {
864
851
  // are mirrored in three repos and locked by `pricing-consistency-check.mjs` §4
865
852
  // — moving them here would split one clamp across two files.
866
853
  'seed-audio': {
854
+ maxPromptLength: 2048,
867
855
  aspectRatios: [],
868
856
  // ONE image XOR up to 3 audio clips; the XOR is enforced by
869
857
  // `validateComposition`, this is only the image arm.
870
858
  maxRefImages: 1,
871
859
  },
872
860
  'eleven-sfx': {
861
+ maxPromptLength: 450,
873
862
  aspectRatios: [],
874
863
  },
875
864
  // ── Text-to-speech ─────────────────────────────────────────────────────────
@@ -905,31 +894,9 @@ export const MODEL_CAPABILITIES = {
905
894
  },
906
895
  };
907
896
  // ── Retired seats ────────────────────────────────────────────────────────────
908
- /**
909
- * Seats that left the roster, each with the seat that replaced it. The desktop
910
- * moves a stored or sent id onto its replacement (slate `migrateRetiredModel`,
911
- * which reads this map and adds the retired video seats this repo does not name).
912
- * The server keeps their cost keys so desktops released before a retirement
913
- * still bill; the list and estimate ops hide those keys and name the replacement
914
- * instead.
915
- */
916
- export const RETIRED_MODELS = {
917
- // 2026-09-09: GPT Image 2.5 replaced it; Sunburst is the seat that does not
918
- // downgrade. 2026-11-10 (Eric): GPT Image 2.6 replaced 2.5, seat for seat.
919
- 'gpt-image-2': 'gpt-image-2-6-sunburst',
920
- 'gpt-image-2-5-flare': 'gpt-image-2-6-flare',
921
- 'gpt-image-2-5-sunburst': 'gpt-image-2-6-sunburst',
922
- // 2026-10-23 (Eric): Nano Banana 2.1 replaced every Nano Banana row, FLUX 3 Image replaced FLUX.2 Max.
923
- 'nano-banana-2': 'nano-banana-2-1',
924
- 'nano-banana-2-lite': 'nano-banana-2-1',
925
- 'nano-banana-pro': 'nano-banana-2-1',
926
- 'flux-2-max': 'flux-3',
927
- // 2026-11-10 (Eric, "Yes, same release"): Gemini Omni Flash 1.2 replaced 1.1, seat for seat.
928
- 'omni-flash': 'omni-flash-1-2',
929
- 'omni-flash-edit': 'omni-flash-1-2-edit',
930
- // 2026-11-16 (Eric): Seedream 5.5 replaced Seedream 5 Lite and became the default image seat.
931
- 'seedream-5-lite': 'seedream-5-5',
932
- };
897
+ // The one list of retired seats lives in its own leaf, re-exported here so
898
+ // `@slatesvideo/shared/model-capabilities` importers read it where they always did.
899
+ export { RETIRED_MODELS, RETIRED_SEATS, HISTORY_MODEL_LABELS } from './retired-models.js';
933
900
  /**
934
901
  * The retired seat a cost key bills, or null when the key belongs to a current
935
902
  * row or to no row. A key is its row's id, alone or followed by `-` and its
@@ -1053,11 +1020,173 @@ export function checkReferenceShape(model, opts) {
1053
1020
  ? `${name} takes ${s(long.max)} on a clip over ${long.aboveSeconds}s (up to ${cap.maxReferenceVideos} at ${long.aboveSeconds}s or less), and this has ${count}. Set ${long.aboveSeconds}s or less, or remove ${count - maxClips}.`
1054
1021
  : `${name} takes at most ${s(maxClips)}, and this has ${count}.`;
1055
1022
  }
1056
- const bounds = cap.referenceVideoDuration;
1057
- if (bounds && clips.some((sec) => !Number.isFinite(sec) || sec > bounds.max + 0.05 || sec < bounds.min)) {
1058
- return `Each ${name} reference video must be ${bounds.min}-${bounds.max}s long. Trim it first.`;
1023
+ return checkReferenceSeconds(model, 'video', clips, { label: name }).error;
1024
+ }
1025
+ /**
1026
+ * Frames beside reference video or audio. A reference endpoint has no frame
1027
+ * parameters, so the pair is refused, never sent with one side dropped. A row
1028
+ * that sends a first frame as reference image 1 (`firstFrameRidesAsReference`)
1029
+ * carries it there, and only its last frame has no slot. A plain message naming
1030
+ * `label`, or null. One function for the agent op, the desktop's composer and
1031
+ * the handlers.
1032
+ */
1033
+ export function checkFramesWithReferenceMedia(model, opts) {
1034
+ const cap = MODEL_CAPABILITIES[model];
1035
+ if (!cap || (opts.referenceVideos ?? 0) + (opts.referenceAudio ?? 0) === 0)
1036
+ return null;
1037
+ const name = opts.label ?? model;
1038
+ if (cap.firstFrameRidesAsReference) {
1039
+ return opts.lastFrame ? `${name} takes a last frame only without references. Remove the last frame or the references.` : null;
1059
1040
  }
1060
- return null;
1041
+ return opts.firstFrame || opts.lastFrame
1042
+ ? `${name} takes first and last frames or reference video and audio, not both: its reference endpoint has no frame slots. Remove one side.`
1043
+ : null;
1044
+ }
1045
+ // ── Reference seconds: one rounding, one tolerance, one verdict ──────────────
1046
+ //
1047
+ // The agent op, the desktop's composition check, the generation handlers and
1048
+ // the server's key derivations all call the functions below, so a clip set one
1049
+ // layer accepts is never refused by the next.
1050
+ /** A probe reads a clip a few hundredths long (an "8 second" file measures
1051
+ * 8.02), so that much over a whole second or over a ceiling is not counted. */
1052
+ export const REFERENCE_SECONDS_TOLERANCE = 0.05;
1053
+ /** An edit's source clip is probed the same way, so it takes the same slack. */
1054
+ export const EDIT_SECONDS_TOLERANCE = REFERENCE_SECONDS_TOLERANCE;
1055
+ /** The whole seconds a probed length counts as: up past the probe slack, so
1056
+ * 4.3s is 5 and 8.02s is 8. The one rounding every billed clip length takes;
1057
+ * slates-api's `check:all` fails on a copy of it anywhere else. */
1058
+ export function probedWholeSeconds(seconds) {
1059
+ return Math.ceil(seconds - REFERENCE_SECONDS_TOLERANCE);
1060
+ }
1061
+ /** The whole seconds a reference-video key bills for these clips: each measured
1062
+ * clip rounds up on its own (4.3s bills 5, 8.02s bills 8), never the sum. A
1063
+ * length of zero or less is an unmeasured clip and adds nothing. */
1064
+ export function billedReferenceSeconds(clips) {
1065
+ let total = 0;
1066
+ for (const sec of clips) {
1067
+ if (Number.isFinite(sec) && sec > 0)
1068
+ total += Math.max(1, probedWholeSeconds(sec));
1069
+ }
1070
+ return total;
1071
+ }
1072
+ /** The whole seconds a video edit bills for a measured source clip. An edit's
1073
+ * output follows its source, so the row's duration window is the clip window
1074
+ * and the probed length is held inside it. A row with no window throws: an
1075
+ * edit priced on a guessed window bills the wrong key. */
1076
+ export function billedEditSeconds(model, seconds) {
1077
+ const window = MODEL_CAPABILITIES[model]?.duration;
1078
+ if (!window)
1079
+ throw new Error(`billedEditSeconds: no duration capability for "${model}"`);
1080
+ return Math.min(window.max, Math.max(window.min, probedWholeSeconds(seconds)));
1081
+ }
1082
+ /** Lip-sync and motion transfer bill in whole blocks of this many seconds. */
1083
+ export const TOOL_BLOCK_SECONDS = 5;
1084
+ /** The whole tool blocks a length bills: rounded up with no probe slack, since a
1085
+ * block already absorbs it (a 5.02s clip and a 5.0s clip are both one block).
1086
+ * Zero for no length; each caller sets its own floor. */
1087
+ export function toolBlocks(seconds) {
1088
+ return Math.ceil(seconds / TOOL_BLOCK_SECONDS);
1089
+ }
1090
+ /** A tool's credit key for `blocks` whole blocks: `${stem}-${blocks × 5}s`, as the
1091
+ * server's price list names them. */
1092
+ export function toolBlockKey(stem, blocks) {
1093
+ return `${stem}-${blocks * TOOL_BLOCK_SECONDS}s`;
1094
+ }
1095
+ /** The per-clip window, the least and most combined seconds a row takes for one
1096
+ * kind of reference, and how its combined cap is counted. `max` 0 = no cap. */
1097
+ export function referenceSecondsBounds(model, kind) {
1098
+ const cap = MODEL_CAPABILITIES[model];
1099
+ const clip = kind === 'video' ? cap?.referenceVideoDuration : cap?.referenceAudioDuration;
1100
+ return {
1101
+ clip,
1102
+ min: (kind === 'video' ? cap?.minReferenceVideoSeconds : undefined) ?? clip?.min ?? 0,
1103
+ max: (kind === 'video' ? cap?.maxReferenceVideoSeconds : cap?.maxReferenceAudioSeconds) ?? 0,
1104
+ basis: kind === 'video' ? (cap?.referenceVideoSecondsBasis ?? 'actual') : 'actual',
1105
+ };
1106
+ }
1107
+ /** Whether one measured clip fits the row's per-clip window. The ceiling takes
1108
+ * the probe tolerance; the floor does not (a probe never reads short). A row
1109
+ * with no per-clip window takes any measured length. */
1110
+ export function referenceClipInBounds(model, kind, seconds) {
1111
+ if (!Number.isFinite(seconds) || seconds <= 0)
1112
+ return false;
1113
+ const { clip } = referenceSecondsBounds(model, kind);
1114
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1115
+ return !clip || (seconds >= clip.min && seconds <= clip.max + tolerance);
1116
+ }
1117
+ /**
1118
+ * THE verdict on a request's reference clips of one kind, from each clip's
1119
+ * length in seconds: every clip inside the row's per-clip window, and the
1120
+ * combined length inside the row's bounds, counted on the row's own basis
1121
+ * (`referenceVideoSecondsBasis`). A length of zero or less is a clip nobody has
1122
+ * measured yet: it is skipped, unless `measured` says every clip was probed, in
1123
+ * which case it is refused. A row with no bounds for the kind accepts.
1124
+ */
1125
+ export function checkReferenceSeconds(model, kind, clips, opts = {}) {
1126
+ const name = opts.label ?? model;
1127
+ const known = clips.filter((sec) => Number.isFinite(sec) && sec > 0);
1128
+ const actual = known.reduce((n, sec) => n + sec, 0);
1129
+ const billed = billedReferenceSeconds(known);
1130
+ const verdict = (error) => ({ actual, billed, error });
1131
+ if (opts.measured && known.length < clips.length) {
1132
+ return verdict(`A reference ${kind} clip could not be measured. Attach it again.`);
1133
+ }
1134
+ const { clip, min, max, basis } = referenceSecondsBounds(model, kind);
1135
+ if (clip && known.some((sec) => !referenceClipInBounds(model, kind, sec))) {
1136
+ return verdict(`Each ${name} reference ${kind === 'audio' ? 'audio clip' : kind} must be ${clip.min}-${clip.max}s long. Trim it first.`);
1137
+ }
1138
+ if (known.length === 0)
1139
+ return verdict(null);
1140
+ const total = basis === 'billed' ? billed : actual;
1141
+ const shown = basis === 'billed' ? `${billed}s, each clip rounded up to a whole second` : `${actual.toFixed(1)}s`;
1142
+ const tolerance = MODEL_CAPABILITIES[model]?.referenceSecondsTolerance ?? REFERENCE_SECONDS_TOLERANCE;
1143
+ if (max > 0 && total > max + (basis === 'billed' ? 0 : tolerance)) {
1144
+ return verdict(`${name} takes at most ${max}s of reference ${kind} in total, and this has ${shown}. Trim a clip first.`);
1145
+ }
1146
+ if (total < min) {
1147
+ return verdict(`${name} needs at least ${min}s of reference ${kind} in total, and this has ${shown}.`);
1148
+ }
1149
+ return verdict(null);
1150
+ }
1151
+ /** Reference images a request may carry at this resolution: none where the
1152
+ * row's endpoint for that resolution has no reference slot
1153
+ * (`noReferenceImagesAt`), else the row's `maxIngredientImages`. */
1154
+ export function maxIngredientImagesFor(model, videoResolution) {
1155
+ const cap = MODEL_CAPABILITIES[model];
1156
+ if (videoResolution && cap?.noReferenceImagesAt?.includes(videoResolution))
1157
+ return 0;
1158
+ return cap?.maxIngredientImages ?? 0;
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
+ }
1182
+ /** Whether the aspect ratio shapes this request. With a start frame the frame
1183
+ * decides, unless the row's frame request carries a ratio
1184
+ * (`aspectRatioWithFirstFrame`). */
1185
+ export function aspectRatioApplies(model, opts = {}) {
1186
+ if (!opts.firstFrame)
1187
+ return true;
1188
+ const rule = MODEL_CAPABILITIES[model]?.aspectRatioWithFirstFrame;
1189
+ return rule === 'always' || (rule === 'with-references' && (opts.referenceImages ?? 0) > 0);
1061
1190
  }
1062
1191
  /** Every legal whole-second duration. Mirrors `getAvailableDurations`. */
1063
1192
  export function durationValuesFor(model, opts = {}) {
@@ -1083,10 +1212,8 @@ export function aspectRatioUnion(models, provider) {
1083
1212
  /** Union of every resolution the given models accept. */
1084
1213
  export function videoResolutionUnion(models) {
1085
1214
  // Ascending by output height, so an enum reads as a ladder. 768p sits between
1086
- // 720p and 1080p; 1440p and 2k (≈2560×1440) are CO-HEIGHT and sit together
1087
- // between 1080p and 4k — their relative order here is cosmetic, because no
1088
- // model declares both (1440p is LTX-only, 2k is H3-only).
1089
- const order = ['480p', '720p', '768p', '1080p', '1440p', '2k', '4k'];
1215
+ // 720p and 1080p.
1216
+ const order = ['480p', '720p', '768p', '1080p', '2k', '4k'];
1090
1217
  const seen = new Set();
1091
1218
  for (const m of models)
1092
1219
  for (const r of videoResolutionsFor(m))
@@ -1124,15 +1251,15 @@ export function durationBounds(models) {
1124
1251
  // Each returns an ACTIONABLE message naming the legal set, or null when the
1125
1252
  // value is fine. The message is generated, so it can never name a set the data
1126
1253
  // does not contain.
1127
- export function checkAspectRatio(model, aspectRatio, provider) {
1254
+ export function checkAspectRatio(model, aspectRatio, provider, label = model) {
1128
1255
  if (!aspectRatio)
1129
1256
  return null;
1130
1257
  const legal = aspectRatiosFor(model, provider);
1131
1258
  if (legal.length === 0 || legal.includes(aspectRatio))
1132
1259
  return null;
1133
- return `${model} does not accept aspectRatio "${aspectRatio}". It accepts ${legal.join(', ')}. Pick one of those, or switch to a model that takes the shape you want.`;
1260
+ return `${label} does not accept aspectRatio "${aspectRatio}". It accepts ${legal.join(', ')}. Pick one of those, or switch to a model that takes the shape you want.`;
1134
1261
  }
1135
- export function checkVideoResolution(model, videoResolution) {
1262
+ export function checkVideoResolution(model, videoResolution, label = model) {
1136
1263
  if (!videoResolution)
1137
1264
  return null;
1138
1265
  const legal = videoResolutionsFor(model);
@@ -1142,9 +1269,39 @@ export function checkVideoResolution(model, videoResolution) {
1142
1269
  return null;
1143
1270
  const vr = MODEL_CAPABILITIES[model]?.videoResolution;
1144
1271
  if (vr?.fixed) {
1145
- return `${model} renders at ${vr.fixed} only — it has no resolution parameter, so videoResolution "${videoResolution}" cannot apply. Drop the param.`;
1272
+ return `${label} renders at ${vr.fixed} only: it has no resolution parameter, so videoResolution "${videoResolution}" cannot apply. Drop the param.`;
1273
+ }
1274
+ return `${label} does not render at ${videoResolution}. It offers ${legal.join(', ')}. Pick one of those, or switch models.`;
1275
+ }
1276
+ /**
1277
+ * THE verdict on a video request's shape parameters, in the order a caller can
1278
+ * fix them: aspect ratio (only where it shapes the request, `aspectRatioApplies`),
1279
+ * resolution, reference images at that resolution, then duration, whose window
1280
+ * depends on the resolution. The agent op and the desktop's composition check
1281
+ * (which the prompt bar, the agent route and the handlers run) both call this,
1282
+ * so a ratio, resolution or length one refuses is refused by all. `field` names
1283
+ * the parameter to change.
1284
+ */
1285
+ export function checkVideoParams(model, req) {
1286
+ const name = req.label ?? model;
1287
+ const refs = req.referenceImages ?? 0;
1288
+ const ratio = aspectRatioApplies(model, { firstFrame: req.firstFrame, referenceImages: refs })
1289
+ ? checkAspectRatio(model, req.aspectRatio, req.provider, name)
1290
+ : null;
1291
+ if (ratio)
1292
+ return { field: 'aspectRatio', message: ratio };
1293
+ const resolution = checkVideoResolution(model, req.videoResolution, name);
1294
+ if (resolution)
1295
+ return { field: 'videoResolution', message: resolution };
1296
+ if (refs > 0 && maxIngredientImagesFor(model) > 0 && maxIngredientImagesFor(model, req.videoResolution) === 0) {
1297
+ return { field: 'references', message: `${name} takes no reference images at ${req.videoResolution}. Pick a lower resolution, or remove the references.` };
1146
1298
  }
1147
- return `${model} does not render at ${videoResolution}. It offers ${legal.join(', ')}. Pick one of those, or switch models.`;
1299
+ const duration = checkDuration(model, req.duration, {
1300
+ videoResolution: req.videoResolution,
1301
+ promptMode: refs > 0 && !req.firstFrame && !req.lastFrame ? 'ingredients' : undefined,
1302
+ label: name,
1303
+ });
1304
+ return duration ? { field: 'duration', message: duration } : null;
1148
1305
  }
1149
1306
  export function checkDuration(model, duration, opts = {}) {
1150
1307
  if (duration == null)
@@ -1168,8 +1325,8 @@ export function checkDuration(model, duration, opts = {}) {
1168
1325
  why = ` at ${opts.videoResolution}`;
1169
1326
  escape = `, or pick a resolution without that restriction (${fmtWindow(base)} at the unrestricted ones)`;
1170
1327
  }
1171
- const allowed = legal.length === 1 ? `${legal[0]}s only` : d.mode === 'discrete' ? `${legal.join('s, ')}s` : `${d.min}-${d.max}s`;
1172
- return `${model}${why} accepts ${allowed} — ${duration}s is not legal. Pick a duration in range${escape}.`;
1328
+ const allowed = legal.length === 1 ? `${legal[0]} seconds only` : d.mode === 'discrete' ? `${legal.join(', ')} seconds` : `${d.min} to ${d.max} seconds`;
1329
+ return `${opts.label ?? model}${why} makes clips of ${allowed}, and ${duration}s was asked. Pick a length in that range${escape}.`;
1173
1330
  }
1174
1331
  // ── Generated prose ──────────────────────────────────────────────────────────
1175
1332
  //
@@ -1194,7 +1351,7 @@ function groupBy(models, fn) {
1194
1351
  export function describeAspectRatios(models, provider) {
1195
1352
  return groupBy(models, (m) => aspectRatiosFor(m, provider).join(', '));
1196
1353
  }
1197
- /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · ltx-2-5-pro: 720p, 1080p (default 1080p)" */
1354
+ /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · wan-3.0: 480p, 720p, 1080p (default 720p)" */
1198
1355
  export function describeVideoResolutions(models) {
1199
1356
  return groupBy(models, (m) => {
1200
1357
  const vr = MODEL_CAPABILITIES[m]?.videoResolution;
@@ -1209,7 +1366,7 @@ export function describeVideoResolutions(models) {
1209
1366
  function fmtWindow(d) {
1210
1367
  return d.mode === 'discrete' && d.values ? `${d.values.join('s/')}s` : `${d.min}-${d.max}s`;
1211
1368
  }
1212
- /** e.g. "kling-v3.0-std: 3-15s · ltx-2-5: 6s/8s/10s/12s/14s/16s/18s/20s (1440p/4k: 6s/8s/10s only)" */
1369
+ /** e.g. "kling-v3.0-std: 3-15s · seedance-2.5: 4-30s" */
1213
1370
  export function describeDurations(models) {
1214
1371
  return groupBy(models, (m) => {
1215
1372
  const d = MODEL_CAPABILITIES[m]?.duration;
@@ -1239,7 +1396,7 @@ export function describeReferenceImageCaps(models) {
1239
1396
  const cap = MODEL_CAPABILITIES[m];
1240
1397
  if (!cap)
1241
1398
  return '';
1242
- // A generate row with no reference cap (LTX) takes none: say so rather than
1399
+ // A generate row with no reference cap takes none: say so rather than
1243
1400
  // dropping the row, which read as "no limit stated".
1244
1401
  const n = cap.maxIngredientImages ?? cap.maxRefImages ?? 0;
1245
1402
  return n === 0 ? '0 (prompt and frames only)' : String(n);