@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/dist/index.cjs
CHANGED
|
@@ -5905,7 +5905,9 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5905
5905
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5906
5906
|
resolutions: ["720p", "1080p", "4k"],
|
|
5907
5907
|
durations: { min: 3, max: 30 },
|
|
5908
|
-
|
|
5908
|
+
preferDefaultDuration: true,
|
|
5909
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5910
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5909
5911
|
references: {
|
|
5910
5912
|
...NO_REFERENCES,
|
|
5911
5913
|
images: 10,
|
|
@@ -5944,6 +5946,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5944
5946
|
inputBilling: "kling-v4",
|
|
5945
5947
|
resolutions: ["720p", "1080p", "4k"],
|
|
5946
5948
|
durations: { min: 3, max: 30 },
|
|
5949
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5950
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5947
5951
|
references: { ...NO_REFERENCES, images: 10 },
|
|
5948
5952
|
requires: ["sourceVideo"],
|
|
5949
5953
|
sourceVideoSeconds: { min: 3, max: 30.05 },
|
|
@@ -5981,7 +5985,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5981
5985
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5982
5986
|
resolutions: ["720p"],
|
|
5983
5987
|
durations: { min: 3, max: 20 },
|
|
5984
|
-
|
|
5988
|
+
preferDefaultDuration: true,
|
|
5985
5989
|
references: {
|
|
5986
5990
|
...NO_REFERENCES,
|
|
5987
5991
|
images: 10,
|
|
@@ -6836,7 +6840,6 @@ var VIDEO_MODELS = [
|
|
|
6836
6840
|
aspectRatios: [...OMNI_RATIOS],
|
|
6837
6841
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
6838
6842
|
durations: { min: 3, max: 15 },
|
|
6839
|
-
durationPresets: [3, 5, 8, 10, 15],
|
|
6840
6843
|
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
6841
6844
|
sourceVideoSeconds: { max: 15 },
|
|
6842
6845
|
supports: ["videoExtension", "lastFrame"],
|
|
@@ -7403,7 +7406,7 @@ var VIDEO_MODELS = [
|
|
|
7403
7406
|
aspectRatios: [...WAN_RATIOS],
|
|
7404
7407
|
resolutions: ["480p", "720p", "1080p"],
|
|
7405
7408
|
durations: { min: 2, max: 30 },
|
|
7406
|
-
|
|
7409
|
+
preferDefaultDuration: true,
|
|
7407
7410
|
references: {
|
|
7408
7411
|
images: 10,
|
|
7409
7412
|
videos: 5,
|
|
@@ -7445,7 +7448,7 @@ var VIDEO_MODELS = [
|
|
|
7445
7448
|
aspectRatios: [...WAN_RATIOS],
|
|
7446
7449
|
resolutions: ["480p", "720p", "1080p"],
|
|
7447
7450
|
durations: { min: 2, max: 30 },
|
|
7448
|
-
|
|
7451
|
+
preferDefaultDuration: true,
|
|
7449
7452
|
references: {
|
|
7450
7453
|
images: 10,
|
|
7451
7454
|
videos: 5,
|
|
@@ -8997,6 +9000,8 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8997
9000
|
resolutions: import_zod3.z.array(VideoResolutionSchema).optional(),
|
|
8998
9001
|
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(),
|
|
8999
9002
|
durationPresets: import_zod3.z.array(import_zod3.z.number()).optional(),
|
|
9003
|
+
maxSecondsByResolution: import_zod3.z.partialRecord(VideoResolutionSchema, import_zod3.z.number().positive()).optional(),
|
|
9004
|
+
preferDefaultDuration: import_zod3.z.boolean().optional(),
|
|
9000
9005
|
qualityOptions: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
9001
9006
|
scaleFactors: import_zod3.z.array(import_zod3.z.number().positive()).min(1).optional(),
|
|
9002
9007
|
exactSizes: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).optional(),
|
|
@@ -9223,6 +9228,19 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
|
9223
9228
|
}
|
|
9224
9229
|
}
|
|
9225
9230
|
}
|
|
9231
|
+
const durations = row2.constraints.durations;
|
|
9232
|
+
for (const [resolution, max] of Object.entries(
|
|
9233
|
+
row2.constraints.maxSecondsByResolution ?? {}
|
|
9234
|
+
)) {
|
|
9235
|
+
const inRange = durations === void 0 || (Array.isArray(durations) ? durations.some((d) => d <= max) && max <= Math.max(...durations) : max >= durations.min && max <= durations.max);
|
|
9236
|
+
if (!Number.isInteger(max) || !inRange) {
|
|
9237
|
+
ctx.addIssue({
|
|
9238
|
+
code: "custom",
|
|
9239
|
+
path: ["constraints", "maxSecondsByResolution", resolution],
|
|
9240
|
+
message: "a resolution cap must be whole seconds within the row's durations"
|
|
9241
|
+
});
|
|
9242
|
+
}
|
|
9243
|
+
}
|
|
9226
9244
|
const audio = row2.constraints.audio;
|
|
9227
9245
|
if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
|
|
9228
9246
|
ctx.addIssue({
|
|
@@ -10665,15 +10683,16 @@ function hasReferences(req) {
|
|
|
10665
10683
|
return count(req.referenceImages) + count(req.referenceVideos) > 0;
|
|
10666
10684
|
}
|
|
10667
10685
|
var KLING_V4_4K_MAX_SECONDS = 15;
|
|
10668
|
-
function klingV4FourK(seconds3, req) {
|
|
10686
|
+
function klingV4FourK(seconds3, req, model) {
|
|
10669
10687
|
if (req.resolution !== "4k") return void 0;
|
|
10688
|
+
const max = model.constraints.maxSecondsByResolution?.["4k"] ?? KLING_V4_4K_MAX_SECONDS;
|
|
10670
10689
|
if (seconds3 === void 0) {
|
|
10671
|
-
return missing(`needs a measured source video of up to ${
|
|
10690
|
+
return missing(`needs a measured source video of up to ${max} s at 4K`);
|
|
10672
10691
|
}
|
|
10673
|
-
return seconds3 >
|
|
10692
|
+
return seconds3 > max ? unsupported3(`renders at most ${max} s at 4K`) : void 0;
|
|
10674
10693
|
}
|
|
10675
|
-
function klingV4(req) {
|
|
10676
|
-
const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
|
|
10694
|
+
function klingV4(req, model) {
|
|
10695
|
+
const fourK = klingV4FourK(req.durationSeconds ?? 5, req, model);
|
|
10677
10696
|
if (fourK !== void 0) return fourK;
|
|
10678
10697
|
if (hasReferences(req)) {
|
|
10679
10698
|
if (req.lastFrame !== void 0) {
|
|
@@ -10688,10 +10707,10 @@ function klingV4(req) {
|
|
|
10688
10707
|
}
|
|
10689
10708
|
return needsPrompt(req);
|
|
10690
10709
|
}
|
|
10691
|
-
function klingV4Flash(req) {
|
|
10710
|
+
function klingV4Flash(req, model) {
|
|
10692
10711
|
if (req.lastFrame !== void 0) return unsupported3("takes no end frame");
|
|
10693
10712
|
if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
|
|
10694
|
-
return klingV4(req);
|
|
10713
|
+
return klingV4(req, model);
|
|
10695
10714
|
}
|
|
10696
10715
|
function h3Turbo(req) {
|
|
10697
10716
|
if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
|
|
@@ -10794,7 +10813,7 @@ var RULES = new Map([
|
|
|
10794
10813
|
[KLING_V4, klingV4],
|
|
10795
10814
|
[
|
|
10796
10815
|
KLING_V4_EDIT,
|
|
10797
|
-
(req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
|
|
10816
|
+
(req, model) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req, model) ?? needsPrompt(req)
|
|
10798
10817
|
],
|
|
10799
10818
|
[KLING_V4_FLASH, klingV4Flash],
|
|
10800
10819
|
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
@@ -10814,8 +10833,8 @@ var RULES = new Map([
|
|
|
10814
10833
|
[LTX25_T2V, ltx(null)],
|
|
10815
10834
|
[LTX25_FAST_T2V, ltx(["720p", "1080p"])]
|
|
10816
10835
|
]);
|
|
10817
|
-
function falVideoProblem(
|
|
10818
|
-
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
10836
|
+
function falVideoProblem(model, req) {
|
|
10837
|
+
return RULES.get(model.providerModelId.toLowerCase())?.(req, model);
|
|
10819
10838
|
}
|
|
10820
10839
|
function viduSilentWarning(model) {
|
|
10821
10840
|
return {
|
|
@@ -10846,7 +10865,7 @@ function fillKlingModeResolution(model, req) {
|
|
|
10846
10865
|
}
|
|
10847
10866
|
function applyFalVideoRules(model, req, callerRatio, warnings) {
|
|
10848
10867
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
10849
|
-
const problem = falVideoProblem(model
|
|
10868
|
+
const problem = falVideoProblem(model, withPromptForResolve(req));
|
|
10850
10869
|
if (problem !== void 0) throw ruleRefusal(model, problem.message, problem.code);
|
|
10851
10870
|
const id = model.providerModelId.toLowerCase();
|
|
10852
10871
|
const references = count(req.referenceImages) + count(req.referenceAudios);
|
|
@@ -10959,7 +10978,7 @@ function happyHorseBody(req, ctx) {
|
|
|
10959
10978
|
}
|
|
10960
10979
|
function planAlibabaVideo(req, ctx) {
|
|
10961
10980
|
const id = ctx.model.providerModelId.toLowerCase();
|
|
10962
|
-
const problem = falVideoProblem(
|
|
10981
|
+
const problem = falVideoProblem(ctx.model, req);
|
|
10963
10982
|
if (problem !== void 0) throw ruleRefusal(ctx.model, problem.message, problem.code);
|
|
10964
10983
|
if (WAN_VIDEO_IDS.has(id)) return wanBody(req, ctx);
|
|
10965
10984
|
if (id === HAPPY_HORSE_FAMILY) return happyHorseBody(req, ctx);
|
|
@@ -14256,7 +14275,7 @@ function planFalFamilyVideo(req, ctx) {
|
|
|
14256
14275
|
const id = ctx.model.providerModelId.toLowerCase();
|
|
14257
14276
|
const family = FAMILIES2.find((f) => f.ids.has(id));
|
|
14258
14277
|
if (family === void 0) return void 0;
|
|
14259
|
-
const problem = falVideoProblem(
|
|
14278
|
+
const problem = falVideoProblem(ctx.model, req);
|
|
14260
14279
|
if (problem !== void 0) throw refusal2(ctx, problem.message, problem.code);
|
|
14261
14280
|
return family.plan(req, ctx);
|
|
14262
14281
|
}
|
|
@@ -20046,6 +20065,27 @@ function resolveDuration(requested, durations, model, onUnsupported, warnings) {
|
|
|
20046
20065
|
});
|
|
20047
20066
|
return to;
|
|
20048
20067
|
}
|
|
20068
|
+
function capDurationAtResolution(seconds3, resolution, model, onUnsupported, warnings) {
|
|
20069
|
+
if (seconds3 === void 0 || resolution === void 0) return seconds3;
|
|
20070
|
+
const max = model.constraints.maxSecondsByResolution?.[resolution];
|
|
20071
|
+
if (max === void 0 || seconds3 <= max) return seconds3;
|
|
20072
|
+
const shown = resolution.endsWith("k") ? resolution.toUpperCase() : resolution;
|
|
20073
|
+
if (onUnsupported === "error") {
|
|
20074
|
+
throw new ModelKitError({
|
|
20075
|
+
code: "unsupported_option",
|
|
20076
|
+
message: `${model.id} renders at most ${max} s at ${shown}`,
|
|
20077
|
+
model: model.id
|
|
20078
|
+
});
|
|
20079
|
+
}
|
|
20080
|
+
warnings.push({
|
|
20081
|
+
code: "duration_coerced",
|
|
20082
|
+
field: "durationSeconds",
|
|
20083
|
+
from: seconds3,
|
|
20084
|
+
to: max,
|
|
20085
|
+
message: `duration ${seconds3}s coerced to ${max}s for ${model.id} at ${shown}`
|
|
20086
|
+
});
|
|
20087
|
+
return max;
|
|
20088
|
+
}
|
|
20049
20089
|
function resolveAspectRatio(requested, supported, model, onUnsupported, warnings) {
|
|
20050
20090
|
if (requested === void 0 || requested === "adaptive" || !supported) return requested;
|
|
20051
20091
|
if (supported.includes(requested)) return requested;
|
|
@@ -20365,6 +20405,14 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
20365
20405
|
warnings
|
|
20366
20406
|
);
|
|
20367
20407
|
if (duration !== void 0) merged.durationSeconds = duration;
|
|
20408
|
+
const capped = capDurationAtResolution(
|
|
20409
|
+
merged.durationSeconds,
|
|
20410
|
+
resolution,
|
|
20411
|
+
model,
|
|
20412
|
+
onUnsupported,
|
|
20413
|
+
warnings
|
|
20414
|
+
);
|
|
20415
|
+
if (capped !== void 0) merged.durationSeconds = capped;
|
|
20368
20416
|
const limits = c.references ?? {};
|
|
20369
20417
|
let images = trim(
|
|
20370
20418
|
"referenceImages",
|