@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 CHANGED
@@ -9,6 +9,45 @@ header in the release PR.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.32.0] - Unreleased
13
+
14
+ ### Added
15
+ - `constraints.maxSecondsByResolution` (`Partial<Record<VideoResolution, number>>`): the longest
16
+ output a video row renders at a resolution that is shorter than its `durations`. The resolver
17
+ enforces it for every row ("renders at most N s at 4K" under `"error"`; snaps to the cap with a
18
+ `duration_coerced` warning under `"coerce"`). The write schema needs whole seconds within the
19
+ row's `durations`. `kling-4.0` and `kling-4.0-edit` set `{ "4k": 15 }`. The Kling 4.0 rule keeps
20
+ 15 s as its floor, so a row may lower the 4K cap but never lift it, and an edit at 4K still needs
21
+ a measured source. Kits before 0.32.0 ignore the field and keep their built-in 15 s.
22
+ - `constraints.preferDefaultDuration`: pickers pre-select the row's `defaults.durationSeconds`
23
+ over their own product default. Set on `wan-3.0`, `wan-3.0-prime`, `kling-4.0` and
24
+ `kling-4.0-flash`, so their 5 s default holds now that every second is listed.
25
+
26
+ ### Changed
27
+ - `wan-3.0`, `wan-3.0-prime`, `kling-4.0`, `kling-4.0-flash` and `gemini-omni-1.2-flash` drop
28
+ `durationPresets`: the providers take any whole second in the row's `durations` and bill per
29
+ second, so pickers list every second. `defaults.durationSeconds` is unchanged (5 s for Wan 3,
30
+ Wan 3 Prime, Kling 4.0 and Kling 4.0 Flash; Omni has none).
31
+
32
+ ### Rollout
33
+ - pro-backend syncs `model_catalog` from its kit's `MODELS` on boot, so the live rows change once
34
+ pro-backend runs 0.32.0. Apps can take 0.32.0 in any order: the 4K floor holds whatever the live
35
+ row says. Until cowork runs 0.32.0 with its Studio change, a 0.31.0 cowork that reads re-synced
36
+ rows lists every second and defaults the four rows above to 8 s.
37
+
38
+ ## [0.31.0] - Unreleased
39
+
40
+ ### Added
41
+ - `ltx-2.5` and `ltx-2.5-fast` (ENG-4326): Lightricks LTX 2.5 Pro and Fast on fal partner endpoints
42
+ `lightricks/ltx-2.5/{text,image}-to-video/{pro,fast}`, on the LTX 2.3 adapter (`adapters/fal-ltx.ts`):
43
+ a start frame routes to image-to-video (with an optional end frame), else text-to-video. Pro renders
44
+ 720p or 1080p, 6/8/10 s; Fast renders 720p to 2160p (`2k`/`4k`), even 6-20 s, over 10 s at 720p or
45
+ 1080p only. LTX 2.5 has no safety-checker field, so the rows do not support `safetyChecker`. No new
46
+ vocabulary.
47
+
48
+ ### Live rows to add after publish
49
+ - Pricing rows (shopos + sloosh, every env) for `ltx-2.5` 720p/1080p and `ltx-2.5-fast` 720p/1080p/2k/4k.
50
+
12
51
  ## [0.30.0] - Unreleased
13
52
 
14
53
  ### Added
package/dist/catalog.cjs CHANGED
@@ -5829,7 +5829,9 @@ var VIDEO_FAMILY_MODELS = [
5829
5829
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5830
5830
  resolutions: ["720p", "1080p", "4k"],
5831
5831
  durations: { min: 3, max: 30 },
5832
- durationPresets: [5, 10, 15, 30],
5832
+ preferDefaultDuration: true,
5833
+ // A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
5834
+ maxSecondsByResolution: { "4k": 15 },
5833
5835
  references: {
5834
5836
  ...NO_REFERENCES,
5835
5837
  images: 10,
@@ -5868,6 +5870,8 @@ var VIDEO_FAMILY_MODELS = [
5868
5870
  inputBilling: "kling-v4",
5869
5871
  resolutions: ["720p", "1080p", "4k"],
5870
5872
  durations: { min: 3, max: 30 },
5873
+ // A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
5874
+ maxSecondsByResolution: { "4k": 15 },
5871
5875
  references: { ...NO_REFERENCES, images: 10 },
5872
5876
  requires: ["sourceVideo"],
5873
5877
  sourceVideoSeconds: { min: 3, max: 30.05 },
@@ -5905,7 +5909,7 @@ var VIDEO_FAMILY_MODELS = [
5905
5909
  aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
5906
5910
  resolutions: ["720p"],
5907
5911
  durations: { min: 3, max: 20 },
5908
- durationPresets: [5, 10, 15, 20],
5912
+ preferDefaultDuration: true,
5909
5913
  references: {
5910
5914
  ...NO_REFERENCES,
5911
5915
  images: 10,
@@ -6352,6 +6356,76 @@ var VIDEO_FAMILY_MODELS = [
6352
6356
  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."
6353
6357
  },
6354
6358
  capabilities: { lastFrameRequiresFirstFrame: true }
6359
+ },
6360
+ {
6361
+ // https://fal.ai/models/lightricks/ltx-2.5/text-to-video/pro/api (+ /image-to-video/pro):
6362
+ // a Lightricks partner endpoint on fal. Pro renders 720p and 1080p only, 6/8/10 s;
6363
+ // no safety checker field. Routing and tiers as LTX 2.3 (adapters/fal-ltx.ts).
6364
+ id: "ltx-2.5",
6365
+ aliases: ["ltx-2-5", "ltx25", "ltx-2.5-pro"],
6366
+ label: "LTX 2.5",
6367
+ type: "video",
6368
+ adapter: "fal",
6369
+ providerModelId: "lightricks/ltx-2.5/text-to-video/pro",
6370
+ lifecycle: "active",
6371
+ exposure: ["cowork", "space_builder"],
6372
+ constraints: {
6373
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6374
+ resolutions: ["720p", "1080p"],
6375
+ durations: [6, 8, 10],
6376
+ supports: ["generateAudio", "lastFrame"],
6377
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6378
+ audio: "optional"
6379
+ },
6380
+ defaults: {
6381
+ durationSeconds: 6,
6382
+ resolution: "1080p",
6383
+ aspectRatio: "adaptive",
6384
+ generateAudio: true
6385
+ },
6386
+ usage: { ...VIDEO_USAGE },
6387
+ pricingKind: "video_per_second",
6388
+ display: {
6389
+ provider: "lightricks",
6390
+ logo: LIGHTRICKS_LOGO,
6391
+ 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."
6392
+ },
6393
+ capabilities: { lastFrameRequiresFirstFrame: true }
6394
+ },
6395
+ {
6396
+ // https://fal.ai/models/lightricks/ltx-2.5/text-to-video/fast/api (+ /image-to-video/fast):
6397
+ // 720p to 2160p, even durations 6-20 s; over 10 s is 720p or 1080p at 24/25 fps only
6398
+ // (the kit never sends fps, so the rule checks the tier).
6399
+ id: "ltx-2.5-fast",
6400
+ aliases: ["ltx-2-5-fast", "ltx25-fast"],
6401
+ label: "LTX 2.5 Fast",
6402
+ type: "video",
6403
+ adapter: "fal",
6404
+ providerModelId: "lightricks/ltx-2.5/text-to-video/fast",
6405
+ lifecycle: "active",
6406
+ exposure: ["cowork", "space_builder"],
6407
+ constraints: {
6408
+ aspectRatios: ["adaptive", "16:9", "9:16"],
6409
+ resolutions: ["720p", "1080p", "2k", "4k"],
6410
+ durations: [6, 8, 10, 12, 14, 16, 18, 20],
6411
+ supports: ["generateAudio", "lastFrame"],
6412
+ prompt: { referenceSyntax: "numbered", maxChars: 5e3 },
6413
+ audio: "optional"
6414
+ },
6415
+ defaults: {
6416
+ durationSeconds: 6,
6417
+ resolution: "1080p",
6418
+ aspectRatio: "adaptive",
6419
+ generateAudio: true
6420
+ },
6421
+ usage: { ...VIDEO_USAGE },
6422
+ pricingKind: "video_per_second",
6423
+ display: {
6424
+ provider: "lightricks",
6425
+ logo: LIGHTRICKS_LOGO,
6426
+ 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."
6427
+ },
6428
+ capabilities: { lastFrameRequiresFirstFrame: true }
6355
6429
  }
6356
6430
  ];
6357
6431
 
@@ -6690,7 +6764,6 @@ var VIDEO_MODELS = [
6690
6764
  aspectRatios: [...OMNI_RATIOS],
6691
6765
  resolutions: ["360p", "720p", "1080p", "4k"],
6692
6766
  durations: { min: 3, max: 15 },
6693
- durationPresets: [3, 5, 8, 10, 15],
6694
6767
  references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
6695
6768
  sourceVideoSeconds: { max: 15 },
6696
6769
  supports: ["videoExtension", "lastFrame"],
@@ -7257,7 +7330,7 @@ var VIDEO_MODELS = [
7257
7330
  aspectRatios: [...WAN_RATIOS],
7258
7331
  resolutions: ["480p", "720p", "1080p"],
7259
7332
  durations: { min: 2, max: 30 },
7260
- durationPresets: [5, 10, 15, 30],
7333
+ preferDefaultDuration: true,
7261
7334
  references: {
7262
7335
  images: 10,
7263
7336
  videos: 5,
@@ -7299,7 +7372,7 @@ var VIDEO_MODELS = [
7299
7372
  aspectRatios: [...WAN_RATIOS],
7300
7373
  resolutions: ["480p", "720p", "1080p"],
7301
7374
  durations: { min: 2, max: 30 },
7302
- durationPresets: [5, 10, 15, 30],
7375
+ preferDefaultDuration: true,
7303
7376
  references: {
7304
7377
  images: 10,
7305
7378
  videos: 5,
@@ -8857,6 +8930,8 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
8857
8930
  resolutions: import_zod3.z.array(VideoResolutionSchema).optional(),
8858
8931
  durations: import_zod3.z.union([import_zod3.z.looseObject({ min: import_zod3.z.number(), max: import_zod3.z.number() }), import_zod3.z.array(import_zod3.z.number())]).optional(),
8859
8932
  durationPresets: import_zod3.z.array(import_zod3.z.number()).optional(),
8933
+ maxSecondsByResolution: import_zod3.z.partialRecord(VideoResolutionSchema, import_zod3.z.number().positive()).optional(),
8934
+ preferDefaultDuration: import_zod3.z.boolean().optional(),
8860
8935
  qualityOptions: import_zod3.z.array(import_zod3.z.string()).optional(),
8861
8936
  scaleFactors: import_zod3.z.array(import_zod3.z.number().positive()).min(1).optional(),
8862
8937
  exactSizes: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).optional(),
@@ -9083,6 +9158,19 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
9083
9158
  }
9084
9159
  }
9085
9160
  }
9161
+ const durations = row2.constraints.durations;
9162
+ for (const [resolution, max] of Object.entries(
9163
+ row2.constraints.maxSecondsByResolution ?? {}
9164
+ )) {
9165
+ const inRange = durations === void 0 || (Array.isArray(durations) ? durations.some((d) => d <= max) && max <= Math.max(...durations) : max >= durations.min && max <= durations.max);
9166
+ if (!Number.isInteger(max) || !inRange) {
9167
+ ctx.addIssue({
9168
+ code: "custom",
9169
+ path: ["constraints", "maxSecondsByResolution", resolution],
9170
+ message: "a resolution cap must be whole seconds within the row's durations"
9171
+ });
9172
+ }
9173
+ }
9086
9174
  const audio = row2.constraints.audio;
9087
9175
  if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
9088
9176
  ctx.addIssue({
@@ -10249,6 +10337,8 @@ var VIDU_Q4 = "fal-ai/vidu/q4";
10249
10337
  var OMNIHUMAN_V2 = "bytedance/omnihuman/v2";
10250
10338
  var LTX_T2V = "fal-ai/ltx-2.3/text-to-video";
10251
10339
  var LTX_FAST_T2V = "fal-ai/ltx-2.3/text-to-video/fast";
10340
+ var LTX25_T2V = "lightricks/ltx-2.5/text-to-video/pro";
10341
+ var LTX25_FAST_T2V = "lightricks/ltx-2.5/text-to-video/fast";
10252
10342
  var KLING_O3_IMAGE_CAP = 7;
10253
10343
  var KLING_V4_IMAGE_CAP = 10;
10254
10344
  var TURBO_AUDIO_MIN_SECONDS = 2;
@@ -10319,15 +10409,16 @@ function hasReferences(req) {
10319
10409
  return count(req.referenceImages) + count(req.referenceVideos) > 0;
10320
10410
  }
10321
10411
  var KLING_V4_4K_MAX_SECONDS = 15;
10322
- function klingV4FourK(seconds3, req) {
10412
+ function klingV4FourK(seconds3, req, model) {
10323
10413
  if (req.resolution !== "4k") return void 0;
10414
+ const max = model.constraints.maxSecondsByResolution?.["4k"] ?? KLING_V4_4K_MAX_SECONDS;
10324
10415
  if (seconds3 === void 0) {
10325
- return missing(`needs a measured source video of up to ${KLING_V4_4K_MAX_SECONDS} s at 4K`);
10416
+ return missing(`needs a measured source video of up to ${max} s at 4K`);
10326
10417
  }
10327
- return seconds3 > KLING_V4_4K_MAX_SECONDS ? unsupported2(`renders at most ${KLING_V4_4K_MAX_SECONDS} s at 4K`) : void 0;
10418
+ return seconds3 > max ? unsupported2(`renders at most ${max} s at 4K`) : void 0;
10328
10419
  }
10329
- function klingV4(req) {
10330
- const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
10420
+ function klingV4(req, model) {
10421
+ const fourK = klingV4FourK(req.durationSeconds ?? 5, req, model);
10331
10422
  if (fourK !== void 0) return fourK;
10332
10423
  if (hasReferences(req)) {
10333
10424
  if (req.lastFrame !== void 0) {
@@ -10342,10 +10433,10 @@ function klingV4(req) {
10342
10433
  }
10343
10434
  return needsPrompt(req);
10344
10435
  }
10345
- function klingV4Flash(req) {
10436
+ function klingV4Flash(req, model) {
10346
10437
  if (req.lastFrame !== void 0) return unsupported2("takes no end frame");
10347
10438
  if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
10348
- return klingV4(req);
10439
+ return klingV4(req, model);
10349
10440
  }
10350
10441
  function h3Turbo(req) {
10351
10442
  if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
@@ -10425,7 +10516,7 @@ function imageAndAudio(req, audioSeconds) {
10425
10516
  }
10426
10517
  return inputSeconds("audio", audio, audioSeconds);
10427
10518
  }
10428
- function ltx(fast) {
10519
+ function ltx(longTiers) {
10429
10520
  return (req) => {
10430
10521
  if (req.lastFrame !== void 0 && req.firstFrame === void 0) {
10431
10522
  return missing("takes an end frame only together with a start frame");
@@ -10433,8 +10524,8 @@ function ltx(fast) {
10433
10524
  if (count(req.referenceImages) + count(req.referenceVideos) + count(req.referenceAudios) > 0) {
10434
10525
  return unsupported2("takes no reference images, videos or audio");
10435
10526
  }
10436
- if (fast && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && req.resolution !== "1080p") {
10437
- return unsupported2("renders over 10 s at 1080p only");
10527
+ if (longTiers !== null && (req.durationSeconds ?? 6) > 10 && req.resolution !== void 0 && !longTiers.includes(req.resolution)) {
10528
+ return unsupported2(`renders over 10 s at ${longTiers.join(" or ")} only`);
10438
10529
  }
10439
10530
  return needsPrompt(req);
10440
10531
  };
@@ -10448,7 +10539,7 @@ var RULES = new Map([
10448
10539
  [KLING_V4, klingV4],
10449
10540
  [
10450
10541
  KLING_V4_EDIT,
10451
- (req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
10542
+ (req, model) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req, model) ?? needsPrompt(req)
10452
10543
  ],
10453
10544
  [KLING_V4_FLASH, klingV4Flash],
10454
10545
  [KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
@@ -10463,11 +10554,13 @@ var RULES = new Map([
10463
10554
  ...AVATAR_AUDIO.map(
10464
10555
  ([id, limits]) => [id, (req) => imageAndAudio(req, limits)]
10465
10556
  ),
10466
- [LTX_T2V, ltx(false)],
10467
- [LTX_FAST_T2V, ltx(true)]
10557
+ [LTX_T2V, ltx(null)],
10558
+ [LTX_FAST_T2V, ltx(["1080p"])],
10559
+ [LTX25_T2V, ltx(null)],
10560
+ [LTX25_FAST_T2V, ltx(["720p", "1080p"])]
10468
10561
  ]);
10469
- function falVideoProblem(providerModelId, req) {
10470
- return RULES.get(providerModelId.toLowerCase())?.(req);
10562
+ function falVideoProblem(model, req) {
10563
+ return RULES.get(model.providerModelId.toLowerCase())?.(req, model);
10471
10564
  }
10472
10565
  function viduSilentWarning(model) {
10473
10566
  return {
@@ -10498,7 +10591,7 @@ function fillKlingModeResolution(model, req) {
10498
10591
  }
10499
10592
  function applyFalVideoRules(model, req, callerRatio, warnings) {
10500
10593
  if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
10501
- const problem = falVideoProblem(model.providerModelId, withPromptForResolve(req));
10594
+ const problem = falVideoProblem(model, withPromptForResolve(req));
10502
10595
  if (problem !== void 0) throw ruleRefusal(model, problem.message, problem.code);
10503
10596
  const id = model.providerModelId.toLowerCase();
10504
10597
  const references = count(req.referenceImages) + count(req.referenceAudios);
@@ -10639,6 +10732,27 @@ function resolveDuration(requested, durations, model, onUnsupported, warnings) {
10639
10732
  });
10640
10733
  return to;
10641
10734
  }
10735
+ function capDurationAtResolution(seconds3, resolution, model, onUnsupported, warnings) {
10736
+ if (seconds3 === void 0 || resolution === void 0) return seconds3;
10737
+ const max = model.constraints.maxSecondsByResolution?.[resolution];
10738
+ if (max === void 0 || seconds3 <= max) return seconds3;
10739
+ const shown = resolution.endsWith("k") ? resolution.toUpperCase() : resolution;
10740
+ if (onUnsupported === "error") {
10741
+ throw new ModelKitError({
10742
+ code: "unsupported_option",
10743
+ message: `${model.id} renders at most ${max} s at ${shown}`,
10744
+ model: model.id
10745
+ });
10746
+ }
10747
+ warnings.push({
10748
+ code: "duration_coerced",
10749
+ field: "durationSeconds",
10750
+ from: seconds3,
10751
+ to: max,
10752
+ message: `duration ${seconds3}s coerced to ${max}s for ${model.id} at ${shown}`
10753
+ });
10754
+ return max;
10755
+ }
10642
10756
  function resolveAspectRatio(requested, supported, model, onUnsupported, warnings) {
10643
10757
  if (requested === void 0 || requested === "adaptive" || !supported) return requested;
10644
10758
  if (supported.includes(requested)) return requested;
@@ -10958,6 +11072,14 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
10958
11072
  warnings
10959
11073
  );
10960
11074
  if (duration !== void 0) merged.durationSeconds = duration;
11075
+ const capped = capDurationAtResolution(
11076
+ merged.durationSeconds,
11077
+ resolution,
11078
+ model,
11079
+ onUnsupported,
11080
+ warnings
11081
+ );
11082
+ if (capped !== void 0) merged.durationSeconds = capped;
10961
11083
  const limits = c.references ?? {};
10962
11084
  let images = trim(
10963
11085
  "referenceImages",