@shop-os/modelkit 0.31.0 → 0.33.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 +37 -0
- package/dist/catalog.cjs +80 -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 +80 -16
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +94 -19
- 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 +94 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5315,6 +5315,22 @@ var TEXT_MODELS = [
|
|
|
5315
5315
|
contextWindow: 1e6
|
|
5316
5316
|
}
|
|
5317
5317
|
}),
|
|
5318
|
+
text("claude-sonnet-5-5", "Claude Sonnet 5.5", "claude-sonnet-5-5", {
|
|
5319
|
+
exposure: [],
|
|
5320
|
+
// Sonnet 5.5 rejects a forced tool_choice, which is how Bedrock's SDK asks for JSON on Sonnet 5.
|
|
5321
|
+
providerOptions: { modelkit: { structuredOutputMode: "outputFormat" } },
|
|
5322
|
+
display: {
|
|
5323
|
+
chat: { providerOptions: ANTHROPIC_ADAPTIVE },
|
|
5324
|
+
provider: "anthropic",
|
|
5325
|
+
costTier: 3,
|
|
5326
|
+
description: "Anthropic Claude Sonnet 5.5 balanced model; text and image input, 1M-token context."
|
|
5327
|
+
},
|
|
5328
|
+
capabilities: {
|
|
5329
|
+
reasoning: true,
|
|
5330
|
+
vision: true,
|
|
5331
|
+
contextWindow: 1e6
|
|
5332
|
+
}
|
|
5333
|
+
}),
|
|
5318
5334
|
text("claude-opus-4-8", "Claude Opus 4.8", "claude-opus-4-8", {
|
|
5319
5335
|
exposure: ["cowork", "space_builder"],
|
|
5320
5336
|
aliases: ["claude-opus-4.8", "claude-opus-4", "claude-opus-4.0", "claude-opus-4-20250514"],
|
|
@@ -5905,7 +5921,9 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5905
5921
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5906
5922
|
resolutions: ["720p", "1080p", "4k"],
|
|
5907
5923
|
durations: { min: 3, max: 30 },
|
|
5908
|
-
|
|
5924
|
+
preferDefaultDuration: true,
|
|
5925
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5926
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5909
5927
|
references: {
|
|
5910
5928
|
...NO_REFERENCES,
|
|
5911
5929
|
images: 10,
|
|
@@ -5944,6 +5962,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5944
5962
|
inputBilling: "kling-v4",
|
|
5945
5963
|
resolutions: ["720p", "1080p", "4k"],
|
|
5946
5964
|
durations: { min: 3, max: 30 },
|
|
5965
|
+
// A 3 s 4K clip took 138 s on fal; 30 s could outlast the 15-minute result wait.
|
|
5966
|
+
maxSecondsByResolution: { "4k": 15 },
|
|
5947
5967
|
references: { ...NO_REFERENCES, images: 10 },
|
|
5948
5968
|
requires: ["sourceVideo"],
|
|
5949
5969
|
sourceVideoSeconds: { min: 3, max: 30.05 },
|
|
@@ -5981,7 +6001,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5981
6001
|
aspectRatios: ["adaptive", "16:9", "9:16", "1:1", "21:9"],
|
|
5982
6002
|
resolutions: ["720p"],
|
|
5983
6003
|
durations: { min: 3, max: 20 },
|
|
5984
|
-
|
|
6004
|
+
preferDefaultDuration: true,
|
|
5985
6005
|
references: {
|
|
5986
6006
|
...NO_REFERENCES,
|
|
5987
6007
|
images: 10,
|
|
@@ -6836,7 +6856,6 @@ var VIDEO_MODELS = [
|
|
|
6836
6856
|
aspectRatios: [...OMNI_RATIOS],
|
|
6837
6857
|
resolutions: ["360p", "720p", "1080p", "4k"],
|
|
6838
6858
|
durations: { min: 3, max: 15 },
|
|
6839
|
-
durationPresets: [3, 5, 8, 10, 15],
|
|
6840
6859
|
references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
|
|
6841
6860
|
sourceVideoSeconds: { max: 15 },
|
|
6842
6861
|
supports: ["videoExtension", "lastFrame"],
|
|
@@ -7403,7 +7422,7 @@ var VIDEO_MODELS = [
|
|
|
7403
7422
|
aspectRatios: [...WAN_RATIOS],
|
|
7404
7423
|
resolutions: ["480p", "720p", "1080p"],
|
|
7405
7424
|
durations: { min: 2, max: 30 },
|
|
7406
|
-
|
|
7425
|
+
preferDefaultDuration: true,
|
|
7407
7426
|
references: {
|
|
7408
7427
|
images: 10,
|
|
7409
7428
|
videos: 5,
|
|
@@ -7445,7 +7464,7 @@ var VIDEO_MODELS = [
|
|
|
7445
7464
|
aspectRatios: [...WAN_RATIOS],
|
|
7446
7465
|
resolutions: ["480p", "720p", "1080p"],
|
|
7447
7466
|
durations: { min: 2, max: 30 },
|
|
7448
|
-
|
|
7467
|
+
preferDefaultDuration: true,
|
|
7449
7468
|
references: {
|
|
7450
7469
|
images: 10,
|
|
7451
7470
|
videos: 5,
|
|
@@ -8997,6 +9016,8 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
|
|
|
8997
9016
|
resolutions: import_zod3.z.array(VideoResolutionSchema).optional(),
|
|
8998
9017
|
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
9018
|
durationPresets: import_zod3.z.array(import_zod3.z.number()).optional(),
|
|
9019
|
+
maxSecondsByResolution: import_zod3.z.partialRecord(VideoResolutionSchema, import_zod3.z.number().positive()).optional(),
|
|
9020
|
+
preferDefaultDuration: import_zod3.z.boolean().optional(),
|
|
9000
9021
|
qualityOptions: import_zod3.z.array(import_zod3.z.string()).optional(),
|
|
9001
9022
|
scaleFactors: import_zod3.z.array(import_zod3.z.number().positive()).min(1).optional(),
|
|
9002
9023
|
exactSizes: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.string()).optional(),
|
|
@@ -9223,6 +9244,19 @@ var CatalogModelSchema = CatalogModelSchemaBase.superRefine(
|
|
|
9223
9244
|
}
|
|
9224
9245
|
}
|
|
9225
9246
|
}
|
|
9247
|
+
const durations = row2.constraints.durations;
|
|
9248
|
+
for (const [resolution, max] of Object.entries(
|
|
9249
|
+
row2.constraints.maxSecondsByResolution ?? {}
|
|
9250
|
+
)) {
|
|
9251
|
+
const inRange = durations === void 0 || (Array.isArray(durations) ? durations.some((d) => d <= max) && max <= Math.max(...durations) : max >= durations.min && max <= durations.max);
|
|
9252
|
+
if (!Number.isInteger(max) || !inRange) {
|
|
9253
|
+
ctx.addIssue({
|
|
9254
|
+
code: "custom",
|
|
9255
|
+
path: ["constraints", "maxSecondsByResolution", resolution],
|
|
9256
|
+
message: "a resolution cap must be whole seconds within the row's durations"
|
|
9257
|
+
});
|
|
9258
|
+
}
|
|
9259
|
+
}
|
|
9226
9260
|
const audio = row2.constraints.audio;
|
|
9227
9261
|
if (audio !== void 0 && !AudioOutputSchema.safeParse(audio).success) {
|
|
9228
9262
|
ctx.addIssue({
|
|
@@ -9450,9 +9484,20 @@ function missingKey(ctx, name) {
|
|
|
9450
9484
|
}
|
|
9451
9485
|
function bedrockMiddleware(ctx, canonicalModelId) {
|
|
9452
9486
|
let warned = false;
|
|
9487
|
+
const structuredOutputMode = ctx.model.providerOptions?.["modelkit"]?.["structuredOutputMode"];
|
|
9453
9488
|
return {
|
|
9454
9489
|
specificationVersion: "v3",
|
|
9455
|
-
transformParams: async ({ params }) => {
|
|
9490
|
+
transformParams: async ({ params: incoming }) => {
|
|
9491
|
+
const params = typeof structuredOutputMode === "string" && incoming.responseFormat?.type === "json" && incoming.providerOptions?.["anthropic"]?.["structuredOutputMode"] === void 0 ? {
|
|
9492
|
+
...incoming,
|
|
9493
|
+
providerOptions: {
|
|
9494
|
+
...incoming.providerOptions,
|
|
9495
|
+
anthropic: {
|
|
9496
|
+
...incoming.providerOptions?.["anthropic"],
|
|
9497
|
+
structuredOutputMode
|
|
9498
|
+
}
|
|
9499
|
+
}
|
|
9500
|
+
} : incoming;
|
|
9456
9501
|
const anthropic = params.providerOptions?.["anthropic"];
|
|
9457
9502
|
if (typeof anthropic !== "object" || anthropic === null || !("cacheControl" in anthropic))
|
|
9458
9503
|
return params;
|
|
@@ -10665,15 +10710,16 @@ function hasReferences(req) {
|
|
|
10665
10710
|
return count(req.referenceImages) + count(req.referenceVideos) > 0;
|
|
10666
10711
|
}
|
|
10667
10712
|
var KLING_V4_4K_MAX_SECONDS = 15;
|
|
10668
|
-
function klingV4FourK(seconds3, req) {
|
|
10713
|
+
function klingV4FourK(seconds3, req, model) {
|
|
10669
10714
|
if (req.resolution !== "4k") return void 0;
|
|
10715
|
+
const max = model.constraints.maxSecondsByResolution?.["4k"] ?? KLING_V4_4K_MAX_SECONDS;
|
|
10670
10716
|
if (seconds3 === void 0) {
|
|
10671
|
-
return missing(`needs a measured source video of up to ${
|
|
10717
|
+
return missing(`needs a measured source video of up to ${max} s at 4K`);
|
|
10672
10718
|
}
|
|
10673
|
-
return seconds3 >
|
|
10719
|
+
return seconds3 > max ? unsupported3(`renders at most ${max} s at 4K`) : void 0;
|
|
10674
10720
|
}
|
|
10675
|
-
function klingV4(req) {
|
|
10676
|
-
const fourK = klingV4FourK(req.durationSeconds ?? 5, req);
|
|
10721
|
+
function klingV4(req, model) {
|
|
10722
|
+
const fourK = klingV4FourK(req.durationSeconds ?? 5, req, model);
|
|
10677
10723
|
if (fourK !== void 0) return fourK;
|
|
10678
10724
|
if (hasReferences(req)) {
|
|
10679
10725
|
if (req.lastFrame !== void 0) {
|
|
@@ -10688,10 +10734,10 @@ function klingV4(req) {
|
|
|
10688
10734
|
}
|
|
10689
10735
|
return needsPrompt(req);
|
|
10690
10736
|
}
|
|
10691
|
-
function klingV4Flash(req) {
|
|
10737
|
+
function klingV4Flash(req, model) {
|
|
10692
10738
|
if (req.lastFrame !== void 0) return unsupported3("takes no end frame");
|
|
10693
10739
|
if (!hasReferences(req) && req.firstFrame !== void 0) return void 0;
|
|
10694
|
-
return klingV4(req);
|
|
10740
|
+
return klingV4(req, model);
|
|
10695
10741
|
}
|
|
10696
10742
|
function h3Turbo(req) {
|
|
10697
10743
|
if (count(req.referenceImages) + count(req.referenceVideos) > 0) {
|
|
@@ -10794,7 +10840,7 @@ var RULES = new Map([
|
|
|
10794
10840
|
[KLING_V4, klingV4],
|
|
10795
10841
|
[
|
|
10796
10842
|
KLING_V4_EDIT,
|
|
10797
|
-
(req) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req) ?? needsPrompt(req)
|
|
10843
|
+
(req, model) => needsSource(req) ?? klingV4FourK(req.durationSeconds ?? req.sourceVideo?.durationSeconds, req, model) ?? needsPrompt(req)
|
|
10798
10844
|
],
|
|
10799
10845
|
[KLING_V4_FLASH, klingV4Flash],
|
|
10800
10846
|
[KLING_V4_FLASH_EDIT, (req) => needsSource(req) ?? needsPrompt(req)],
|
|
@@ -10814,8 +10860,8 @@ var RULES = new Map([
|
|
|
10814
10860
|
[LTX25_T2V, ltx(null)],
|
|
10815
10861
|
[LTX25_FAST_T2V, ltx(["720p", "1080p"])]
|
|
10816
10862
|
]);
|
|
10817
|
-
function falVideoProblem(
|
|
10818
|
-
return RULES.get(providerModelId.toLowerCase())?.(req);
|
|
10863
|
+
function falVideoProblem(model, req) {
|
|
10864
|
+
return RULES.get(model.providerModelId.toLowerCase())?.(req, model);
|
|
10819
10865
|
}
|
|
10820
10866
|
function viduSilentWarning(model) {
|
|
10821
10867
|
return {
|
|
@@ -10846,7 +10892,7 @@ function fillKlingModeResolution(model, req) {
|
|
|
10846
10892
|
}
|
|
10847
10893
|
function applyFalVideoRules(model, req, callerRatio, warnings) {
|
|
10848
10894
|
if (model.adapter !== "fal" && model.adapter !== "alibaba") return;
|
|
10849
|
-
const problem = falVideoProblem(model
|
|
10895
|
+
const problem = falVideoProblem(model, withPromptForResolve(req));
|
|
10850
10896
|
if (problem !== void 0) throw ruleRefusal(model, problem.message, problem.code);
|
|
10851
10897
|
const id = model.providerModelId.toLowerCase();
|
|
10852
10898
|
const references = count(req.referenceImages) + count(req.referenceAudios);
|
|
@@ -10959,7 +11005,7 @@ function happyHorseBody(req, ctx) {
|
|
|
10959
11005
|
}
|
|
10960
11006
|
function planAlibabaVideo(req, ctx) {
|
|
10961
11007
|
const id = ctx.model.providerModelId.toLowerCase();
|
|
10962
|
-
const problem = falVideoProblem(
|
|
11008
|
+
const problem = falVideoProblem(ctx.model, req);
|
|
10963
11009
|
if (problem !== void 0) throw ruleRefusal(ctx.model, problem.message, problem.code);
|
|
10964
11010
|
if (WAN_VIDEO_IDS.has(id)) return wanBody(req, ctx);
|
|
10965
11011
|
if (id === HAPPY_HORSE_FAMILY) return happyHorseBody(req, ctx);
|
|
@@ -14256,7 +14302,7 @@ function planFalFamilyVideo(req, ctx) {
|
|
|
14256
14302
|
const id = ctx.model.providerModelId.toLowerCase();
|
|
14257
14303
|
const family = FAMILIES2.find((f) => f.ids.has(id));
|
|
14258
14304
|
if (family === void 0) return void 0;
|
|
14259
|
-
const problem = falVideoProblem(
|
|
14305
|
+
const problem = falVideoProblem(ctx.model, req);
|
|
14260
14306
|
if (problem !== void 0) throw refusal2(ctx, problem.message, problem.code);
|
|
14261
14307
|
return family.plan(req, ctx);
|
|
14262
14308
|
}
|
|
@@ -20046,6 +20092,27 @@ function resolveDuration(requested, durations, model, onUnsupported, warnings) {
|
|
|
20046
20092
|
});
|
|
20047
20093
|
return to;
|
|
20048
20094
|
}
|
|
20095
|
+
function capDurationAtResolution(seconds3, resolution, model, onUnsupported, warnings) {
|
|
20096
|
+
if (seconds3 === void 0 || resolution === void 0) return seconds3;
|
|
20097
|
+
const max = model.constraints.maxSecondsByResolution?.[resolution];
|
|
20098
|
+
if (max === void 0 || seconds3 <= max) return seconds3;
|
|
20099
|
+
const shown = resolution.endsWith("k") ? resolution.toUpperCase() : resolution;
|
|
20100
|
+
if (onUnsupported === "error") {
|
|
20101
|
+
throw new ModelKitError({
|
|
20102
|
+
code: "unsupported_option",
|
|
20103
|
+
message: `${model.id} renders at most ${max} s at ${shown}`,
|
|
20104
|
+
model: model.id
|
|
20105
|
+
});
|
|
20106
|
+
}
|
|
20107
|
+
warnings.push({
|
|
20108
|
+
code: "duration_coerced",
|
|
20109
|
+
field: "durationSeconds",
|
|
20110
|
+
from: seconds3,
|
|
20111
|
+
to: max,
|
|
20112
|
+
message: `duration ${seconds3}s coerced to ${max}s for ${model.id} at ${shown}`
|
|
20113
|
+
});
|
|
20114
|
+
return max;
|
|
20115
|
+
}
|
|
20049
20116
|
function resolveAspectRatio(requested, supported, model, onUnsupported, warnings) {
|
|
20050
20117
|
if (requested === void 0 || requested === "adaptive" || !supported) return requested;
|
|
20051
20118
|
if (supported.includes(requested)) return requested;
|
|
@@ -20365,6 +20432,14 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
|
|
|
20365
20432
|
warnings
|
|
20366
20433
|
);
|
|
20367
20434
|
if (duration !== void 0) merged.durationSeconds = duration;
|
|
20435
|
+
const capped = capDurationAtResolution(
|
|
20436
|
+
merged.durationSeconds,
|
|
20437
|
+
resolution,
|
|
20438
|
+
model,
|
|
20439
|
+
onUnsupported,
|
|
20440
|
+
warnings
|
|
20441
|
+
);
|
|
20442
|
+
if (capped !== void 0) merged.durationSeconds = capped;
|
|
20368
20443
|
const limits = c.references ?? {};
|
|
20369
20444
|
let images = trim(
|
|
20370
20445
|
"referenceImages",
|