@slatesvideo/shared 0.7.21 → 0.7.22

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
@@ -100,18 +101,6 @@ const SEEDANCE_ASPECT_RATIOS = ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'];
100
101
  * is not an AspectRatio in this vocabulary.
101
102
  */
102
103
  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
104
  export const GPT_QUALITY_TIERS = ['low', 'medium', 'high', 'xhigh', 'max'];
116
105
  export const DEFAULT_GPT_QUALITY = 'high';
117
106
  export const GPT_BACKGROUNDS = ['auto', 'transparent', 'opaque'];
@@ -458,6 +447,13 @@ export const MODEL_CAPABILITIES = {
458
447
  // pro: ... The output video resolution is 1080P." The fal Standard endpoint
459
448
  // takes no resolution parameter, and every Standard and Omni render we
460
449
  // measured came back 1280x720 (2026-09-29). This row said 1080p until then.
450
+ //
451
+ // `noReferenceImagesAt: ['4k']` on all four: the 4K seats are sold as
452
+ // text-to-video and image-to-video only (fal has no 4K reference-to-video).
453
+ // `aspectRatioWithFirstFrame`: fal's v3 and O3 image-to-video schemas have no
454
+ // `aspect_ratio` (the frame decides); O3 reference-to-video, where a frame
455
+ // with reference images lands, takes the three-ratio enum (fal OpenAPI, read
456
+ // 2026-11-24).
461
457
  'kling-v3.0-std': {
462
458
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
463
459
  providerAspectRatios: { fal: KLING_FAL_ASPECT_RATIOS },
@@ -465,6 +461,7 @@ export const MODEL_CAPABILITIES = {
465
461
  // 3, not 5. The op claimed "Kling: 5-15" and refused legal 3-4s takes.
466
462
  duration: { min: 3, max: 15, mode: 'continuous' },
467
463
  maxIngredientImages: 4,
464
+ noReferenceImagesAt: ['4k'],
468
465
  },
469
466
  'kling-v3.0-pro': {
470
467
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
@@ -472,6 +469,7 @@ export const MODEL_CAPABILITIES = {
472
469
  videoResolution: { options: ['1080p', '4k'] },
473
470
  duration: { min: 3, max: 15, mode: 'continuous' },
474
471
  maxIngredientImages: 4,
472
+ noReferenceImagesAt: ['4k'],
475
473
  },
476
474
  'kling-v3.0-omni': {
477
475
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
@@ -480,6 +478,8 @@ export const MODEL_CAPABILITIES = {
480
478
  videoResolution: { options: ['720p', '4k'] },
481
479
  duration: { min: 3, max: 15, mode: 'continuous' },
482
480
  maxIngredientImages: 4,
481
+ noReferenceImagesAt: ['4k'],
482
+ aspectRatioWithFirstFrame: 'with-references',
483
483
  },
484
484
  'kling-v3.0-omni-pro': {
485
485
  aspectRatios: KLING_DIRECT_ASPECT_RATIOS,
@@ -487,6 +487,8 @@ export const MODEL_CAPABILITIES = {
487
487
  videoResolution: { options: ['1080p', '4k'] },
488
488
  duration: { min: 3, max: 15, mode: 'continuous' },
489
489
  maxIngredientImages: 4,
490
+ noReferenceImagesAt: ['4k'],
491
+ aspectRatioWithFirstFrame: 'with-references',
490
492
  },
491
493
  // Kling O3 video-to-video edit (fal-only; the source clip is the canvas, so
492
494
  // aspect/resolution/duration all follow it).
@@ -556,6 +558,13 @@ export const MODEL_CAPABILITIES = {
556
558
  // No combined ceiling is published, so the total is the two arms summed.
557
559
  // Google: "Uploading audio inputs or audio references is unsupported".
558
560
  maxReferenceFilesTotal: 9,
561
+ // fal's v1.2 image-to-video takes `aspect_ratio` (16:9 / 9:16, default
562
+ // 16:9), so the ratio is a real parameter beside a start frame.
563
+ aspectRatioWithFirstFrame: 'always',
564
+ // fal's v1.2 reference-to-video takes `image_urls` and `reference_video_urls`
565
+ // together and has no frame slot: a start frame is sent as reference image 1
566
+ // beside reference images or reference videos, and a last frame is refused.
567
+ firstFrameRidesAsReference: true,
559
568
  },
560
569
  'omni-flash-1-2-edit': {
561
570
  aspectRatios: OMNI_FLASH_ASPECT_RATIOS,
@@ -637,6 +646,12 @@ export const MODEL_CAPABILITIES = {
637
646
  maxReferenceFilesTotal: 12,
638
647
  maxReferenceVideoSeconds: 15,
639
648
  maxReferenceAudioSeconds: 15,
649
+ // The vref key bills each clip rounded up, and its ladder ends at the cap
650
+ // plus the longest output. Providers state "video refs combined 2-15s".
651
+ referenceVideoSecondsBasis: 'billed',
652
+ minReferenceVideoSeconds: 2,
653
+ // The frames task sends the chosen ratio (2.5 sends `adaptive` instead).
654
+ aspectRatioWithFirstFrame: 'always',
640
655
  },
641
656
  'seedance-2.5': {
642
657
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
@@ -650,24 +665,18 @@ export const MODEL_CAPABILITIES = {
650
665
  maxReferenceFilesTotal: 50,
651
666
  maxReferenceVideoSeconds: 30,
652
667
  maxReferenceAudioSeconds: 30,
668
+ referenceVideoSecondsBasis: 'billed',
669
+ minReferenceVideoSeconds: 2,
653
670
  },
654
671
  'seedance-2.5-edit': {
655
672
  aspectRatios: SEEDANCE_ASPECT_RATIOS,
656
673
  videoResolution: { options: ['480p', '720p', '1080p', '4k'], default: '720p' },
657
674
  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,
675
+ // ByteDance recommends 1–5 reference images on video edits ("replace the man
676
+ // in dark clothing in @Video 1 with @Image 2"). Wired in slate's
677
+ // `generation/handlers/edit-video.ts` (BytePlus `role: 'reference_image'`
678
+ // items + EvoLink `image_urls`) and V2V Video Brush / Swap Person / Location.
679
+ maxIngredientImages: 5,
671
680
  // NO multimodal reference caps, deliberately: on an edit row the clip IS the
672
681
  // canvas and arrives through `sourceVideo`, not as a reference.
673
682
  },
@@ -774,87 +783,6 @@ export const MODEL_CAPABILITIES = {
774
783
  // image-to-video and live in MODEL_REGISTRY.features.lastFrame.
775
784
  maxIngredientImages: 0,
776
785
  },
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
786
  // ── Audio ──────────────────────────────────────────────────────────────────
859
787
  //
860
788
  // `aspectRatios: []` is deliberate, not an oversight: audio has no frame, and
@@ -905,31 +833,9 @@ export const MODEL_CAPABILITIES = {
905
833
  },
906
834
  };
907
835
  // ── 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
- };
836
+ // The one list of retired seats lives in its own leaf, re-exported here so
837
+ // `@slatesvideo/shared/model-capabilities` importers read it where they always did.
838
+ export { RETIRED_MODELS, RETIRED_SEATS, HISTORY_MODEL_LABELS } from './retired-models.js';
933
839
  /**
934
840
  * The retired seat a cost key bills, or null when the key belongs to a current
935
841
  * row or to no row. A key is its row's id, alone or followed by `-` and its
@@ -1053,11 +959,149 @@ export function checkReferenceShape(model, opts) {
1053
959
  ? `${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
960
  : `${name} takes at most ${s(maxClips)}, and this has ${count}.`;
1055
961
  }
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.`;
962
+ return checkReferenceSeconds(model, 'video', clips, { label: name }).error;
963
+ }
964
+ /**
965
+ * Frames beside reference video or audio. A reference endpoint has no frame
966
+ * parameters, so the pair is refused, never sent with one side dropped. A row
967
+ * that sends a first frame as reference image 1 (`firstFrameRidesAsReference`)
968
+ * carries it there, and only its last frame has no slot. A plain message naming
969
+ * `label`, or null. One function for the agent op, the desktop's composer and
970
+ * the handlers.
971
+ */
972
+ export function checkFramesWithReferenceMedia(model, opts) {
973
+ const cap = MODEL_CAPABILITIES[model];
974
+ if (!cap || (opts.referenceVideos ?? 0) + (opts.referenceAudio ?? 0) === 0)
975
+ return null;
976
+ const name = opts.label ?? model;
977
+ if (cap.firstFrameRidesAsReference) {
978
+ return opts.lastFrame ? `${name} takes a last frame only without references. Remove the last frame or the references.` : null;
1059
979
  }
1060
- return null;
980
+ return opts.firstFrame || opts.lastFrame
981
+ ? `${name} takes first and last frames or reference video and audio, not both: its reference endpoint has no frame slots. Remove one side.`
982
+ : null;
983
+ }
984
+ // ── Reference seconds: one rounding, one tolerance, one verdict ──────────────
985
+ //
986
+ // The agent op, the desktop's composition check, the generation handlers and
987
+ // the server's key derivations all call the functions below, so a clip set one
988
+ // layer accepts is never refused by the next.
989
+ /** A probe reads a clip a few hundredths long (an "8 second" file measures
990
+ * 8.02), so that much over a whole second or over a ceiling is not counted. */
991
+ export const REFERENCE_SECONDS_TOLERANCE = 0.05;
992
+ /** An edit's source clip is probed the same way, so it takes the same slack. */
993
+ export const EDIT_SECONDS_TOLERANCE = REFERENCE_SECONDS_TOLERANCE;
994
+ /** The whole seconds a probed length counts as: up past the probe slack, so
995
+ * 4.3s is 5 and 8.02s is 8. The one rounding every billed clip length takes;
996
+ * slates-api's `check:all` fails on a copy of it anywhere else. */
997
+ export function probedWholeSeconds(seconds) {
998
+ return Math.ceil(seconds - REFERENCE_SECONDS_TOLERANCE);
999
+ }
1000
+ /** The whole seconds a reference-video key bills for these clips: each measured
1001
+ * clip rounds up on its own (4.3s bills 5, 8.02s bills 8), never the sum. A
1002
+ * length of zero or less is an unmeasured clip and adds nothing. */
1003
+ export function billedReferenceSeconds(clips) {
1004
+ let total = 0;
1005
+ for (const sec of clips) {
1006
+ if (Number.isFinite(sec) && sec > 0)
1007
+ total += Math.max(1, probedWholeSeconds(sec));
1008
+ }
1009
+ return total;
1010
+ }
1011
+ /** The whole seconds a video edit bills for a measured source clip. An edit's
1012
+ * output follows its source, so the row's duration window is the clip window
1013
+ * and the probed length is held inside it. A row with no window throws: an
1014
+ * edit priced on a guessed window bills the wrong key. */
1015
+ export function billedEditSeconds(model, seconds) {
1016
+ const window = MODEL_CAPABILITIES[model]?.duration;
1017
+ if (!window)
1018
+ throw new Error(`billedEditSeconds: no duration capability for "${model}"`);
1019
+ return Math.min(window.max, Math.max(window.min, probedWholeSeconds(seconds)));
1020
+ }
1021
+ /** Lip-sync and motion transfer bill in whole blocks of this many seconds. */
1022
+ export const TOOL_BLOCK_SECONDS = 5;
1023
+ /** The whole tool blocks a length bills: rounded up with no probe slack, since a
1024
+ * block already absorbs it (a 5.02s clip and a 5.0s clip are both one block).
1025
+ * Zero for no length; each caller sets its own floor. */
1026
+ export function toolBlocks(seconds) {
1027
+ return Math.ceil(seconds / TOOL_BLOCK_SECONDS);
1028
+ }
1029
+ /** A tool's credit key for `blocks` whole blocks: `${stem}-${blocks × 5}s`, as the
1030
+ * server's price list names them. */
1031
+ export function toolBlockKey(stem, blocks) {
1032
+ return `${stem}-${blocks * TOOL_BLOCK_SECONDS}s`;
1033
+ }
1034
+ /** The per-clip window, the least and most combined seconds a row takes for one
1035
+ * kind of reference, and how its combined cap is counted. `max` 0 = no cap. */
1036
+ export function referenceSecondsBounds(model, kind) {
1037
+ const cap = MODEL_CAPABILITIES[model];
1038
+ const clip = kind === 'video' ? cap?.referenceVideoDuration : cap?.referenceAudioDuration;
1039
+ return {
1040
+ clip,
1041
+ min: (kind === 'video' ? cap?.minReferenceVideoSeconds : undefined) ?? clip?.min ?? 0,
1042
+ max: (kind === 'video' ? cap?.maxReferenceVideoSeconds : cap?.maxReferenceAudioSeconds) ?? 0,
1043
+ basis: kind === 'video' ? (cap?.referenceVideoSecondsBasis ?? 'actual') : 'actual',
1044
+ };
1045
+ }
1046
+ /** Whether one measured clip fits the row's per-clip window. The ceiling takes
1047
+ * the probe tolerance; the floor does not (a probe never reads short). A row
1048
+ * with no per-clip window takes any measured length. */
1049
+ export function referenceClipInBounds(model, kind, seconds) {
1050
+ if (!Number.isFinite(seconds) || seconds <= 0)
1051
+ return false;
1052
+ const { clip } = referenceSecondsBounds(model, kind);
1053
+ return !clip || (seconds >= clip.min && seconds <= clip.max + REFERENCE_SECONDS_TOLERANCE);
1054
+ }
1055
+ /**
1056
+ * THE verdict on a request's reference clips of one kind, from each clip's
1057
+ * length in seconds: every clip inside the row's per-clip window, and the
1058
+ * combined length inside the row's bounds, counted on the row's own basis
1059
+ * (`referenceVideoSecondsBasis`). A length of zero or less is a clip nobody has
1060
+ * measured yet: it is skipped, unless `measured` says every clip was probed, in
1061
+ * which case it is refused. A row with no bounds for the kind accepts.
1062
+ */
1063
+ export function checkReferenceSeconds(model, kind, clips, opts = {}) {
1064
+ const name = opts.label ?? model;
1065
+ const known = clips.filter((sec) => Number.isFinite(sec) && sec > 0);
1066
+ const actual = known.reduce((n, sec) => n + sec, 0);
1067
+ const billed = billedReferenceSeconds(known);
1068
+ const verdict = (error) => ({ actual, billed, error });
1069
+ if (opts.measured && known.length < clips.length) {
1070
+ return verdict(`A reference ${kind} clip could not be measured. Attach it again.`);
1071
+ }
1072
+ const { clip, min, max, basis } = referenceSecondsBounds(model, kind);
1073
+ if (clip && known.some((sec) => !referenceClipInBounds(model, kind, sec))) {
1074
+ return verdict(`Each ${name} reference ${kind === 'audio' ? 'audio clip' : kind} must be ${clip.min}-${clip.max}s long. Trim it first.`);
1075
+ }
1076
+ if (known.length === 0)
1077
+ return verdict(null);
1078
+ const total = basis === 'billed' ? billed : actual;
1079
+ 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)) {
1081
+ return verdict(`${name} takes at most ${max}s of reference ${kind} in total, and this has ${shown}. Trim a clip first.`);
1082
+ }
1083
+ if (total < min) {
1084
+ return verdict(`${name} needs at least ${min}s of reference ${kind} in total, and this has ${shown}.`);
1085
+ }
1086
+ return verdict(null);
1087
+ }
1088
+ /** Reference images a request may carry at this resolution: none where the
1089
+ * row's endpoint for that resolution has no reference slot
1090
+ * (`noReferenceImagesAt`), else the row's `maxIngredientImages`. */
1091
+ export function maxIngredientImagesFor(model, videoResolution) {
1092
+ const cap = MODEL_CAPABILITIES[model];
1093
+ if (videoResolution && cap?.noReferenceImagesAt?.includes(videoResolution))
1094
+ return 0;
1095
+ return cap?.maxIngredientImages ?? 0;
1096
+ }
1097
+ /** Whether the aspect ratio shapes this request. With a start frame the frame
1098
+ * decides, unless the row's frame request carries a ratio
1099
+ * (`aspectRatioWithFirstFrame`). */
1100
+ export function aspectRatioApplies(model, opts = {}) {
1101
+ if (!opts.firstFrame)
1102
+ return true;
1103
+ const rule = MODEL_CAPABILITIES[model]?.aspectRatioWithFirstFrame;
1104
+ return rule === 'always' || (rule === 'with-references' && (opts.referenceImages ?? 0) > 0);
1061
1105
  }
1062
1106
  /** Every legal whole-second duration. Mirrors `getAvailableDurations`. */
1063
1107
  export function durationValuesFor(model, opts = {}) {
@@ -1083,10 +1127,8 @@ export function aspectRatioUnion(models, provider) {
1083
1127
  /** Union of every resolution the given models accept. */
1084
1128
  export function videoResolutionUnion(models) {
1085
1129
  // 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'];
1130
+ // 720p and 1080p.
1131
+ const order = ['480p', '720p', '768p', '1080p', '2k', '4k'];
1090
1132
  const seen = new Set();
1091
1133
  for (const m of models)
1092
1134
  for (const r of videoResolutionsFor(m))
@@ -1124,15 +1166,15 @@ export function durationBounds(models) {
1124
1166
  // Each returns an ACTIONABLE message naming the legal set, or null when the
1125
1167
  // value is fine. The message is generated, so it can never name a set the data
1126
1168
  // does not contain.
1127
- export function checkAspectRatio(model, aspectRatio, provider) {
1169
+ export function checkAspectRatio(model, aspectRatio, provider, label = model) {
1128
1170
  if (!aspectRatio)
1129
1171
  return null;
1130
1172
  const legal = aspectRatiosFor(model, provider);
1131
1173
  if (legal.length === 0 || legal.includes(aspectRatio))
1132
1174
  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.`;
1175
+ 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
1176
  }
1135
- export function checkVideoResolution(model, videoResolution) {
1177
+ export function checkVideoResolution(model, videoResolution, label = model) {
1136
1178
  if (!videoResolution)
1137
1179
  return null;
1138
1180
  const legal = videoResolutionsFor(model);
@@ -1142,9 +1184,39 @@ export function checkVideoResolution(model, videoResolution) {
1142
1184
  return null;
1143
1185
  const vr = MODEL_CAPABILITIES[model]?.videoResolution;
1144
1186
  if (vr?.fixed) {
1145
- return `${model} renders at ${vr.fixed} only — it has no resolution parameter, so videoResolution "${videoResolution}" cannot apply. Drop the param.`;
1187
+ return `${label} renders at ${vr.fixed} only: it has no resolution parameter, so videoResolution "${videoResolution}" cannot apply. Drop the param.`;
1188
+ }
1189
+ return `${label} does not render at ${videoResolution}. It offers ${legal.join(', ')}. Pick one of those, or switch models.`;
1190
+ }
1191
+ /**
1192
+ * THE verdict on a video request's shape parameters, in the order a caller can
1193
+ * fix them: aspect ratio (only where it shapes the request, `aspectRatioApplies`),
1194
+ * resolution, reference images at that resolution, then duration, whose window
1195
+ * depends on the resolution. The agent op and the desktop's composition check
1196
+ * (which the prompt bar, the agent route and the handlers run) both call this,
1197
+ * so a ratio, resolution or length one refuses is refused by all. `field` names
1198
+ * the parameter to change.
1199
+ */
1200
+ export function checkVideoParams(model, req) {
1201
+ const name = req.label ?? model;
1202
+ const refs = req.referenceImages ?? 0;
1203
+ const ratio = aspectRatioApplies(model, { firstFrame: req.firstFrame, referenceImages: refs })
1204
+ ? checkAspectRatio(model, req.aspectRatio, req.provider, name)
1205
+ : null;
1206
+ if (ratio)
1207
+ return { field: 'aspectRatio', message: ratio };
1208
+ const resolution = checkVideoResolution(model, req.videoResolution, name);
1209
+ if (resolution)
1210
+ return { field: 'videoResolution', message: resolution };
1211
+ if (refs > 0 && maxIngredientImagesFor(model) > 0 && maxIngredientImagesFor(model, req.videoResolution) === 0) {
1212
+ return { field: 'references', message: `${name} takes no reference images at ${req.videoResolution}. Pick a lower resolution, or remove the references.` };
1146
1213
  }
1147
- return `${model} does not render at ${videoResolution}. It offers ${legal.join(', ')}. Pick one of those, or switch models.`;
1214
+ const duration = checkDuration(model, req.duration, {
1215
+ videoResolution: req.videoResolution,
1216
+ promptMode: refs > 0 && !req.firstFrame && !req.lastFrame ? 'ingredients' : undefined,
1217
+ label: name,
1218
+ });
1219
+ return duration ? { field: 'duration', message: duration } : null;
1148
1220
  }
1149
1221
  export function checkDuration(model, duration, opts = {}) {
1150
1222
  if (duration == null)
@@ -1168,8 +1240,8 @@ export function checkDuration(model, duration, opts = {}) {
1168
1240
  why = ` at ${opts.videoResolution}`;
1169
1241
  escape = `, or pick a resolution without that restriction (${fmtWindow(base)} at the unrestricted ones)`;
1170
1242
  }
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}.`;
1243
+ const allowed = legal.length === 1 ? `${legal[0]} seconds only` : d.mode === 'discrete' ? `${legal.join(', ')} seconds` : `${d.min} to ${d.max} seconds`;
1244
+ return `${opts.label ?? model}${why} makes clips of ${allowed}, and ${duration}s was asked. Pick a length in that range${escape}.`;
1173
1245
  }
1174
1246
  // ── Generated prose ──────────────────────────────────────────────────────────
1175
1247
  //
@@ -1194,7 +1266,7 @@ function groupBy(models, fn) {
1194
1266
  export function describeAspectRatios(models, provider) {
1195
1267
  return groupBy(models, (m) => aspectRatiosFor(m, provider).join(', '));
1196
1268
  }
1197
- /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · ltx-2-5-pro: 720p, 1080p (default 1080p)" */
1269
+ /** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · wan-3.0: 480p, 720p, 1080p (default 720p)" */
1198
1270
  export function describeVideoResolutions(models) {
1199
1271
  return groupBy(models, (m) => {
1200
1272
  const vr = MODEL_CAPABILITIES[m]?.videoResolution;
@@ -1209,7 +1281,7 @@ export function describeVideoResolutions(models) {
1209
1281
  function fmtWindow(d) {
1210
1282
  return d.mode === 'discrete' && d.values ? `${d.values.join('s/')}s` : `${d.min}-${d.max}s`;
1211
1283
  }
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)" */
1284
+ /** e.g. "kling-v3.0-std: 3-15s · seedance-2.5: 4-30s" */
1213
1285
  export function describeDurations(models) {
1214
1286
  return groupBy(models, (m) => {
1215
1287
  const d = MODEL_CAPABILITIES[m]?.duration;
@@ -1239,7 +1311,7 @@ export function describeReferenceImageCaps(models) {
1239
1311
  const cap = MODEL_CAPABILITIES[m];
1240
1312
  if (!cap)
1241
1313
  return '';
1242
- // A generate row with no reference cap (LTX) takes none: say so rather than
1314
+ // A generate row with no reference cap takes none: say so rather than
1243
1315
  // dropping the row, which read as "no limit stated".
1244
1316
  const n = cap.maxIngredientImages ?? cap.maxRefImages ?? 0;
1245
1317
  return n === 0 ? '0 (prompt and frames only)' : String(n);
@@ -6,6 +6,7 @@ export declare const CHATGPT_IMAGE_HOST: {
6
6
  readonly usage: "Uses your ChatGPT account limits";
7
7
  };
8
8
  import { type BuiltInTool } from './generation-policy.js';
9
+ import type { PromptingTipsKey } from './prompting-tips.js';
9
10
  /** Authoring presets only: these do not claim hosted ChatGPT API capabilities. */
10
11
  export declare const CHATGPT_FRAMING_RATIOS: import("./model-capabilities.js").AspectRatio[];
11
12
  export declare function composeChatGptFraming(prompt: string, aspectRatio?: string): string;
@@ -54,6 +55,19 @@ export interface ModelFact {
54
55
  * and to fail its build when a niche seat is named more often than the default.
55
56
  */
56
57
  tier: 'default' | 'specialist' | 'niche';
58
+ /**
59
+ * The model's entry in `PROMPTING_TIPS`, the user-facing tips page
60
+ * (slates.video/docs/prompting). Several seats share one (both GPT Image 2.6
61
+ * seats, the MiniMax H3 seats). `null` declares the model has none yet;
62
+ * slates-api's model-lifecycle check fails a fact without the field.
63
+ */
64
+ tipsKey: PromptingTipsKey | null;
65
+ /**
66
+ * The registry rows a family-level fact speaks for, when its id is not their
67
+ * prefix (`kling-v3` for `kling-v3.0-std`). Any other row takes the fact whose
68
+ * id it equals or starts with followed by `-`, the longest such id winning.
69
+ */
70
+ variants?: readonly string[];
57
71
  /** Max reference images (image models) — null if not applicable. */
58
72
  maxRefImages: number | null;
59
73
  /** Max ingredient images (video models) — null if not applicable. */