@shop-os/modelkit 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/dist/catalog.cjs +143 -21
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +14 -0
- package/dist/catalog.d.ts +14 -0
- package/dist/catalog.js +143 -21
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +163 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +163 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.d.cts
CHANGED
|
@@ -796,6 +796,10 @@ interface ModelConstraints {
|
|
|
796
796
|
} | number[];
|
|
797
797
|
/** Curated UI choices when `durations` is a range; `resolveOptions` ignores it. */
|
|
798
798
|
durationPresets?: number[];
|
|
799
|
+
/** Video rows: the longest output, in seconds, at a resolution that renders shorter than `durations`. */
|
|
800
|
+
maxSecondsByResolution?: Partial<Record<VideoResolution, number>>;
|
|
801
|
+
/** Pickers pre-select `defaults.durationSeconds` over their own product default. */
|
|
802
|
+
preferDefaultDuration?: boolean;
|
|
799
803
|
/** Curated quality choices for rows whose `supports` includes "quality". */
|
|
800
804
|
qualityOptions?: string[];
|
|
801
805
|
/** Upscale rows: the `scaleFactor` values the row offers; absent means any. */
|
|
@@ -1361,6 +1365,16 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
1361
1365
|
max: z.ZodNumber;
|
|
1362
1366
|
}, z.core.$loose>, z.ZodArray<z.ZodNumber>]>>;
|
|
1363
1367
|
durationPresets: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1368
|
+
maxSecondsByResolution: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
1369
|
+
"360p": "360p";
|
|
1370
|
+
"480p": "480p";
|
|
1371
|
+
"720p": "720p";
|
|
1372
|
+
"768p": "768p";
|
|
1373
|
+
"1080p": "1080p";
|
|
1374
|
+
"2k": "2k";
|
|
1375
|
+
"4k": "4k";
|
|
1376
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
1377
|
+
preferDefaultDuration: z.ZodOptional<z.ZodBoolean>;
|
|
1364
1378
|
qualityOptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1365
1379
|
scaleFactors: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1366
1380
|
exactSizes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
package/dist/catalog.d.ts
CHANGED
|
@@ -796,6 +796,10 @@ interface ModelConstraints {
|
|
|
796
796
|
} | number[];
|
|
797
797
|
/** Curated UI choices when `durations` is a range; `resolveOptions` ignores it. */
|
|
798
798
|
durationPresets?: number[];
|
|
799
|
+
/** Video rows: the longest output, in seconds, at a resolution that renders shorter than `durations`. */
|
|
800
|
+
maxSecondsByResolution?: Partial<Record<VideoResolution, number>>;
|
|
801
|
+
/** Pickers pre-select `defaults.durationSeconds` over their own product default. */
|
|
802
|
+
preferDefaultDuration?: boolean;
|
|
799
803
|
/** Curated quality choices for rows whose `supports` includes "quality". */
|
|
800
804
|
qualityOptions?: string[];
|
|
801
805
|
/** Upscale rows: the `scaleFactor` values the row offers; absent means any. */
|
|
@@ -1361,6 +1365,16 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
|
|
|
1361
1365
|
max: z.ZodNumber;
|
|
1362
1366
|
}, z.core.$loose>, z.ZodArray<z.ZodNumber>]>>;
|
|
1363
1367
|
durationPresets: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1368
|
+
maxSecondsByResolution: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
1369
|
+
"360p": "360p";
|
|
1370
|
+
"480p": "480p";
|
|
1371
|
+
"720p": "720p";
|
|
1372
|
+
"768p": "768p";
|
|
1373
|
+
"1080p": "1080p";
|
|
1374
|
+
"2k": "2k";
|
|
1375
|
+
"4k": "4k";
|
|
1376
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
1377
|
+
preferDefaultDuration: z.ZodOptional<z.ZodBoolean>;
|
|
1364
1378
|
qualityOptions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1365
1379
|
scaleFactors: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1366
1380
|
exactSizes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
package/dist/catalog.js
CHANGED
|
@@ -5737,7 +5737,9 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5737
5737
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5738
5738
|
resolutions: ["720p", "1080p", "4k"],
|
|
5739
5739
|
durations: { min: 3, max: 30 },
|
|
5740
|
-
|
|
5740
|
+
preferDefaultDuration: true,
|
|
5741
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5742
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5741
5743
|
references: {
|
|
5742
5744
|
...NO_REFERENCES,
|
|
5743
5745
|
images: 10,
|
|
@@ -5776,6 +5778,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5776
5778
|
inputBilling: "kling-v4",
|
|
5777
5779
|
resolutions: ["720p", "1080p", "4k"],
|
|
5778
5780
|
durations: { min: 3, max: 30 },
|
|
5781
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5782
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5779
5783
|
references: { ...NO_REFERENCES, images: 10 },
|
|
5780
5784
|
requires: ["sourceVideo"],
|
|
5781
5785
|
sourceVideoSeconds: { min: 3, max: 30.05 },
|
|
@@ -5813,7 +5817,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5813
5817
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5814
5818
|
resolutions: ["720p"],
|
|
5815
5819
|
durations: { min: 3, max: 20 },
|
|
5816
|
-
|
|
5820
|
+
preferDefaultDuration: true,
|
|
5817
5821
|
references: {
|
|
5818
5822
|
...NO_REFERENCES,
|
|
5819
5823
|
images: 10,
|
|
@@ -6260,6 +6264,76 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
6260
6264
|
description: "Speed-optimized Lightricks LTX 2.3 Fast text-to-video and start/end-frame image-to-video with native audio; 6-20 seconds at up to 4K, over 10 seconds at 1080p."
|
|
6261
6265
|
},
|
|
6262
6266
|
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6267
|
+
},
|
|
6268
|
+
{
|
|
6269
|
+
// https://fal.ai/models/lightricks/ltx-2.5/text-to-video/pro/api (+ /image-to-video/pro):
|
|
6270
|
+
// a Lightricks partner endpoint on fal. Pro renders 720p and 1080p only, 6/8/10 s;
|
|
6271
|
+
// no safety checker field. Routing and tiers as LTX 2.3 (adapters/fal-ltx.ts).
|
|
6272
|
+
id: "ltx-2.5",
|
|
6273
|
+
aliases: ["ltx-2-5", "ltx25", "ltx-2.5-pro"],
|
|
6274
|
+
label: "LTX 2.5",
|
|
6275
|
+
type: "video",
|
|
6276
|
+
adapter: "fal",
|
|
6277
|
+
providerModelId: "lightricks/ltx-2.5/text-to-video/pro",
|
|
6278
|
+
lifecycle: "active",
|
|
6279
|
+
exposure: ["cowork", "space_builder"],
|
|
6280
|
+
constraints: {
|
|
6281
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6282
|
+
resolutions: ["720p", "1080p"],
|
|
6283
|
+
durations: [6, 8, 10],
|
|
6284
|
+
supports: ["generateAudio", "lastFrame"],
|
|
6285
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6286
|
+
audio: "optional"
|
|
6287
|
+
},
|
|
6288
|
+
defaults: {
|
|
6289
|
+
durationSeconds: 6,
|
|
6290
|
+
resolution: "1080p",
|
|
6291
|
+
aspectRatio: "adaptive",
|
|
6292
|
+
generateAudio: true
|
|
6293
|
+
},
|
|
6294
|
+
usage: { ...VIDEO_USAGE },
|
|
6295
|
+
pricingKind: "video_per_second",
|
|
6296
|
+
display: {
|
|
6297
|
+
provider: "lightricks",
|
|
6298
|
+
logo: LIGHTRICKS_LOGO,
|
|
6299
|
+
description: "Lightricks LTX 2.5 Pro text-to-video and start/end-frame image-to-video with native audio; 6, 8 or 10 seconds at 720p or 1080p in landscape or portrait."
|
|
6300
|
+
},
|
|
6301
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6302
|
+
},
|
|
6303
|
+
{
|
|
6304
|
+
// https://fal.ai/models/lightricks/ltx-2.5/text-to-video/fast/api (+ /image-to-video/fast):
|
|
6305
|
+
// 720p to 2160p, even durations 6-20 s; over 10 s is 720p or 1080p at 24/25 fps only
|
|
6306
|
+
// (the kit never sends fps, so the rule checks the tier).
|
|
6307
|
+
id: "ltx-2.5-fast",
|
|
6308
|
+
aliases: ["ltx-2-5-fast", "ltx25-fast"],
|
|
6309
|
+
label: "LTX 2.5 Fast",
|
|
6310
|
+
type: "video",
|
|
6311
|
+
adapter: "fal",
|
|
6312
|
+
providerModelId: "lightricks/ltx-2.5/text-to-video/fast",
|
|
6313
|
+
lifecycle: "active",
|
|
6314
|
+
exposure: ["cowork", "space_builder"],
|
|
6315
|
+
constraints: {
|
|
6316
|
+
aspectRatios: ["adaptive", "16:9", "9:16"],
|
|
6317
|
+
resolutions: ["720p", "1080p", "2k", "4k"],
|
|
6318
|
+
durations: [6, 8, 10, 12, 14, 16, 18, 20],
|
|
6319
|
+
supports: ["generateAudio", "lastFrame"],
|
|
6320
|
+
prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
|
|
6321
|
+
audio: "optional"
|
|
6322
|
+
},
|
|
6323
|
+
defaults: {
|
|
6324
|
+
durationSeconds: 6,
|
|
6325
|
+
resolution: "1080p",
|
|
6326
|
+
aspectRatio: "adaptive",
|
|
6327
|
+
generateAudio: true
|
|
6328
|
+
},
|
|
6329
|
+
usage: { ...VIDEO_USAGE },
|
|
6330
|
+
pricingKind: "video_per_second",
|
|
6331
|
+
display: {
|
|
6332
|
+
provider: "lightricks",
|
|
6333
|
+
logo: LIGHTRICKS_LOGO,
|
|
6334
|
+
description: "Speed-optimized Lightricks LTX 2.5 Fast text-to-video and start/end-frame image-to-video with native audio; 6-20 seconds at up to 4K, over 10 seconds at 720p or 1080p."
|
|
6335
|
+
},
|
|
6336
|
+
capabilities: { lastFrameRequiresFirstFrame: true }
|
|
6263
6337
|
}
|
|
6264
6338
|
];
|
|
6265
6339
|
|
|
@@ -6598,7 +6672,6 @@ var VIDEO_MODELS = [
|
|
|
6598
6672
|
aspectRatios: [...OMNI_RATIOS],
|
|
6599
6673
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
6600
6674
|
durations: { min: 3, max: 15 },
|
|
6601
|
-
durationPresets: [3, 5, 8, 10, 15],
|
|
6602
6675
|
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
6603
6676
|
sourceVideoSeconds: { max: 15 },
|
|
6604
6677
|
supports: ["videoExtension", "lastFrame"],
|
|
@@ -7165,7 +7238,7 @@ var VIDEO_MODELS = [
|
|
|
7165
7238
|
aspectRatios: [...WAN_RATIOS],
|
|
7166
7239
|
resolutions: ["480p", "720p", "1080p"],
|
|
7167
7240
|
durations: { min: 2, max: 30 },
|
|
7168
|
-
|
|
7241
|
+
preferDefaultDuration: true,
|
|
7169
7242
|
references: {
|
|
7170
7243
|
images: 10,
|
|
7171
7244
|
videos: 5,
|
|
@@ -7207,7 +7280,7 @@ var VIDEO_MODELS = [
|
|
|
7207
7280
|
aspectRatios: [...WAN_RATIOS],
|
|
7208
7281
|
resolutions: ["480p", "720p", "1080p"],
|
|
7209
7282
|
durations: { min: 2, max: 30 },
|
|
7210
|
-
|
|
7283
|
+
preferDefaultDuration: true,
|
|
7211
7284
|
references: {
|
|
7212
7285
|
images: 10,
|
|
7213
7286
|
videos: 5,
|
|
@@ -8765,6 +8838,8 @@ var ModelConstraintsSchema = z3.looseObject({
|
|
|
8765
8838
|
resolutions: z3.array(VideoResolutionSchema).optional(),
|
|
8766
8839
|
durations: z3.union([z3.looseObject({ min: z3.number(), max: z3.number() }), z3.array(z3.number())]).optional(),
|
|
8767
8840
|
durationPresets: z3.array(z3.number()).optional(),
|
|
8841
|
+
maxSecondsByResolution: z3.partialRecord(VideoResolutionSchema, z3.number().positive()).optional(),
|
|
8842
|
+
preferDefaultDuration: z3.boolean().optional(),
|
|
8768
8843
|
qualityOptions: z3.array(z3.string()).optional(),
|
|
8769
8844
|
scaleFactors: z3.array(z3.number().positive()).min(1).optional(),
|
|
8770
8845
|
exactSizes: z3.record(z3.string(), z3.string()).optional(),
|
|
@@ -8991,6 +9066,19 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
|
8991
9066
|
}
|
|
8992
9067
|
}
|
|
8993
9068
|
}
|
|
9069
|
+
const durations = row2.constraints.durations;
|
|
9070
|
+
for (const [resolution, max] of Object.entries(
|
|
9071
|
+
row2.constraints.maxSecondsByResolution ?? {}
|
|
9072
|
+
)) {
|
|
9073
|
+
const inRange = durations === void 0 || (Array.isArray(durations) ? durations.some((d) => d <= max) && max <= Math.max(...durations) : max >= durations.min && max <= durations.max);
|
|
9074
|
+
if (!Number.isInteger(max) || !inRange) {
|
|
9075
|
+
ctx.addIssue({
|
|
9076
|
+
code: "custom",
|
|
9077
|
+
path: ["constraints", "maxSecondsByResolution", resolution],
|
|
9078
|
+
message: "a resolution cap must be whole seconds within the row's durations"
|
|
9079
|
+
});
|
|
9080
|
+
}
|
|
9081
|
+
}
|
|
8994
9082
|
const audio = row2.constraints.audio;
|
|
8995
9083
|
if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
|
|
8996
9084
|
ctx.addIssue({
|
|
@@ -10157,6 +10245,8 @@ var VIDU_Q4 = "fal-ai/vidu/q4";
|
|
|
10157
10245
|
var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
|
|
10158
10246
|
var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
|
|
10159
10247
|
var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
|
|
10248
|
+
var LTX25_T2V = "lightricks/ltx-2.5/text-to-video/pro";
|
|
10249
|
+
var LTX25_FAST_T2V = "lightricks/ltx-2.5/text-to-video/fast";
|
|
10160
10250
|
var KLING_O3_IMAGE_CAP = 7;
|
|
10161
10251
|
var KLING_V4_IMAGE_CAP = 10;
|
|
10162
10252
|
var TURBO_AUDIO_MIN_SECONDS = 2;
|
|
@@ -10227,15 +10317,16 @@ function hasReferences(req) {
|
|
|
10227
10317
|
return count(req.referenceImages) + count(req.referenceVideos) > 0;
|
|
10228
10318
|
}
|
|
10229
10319
|
var KLING_V4_4K_MAX_SECONDS = 15;
|
|
10230
|
-
function klingV4FourK(seconds3, req) {
|
|
10320
|
+
function klingV4FourK(seconds3, req, model) {
|
|
10231
10321
|
if (req.resolution !== "4k") return void 0;
|
|
10322
|
+
const max = model.constraints.maxSecondsByResolution?.["4k"] ?? KLING_V4_4K_MAX_SECONDS;
|
|
10232
10323
|
if (seconds3 === void 0) {
|
|
10233
|
-
return missing(`needs a measured source video of up to ${
|
|
10324
|
+
return missing(`needs a measured source video of up to ${max} s at 4K`);
|
|
10234
10325
|
}
|
|
10235
|
-
return seconds3 >
|
|
10326
|
+
return seconds3 > max ? unsupported2(`renders at most ${max} s at 4K`) : void 0;
|
|
10236
10327
|
}
|
|
10237
|
-
function klingV4(req) {
|
|
10238
|
-
const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
|
|
10328
|
+
function klingV4(req, model) {
|
|
10329
|
+
const fourK = klingV4FourK(req.durationSeconds ?? 5, req, model);
|
|
10239
10330
|
if (fourK !== void 0) return fourK;
|
|
10240
10331
|
if (hasReferences(req)) {
|
|
10241
10332
|
if (req.lastFrame !== void 0) {
|
|
@@ -10250,10 +10341,10 @@ function klingV4(req) {
|
|
|
10250
10341
|
}
|
|
10251
10342
|
return needsPrompt(req);
|
|
10252
10343
|
}
|
|
10253
|
-
function klingV4Flash(req) {
|
|
10344
|
+
function klingV4Flash(req, model) {
|
|
10254
10345
|
if (req.lastFrame !== void 0) return unsupported2("takes no end frame");
|
|
10255
10346
|
if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
|
|
10256
|
-
return klingV4(req);
|
|
10347
|
+
return klingV4(req, model);
|
|
10257
10348
|
}
|
|
10258
10349
|
function h3Turbo(req) {
|
|
10259
10350
|
if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
|
|
@@ -10333,7 +10424,7 @@ function imageAndAudio(req, audioSeconds) {
|
|
|
10333
10424
|
}
|
|
10334
10425
|
return inputSeconds("audio", audio, audioSeconds);
|
|
10335
10426
|
}
|
|
10336
|
-
function ltx(
|
|
10427
|
+
function ltx(longTiers) {
|
|
10337
10428
|
return (req) => {
|
|
10338
10429
|
if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
|
|
10339
10430
|
return missing("takes an end frame only together with a start frame");
|
|
@@ -10341,8 +10432,8 @@ function ltx(fast) {
|
|
|
10341
10432
|
if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
|
|
10342
10433
|
return unsupported2("takes no reference images, videos or audio");
|
|
10343
10434
|
}
|
|
10344
|
-
if (
|
|
10345
|
-
return unsupported2(
|
|
10435
|
+
if (longTiers !== null && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && !longTiers.includes(req.resolution)) {
|
|
10436
|
+
return unsupported2(`renders over 10 s at ${longTiers.join(" or ")} only`);
|
|
10346
10437
|
}
|
|
10347
10438
|
return needsPrompt(req);
|
|
10348
10439
|
};
|
|
@@ -10356,7 +10447,7 @@ var RULES = new Map([
|
|
|
10356
10447
|
[KLING_V4, klingV4],
|
|
10357
10448
|
[
|
|
10358
10449
|
KLING_V4_EDIT,
|
|
10359
|
-
(req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
|
|
10450
|
+
(req, model) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req, model) ?? needsPrompt(req)
|
|
10360
10451
|
],
|
|
10361
10452
|
[KLING_V4_FLASH, klingV4Flash],
|
|
10362
10453
|
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
@@ -10371,11 +10462,13 @@ var RULES = new Map([
|
|
|
10371
10462
|
...AVATAR_AUDIO.map(
|
|
10372
10463
|
([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
|
|
10373
10464
|
),
|
|
10374
|
-
[LTX_T2V, ltx(
|
|
10375
|
-
[LTX_FAST_T2V, ltx(
|
|
10465
|
+
[LTX_T2V, ltx(null)],
|
|
10466
|
+
[LTX_FAST_T2V, ltx(["1080p"])],
|
|
10467
|
+
[LTX25_T2V, ltx(null)],
|
|
10468
|
+
[LTX25_FAST_T2V, ltx(["720p", "1080p"])]
|
|
10376
10469
|
]);
|
|
10377
|
-
function falVideoProblem(
|
|
10378
|
-
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
10470
|
+
function falVideoProblem(model, req) {
|
|
10471
|
+
return RULES.get(model.providerModelId.toLowerCase())?.(req, model);
|
|
10379
10472
|
}
|
|
10380
10473
|
function viduSilentWarning(model) {
|
|
10381
10474
|
return {
|
|
@@ -10406,7 +10499,7 @@ function fillKlingModeResolution(model, req) {
|
|
|
10406
10499
|
}
|
|
10407
10500
|
function applyFalVideoRules(model, req, callerRatio, warnings) {
|
|
10408
10501
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
10409
|
-
const problem = falVideoProblem(model
|
|
10502
|
+
const problem = falVideoProblem(model, withPromptForResolve(req));
|
|
10410
10503
|
if (problem !== void 0) throw ruleRefusal(model, problem.message, problem.code);
|
|
10411
10504
|
const id = model.providerModelId.toLowerCase();
|
|
10412
10505
|
const references = count(req.referenceImages) + count(req.referenceAudios);
|
|
@@ -10547,6 +10640,27 @@ function resolveDuration(requested, durations, model, onUnsupported, warnings) {
|
|
|
10547
10640
|
});
|
|
10548
10641
|
return to;
|
|
10549
10642
|
}
|
|
10643
|
+
function capDurationAtResolution(seconds3, resolution, model, onUnsupported, warnings) {
|
|
10644
|
+
if (seconds3 === void 0 || resolution === void 0) return seconds3;
|
|
10645
|
+
const max = model.constraints.maxSecondsByResolution?.[resolution];
|
|
10646
|
+
if (max === void 0 || seconds3 <= max) return seconds3;
|
|
10647
|
+
const shown = resolution.endsWith("k") ? resolution.toUpperCase() : resolution;
|
|
10648
|
+
if (onUnsupported === "error") {
|
|
10649
|
+
throw new ModelKitError({
|
|
10650
|
+
code: "unsupported_option",
|
|
10651
|
+
message: `${model.id} renders at most ${max} s at ${shown}`,
|
|
10652
|
+
model: model.id
|
|
10653
|
+
});
|
|
10654
|
+
}
|
|
10655
|
+
warnings.push({
|
|
10656
|
+
code: "duration_coerced",
|
|
10657
|
+
field: "durationSeconds",
|
|
10658
|
+
from: seconds3,
|
|
10659
|
+
to: max,
|
|
10660
|
+
message: `duration ${seconds3}s coerced to ${max}s for ${model.id} at ${shown}`
|
|
10661
|
+
});
|
|
10662
|
+
return max;
|
|
10663
|
+
}
|
|
10550
10664
|
function resolveAspectRatio(requested, supported, model, onUnsupported, warnings) {
|
|
10551
10665
|
if (requested === void 0 || requested === "adaptive" || !supported) return requested;
|
|
10552
10666
|
if (supported.includes(requested)) return requested;
|
|
@@ -10866,6 +10980,14 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
10866
10980
|
warnings
|
|
10867
10981
|
);
|
|
10868
10982
|
if (duration !== void 0) merged.durationSeconds = duration;
|
|
10983
|
+
const capped = capDurationAtResolution(
|
|
10984
|
+
merged.durationSeconds,
|
|
10985
|
+
resolution,
|
|
10986
|
+
model,
|
|
10987
|
+
onUnsupported,
|
|
10988
|
+
warnings
|
|
10989
|
+
);
|
|
10990
|
+
if (capped !== void 0) merged.durationSeconds = capped;
|
|
10869
10991
|
const limits = c.references ?? {};
|
|
10870
10992
|
let images = trim(
|
|
10871
10993
|
"referenceImages",
|