@shop-os/modelkit 0.2.0 → 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.d.cts CHANGED
@@ -456,6 +456,15 @@ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-imag
456
456
  declare const CatalogModelSchema: z.ZodType<CatalogModel>;
457
457
  declare const CatalogSchema: z.ZodType<CatalogModel[]>;
458
458
 
459
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
460
+ interface LiveCatalogState {
461
+ catalog: Catalog;
462
+ memo: Promise<unknown> | undefined;
463
+ timer: ReturnType<typeof setInterval> | undefined;
464
+ revision: string | undefined;
465
+ origin: CatalogOrigin;
466
+ }
467
+ declare const liveState: LiveCatalogState;
459
468
  declare const liveCatalog: Catalog;
460
469
 
461
470
  interface CatalogCache {
@@ -477,7 +486,7 @@ interface CatalogSource {
477
486
  fetch?: typeof fetch;
478
487
  logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
479
488
  }
480
- type CatalogOrigin = "remote" | "last-good" | "snapshot";
489
+
481
490
  interface PrimeCatalogResult {
482
491
  origin: CatalogOrigin;
483
492
  rowCount: number;
@@ -486,7 +495,7 @@ interface PrimeCatalogResult {
486
495
  }
487
496
  /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
488
497
  declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
489
- /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
498
+ /** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
490
499
  declare function resetLiveCatalog(): void;
491
500
 
492
501
  declare function fileCatalogCache(path: string): CatalogCache;
@@ -732,4 +741,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
732
741
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
733
742
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
734
743
 
735
- export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
744
+ export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -456,6 +456,15 @@ declare const ADAPTER_IDS: readonly ["ai-sdk-text", "google-image", "openai-imag
456
456
  declare const CatalogModelSchema: z.ZodType<CatalogModel>;
457
457
  declare const CatalogSchema: z.ZodType<CatalogModel[]>;
458
458
 
459
+ type CatalogOrigin = "remote" | "last-good" | "snapshot";
460
+ interface LiveCatalogState {
461
+ catalog: Catalog;
462
+ memo: Promise<unknown> | undefined;
463
+ timer: ReturnType<typeof setInterval> | undefined;
464
+ revision: string | undefined;
465
+ origin: CatalogOrigin;
466
+ }
467
+ declare const liveState: LiveCatalogState;
459
468
  declare const liveCatalog: Catalog;
460
469
 
461
470
  interface CatalogCache {
@@ -477,7 +486,7 @@ interface CatalogSource {
477
486
  fetch?: typeof fetch;
478
487
  logger?: Pick<Console, "debug" | "info" | "warn" | "error">;
479
488
  }
480
- type CatalogOrigin = "remote" | "last-good" | "snapshot";
489
+
481
490
  interface PrimeCatalogResult {
482
491
  origin: CatalogOrigin;
483
492
  rowCount: number;
@@ -486,7 +495,7 @@ interface PrimeCatalogResult {
486
495
  }
487
496
  /** Fetch, validate, swap into liveCatalog. Never throws. Second call returns the same promise. */
488
497
  declare function primeCatalog(source: CatalogSource): Promise<PrimeCatalogResult>;
489
- /** Test seam: stop the refresh timer and reset liveCatalog to MODELS and clear the memo. */
498
+ /** Test seam: stop the refresh timer, reset liveCatalog to MODELS and clear the memo. */
490
499
  declare function resetLiveCatalog(): void;
491
500
 
492
501
  declare function fileCatalogCache(path: string): CatalogCache;
@@ -732,4 +741,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
732
741
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
733
742
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
734
743
 
735
- export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
744
+ export { ADAPTER_IDS, ADAPTER_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogModel, CatalogModelSchema, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DefaultObjectOutput, type GeneratedImage, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type LanguageModelHandle, type Lifecycle, type LiveCatalogState, MODELS, type MediaPart, type MediaRef, type ModelConstraints, type ModelKit, type ModelKitConfig, ModelKitError, type ModelKitErrorCode, type ModelKitErrorInit, type ModelType, type ModelkitGenerateObjectOptions, type ModelkitGenerateTextOptions, type ModelkitStreamObjectOptions, type ModelkitStreamTextOptions, type ObjectOutput, type ObjectResult, type OnUnsupported, type OutputFormat, type PricingKind, type PrimeCatalogResult, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type ReferenceLimits, type RequiredInput, type ResolveResult, type Routing, type SupportedOption, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type Warning, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, createDefaultModelKit, createModelKit, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, higgsfieldAdapter, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, nearestAspectRatio, openaiImageAdapter, passthroughTextModel, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, streamObject, streamText, textUsageEvent, toGeneratedImage, withRetry, xaiVideoAdapter };
package/dist/index.js CHANGED
@@ -121,7 +121,7 @@ var GEMINI_RATIOS = [
121
121
  "5:4",
122
122
  "adaptive"
123
123
  ];
124
- function geminiImage(id, label, aliases, sizes, display, exposure) {
124
+ function geminiImage(id, label, aliases, sizes, display, exposure, references) {
125
125
  const model = {
126
126
  id,
127
127
  aliases,
@@ -134,7 +134,8 @@ function geminiImage(id, label, aliases, sizes, display, exposure) {
134
134
  constraints: {
135
135
  aspectRatios: [...GEMINI_RATIOS],
136
136
  sizes,
137
- supports: ["safetySettings", "temperature"]
137
+ supports: ["safetySettings", "temperature"],
138
+ ...references ? { references } : {}
138
139
  },
139
140
  defaults: { size: "1K", aspectRatio: "1:1" },
140
141
  usage: { ...IMAGE_USAGE, slug: "gemini" },
@@ -154,7 +155,8 @@ var IMAGE_MODELS = [
154
155
  description: "Create stunning, production-quality visuals with exceptional realism, detail, and typography. Best for campaigns, e-commerce, product photography, and hero creatives.",
155
156
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
156
157
  },
157
- "catalog"
158
+ "catalog",
159
+ { images: 14 }
158
160
  ),
159
161
  geminiImage(
160
162
  "gemini-3.1-flash-image-preview",
@@ -167,7 +169,8 @@ var IMAGE_MODELS = [
167
169
  description: "Generate high-quality images at speed. Perfect for brainstorming, moodboards, concept testing, creative exploration, and large batch workflows.",
168
170
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
169
171
  },
170
- "catalog"
172
+ "catalog",
173
+ { images: 14 }
171
174
  ),
172
175
  geminiImage(
173
176
  "gemini-3.1-flash-lite-image",
@@ -179,14 +182,15 @@ var IMAGE_MODELS = [
179
182
  description: "The fastest and most affordable image model. Ideal for rapid drafts, bulk exploration, and iterative concept testing at 1K resolution.",
180
183
  logo: "https://d31vvfpk2ppdyq.cloudfront.net/assets/image/192485d2-a76a-4657-9c06-930b2c70badd_compressed.png"
181
184
  },
182
- "catalog"
185
+ "catalog",
186
+ { images: 14 }
183
187
  ),
184
188
  // trigger-workflows validates 1K only; pricing seeds 2K/4K rows so allow all three.
185
189
  geminiImage(
186
190
  "gemini-2.5-flash-image",
187
191
  "Gemini 2.5 Flash Image",
188
192
  [],
189
- ["1K", "2K", "4K"],
193
+ ["1K"],
190
194
  {
191
195
  provider: "google",
192
196
  description: "Nano Banana (legacy Gemini 2.5 Flash Image) native image generation and editing model for high-volume, low-latency creative workflows."
@@ -217,7 +221,7 @@ var IMAGE_MODELS = [
217
221
  sizes: ["1K", "2K", "4K"],
218
222
  qualityOptions: ["auto", "low", "medium", "high"],
219
223
  references: { images: 16 },
220
- supports: ["quality", "count"]
224
+ supports: ["quality", "count", "outputFormat"]
221
225
  },
222
226
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
223
227
  usage: { ...IMAGE_USAGE, slug: "gpt" },
@@ -237,7 +241,7 @@ var IMAGE_MODELS = [
237
241
  adapter: "openai-image",
238
242
  providerModelId: "gpt-image-2.5-sunburst",
239
243
  lifecycle: "active",
240
- exposure: "internal",
244
+ exposure: "catalog",
241
245
  constraints: {
242
246
  exactSizes: {
243
247
  "1:1": "1024x1024",
@@ -250,9 +254,9 @@ var IMAGE_MODELS = [
250
254
  },
251
255
  aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
252
256
  sizes: ["1K", "2K", "4K"],
253
- qualityOptions: ["auto", "low", "medium", "high"],
257
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
254
258
  references: { images: 16 },
255
- supports: ["quality", "count"]
259
+ supports: ["quality", "count", "outputFormat"]
256
260
  },
257
261
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
258
262
  usage: { ...IMAGE_USAGE },
@@ -271,7 +275,7 @@ var IMAGE_MODELS = [
271
275
  adapter: "openai-image",
272
276
  providerModelId: "gpt-image-2.5-flare",
273
277
  lifecycle: "active",
274
- exposure: "internal",
278
+ exposure: "catalog",
275
279
  constraints: {
276
280
  exactSizes: {
277
281
  "1:1": "1024x1024",
@@ -284,9 +288,9 @@ var IMAGE_MODELS = [
284
288
  },
285
289
  aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:5", "5:4", "adaptive"],
286
290
  sizes: ["1K", "2K", "4K"],
287
- qualityOptions: ["auto", "low", "medium", "high"],
291
+ qualityOptions: ["auto", "low", "medium", "high", "xhigh", "max"],
288
292
  references: { images: 16 },
289
- supports: ["quality", "count"]
293
+ supports: ["quality", "count", "outputFormat"]
290
294
  },
291
295
  defaults: { size: "1K", aspectRatio: "adaptive", quality: "auto" },
292
296
  usage: { ...IMAGE_USAGE },
@@ -316,8 +320,6 @@ var IMAGE_MODELS = [
316
320
  "2:3",
317
321
  "3:4",
318
322
  "9:16",
319
- "4:5",
320
- "5:4",
321
323
  "9:21",
322
324
  "adaptive"
323
325
  ],
@@ -349,7 +351,7 @@ var IMAGE_MODELS = [
349
351
  references: { images: 10 },
350
352
  // Ark's Images API has no output-format, quality or count field; only
351
353
  // the seed is forwarded, so anything else must warn, not vanish.
352
- supports: ["seed"]
354
+ supports: ["seed", "outputFormat"]
353
355
  },
354
356
  defaults: { size: "1K", aspectRatio: "1:1" },
355
357
  usage: { ...IMAGE_USAGE },
@@ -385,7 +387,7 @@ var IMAGE_MODELS = [
385
387
  "21:9",
386
388
  "9:21"
387
389
  ],
388
- sizes: ["1K", "2K", "4K"],
390
+ sizes: ["2K", "4K"],
389
391
  references: { images: 10 },
390
392
  supports: ["seed"]
391
393
  },
@@ -437,7 +439,7 @@ var IMAGE_MODELS = [
437
439
  aspectRatios: ["1:1", "2:3", "3:2", "4:3", "3:4", "4:5", "5:4", "9:16", "16:9", "21:9"],
438
440
  sizes: ["1K", "2K", "4K"],
439
441
  requires: ["references"],
440
- supports: ["seed"]
442
+ supports: []
441
443
  },
442
444
  defaults: { size: "1K", aspectRatio: "1:1" },
443
445
  usage: { ...IMAGE_USAGE },
@@ -462,7 +464,7 @@ var IMAGE_MODELS = [
462
464
  aspectRatios: ["1:1", "2:3", "3:4", "4:3", "9:16", "16:9", "21:9"],
463
465
  sizes: ["1K"],
464
466
  requires: ["references"],
465
- supports: ["seed"]
467
+ supports: []
466
468
  },
467
469
  defaults: { size: "1K", aspectRatio: "1:1" },
468
470
  usage: { ...IMAGE_USAGE },
@@ -514,7 +516,6 @@ var IMAGE_MODELS = [
514
516
  aspectRatios: ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"],
515
517
  sizes: [],
516
518
  references: { images: 1 },
517
- requires: ["references"],
518
519
  supports: []
519
520
  },
520
521
  defaults: { aspectRatio: "1:1" },
@@ -1233,7 +1234,7 @@ var VIDEO_MODELS = [
1233
1234
  resolutions: ["720p", "1080p", "4k"],
1234
1235
  durations: [8],
1235
1236
  references: { images: 3 },
1236
- supports: ["lastFrame"]
1237
+ supports: ["lastFrame", "seed"]
1237
1238
  },
1238
1239
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1239
1240
  usage: { ...VIDEO_USAGE, slug: "veo" },
@@ -1261,9 +1262,9 @@ var VIDEO_MODELS = [
1261
1262
  constraints: {
1262
1263
  aspectRatios: [...OMNI_RATIOS],
1263
1264
  resolutions: ["720p", "1080p", "4k"],
1264
- durations: [4, 8],
1265
+ durations: [4, 6, 8],
1265
1266
  references: { images: 3 },
1266
- supports: ["lastFrame"]
1267
+ supports: ["lastFrame", "seed"]
1267
1268
  },
1268
1269
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1269
1270
  usage: { ...VIDEO_USAGE },
@@ -1290,9 +1291,8 @@ var VIDEO_MODELS = [
1290
1291
  constraints: {
1291
1292
  aspectRatios: [...OMNI_RATIOS],
1292
1293
  resolutions: ["720p", "1080p"],
1293
- durations: [4, 8],
1294
- references: { images: 3 },
1295
- supports: ["lastFrame"]
1294
+ durations: [4, 6, 8],
1295
+ supports: ["lastFrame", "seed"]
1296
1296
  },
1297
1297
  defaults: { durationSeconds: 8, resolution: "720p", aspectRatio: "16:9" },
1298
1298
  usage: { ...VIDEO_USAGE },
@@ -1324,7 +1324,7 @@ var VIDEO_MODELS = [
1324
1324
  // reference clip keeps its own framing.
1325
1325
  aspectRatios: [...OMNI_RATIOS],
1326
1326
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1327
- references: { images: 6, videos: 1 },
1327
+ references: { images: 6, videos: 3 },
1328
1328
  supports: []
1329
1329
  },
1330
1330
  defaults: {},
@@ -1350,7 +1350,7 @@ var VIDEO_MODELS = [
1350
1350
  aspectRatios: [...OMNI_RATIOS],
1351
1351
  resolutions: ["360p", "720p", "1080p", "4k"],
1352
1352
  durations: [3, 4, 5, 6, 7, 8, 9, 10],
1353
- references: { images: 6, videos: 1 },
1353
+ references: { images: 6, videos: 3 },
1354
1354
  supports: []
1355
1355
  },
1356
1356
  defaults: {},
@@ -1379,7 +1379,7 @@ var VIDEO_MODELS = [
1379
1379
  durations: { min: 4, max: 15 },
1380
1380
  durationPresets: [4, 6, 8, 10, 12, 15],
1381
1381
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1382
- ratioIgnoredWith: ["firstFrame"],
1382
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1383
1383
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1384
1384
  },
1385
1385
  defaults: {
@@ -1411,7 +1411,7 @@ var VIDEO_MODELS = [
1411
1411
  resolutions: ["480p", "720p"],
1412
1412
  durations: { min: 4, max: 15 },
1413
1413
  references: { images: 9, videos: 3, audios: 3, audioOnly: false },
1414
- ratioIgnoredWith: ["firstFrame"],
1414
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1415
1415
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1416
1416
  },
1417
1417
  defaults: {
@@ -1444,7 +1444,7 @@ var VIDEO_MODELS = [
1444
1444
  resolutions: ["480p", "720p", "1080p"],
1445
1445
  durations: { min: 4, max: 30 },
1446
1446
  references: { images: 30, videos: 10, audios: 10 },
1447
- ratioIgnoredWith: ["firstFrame"],
1447
+ ratioIgnoredWith: ["firstFrame", "sourceVideo"],
1448
1448
  supports: ["generateAudio", "seed", "lastFrame", "watermark"]
1449
1449
  },
1450
1450
  defaults: {
@@ -1563,18 +1563,7 @@ var VIDEO_MODELS = [
1563
1563
  lifecycle: "active",
1564
1564
  exposure: "catalog",
1565
1565
  constraints: {
1566
- aspectRatios: [
1567
- "1:1",
1568
- "16:9",
1569
- "9:16",
1570
- "4:3",
1571
- "3:4",
1572
- "3:2",
1573
- "2:3",
1574
- "21:9",
1575
- "4:5",
1576
- "adaptive"
1577
- ],
1566
+ aspectRatios: [...KLING_RATIOS],
1578
1567
  resolutions: ["720p", "1080p"],
1579
1568
  durations: { min: 3, max: 15 },
1580
1569
  references: { images: 7 },
@@ -2036,13 +2025,18 @@ var CatalogSchema = z.array(CatalogModelSchemaBase).superRefine((rows, ctx) => {
2036
2025
  });
2037
2026
 
2038
2027
  // src/catalog/live.ts
2039
- var liveCatalog = new Catalog(MODELS);
2028
+ var KEY = /* @__PURE__ */ Symbol.for("@shop-os/modelkit/live-catalog");
2029
+ var store = globalThis;
2030
+ var liveState = store[KEY] ??= {
2031
+ catalog: new Catalog(MODELS),
2032
+ memo: void 0,
2033
+ timer: void 0,
2034
+ revision: void 0,
2035
+ origin: "snapshot"
2036
+ };
2037
+ var liveCatalog = liveState.catalog;
2040
2038
 
2041
2039
  // src/catalog/load.ts
2042
- var memo;
2043
- var timer;
2044
- var revision;
2045
- var origin = "snapshot";
2046
2040
  function rowCount() {
2047
2041
  return liveCatalog.list({ lifecycle: ["active", "deprecated", "retired"] }).length;
2048
2042
  }
@@ -2072,7 +2066,7 @@ function logPrimed(logger, result) {
2072
2066
  async function fetchRemote(source, logger) {
2073
2067
  const fetchImpl = source.fetch ?? globalThis.fetch;
2074
2068
  const headers2 = authHeaders(source.auth);
2075
- if (revision !== void 0) headers2["If-None-Match"] = `"${revision}"`;
2069
+ if (liveState.revision !== void 0) headers2["If-None-Match"] = `"${liveState.revision}"`;
2076
2070
  const res = await fetchImpl(`${source.baseUrl}/models/catalog`, {
2077
2071
  headers: headers2,
2078
2072
  signal: AbortSignal.timeout(source.timeoutMs ?? 1e4)
@@ -2096,16 +2090,16 @@ async function prime(source, logger) {
2096
2090
  try {
2097
2091
  const fetched = await fetchRemote(source, logger);
2098
2092
  if ("kept" in fetched) {
2099
- const result2 = { origin, rowCount: rowCount() };
2100
- if (revision !== void 0) result2.revision = revision;
2093
+ const result2 = { origin: liveState.origin, rowCount: rowCount() };
2094
+ if (liveState.revision !== void 0) result2.revision = liveState.revision;
2101
2095
  logPrimed(logger, result2);
2102
2096
  return result2;
2103
2097
  }
2104
2098
  liveCatalog.replace(fetched.rows);
2105
- origin = "remote";
2106
- revision = fetched.revision;
2099
+ liveState.origin = "remote";
2100
+ liveState.revision = fetched.revision;
2107
2101
  await writeCache(source, logger, fetched.rows, fetched.revision);
2108
- const result = { origin, rowCount: rowCount() };
2102
+ const result = { origin: liveState.origin, rowCount: rowCount() };
2109
2103
  if (fetched.revision !== void 0) result.revision = fetched.revision;
2110
2104
  logPrimed(logger, result);
2111
2105
  return result;
@@ -2117,19 +2111,23 @@ async function prime(source, logger) {
2117
2111
  if (!cached) throw new Error("no cached catalog");
2118
2112
  const { rows, revision: rev } = parseEnvelope(JSON.parse(cached));
2119
2113
  liveCatalog.replace(rows);
2120
- origin = "last-good";
2121
- revision = rev;
2122
- const result = { origin, rowCount: rowCount(), error };
2114
+ liveState.origin = "last-good";
2115
+ liveState.revision = rev;
2116
+ const result = {
2117
+ origin: liveState.origin,
2118
+ rowCount: rowCount(),
2119
+ error
2120
+ };
2123
2121
  if (rev !== void 0) result.revision = rev;
2124
2122
  logPrimed(logger, result);
2125
2123
  return result;
2126
2124
  } catch (cacheErr) {
2127
2125
  logger.warn("[modelkit] catalog cache failed, using snapshot", cacheErr);
2128
2126
  liveCatalog.replace([...MODELS]);
2129
- origin = "snapshot";
2130
- revision = void 0;
2127
+ liveState.origin = "snapshot";
2128
+ liveState.revision = void 0;
2131
2129
  const result = {
2132
- origin,
2130
+ origin: liveState.origin,
2133
2131
  rowCount: rowCount(),
2134
2132
  error
2135
2133
  };
@@ -2143,35 +2141,36 @@ async function refresh(source, logger) {
2143
2141
  const fetched = await fetchRemote(source, logger);
2144
2142
  if ("kept" in fetched) return;
2145
2143
  liveCatalog.replace(fetched.rows);
2146
- origin = "remote";
2147
- revision = fetched.revision;
2144
+ liveState.origin = "remote";
2145
+ liveState.revision = fetched.revision;
2148
2146
  await writeCache(source, logger, fetched.rows, fetched.revision);
2149
2147
  } catch (err) {
2150
2148
  logger.warn("[modelkit] catalog refresh failed, keeping current rows", err);
2151
2149
  }
2152
2150
  }
2153
2151
  function primeCatalog(source) {
2152
+ const memo = liveState.memo;
2154
2153
  if (memo) return memo;
2155
2154
  const logger = source.logger ?? console;
2156
- memo = prime(source, logger).then((result) => {
2155
+ liveState.memo = prime(source, logger).then((result) => {
2157
2156
  const ttlMs = source.ttlMs ?? 3e5;
2158
- if (ttlMs > 0 && timer === void 0) {
2159
- timer = setInterval(() => void refresh(source, logger), ttlMs);
2160
- const maybeUnref = timer;
2157
+ if (ttlMs > 0 && liveState.timer === void 0) {
2158
+ liveState.timer = setInterval(() => void refresh(source, logger), ttlMs);
2159
+ const maybeUnref = liveState.timer;
2161
2160
  maybeUnref.unref?.();
2162
2161
  }
2163
2162
  return result;
2164
2163
  });
2165
- return memo;
2164
+ return liveState.memo;
2166
2165
  }
2167
2166
  function resetLiveCatalog() {
2168
- if (timer !== void 0) {
2169
- clearInterval(timer);
2170
- timer = void 0;
2167
+ if (liveState.timer !== void 0) {
2168
+ clearInterval(liveState.timer);
2169
+ liveState.timer = void 0;
2171
2170
  }
2172
- memo = void 0;
2173
- revision = void 0;
2174
- origin = "snapshot";
2171
+ liveState.memo = void 0;
2172
+ liveState.revision = void 0;
2173
+ liveState.origin = "snapshot";
2175
2174
  liveCatalog.replace([...MODELS]);
2176
2175
  }
2177
2176
 
@@ -2715,12 +2714,12 @@ function sleep(ms, signal) {
2715
2714
  rejectAborted();
2716
2715
  return;
2717
2716
  }
2718
- let timer2;
2717
+ let timer;
2719
2718
  const onAbort = () => {
2720
- if (timer2 !== void 0) clearTimeout(timer2);
2719
+ if (timer !== void 0) clearTimeout(timer);
2721
2720
  rejectAborted();
2722
2721
  };
2723
- timer2 = setTimeout(() => {
2722
+ timer = setTimeout(() => {
2724
2723
  signal?.removeEventListener("abort", onAbort);
2725
2724
  resolve();
2726
2725
  }, ms);
@@ -3813,6 +3812,18 @@ async function generateSeedreamImage(req, ctx) {
3813
3812
  watermark: false
3814
3813
  };
3815
3814
  if (req.seed !== void 0) body.seed = req.seed;
3815
+ if (req.outputFormat !== void 0) {
3816
+ if (req.outputFormat === "webp") {
3817
+ ctx.warnings.push({
3818
+ code: "option_ignored",
3819
+ field: "outputFormat",
3820
+ from: "webp",
3821
+ to: "png",
3822
+ message: `${modelId} accepts png or jpeg output; using png`
3823
+ });
3824
+ }
3825
+ body.output_format = req.outputFormat === "jpeg" ? "jpeg" : "png";
3826
+ }
3816
3827
  const firstRef = refs[0];
3817
3828
  if (refs.length === 1 && firstRef !== void 0) body.image = firstRef;
3818
3829
  else if (refs.length > 1) body.image = refs;
@@ -4958,6 +4969,7 @@ async function generateVeoVideo(req, ctx, createGenAIClient) {
4958
4969
  const config = { durationSeconds: duration, personGeneration };
4959
4970
  if (req.aspectRatio !== void 0) config.aspectRatio = req.aspectRatio;
4960
4971
  if (req.resolution !== void 0) config.resolution = req.resolution;
4972
+ if (req.seed !== void 0) config.seed = req.seed;
4961
4973
  if (lastFrame !== void 0) config.lastFrame = lastFrame;
4962
4974
  if (referenceImages !== void 0) config.referenceImages = referenceImages;
4963
4975
  const requestBody = {
@@ -6101,6 +6113,19 @@ var openaiImageAdapter = {
6101
6113
  const quality = req.quality ?? (isEdit ? "medium" : "auto");
6102
6114
  const sdkQuality = quality;
6103
6115
  const count = req.count !== void 0 && req.count > 1 ? { n: req.count } : {};
6116
+ let outputFormat = req.outputFormat;
6117
+ if (outputFormat === "webp") {
6118
+ ctx.warnings.push({
6119
+ code: "option_ignored",
6120
+ field: "outputFormat",
6121
+ from: "webp",
6122
+ to: "png",
6123
+ message: `${ctx.model.id} returns PNG for output_format webp; using png`
6124
+ });
6125
+ outputFormat = "png";
6126
+ }
6127
+ const format = outputFormat !== void 0 ? { output_format: outputFormat } : {};
6128
+ const mime = outputFormat === "jpeg" ? "image/jpeg" : "image/png";
6104
6129
  const retryOptions = {};
6105
6130
  if (ctx.signal !== void 0) retryOptions.signal = ctx.signal;
6106
6131
  const response = await withRetry(async () => {
@@ -6113,7 +6138,8 @@ var openaiImageAdapter = {
6113
6138
  prompt: req.prompt,
6114
6139
  size,
6115
6140
  quality: sdkQuality,
6116
- ...count
6141
+ ...count,
6142
+ ...format
6117
6143
  },
6118
6144
  { signal: ctx.signal }
6119
6145
  );
@@ -6123,20 +6149,21 @@ var openaiImageAdapter = {
6123
6149
  model: ctx.model.providerModelId,
6124
6150
  prompt: req.prompt,
6125
6151
  quality: sdkQuality,
6126
- ...count
6152
+ ...count,
6153
+ ...format
6127
6154
  },
6128
6155
  { signal: ctx.signal }
6129
6156
  );
6130
6157
  }
6131
6158
  const files = await Promise.all(
6132
6159
  refs.slice(0, MAX_EDIT_REFERENCES).map(async (ref, i) => {
6133
- const { bytes, mime } = await mediaRefToBytes(ref, ctx.fetch, {
6160
+ const { bytes, mime: mime2 } = await mediaRefToBytes(ref, ctx.fetch, {
6134
6161
  signal: ctx.signal,
6135
6162
  provider: "openai-image",
6136
6163
  model: ctx.model.id
6137
6164
  });
6138
- const ext = mime.includes("jpeg") ? "jpg" : mime.includes("webp") ? "webp" : "png";
6139
- return new File([bytes], `ref-${i}.${ext}`, { type: mime });
6165
+ const ext = mime2.includes("jpeg") ? "jpg" : mime2.includes("webp") ? "webp" : "png";
6166
+ return new File([bytes], `ref-${i}.${ext}`, { type: mime2 });
6140
6167
  })
6141
6168
  );
6142
6169
  const single = files.length === 1 ? files[0] : void 0;
@@ -6149,7 +6176,8 @@ var openaiImageAdapter = {
6149
6176
  prompt: req.prompt,
6150
6177
  size,
6151
6178
  quality: sdkQuality,
6152
- ...count
6179
+ ...count,
6180
+ ...format
6153
6181
  },
6154
6182
  { signal: ctx.signal }
6155
6183
  );
@@ -6160,7 +6188,8 @@ var openaiImageAdapter = {
6160
6188
  image: imageInput,
6161
6189
  prompt: req.prompt,
6162
6190
  quality: sdkQuality,
6163
- ...count
6191
+ ...count,
6192
+ ...format
6164
6193
  },
6165
6194
  { signal: ctx.signal }
6166
6195
  );
@@ -6169,7 +6198,7 @@ var openaiImageAdapter = {
6169
6198
  }
6170
6199
  }, retryOptions);
6171
6200
  const images = (response.data ?? []).flatMap(
6172
- (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime: "image/png" }] : []
6201
+ (item) => item.b64_json ? [{ bytes: base64ToBytes(item.b64_json), mime }] : []
6173
6202
  );
6174
6203
  if (images.length === 0)
6175
6204
  throw classifyHttpError(
@@ -7317,6 +7346,7 @@ export {
7317
7346
  keysFromEnv,
7318
7347
  languageModel,
7319
7348
  liveCatalog,
7349
+ liveState,
7320
7350
  mergeTextProviderOptions,
7321
7351
  nearestAspectRatio,
7322
7352
  openaiImageAdapter,