@shop-os/modelkit 0.17.0 → 0.18.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/dist/index.js CHANGED
@@ -450,6 +450,25 @@ var NANO_BANANA_2_1_RATIOS = [
450
450
  "adaptive"
451
451
  ];
452
452
  var GEMINI_PROMPT_MAX_CHARS = 5e4;
453
+ var GPT_IMAGE_2_6_ANIMATION = {
454
+ frameSizes: [
455
+ { size: "288x288", minFrames: 2, maxFrames: 16 },
456
+ { size: "384x384", minFrames: 2, maxFrames: 16 },
457
+ { size: "512x288", minFrames: 2, maxFrames: 16 },
458
+ { size: "288x512", minFrames: 2, maxFrames: 16 },
459
+ { size: "512x512", minFrames: 2, maxFrames: 16 },
460
+ { size: "768x768", minFrames: 2, maxFrames: 12 }
461
+ ],
462
+ frameDurationMs: { min: 20, max: 2e3 },
463
+ defaultFrameCount: 9,
464
+ defaultFrameDurationMs: 200
465
+ };
466
+ var GPT_IMAGE_2_6_OUTPUT = {
467
+ imageFormats: ["png", "gif", "svg"],
468
+ backgrounds: ["auto", "opaque", "transparent"],
469
+ animation: GPT_IMAGE_2_6_ANIMATION,
470
+ svgModel: "gpt-6.1-sol"
471
+ };
453
472
  var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
454
473
  function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars, aspectRatios = GEMINI_RATIOS) {
455
474
  const prompt = { referenceSyntax: "caption" };
@@ -593,6 +612,78 @@ var IMAGE_MODELS = [
593
612
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/1204b494-8962-4f7f-af5e-699a8bdc98e3_compressed.png"
594
613
  }
595
614
  },
615
+ {
616
+ // Same Images API surface as gpt-image-2.5 (live-checked 2026-11-05; 2.6 also takes a `complexity` field the kit does not send).
617
+ id: "gpt-image-2.6-sunburst",
618
+ aliases: [],
619
+ label: "GPT Image 2.6 Sunburst",
620
+ type: "image",
621
+ adapter: "openai-image",
622
+ providerModelId: "gpt-image-2.6-sunburst",
623
+ lifecycle: "active",
624
+ exposure: ["cowork", "space_builder"],
625
+ constraints: {
626
+ exactSizes: {
627
+ "1:1": "1024x1024",
628
+ "3:2": "1536x1024",
629
+ "2:3": "1024x1536",
630
+ "16:9": "2048x1152",
631
+ "9:16": "1152x2048",
632
+ "4:5": "1024x1280",
633
+ "5:4": "1280x1024"
634
+ },
635
+ aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
636
+ sizes: ["1K", "2K", "4K"],
637
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
638
+ references: { images: 16 },
639
+ supports: ["quality", "count", "outputFormat"],
640
+ prompt: GPT_IMAGE_PROMPT,
641
+ ...GPT_IMAGE_2_6_OUTPUT
642
+ },
643
+ defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
644
+ usage: { ...IMAGE_USAGE3 },
645
+ pricingKind: "image_size",
646
+ display: {
647
+ provider: "openai",
648
+ description: "OpenAI's most detailed GPT Image 2.6 tier, built for intricate detail and editing precision; takes text and image input and outputs images in low, medium, high, xhigh, or max quality."
649
+ }
650
+ },
651
+ {
652
+ // Same Images API surface as gpt-image-2.5 (live-checked 2026-11-05; 2.6 also takes a `complexity` field the kit does not send).
653
+ id: "gpt-image-2.6-flare",
654
+ aliases: [],
655
+ label: "GPT Image 2.6 Flare",
656
+ type: "image",
657
+ adapter: "openai-image",
658
+ providerModelId: "gpt-image-2.6-flare",
659
+ lifecycle: "active",
660
+ exposure: ["cowork", "space_builder"],
661
+ constraints: {
662
+ exactSizes: {
663
+ "1:1": "1024x1024",
664
+ "3:2": "1536x1024",
665
+ "2:3": "1024x1536",
666
+ "16:9": "2048x1152",
667
+ "9:16": "1152x2048",
668
+ "4:5": "1024x1280",
669
+ "5:4": "1280x1024"
670
+ },
671
+ aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
672
+ sizes: ["1K", "2K", "4K"],
673
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
674
+ references: { images: 16 },
675
+ supports: ["quality", "count", "outputFormat"],
676
+ prompt: GPT_IMAGE_PROMPT,
677
+ ...GPT_IMAGE_2_6_OUTPUT
678
+ },
679
+ defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
680
+ usage: { ...IMAGE_USAGE3 },
681
+ pricingKind: "image_size",
682
+ display: {
683
+ provider: "openai",
684
+ description: "OpenAI's fast GPT Image 2.6 tier for everyday image generation and editing, with natural lighting, rich textures and complex layouts; takes text and image input and outputs images in low, medium, high, xhigh, or max quality."
685
+ }
686
+ },
596
687
  {
597
688
  // Same Images API surface as gpt-image-2 plus the "xhigh" and "max" quality tiers.
598
689
  id: "gpt-image-2.5-sunburst",
@@ -7809,7 +7900,20 @@ var AspectRatioSchema = z3.enum([
7809
7900
  var ImageSizeSchema = z3.enum(["512", "1K", "2K", "4K"]);
7810
7901
  var VideoResolutionSchema = z3.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
7811
7902
  var ImageQualitySchema = z3.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
7812
- var OutputFormatSchema = z3.enum(["png", "jpeg", "webp"]);
7903
+ var OutputFormatSchema = z3.enum(["png", "jpeg", "webp", "gif", "svg"]);
7904
+ var ImageBackgroundSchema = z3.enum(["auto", "opaque", "transparent"]);
7905
+ var AnimationLimitsSchema = z3.looseObject({
7906
+ frameSizes: z3.array(
7907
+ z3.looseObject({
7908
+ size: z3.string().regex(/^\d+x\d+$/u),
7909
+ minFrames: z3.number().int().positive(),
7910
+ maxFrames: z3.number().int().positive()
7911
+ })
7912
+ ).min(1),
7913
+ frameDurationMs: z3.looseObject({ min: z3.number().positive(), max: z3.number().positive() }),
7914
+ defaultFrameCount: z3.number().int().positive(),
7915
+ defaultFrameDurationMs: z3.number().positive()
7916
+ });
7813
7917
  var RequiredInputSchema = z3.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
7814
7918
  var SupportedOptionSchema = z3.enum([
7815
7919
  "seed",
@@ -7963,6 +8067,10 @@ var ModelConstraintsSchema = z3.looseObject({
7963
8067
  }).optional(),
7964
8068
  languages: z3.array(LanguageOptionSchema).optional(),
7965
8069
  outputFormats: z3.array(z3.string().min(1)).min(1).optional(),
8070
+ imageFormats: z3.array(OutputFormatSchema).min(1).optional(),
8071
+ backgrounds: z3.array(ImageBackgroundSchema).min(1).optional(),
8072
+ animation: AnimationLimitsSchema.optional(),
8073
+ svgModel: z3.string().min(1).optional(),
7966
8074
  sourceVideoPixels: VideoPixelLimitsSchema.optional(),
7967
8075
  sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: z3.boolean().optional() }).optional(),
7968
8076
  // segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
@@ -15761,7 +15869,37 @@ var lumaAdapter = {
15761
15869
  // src/adapters/openai-image.ts
15762
15870
  import OpenAI from "openai";
15763
15871
  import { z as z28 } from "zod";
15872
+
15873
+ // src/adapters/svg-sanitize.ts
15874
+ var BLOCK_ELEMENTS = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[\s\S]*?<\/\1\s*>/giu;
15875
+ var SELF_CLOSING = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[^>]*\/>/giu;
15876
+ var EVENT_ATTRIBUTE = /\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/giu;
15877
+ var EXTERNAL_HREF = /\s+(xlink:)?href\s*=\s*("(?!#)[^"]*"|'(?!#)[^']*')/giu;
15878
+ var STYLE_IMPORT = /@import\b[^;]*;?/giu;
15879
+ var STILL_ACTIVE = /<(script|foreignObject|iframe|object|embed)\b|\son[a-z]+\s*=|javascript:|<!ENTITY|<\?xml-stylesheet/iu;
15880
+ function sanitizeSvg(svg, model) {
15881
+ const cleaned = svg.replace(BLOCK_ELEMENTS, "").replace(SELF_CLOSING, "").replace(EVENT_ATTRIBUTE, "").replace(EXTERNAL_HREF, "").replace(STYLE_IMPORT, "");
15882
+ if (!/<svg\b/iu.test(cleaned) || STILL_ACTIVE.test(cleaned)) {
15883
+ throw new ModelKitError({
15884
+ code: "provider_rejected",
15885
+ message: `${model} returned an SVG that could not be made safe`,
15886
+ provider: "openai-image",
15887
+ model,
15888
+ retryable: false
15889
+ });
15890
+ }
15891
+ return cleaned;
15892
+ }
15893
+
15894
+ // src/adapters/openai-image.ts
15764
15895
  var MAX_EDIT_REFERENCES = 16;
15896
+ var MIME_BY_FORMAT = {
15897
+ png: "image/png",
15898
+ jpeg: "image/jpeg",
15899
+ webp: "image/webp",
15900
+ gif: "image/gif",
15901
+ svg: "image/svg+xml"
15902
+ };
15765
15903
  function aspectRatioToSize(ratio, tier) {
15766
15904
  const TIER_LONG_EDGE = {
15767
15905
  "1K": 1024,
@@ -15873,7 +16011,6 @@ var openaiImageAdapter = {
15873
16011
  const isEdit = refs.length > 0;
15874
16012
  const quality = req.quality ?? (isEdit ? "medium" : "auto");
15875
16013
  const sdkQuality = quality;
15876
- const count2 = req.count !== void 0 && req.count > 1 ? { n: req.count } : {};
15877
16014
  let outputFormat = req.outputFormat;
15878
16015
  if (outputFormat === "webp") {
15879
16016
  ctx.warnings.push({
@@ -15885,35 +16022,50 @@ var openaiImageAdapter = {
15885
16022
  });
15886
16023
  outputFormat = "png";
15887
16024
  }
15888
- const format = outputFormat !== void 0 ? { output_format: outputFormat } : {};
15889
- const mime = outputFormat === "jpeg" ? "image/jpeg" : "image/png";
16025
+ if (isEdit && outputFormat === "svg") {
16026
+ throw new ModelKitError({
16027
+ code: "unsupported_option",
16028
+ message: `${ctx.model.id} cannot make an SVG from reference images`,
16029
+ provider: "openai-image",
16030
+ model: ctx.model.id,
16031
+ retryable: false
16032
+ });
16033
+ }
16034
+ const svgModel = ctx.model.constraints.svgModel;
16035
+ if (outputFormat === "svg" && !svgModel) {
16036
+ throw new ModelKitError({
16037
+ code: "unsupported_option",
16038
+ message: `${ctx.model.id} names no svgModel to write the SVG`,
16039
+ provider: "openai-image",
16040
+ model: ctx.model.id,
16041
+ retryable: false
16042
+ });
16043
+ }
16044
+ const params = {
16045
+ model: ctx.model.providerModelId,
16046
+ prompt: req.prompt,
16047
+ quality: sdkQuality,
16048
+ ...size !== void 0 && { size },
16049
+ // SVG takes no `n` at all (OpenAI: "Use n=1"), not even 1.
16050
+ ...req.count !== void 0 && req.count > 1 && outputFormat !== "svg" && { n: req.count },
16051
+ ...outputFormat !== void 0 && { output_format: outputFormat },
16052
+ ...req.background !== void 0 && { background: req.background },
16053
+ ...outputFormat === "gif" && req.animation?.frameCount !== void 0 && {
16054
+ frame_count: req.animation.frameCount
16055
+ },
16056
+ ...outputFormat === "gif" && req.animation?.frameDurationMs !== void 0 && {
16057
+ frame_duration_ms: req.animation.frameDurationMs
16058
+ },
16059
+ ...outputFormat === "svg" && { svg: { model: svgModel } }
16060
+ };
16061
+ const mime = MIME_BY_FORMAT[outputFormat ?? "png"];
15890
16062
  const retryOptions = mediaRetryOptions(ctx.call, ctx.signal);
15891
16063
  const response = await withRetry(async () => {
15892
16064
  try {
15893
16065
  if (!isEdit) {
15894
- if (size !== void 0) {
15895
- return await client2.images.generate(
15896
- {
15897
- model: ctx.model.providerModelId,
15898
- prompt: req.prompt,
15899
- size,
15900
- quality: sdkQuality,
15901
- ...count2,
15902
- ...format
15903
- },
15904
- { signal: ctx.signal }
15905
- );
15906
- }
15907
- return await client2.images.generate(
15908
- {
15909
- model: ctx.model.providerModelId,
15910
- prompt: req.prompt,
15911
- quality: sdkQuality,
15912
- ...count2,
15913
- ...format
15914
- },
15915
- { signal: ctx.signal }
15916
- );
16066
+ return await client2.images.generate(params, {
16067
+ signal: ctx.signal
16068
+ });
15917
16069
  }
15918
16070
  const files = await Promise.all(
15919
16071
  refs.slice(0, MAX_EDIT_REFERENCES).map(async (ref, i) => {
@@ -15928,37 +16080,19 @@ var openaiImageAdapter = {
15928
16080
  );
15929
16081
  const single = files.length === 1 ? files[0] : void 0;
15930
16082
  const imageInput = single ?? files;
15931
- if (size !== void 0) {
15932
- return await client2.images.edit(
15933
- {
15934
- model: ctx.model.providerModelId,
15935
- image: imageInput,
15936
- prompt: req.prompt,
15937
- size,
15938
- quality: sdkQuality,
15939
- ...count2,
15940
- ...format
15941
- },
15942
- { signal: ctx.signal }
15943
- );
15944
- }
15945
16083
  return await client2.images.edit(
15946
- {
15947
- model: ctx.model.providerModelId,
15948
- image: imageInput,
15949
- prompt: req.prompt,
15950
- quality: sdkQuality,
15951
- ...count2,
15952
- ...format
15953
- },
16084
+ { ...params, image: imageInput },
15954
16085
  { signal: ctx.signal }
15955
16086
  );
15956
16087
  } catch (cause) {
15957
16088
  throw toProviderError2(cause, ctx);
15958
16089
  }
15959
16090
  }, retryOptions);
16091
+ const decode = (b64) => outputFormat === "svg" ? new TextEncoder().encode(
16092
+ sanitizeSvg(new TextDecoder().decode(base64ToBytes(b64)), ctx.model.id)
16093
+ ) : base64ToBytes(b64);
15960
16094
  const images = (response.data ?? []).flatMap(
15961
- (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime }] : []
16095
+ (item) => item.b64_json ? [{ bytes: decode(item.b64_json), mime }] : []
15962
16096
  );
15963
16097
  if (images.length === 0)
15964
16098
  throw classifyHttpError(
@@ -17542,6 +17676,155 @@ function fileCatalogCache(path) {
17542
17676
  };
17543
17677
  }
17544
17678
 
17679
+ // src/resolve-image-output.ts
17680
+ var BASE_FORMATS = ["png", "jpeg", "webp"];
17681
+ var ONE_K_FRAME_PIXELS = 288 * 512;
17682
+ function imageOutputFormats(model) {
17683
+ return model.constraints.imageFormats ?? BASE_FORMATS;
17684
+ }
17685
+ function animationTier(model, frameSize) {
17686
+ const [w, h] = frameSize.split("x").map(Number);
17687
+ const tier = (w ?? 0) * (h ?? 0) <= ONE_K_FRAME_PIXELS ? "1K" : "2K";
17688
+ const offered = model.constraints.sizes ?? ["1K", "2K", "4K"];
17689
+ if (offered.includes(tier)) return tier;
17690
+ return offered[offered.length - 1] ?? tier;
17691
+ }
17692
+ function refuse(model, message) {
17693
+ throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
17694
+ }
17695
+ function clamp(value, min, max) {
17696
+ return Math.min(Math.max(value, min), max);
17697
+ }
17698
+ function applyAnimation(model, req, onUnsupported, warnings) {
17699
+ const limits = model.constraints.animation;
17700
+ if (!limits) return;
17701
+ const sizes = limits.frameSizes;
17702
+ let frameSize = sizes.find((s) => s.size === req.exactSize);
17703
+ if (!frameSize) {
17704
+ const fallback = sizes[0];
17705
+ if (req.exactSize !== void 0) {
17706
+ if (onUnsupported === "error") {
17707
+ refuse(
17708
+ model,
17709
+ `${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
17710
+ );
17711
+ }
17712
+ warnings.push({
17713
+ code: "option_ignored",
17714
+ field: "exactSize",
17715
+ from: req.exactSize,
17716
+ to: fallback.size,
17717
+ message: `${model.id} has no ${req.exactSize} GIF frame; using ${fallback.size}`
17718
+ });
17719
+ }
17720
+ frameSize = fallback;
17721
+ }
17722
+ req.exactSize = frameSize.size;
17723
+ delete req.aspectRatio;
17724
+ const animation = { ...req.animation };
17725
+ const asked = animation.frameCount;
17726
+ const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
17727
+ if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
17728
+ if (onUnsupported === "error") {
17729
+ refuse(
17730
+ model,
17731
+ `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
17732
+ );
17733
+ }
17734
+ const snapped = clamp(Math.round(frames), frameSize.minFrames, frameSize.maxFrames);
17735
+ warnings.push({
17736
+ code: "option_ignored",
17737
+ field: "animation.frameCount",
17738
+ from: frames,
17739
+ to: snapped,
17740
+ message: `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; using ${snapped}`
17741
+ });
17742
+ animation.frameCount = snapped;
17743
+ } else {
17744
+ animation.frameCount = frames;
17745
+ }
17746
+ const { min, max } = limits.frameDurationMs;
17747
+ const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
17748
+ if (duration < min || duration > max) {
17749
+ if (onUnsupported === "error") {
17750
+ refuse(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
17751
+ }
17752
+ const snapped = clamp(duration, min, max);
17753
+ warnings.push({
17754
+ code: "option_ignored",
17755
+ field: "animation.frameDurationMs",
17756
+ from: duration,
17757
+ to: snapped,
17758
+ message: `${model.id} shows each GIF frame ${min} to ${max} ms; using ${snapped}`
17759
+ });
17760
+ animation.frameDurationMs = snapped;
17761
+ } else {
17762
+ animation.frameDurationMs = duration;
17763
+ }
17764
+ req.animation = animation;
17765
+ req.size = animationTier(model, frameSize.size);
17766
+ }
17767
+ function applyImageOutputRules(model, req, onUnsupported, warnings) {
17768
+ const c = model.constraints;
17769
+ const format = req.outputFormat;
17770
+ if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
17771
+ if (onUnsupported === "error") {
17772
+ refuse(
17773
+ model,
17774
+ `${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
17775
+ );
17776
+ }
17777
+ warnings.push({
17778
+ code: "option_ignored",
17779
+ field: "outputFormat",
17780
+ from: format,
17781
+ message: `${model.id} does not offer ${format}; ignored`
17782
+ });
17783
+ delete req.outputFormat;
17784
+ }
17785
+ if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
17786
+ if (onUnsupported === "error") {
17787
+ refuse(model, `${model.id} does not offer background ${req.background}`);
17788
+ }
17789
+ warnings.push({
17790
+ code: "option_ignored",
17791
+ field: "background",
17792
+ from: req.background,
17793
+ message: `${model.id} does not offer background ${req.background}; ignored`
17794
+ });
17795
+ delete req.background;
17796
+ }
17797
+ if (req.outputFormat === "gif") {
17798
+ applyAnimation(model, req, onUnsupported, warnings);
17799
+ } else if (req.animation !== void 0) {
17800
+ warnings.push({
17801
+ code: "option_ignored",
17802
+ field: "animation",
17803
+ message: `animation applies to GIF output only; ignored`
17804
+ });
17805
+ delete req.animation;
17806
+ }
17807
+ if (req.outputFormat === "svg") {
17808
+ if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
17809
+ if ((req.references ?? []).length > 0) {
17810
+ refuse(model, `${model.label} cannot make an SVG from reference images`);
17811
+ }
17812
+ if ((req.count ?? 1) > 1) {
17813
+ if (onUnsupported === "error") {
17814
+ refuse(model, `${model.label} makes one SVG per call`);
17815
+ }
17816
+ warnings.push({
17817
+ code: "option_ignored",
17818
+ field: "count",
17819
+ from: req.count,
17820
+ to: 1,
17821
+ message: `${model.id} makes one SVG per call; using 1`
17822
+ });
17823
+ req.count = 1;
17824
+ }
17825
+ }
17826
+ }
17827
+
17545
17828
  // src/resolve-lists.ts
17546
17829
  function preview(listed2) {
17547
17830
  const shown = listed2.slice(0, 12).join(", ");
@@ -17854,6 +18137,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
17854
18137
  "points",
17855
18138
  "boxes"
17856
18139
  ]);
18140
+ applyImageOutputRules(model, merged, onUnsupported, warnings);
17857
18141
  const factor = merged.scaleFactor;
17858
18142
  if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
17859
18143
  if (onUnsupported === "error") {
@@ -18190,7 +18474,7 @@ function setOrDelete(req, field, refs) {
18190
18474
  else delete req[field];
18191
18475
  }
18192
18476
  function isImageFormat(format) {
18193
- return format === "png" || format === "jpeg" || format === "webp";
18477
+ return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
18194
18478
  }
18195
18479
  function stripUndefined(obj) {
18196
18480
  return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
@@ -18397,7 +18681,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
18397
18681
  }
18398
18682
 
18399
18683
  // src/resolve-voice.ts
18400
- function refuse(model, code, message) {
18684
+ function refuse2(model, code, message) {
18401
18685
  return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
18402
18686
  }
18403
18687
  function checkSample(model, sample, index) {
@@ -18406,7 +18690,7 @@ function checkSample(model, sample, index) {
18406
18690
  if (limits === void 0 || length === void 0) return;
18407
18691
  if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
18408
18692
  const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
18409
- throw refuse(
18693
+ throw refuse2(
18410
18694
  model,
18411
18695
  "unsupported_option",
18412
18696
  `takes samples of ${range2}; sample ${index + 1} is ${length} s`
@@ -18415,11 +18699,11 @@ function checkSample(model, sample, index) {
18415
18699
  }
18416
18700
  function resolveVoiceCloneOptions(model, request) {
18417
18701
  const title = request.title.trim();
18418
- if (!title) throw refuse(model, "missing_input", "needs a title");
18419
- if (request.samples.length === 0) throw refuse(model, "missing_input", "needs a voice sample");
18702
+ if (!title) throw refuse2(model, "missing_input", "needs a title");
18703
+ if (request.samples.length === 0) throw refuse2(model, "missing_input", "needs a voice sample");
18420
18704
  const max = model.constraints.references?.audios;
18421
18705
  if (max !== void 0 && request.samples.length > max) {
18422
- throw refuse(
18706
+ throw refuse2(
18423
18707
  model,
18424
18708
  "unsupported_option",
18425
18709
  `takes up to ${max} samples; got ${request.samples.length}`
@@ -18429,7 +18713,7 @@ function resolveVoiceCloneOptions(model, request) {
18429
18713
  const total = model.constraints.references?.audioSeconds?.total;
18430
18714
  const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
18431
18715
  if (total !== void 0 && seconds3 > total) {
18432
- throw refuse(
18716
+ throw refuse2(
18433
18717
  model,
18434
18718
  "unsupported_option",
18435
18719
  `takes up to ${total} s of samples; got ${seconds3} s`
@@ -18438,7 +18722,7 @@ function resolveVoiceCloneOptions(model, request) {
18438
18722
  for (const field of ["transcript", "designSignature"]) {
18439
18723
  const set = request.samples.filter((s) => s[field]?.trim()).length;
18440
18724
  if (set !== 0 && set !== request.samples.length) {
18441
- throw refuse(model, "missing_input", `needs ${field} on every sample or on none`);
18725
+ throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
18442
18726
  }
18443
18727
  }
18444
18728
  return { request: { ...request, model: model.id, title }, warnings: [] };
@@ -18446,10 +18730,10 @@ function resolveVoiceCloneOptions(model, request) {
18446
18730
  function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18447
18731
  const warnings = [];
18448
18732
  const prompt = request.prompt.trim();
18449
- if (!prompt) throw refuse(model, "missing_input", "needs a voice description");
18733
+ if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
18450
18734
  const maxChars = promptConventions(model).maxChars;
18451
18735
  if (maxChars !== void 0 && prompt.length > maxChars) {
18452
- throw refuse(
18736
+ throw refuse2(
18453
18737
  model,
18454
18738
  "unsupported_option",
18455
18739
  `takes up to ${maxChars} characters; got ${prompt.length}`
@@ -18460,7 +18744,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18460
18744
  const preview2 = request.previewText?.trim();
18461
18745
  if (preview2) {
18462
18746
  if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
18463
- throw refuse(
18747
+ throw refuse2(
18464
18748
  model,
18465
18749
  "unsupported_option",
18466
18750
  `takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
@@ -18476,7 +18760,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18476
18760
  const cap = limits?.maxCandidates ?? count2;
18477
18761
  if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
18478
18762
  if (onUnsupported === "error" || !Number.isInteger(count2)) {
18479
- throw refuse(
18763
+ throw refuse2(
18480
18764
  model,
18481
18765
  "unsupported_option",
18482
18766
  `returns 1-${cap} candidates; got ${count2}`
@@ -19992,6 +20276,7 @@ export {
19992
20276
  VideoResolutionSchema,
19993
20277
  adapterServesType,
19994
20278
  aiSdkTextAdapter,
20279
+ animationTier,
19995
20280
  arkAdapter,
19996
20281
  aspectRatioToSize,
19997
20282
  byokProviderForModel,
@@ -20017,6 +20302,7 @@ export {
20017
20302
  googleImageAdapter,
20018
20303
  hasAwsCredentials,
20019
20304
  higgsfieldAdapter,
20305
+ imageOutputFormats,
20020
20306
  isArrayInputSpecKey,
20021
20307
  isInputSpecKey,
20022
20308
  isListed,