@shop-os/modelkit 0.2.14 → 0.2.15

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.
@@ -22,10 +22,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
22
22
  type MediaRef = {
23
23
  url: string;
24
24
  label?: string;
25
+ /** Measured length of a video/audio; the kit never measures it. */
26
+ durationSeconds?: number;
25
27
  } | {
26
28
  bytes: Uint8Array;
27
29
  mime: string;
28
30
  label?: string;
31
+ /** Measured length of a video/audio; the kit never measures it. */
32
+ durationSeconds?: number;
29
33
  };
30
34
  /** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
31
35
  interface UpscaleOptions {
@@ -157,6 +161,16 @@ interface MediaPart {
157
161
  }
158
162
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
159
163
  type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
164
+ interface VideoSecondsLimits {
165
+ /** Minimum length of each reference video, in seconds. */
166
+ min?: number;
167
+ /** Maximum length of each reference video, in seconds. */
168
+ max?: number;
169
+ /** Maximum combined length of the reference videos, in seconds. */
170
+ total?: number;
171
+ /** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
172
+ editMin?: number;
173
+ }
160
174
  interface ReferenceLimits {
161
175
  images?: number;
162
176
  /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
@@ -166,6 +180,8 @@ interface ReferenceLimits {
166
180
  total?: number;
167
181
  /** Provider rejects a request whose only references are audio. */
168
182
  audioOnly?: boolean;
183
+ /** Per-video length caps (min/max each) and combined total for reference videos. */
184
+ videoSeconds?: VideoSecondsLimits;
169
185
  }
170
186
  interface ModelConstraints {
171
187
  aspectRatios?: AspectRatio[];
@@ -189,6 +205,11 @@ interface ModelConstraints {
189
205
  supports?: SupportedOption[];
190
206
  /** Ratio is dropped, with a warning, when one of these inputs is present. */
191
207
  ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
208
+ /** Length limits for the source video the row edits or extends. */
209
+ sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
210
+ /** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
211
+ inReferenceTotal?: boolean;
212
+ };
192
213
  }
193
214
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
194
215
  type JsonPrimitive = string | number | boolean | null;
@@ -562,6 +583,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
562
583
  audios: z.ZodOptional<z.ZodNumber>;
563
584
  total: z.ZodOptional<z.ZodNumber>;
564
585
  audioOnly: z.ZodOptional<z.ZodBoolean>;
586
+ videoSeconds: z.ZodOptional<z.ZodObject<{
587
+ min: z.ZodOptional<z.ZodNumber>;
588
+ max: z.ZodOptional<z.ZodNumber>;
589
+ total: z.ZodOptional<z.ZodNumber>;
590
+ editMin: z.ZodOptional<z.ZodNumber>;
591
+ }, z.core.$loose>>;
565
592
  }, z.core.$loose>>;
566
593
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
567
594
  references: "references";
@@ -591,15 +618,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
591
618
  firstFrame: "firstFrame";
592
619
  sourceVideo: "sourceVideo";
593
620
  }>>>;
621
+ sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
622
+ max: z.ZodOptional<z.ZodNumber>;
623
+ min: z.ZodOptional<z.ZodNumber>;
624
+ editMin: z.ZodOptional<z.ZodNumber>;
625
+ inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
626
+ }, z.core.$loose>>;
594
627
  }, z.core.$loose>;
595
628
  defaults: z.ZodObject<{
596
629
  references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
597
630
  url: z.ZodString;
598
631
  label: z.ZodOptional<z.ZodString>;
632
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
599
633
  }, z.core.$loose>, z.ZodObject<{
600
634
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
601
635
  mime: z.ZodString;
602
636
  label: z.ZodOptional<z.ZodString>;
637
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
603
638
  }, z.core.$loose>]>>>;
604
639
  aspectRatio: z.ZodOptional<z.ZodEnum<{
605
640
  "1:1": "1:1";
@@ -654,50 +689,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
654
689
  firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
655
690
  url: z.ZodString;
656
691
  label: z.ZodOptional<z.ZodString>;
692
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
657
693
  }, z.core.$loose>, z.ZodObject<{
658
694
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
659
695
  mime: z.ZodString;
660
696
  label: z.ZodOptional<z.ZodString>;
697
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
661
698
  }, z.core.$loose>]>>;
662
699
  lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
663
700
  url: z.ZodString;
664
701
  label: z.ZodOptional<z.ZodString>;
702
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
665
703
  }, z.core.$loose>, z.ZodObject<{
666
704
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
667
705
  mime: z.ZodString;
668
706
  label: z.ZodOptional<z.ZodString>;
707
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
669
708
  }, z.core.$loose>]>>;
670
709
  sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
671
710
  url: z.ZodString;
672
711
  label: z.ZodOptional<z.ZodString>;
712
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
673
713
  }, z.core.$loose>, z.ZodObject<{
674
714
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
675
715
  mime: z.ZodString;
676
716
  label: z.ZodOptional<z.ZodString>;
717
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
677
718
  }, z.core.$loose>]>>;
678
719
  referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
679
720
  url: z.ZodString;
680
721
  label: z.ZodOptional<z.ZodString>;
722
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
681
723
  }, z.core.$loose>, z.ZodObject<{
682
724
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
683
725
  mime: z.ZodString;
684
726
  label: z.ZodOptional<z.ZodString>;
727
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
685
728
  }, z.core.$loose>]>>>;
686
729
  referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
687
730
  url: z.ZodString;
688
731
  label: z.ZodOptional<z.ZodString>;
732
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
689
733
  }, z.core.$loose>, z.ZodObject<{
690
734
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
691
735
  mime: z.ZodString;
692
736
  label: z.ZodOptional<z.ZodString>;
737
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
693
738
  }, z.core.$loose>]>>>;
694
739
  referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
695
740
  url: z.ZodString;
696
741
  label: z.ZodOptional<z.ZodString>;
742
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
697
743
  }, z.core.$loose>, z.ZodObject<{
698
744
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
699
745
  mime: z.ZodString;
700
746
  label: z.ZodOptional<z.ZodString>;
747
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
701
748
  }, z.core.$loose>]>>>;
702
749
  resolution: z.ZodOptional<z.ZodEnum<{
703
750
  "360p": "360p";
@@ -839,6 +886,12 @@ interface ResolveResult<T> {
839
886
  }
840
887
  /** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
841
888
  declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
889
+ /** First length violation for the videos a request sends, as a user-facing message. */
890
+ declare function videoLengthViolation(model: CatalogModel, input: {
891
+ referenceVideos?: (number | undefined)[];
892
+ sourceVideo?: number;
893
+ taskType?: VideoRequest["taskType"];
894
+ }): string | undefined;
842
895
  declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
843
896
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
844
897
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
@@ -878,4 +931,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
878
931
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
879
932
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
880
933
 
881
- export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
934
+ export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
package/dist/catalog.d.ts CHANGED
@@ -22,10 +22,14 @@ type OutputFormat = "png" | "jpeg" | "webp";
22
22
  type MediaRef = {
23
23
  url: string;
24
24
  label?: string;
25
+ /** Measured length of a video/audio; the kit never measures it. */
26
+ durationSeconds?: number;
25
27
  } | {
26
28
  bytes: Uint8Array;
27
29
  mime: string;
28
30
  label?: string;
31
+ /** Measured length of a video/audio; the kit never measures it. */
32
+ durationSeconds?: number;
29
33
  };
30
34
  /** Caller-driven Topaz upscale controls; see the topaz row and TopazImageInput. */
31
35
  interface UpscaleOptions {
@@ -157,6 +161,16 @@ interface MediaPart {
157
161
  }
158
162
  type RequiredInput = "firstFrame" | "sourceVideo" | "references";
159
163
  type SupportedOption = "seed" | "quality" | "negativePrompt" | "cfgScale" | "generateAudio" | "promptExpansion" | "lastFrame" | "count" | "outputFormat" | "scaleFactor" | "safetySettings" | "temperature" | "upscale" | "watermark" | "safetyChecker" | "taskType" | "instrumental";
164
+ interface VideoSecondsLimits {
165
+ /** Minimum length of each reference video, in seconds. */
166
+ min?: number;
167
+ /** Maximum length of each reference video, in seconds. */
168
+ max?: number;
169
+ /** Maximum combined length of the reference videos, in seconds. */
170
+ total?: number;
171
+ /** Higher per-video minimum when `taskType` is `edit` (Seedance 2.5: 4 s). */
172
+ editMin?: number;
173
+ }
160
174
  interface ReferenceLimits {
161
175
  images?: number;
162
176
  /** Lower image cap when a reference video is also sent (Kling V3 Omni: 7 → 4). */
@@ -166,6 +180,8 @@ interface ReferenceLimits {
166
180
  total?: number;
167
181
  /** Provider rejects a request whose only references are audio. */
168
182
  audioOnly?: boolean;
183
+ /** Per-video length caps (min/max each) and combined total for reference videos. */
184
+ videoSeconds?: VideoSecondsLimits;
169
185
  }
170
186
  interface ModelConstraints {
171
187
  aspectRatios?: AspectRatio[];
@@ -189,6 +205,11 @@ interface ModelConstraints {
189
205
  supports?: SupportedOption[];
190
206
  /** Ratio is dropped, with a warning, when one of these inputs is present. */
191
207
  ratioIgnoredWith?: ("firstFrame" | "sourceVideo")[];
208
+ /** Length limits for the source video the row edits or extends. */
209
+ sourceVideoSeconds?: Omit<VideoSecondsLimits, "total"> & {
210
+ /** The provider sends the source as a reference video, so it counts toward `references.videoSeconds.total` (Seedance). */
211
+ inReferenceTotal?: boolean;
212
+ };
192
213
  }
193
214
  /** JSON-compatible value. Provider options and raw payloads carry these, never `unknown`. */
194
215
  type JsonPrimitive = string | number | boolean | null;
@@ -562,6 +583,12 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
562
583
  audios: z.ZodOptional<z.ZodNumber>;
563
584
  total: z.ZodOptional<z.ZodNumber>;
564
585
  audioOnly: z.ZodOptional<z.ZodBoolean>;
586
+ videoSeconds: z.ZodOptional<z.ZodObject<{
587
+ min: z.ZodOptional<z.ZodNumber>;
588
+ max: z.ZodOptional<z.ZodNumber>;
589
+ total: z.ZodOptional<z.ZodNumber>;
590
+ editMin: z.ZodOptional<z.ZodNumber>;
591
+ }, z.core.$loose>>;
565
592
  }, z.core.$loose>>;
566
593
  requires: z.ZodOptional<z.ZodArray<z.ZodEnum<{
567
594
  references: "references";
@@ -591,15 +618,23 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
591
618
  firstFrame: "firstFrame";
592
619
  sourceVideo: "sourceVideo";
593
620
  }>>>;
621
+ sourceVideoSeconds: z.ZodOptional<z.ZodObject<{
622
+ max: z.ZodOptional<z.ZodNumber>;
623
+ min: z.ZodOptional<z.ZodNumber>;
624
+ editMin: z.ZodOptional<z.ZodNumber>;
625
+ inReferenceTotal: z.ZodOptional<z.ZodBoolean>;
626
+ }, z.core.$loose>>;
594
627
  }, z.core.$loose>;
595
628
  defaults: z.ZodObject<{
596
629
  references: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
597
630
  url: z.ZodString;
598
631
  label: z.ZodOptional<z.ZodString>;
632
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
599
633
  }, z.core.$loose>, z.ZodObject<{
600
634
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
601
635
  mime: z.ZodString;
602
636
  label: z.ZodOptional<z.ZodString>;
637
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
603
638
  }, z.core.$loose>]>>>;
604
639
  aspectRatio: z.ZodOptional<z.ZodEnum<{
605
640
  "1:1": "1:1";
@@ -654,50 +689,62 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
654
689
  firstFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
655
690
  url: z.ZodString;
656
691
  label: z.ZodOptional<z.ZodString>;
692
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
657
693
  }, z.core.$loose>, z.ZodObject<{
658
694
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
659
695
  mime: z.ZodString;
660
696
  label: z.ZodOptional<z.ZodString>;
697
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
661
698
  }, z.core.$loose>]>>;
662
699
  lastFrame: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
663
700
  url: z.ZodString;
664
701
  label: z.ZodOptional<z.ZodString>;
702
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
665
703
  }, z.core.$loose>, z.ZodObject<{
666
704
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
667
705
  mime: z.ZodString;
668
706
  label: z.ZodOptional<z.ZodString>;
707
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
669
708
  }, z.core.$loose>]>>;
670
709
  sourceVideo: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
671
710
  url: z.ZodString;
672
711
  label: z.ZodOptional<z.ZodString>;
712
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
673
713
  }, z.core.$loose>, z.ZodObject<{
674
714
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
675
715
  mime: z.ZodString;
676
716
  label: z.ZodOptional<z.ZodString>;
717
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
677
718
  }, z.core.$loose>]>>;
678
719
  referenceImages: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
679
720
  url: z.ZodString;
680
721
  label: z.ZodOptional<z.ZodString>;
722
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
681
723
  }, z.core.$loose>, z.ZodObject<{
682
724
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
683
725
  mime: z.ZodString;
684
726
  label: z.ZodOptional<z.ZodString>;
727
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
685
728
  }, z.core.$loose>]>>>;
686
729
  referenceVideos: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
687
730
  url: z.ZodString;
688
731
  label: z.ZodOptional<z.ZodString>;
732
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
689
733
  }, z.core.$loose>, z.ZodObject<{
690
734
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
691
735
  mime: z.ZodString;
692
736
  label: z.ZodOptional<z.ZodString>;
737
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
693
738
  }, z.core.$loose>]>>>;
694
739
  referenceAudios: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
695
740
  url: z.ZodString;
696
741
  label: z.ZodOptional<z.ZodString>;
742
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
697
743
  }, z.core.$loose>, z.ZodObject<{
698
744
  bytes: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
699
745
  mime: z.ZodString;
700
746
  label: z.ZodOptional<z.ZodString>;
747
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
701
748
  }, z.core.$loose>]>>>;
702
749
  resolution: z.ZodOptional<z.ZodEnum<{
703
750
  "360p": "360p";
@@ -839,6 +886,12 @@ interface ResolveResult<T> {
839
886
  }
840
887
  /** Nearest supported ratio in the same orientation bucket, else nearest overall, by log distance. */
841
888
  declare function nearestAspectRatio(requested: AspectRatio, supported: AspectRatio[]): AspectRatio;
889
+ /** First length violation for the videos a request sends, as a user-facing message. */
890
+ declare function videoLengthViolation(model: CatalogModel, input: {
891
+ referenceVideos?: (number | undefined)[];
892
+ sourceVideo?: number;
893
+ taskType?: VideoRequest["taskType"];
894
+ }): string | undefined;
842
895
  declare function resolveImageOptions(model: CatalogModel, request: ImageRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest>;
843
896
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
844
897
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
@@ -878,4 +931,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
878
931
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
879
932
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
880
933
 
881
- export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows };
934
+ export { ADAPTER_IDS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, primeCatalog, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
package/dist/catalog.js CHANGED
@@ -1362,7 +1362,8 @@ var VIDEO_MODELS = [
1362
1362
  // reference clip keeps its own framing.
1363
1363
  aspectRatios: [...OMNI_RATIOS],
1364
1364
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1365
- references: { images: 6, videos: 1 },
1365
+ references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
1366
+ sourceVideoSeconds: { max: 10 },
1366
1367
  supports: []
1367
1368
  },
1368
1369
  defaults: {},
@@ -1388,7 +1389,8 @@ var VIDEO_MODELS = [
1388
1389
  aspectRatios: [...OMNI_RATIOS],
1389
1390
  resolutions: ["360p", "720p", "1080p", "4k"],
1390
1391
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1391
- references: { images: 6, videos: 1 },
1392
+ references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
1393
+ sourceVideoSeconds: { max: 10 },
1392
1394
  supports: []
1393
1395
  },
1394
1396
  defaults: {},
@@ -1416,7 +1418,14 @@ var VIDEO_MODELS = [
1416
1418
  resolutions: ["480p", "720p", "1080p", "4k"],
1417
1419
  durations: { min: 4, max: 15 },
1418
1420
  durationPresets: [4, 6, 8, 10, 12, 15],
1419
- references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1421
+ references: {
1422
+ images: 9,
1423
+ videos: 3,
1424
+ audios: 3,
1425
+ audioOnly: false,
1426
+ videoSeconds: { min: 2, max: 15, total: 15 }
1427
+ },
1428
+ sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
1420
1429
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1421
1430
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1422
1431
  },
@@ -1448,7 +1457,14 @@ var VIDEO_MODELS = [
1448
1457
  aspectRatios: [...SEEDANCE_RATIOS],
1449
1458
  resolutions: ["480p", "720p"],
1450
1459
  durations: { min: 4, max: 15 },
1451
- references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1460
+ references: {
1461
+ images: 9,
1462
+ videos: 3,
1463
+ audios: 3,
1464
+ audioOnly: false,
1465
+ videoSeconds: { min: 2, max: 15, total: 15 }
1466
+ },
1467
+ sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
1452
1468
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1453
1469
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1454
1470
  },
@@ -1482,7 +1498,13 @@ var VIDEO_MODELS = [
1482
1498
  aspectRatios: [...SEEDANCE_RATIOS],
1483
1499
  resolutions: ["480p", "720p", "1080p"],
1484
1500
  durations: { min: 4, max: 30 },
1485
- references: { images: 30, videos: 10, audios: 10 },
1501
+ references: {
1502
+ images: 30,
1503
+ videos: 10,
1504
+ audios: 10,
1505
+ videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 }
1506
+ },
1507
+ sourceVideoSeconds: { min: 2, max: 30, editMin: 4, inReferenceTotal: true },
1486
1508
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1487
1509
  supports: ["generateAudio", "seed", "lastFrame", "watermark", "taskType"]
1488
1510
  },
@@ -1694,7 +1716,14 @@ var VIDEO_MODELS = [
1694
1716
  aspectRatios: [...H3_REFERENCE_RATIOS],
1695
1717
  resolutions: ["480p", "768p", "2k", "4k"],
1696
1718
  durations: { min: 5, max: 15 },
1697
- references: { images: 9, videos: 3, audios: 3, total: 12, audioOnly: false },
1719
+ references: {
1720
+ images: 9,
1721
+ videos: 3,
1722
+ audios: 3,
1723
+ total: 12,
1724
+ audioOnly: false,
1725
+ videoSeconds: { min: 2, max: 15, total: 15 }
1726
+ },
1698
1727
  supports: ["seed", "promptExpansion", "safetyChecker"]
1699
1728
  },
1700
1729
  defaults: {
@@ -1725,7 +1754,14 @@ var VIDEO_MODELS = [
1725
1754
  aspectRatios: [...H3_REFERENCE_RATIOS],
1726
1755
  resolutions: ["480p", "768p"],
1727
1756
  durations: { min: 5, max: 15 },
1728
- references: { images: 9, videos: 3, audios: 3, total: 12, audioOnly: false },
1757
+ references: {
1758
+ images: 9,
1759
+ videos: 3,
1760
+ audios: 3,
1761
+ total: 12,
1762
+ audioOnly: false,
1763
+ videoSeconds: { min: 2, max: 15, total: 15 }
1764
+ },
1729
1765
  supports: ["seed", "promptExpansion", "safetyChecker"]
1730
1766
  },
1731
1767
  defaults: {
@@ -1757,6 +1793,7 @@ var VIDEO_MODELS = [
1757
1793
  aspectRatios: [...KLING_RATIOS],
1758
1794
  durations: { min: 3, max: 10 },
1759
1795
  requires: ["sourceVideo"],
1796
+ sourceVideoSeconds: { min: 3, max: 10.05 },
1760
1797
  supports: []
1761
1798
  },
1762
1799
  defaults: { durationSeconds: 5, aspectRatio: "16:9" },
@@ -2113,13 +2150,20 @@ var ProviderOptionValueSchema = z2.lazy(
2113
2150
  ])
2114
2151
  );
2115
2152
  var ProviderOptionsSchema = z2.record(z2.string(), z2.record(z2.string(), ProviderOptionValueSchema));
2153
+ var VideoSecondsLimitsSchema = z2.looseObject({
2154
+ min: z2.number().optional(),
2155
+ max: z2.number().optional(),
2156
+ total: z2.number().optional(),
2157
+ editMin: z2.number().optional()
2158
+ });
2116
2159
  var ReferenceLimitsSchema = z2.looseObject({
2117
2160
  images: z2.number().optional(),
2118
2161
  imagesWithVideo: z2.number().optional(),
2119
2162
  videos: z2.number().optional(),
2120
2163
  audios: z2.number().optional(),
2121
2164
  total: z2.number().optional(),
2122
- audioOnly: z2.boolean().optional()
2165
+ audioOnly: z2.boolean().optional(),
2166
+ videoSeconds: VideoSecondsLimitsSchema.optional()
2123
2167
  });
2124
2168
  var ModelConstraintsSchema = z2.looseObject({
2125
2169
  aspectRatios: z2.array(AspectRatioSchema).optional(),
@@ -2132,14 +2176,20 @@ var ModelConstraintsSchema = z2.looseObject({
2132
2176
  references: ReferenceLimitsSchema.optional(),
2133
2177
  requires: z2.array(RequiredInputSchema).optional(),
2134
2178
  supports: z2.array(SupportedOptionSchema).optional(),
2135
- ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional()
2179
+ ratioIgnoredWith: z2.array(z2.enum(["firstFrame", "sourceVideo"])).optional(),
2180
+ sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: z2.boolean().optional() }).optional()
2136
2181
  });
2137
2182
  var MediaRefSchema = z2.union([
2138
- z2.looseObject({ url: z2.string(), label: z2.string().optional() }),
2183
+ z2.looseObject({
2184
+ url: z2.string(),
2185
+ label: z2.string().optional(),
2186
+ durationSeconds: z2.number().optional()
2187
+ }),
2139
2188
  z2.looseObject({
2140
2189
  bytes: z2.instanceof(Uint8Array),
2141
2190
  mime: z2.string(),
2142
- label: z2.string().optional()
2191
+ label: z2.string().optional(),
2192
+ durationSeconds: z2.number().optional()
2143
2193
  })
2144
2194
  ]);
2145
2195
  var ImageSafetySettingSchema = z2.looseObject({ category: z2.string(), threshold: z2.string() });
@@ -2628,6 +2678,49 @@ function trim(field, refs, limit, model, warnings) {
2628
2678
  });
2629
2679
  return refs.slice(0, limit);
2630
2680
  }
2681
+ function knownLength(value) {
2682
+ return value !== void 0 && Number.isFinite(value) ? value : void 0;
2683
+ }
2684
+ function seconds(len, limit) {
2685
+ let digits = 1;
2686
+ while (digits < 3 && Number(len.toFixed(digits)) === limit) digits++;
2687
+ return len.toFixed(digits);
2688
+ }
2689
+ function effectiveMin(limits, taskType) {
2690
+ if (taskType !== "edit" || limits?.editMin === void 0) return limits?.min;
2691
+ return Math.max(limits.min ?? 0, limits.editMin);
2692
+ }
2693
+ function videoLengthViolation(model, input) {
2694
+ const limits = model.constraints.references?.videoSeconds;
2695
+ const refMin = effectiveMin(limits, input.taskType);
2696
+ const lengths = (input.referenceVideos ?? []).map(knownLength);
2697
+ if (limits?.max !== void 0) {
2698
+ const max = limits.max;
2699
+ const i = lengths.findIndex((len) => len !== void 0 && len > max);
2700
+ if (i >= 0)
2701
+ return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
2702
+ }
2703
+ if (refMin !== void 0) {
2704
+ const i = lengths.findIndex((len) => len !== void 0 && len < refMin);
2705
+ if (i >= 0)
2706
+ return `${model.label} takes reference videos of at least ${String(refMin)} s each; video ${i + 1} is ${seconds(lengths[i], refMin)} s.`;
2707
+ }
2708
+ const source = knownLength(input.sourceVideo);
2709
+ const sourceLimits = model.constraints.sourceVideoSeconds;
2710
+ if (limits?.total !== void 0) {
2711
+ const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
2712
+ const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
2713
+ if (sum > limits.total)
2714
+ return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
2715
+ }
2716
+ if (source === void 0) return void 0;
2717
+ const sourceMin = effectiveMin(sourceLimits, input.taskType);
2718
+ if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
2719
+ return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
2720
+ if (sourceMin !== void 0 && source < sourceMin)
2721
+ return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;
2722
+ return void 0;
2723
+ }
2631
2724
  function resolveImageOptions(model, request, onUnsupported = "error") {
2632
2725
  const warnings = [];
2633
2726
  const c = model.constraints;
@@ -2813,6 +2906,21 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
2813
2906
  model: model.id
2814
2907
  });
2815
2908
  }
2909
+ const lengthViolation = videoLengthViolation(model, {
2910
+ referenceVideos: videos.map((v) => v.durationSeconds),
2911
+ taskType: merged.taskType,
2912
+ ...merged.sourceVideo?.durationSeconds !== void 0 && {
2913
+ sourceVideo: merged.sourceVideo.durationSeconds
2914
+ }
2915
+ });
2916
+ if (lengthViolation !== void 0) {
2917
+ throw new ModelKitError({
2918
+ code: "unsupported_option",
2919
+ message: lengthViolation,
2920
+ model: model.id,
2921
+ retryable: false
2922
+ });
2923
+ }
2816
2924
  setOrDelete(merged, "referenceImages", images);
2817
2925
  setOrDelete(merged, "referenceVideos", videos);
2818
2926
  setOrDelete(merged, "referenceAudios", audios);
@@ -2928,6 +3036,7 @@ export {
2928
3036
  resolveImageOptions,
2929
3037
  resolveOptions,
2930
3038
  resolveVideoOptions,
2931
- sortCatalogRows
3039
+ sortCatalogRows,
3040
+ videoLengthViolation
2932
3041
  };
2933
3042
  //# sourceMappingURL=catalog.js.map