@shop-os/modelkit 0.2.21 → 0.2.23

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.
@@ -942,6 +942,17 @@ declare const REFERENCE_SYNTAXES: ("numbered" | "caption" | "descriptive")[];
942
942
  declare function outputAudio(row: {
943
943
  constraints: unknown;
944
944
  }): AudioOutput | undefined;
945
+ /**
946
+ * Whether a video request is billed as having sound. `always` rows are true and `never` rows
947
+ * false; an `optional` row takes the request's `generateAudio`, then the row's default, then
948
+ * true. A row with no declared audio is true. Every fallback is true because the base video
949
+ * price is the sound-on price: a guess must never pick the cheaper silent rate. Pass the same
950
+ * `requested` value the request dispatches with, so the billed and generated sound agree.
951
+ */
952
+ declare function billedAudio(row: {
953
+ constraints: unknown;
954
+ defaults?: unknown;
955
+ }, requested?: boolean): boolean;
945
956
  declare function promptConventions(row: {
946
957
  constraints: unknown;
947
958
  }): PromptConventions;
@@ -981,4 +992,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
981
992
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
982
993
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
983
994
 
984
- export { ADAPTER_IDS, AUDIO_OUTPUTS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, REFERENCE_SYNTAXES, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, outputAudio, primeCatalog, promptConventions, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
995
+ export { ADAPTER_IDS, AUDIO_OUTPUTS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, REFERENCE_SYNTAXES, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, billedAudio, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, outputAudio, primeCatalog, promptConventions, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
package/dist/catalog.d.ts CHANGED
@@ -942,6 +942,17 @@ declare const REFERENCE_SYNTAXES: ("numbered" | "caption" | "descriptive")[];
942
942
  declare function outputAudio(row: {
943
943
  constraints: unknown;
944
944
  }): AudioOutput | undefined;
945
+ /**
946
+ * Whether a video request is billed as having sound. `always` rows are true and `never` rows
947
+ * false; an `optional` row takes the request's `generateAudio`, then the row's default, then
948
+ * true. A row with no declared audio is true. Every fallback is true because the base video
949
+ * price is the sound-on price: a guess must never pick the cheaper silent rate. Pass the same
950
+ * `requested` value the request dispatches with, so the billed and generated sound agree.
951
+ */
952
+ declare function billedAudio(row: {
953
+ constraints: unknown;
954
+ defaults?: unknown;
955
+ }, requested?: boolean): boolean;
945
956
  declare function promptConventions(row: {
946
957
  constraints: unknown;
947
958
  }): PromptConventions;
@@ -981,4 +992,4 @@ declare function isModelKitError(err: unknown): err is ModelKitError;
981
992
  /** Resolve caller options against a catalog row, dispatching on `model.type`. */
982
993
  declare function resolveOptions(model: CatalogModel, request: ImageRequest | VideoRequest | AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<ImageRequest | VideoRequest | AudioRequest>;
983
994
 
984
- export { ADAPTER_IDS, AUDIO_OUTPUTS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, REFERENCE_SYNTAXES, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, outputAudio, primeCatalog, promptConventions, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
995
+ export { ADAPTER_IDS, AUDIO_OUTPUTS, type AdapterEndpoints, type AdapterId, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type Exposure, ExposureSchema, type GeneratedImage, IMAGE_MODELS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, type JsonPrimitive, type JsonValue, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, OTHER_MODELS, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, REFERENCE_SYNTAXES, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, TEXT_MODELS, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type Warning, billedAudio, compareCatalogOrder, hasAwsCredentials, isListed, isListedOn, isModelKitError, liveCatalog, liveState, nearestAspectRatio, normalizeExposure, outputAudio, primeCatalog, promptConventions, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveOptions, resolveVideoOptions, sortCatalogRows, videoLengthViolation };
package/dist/catalog.js CHANGED
@@ -158,13 +158,16 @@ var GEMINI_RATIOS = [
158
158
  "5:4",
159
159
  "adaptive"
160
160
  ];
161
- function geminiImage(id, label, aliases, sizes, display, exposure, references) {
161
+ var GEMINI_PROMPT_MAX_CHARS = 5e4;
162
+ var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
163
+ function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars) {
164
+ const prompt = { referenceSyntax: "caption" };
165
+ if (promptMaxChars !== void 0) prompt.maxChars = promptMaxChars;
162
166
  const constraints = {
163
167
  aspectRatios: [...GEMINI_RATIOS],
164
168
  sizes,
165
169
  supports: ["safetySettings", "temperature"],
166
- // google-image sends MediaRef.label as a text part beside each reference.
167
- prompt: { referenceSyntax: "caption" }
170
+ prompt
168
171
  };
169
172
  if (references !== void 0) constraints.references = references;
170
173
  const model = {
@@ -196,7 +199,8 @@ var IMAGE_MODELS = [
196
199
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
197
200
  },
198
201
  ["cowork", "space_builder"],
199
- { images: 14 }
202
+ { images: 14 },
203
+ GEMINI_PROMPT_MAX_CHARS
200
204
  ),
201
205
  geminiImage(
202
206
  "gemini-3.1-flash-image-preview",
@@ -210,7 +214,8 @@ var IMAGE_MODELS = [
210
214
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
211
215
  },
212
216
  ["cowork", "space_builder"],
213
- { images: 14 }
217
+ { images: 14 },
218
+ GEMINI_PROMPT_MAX_CHARS
214
219
  ),
215
220
  geminiImage(
216
221
  "gemini-3.1-flash-lite-image",
@@ -223,7 +228,8 @@ var IMAGE_MODELS = [
223
228
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
224
229
  },
225
230
  ["cowork", "space_builder"],
226
- { images: 14 }
231
+ { images: 14 },
232
+ GEMINI_PROMPT_MAX_CHARS
227
233
  ),
228
234
  // trigger-workflows validates 1K only; pricing seeds 2K/4K rows so allow all three.
229
235
  geminiImage(
@@ -261,7 +267,8 @@ var IMAGE_MODELS = [
261
267
  sizes: ["1K", "2K", "4K"],
262
268
  qualityOptions: ["auto", "low", "medium", "high"],
263
269
  references: { images: 16 },
264
- supports: ["quality", "count", "outputFormat"]
270
+ supports: ["quality", "count", "outputFormat"],
271
+ prompt: GPT_IMAGE_PROMPT
265
272
  },
266
273
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
267
274
  usage: { ...IMAGE_USAGE, slug: "gpt" },
@@ -296,7 +303,8 @@ var IMAGE_MODELS = [
296
303
  sizes: ["1K", "2K", "4K"],
297
304
  qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
298
305
  references: { images: 16 },
299
- supports: ["quality", "count", "outputFormat"]
306
+ supports: ["quality", "count", "outputFormat"],
307
+ prompt: GPT_IMAGE_PROMPT
300
308
  },
301
309
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
302
310
  usage: { ...IMAGE_USAGE },
@@ -330,7 +338,8 @@ var IMAGE_MODELS = [
330
338
  sizes: ["1K", "2K", "4K"],
331
339
  qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
332
340
  references: { images: 16 },
333
- supports: ["quality", "count", "outputFormat"]
341
+ supports: ["quality", "count", "outputFormat"],
342
+ prompt: GPT_IMAGE_PROMPT
334
343
  },
335
344
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
336
345
  usage: { ...IMAGE_USAGE },
@@ -453,7 +462,9 @@ var IMAGE_MODELS = [
453
462
  sizes: ["1K"],
454
463
  references: { images: 8 },
455
464
  // flux-2-pro's job type always returns image/png; only the seed is forwarded.
456
- supports: ["seed"]
465
+ supports: ["seed"],
466
+ // Prodia's flux-2-pro schema gives the prompt a maxLength of 32,768.
467
+ prompt: { referenceSyntax: "numbered", maxChars: 32768 }
457
468
  },
458
469
  defaults: { size: "1K", aspectRatio: "1:1" },
459
470
  usage: { ...IMAGE_USAGE },
@@ -1255,6 +1266,9 @@ var H3_REFERENCE_RATIOS = ["adaptive", ...H3_RATIOS];
1255
1266
  var NEGATIVE_PROMPT = "blur, distort, and low quality";
1256
1267
  var FRAMES_EXCLUDE_REFERENCES = { framesExcludeReferences: true };
1257
1268
  var KLING_PROMPT = { referenceSyntax: "numbered", maxChars: 2500 };
1269
+ var SEEDANCE_PROMPT = { referenceSyntax: "numbered", maxChars: 3e4 };
1270
+ var H3_PROMPT = { referenceSyntax: "numbered", maxChars: 5e4 };
1271
+ var OMNI_PROMPT = { referenceSyntax: "caption", maxChars: 5e4 };
1258
1272
  var BYTEDANCE_LOGO = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/3bba5d81-4e57-4e71-911b-cdfa05acca2c_compressed.png";
1259
1273
  var GOOGLE_LOGO2 = "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png";
1260
1274
  var VIDEO_MODELS = [
@@ -1378,8 +1392,7 @@ var VIDEO_MODELS = [
1378
1392
  references: { images: 6, videos: 1, videoSeconds: { max: 10 } },
1379
1393
  sourceVideoSeconds: { max: 10 },
1380
1394
  supports: [],
1381
- // generateOmniVideo sends MediaRef.label as a text part beside each image.
1382
- prompt: { referenceSyntax: "caption" },
1395
+ prompt: OMNI_PROMPT,
1383
1396
  audio: "always"
1384
1397
  },
1385
1398
  defaults: {},
@@ -1416,8 +1429,7 @@ var VIDEO_MODELS = [
1416
1429
  // First-to-last-frame interpolation: `<LAST_FRAME>` goes with `<FIRST_FRAME>`.
1417
1430
  supports: ["videoExtension", "lastFrame"],
1418
1431
  extension: { segmentSeconds: 10, maxTotalSeconds: 40 },
1419
- // generateOmniVideo sends MediaRef.label as a text part beside each image.
1420
- prompt: { referenceSyntax: "caption" },
1432
+ prompt: OMNI_PROMPT,
1421
1433
  audio: "always"
1422
1434
  },
1423
1435
  defaults: {},
@@ -1456,6 +1468,7 @@ var VIDEO_MODELS = [
1456
1468
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1457
1469
  // No seed: 2.x echoes it but does not honour it (two seeded runs differed, 2026-10-01).
1458
1470
  supports: ["generateAudio", "lastFrame", "watermark"],
1471
+ prompt: SEEDANCE_PROMPT,
1459
1472
  audio: "optional"
1460
1473
  },
1461
1474
  defaults: {
@@ -1497,6 +1510,7 @@ var VIDEO_MODELS = [
1497
1510
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1498
1511
  // No seed: 2.x echoes it but does not honour it (two seeded runs differed, 2026-10-01).
1499
1512
  supports: ["generateAudio", "lastFrame", "watermark"],
1513
+ prompt: SEEDANCE_PROMPT,
1500
1514
  audio: "optional"
1501
1515
  },
1502
1516
  defaults: {
@@ -1538,6 +1552,7 @@ var VIDEO_MODELS = [
1538
1552
  ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1539
1553
  // No seed: 2.x echoes it but does not honour it (two seeded runs differed, 2026-10-01).
1540
1554
  supports: ["generateAudio", "lastFrame", "watermark", "taskType"],
1555
+ prompt: SEEDANCE_PROMPT,
1541
1556
  audio: "optional"
1542
1557
  },
1543
1558
  defaults: {
@@ -1699,6 +1714,7 @@ var VIDEO_MODELS = [
1699
1714
  // fal's image-to-video endpoint has no aspect_ratio; the frame sets it.
1700
1715
  ratioIgnoredWith: ["firstFrame"],
1701
1716
  supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
1717
+ prompt: H3_PROMPT,
1702
1718
  audio: "always"
1703
1719
  },
1704
1720
  defaults: {
@@ -1732,6 +1748,7 @@ var VIDEO_MODELS = [
1732
1748
  // fal's image-to-video endpoint has no aspect_ratio; the frame sets it.
1733
1749
  ratioIgnoredWith: ["firstFrame"],
1734
1750
  supports: ["seed", "promptExpansion", "lastFrame", "safetyChecker"],
1751
+ prompt: H3_PROMPT,
1735
1752
  audio: "always"
1736
1753
  },
1737
1754
  defaults: {
@@ -1773,6 +1790,7 @@ var VIDEO_MODELS = [
1773
1790
  videoSeconds: { min: 2, max: 15, total: 15 }
1774
1791
  },
1775
1792
  supports: ["seed", "promptExpansion", "safetyChecker"],
1793
+ prompt: H3_PROMPT,
1776
1794
  audio: "always"
1777
1795
  },
1778
1796
  defaults: {
@@ -1816,6 +1834,7 @@ var VIDEO_MODELS = [
1816
1834
  videoSeconds: { min: 2, max: 15, total: 15 }
1817
1835
  },
1818
1836
  supports: ["seed", "promptExpansion", "safetyChecker"],
1837
+ prompt: H3_PROMPT,
1819
1838
  audio: "always"
1820
1839
  },
1821
1840
  defaults: {
@@ -1992,6 +2011,17 @@ function outputAudio(row) {
1992
2011
  const view = ConstraintsReadView.safeParse(row.constraints);
1993
2012
  return view.success ? view.data.audio : void 0;
1994
2013
  }
2014
+ var DefaultsReadView = z.looseObject({
2015
+ generateAudio: z.boolean().optional().catch(void 0)
2016
+ });
2017
+ function billedAudio(row, requested) {
2018
+ const audio = outputAudio(row);
2019
+ if (audio === "never") return false;
2020
+ if (audio !== "optional") return true;
2021
+ if (requested !== void 0) return requested;
2022
+ const defaults = DefaultsReadView.safeParse(row.defaults);
2023
+ return (defaults.success ? defaults.data.generateAudio : void 0) ?? true;
2024
+ }
1995
2025
  function promptConventions(row) {
1996
2026
  const view = ConstraintsReadView.safeParse(row.constraints);
1997
2027
  const prompt = view.success ? view.data.prompt : void 0;
@@ -3198,6 +3228,7 @@ export {
3198
3228
  SurfaceSchema,
3199
3229
  TEXT_MODELS,
3200
3230
  VIDEO_MODELS,
3231
+ billedAudio,
3201
3232
  compareCatalogOrder,
3202
3233
  isListed,
3203
3234
  isListedOn,