@shop-os/modelkit 0.1.11 → 0.2.2

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
@@ -31,8 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.ts
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
+ ADAPTER_IDS: () => ADAPTER_IDS,
34
35
  ADAPTER_KEYS: () => ADAPTER_KEYS,
35
36
  Catalog: () => Catalog,
37
+ CatalogModelSchema: () => CatalogModelSchema,
38
+ CatalogSchema: () => CatalogSchema,
36
39
  DEFAULT_ADAPTERS: () => DEFAULT_ADAPTERS,
37
40
  JsonObjectSchema: () => JsonObjectSchema,
38
41
  JsonValueSchema: () => JsonValueSchema,
@@ -48,6 +51,7 @@ __export(index_exports, {
48
51
  describeThrown: () => describeThrown,
49
52
  experimental_generateImage: () => generateImage,
50
53
  falAdapter: () => falAdapter,
54
+ fileCatalogCache: () => fileCatalogCache,
51
55
  generateAudio: () => generateAudio,
52
56
  generateImage: () => generateImage,
53
57
  generateObject: () => generateObject,
@@ -59,15 +63,19 @@ __export(index_exports, {
59
63
  isModelKitError: () => isModelKitError,
60
64
  keysFromEnv: () => keysFromEnv,
61
65
  languageModel: () => languageModel,
66
+ liveCatalog: () => liveCatalog,
67
+ liveState: () => liveState,
62
68
  mergeTextProviderOptions: () => mergeTextProviderOptions,
63
69
  nearestAspectRatio: () => nearestAspectRatio,
64
70
  openaiImageAdapter: () => openaiImageAdapter,
65
71
  passthroughTextModel: () => passthroughTextModel,
66
72
  pollUntil: () => pollUntil,
67
73
  prepareMediaPart: () => prepareMediaPart,
74
+ primeCatalog: () => primeCatalog,
68
75
  prodiaAdapter: () => prodiaAdapter,
69
76
  readErrorBody: () => readErrorBody,
70
77
  replicateAdapter: () => replicateAdapter,
78
+ resetLiveCatalog: () => resetLiveCatalog,
71
79
  resolveAudioOptions: () => resolveAudioOptions,
72
80
  resolveImageOptions: () => resolveImageOptions,
73
81
  resolveKeys: () => resolveKeys,
@@ -179,6 +187,14 @@ var Catalog = class _Catalog {
179
187
  ...rows
180
188
  ]);
181
189
  }
190
+ /** Atomically swap every row. Builds the maps first so a bad batch throws before anything changes. */
191
+ replace(rows) {
192
+ const next = new _Catalog(rows);
193
+ this.byId.clear();
194
+ this.byAlias.clear();
195
+ for (const [id, model] of next.byId) this.byId.set(id, model);
196
+ for (const [alias, id] of next.byAlias) this.byAlias.set(alias, id);
197
+ }
182
198
  };
183
199
 
184
200
  // src/catalog/image.ts
@@ -196,7 +212,7 @@ var GEMINI_RATIOS = [
196
212
  "5:4",
197
213
  "adaptive"
198
214
  ];
199
- function geminiImage(id, label, aliases, sizes, display, exposure) {
215
+ function geminiImage(id, label, aliases, sizes, display, exposure, references) {
200
216
  const model = {
201
217
  id,
202
218
  aliases,
@@ -209,7 +225,8 @@ function geminiImage(id, label, aliases, sizes, display, exposure) {
209
225
  constraints: {
210
226
  aspectRatios: [...GEMINI_RATIOS],
211
227
  sizes,
212
- supports: ["safetySettings", "temperature"]
228
+ supports: ["safetySettings", "temperature"],
229
+ ...references ? { references } : {}
213
230
  },
214
231
  defaults: { size: "1K", aspectRatio: "1:1" },
215
232
  usage: { ...IMAGE_USAGE, slug: "gemini" },
@@ -229,7 +246,8 @@ var IMAGE_MODELS = [
229
246
  description: "Create stunning, production-quality visuals with exceptional realism, detail, and typography. Best for campaigns, e-commerce, product photography, and hero creatives.",
230
247
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
231
248
  },
232
- "catalog"
249
+ "catalog",
250
+ { images: 14 }
233
251
  ),
234
252
  geminiImage(
235
253
  "gemini-3.1-flash-image-preview",
@@ -242,7 +260,8 @@ var IMAGE_MODELS = [
242
260
  description: "Generate high-quality images at speed. Perfect for brainstorming, moodboards, concept testing, creative exploration, and large batch workflows.",
243
261
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
244
262
  },
245
- "catalog"
263
+ "catalog",
264
+ { images: 14 }
246
265
  ),
247
266
  geminiImage(
248
267
  "gemini-3.1-flash-lite-image",
@@ -254,14 +273,15 @@ var IMAGE_MODELS = [
254
273
  description: "The fastest and most affordable image model. Ideal for rapid drafts, bulk exploration, and iterative concept testing at 1K resolution.",
255
274
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
256
275
  },
257
- "catalog"
276
+ "catalog",
277
+ { images: 14 }
258
278
  ),
259
279
  // trigger-workflows validates 1K only; pricing seeds 2K/4K rows so allow all three.
260
280
  geminiImage(
261
281
  "gemini-2.5-flash-image",
262
282
  "Gemini 2.5 Flash Image",
263
283
  [],
264
- ["1K", "2K", "4K"],
284
+ ["1K"],
265
285
  {
266
286
  provider: "google",
267
287
  description: "Nano Banana (legacy Gemini 2.5 Flash Image) native image generation and editing model for high-volume, low-latency creative workflows."
@@ -292,7 +312,7 @@ var IMAGE_MODELS = [
292
312
  sizes: ["1K", "2K", "4K"],
293
313
  qualityOptions: ["auto", "low", "medium", "high"],
294
314
  references: { images: 16 },
295
- supports: ["quality", "count"]
315
+ supports: ["quality", "count", "outputFormat"]
296
316
  },
297
317
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
298
318
  usage: { ...IMAGE_USAGE, slug: "gpt" },
@@ -312,7 +332,7 @@ var IMAGE_MODELS = [
312
332
  adapter: "openai-image",
313
333
  providerModelId: "gpt-image-2.5-sunburst",
314
334
  lifecycle: "active",
315
- exposure: "internal",
335
+ exposure: "catalog",
316
336
  constraints: {
317
337
  exactSizes: {
318
338
  "1:1": "1024x1024",
@@ -325,9 +345,9 @@ var IMAGE_MODELS = [
325
345
  },
326
346
  aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
327
347
  sizes: ["1K", "2K", "4K"],
328
- qualityOptions: ["auto", "low", "medium", "high"],
348
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
329
349
  references: { images: 16 },
330
- supports: ["quality", "count"]
350
+ supports: ["quality", "count", "outputFormat"]
331
351
  },
332
352
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
333
353
  usage: { ...IMAGE_USAGE },
@@ -346,7 +366,7 @@ var IMAGE_MODELS = [
346
366
  adapter: "openai-image",
347
367
  providerModelId: "gpt-image-2.5-flare",
348
368
  lifecycle: "active",
349
- exposure: "internal",
369
+ exposure: "catalog",
350
370
  constraints: {
351
371
  exactSizes: {
352
372
  "1:1": "1024x1024",
@@ -359,9 +379,9 @@ var IMAGE_MODELS = [
359
379
  },
360
380
  aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
361
381
  sizes: ["1K", "2K", "4K"],
362
- qualityOptions: ["auto", "low", "medium", "high"],
382
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
363
383
  references: { images: 16 },
364
- supports: ["quality", "count"]
384
+ supports: ["quality", "count", "outputFormat"]
365
385
  },
366
386
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
367
387
  usage: { ...IMAGE_USAGE },
@@ -391,8 +411,6 @@ var IMAGE_MODELS = [
391
411
  "2:3",
392
412
  "3:4",
393
413
  "9:16",
394
- "4:5",
395
- "5:4",
396
414
  "9:21",
397
415
  "adaptive"
398
416
  ],
@@ -424,7 +442,7 @@ var IMAGE_MODELS = [
424
442
  references: { images: 10 },
425
443
  // Ark's Images API has no output-format, quality or count field; only
426
444
  // the seed is forwarded, so anything else must warn, not vanish.
427
- supports: ["seed"]
445
+ supports: ["seed", "outputFormat"]
428
446
  },
429
447
  defaults: { size: "1K", aspectRatio: "1:1" },
430
448
  usage: { ...IMAGE_USAGE },
@@ -460,7 +478,7 @@ var IMAGE_MODELS = [
460
478
  "21:9",
461
479
  "9:21"
462
480
  ],
463
- sizes: ["1K", "2K", "4K"],
481
+ sizes: ["2K", "4K"],
464
482
  references: { images: 10 },
465
483
  supports: ["seed"]
466
484
  },
@@ -512,7 +530,7 @@ var IMAGE_MODELS = [
512
530
  aspectRatios: ["1:1", "2:3", "3:2", "4:3", "3:4", "4:5", "5:4", "9:16", "16:9", "21:9"],
513
531
  sizes: ["1K", "2K", "4K"],
514
532
  requires: ["references"],
515
- supports: ["seed"]
533
+ supports: []
516
534
  },
517
535
  defaults: { size: "1K", aspectRatio: "1:1" },
518
536
  usage: { ...IMAGE_USAGE },
@@ -537,7 +555,7 @@ var IMAGE_MODELS = [
537
555
  aspectRatios: ["1:1", "2:3", "3:4", "4:3", "9:16", "16:9", "21:9"],
538
556
  sizes: ["1K"],
539
557
  requires: ["references"],
540
- supports: ["seed"]
558
+ supports: []
541
559
  },
542
560
  defaults: { size: "1K", aspectRatio: "1:1" },
543
561
  usage: { ...IMAGE_USAGE },
@@ -589,7 +607,6 @@ var IMAGE_MODELS = [
589
607
  aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"],
590
608
  sizes: [],
591
609
  references: { images: 1 },
592
- requires: ["references"],
593
610
  supports: []
594
611
  },
595
612
  defaults: { aspectRatio: "1:1" },
@@ -1308,7 +1325,7 @@ var VIDEO_MODELS = [
1308
1325
  resolutions: ["720p", "1080p", "4k"],
1309
1326
  durations: [8],
1310
1327
  references: { images: 3 },
1311
- supports: ["lastFrame"]
1328
+ supports: ["lastFrame", "seed"]
1312
1329
  },
1313
1330
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1314
1331
  usage: { ...VIDEO_USAGE, slug: "veo" },
@@ -1336,9 +1353,9 @@ var VIDEO_MODELS = [
1336
1353
  constraints: {
1337
1354
  aspectRatios: [...OMNI_RATIOS],
1338
1355
  resolutions: ["720p", "1080p", "4k"],
1339
- durations: [4, 8],
1356
+ durations: [4, 6, 8],
1340
1357
  references: { images: 3 },
1341
- supports: ["lastFrame"]
1358
+ supports: ["lastFrame", "seed"]
1342
1359
  },
1343
1360
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1344
1361
  usage: { ...VIDEO_USAGE },
@@ -1365,9 +1382,8 @@ var VIDEO_MODELS = [
1365
1382
  constraints: {
1366
1383
  aspectRatios: [...OMNI_RATIOS],
1367
1384
  resolutions: ["720p", "1080p"],
1368
- durations: [4, 8],
1369
- references: { images: 3 },
1370
- supports: ["lastFrame"]
1385
+ durations: [4, 6, 8],
1386
+ supports: ["lastFrame", "seed"]
1371
1387
  },
1372
1388
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1373
1389
  usage: { ...VIDEO_USAGE },
@@ -1399,7 +1415,7 @@ var VIDEO_MODELS = [
1399
1415
  // reference clip keeps its own framing.
1400
1416
  aspectRatios: [...OMNI_RATIOS],
1401
1417
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1402
- references: { images: 6, videos: 1 },
1418
+ references: { images: 6, videos: 3 },
1403
1419
  supports: []
1404
1420
  },
1405
1421
  defaults: {},
@@ -1425,7 +1441,7 @@ var VIDEO_MODELS = [
1425
1441
  aspectRatios: [...OMNI_RATIOS],
1426
1442
  resolutions: ["360p", "720p", "1080p", "4k"],
1427
1443
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1428
- references: { images: 6, videos: 1 },
1444
+ references: { images: 6, videos: 3 },
1429
1445
  supports: []
1430
1446
  },
1431
1447
  defaults: {},
@@ -1454,7 +1470,7 @@ var VIDEO_MODELS = [
1454
1470
  durations: { min: 4, max: 15 },
1455
1471
  durationPresets: [4, 6, 8, 10, 12, 15],
1456
1472
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1457
- ratioIgnoredWith: ["firstFrame"],
1473
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1458
1474
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1459
1475
  },
1460
1476
  defaults: {
@@ -1486,7 +1502,7 @@ var VIDEO_MODELS = [
1486
1502
  resolutions: ["480p", "720p"],
1487
1503
  durations: { min: 4, max: 15 },
1488
1504
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1489
- ratioIgnoredWith: ["firstFrame"],
1505
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1490
1506
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1491
1507
  },
1492
1508
  defaults: {
@@ -1519,7 +1535,7 @@ var VIDEO_MODELS = [
1519
1535
  resolutions: ["480p", "720p", "1080p"],
1520
1536
  durations: { min: 4, max: 30 },
1521
1537
  references: { images: 30, videos: 10, audios: 10 },
1522
- ratioIgnoredWith: ["firstFrame"],
1538
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1523
1539
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1524
1540
  },
1525
1541
  defaults: {
@@ -1638,18 +1654,7 @@ var VIDEO_MODELS = [
1638
1654
  lifecycle: "active",
1639
1655
  exposure: "catalog",
1640
1656
  constraints: {
1641
- aspectRatios: [
1642
- "1:1",
1643
- "16:9",
1644
- "9:16",
1645
- "4:3",
1646
- "3:4",
1647
- "3:2",
1648
- "2:3",
1649
- "21:9",
1650
- "4:5",
1651
- "adaptive"
1652
- ],
1657
+ aspectRatios: [...KLING_RATIOS],
1653
1658
  resolutions: ["720p", "1080p"],
1654
1659
  durations: { min: 3, max: 15 },
1655
1660
  references: { images: 7 },
@@ -1869,6 +1874,417 @@ var MODELS = [
1869
1874
  ...OTHER_MODELS
1870
1875
  ];
1871
1876
 
1877
+ // src/catalog/schema.ts
1878
+ var import_zod = require("zod");
1879
+ var ADAPTER_IDS = [
1880
+ "ai-sdk-text",
1881
+ "google-image",
1882
+ "openai-image",
1883
+ "google-genai",
1884
+ "ark",
1885
+ "fal",
1886
+ "replicate",
1887
+ "prodia",
1888
+ "higgsfield",
1889
+ "xai-video"
1890
+ ];
1891
+ var ModelTypeSchema = import_zod.z.enum(["text", "image", "video", "audio", "upscale", "bg-remove"]);
1892
+ var LifecycleSchema = import_zod.z.enum(["active", "deprecated", "retired"]);
1893
+ var AdapterSchema = import_zod.z.enum(ADAPTER_IDS);
1894
+ var AspectRatioSchema = import_zod.z.enum([
1895
+ "1:1",
1896
+ "16:9",
1897
+ "9:16",
1898
+ "4:3",
1899
+ "3:4",
1900
+ "3:2",
1901
+ "2:3",
1902
+ "4:5",
1903
+ "5:4",
1904
+ "21:9",
1905
+ "9:21",
1906
+ "97:30",
1907
+ "adaptive"
1908
+ ]);
1909
+ var ImageSizeSchema = import_zod.z.enum(["512", "1K", "2K", "4K"]);
1910
+ var VideoResolutionSchema = import_zod.z.enum(["360p", "480p", "720p", "768p", "1080p", "2k", "4k"]);
1911
+ var ImageQualitySchema = import_zod.z.enum(["auto", "low", "medium", "high", "xhigh", "max"]);
1912
+ var OutputFormatSchema = import_zod.z.enum(["png", "jpeg", "webp"]);
1913
+ var RequiredInputSchema = import_zod.z.enum(["firstFrame", "sourceVideo", "references"]);
1914
+ var SupportedOptionSchema = import_zod.z.enum([
1915
+ "seed",
1916
+ "quality",
1917
+ "negativePrompt",
1918
+ "cfgScale",
1919
+ "generateAudio",
1920
+ "promptExpansion",
1921
+ "lastFrame",
1922
+ "count",
1923
+ "outputFormat",
1924
+ "scaleFactor",
1925
+ "safetySettings",
1926
+ "temperature",
1927
+ "upscale",
1928
+ "watermark",
1929
+ "safetyChecker",
1930
+ "instrumental"
1931
+ ]);
1932
+ var UsageUnitSchema = import_zod.z.enum([
1933
+ "tokens",
1934
+ "images",
1935
+ "seconds",
1936
+ "reported_cost_usd",
1937
+ "compute_seconds"
1938
+ ]);
1939
+ var PricingKindSchema = import_zod.z.enum(["token", "image_size", "video_per_second", "flat"]);
1940
+ var ProviderOptionValueSchema = import_zod.z.lazy(
1941
+ () => import_zod.z.union([
1942
+ import_zod.z.string(),
1943
+ import_zod.z.number(),
1944
+ import_zod.z.boolean(),
1945
+ import_zod.z.array(ProviderOptionValueSchema),
1946
+ import_zod.z.record(import_zod.z.string(), ProviderOptionValueSchema)
1947
+ ])
1948
+ );
1949
+ var ProviderOptionsSchema = import_zod.z.record(import_zod.z.string(), import_zod.z.record(import_zod.z.string(), ProviderOptionValueSchema));
1950
+ var ReferenceLimitsSchema = import_zod.z.looseObject({
1951
+ images: import_zod.z.number().optional(),
1952
+ videos: import_zod.z.number().optional(),
1953
+ audios: import_zod.z.number().optional(),
1954
+ total: import_zod.z.number().optional(),
1955
+ audioOnly: import_zod.z.boolean().optional()
1956
+ });
1957
+ var ModelConstraintsSchema = import_zod.z.looseObject({
1958
+ aspectRatios: import_zod.z.array(AspectRatioSchema).optional(),
1959
+ sizes: import_zod.z.array(ImageSizeSchema).optional(),
1960
+ resolutions: import_zod.z.array(VideoResolutionSchema).optional(),
1961
+ durations: import_zod.z.union([import_zod.z.looseObject({ min: import_zod.z.number(), max: import_zod.z.number() }), import_zod.z.array(import_zod.z.number())]).optional(),
1962
+ durationPresets: import_zod.z.array(import_zod.z.number()).optional(),
1963
+ qualityOptions: import_zod.z.array(import_zod.z.string()).optional(),
1964
+ exactSizes: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional(),
1965
+ references: ReferenceLimitsSchema.optional(),
1966
+ requires: import_zod.z.array(RequiredInputSchema).optional(),
1967
+ supports: import_zod.z.array(SupportedOptionSchema).optional(),
1968
+ ratioIgnoredWith: import_zod.z.array(import_zod.z.enum(["firstFrame", "sourceVideo"])).optional()
1969
+ });
1970
+ var MediaRefSchema = import_zod.z.union([
1971
+ import_zod.z.looseObject({ url: import_zod.z.string(), label: import_zod.z.string().optional() }),
1972
+ import_zod.z.looseObject({
1973
+ bytes: import_zod.z.instanceof(Uint8Array),
1974
+ mime: import_zod.z.string(),
1975
+ label: import_zod.z.string().optional()
1976
+ })
1977
+ ]);
1978
+ var ImageSafetySettingSchema = import_zod.z.looseObject({ category: import_zod.z.string(), threshold: import_zod.z.string() });
1979
+ var UpscaleOptionsSchema = import_zod.z.looseObject({
1980
+ enhanceModel: import_zod.z.string().optional(),
1981
+ subjectDetection: import_zod.z.string().optional(),
1982
+ faceEnhancement: import_zod.z.boolean().optional(),
1983
+ faceEnhancementCreativity: import_zod.z.number().optional(),
1984
+ faceEnhancementStrength: import_zod.z.number().optional()
1985
+ });
1986
+ var DefaultsSchema = import_zod.z.looseObject({
1987
+ references: import_zod.z.array(MediaRefSchema).optional(),
1988
+ aspectRatio: AspectRatioSchema.optional(),
1989
+ size: ImageSizeSchema.optional(),
1990
+ exactSize: import_zod.z.string().optional(),
1991
+ quality: ImageQualitySchema.optional(),
1992
+ seed: import_zod.z.number().optional(),
1993
+ count: import_zod.z.number().optional(),
1994
+ outputFormat: OutputFormatSchema.optional(),
1995
+ scaleFactor: import_zod.z.number().optional(),
1996
+ safetySettings: import_zod.z.array(ImageSafetySettingSchema).optional(),
1997
+ temperature: import_zod.z.number().optional(),
1998
+ upscale: UpscaleOptionsSchema.optional(),
1999
+ firstFrame: MediaRefSchema.optional(),
2000
+ lastFrame: MediaRefSchema.optional(),
2001
+ sourceVideo: MediaRefSchema.optional(),
2002
+ referenceImages: import_zod.z.array(MediaRefSchema).optional(),
2003
+ referenceVideos: import_zod.z.array(MediaRefSchema).optional(),
2004
+ referenceAudios: import_zod.z.array(MediaRefSchema).optional(),
2005
+ resolution: VideoResolutionSchema.optional(),
2006
+ durationSeconds: import_zod.z.number().optional(),
2007
+ generateAudio: import_zod.z.boolean().optional(),
2008
+ negativePrompt: import_zod.z.string().optional(),
2009
+ cfgScale: import_zod.z.number().optional(),
2010
+ promptExpansion: import_zod.z.enum(["fast", "balanced", "quality"]).optional(),
2011
+ watermark: import_zod.z.boolean().optional(),
2012
+ safetyChecker: import_zod.z.boolean().optional(),
2013
+ mode: import_zod.z.enum(["standard", "pro"]).optional(),
2014
+ instrumental: import_zod.z.boolean().optional()
2015
+ });
2016
+ var CatalogDisplaySchema = import_zod.z.looseObject({
2017
+ provider: import_zod.z.string(),
2018
+ description: import_zod.z.string(),
2019
+ logo: import_zod.z.string().optional(),
2020
+ costTier: import_zod.z.union([import_zod.z.literal(1), import_zod.z.literal(2), import_zod.z.literal(3)]).optional(),
2021
+ recommended: import_zod.z.boolean().optional(),
2022
+ sortOrder: import_zod.z.number().optional(),
2023
+ chat: import_zod.z.looseObject({
2024
+ providerOptions: ProviderOptionsSchema.optional(),
2025
+ temperature: import_zod.z.number().optional()
2026
+ }).optional()
2027
+ });
2028
+ var CatalogCapabilitiesSchema = import_zod.z.looseObject({
2029
+ acceptsSourceVideo: import_zod.z.boolean().optional(),
2030
+ framesExcludeReferences: import_zod.z.boolean().optional(),
2031
+ reasoning: import_zod.z.boolean().optional(),
2032
+ vision: import_zod.z.boolean().optional(),
2033
+ contextWindow: import_zod.z.number().optional()
2034
+ });
2035
+ var CatalogModelSchemaBase = import_zod.z.looseObject({
2036
+ id: import_zod.z.string().min(1),
2037
+ aliases: import_zod.z.array(import_zod.z.string()).default([]),
2038
+ label: import_zod.z.string().min(1),
2039
+ type: ModelTypeSchema,
2040
+ adapter: AdapterSchema,
2041
+ providerModelId: import_zod.z.string().min(1),
2042
+ lifecycle: LifecycleSchema,
2043
+ replacedBy: import_zod.z.string().optional(),
2044
+ exposure: import_zod.z.enum(["catalog", "internal"]),
2045
+ constraints: ModelConstraintsSchema,
2046
+ defaults: DefaultsSchema,
2047
+ providerOptions: ProviderOptionsSchema.optional(),
2048
+ usage: import_zod.z.looseObject({
2049
+ unit: UsageUnitSchema,
2050
+ slug: import_zod.z.string().optional(),
2051
+ providerLabel: import_zod.z.string().optional()
2052
+ }),
2053
+ pricingKind: PricingKindSchema,
2054
+ display: CatalogDisplaySchema.optional(),
2055
+ capabilities: CatalogCapabilitiesSchema.optional()
2056
+ }).superRefine((row, ctx) => {
2057
+ if (row.lifecycle === "active" && !row.display) {
2058
+ ctx.addIssue({
2059
+ code: "custom",
2060
+ path: ["display"],
2061
+ message: "active rows need display"
2062
+ });
2063
+ }
2064
+ if (row.lifecycle === "active" && row.type === "text" && !row.capabilities?.contextWindow) {
2065
+ ctx.addIssue({
2066
+ code: "custom",
2067
+ path: ["capabilities", "contextWindow"],
2068
+ message: "active text rows need contextWindow"
2069
+ });
2070
+ }
2071
+ if (row.replacedBy !== void 0 && row.replacedBy === row.id) {
2072
+ ctx.addIssue({
2073
+ code: "custom",
2074
+ path: ["replacedBy"],
2075
+ message: "replacedBy must not equal id"
2076
+ });
2077
+ }
2078
+ });
2079
+ var CatalogModelSchema = CatalogModelSchemaBase;
2080
+ var CatalogSchema = import_zod.z.array(CatalogModelSchemaBase).superRefine((rows, ctx) => {
2081
+ const seenIds = /* @__PURE__ */ new Map();
2082
+ rows.forEach((row, index) => {
2083
+ if (seenIds.has(row.id)) {
2084
+ ctx.addIssue({
2085
+ code: "custom",
2086
+ path: [index, "id"],
2087
+ message: `Duplicate model id "${row.id}"`
2088
+ });
2089
+ } else {
2090
+ seenIds.set(row.id, index);
2091
+ }
2092
+ });
2093
+ const seenAliases = /* @__PURE__ */ new Map();
2094
+ rows.forEach((row, index) => {
2095
+ row.aliases.forEach((alias, aliasIndex) => {
2096
+ const path = [index, "aliases", aliasIndex];
2097
+ if (alias === row.id || seenIds.has(alias)) {
2098
+ ctx.addIssue({
2099
+ code: "custom",
2100
+ path,
2101
+ message: `Alias "${alias}" collides with a model id`
2102
+ });
2103
+ return;
2104
+ }
2105
+ if (seenAliases.has(alias)) {
2106
+ ctx.addIssue({
2107
+ code: "custom",
2108
+ path,
2109
+ message: `Duplicate alias "${alias}"`
2110
+ });
2111
+ } else {
2112
+ seenAliases.set(alias, index);
2113
+ }
2114
+ });
2115
+ });
2116
+ });
2117
+
2118
+ // src/catalog/live.ts
2119
+ var KEY = /* @__PURE__ */ Symbol.for("@shop-os/modelkit/live-catalog");
2120
+ var store = globalThis;
2121
+ var liveState = store[KEY] ??= {
2122
+ catalog: new Catalog(MODELS),
2123
+ memo: void 0,
2124
+ timer: void 0,
2125
+ revision: void 0,
2126
+ origin: "snapshot"
2127
+ };
2128
+ var liveCatalog = liveState.catalog;
2129
+
2130
+ // src/catalog/load.ts
2131
+ function rowCount() {
2132
+ return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
2133
+ }
2134
+ function authHeaders(auth) {
2135
+ return "bearer" in auth ? { Authorization: `Bearer ${auth.bearer}` } : { "x-api-key": auth.apiKey };
2136
+ }
2137
+ function describeError(err) {
2138
+ return err instanceof Error ? err.message : String(err);
2139
+ }
2140
+ function parseEnvelope(json) {
2141
+ if (typeof json !== "object" || json === null || !("rows" in json)) {
2142
+ throw new Error("invalid catalog response: missing rows");
2143
+ }
2144
+ const rows = CatalogSchema.parse(json.rows);
2145
+ const rev = json.revision;
2146
+ if (typeof rev === "string") return { rows, revision: rev };
2147
+ return { rows };
2148
+ }
2149
+ function logPrimed(logger, result) {
2150
+ const { origin: loggedOrigin, rowCount: loggedCount, revision: loggedRevision } = result;
2151
+ logger.info("[modelkit] catalog primed", {
2152
+ origin: loggedOrigin,
2153
+ rowCount: loggedCount,
2154
+ revision: loggedRevision
2155
+ });
2156
+ }
2157
+ async function fetchRemote(source, logger) {
2158
+ const fetchImpl = source.fetch ?? globalThis.fetch;
2159
+ const headers2 = authHeaders(source.auth);
2160
+ if (liveState.revision !== void 0) headers2["If-None-Match"] = `"${liveState.revision}"`;
2161
+ const res = await fetchImpl(`${source.baseUrl}/models/catalog`, {
2162
+ headers: headers2,
2163
+ signal: AbortSignal.timeout(source.timeoutMs ?? 1e4)
2164
+ });
2165
+ if (res.status === 304) return { kept: true };
2166
+ if (!res.ok) throw new Error(`catalog fetch failed with status ${res.status}`);
2167
+ const json = await res.json();
2168
+ const { rows, revision: rev } = parseEnvelope(json);
2169
+ if (rev === void 0) return { rows, fromCache: false };
2170
+ return { rows, revision: rev, fromCache: false };
2171
+ }
2172
+ async function writeCache(source, logger, rows, rev) {
2173
+ if (!source.cache) return;
2174
+ try {
2175
+ await source.cache.set(JSON.stringify({ rows, revision: rev }));
2176
+ } catch (err) {
2177
+ logger.warn("[modelkit] catalog cache write failed", err);
2178
+ }
2179
+ }
2180
+ async function prime(source, logger) {
2181
+ try {
2182
+ const fetched = await fetchRemote(source, logger);
2183
+ if ("kept" in fetched) {
2184
+ const result2 = { origin: liveState.origin, rowCount: rowCount() };
2185
+ if (liveState.revision !== void 0) result2.revision = liveState.revision;
2186
+ logPrimed(logger, result2);
2187
+ return result2;
2188
+ }
2189
+ liveCatalog.replace(fetched.rows);
2190
+ liveState.origin = "remote";
2191
+ liveState.revision = fetched.revision;
2192
+ await writeCache(source, logger, fetched.rows, fetched.revision);
2193
+ const result = { origin: liveState.origin, rowCount: rowCount() };
2194
+ if (fetched.revision !== void 0) result.revision = fetched.revision;
2195
+ logPrimed(logger, result);
2196
+ return result;
2197
+ } catch (err) {
2198
+ logger.warn("[modelkit] catalog remote failed, trying cache", err);
2199
+ const error = describeError(err);
2200
+ try {
2201
+ const cached = await source.cache?.get();
2202
+ if (!cached) throw new Error("no cached catalog");
2203
+ const { rows, revision: rev } = parseEnvelope(JSON.parse(cached));
2204
+ liveCatalog.replace(rows);
2205
+ liveState.origin = "last-good";
2206
+ liveState.revision = rev;
2207
+ const result = {
2208
+ origin: liveState.origin,
2209
+ rowCount: rowCount(),
2210
+ error
2211
+ };
2212
+ if (rev !== void 0) result.revision = rev;
2213
+ logPrimed(logger, result);
2214
+ return result;
2215
+ } catch (cacheErr) {
2216
+ logger.warn("[modelkit] catalog cache failed, using snapshot", cacheErr);
2217
+ liveCatalog.replace([...MODELS]);
2218
+ liveState.origin = "snapshot";
2219
+ liveState.revision = void 0;
2220
+ const result = {
2221
+ origin: liveState.origin,
2222
+ rowCount: rowCount(),
2223
+ error
2224
+ };
2225
+ logPrimed(logger, result);
2226
+ return result;
2227
+ }
2228
+ }
2229
+ }
2230
+ async function refresh(source, logger) {
2231
+ try {
2232
+ const fetched = await fetchRemote(source, logger);
2233
+ if ("kept" in fetched) return;
2234
+ liveCatalog.replace(fetched.rows);
2235
+ liveState.origin = "remote";
2236
+ liveState.revision = fetched.revision;
2237
+ await writeCache(source, logger, fetched.rows, fetched.revision);
2238
+ } catch (err) {
2239
+ logger.warn("[modelkit] catalog refresh failed, keeping current rows", err);
2240
+ }
2241
+ }
2242
+ function primeCatalog(source) {
2243
+ const memo = liveState.memo;
2244
+ if (memo) return memo;
2245
+ const logger = source.logger ?? console;
2246
+ liveState.memo = prime(source, logger).then((result) => {
2247
+ const ttlMs = source.ttlMs ?? 3e5;
2248
+ if (ttlMs > 0 && liveState.timer === void 0) {
2249
+ liveState.timer = setInterval(() => void refresh(source, logger), ttlMs);
2250
+ const maybeUnref = liveState.timer;
2251
+ maybeUnref.unref?.();
2252
+ }
2253
+ return result;
2254
+ });
2255
+ return liveState.memo;
2256
+ }
2257
+ function resetLiveCatalog() {
2258
+ if (liveState.timer !== void 0) {
2259
+ clearInterval(liveState.timer);
2260
+ liveState.timer = void 0;
2261
+ }
2262
+ liveState.memo = void 0;
2263
+ liveState.revision = void 0;
2264
+ liveState.origin = "snapshot";
2265
+ liveCatalog.replace([...MODELS]);
2266
+ }
2267
+
2268
+ // src/catalog/file-cache.ts
2269
+ var import_promises = require("fs/promises");
2270
+ function fileCatalogCache(path) {
2271
+ return {
2272
+ async get() {
2273
+ try {
2274
+ return await (0, import_promises.readFile)(path, "utf8");
2275
+ } catch (err) {
2276
+ if (err?.code === "ENOENT") return null;
2277
+ throw err;
2278
+ }
2279
+ },
2280
+ async set(json) {
2281
+ const tmp = `${path}.tmp`;
2282
+ await (0, import_promises.writeFile)(tmp, json, "utf8");
2283
+ await (0, import_promises.rename)(tmp, path);
2284
+ }
2285
+ };
2286
+ }
2287
+
1872
2288
  // src/resolve-options.ts
1873
2289
  var SIZE_ORDER = ["512", "1K", "2K", "4K"];
1874
2290
  var RESOLUTION_ORDER = ["360p", "480p", "720p", "768p", "1080p", "2k", "4k"];
@@ -2294,21 +2710,21 @@ function keysFromEnv(env, prefix = "") {
2294
2710
  }
2295
2711
 
2296
2712
  // src/retry.ts
2297
- var import_zod2 = require("zod");
2713
+ var import_zod3 = require("zod");
2298
2714
 
2299
2715
  // src/json.ts
2300
- var import_zod = require("zod");
2301
- var JsonValueSchema = import_zod.z.lazy(
2302
- () => import_zod.z.union([
2303
- import_zod.z.string(),
2304
- import_zod.z.number(),
2305
- import_zod.z.boolean(),
2306
- import_zod.z.null(),
2307
- import_zod.z.array(JsonValueSchema),
2308
- import_zod.z.record(import_zod.z.string(), JsonValueSchema)
2716
+ var import_zod2 = require("zod");
2717
+ var JsonValueSchema = import_zod2.z.lazy(
2718
+ () => import_zod2.z.union([
2719
+ import_zod2.z.string(),
2720
+ import_zod2.z.number(),
2721
+ import_zod2.z.boolean(),
2722
+ import_zod2.z.null(),
2723
+ import_zod2.z.array(JsonValueSchema),
2724
+ import_zod2.z.record(import_zod2.z.string(), JsonValueSchema)
2309
2725
  ])
2310
2726
  );
2311
- var JsonObjectSchema = import_zod.z.record(import_zod.z.string(), JsonValueSchema);
2727
+ var JsonObjectSchema = import_zod2.z.record(import_zod2.z.string(), JsonValueSchema);
2312
2728
  async function readErrorBody(res) {
2313
2729
  const text2 = await res.text().catch(() => "");
2314
2730
  try {
@@ -2317,11 +2733,11 @@ async function readErrorBody(res) {
2317
2733
  return text2;
2318
2734
  }
2319
2735
  }
2320
- var thrownErrorSchema = import_zod.z.object({
2321
- message: import_zod.z.string().optional(),
2322
- status: import_zod.z.number().optional(),
2323
- statusCode: import_zod.z.number().optional(),
2324
- responseBody: import_zod.z.string().optional()
2736
+ var thrownErrorSchema = import_zod2.z.object({
2737
+ message: import_zod2.z.string().optional(),
2738
+ status: import_zod2.z.number().optional(),
2739
+ statusCode: import_zod2.z.number().optional(),
2740
+ responseBody: import_zod2.z.string().optional()
2325
2741
  });
2326
2742
  function describeThrown(cause) {
2327
2743
  const parsed = thrownErrorSchema.safeParse(cause);
@@ -2332,7 +2748,7 @@ function describeThrown(cause) {
2332
2748
  }
2333
2749
 
2334
2750
  // src/retry.ts
2335
- var textBody = import_zod2.z.string();
2751
+ var textBody = import_zod3.z.string();
2336
2752
  function classifyHttpError(status, body, provider, model) {
2337
2753
  const asText = textBody.safeParse(body);
2338
2754
  const text2 = asText.success ? asText.data : JSON.stringify(body);
@@ -2540,7 +2956,7 @@ function createTextSteps(initial, resolve, callerProviderOptions) {
2540
2956
 
2541
2957
  // src/client.ts
2542
2958
  var import_ai2 = require("ai");
2543
- var import_zod4 = require("zod");
2959
+ var import_zod5 = require("zod");
2544
2960
 
2545
2961
  // src/adapters/media-ref.ts
2546
2962
  function isUrlRef(ref) {
@@ -2625,7 +3041,7 @@ var import_perplexity = require("@ai-sdk/perplexity");
2625
3041
  var import_xai = require("@ai-sdk/xai");
2626
3042
  var import_deepseek = require("@ai-sdk/deepseek");
2627
3043
  var import_moonshotai = require("@ai-sdk/moonshotai");
2628
- var import_zod3 = require("zod");
3044
+ var import_zod4 = require("zod");
2629
3045
  var TEXT_PROVIDERS = [
2630
3046
  "openai",
2631
3047
  "anthropic",
@@ -2636,7 +3052,7 @@ var TEXT_PROVIDERS = [
2636
3052
  "moonshot",
2637
3053
  "minimax"
2638
3054
  ];
2639
- var textProviderSchema = import_zod3.z.enum(TEXT_PROVIDERS);
3055
+ var textProviderSchema = import_zod4.z.enum(TEXT_PROVIDERS);
2640
3056
  function isTextProvider(value) {
2641
3057
  return textProviderSchema.safeParse(value).success;
2642
3058
  }
@@ -2806,10 +3222,10 @@ function textAbortOptions(sdk, context) {
2806
3222
  if (abortSignal) return { abortSignal };
2807
3223
  return {};
2808
3224
  }
2809
- var catalogId = import_zod4.z.string();
2810
- var exactSize = import_zod4.z.templateLiteral([import_zod4.z.number(), "x", import_zod4.z.number()]);
2811
- var sdkRatio = import_zod4.z.templateLiteral([import_zod4.z.number(), ":", import_zod4.z.number()]);
2812
- var sizeTier = import_zod4.z.enum(["512", "1K", "2K", "4K"]);
3225
+ var catalogId = import_zod5.z.string();
3226
+ var exactSize = import_zod5.z.templateLiteral([import_zod5.z.number(), "x", import_zod5.z.number()]);
3227
+ var sdkRatio = import_zod5.z.templateLiteral([import_zod5.z.number(), ":", import_zod5.z.number()]);
3228
+ var sizeTier = import_zod5.z.enum(["512", "1K", "2K", "4K"]);
2813
3229
  function isCatalogId(model) {
2814
3230
  return catalogId.safeParse(model).success;
2815
3231
  }
@@ -2876,7 +3292,7 @@ function logCoercions(logger, modelId, warnings) {
2876
3292
  logger.warn(`[modelkit] ${modelId} request coerced`, { model: modelId, warnings });
2877
3293
  }
2878
3294
  function createModelKit(config, adapters) {
2879
- const catalog = new Catalog(MODELS).withOverrides(config.catalogOverride ?? []);
3295
+ const catalog = config.catalogOverride ? liveCatalog.withOverrides(config.catalogOverride) : liveCatalog;
2880
3296
  const logger = config.logger ?? console;
2881
3297
  const fetchImpl = config.fetch ?? globalThis.fetch;
2882
3298
  function context(model, call, warnings) {
@@ -3330,7 +3746,7 @@ function createModelKit(config, adapters) {
3330
3746
  }
3331
3747
 
3332
3748
  // src/adapters/ark.ts
3333
- var import_zod5 = require("zod");
3749
+ var import_zod6 = require("zod");
3334
3750
  var ARK_BASE_URL = "https://ark.ap-southeast.bytepluses.com/api/v3";
3335
3751
  var SUBMIT_PATH = "/contents/generations/tasks";
3336
3752
  var SEEDANCE_POLL_INTERVAL_MS = 15e3;
@@ -3407,7 +3823,7 @@ function arkKey(ctx) {
3407
3823
  return key;
3408
3824
  }
3409
3825
  function throwArkError(status, body, model) {
3410
- const parsed = import_zod5.z.string().safeParse(body);
3826
+ const parsed = import_zod6.z.string().safeParse(body);
3411
3827
  const text2 = parsed.success ? parsed.data : JSON.stringify(body ?? "");
3412
3828
  if (/sensitive.?content|human.?face/i.test(text2)) {
3413
3829
  const init = {
@@ -3445,13 +3861,13 @@ function sniffedImageMime(bytes) {
3445
3861
  return "image/webp";
3446
3862
  return "image/jpeg";
3447
3863
  }
3448
- var SeedreamImageSchema = import_zod5.z.object({
3449
- url: import_zod5.z.string().optional(),
3450
- b64_json: import_zod5.z.string().optional()
3864
+ var SeedreamImageSchema = import_zod6.z.object({
3865
+ url: import_zod6.z.string().optional(),
3866
+ b64_json: import_zod6.z.string().optional()
3451
3867
  });
3452
- var SeedreamResponseSchema = import_zod5.z.object({
3453
- data: import_zod5.z.array(SeedreamImageSchema).optional(),
3454
- error: import_zod5.z.object({ message: import_zod5.z.string().optional(), code: import_zod5.z.string().optional() }).optional()
3868
+ var SeedreamResponseSchema = import_zod6.z.object({
3869
+ data: import_zod6.z.array(SeedreamImageSchema).optional(),
3870
+ error: import_zod6.z.object({ message: import_zod6.z.string().optional(), code: import_zod6.z.string().optional() }).optional()
3455
3871
  });
3456
3872
  function retryOptsFor(ctx, attempts = 3) {
3457
3873
  const opts = { attempts };
@@ -3480,6 +3896,18 @@ async function generateSeedreamImage(req, ctx) {
3480
3896
  watermark: false
3481
3897
  };
3482
3898
  if (req.seed !== void 0) body.seed = req.seed;
3899
+ if (req.outputFormat !== void 0) {
3900
+ if (req.outputFormat === "webp") {
3901
+ ctx.warnings.push({
3902
+ code: "option_ignored",
3903
+ field: "outputFormat",
3904
+ from: "webp",
3905
+ to: "png",
3906
+ message: `${modelId} accepts png or jpeg output; using png`
3907
+ });
3908
+ }
3909
+ body.output_format = req.outputFormat === "jpeg" ? "jpeg" : "png";
3910
+ }
3483
3911
  const firstRef = refs[0];
3484
3912
  if (refs.length === 1 && firstRef !== void 0) body.image = firstRef;
3485
3913
  else if (refs.length > 1) body.image = refs;
@@ -3523,21 +3951,21 @@ async function generateSeedreamImage(req, ctx) {
3523
3951
  if (req.quality !== void 0) usage2.imageQuality = req.quality;
3524
3952
  return { images: [{ bytes, mime: sniffedImageMime(bytes) }], usage: usage2, raw: data };
3525
3953
  }
3526
- var SeedanceUsageSchema = import_zod5.z.object({
3527
- total_tokens: import_zod5.z.number().optional(),
3528
- completion_tokens: import_zod5.z.number().optional()
3954
+ var SeedanceUsageSchema = import_zod6.z.object({
3955
+ total_tokens: import_zod6.z.number().optional(),
3956
+ completion_tokens: import_zod6.z.number().optional()
3529
3957
  });
3530
- var SeedanceResponseSchema = import_zod5.z.object({
3531
- id: import_zod5.z.string().optional(),
3532
- status: import_zod5.z.string().optional(),
3533
- content: import_zod5.z.object({ video_url: import_zod5.z.string().optional() }).optional(),
3958
+ var SeedanceResponseSchema = import_zod6.z.object({
3959
+ id: import_zod6.z.string().optional(),
3960
+ status: import_zod6.z.string().optional(),
3961
+ content: import_zod6.z.object({ video_url: import_zod6.z.string().optional() }).optional(),
3534
3962
  usage: SeedanceUsageSchema.optional(),
3535
- duration: import_zod5.z.number().optional(),
3536
- framespersecond: import_zod5.z.number().optional(),
3537
- resolution: import_zod5.z.string().optional(),
3538
- error: import_zod5.z.union([import_zod5.z.string(), import_zod5.z.object({ message: import_zod5.z.string().optional() })]).optional()
3963
+ duration: import_zod6.z.number().optional(),
3964
+ framespersecond: import_zod6.z.number().optional(),
3965
+ resolution: import_zod6.z.string().optional(),
3966
+ error: import_zod6.z.union([import_zod6.z.string(), import_zod6.z.object({ message: import_zod6.z.string().optional() })]).optional()
3539
3967
  });
3540
- var SeedanceErrorMessageSchema = import_zod5.z.object({ message: import_zod5.z.string().optional() });
3968
+ var SeedanceErrorMessageSchema = import_zod6.z.object({ message: import_zod6.z.string().optional() });
3541
3969
  function seedanceUsage(ctx, req, duration) {
3542
3970
  const usage2 = {
3543
3971
  model: ctx.model.id,
@@ -3551,7 +3979,7 @@ function seedanceUsage(ctx, req, duration) {
3551
3979
  return usage2;
3552
3980
  }
3553
3981
  function seedanceErrorMessage(error, status) {
3554
- const asString = import_zod5.z.string().safeParse(error);
3982
+ const asString = import_zod6.z.string().safeParse(error);
3555
3983
  if (asString.success) return asString.data;
3556
3984
  const asObject = SeedanceErrorMessageSchema.safeParse(error);
3557
3985
  if (asObject.success && asObject.data.message !== void 0) return asObject.data.message;
@@ -3700,7 +4128,7 @@ async function generateSeedanceVideo(req, ctx) {
3700
4128
  }
3701
4129
 
3702
4130
  // src/adapters/fal.ts
3703
- var import_zod6 = require("zod");
4131
+ var import_zod7 = require("zod");
3704
4132
  var import_client = require("@fal-ai/client");
3705
4133
  var MUSE_T2I_ENDPOINT = "meta/muse-image/text-to-image";
3706
4134
  var MUSE_EDIT_ENDPOINT = "meta/muse-image/edit";
@@ -3708,7 +4136,7 @@ var KLING_O1_ENDPOINT = "fal-ai/kling-video/o1/video-to-video/reference";
3708
4136
  var FAL_QUEUE_HOST = "https://queue.fal.run";
3709
4137
  var PASSTHROUGH_POLL_MS = 2e3;
3710
4138
  var PASSTHROUGH_MAX_WAIT_MS = 18e4;
3711
- var falSubscribePayloadSchema = import_zod6.z.object({ data: JsonValueSchema });
4139
+ var falSubscribePayloadSchema = import_zod7.z.object({ data: JsonValueSchema });
3712
4140
  function defaultCreateFalClient(opts) {
3713
4141
  const client2 = (0, import_client.createFalClient)(opts);
3714
4142
  return {
@@ -3758,7 +4186,7 @@ function createFalAdapter(deps = defaultDeps) {
3758
4186
  };
3759
4187
  }
3760
4188
  var falAdapter = createFalAdapter();
3761
- var falDetailSchema = import_zod6.z.object({ detail: JsonValueSchema });
4189
+ var falDetailSchema = import_zod7.z.object({ detail: JsonValueSchema });
3762
4190
  function liftDetail(body) {
3763
4191
  const parsed = falDetailSchema.safeParse(body);
3764
4192
  const detail = parsed.success ? parsed.data.detail : void 0;
@@ -3767,11 +4195,11 @@ function liftDetail(body) {
3767
4195
  function falError(status, body, model) {
3768
4196
  return classifyHttpError(status, liftDetail(body), "fal", model);
3769
4197
  }
3770
- var falSdkThrownSchema = import_zod6.z.object({
3771
- status: import_zod6.z.number().optional(),
3772
- statusCode: import_zod6.z.number().optional(),
4198
+ var falSdkThrownSchema = import_zod7.z.object({
4199
+ status: import_zod7.z.number().optional(),
4200
+ statusCode: import_zod7.z.number().optional(),
3773
4201
  body: JsonValueSchema.optional(),
3774
- message: import_zod6.z.string().optional()
4202
+ message: import_zod7.z.string().optional()
3775
4203
  });
3776
4204
  function falSdkError(cause, model) {
3777
4205
  const parsed = falSdkThrownSchema.safeParse(cause);
@@ -3815,12 +4243,12 @@ async function gatewayFetch(cfg, fetchImpl, targetUrl, init) {
3815
4243
  if (init.body !== void 0) request.body = init.body;
3816
4244
  return fetchImpl(cfg.baseUrl, request);
3817
4245
  }
3818
- var falQueueSubmitSchema = import_zod6.z.object({
3819
- request_id: import_zod6.z.string(),
3820
- status_url: import_zod6.z.string(),
3821
- response_url: import_zod6.z.string()
4246
+ var falQueueSubmitSchema = import_zod7.z.object({
4247
+ request_id: import_zod7.z.string(),
4248
+ status_url: import_zod7.z.string(),
4249
+ response_url: import_zod7.z.string()
3822
4250
  });
3823
- var falQueueStatusSchema = import_zod6.z.object({ status: import_zod6.z.string() });
4251
+ var falQueueStatusSchema = import_zod7.z.object({ status: import_zod7.z.string() });
3824
4252
  async function passthroughRequest(ctx, endpoint, input) {
3825
4253
  const cfg = gatewayConfig(ctx);
3826
4254
  const submitRes = await gatewayFetch(cfg, ctx.fetch, `${FAL_QUEUE_HOST}/${endpoint}`, {
@@ -3946,11 +4374,11 @@ async function decodeImage(ctx, url, contentType) {
3946
4374
  const mime = res.headers.get("content-type") ?? contentType ?? "image/png";
3947
4375
  return { bytes: new Uint8Array(await res.arrayBuffer()), mime };
3948
4376
  }
3949
- var museImageResultSchema = import_zod6.z.object({
3950
- images: import_zod6.z.array(
3951
- import_zod6.z.object({
3952
- url: import_zod6.z.string().optional(),
3953
- content_type: import_zod6.z.string().nullable().optional()
4377
+ var museImageResultSchema = import_zod7.z.object({
4378
+ images: import_zod7.z.array(
4379
+ import_zod7.z.object({
4380
+ url: import_zod7.z.string().optional(),
4381
+ content_type: import_zod7.z.string().nullable().optional()
3954
4382
  })
3955
4383
  ).optional()
3956
4384
  });
@@ -4042,8 +4470,8 @@ function klingO1Input(req) {
4042
4470
  if (refs.length > 0) input.image_urls = refs;
4043
4471
  return input;
4044
4472
  }
4045
- var falVideoResultSchema = import_zod6.z.object({
4046
- video: import_zod6.z.object({ url: import_zod6.z.string().optional() }).optional()
4473
+ var falVideoResultSchema = import_zod7.z.object({
4474
+ video: import_zod7.z.object({ url: import_zod7.z.string().optional() }).optional()
4047
4475
  });
4048
4476
  function extractVideoUrl(result, endpoint, model) {
4049
4477
  const parsed = falVideoResultSchema.safeParse(result);
@@ -4233,11 +4661,11 @@ async function passthroughVideoJob(ctx, req, endpoint, input) {
4233
4661
  }
4234
4662
 
4235
4663
  // src/adapters/google-genai.ts
4236
- var import_zod8 = require("zod");
4664
+ var import_zod9 = require("zod");
4237
4665
  var import_genai = require("@google/genai");
4238
4666
 
4239
4667
  // src/adapters/google-files.ts
4240
- var import_zod7 = require("zod");
4668
+ var import_zod8 = require("zod");
4241
4669
  var GOOGLE_FILES_BASE = "https://generativelanguage.googleapis.com";
4242
4670
  var GOOGLE_FILES_POLL_INTERVAL_MS = 2e3;
4243
4671
  var GOOGLE_FILES_POLL_TIMEOUT_MS = 5 * 60 * 1e3;
@@ -4247,17 +4675,17 @@ var GENERIC_MEDIA_TYPES = /* @__PURE__ */ new Set([
4247
4675
  "binary/octet-stream",
4248
4676
  "application/binary"
4249
4677
  ]);
4250
- var uploadedFileSchema = import_zod7.z.object({
4251
- file: import_zod7.z.object({
4252
- uri: import_zod7.z.string().optional(),
4253
- name: import_zod7.z.string().optional(),
4254
- state: import_zod7.z.string().optional(),
4255
- mimeType: import_zod7.z.string().optional()
4678
+ var uploadedFileSchema = import_zod8.z.object({
4679
+ file: import_zod8.z.object({
4680
+ uri: import_zod8.z.string().optional(),
4681
+ name: import_zod8.z.string().optional(),
4682
+ state: import_zod8.z.string().optional(),
4683
+ mimeType: import_zod8.z.string().optional()
4256
4684
  }).optional()
4257
4685
  });
4258
- var fileStateSchema = import_zod7.z.object({
4259
- state: import_zod7.z.string().optional(),
4260
- error: import_zod7.z.object({ message: import_zod7.z.string().optional() }).optional()
4686
+ var fileStateSchema = import_zod8.z.object({
4687
+ state: import_zod8.z.string().optional(),
4688
+ error: import_zod8.z.object({ message: import_zod8.z.string().optional() }).optional()
4261
4689
  });
4262
4690
  function resolveMime(declared, fallback) {
4263
4691
  const clean = declared?.split(";")[0]?.trim().toLowerCase();
@@ -4470,7 +4898,7 @@ var OMNI_POLL_INTERVAL_MS = 1e4;
4470
4898
  var RESULT_TIMEOUT_MS2 = 15 * 60 * 1e3;
4471
4899
  var OMNI_INLINE_LIMIT_BYTES = 4 * 1024 * 1024;
4472
4900
  var MEDIA_PART_INLINE_LIMIT_BYTES = 20 * 1024 * 1024;
4473
- var errorTextSchema = import_zod8.z.string();
4901
+ var errorTextSchema = import_zod9.z.string();
4474
4902
  function createGoogleGenaiAdapter(deps = defaultDeps2) {
4475
4903
  const { createGenAIClient } = deps;
4476
4904
  return {
@@ -4623,6 +5051,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
4623
5051
  const config = { durationSeconds: duration, personGeneration };
4624
5052
  if (req.aspectRatio !== void 0) config.aspectRatio = req.aspectRatio;
4625
5053
  if (req.resolution !== void 0) config.resolution = req.resolution;
5054
+ if (req.seed !== void 0) config.seed = req.seed;
4626
5055
  if (lastFrame !== void 0) config.lastFrame = lastFrame;
4627
5056
  if (referenceImages !== void 0) config.referenceImages = referenceImages;
4628
5057
  const requestBody = {
@@ -5028,15 +5457,15 @@ async function prepareGoogleMediaPart(ref, mediaType, ctx) {
5028
5457
  // src/adapters/google-image.ts
5029
5458
  var import_google2 = require("@ai-sdk/google");
5030
5459
  var import_ai3 = require("ai");
5031
- var import_zod9 = require("zod");
5460
+ var import_zod10 = require("zod");
5032
5461
  var GEMINI_IMAGE_TIMEOUT_MS = 6e5;
5033
5462
  var defaultGoogleImageDeps = {
5034
5463
  createGoogleClient: (opts) => (0, import_google2.createGoogleGenerativeAI)(opts),
5035
5464
  runTextGeneration: (opts) => (0, import_ai3.generateText)(opts)
5036
5465
  };
5037
- var causeChainNodeSchema = import_zod9.z.object({
5038
- message: import_zod9.z.string().optional(),
5039
- cause: import_zod9.z.unknown().optional()
5466
+ var causeChainNodeSchema = import_zod10.z.object({
5467
+ message: import_zod10.z.string().optional(),
5468
+ cause: import_zod10.z.unknown().optional()
5040
5469
  });
5041
5470
  function extractBlockReason(cause) {
5042
5471
  let current = cause;
@@ -5157,7 +5586,7 @@ function createGoogleImageAdapter(deps = defaultGoogleImageDeps) {
5157
5586
  var googleImageAdapter = createGoogleImageAdapter();
5158
5587
 
5159
5588
  // src/adapters/higgsfield.ts
5160
- var import_zod10 = require("zod");
5589
+ var import_zod11 = require("zod");
5161
5590
 
5162
5591
  // src/adapters/higgsfield-motions.ts
5163
5592
  var MOTION_MAP = {
@@ -5345,14 +5774,14 @@ function videoUsage3(ctx, req, duration) {
5345
5774
  if (req.durationSeconds !== void 0) event.durationSeconds = req.durationSeconds;
5346
5775
  return event;
5347
5776
  }
5348
- var klingCreateSchema = import_zod10.z.object({ status_url: import_zod10.z.string() });
5349
- var klingStatusSchema = import_zod10.z.object({
5350
- status: import_zod10.z.string().optional(),
5351
- video: import_zod10.z.object({ url: import_zod10.z.string().optional() }).optional(),
5777
+ var klingCreateSchema = import_zod11.z.object({ status_url: import_zod11.z.string() });
5778
+ var klingStatusSchema = import_zod11.z.object({
5779
+ status: import_zod11.z.string().optional(),
5780
+ video: import_zod11.z.object({ url: import_zod11.z.string().optional() }).optional(),
5352
5781
  error: JsonValueSchema.optional()
5353
5782
  });
5354
- var errorMessageSchema = import_zod10.z.object({ message: import_zod10.z.string().optional() });
5355
- var textValueSchema = import_zod10.z.string();
5783
+ var errorMessageSchema = import_zod11.z.object({ message: import_zod11.z.string().optional() });
5784
+ var textValueSchema = import_zod11.z.string();
5356
5785
  function klingErrorDetail(error) {
5357
5786
  if (error === void 0) return "unknown_error";
5358
5787
  const asText = textValueSchema.safeParse(error);
@@ -5486,8 +5915,8 @@ async function generateKlingVideo(req, ctx) {
5486
5915
  }
5487
5916
  };
5488
5917
  }
5489
- var dopMotionOptionsSchema = import_zod10.z.object({
5490
- modelkit: import_zod10.z.object({ motion: import_zod10.z.string().optional() }).optional()
5918
+ var dopMotionOptionsSchema = import_zod11.z.object({
5919
+ modelkit: import_zod11.z.object({ motion: import_zod11.z.string().optional() }).optional()
5491
5920
  });
5492
5921
  function dopMotionId(ctx) {
5493
5922
  const parsed = dopMotionOptionsSchema.safeParse(ctx.model.providerOptions);
@@ -5503,7 +5932,7 @@ function dopMotionId(ctx) {
5503
5932
  });
5504
5933
  return id;
5505
5934
  }
5506
- var jsonRecordSchema = import_zod10.z.record(import_zod10.z.string(), JsonValueSchema);
5935
+ var jsonRecordSchema = import_zod11.z.record(import_zod11.z.string(), JsonValueSchema);
5507
5936
  var DOP_URL_KEYS = ["url", "video_url", "output_url", "result_url", "download_url"];
5508
5937
  var DOP_NESTED_KEYS = ["video", "result", "results"];
5509
5938
  function dopUrl(body) {
@@ -5531,8 +5960,8 @@ function dopUrl(body) {
5531
5960
  }
5532
5961
  return void 0;
5533
5962
  }
5534
- var dopCreateSchema = import_zod10.z.object({ id: import_zod10.z.string() });
5535
- var dopStatusSchema = import_zod10.z.object({ status: import_zod10.z.string().optional() });
5963
+ var dopCreateSchema = import_zod11.z.object({ id: import_zod11.z.string() });
5964
+ var dopStatusSchema = import_zod11.z.object({ status: import_zod11.z.string().optional() });
5536
5965
  async function generateDopVideo(req, ctx) {
5537
5966
  const firstFrame = req.firstFrame ? refToUrl(req.firstFrame) : void 0;
5538
5967
  if (!firstFrame) {
@@ -5652,7 +6081,7 @@ var higgsfieldAdapter = {
5652
6081
 
5653
6082
  // src/adapters/openai-image.ts
5654
6083
  var import_openai2 = __toESM(require("openai"), 1);
5655
- var import_zod11 = require("zod");
6084
+ var import_zod12 = require("zod");
5656
6085
  var MAX_EDIT_REFERENCES = 16;
5657
6086
  function aspectRatioToSize(ratio, tier) {
5658
6087
  const TIER_LONG_EDGE = {
@@ -5735,9 +6164,9 @@ function toProviderError2(cause, ctx) {
5735
6164
  ctx.model.id
5736
6165
  );
5737
6166
  }
5738
- var openaiUsageSchema = import_zod11.z.object({
5739
- input_tokens: import_zod11.z.number().optional(),
5740
- output_tokens: import_zod11.z.number().optional()
6167
+ var openaiUsageSchema = import_zod12.z.object({
6168
+ input_tokens: import_zod12.z.number().optional(),
6169
+ output_tokens: import_zod12.z.number().optional()
5741
6170
  });
5742
6171
  var openaiImageAdapter = {
5743
6172
  id: "openai-image",
@@ -5766,6 +6195,19 @@ var openaiImageAdapter = {
5766
6195
  const quality = req.quality ?? (isEdit ? "medium" : "auto");
5767
6196
  const sdkQuality = quality;
5768
6197
  const count = req.count !== void 0 && req.count > 1 ? { n: req.count } : {};
6198
+ let outputFormat = req.outputFormat;
6199
+ if (outputFormat === "webp") {
6200
+ ctx.warnings.push({
6201
+ code: "option_ignored",
6202
+ field: "outputFormat",
6203
+ from: "webp",
6204
+ to: "png",
6205
+ message: `${ctx.model.id} returns PNG for output_format webp; using png`
6206
+ });
6207
+ outputFormat = "png";
6208
+ }
6209
+ const format = outputFormat !== void 0 ? { output_format: outputFormat } : {};
6210
+ const mime = outputFormat === "jpeg" ? "image/jpeg" : "image/png";
5769
6211
  const retryOptions = {};
5770
6212
  if (ctx.signal !== void 0) retryOptions.signal = ctx.signal;
5771
6213
  const response = await withRetry(async () => {
@@ -5778,7 +6220,8 @@ var openaiImageAdapter = {
5778
6220
  prompt: req.prompt,
5779
6221
  size,
5780
6222
  quality: sdkQuality,
5781
- ...count
6223
+ ...count,
6224
+ ...format
5782
6225
  },
5783
6226
  { signal: ctx.signal }
5784
6227
  );
@@ -5788,20 +6231,21 @@ var openaiImageAdapter = {
5788
6231
  model: ctx.model.providerModelId,
5789
6232
  prompt: req.prompt,
5790
6233
  quality: sdkQuality,
5791
- ...count
6234
+ ...count,
6235
+ ...format
5792
6236
  },
5793
6237
  { signal: ctx.signal }
5794
6238
  );
5795
6239
  }
5796
6240
  const files = await Promise.all(
5797
6241
  refs.slice(0, MAX_EDIT_REFERENCES).map(async (ref, i) => {
5798
- const { bytes, mime } = await mediaRefToBytes(ref, ctx.fetch, {
6242
+ const { bytes, mime: mime2 } = await mediaRefToBytes(ref, ctx.fetch, {
5799
6243
  signal: ctx.signal,
5800
6244
  provider: "openai-image",
5801
6245
  model: ctx.model.id
5802
6246
  });
5803
- const ext = mime.includes("jpeg") ? "jpg" : mime.includes("webp") ? "webp" : "png";
5804
- return new File([bytes], `ref-${i}.${ext}`, { type: mime });
6247
+ const ext = mime2.includes("jpeg") ? "jpg" : mime2.includes("webp") ? "webp" : "png";
6248
+ return new File([bytes], `ref-${i}.${ext}`, { type: mime2 });
5805
6249
  })
5806
6250
  );
5807
6251
  const single = files.length === 1 ? files[0] : void 0;
@@ -5814,7 +6258,8 @@ var openaiImageAdapter = {
5814
6258
  prompt: req.prompt,
5815
6259
  size,
5816
6260
  quality: sdkQuality,
5817
- ...count
6261
+ ...count,
6262
+ ...format
5818
6263
  },
5819
6264
  { signal: ctx.signal }
5820
6265
  );
@@ -5825,7 +6270,8 @@ var openaiImageAdapter = {
5825
6270
  image: imageInput,
5826
6271
  prompt: req.prompt,
5827
6272
  quality: sdkQuality,
5828
- ...count
6273
+ ...count,
6274
+ ...format
5829
6275
  },
5830
6276
  { signal: ctx.signal }
5831
6277
  );
@@ -5834,7 +6280,7 @@ var openaiImageAdapter = {
5834
6280
  }
5835
6281
  }, retryOptions);
5836
6282
  const images = (response.data ?? []).flatMap(
5837
- (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime: "image/png" }] : []
6283
+ (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime }] : []
5838
6284
  );
5839
6285
  if (images.length === 0)
5840
6286
  throw classifyHttpError(
@@ -6127,7 +6573,7 @@ var prodiaAdapter = {
6127
6573
 
6128
6574
  // src/adapters/replicate.ts
6129
6575
  var import_replicate = __toESM(require("replicate"), 1);
6130
- var import_zod12 = require("zod");
6576
+ var import_zod13 = require("zod");
6131
6577
  var POLL_INTERVAL_MS = 1e3;
6132
6578
  var POLL_TIMEOUT_MS = 15 * 6e4;
6133
6579
  var defaultReplicateDeps = {
@@ -6163,8 +6609,8 @@ function route(providerModelId) {
6163
6609
  if (!providerModelId.includes("/")) return { version: providerModelId };
6164
6610
  return { model: providerModelId };
6165
6611
  }
6166
- var replicateResponseStatusSchema = import_zod12.z.object({
6167
- response: import_zod12.z.object({ status: import_zod12.z.number() }).partial()
6612
+ var replicateResponseStatusSchema = import_zod13.z.object({
6613
+ response: import_zod13.z.object({ status: import_zod13.z.number() }).partial()
6168
6614
  });
6169
6615
  function replicateError(cause, ctx) {
6170
6616
  if (isModelKitError(cause)) return cause;
@@ -6191,7 +6637,7 @@ function isUrlFn(value) {
6191
6637
  function extractOutputUrl(output) {
6192
6638
  const root = Array.isArray(output) ? output[0] : output;
6193
6639
  if (root === void 0) throw noOutput();
6194
- const asString = import_zod12.z.string().safeParse(root);
6640
+ const asString = import_zod13.z.string().safeParse(root);
6195
6641
  if (asString.success && asString.data) return asString.data;
6196
6642
  if (root instanceof URL) return root.href;
6197
6643
  if (isObjectOutput(root)) {
@@ -6200,15 +6646,15 @@ function extractOutputUrl(output) {
6200
6646
  if (urlValue !== void 0 && isUrlFn(urlValue)) {
6201
6647
  const called = urlValue();
6202
6648
  if (called instanceof URL) return called.href;
6203
- const calledString = import_zod12.z.string().safeParse(called);
6649
+ const calledString = import_zod13.z.string().safeParse(called);
6204
6650
  if (calledString.success && calledString.data) return calledString.data;
6205
6651
  } else {
6206
- const direct = import_zod12.z.string().safeParse(urlValue);
6652
+ const direct = import_zod13.z.string().safeParse(urlValue);
6207
6653
  if (direct.success && direct.data) return direct.data;
6208
6654
  }
6209
6655
  }
6210
6656
  if ("default" in root) {
6211
- const fallback = import_zod12.z.string().safeParse(root.default);
6657
+ const fallback = import_zod13.z.string().safeParse(root.default);
6212
6658
  if (fallback.success && fallback.data) return fallback.data;
6213
6659
  }
6214
6660
  }
@@ -6269,7 +6715,7 @@ async function runPrediction(ctx, input, deps) {
6269
6715
  }
6270
6716
  return void 0;
6271
6717
  }, pollOpts);
6272
- const predictTime = import_zod12.z.number().safeParse(done.metrics?.predict_time);
6718
+ const predictTime = import_zod13.z.number().safeParse(done.metrics?.predict_time);
6273
6719
  if (done.output === void 0) throw noOutput();
6274
6720
  return {
6275
6721
  url: extractOutputUrl(done.output),
@@ -6612,7 +7058,7 @@ async function generateReplicateVideo(req, ctx, deps) {
6612
7058
  throw replicateError(cause, ctx);
6613
7059
  }
6614
7060
  if (current.status === "succeeded") {
6615
- const predictTime = import_zod12.z.number().safeParse(current.metrics?.predict_time);
7061
+ const predictTime = import_zod13.z.number().safeParse(current.metrics?.predict_time);
6616
7062
  if (current.output === void 0) throw noOutput();
6617
7063
  return {
6618
7064
  url: extractOutputUrl(current.output),
@@ -6744,7 +7190,7 @@ async function generateReplicateAudio(req, ctx, deps) {
6744
7190
  // src/adapters/xai-video.ts
6745
7191
  var import_ai4 = require("ai");
6746
7192
  var import_xai2 = require("@ai-sdk/xai");
6747
- var import_zod13 = require("zod");
7193
+ var import_zod14 = require("zod");
6748
7194
  var POLL_INTERVAL_MS2 = 1e4;
6749
7195
  var POLL_TIMEOUT_MS2 = 15 * 6e4;
6750
7196
  var defaultXaiDeps = {
@@ -6757,8 +7203,8 @@ function createXaiVideoAdapter(deps = defaultXaiDeps) {
6757
7203
  };
6758
7204
  }
6759
7205
  var xaiVideoAdapter = createXaiVideoAdapter();
6760
- var xaiResponseStatusSchema = import_zod13.z.object({
6761
- response: import_zod13.z.object({ status: import_zod13.z.number() }).partial()
7206
+ var xaiResponseStatusSchema = import_zod14.z.object({
7207
+ response: import_zod14.z.object({ status: import_zod14.z.number() }).partial()
6762
7208
  });
6763
7209
  function xaiError(cause, ctx) {
6764
7210
  const info = describeThrown(cause);
@@ -6766,12 +7212,12 @@ function xaiError(cause, ctx) {
6766
7212
  const status = info.status ?? (nested.success ? nested.data.response?.status : void 0);
6767
7213
  return classifyThrown("xai-video", cause, ctx.model.id, { status, body: info.body });
6768
7214
  }
6769
- var xaiMetaSchema = import_zod13.z.object({
7215
+ var xaiMetaSchema = import_zod14.z.object({
6770
7216
  videoUrl: JsonValueSchema.optional(),
6771
7217
  costInUsdTicks: JsonValueSchema.optional(),
6772
7218
  duration: JsonValueSchema.optional()
6773
7219
  });
6774
- var xaiProviderMetadataSchema = import_zod13.z.object({ xai: xaiMetaSchema });
7220
+ var xaiProviderMetadataSchema = import_zod14.z.object({ xai: xaiMetaSchema });
6775
7221
  function metaOf(result) {
6776
7222
  const parsed = xaiProviderMetadataSchema.partial().safeParse(result.providerMetadata);
6777
7223
  if (!parsed.success) return {};
@@ -6878,7 +7324,7 @@ async function mapResult(ctx, req, result) {
6878
7324
  };
6879
7325
  }
6880
7326
  const meta = metaOf(result);
6881
- const videoUrl = import_zod13.z.string().safeParse(meta.videoUrl);
7327
+ const videoUrl = import_zod14.z.string().safeParse(meta.videoUrl);
6882
7328
  if (videoUrl.success && videoUrl.data) {
6883
7329
  const res = await ctx.fetch(videoUrl.data);
6884
7330
  if (!res.ok) {
@@ -6901,7 +7347,7 @@ async function mapResult(ctx, req, result) {
6901
7347
  });
6902
7348
  }
6903
7349
  function usage(ctx, req, meta) {
6904
- const costTicks = import_zod13.z.number().safeParse(meta.costInUsdTicks);
7350
+ const costTicks = import_zod14.z.number().safeParse(meta.costInUsdTicks);
6905
7351
  const cost = costTicks.success ? costTicks.data / 1e10 : void 0;
6906
7352
  const event = {
6907
7353
  model: ctx.model.id,
@@ -6950,8 +7396,11 @@ var languageModel = (modelId, call) => createDefaultModelKit().languageModel(mod
6950
7396
  var describe = (modelId) => createDefaultModelKit().describe(modelId);
6951
7397
  // Annotate the CommonJS export names for ESM import in node:
6952
7398
  0 && (module.exports = {
7399
+ ADAPTER_IDS,
6953
7400
  ADAPTER_KEYS,
6954
7401
  Catalog,
7402
+ CatalogModelSchema,
7403
+ CatalogSchema,
6955
7404
  DEFAULT_ADAPTERS,
6956
7405
  JsonObjectSchema,
6957
7406
  JsonValueSchema,
@@ -6967,6 +7416,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
6967
7416
  describeThrown,
6968
7417
  experimental_generateImage,
6969
7418
  falAdapter,
7419
+ fileCatalogCache,
6970
7420
  generateAudio,
6971
7421
  generateImage,
6972
7422
  generateObject,
@@ -6978,15 +7428,19 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
6978
7428
  isModelKitError,
6979
7429
  keysFromEnv,
6980
7430
  languageModel,
7431
+ liveCatalog,
7432
+ liveState,
6981
7433
  mergeTextProviderOptions,
6982
7434
  nearestAspectRatio,
6983
7435
  openaiImageAdapter,
6984
7436
  passthroughTextModel,
6985
7437
  pollUntil,
6986
7438
  prepareMediaPart,
7439
+ primeCatalog,
6987
7440
  prodiaAdapter,
6988
7441
  readErrorBody,
6989
7442
  replicateAdapter,
7443
+ resetLiveCatalog,
6990
7444
  resolveAudioOptions,
6991
7445
  resolveImageOptions,
6992
7446
  resolveKeys,