@shop-os/modelkit 0.18.1 → 0.19.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 +54 -0
- package/dist/catalog.cjs +246 -19
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +109 -2
- package/dist/catalog.d.ts +109 -2
- package/dist/catalog.js +246 -19
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +278 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -2
- package/dist/index.d.ts +109 -2
- package/dist/index.js +275 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/catalog.js
CHANGED
|
@@ -147,6 +147,7 @@ function isListed(row2) {
|
|
|
147
147
|
var IMAGE_USAGE = { unit: "images" };
|
|
148
148
|
var EXPOSURE = ["cowork", "space_builder"];
|
|
149
149
|
var LOBE = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light";
|
|
150
|
+
var MINIMAX_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
150
151
|
var SIZED_RATIOS = [
|
|
151
152
|
"1:1",
|
|
152
153
|
"16:9",
|
|
@@ -172,6 +173,36 @@ var RECRAFT_RATIOS = [
|
|
|
172
173
|
"5:4",
|
|
173
174
|
"4:5"
|
|
174
175
|
];
|
|
176
|
+
function minimaxH3ImageRow(row2) {
|
|
177
|
+
return {
|
|
178
|
+
id: row2.id,
|
|
179
|
+
aliases: [],
|
|
180
|
+
label: row2.label,
|
|
181
|
+
type: "image",
|
|
182
|
+
adapter: "fal",
|
|
183
|
+
providerModelId: row2.providerModelId,
|
|
184
|
+
lifecycle: "active",
|
|
185
|
+
exposure: EXPOSURE,
|
|
186
|
+
constraints: {
|
|
187
|
+
aspectRatios: [...SIZED_RATIOS],
|
|
188
|
+
sizes: ["1K", "2K", "4K"],
|
|
189
|
+
references: {
|
|
190
|
+
images: 16,
|
|
191
|
+
imagePixels: { minWidth: 128, minHeight: 128, maxSide: 8192 }
|
|
192
|
+
},
|
|
193
|
+
supports: ["count", "outputFormat"],
|
|
194
|
+
prompt: { referenceSyntax: "numbered", maxChars: 32e3 }
|
|
195
|
+
},
|
|
196
|
+
defaults: { size: "2K", aspectRatio: "1:1", count: 1 },
|
|
197
|
+
usage: { ...IMAGE_USAGE },
|
|
198
|
+
pricingKind: "image_size",
|
|
199
|
+
display: {
|
|
200
|
+
provider: "minimax",
|
|
201
|
+
description: row2.description,
|
|
202
|
+
logo: MINIMAX_LOGO
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
175
206
|
var FAL_IMAGE_MODELS = [
|
|
176
207
|
{
|
|
177
208
|
// krea/v3/text-to-image; references switch to krea/v3/edit (1-8 images). Billed per
|
|
@@ -255,6 +286,22 @@ var FAL_IMAGE_MODELS = [
|
|
|
255
286
|
logo: `${LOBE}/qwen-color.png`
|
|
256
287
|
}
|
|
257
288
|
},
|
|
289
|
+
minimaxH3ImageRow({
|
|
290
|
+
// minimax/h3-image/text-to-image; references switch to minimax/h3-image/edit. Billed on
|
|
291
|
+
// tokens: $2.30/M input text, $1.50/M input image, $3.80/M output image.
|
|
292
|
+
id: "minimax-h3-image",
|
|
293
|
+
label: "MiniMax H3 Image",
|
|
294
|
+
providerModelId: "minimax/h3-image/text-to-image",
|
|
295
|
+
description: "MiniMax H3 Image text-to-image and multi-image editing with precise instruction following; takes a prompt and up to 16 reference images and outputs 1K, 2K or 4K."
|
|
296
|
+
}),
|
|
297
|
+
minimaxH3ImageRow({
|
|
298
|
+
// minimax/h3-image/highspeed/text-to-image; references switch to .../highspeed/edit.
|
|
299
|
+
// Billed on tokens: $2.30/M input text, $3.00/M input image, $7.60/M output image.
|
|
300
|
+
id: "minimax-h3-image-highspeed",
|
|
301
|
+
label: "MiniMax H3 Image Highspeed",
|
|
302
|
+
providerModelId: "minimax/h3-image/highspeed/text-to-image",
|
|
303
|
+
description: "MiniMax H3 Image Highspeed, the faster tier of H3 Image for text-to-image and multi-image editing; takes a prompt and up to 16 reference images and outputs 1K, 2K or 4K."
|
|
304
|
+
}),
|
|
258
305
|
{
|
|
259
306
|
// fal-ai/kling-image/o3/text-to-image; references switch to .../o3/image-to-image (up to
|
|
260
307
|
// 10, "@Image1".."@Image10"). $0.028 per image at 1K and 2K, double at 4K.
|
|
@@ -3753,7 +3800,7 @@ var MINIMAX_VOICES = [
|
|
|
3753
3800
|
// src/catalog/media-nodes.ts
|
|
3754
3801
|
var ELEVENLABS_LOGO2 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
3755
3802
|
var GOOGLE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
3756
|
-
var
|
|
3803
|
+
var MINIMAX_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
3757
3804
|
var SYNC_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/sync.png";
|
|
3758
3805
|
var PER_CALL3 = { unit: "images" };
|
|
3759
3806
|
var EXPOSURE5 = ["cowork", "space_builder"];
|
|
@@ -3888,7 +3935,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
3888
3935
|
pricingKind: "flat",
|
|
3889
3936
|
display: {
|
|
3890
3937
|
provider: "minimax",
|
|
3891
|
-
logo:
|
|
3938
|
+
logo: MINIMAX_LOGO2,
|
|
3892
3939
|
description: "MiniMax Speech 2.8 HD text to speech; studio-quality narration in over 300 voices, with pause and interjection tags."
|
|
3893
3940
|
},
|
|
3894
3941
|
capabilities: {}
|
|
@@ -4015,7 +4062,7 @@ var MEDIA_NODE_MODELS = [
|
|
|
4015
4062
|
pricingKind: "video_per_second",
|
|
4016
4063
|
display: {
|
|
4017
4064
|
provider: "minimax",
|
|
4018
|
-
logo:
|
|
4065
|
+
logo: MINIMAX_LOGO2,
|
|
4019
4066
|
description: "MiniMax H3 Max lip sync; animates a portrait image into a talking video as long as the speech, up to 2K."
|
|
4020
4067
|
},
|
|
4021
4068
|
capabilities: {}
|
|
@@ -4245,7 +4292,7 @@ var MODEL3D_MODELS = [
|
|
|
4245
4292
|
// src/catalog/other.ts
|
|
4246
4293
|
var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
|
|
4247
4294
|
var ELEVENLABS_LOGO3 = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/elevenlabs.png";
|
|
4248
|
-
var
|
|
4295
|
+
var MINIMAX_LOGO3 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
4249
4296
|
var OTHER_MODELS = [
|
|
4250
4297
|
{
|
|
4251
4298
|
id: "lyria-3-clip-preview",
|
|
@@ -4434,7 +4481,7 @@ var OTHER_MODELS = [
|
|
|
4434
4481
|
pricingKind: "flat",
|
|
4435
4482
|
display: {
|
|
4436
4483
|
provider: "minimax",
|
|
4437
|
-
logo:
|
|
4484
|
+
logo: MINIMAX_LOGO3,
|
|
4438
4485
|
description: "MiniMax Music 3 songs from a style prompt and your lyrics (or instrumental), up to 5 minutes."
|
|
4439
4486
|
},
|
|
4440
4487
|
capabilities: {}
|
|
@@ -4852,6 +4899,7 @@ var TEXT_MODELS = [
|
|
|
4852
4899
|
description: "Anthropic Claude Fable 5 (legacy) model for demanding reasoning and long-horizon agentic work; text and image input, 1M-token context."
|
|
4853
4900
|
},
|
|
4854
4901
|
capabilities: {
|
|
4902
|
+
reasoning: true,
|
|
4855
4903
|
vision: true,
|
|
4856
4904
|
contextWindow: 1e6
|
|
4857
4905
|
}
|
|
@@ -5131,7 +5179,7 @@ var TEXT_MODELS = [
|
|
|
5131
5179
|
var VIDEO_USAGE = { unit: "seconds" };
|
|
5132
5180
|
var MB = 1024 * 1024;
|
|
5133
5181
|
var KLING_LOGO = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png@1.97.0/light/kling-color.png";
|
|
5134
|
-
var
|
|
5182
|
+
var MINIMAX_LOGO4 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/f4c2e906-28b7-4a4a-b491-df8fef7808ed.png";
|
|
5135
5183
|
var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
|
|
5136
5184
|
var XAI_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/858b7fcc-9bd5-411d-aea1-a7b35ecfffab_compressed.png";
|
|
5137
5185
|
var H3_RATIOS = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"];
|
|
@@ -5283,7 +5331,8 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5283
5331
|
images: 10,
|
|
5284
5332
|
videos: 5,
|
|
5285
5333
|
videoSeconds: { min: 3, max: 30.05, total: 30 },
|
|
5286
|
-
videoPixels: { minWidth: 700, minHeight: 700 }
|
|
5334
|
+
videoPixels: { minWidth: 700, minHeight: 700 },
|
|
5335
|
+
videoFps: { min: 23.9, max: 60.05 }
|
|
5287
5336
|
},
|
|
5288
5337
|
supports: ["lastFrame"],
|
|
5289
5338
|
prompt: KLING_V4_PROMPT,
|
|
@@ -5449,7 +5498,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5449
5498
|
pricingKind: "video_per_second",
|
|
5450
5499
|
display: {
|
|
5451
5500
|
provider: "minimax",
|
|
5452
|
-
logo:
|
|
5501
|
+
logo: MINIMAX_LOGO4,
|
|
5453
5502
|
description: "The fast tier of MiniMax H3 Max: text-to-video and start/end-frame image-to-video with native audio and an optional soundtrack clip, up to 15 seconds at 1080p."
|
|
5454
5503
|
},
|
|
5455
5504
|
capabilities: {}
|
|
@@ -5479,7 +5528,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5479
5528
|
pricingKind: "video_per_second",
|
|
5480
5529
|
display: {
|
|
5481
5530
|
provider: "minimax",
|
|
5482
|
-
logo:
|
|
5531
|
+
logo: MINIMAX_LOGO4,
|
|
5483
5532
|
description: "MiniMax H3 Max Insert: generates a new 5-13 second scene inside an existing video from a prompt, reference images or videos, then returns to the original footage."
|
|
5484
5533
|
},
|
|
5485
5534
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5508,7 +5557,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5508
5557
|
pricingKind: "video_per_second",
|
|
5509
5558
|
display: {
|
|
5510
5559
|
provider: "minimax",
|
|
5511
|
-
logo:
|
|
5560
|
+
logo: MINIMAX_LOGO4,
|
|
5512
5561
|
description: "MiniMax H3 Max Recast: replaces the people in a 5-30 second video with up to 4 reference photos, keeping the motion, camera, cuts and soundtrack."
|
|
5513
5562
|
},
|
|
5514
5563
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5539,7 +5588,7 @@ var VIDEO_FAMILY_MODELS = [
|
|
|
5539
5588
|
pricingKind: "video_per_second",
|
|
5540
5589
|
display: {
|
|
5541
5590
|
provider: "minimax",
|
|
5542
|
-
logo:
|
|
5591
|
+
logo: MINIMAX_LOGO4,
|
|
5543
5592
|
description: "MiniMax H3 Max Relight: relights a video of up to 15 seconds from a lighting sphere image, keeping the subjects, motion, camera and audio."
|
|
5544
5593
|
},
|
|
5545
5594
|
capabilities: { acceptsSourceVideo: true, videoEdit: true }
|
|
@@ -5851,6 +5900,11 @@ var SEEDANCE_2_AUDIO = {
|
|
|
5851
5900
|
audioFormats: ["wav", "mp3"],
|
|
5852
5901
|
audioMaxBytes: 15 * 1024 * 1024
|
|
5853
5902
|
};
|
|
5903
|
+
var SEEDANCE_REFERENCE_MEDIA = {
|
|
5904
|
+
videoPixels: { minPixels: 407696, maxPixels: 8295044 },
|
|
5905
|
+
videoFps: { min: 23.8, max: 60 },
|
|
5906
|
+
imagePixels: { minPixels: 9e4 }
|
|
5907
|
+
};
|
|
5854
5908
|
var H3_PROMPT2 = { referenceSyntax: "numbered", maxChars: 5e4 };
|
|
5855
5909
|
var WAN_PROMPT = { referenceSyntax: "numbered", maxChars: 2e4 };
|
|
5856
5910
|
var OMNI_PROMPT = { referenceSyntax: "caption", maxChars: 5e4 };
|
|
@@ -6095,6 +6149,7 @@ var VIDEO_MODELS = [
|
|
|
6095
6149
|
audios: 3,
|
|
6096
6150
|
audioOnly: false,
|
|
6097
6151
|
videoSeconds: { min: 2, max: 15, total: 15 },
|
|
6152
|
+
...SEEDANCE_REFERENCE_MEDIA,
|
|
6098
6153
|
...SEEDANCE_2_AUDIO
|
|
6099
6154
|
},
|
|
6100
6155
|
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
@@ -6138,6 +6193,7 @@ var VIDEO_MODELS = [
|
|
|
6138
6193
|
audios: 3,
|
|
6139
6194
|
audioOnly: false,
|
|
6140
6195
|
videoSeconds: { min: 2, max: 15, total: 15 },
|
|
6196
|
+
...SEEDANCE_REFERENCE_MEDIA,
|
|
6141
6197
|
...SEEDANCE_2_AUDIO
|
|
6142
6198
|
},
|
|
6143
6199
|
sourceVideoSeconds: { min: 2, max: 15, inReferenceTotal: true },
|
|
@@ -6181,6 +6237,7 @@ var VIDEO_MODELS = [
|
|
|
6181
6237
|
videos: 10,
|
|
6182
6238
|
audios: 10,
|
|
6183
6239
|
videoSeconds: { min: 2, max: 30, total: 30, editMin: 4 },
|
|
6240
|
+
...SEEDANCE_REFERENCE_MEDIA,
|
|
6184
6241
|
// BytePlus: 2-30 s per clip, 30 s in all, wav/mp3, 15 MB each.
|
|
6185
6242
|
audioSeconds: { min: 2, max: 30, total: 30 },
|
|
6186
6243
|
audioFormats: ["wav", "mp3"],
|
|
@@ -6329,7 +6386,12 @@ var VIDEO_MODELS = [
|
|
|
6329
6386
|
prompt: KLING_PROMPT2,
|
|
6330
6387
|
audio: "optional"
|
|
6331
6388
|
},
|
|
6332
|
-
defaults: {
|
|
6389
|
+
defaults: {
|
|
6390
|
+
durationSeconds: 5,
|
|
6391
|
+
aspectRatio: "16:9",
|
|
6392
|
+
generateAudio: true,
|
|
6393
|
+
mode: "standard"
|
|
6394
|
+
},
|
|
6333
6395
|
usage: { ...VIDEO_USAGE3 },
|
|
6334
6396
|
pricingKind: "video_per_second",
|
|
6335
6397
|
display: {
|
|
@@ -8000,7 +8062,14 @@ var VideoSecondsLimitsSchema = z3.looseObject({
|
|
|
8000
8062
|
});
|
|
8001
8063
|
var VideoPixelLimitsSchema = z3.looseObject({
|
|
8002
8064
|
minWidth: z3.number().int().positive().optional(),
|
|
8003
|
-
minHeight: z3.number().int().positive().optional()
|
|
8065
|
+
minHeight: z3.number().int().positive().optional(),
|
|
8066
|
+
minPixels: z3.number().int().positive().optional(),
|
|
8067
|
+
maxPixels: z3.number().int().positive().optional(),
|
|
8068
|
+
maxSide: z3.number().int().positive().optional()
|
|
8069
|
+
});
|
|
8070
|
+
var VideoFpsLimitsSchema = z3.looseObject({
|
|
8071
|
+
min: z3.number().positive().optional(),
|
|
8072
|
+
max: z3.number().positive().optional()
|
|
8004
8073
|
});
|
|
8005
8074
|
var ReferenceLimitsSchema = z3.looseObject({
|
|
8006
8075
|
images: z3.number().optional(),
|
|
@@ -8011,6 +8080,13 @@ var ReferenceLimitsSchema = z3.looseObject({
|
|
|
8011
8080
|
audioOnly: z3.boolean().optional(),
|
|
8012
8081
|
videoSeconds: VideoSecondsLimitsSchema.optional(),
|
|
8013
8082
|
videoPixels: VideoPixelLimitsSchema.optional(),
|
|
8083
|
+
videoFps: VideoFpsLimitsSchema.optional(),
|
|
8084
|
+
videoMaxBytes: z3.number().positive().optional(),
|
|
8085
|
+
imagePixels: VideoPixelLimitsSchema.optional(),
|
|
8086
|
+
imageAspect: z3.looseObject({
|
|
8087
|
+
min: z3.number().positive().optional(),
|
|
8088
|
+
max: z3.number().positive().optional()
|
|
8089
|
+
}).optional(),
|
|
8014
8090
|
audioSeconds: z3.looseObject({
|
|
8015
8091
|
min: z3.number().optional(),
|
|
8016
8092
|
max: z3.number().optional(),
|
|
@@ -8993,9 +9069,6 @@ function applyImageOutputRules(model, req, onUnsupported, warnings) {
|
|
|
8993
9069
|
}
|
|
8994
9070
|
if (req.outputFormat === "svg") {
|
|
8995
9071
|
if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
|
|
8996
|
-
if ((req.references ?? []).length > 0) {
|
|
8997
|
-
refuse(model, `${model.label} cannot make an SVG from reference images`);
|
|
8998
|
-
}
|
|
8999
9072
|
if ((req.count ?? 1) > 1) {
|
|
9000
9073
|
if (onUnsupported === "error") {
|
|
9001
9074
|
refuse(model, `${model.label} makes one SVG per call`);
|
|
@@ -9130,6 +9203,27 @@ var QWEN_EXACT = {
|
|
|
9130
9203
|
maxArea: 2048 * 2048,
|
|
9131
9204
|
multipleOf: 1
|
|
9132
9205
|
};
|
|
9206
|
+
var MINIMAX_H3_IMAGE_EXACT = {
|
|
9207
|
+
minSide: 1,
|
|
9208
|
+
maxSide: 14142,
|
|
9209
|
+
minArea: 655360,
|
|
9210
|
+
maxArea: 4096 * 4096,
|
|
9211
|
+
multipleOf: 1,
|
|
9212
|
+
maxAspect: 3,
|
|
9213
|
+
topTier: "4K"
|
|
9214
|
+
};
|
|
9215
|
+
function minimaxH3ImageSpec(label) {
|
|
9216
|
+
return {
|
|
9217
|
+
label,
|
|
9218
|
+
maxReferences: 16,
|
|
9219
|
+
maxCount: 10,
|
|
9220
|
+
outputFormats: ALL_FORMATS,
|
|
9221
|
+
promptMax: 32e3,
|
|
9222
|
+
promptRequired: true,
|
|
9223
|
+
aspectRatios: WIDE_RATIOS,
|
|
9224
|
+
exactSize: MINIMAX_H3_IMAGE_EXACT
|
|
9225
|
+
};
|
|
9226
|
+
}
|
|
9133
9227
|
var FAL_IMAGE_SPECS = /* @__PURE__ */ new Map([
|
|
9134
9228
|
[
|
|
9135
9229
|
"krea/v3/text-to-image",
|
|
@@ -9171,6 +9265,8 @@ var FAL_IMAGE_SPECS = /* @__PURE__ */ new Map([
|
|
|
9171
9265
|
exactSize: QWEN_EXACT
|
|
9172
9266
|
}
|
|
9173
9267
|
],
|
|
9268
|
+
["minimax/h3-image/text-to-image", minimaxH3ImageSpec("MiniMax H3 Image")],
|
|
9269
|
+
["minimax/h3-image/highspeed/text-to-image", minimaxH3ImageSpec("MiniMax H3 Image Highspeed")],
|
|
9174
9270
|
[
|
|
9175
9271
|
"fal-ai/kling-image/o3/text-to-image",
|
|
9176
9272
|
{
|
|
@@ -9234,6 +9330,7 @@ function falImageSpec(providerModelId) {
|
|
|
9234
9330
|
return FAL_IMAGE_SPECS.get(providerModelId.toLowerCase());
|
|
9235
9331
|
}
|
|
9236
9332
|
var AREA_1K = 1024 * 1024;
|
|
9333
|
+
var AREA_2K = 2048 * 2048;
|
|
9237
9334
|
function checkExactSize(exact, b) {
|
|
9238
9335
|
const match = /^(\d+)x(\d+)$/.exec(exact);
|
|
9239
9336
|
if (match === null) {
|
|
@@ -9245,14 +9342,21 @@ function checkExactSize(exact, b) {
|
|
|
9245
9342
|
const sideOk = [width, height].every(
|
|
9246
9343
|
(side) => side >= b.minSide && side <= b.maxSide && side % b.multipleOf === 0
|
|
9247
9344
|
);
|
|
9248
|
-
|
|
9345
|
+
const aspectOk = b.maxAspect === void 0 || Math.max(width, height) <= b.maxAspect * Math.min(width, height);
|
|
9346
|
+
if (!sideOk || !aspectOk || area < b.minArea || area > b.maxArea) {
|
|
9249
9347
|
const step = b.multipleOf > 1 ? `, multiples of ${b.multipleOf}` : "";
|
|
9348
|
+
const aspectLimit = b.maxAspect === void 0 ? "" : `, at most ${b.maxAspect}:1,`;
|
|
9250
9349
|
return {
|
|
9251
9350
|
ok: false,
|
|
9252
|
-
message: `takes an exactSize with sides of ${b.minSide} to ${b.maxSide} px${step} and ${b.minArea} to ${b.maxArea} px in total; got ${exact}`
|
|
9351
|
+
message: `takes an exactSize with sides of ${b.minSide} to ${b.maxSide} px${step}${aspectLimit} and ${b.minArea} to ${b.maxArea} px in total; got ${exact}`
|
|
9253
9352
|
};
|
|
9254
9353
|
}
|
|
9255
|
-
return { ok: true, size: { width, height, tier: area
|
|
9354
|
+
return { ok: true, size: { width, height, tier: exactTier(area, b) } };
|
|
9355
|
+
}
|
|
9356
|
+
function exactTier(area, b) {
|
|
9357
|
+
if (area <= AREA_1K) return "1K";
|
|
9358
|
+
if (b.topTier === void 0 || area <= AREA_2K) return "2K";
|
|
9359
|
+
return b.topTier;
|
|
9256
9360
|
}
|
|
9257
9361
|
function unsupported(message) {
|
|
9258
9362
|
return { code: "unsupported_option", message };
|
|
@@ -10653,6 +10757,126 @@ function resolveOptions(model, call, onUnsupported = "error") {
|
|
|
10653
10757
|
return { method: call.method, ...resolveVideoToolCall(model, call.request) };
|
|
10654
10758
|
}
|
|
10655
10759
|
}
|
|
10760
|
+
|
|
10761
|
+
// src/reference-video-conform.ts
|
|
10762
|
+
var REFERENCE_VIDEO_CONFORM_PROFILE = "model-safe-v1";
|
|
10763
|
+
var SHRINK_MARGIN = 0.998;
|
|
10764
|
+
var GROW_MARGIN = 1.002;
|
|
10765
|
+
var LOW_FPS_TARGET = 24;
|
|
10766
|
+
var HIGH_FPS_TARGET = 30;
|
|
10767
|
+
function measured(value) {
|
|
10768
|
+
return value !== void 0 && Number.isFinite(value) && value > 0;
|
|
10769
|
+
}
|
|
10770
|
+
function evenDown(value) {
|
|
10771
|
+
return Math.max(2, Math.floor(value / 2) * 2);
|
|
10772
|
+
}
|
|
10773
|
+
function evenUp(value) {
|
|
10774
|
+
return Math.max(2, Math.ceil(value / 2) * 2);
|
|
10775
|
+
}
|
|
10776
|
+
function sizeFix(limits, width, height) {
|
|
10777
|
+
if (!limits) return null;
|
|
10778
|
+
const pixels = width * height;
|
|
10779
|
+
const long = Math.max(width, height);
|
|
10780
|
+
const shrink = [];
|
|
10781
|
+
const grow = [];
|
|
10782
|
+
const reasons = [];
|
|
10783
|
+
if (limits.maxPixels !== void 0 && pixels > limits.maxPixels) {
|
|
10784
|
+
shrink.push(Math.sqrt(limits.maxPixels / pixels) * SHRINK_MARGIN);
|
|
10785
|
+
reasons.push("pixels_over");
|
|
10786
|
+
}
|
|
10787
|
+
if (limits.maxSide !== void 0 && long > limits.maxSide) {
|
|
10788
|
+
shrink.push(limits.maxSide / long * SHRINK_MARGIN);
|
|
10789
|
+
reasons.push("side_over");
|
|
10790
|
+
}
|
|
10791
|
+
if (shrink.length > 0) return { scale: Math.min(...shrink), up: false, reasons };
|
|
10792
|
+
if (limits.minPixels !== void 0 && pixels < limits.minPixels) {
|
|
10793
|
+
grow.push(Math.sqrt(limits.minPixels / pixels) * GROW_MARGIN);
|
|
10794
|
+
reasons.push("pixels_under");
|
|
10795
|
+
}
|
|
10796
|
+
const sideUnder = [
|
|
10797
|
+
limits.minWidth !== void 0 && width < limits.minWidth ? limits.minWidth / width * GROW_MARGIN : 0,
|
|
10798
|
+
limits.minHeight !== void 0 && height < limits.minHeight ? limits.minHeight / height * GROW_MARGIN : 0
|
|
10799
|
+
].filter((scale) => scale > 0);
|
|
10800
|
+
if (sideUnder.length > 0) {
|
|
10801
|
+
grow.push(...sideUnder);
|
|
10802
|
+
reasons.push("side_under");
|
|
10803
|
+
}
|
|
10804
|
+
if (grow.length > 0) return { scale: Math.max(...grow), up: true, reasons };
|
|
10805
|
+
return null;
|
|
10806
|
+
}
|
|
10807
|
+
function fpsFix(model, fps) {
|
|
10808
|
+
const limits = model.constraints.references?.videoFps;
|
|
10809
|
+
if (!limits || !measured(fps)) return void 0;
|
|
10810
|
+
const inRange = (rate) => (limits.min === void 0 || rate >= limits.min) && (limits.max === void 0 || rate <= limits.max);
|
|
10811
|
+
if (limits.min !== void 0 && fps < limits.min) {
|
|
10812
|
+
const target = inRange(LOW_FPS_TARGET) ? LOW_FPS_TARGET : Math.ceil(limits.min);
|
|
10813
|
+
return { fps: target, reason: "fps_under" };
|
|
10814
|
+
}
|
|
10815
|
+
if (limits.max !== void 0 && fps > limits.max) {
|
|
10816
|
+
const target = inRange(HIGH_FPS_TARGET) ? HIGH_FPS_TARGET : Math.floor(limits.max);
|
|
10817
|
+
return { fps: target, reason: "fps_over" };
|
|
10818
|
+
}
|
|
10819
|
+
return void 0;
|
|
10820
|
+
}
|
|
10821
|
+
function referenceVideoConformPlan(model, probe) {
|
|
10822
|
+
const rate = fpsFix(model, probe.fps);
|
|
10823
|
+
const maxBytes = model.constraints.references?.videoMaxBytes;
|
|
10824
|
+
const overBytes = maxBytes !== void 0 && measured(probe.bytes) && probe.bytes > maxBytes;
|
|
10825
|
+
const { width: probedWidth, height: probedHeight } = probe;
|
|
10826
|
+
if (!measured(probedWidth) || !measured(probedHeight)) return null;
|
|
10827
|
+
const width = Math.round(probedWidth);
|
|
10828
|
+
const height = Math.round(probedHeight);
|
|
10829
|
+
const size = sizeFix(model.constraints.references?.videoPixels, width, height);
|
|
10830
|
+
if (!size && !rate && !overBytes) return null;
|
|
10831
|
+
const round = size?.up ? evenUp : evenDown;
|
|
10832
|
+
const scale = size?.scale ?? 1;
|
|
10833
|
+
const reasons = [...size?.reasons ?? []];
|
|
10834
|
+
if (rate) reasons.push(rate.reason);
|
|
10835
|
+
if (overBytes) reasons.push("bytes_over");
|
|
10836
|
+
const plan = {
|
|
10837
|
+
width: round(width * scale),
|
|
10838
|
+
height: round(height * scale),
|
|
10839
|
+
reasons
|
|
10840
|
+
};
|
|
10841
|
+
if (rate) plan.fps = rate.fps;
|
|
10842
|
+
if (maxBytes !== void 0) plan.maxBytes = maxBytes;
|
|
10843
|
+
return plan;
|
|
10844
|
+
}
|
|
10845
|
+
function referenceImageConformPlan(model, probe) {
|
|
10846
|
+
const { width: probedWidth, height: probedHeight } = probe;
|
|
10847
|
+
if (!measured(probedWidth) || !measured(probedHeight)) return null;
|
|
10848
|
+
const references = model.constraints.references;
|
|
10849
|
+
const width = Math.round(probedWidth);
|
|
10850
|
+
const height = Math.round(probedHeight);
|
|
10851
|
+
const reasons = [];
|
|
10852
|
+
let frameWidth = width;
|
|
10853
|
+
let frameHeight = height;
|
|
10854
|
+
const aspect = references?.imageAspect;
|
|
10855
|
+
if (aspect?.min !== void 0 && width / height < aspect.min) {
|
|
10856
|
+
frameWidth = Math.ceil(height * aspect.min);
|
|
10857
|
+
reasons.push("aspect");
|
|
10858
|
+
} else if (aspect?.max !== void 0 && width / height > aspect.max) {
|
|
10859
|
+
frameHeight = Math.ceil(width / aspect.max);
|
|
10860
|
+
reasons.push("aspect");
|
|
10861
|
+
}
|
|
10862
|
+
const size = sizeFix(references?.imagePixels, frameWidth, frameHeight);
|
|
10863
|
+
if (!size && reasons.length === 0) return null;
|
|
10864
|
+
if (size) reasons.push(...size.reasons);
|
|
10865
|
+
const scale = size?.scale ?? 1;
|
|
10866
|
+
const round = size?.up ? Math.ceil : Math.floor;
|
|
10867
|
+
const frame = {
|
|
10868
|
+
width: Math.max(1, round(frameWidth * scale)),
|
|
10869
|
+
height: Math.max(1, round(frameHeight * scale))
|
|
10870
|
+
};
|
|
10871
|
+
const image = frameWidth > width ? {
|
|
10872
|
+
width: Math.max(1, Math.round(frame.height * width / height)),
|
|
10873
|
+
height: frame.height
|
|
10874
|
+
} : frameHeight > height ? {
|
|
10875
|
+
width: frame.width,
|
|
10876
|
+
height: Math.max(1, Math.round(frame.width * height / width))
|
|
10877
|
+
} : { ...frame };
|
|
10878
|
+
return { ...frame, image, reasons };
|
|
10879
|
+
}
|
|
10656
10880
|
export {
|
|
10657
10881
|
ADAPTER_IDS,
|
|
10658
10882
|
AUDIO_OUTPUTS,
|
|
@@ -10670,6 +10894,7 @@ export {
|
|
|
10670
10894
|
ModelKitError,
|
|
10671
10895
|
OTHER_MODELS,
|
|
10672
10896
|
REFERENCE_SYNTAXES,
|
|
10897
|
+
REFERENCE_VIDEO_CONFORM_PROFILE,
|
|
10673
10898
|
SURFACES2 as SURFACES,
|
|
10674
10899
|
SurfaceSchema,
|
|
10675
10900
|
TEXT_MODELS,
|
|
@@ -10697,6 +10922,8 @@ export {
|
|
|
10697
10922
|
planVideoTool,
|
|
10698
10923
|
primeCatalog,
|
|
10699
10924
|
promptConventions,
|
|
10925
|
+
referenceImageConformPlan,
|
|
10926
|
+
referenceVideoConformPlan,
|
|
10700
10927
|
resetLiveCatalog,
|
|
10701
10928
|
resolutionTier,
|
|
10702
10929
|
resolveAudioOptions,
|