@shop-os/modelkit 0.31.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 +26 -0
- package/dist/catalog.cjs +64 -16
- 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 +64 -16
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +66 -18
- 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 +66 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,32 @@ 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
|
+
|
|
12
38
|
## [0.31.0] - Unreleased
|
|
13
39
|
|
|
14
40
|
### 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
|
-
|
|
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
|
-
|
|
5912
|
+
preferDefaultDuration: true,
|
|
5909
5913
|
references: {
|
|
5910
5914
|
...NO_REFERENCES,
|
|
5911
5915
|
images: 10,
|
|
@@ -6760,7 +6764,6 @@ var VIDEO_MODELS = [
|
|
|
6760
6764
|
aspectRatios: [...OMNI_RATIOS],
|
|
6761
6765
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
6762
6766
|
durations: { min: 3, max: 15 },
|
|
6763
|
-
durationPresets: [3, 5, 8, 10, 15],
|
|
6764
6767
|
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
6765
6768
|
sourceVideoSeconds: { max: 15 },
|
|
6766
6769
|
supports: ["videoExtension", "lastFrame"],
|
|
@@ -7327,7 +7330,7 @@ var VIDEO_MODELS = [
|
|
|
7327
7330
|
aspectRatios: [...WAN_RATIOS],
|
|
7328
7331
|
resolutions: ["480p", "720p", "1080p"],
|
|
7329
7332
|
durations: { min: 2, max: 30 },
|
|
7330
|
-
|
|
7333
|
+
preferDefaultDuration: true,
|
|
7331
7334
|
references: {
|
|
7332
7335
|
images: 10,
|
|
7333
7336
|
videos: 5,
|
|
@@ -7369,7 +7372,7 @@ var VIDEO_MODELS = [
|
|
|
7369
7372
|
aspectRatios: [...WAN_RATIOS],
|
|
7370
7373
|
resolutions: ["480p", "720p", "1080p"],
|
|
7371
7374
|
durations: { min: 2, max: 30 },
|
|
7372
|
-
|
|
7375
|
+
preferDefaultDuration: true,
|
|
7373
7376
|
references: {
|
|
7374
7377
|
images: 10,
|
|
7375
7378
|
videos: 5,
|
|
@@ -8927,6 +8930,8 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8927
8930
|
resolutions: import_zod3.z.array(VideoResolutionSchema).optional(),
|
|
8928
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(),
|
|
8929
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(),
|
|
8930
8935
|
qualityOptions: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
8931
8936
|
scaleFactors: import_zod3.z.array(import_zod3.z.number().positive()).min(1).optional(),
|
|
8932
8937
|
exactSizes: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).optional(),
|
|
@@ -9153,6 +9158,19 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
|
9153
9158
|
}
|
|
9154
9159
|
}
|
|
9155
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
|
+
}
|
|
9156
9174
|
const audio = row2.constraints.audio;
|
|
9157
9175
|
if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
|
|
9158
9176
|
ctx.addIssue({
|
|
@@ -10391,15 +10409,16 @@ function hasReferences(req) {
|
|
|
10391
10409
|
return count(req.referenceImages) + count(req.referenceVideos) > 0;
|
|
10392
10410
|
}
|
|
10393
10411
|
var KLING_V4_4K_MAX_SECONDS = 15;
|
|
10394
|
-
function klingV4FourK(seconds3, req) {
|
|
10412
|
+
function klingV4FourK(seconds3, req, model) {
|
|
10395
10413
|
if (req.resolution !== "4k") return void 0;
|
|
10414
|
+
const max = model.constraints.maxSecondsByResolution?.["4k"] ?? KLING_V4_4K_MAX_SECONDS;
|
|
10396
10415
|
if (seconds3 === void 0) {
|
|
10397
|
-
return missing(`needs a measured source video of up to ${
|
|
10416
|
+
return missing(`needs a measured source video of up to ${max} s at 4K`);
|
|
10398
10417
|
}
|
|
10399
|
-
return seconds3 >
|
|
10418
|
+
return seconds3 > max ? unsupported2(`renders at most ${max} s at 4K`) : void 0;
|
|
10400
10419
|
}
|
|
10401
|
-
function klingV4(req) {
|
|
10402
|
-
const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
|
|
10420
|
+
function klingV4(req, model) {
|
|
10421
|
+
const fourK = klingV4FourK(req.durationSeconds ?? 5, req, model);
|
|
10403
10422
|
if (fourK !== void 0) return fourK;
|
|
10404
10423
|
if (hasReferences(req)) {
|
|
10405
10424
|
if (req.lastFrame !== void 0) {
|
|
@@ -10414,10 +10433,10 @@ function klingV4(req) {
|
|
|
10414
10433
|
}
|
|
10415
10434
|
return needsPrompt(req);
|
|
10416
10435
|
}
|
|
10417
|
-
function klingV4Flash(req) {
|
|
10436
|
+
function klingV4Flash(req, model) {
|
|
10418
10437
|
if (req.lastFrame !== void 0) return unsupported2("takes no end frame");
|
|
10419
10438
|
if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
|
|
10420
|
-
return klingV4(req);
|
|
10439
|
+
return klingV4(req, model);
|
|
10421
10440
|
}
|
|
10422
10441
|
function h3Turbo(req) {
|
|
10423
10442
|
if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
|
|
@@ -10520,7 +10539,7 @@ var RULES = new Map([
|
|
|
10520
10539
|
[KLING_V4, klingV4],
|
|
10521
10540
|
[
|
|
10522
10541
|
KLING_V4_EDIT,
|
|
10523
|
-
(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)
|
|
10524
10543
|
],
|
|
10525
10544
|
[KLING_V4_FLASH, klingV4Flash],
|
|
10526
10545
|
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
@@ -10540,8 +10559,8 @@ var RULES = new Map([
|
|
|
10540
10559
|
[LTX25_T2V, ltx(null)],
|
|
10541
10560
|
[LTX25_FAST_T2V, ltx(["720p", "1080p"])]
|
|
10542
10561
|
]);
|
|
10543
|
-
function falVideoProblem(
|
|
10544
|
-
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
10562
|
+
function falVideoProblem(model, req) {
|
|
10563
|
+
return RULES.get(model.providerModelId.toLowerCase())?.(req, model);
|
|
10545
10564
|
}
|
|
10546
10565
|
function viduSilentWarning(model) {
|
|
10547
10566
|
return {
|
|
@@ -10572,7 +10591,7 @@ function fillKlingModeResolution(model, req) {
|
|
|
10572
10591
|
}
|
|
10573
10592
|
function applyFalVideoRules(model, req, callerRatio, warnings) {
|
|
10574
10593
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
10575
|
-
const problem = falVideoProblem(model
|
|
10594
|
+
const problem = falVideoProblem(model, withPromptForResolve(req));
|
|
10576
10595
|
if (problem !== void 0) throw ruleRefusal(model, problem.message, problem.code);
|
|
10577
10596
|
const id = model.providerModelId.toLowerCase();
|
|
10578
10597
|
const references = count(req.referenceImages) + count(req.referenceAudios);
|
|
@@ -10713,6 +10732,27 @@ function resolveDuration(requested, durations, model, onUnsupported, warnings) {
|
|
|
10713
10732
|
});
|
|
10714
10733
|
return to;
|
|
10715
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
|
+
}
|
|
10716
10756
|
function resolveAspectRatio(requested, supported, model, onUnsupported, warnings) {
|
|
10717
10757
|
if (requested === void 0 || requested === "adaptive" || !supported) return requested;
|
|
10718
10758
|
if (supported.includes(requested)) return requested;
|
|
@@ -11032,6 +11072,14 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
11032
11072
|
warnings
|
|
11033
11073
|
);
|
|
11034
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;
|
|
11035
11083
|
const limits = c.references ?? {};
|
|
11036
11084
|
let images = trim(
|
|
11037
11085
|
"referenceImages",
|