@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.cjs CHANGED
@@ -58,6 +58,7 @@ __export(index_exports, {
58
58
  VideoResolutionSchema: () => VideoResolutionSchema,
59
59
  adapterServesType: () => adapterServesType,
60
60
  aiSdkTextAdapter: () => aiSdkTextAdapter,
61
+ animationTier: () => animationTier,
61
62
  arkAdapter: () => arkAdapter,
62
63
  aspectRatioToSize: () => aspectRatioToSize,
63
64
  byokProviderForModel: () => byokProviderForModel,
@@ -83,6 +84,7 @@ __export(index_exports, {
83
84
  googleImageAdapter: () => googleImageAdapter,
84
85
  hasAwsCredentials: () => hasAwsCredentials,
85
86
  higgsfieldAdapter: () => higgsfieldAdapter,
87
+ imageOutputFormats: () => imageOutputFormats,
86
88
  isArrayInputSpecKey: () => isArrayInputSpecKey,
87
89
  isInputSpecKey: () => isInputSpecKey,
88
90
  isListed: () => isListed,
@@ -598,6 +600,25 @@ var NANO_BANANA_2_1_RATIOS = [
598
600
  "adaptive"
599
601
  ];
600
602
  var GEMINI_PROMPT_MAX_CHARS = 5e4;
603
+ var GPT_IMAGE_2_6_ANIMATION = {
604
+ frameSizes: [
605
+ { size: "288x288", minFrames: 2, maxFrames: 16 },
606
+ { size: "384x384", minFrames: 2, maxFrames: 16 },
607
+ { size: "512x288", minFrames: 2, maxFrames: 16 },
608
+ { size: "288x512", minFrames: 2, maxFrames: 16 },
609
+ { size: "512x512", minFrames: 2, maxFrames: 16 },
610
+ { size: "768x768", minFrames: 2, maxFrames: 12 }
611
+ ],
612
+ frameDurationMs: { min: 20, max: 2e3 },
613
+ defaultFrameCount: 9,
614
+ defaultFrameDurationMs: 200
615
+ };
616
+ var GPT_IMAGE_2_6_OUTPUT = {
617
+ imageFormats: ["png", "gif", "svg"],
618
+ backgrounds: ["auto", "opaque", "transparent"],
619
+ animation: GPT_IMAGE_2_6_ANIMATION,
620
+ svgModel: "gpt-6.1-sol"
621
+ };
601
622
  var GPT_IMAGE_PROMPT = { referenceSyntax: "numbered", maxChars: 32e3 };
602
623
  function geminiImage(id, label, aliases, sizes, display, exposure, references, promptMaxChars, aspectRatios = GEMINI_RATIOS) {
603
624
  const prompt = { referenceSyntax: "caption" };
@@ -741,6 +762,78 @@ var IMAGE_MODELS = [
741
762
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/1204b494-8962-4f7f-af5e-699a8bdc98e3_compressed.png"
742
763
  }
743
764
  },
765
+ {
766
+ // 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).
767
+ id: "gpt-image-2.6-sunburst",
768
+ aliases: [],
769
+ label: "GPT Image 2.6 Sunburst",
770
+ type: "image",
771
+ adapter: "openai-image",
772
+ providerModelId: "gpt-image-2.6-sunburst",
773
+ lifecycle: "active",
774
+ exposure: ["cowork", "space_builder"],
775
+ constraints: {
776
+ exactSizes: {
777
+ "1:1": "1024x1024",
778
+ "3:2": "1536x1024",
779
+ "2:3": "1024x1536",
780
+ "16:9": "2048x1152",
781
+ "9:16": "1152x2048",
782
+ "4:5": "1024x1280",
783
+ "5:4": "1280x1024"
784
+ },
785
+ aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
786
+ sizes: ["1K", "2K", "4K"],
787
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
788
+ references: { images: 16 },
789
+ supports: ["quality", "count", "outputFormat"],
790
+ prompt: GPT_IMAGE_PROMPT,
791
+ ...GPT_IMAGE_2_6_OUTPUT
792
+ },
793
+ defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
794
+ usage: { ...IMAGE_USAGE3 },
795
+ pricingKind: "image_size",
796
+ display: {
797
+ provider: "openai",
798
+ 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."
799
+ }
800
+ },
801
+ {
802
+ // 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).
803
+ id: "gpt-image-2.6-flare",
804
+ aliases: [],
805
+ label: "GPT Image 2.6 Flare",
806
+ type: "image",
807
+ adapter: "openai-image",
808
+ providerModelId: "gpt-image-2.6-flare",
809
+ lifecycle: "active",
810
+ exposure: ["cowork", "space_builder"],
811
+ constraints: {
812
+ exactSizes: {
813
+ "1:1": "1024x1024",
814
+ "3:2": "1536x1024",
815
+ "2:3": "1024x1536",
816
+ "16:9": "2048x1152",
817
+ "9:16": "1152x2048",
818
+ "4:5": "1024x1280",
819
+ "5:4": "1280x1024"
820
+ },
821
+ aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
822
+ sizes: ["1K", "2K", "4K"],
823
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
824
+ references: { images: 16 },
825
+ supports: ["quality", "count", "outputFormat"],
826
+ prompt: GPT_IMAGE_PROMPT,
827
+ ...GPT_IMAGE_2_6_OUTPUT
828
+ },
829
+ defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
830
+ usage: { ...IMAGE_USAGE3 },
831
+ pricingKind: "image_size",
832
+ display: {
833
+ provider: "openai",
834
+ 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."
835
+ }
836
+ },
744
837
  {
745
838
  // Same Images API surface as gpt-image-2 plus the "xhigh" and "max" quality tiers.
746
839
  id: "gpt-image-2.5-sunburst",
@@ -7957,7 +8050,20 @@ var AspectRatioSchema = import_zod3.z.enum([
7957
8050
  var ImageSizeSchema = import_zod3.z.enum(["512", "1K", "2K", "4K"]);
7958
8051
  var VideoResolutionSchema = import_zod3.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
7959
8052
  var ImageQualitySchema = import_zod3.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
7960
- var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp"]);
8053
+ var OutputFormatSchema = import_zod3.z.enum(["png", "jpeg", "webp", "gif", "svg"]);
8054
+ var ImageBackgroundSchema = import_zod3.z.enum(["auto", "opaque", "transparent"]);
8055
+ var AnimationLimitsSchema = import_zod3.z.looseObject({
8056
+ frameSizes: import_zod3.z.array(
8057
+ import_zod3.z.looseObject({
8058
+ size: import_zod3.z.string().regex(/^\d+x\d+$/u),
8059
+ minFrames: import_zod3.z.number().int().positive(),
8060
+ maxFrames: import_zod3.z.number().int().positive()
8061
+ })
8062
+ ).min(1),
8063
+ frameDurationMs: import_zod3.z.looseObject({ min: import_zod3.z.number().positive(), max: import_zod3.z.number().positive() }),
8064
+ defaultFrameCount: import_zod3.z.number().int().positive(),
8065
+ defaultFrameDurationMs: import_zod3.z.number().positive()
8066
+ });
7961
8067
  var RequiredInputSchema = import_zod3.z.enum(["firstFrame", "sourceVideo", "references", "sourceAudio"]);
7962
8068
  var SupportedOptionSchema = import_zod3.z.enum([
7963
8069
  "seed",
@@ -8111,6 +8217,10 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
8111
8217
  }).optional(),
8112
8218
  languages: import_zod3.z.array(LanguageOptionSchema).optional(),
8113
8219
  outputFormats: import_zod3.z.array(import_zod3.z.string().min(1)).min(1).optional(),
8220
+ imageFormats: import_zod3.z.array(OutputFormatSchema).min(1).optional(),
8221
+ backgrounds: import_zod3.z.array(ImageBackgroundSchema).min(1).optional(),
8222
+ animation: AnimationLimitsSchema.optional(),
8223
+ svgModel: import_zod3.z.string().min(1).optional(),
8114
8224
  sourceVideoPixels: VideoPixelLimitsSchema.optional(),
8115
8225
  sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
8116
8226
  // segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
@@ -15907,7 +16017,37 @@ var lumaAdapter = {
15907
16017
  // src/adapters/openai-image.ts
15908
16018
  var import_openai2 = __toESM(require("openai"), 1);
15909
16019
  var import_zod28 = require("zod");
16020
+
16021
+ // src/adapters/svg-sanitize.ts
16022
+ var BLOCK_ELEMENTS = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[\s\S]*?<\/\1\s*>/giu;
16023
+ var SELF_CLOSING = /<(script|foreignObject|iframe|object|embed|audio|video|handler|listener)\b[^>]*\/>/giu;
16024
+ var EVENT_ATTRIBUTE = /\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/giu;
16025
+ var EXTERNAL_HREF = /\s+(xlink:)?href\s*=\s*("(?!#)[^"]*"|'(?!#)[^']*')/giu;
16026
+ var STYLE_IMPORT = /@import\b[^;]*;?/giu;
16027
+ var STILL_ACTIVE = /<(script|foreignObject|iframe|object|embed)\b|\son[a-z]+\s*=|javascript:|<!ENTITY|<\?xml-stylesheet/iu;
16028
+ function sanitizeSvg(svg, model) {
16029
+ const cleaned = svg.replace(BLOCK_ELEMENTS, "").replace(SELF_CLOSING, "").replace(EVENT_ATTRIBUTE, "").replace(EXTERNAL_HREF, "").replace(STYLE_IMPORT, "");
16030
+ if (!/<svg\b/iu.test(cleaned) || STILL_ACTIVE.test(cleaned)) {
16031
+ throw new ModelKitError({
16032
+ code: "provider_rejected",
16033
+ message: `${model} returned an SVG that could not be made safe`,
16034
+ provider: "openai-image",
16035
+ model,
16036
+ retryable: false
16037
+ });
16038
+ }
16039
+ return cleaned;
16040
+ }
16041
+
16042
+ // src/adapters/openai-image.ts
15910
16043
  var MAX_EDIT_REFERENCES = 16;
16044
+ var MIME_BY_FORMAT = {
16045
+ png: "image/png",
16046
+ jpeg: "image/jpeg",
16047
+ webp: "image/webp",
16048
+ gif: "image/gif",
16049
+ svg: "image/svg+xml"
16050
+ };
15911
16051
  function aspectRatioToSize(ratio, tier) {
15912
16052
  const TIER_LONG_EDGE = {
15913
16053
  "1K": 1024,
@@ -16019,7 +16159,6 @@ var openaiImageAdapter = {
16019
16159
  const isEdit = refs.length > 0;
16020
16160
  const quality = req.quality ?? (isEdit ? "medium" : "auto");
16021
16161
  const sdkQuality = quality;
16022
- const count2 = req.count !== void 0 && req.count > 1 ? { n: req.count } : {};
16023
16162
  let outputFormat = req.outputFormat;
16024
16163
  if (outputFormat === "webp") {
16025
16164
  ctx.warnings.push({
@@ -16031,35 +16170,50 @@ var openaiImageAdapter = {
16031
16170
  });
16032
16171
  outputFormat = "png";
16033
16172
  }
16034
- const format = outputFormat !== void 0 ? { output_format: outputFormat } : {};
16035
- const mime = outputFormat === "jpeg" ? "image/jpeg" : "image/png";
16173
+ if (isEdit && outputFormat === "svg") {
16174
+ throw new ModelKitError({
16175
+ code: "unsupported_option",
16176
+ message: `${ctx.model.id} cannot make an SVG from reference images`,
16177
+ provider: "openai-image",
16178
+ model: ctx.model.id,
16179
+ retryable: false
16180
+ });
16181
+ }
16182
+ const svgModel = ctx.model.constraints.svgModel;
16183
+ if (outputFormat === "svg" && !svgModel) {
16184
+ throw new ModelKitError({
16185
+ code: "unsupported_option",
16186
+ message: `${ctx.model.id} names no svgModel to write the SVG`,
16187
+ provider: "openai-image",
16188
+ model: ctx.model.id,
16189
+ retryable: false
16190
+ });
16191
+ }
16192
+ const params = {
16193
+ model: ctx.model.providerModelId,
16194
+ prompt: req.prompt,
16195
+ quality: sdkQuality,
16196
+ ...size !== void 0 && { size },
16197
+ // SVG takes no `n` at all (OpenAI: "Use n=1"), not even 1.
16198
+ ...req.count !== void 0 && req.count > 1 && outputFormat !== "svg" && { n: req.count },
16199
+ ...outputFormat !== void 0 && { output_format: outputFormat },
16200
+ ...req.background !== void 0 && { background: req.background },
16201
+ ...outputFormat === "gif" && req.animation?.frameCount !== void 0 && {
16202
+ frame_count: req.animation.frameCount
16203
+ },
16204
+ ...outputFormat === "gif" && req.animation?.frameDurationMs !== void 0 && {
16205
+ frame_duration_ms: req.animation.frameDurationMs
16206
+ },
16207
+ ...outputFormat === "svg" && { svg: { model: svgModel } }
16208
+ };
16209
+ const mime = MIME_BY_FORMAT[outputFormat ?? "png"];
16036
16210
  const retryOptions = mediaRetryOptions(ctx.call, ctx.signal);
16037
16211
  const response = await withRetry(async () => {
16038
16212
  try {
16039
16213
  if (!isEdit) {
16040
- if (size !== void 0) {
16041
- return await client2.images.generate(
16042
- {
16043
- model: ctx.model.providerModelId,
16044
- prompt: req.prompt,
16045
- size,
16046
- quality: sdkQuality,
16047
- ...count2,
16048
- ...format
16049
- },
16050
- { signal: ctx.signal }
16051
- );
16052
- }
16053
- return await client2.images.generate(
16054
- {
16055
- model: ctx.model.providerModelId,
16056
- prompt: req.prompt,
16057
- quality: sdkQuality,
16058
- ...count2,
16059
- ...format
16060
- },
16061
- { signal: ctx.signal }
16062
- );
16214
+ return await client2.images.generate(params, {
16215
+ signal: ctx.signal
16216
+ });
16063
16217
  }
16064
16218
  const files = await Promise.all(
16065
16219
  refs.slice(0, MAX_EDIT_REFERENCES).map(async (ref, i) => {
@@ -16074,37 +16228,19 @@ var openaiImageAdapter = {
16074
16228
  );
16075
16229
  const single = files.length === 1 ? files[0] : void 0;
16076
16230
  const imageInput = single ?? files;
16077
- if (size !== void 0) {
16078
- return await client2.images.edit(
16079
- {
16080
- model: ctx.model.providerModelId,
16081
- image: imageInput,
16082
- prompt: req.prompt,
16083
- size,
16084
- quality: sdkQuality,
16085
- ...count2,
16086
- ...format
16087
- },
16088
- { signal: ctx.signal }
16089
- );
16090
- }
16091
16231
  return await client2.images.edit(
16092
- {
16093
- model: ctx.model.providerModelId,
16094
- image: imageInput,
16095
- prompt: req.prompt,
16096
- quality: sdkQuality,
16097
- ...count2,
16098
- ...format
16099
- },
16232
+ { ...params, image: imageInput },
16100
16233
  { signal: ctx.signal }
16101
16234
  );
16102
16235
  } catch (cause) {
16103
16236
  throw toProviderError2(cause, ctx);
16104
16237
  }
16105
16238
  }, retryOptions);
16239
+ const decode = (b64) => outputFormat === "svg" ? new TextEncoder().encode(
16240
+ sanitizeSvg(new TextDecoder().decode(base64ToBytes(b64)), ctx.model.id)
16241
+ ) : base64ToBytes(b64);
16106
16242
  const images = (response.data ?? []).flatMap(
16107
- (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime }] : []
16243
+ (item) => item.b64_json ? [{ bytes: decode(item.b64_json), mime }] : []
16108
16244
  );
16109
16245
  if (images.length === 0)
16110
16246
  throw classifyHttpError(
@@ -17688,6 +17824,155 @@ function fileCatalogCache(path) {
17688
17824
  };
17689
17825
  }
17690
17826
 
17827
+ // src/resolve-image-output.ts
17828
+ var BASE_FORMATS = ["png", "jpeg", "webp"];
17829
+ var ONE_K_FRAME_PIXELS = 288 * 512;
17830
+ function imageOutputFormats(model) {
17831
+ return model.constraints.imageFormats ?? BASE_FORMATS;
17832
+ }
17833
+ function animationTier(model, frameSize) {
17834
+ const [w, h] = frameSize.split("x").map(Number);
17835
+ const tier = (w ?? 0) * (h ?? 0) <= ONE_K_FRAME_PIXELS ? "1K" : "2K";
17836
+ const offered = model.constraints.sizes ?? ["1K", "2K", "4K"];
17837
+ if (offered.includes(tier)) return tier;
17838
+ return offered[offered.length - 1] ?? tier;
17839
+ }
17840
+ function refuse(model, message) {
17841
+ throw new ModelKitError({ code: "unsupported_option", message, model: model.id });
17842
+ }
17843
+ function clamp(value, min, max) {
17844
+ return Math.min(Math.max(value, min), max);
17845
+ }
17846
+ function applyAnimation(model, req, onUnsupported, warnings) {
17847
+ const limits = model.constraints.animation;
17848
+ if (!limits) return;
17849
+ const sizes = limits.frameSizes;
17850
+ let frameSize = sizes.find((s) => s.size === req.exactSize);
17851
+ if (!frameSize) {
17852
+ const fallback = sizes[0];
17853
+ if (req.exactSize !== void 0) {
17854
+ if (onUnsupported === "error") {
17855
+ refuse(
17856
+ model,
17857
+ `${model.id} makes GIF frames at ${sizes.map((s) => s.size).join(", ")}; got ${req.exactSize}`
17858
+ );
17859
+ }
17860
+ warnings.push({
17861
+ code: "option_ignored",
17862
+ field: "exactSize",
17863
+ from: req.exactSize,
17864
+ to: fallback.size,
17865
+ message: `${model.id} has no ${req.exactSize} GIF frame; using ${fallback.size}`
17866
+ });
17867
+ }
17868
+ frameSize = fallback;
17869
+ }
17870
+ req.exactSize = frameSize.size;
17871
+ delete req.aspectRatio;
17872
+ const animation = { ...req.animation };
17873
+ const asked = animation.frameCount;
17874
+ const frames = asked ?? clamp(limits.defaultFrameCount, frameSize.minFrames, frameSize.maxFrames);
17875
+ if (frames < frameSize.minFrames || frames > frameSize.maxFrames || !Number.isInteger(frames)) {
17876
+ if (onUnsupported === "error") {
17877
+ refuse(
17878
+ model,
17879
+ `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; got ${frames}`
17880
+ );
17881
+ }
17882
+ const snapped = clamp(Math.round(frames), frameSize.minFrames, frameSize.maxFrames);
17883
+ warnings.push({
17884
+ code: "option_ignored",
17885
+ field: "animation.frameCount",
17886
+ from: frames,
17887
+ to: snapped,
17888
+ message: `${model.id} makes ${frameSize.minFrames} to ${frameSize.maxFrames} frames at ${frameSize.size}; using ${snapped}`
17889
+ });
17890
+ animation.frameCount = snapped;
17891
+ } else {
17892
+ animation.frameCount = frames;
17893
+ }
17894
+ const { min, max } = limits.frameDurationMs;
17895
+ const duration = animation.frameDurationMs ?? limits.defaultFrameDurationMs;
17896
+ if (duration < min || duration > max) {
17897
+ if (onUnsupported === "error") {
17898
+ refuse(model, `${model.id} shows each GIF frame ${min} to ${max} ms; got ${duration}`);
17899
+ }
17900
+ const snapped = clamp(duration, min, max);
17901
+ warnings.push({
17902
+ code: "option_ignored",
17903
+ field: "animation.frameDurationMs",
17904
+ from: duration,
17905
+ to: snapped,
17906
+ message: `${model.id} shows each GIF frame ${min} to ${max} ms; using ${snapped}`
17907
+ });
17908
+ animation.frameDurationMs = snapped;
17909
+ } else {
17910
+ animation.frameDurationMs = duration;
17911
+ }
17912
+ req.animation = animation;
17913
+ req.size = animationTier(model, frameSize.size);
17914
+ }
17915
+ function applyImageOutputRules(model, req, onUnsupported, warnings) {
17916
+ const c = model.constraints;
17917
+ const format = req.outputFormat;
17918
+ if (format !== void 0 && !imageOutputFormats(model).includes(format)) {
17919
+ if (onUnsupported === "error") {
17920
+ refuse(
17921
+ model,
17922
+ `${model.id} does not offer outputFormat ${format}. Supported: ${imageOutputFormats(model).join(", ")}.`
17923
+ );
17924
+ }
17925
+ warnings.push({
17926
+ code: "option_ignored",
17927
+ field: "outputFormat",
17928
+ from: format,
17929
+ message: `${model.id} does not offer ${format}; ignored`
17930
+ });
17931
+ delete req.outputFormat;
17932
+ }
17933
+ if (req.background !== void 0 && !(c.backgrounds ?? []).includes(req.background)) {
17934
+ if (onUnsupported === "error") {
17935
+ refuse(model, `${model.id} does not offer background ${req.background}`);
17936
+ }
17937
+ warnings.push({
17938
+ code: "option_ignored",
17939
+ field: "background",
17940
+ from: req.background,
17941
+ message: `${model.id} does not offer background ${req.background}; ignored`
17942
+ });
17943
+ delete req.background;
17944
+ }
17945
+ if (req.outputFormat === "gif") {
17946
+ applyAnimation(model, req, onUnsupported, warnings);
17947
+ } else if (req.animation !== void 0) {
17948
+ warnings.push({
17949
+ code: "option_ignored",
17950
+ field: "animation",
17951
+ message: `animation applies to GIF output only; ignored`
17952
+ });
17953
+ delete req.animation;
17954
+ }
17955
+ if (req.outputFormat === "svg") {
17956
+ if (!c.svgModel) refuse(model, `${model.id} names no svgModel to write the SVG`);
17957
+ if ((req.references ?? []).length > 0) {
17958
+ refuse(model, `${model.label} cannot make an SVG from reference images`);
17959
+ }
17960
+ if ((req.count ?? 1) > 1) {
17961
+ if (onUnsupported === "error") {
17962
+ refuse(model, `${model.label} makes one SVG per call`);
17963
+ }
17964
+ warnings.push({
17965
+ code: "option_ignored",
17966
+ field: "count",
17967
+ from: req.count,
17968
+ to: 1,
17969
+ message: `${model.id} makes one SVG per call; using 1`
17970
+ });
17971
+ req.count = 1;
17972
+ }
17973
+ }
17974
+ }
17975
+
17691
17976
  // src/resolve-lists.ts
17692
17977
  function preview(listed2) {
17693
17978
  const shown = listed2.slice(0, 12).join(", ");
@@ -18000,6 +18285,7 @@ function resolveImageOptions(model, request, onUnsupported = "error") {
18000
18285
  "points",
18001
18286
  "boxes"
18002
18287
  ]);
18288
+ applyImageOutputRules(model, merged, onUnsupported, warnings);
18003
18289
  const factor = merged.scaleFactor;
18004
18290
  if (factor !== void 0 && c.scaleFactors && !c.scaleFactors.includes(factor)) {
18005
18291
  if (onUnsupported === "error") {
@@ -18336,7 +18622,7 @@ function setOrDelete(req, field, refs) {
18336
18622
  else delete req[field];
18337
18623
  }
18338
18624
  function isImageFormat(format) {
18339
- return format === "png" || format === "jpeg" || format === "webp";
18625
+ return format === "png" || format === "jpeg" || format === "webp" || format === "gif" || format === "svg";
18340
18626
  }
18341
18627
  function stripUndefined(obj) {
18342
18628
  return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== void 0));
@@ -18543,7 +18829,7 @@ function resolveTranscriptionOptions(model, request, onUnsupported = "error") {
18543
18829
  }
18544
18830
 
18545
18831
  // src/resolve-voice.ts
18546
- function refuse(model, code, message) {
18832
+ function refuse2(model, code, message) {
18547
18833
  return new ModelKitError({ code, message: `${model.label} ${message}`, model: model.id });
18548
18834
  }
18549
18835
  function checkSample(model, sample, index) {
@@ -18552,7 +18838,7 @@ function checkSample(model, sample, index) {
18552
18838
  if (limits === void 0 || length === void 0) return;
18553
18839
  if (limits.min !== void 0 && length < limits.min || limits.max !== void 0 && length > limits.max) {
18554
18840
  const range2 = `${limits.min ?? 0}-${limits.max ?? "any"} s`;
18555
- throw refuse(
18841
+ throw refuse2(
18556
18842
  model,
18557
18843
  "unsupported_option",
18558
18844
  `takes samples of ${range2}; sample ${index + 1} is ${length} s`
@@ -18561,11 +18847,11 @@ function checkSample(model, sample, index) {
18561
18847
  }
18562
18848
  function resolveVoiceCloneOptions(model, request) {
18563
18849
  const title = request.title.trim();
18564
- if (!title) throw refuse(model, "missing_input", "needs a title");
18565
- if (request.samples.length === 0) throw refuse(model, "missing_input", "needs a voice sample");
18850
+ if (!title) throw refuse2(model, "missing_input", "needs a title");
18851
+ if (request.samples.length === 0) throw refuse2(model, "missing_input", "needs a voice sample");
18566
18852
  const max = model.constraints.references?.audios;
18567
18853
  if (max !== void 0 && request.samples.length > max) {
18568
- throw refuse(
18854
+ throw refuse2(
18569
18855
  model,
18570
18856
  "unsupported_option",
18571
18857
  `takes up to ${max} samples; got ${request.samples.length}`
@@ -18575,7 +18861,7 @@ function resolveVoiceCloneOptions(model, request) {
18575
18861
  const total = model.constraints.references?.audioSeconds?.total;
18576
18862
  const seconds3 = request.samples.reduce((sum, s) => sum + (s.audio.durationSeconds ?? 0), 0);
18577
18863
  if (total !== void 0 && seconds3 > total) {
18578
- throw refuse(
18864
+ throw refuse2(
18579
18865
  model,
18580
18866
  "unsupported_option",
18581
18867
  `takes up to ${total} s of samples; got ${seconds3} s`
@@ -18584,7 +18870,7 @@ function resolveVoiceCloneOptions(model, request) {
18584
18870
  for (const field of ["transcript", "designSignature"]) {
18585
18871
  const set = request.samples.filter((s) => s[field]?.trim()).length;
18586
18872
  if (set !== 0 && set !== request.samples.length) {
18587
- throw refuse(model, "missing_input", `needs ${field} on every sample or on none`);
18873
+ throw refuse2(model, "missing_input", `needs ${field} on every sample or on none`);
18588
18874
  }
18589
18875
  }
18590
18876
  return { request: { ...request, model: model.id, title }, warnings: [] };
@@ -18592,10 +18878,10 @@ function resolveVoiceCloneOptions(model, request) {
18592
18878
  function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18593
18879
  const warnings = [];
18594
18880
  const prompt = request.prompt.trim();
18595
- if (!prompt) throw refuse(model, "missing_input", "needs a voice description");
18881
+ if (!prompt) throw refuse2(model, "missing_input", "needs a voice description");
18596
18882
  const maxChars = promptConventions(model).maxChars;
18597
18883
  if (maxChars !== void 0 && prompt.length > maxChars) {
18598
- throw refuse(
18884
+ throw refuse2(
18599
18885
  model,
18600
18886
  "unsupported_option",
18601
18887
  `takes up to ${maxChars} characters; got ${prompt.length}`
@@ -18606,7 +18892,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18606
18892
  const preview2 = request.previewText?.trim();
18607
18893
  if (preview2) {
18608
18894
  if (limits !== void 0 && preview2.length > limits.previewMaxChars) {
18609
- throw refuse(
18895
+ throw refuse2(
18610
18896
  model,
18611
18897
  "unsupported_option",
18612
18898
  `takes a preview line of up to ${limits.previewMaxChars} characters; got ${preview2.length}`
@@ -18622,7 +18908,7 @@ function resolveVoiceDesignOptions(model, request, onUnsupported = "error") {
18622
18908
  const cap = limits?.maxCandidates ?? count2;
18623
18909
  if (!Number.isInteger(count2) || count2 < 1 || count2 > cap) {
18624
18910
  if (onUnsupported === "error" || !Number.isInteger(count2)) {
18625
- throw refuse(
18911
+ throw refuse2(
18626
18912
  model,
18627
18913
  "unsupported_option",
18628
18914
  `returns 1-${cap} candidates; got ${count2}`
@@ -20132,6 +20418,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
20132
20418
  VideoResolutionSchema,
20133
20419
  adapterServesType,
20134
20420
  aiSdkTextAdapter,
20421
+ animationTier,
20135
20422
  arkAdapter,
20136
20423
  aspectRatioToSize,
20137
20424
  byokProviderForModel,
@@ -20157,6 +20444,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
20157
20444
  googleImageAdapter,
20158
20445
  hasAwsCredentials,
20159
20446
  higgsfieldAdapter,
20447
+ imageOutputFormats,
20160
20448
  isArrayInputSpecKey,
20161
20449
  isInputSpecKey,
20162
20450
  isListed,