@shop-os/modelkit 0.3.2 → 0.3.3

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
@@ -396,6 +396,8 @@ interface CatalogCapabilities {
396
396
  videoEdit?: boolean;
397
397
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
398
398
  framesExcludeReferences?: boolean;
399
+ /** Video rows: a source video is never sent with first/last frames or reference images. */
400
+ sourceVideoExcludesFrames?: boolean;
399
401
  /** Video rows: a last frame is accepted only together with a first frame. */
400
402
  lastFrameRequiresFirstFrame?: boolean;
401
403
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
@@ -1021,6 +1023,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1021
1023
  acceptsSourceVideo: z.ZodOptional<z.ZodBoolean>;
1022
1024
  videoEdit: z.ZodOptional<z.ZodBoolean>;
1023
1025
  framesExcludeReferences: z.ZodOptional<z.ZodBoolean>;
1026
+ sourceVideoExcludesFrames: z.ZodOptional<z.ZodBoolean>;
1024
1027
  lastFrameRequiresFirstFrame: z.ZodOptional<z.ZodBoolean>;
1025
1028
  reasoning: z.ZodOptional<z.ZodBoolean>;
1026
1029
  vision: z.ZodOptional<z.ZodBoolean>;
@@ -1030,15 +1033,19 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1030
1033
  declare const CatalogModelSchema: z.ZodType<CatalogModel>;
1031
1034
  declare const CatalogSchema: z.ZodType<CatalogModel[]>;
1032
1035
 
1033
- declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
1036
+ declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages", "sourceVideo"];
1034
1037
  declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
1035
1038
  declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
1039
+ /** Image inputs that `inputSpec.arrays` can join into one provider array field. */
1040
+ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages", "lastFrame", "references"];
1041
+ type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
1036
1042
  type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
1037
1043
  declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
1038
1044
  declare const InputSpecSchema: z.ZodObject<{
1039
1045
  fields: z.ZodRecord<z.ZodString, z.ZodString>;
1040
1046
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
1041
1047
  static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1048
+ arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
1042
1049
  editEndpoint: z.ZodOptional<z.ZodString>;
1043
1050
  }, z.core.$strict>;
1044
1051
  type InputSpec = z.infer<typeof InputSpecSchema>;
@@ -1054,6 +1061,7 @@ interface ValidateRow {
1054
1061
  };
1055
1062
  }
1056
1063
  declare function isInputSpecKey(key: string): key is InputSpecKey;
1064
+ declare function isArrayInputSpecKey(key: string): key is ArrayInputSpecKey;
1057
1065
  declare function validateInputSpec(raw: ProviderOptionValue, row: ValidateRow): {
1058
1066
  ok: true;
1059
1067
  spec: InputSpec;
@@ -1445,4 +1453,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1445
1453
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1446
1454
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1447
1455
 
1448
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
1456
+ export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -396,6 +396,8 @@ interface CatalogCapabilities {
396
396
  videoEdit?: boolean;
397
397
  /** Video rows: first/last frames and reference images are mutually exclusive inputs. */
398
398
  framesExcludeReferences?: boolean;
399
+ /** Video rows: a source video is never sent with first/last frames or reference images. */
400
+ sourceVideoExcludesFrames?: boolean;
399
401
  /** Video rows: a last frame is accepted only together with a first frame. */
400
402
  lastFrameRequiresFirstFrame?: boolean;
401
403
  /** Text rows. `reasoning`: the model streams reasoning the UI should surface. */
@@ -1021,6 +1023,7 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1021
1023
  acceptsSourceVideo: z.ZodOptional<z.ZodBoolean>;
1022
1024
  videoEdit: z.ZodOptional<z.ZodBoolean>;
1023
1025
  framesExcludeReferences: z.ZodOptional<z.ZodBoolean>;
1026
+ sourceVideoExcludesFrames: z.ZodOptional<z.ZodBoolean>;
1024
1027
  lastFrameRequiresFirstFrame: z.ZodOptional<z.ZodBoolean>;
1025
1028
  reasoning: z.ZodOptional<z.ZodBoolean>;
1026
1029
  vision: z.ZodOptional<z.ZodBoolean>;
@@ -1030,15 +1033,19 @@ declare const CatalogModelSchemaBase: z.ZodObject<{
1030
1033
  declare const CatalogModelSchema: z.ZodType<CatalogModel>;
1031
1034
  declare const CatalogSchema: z.ZodType<CatalogModel[]>;
1032
1035
 
1033
- declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages"];
1036
+ declare const VIDEO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "aspectRatio", "resolution", "firstFrame", "lastFrame", "seed", "negativePrompt", "generateAudio", "cfgScale", "promptExpansion", "referenceImages", "sourceVideo"];
1034
1037
  declare const IMAGE_INPUT_SPEC_KEYS: readonly ["prompt", "references", "aspectRatio", "size", "outputFormat", "seed"];
1035
1038
  declare const AUDIO_INPUT_SPEC_KEYS: readonly ["prompt", "durationSeconds", "seed", "negativePrompt", "references", "sourceVideo", "instrumental"];
1039
+ /** Image inputs that `inputSpec.arrays` can join into one provider array field. */
1040
+ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages", "lastFrame", "references"];
1041
+ type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
1036
1042
  type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
1037
1043
  declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
1038
1044
  declare const InputSpecSchema: z.ZodObject<{
1039
1045
  fields: z.ZodRecord<z.ZodString, z.ZodString>;
1040
1046
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
1041
1047
  static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1048
+ arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
1042
1049
  editEndpoint: z.ZodOptional<z.ZodString>;
1043
1050
  }, z.core.$strict>;
1044
1051
  type InputSpec = z.infer<typeof InputSpecSchema>;
@@ -1054,6 +1061,7 @@ interface ValidateRow {
1054
1061
  };
1055
1062
  }
1056
1063
  declare function isInputSpecKey(key: string): key is InputSpecKey;
1064
+ declare function isArrayInputSpecKey(key: string): key is ArrayInputSpecKey;
1057
1065
  declare function validateInputSpec(raw: ProviderOptionValue, row: ValidateRow): {
1058
1066
  ok: true;
1059
1067
  spec: InputSpec;
@@ -1445,4 +1453,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1445
1453
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1446
1454
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1447
1455
 
1448
- export { ADAPTER_IDS, ADAPTER_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
1456
+ export { ADAPTER_IDS, ADAPTER_KEYS, ARRAY_INPUT_SPEC_KEYS, AUDIO_INPUT_SPEC_KEYS, type Adapter, type AdapterContext, type AdapterEndpoints, type AdapterId, type AdapterRegistry, type AiTextProviderOptions, type ArrayInputSpecKey, type AspectRatio, type AudioOutput, type AudioRequest, type AudioResult, type CallContext, Catalog, type CatalogAuth, type CatalogCache, type CatalogCapabilities, type CatalogDisplay, type CatalogEnvelope, type CatalogModel, CatalogModelSchema, CatalogModelSchemaBase, type CatalogOrigin, CatalogSchema, type CatalogSource, type CatalogTextModel, DEFAULT_ADAPTERS, type DataOnlyRow, type DataOnlyVerdict, type DefaultObjectOutput, type Exposure, ExposureSchema, type FalWebhookBody, type GeneratedImage, IMAGE_INPUT_SPEC_KEYS, INPUT_SPEC_SUPPORTS_KEYS, type ImageBytes, type ImageCallOptions, type ImageCallResult, type ImageQuality, type ImageRequest, type ImageResult, type ImageSafetySetting, type ImageSize, type InputSpec, type InputSpecIssue, type InputSpecKey, InputSpecSchema, type JsonObject, JsonObjectSchema, type JsonPrimitive, type JsonValue, JsonValueSchema, type KeyTier, 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 PromptConventions, type ProviderErrorBody, type ProviderKeyName, type ProviderKeys, type ProviderOptionValue, type ProviderOptions, type QuarantineResult, type ReferenceLimits, type ReferenceSyntax, type RequiredInput, type RequiredKeyName, type ResolveResult, type Routing, SURFACES, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type UpscaleOptions, type UsageEvent, type UsageModality, type UsageUnit, VIDEO_INPUT_SPEC_KEYS, VIDEO_TOOL_MODELS, type VideoCallJob, type VideoCallOptions, type VideoJob, type VideoModel, type VideoRequest, type VideoResolution, type VideoResult, type VideoSecondsLimits, type VideoToolCallContext, type VideoToolConstraints, type VideoToolKind, type VideoToolOutputFormat, type VideoToolOutputSpec, type VideoToolPlan, type VideoToolRequest, type VideoToolResult, type VideoToolSource, type VideoToolStatus, type VideoToolSubmission, type Warning, adapterServesType, aiSdkTextAdapter, arkAdapter, aspectRatioToSize, classifyHttpError, compareCatalogOrder, createDefaultModelKit, createModelKit, dataOnlyCapable, describe, describeThrown, generateImage as experimental_generateImage, falAdapter, falWebhookBodySchema, fileCatalogCache, generateAudio, generateImage, generateObject, generateText, generateVideo, googleGenaiAdapter, googleImageAdapter, hasAwsCredentials, higgsfieldAdapter, isArrayInputSpecKey, isInputSpecKey, isListed, isListedOn, isModelKitError, keysFromEnv, languageModel, liveCatalog, liveState, mergeTextProviderOptions, missingTierKeys, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveImageOptions, resolveKeys, resolveVideoOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.js CHANGED
@@ -2238,7 +2238,8 @@ var VIDEO_INPUT_SPEC_KEYS = [
2238
2238
  "generateAudio",
2239
2239
  "cfgScale",
2240
2240
  "promptExpansion",
2241
- "referenceImages"
2241
+ "referenceImages",
2242
+ "sourceVideo"
2242
2243
  ];
2243
2244
  var IMAGE_INPUT_SPEC_KEYS = [
2244
2245
  "prompt",
@@ -2257,6 +2258,12 @@ var AUDIO_INPUT_SPEC_KEYS = [
2257
2258
  "sourceVideo",
2258
2259
  "instrumental"
2259
2260
  ];
2261
+ var ARRAY_INPUT_SPEC_KEYS = [
2262
+ "firstFrame",
2263
+ "referenceImages",
2264
+ "lastFrame",
2265
+ "references"
2266
+ ];
2260
2267
  var INPUT_SPEC_SUPPORTS_KEYS = [
2261
2268
  "lastFrame",
2262
2269
  "seed",
@@ -2270,6 +2277,7 @@ var INPUT_SPEC_SUPPORTS_KEYS = [
2270
2277
  var VIDEO_KEY_SET = new Set(VIDEO_INPUT_SPEC_KEYS);
2271
2278
  var IMAGE_KEY_SET = new Set(IMAGE_INPUT_SPEC_KEYS);
2272
2279
  var AUDIO_KEY_SET = new Set(AUDIO_INPUT_SPEC_KEYS);
2280
+ var ARRAY_KEY_SET = new Set(ARRAY_INPUT_SPEC_KEYS);
2273
2281
  var ALL_KEY_SET = /* @__PURE__ */ new Set([
2274
2282
  ...VIDEO_INPUT_SPEC_KEYS,
2275
2283
  ...IMAGE_INPUT_SPEC_KEYS,
@@ -2314,13 +2322,30 @@ var ValuesSchema = z2.record(z2.string(), z2.record(z2.string(), ProviderScalarS
2314
2322
  }
2315
2323
  });
2316
2324
  var StaticSchema = z2.record(z2.string(), ProviderScalarSchema);
2325
+ var ArraysSchema = z2.record(z2.string().min(1), z2.array(z2.string()).min(1)).superRefine((arrays, ctx) => {
2326
+ for (const [name, keys] of Object.entries(arrays)) {
2327
+ for (const key of keys) {
2328
+ if (!ARRAY_KEY_SET.has(key)) {
2329
+ ctx.addIssue({
2330
+ code: "custom",
2331
+ path: [name],
2332
+ message: `inputSpec.arrays "${name}" has unknown image key "${key}"`
2333
+ });
2334
+ }
2335
+ }
2336
+ }
2337
+ });
2317
2338
  var InputSpecSchema = z2.strictObject({
2318
2339
  fields: FieldsSchema,
2319
2340
  values: ValuesSchema.optional(),
2320
2341
  static: StaticSchema.optional(),
2342
+ arrays: ArraysSchema.optional(),
2321
2343
  editEndpoint: z2.string().min(1).optional()
2322
2344
  }).superRefine((spec, ctx) => {
2323
- const mappedNames = new Set(Object.values(spec.fields));
2345
+ const mappedNames = /* @__PURE__ */ new Set([
2346
+ ...Object.values(spec.fields),
2347
+ ...Object.keys(spec.arrays ?? {})
2348
+ ]);
2324
2349
  for (const key of Object.keys(spec.static ?? {})) {
2325
2350
  if (mappedNames.has(key)) {
2326
2351
  ctx.addIssue({
@@ -2334,6 +2359,9 @@ var InputSpecSchema = z2.strictObject({
2334
2359
  function isInputSpecKey(key) {
2335
2360
  return ALL_KEY_SET.has(key);
2336
2361
  }
2362
+ function isArrayInputSpecKey(key) {
2363
+ return ARRAY_KEY_SET.has(key);
2364
+ }
2337
2365
  function validateInputSpec(raw, row) {
2338
2366
  const parsed = InputSpecSchema.safeParse(raw);
2339
2367
  if (!parsed.success) {
@@ -2412,14 +2440,54 @@ function validateInputSpec(raw, row) {
2412
2440
  });
2413
2441
  }
2414
2442
  }
2443
+ const arrayOwner = /* @__PURE__ */ new Map();
2444
+ for (const [name, keys] of Object.entries(spec.arrays ?? {})) {
2445
+ const fieldKey = seenNames.get(name);
2446
+ if (fieldKey !== void 0) {
2447
+ issues.push({
2448
+ path: ["arrays", name],
2449
+ message: `inputSpec.arrays "${name}" is also the provider field of inputSpec.fields "${fieldKey}"`
2450
+ });
2451
+ }
2452
+ for (const key of keys) {
2453
+ if (allowed !== void 0 && !allowed.has(key)) {
2454
+ issues.push({
2455
+ path: ["arrays", name],
2456
+ message: `inputSpec.arrays "${key}" is not supported for ${row.type} rows`
2457
+ });
2458
+ }
2459
+ if (key in spec.fields) {
2460
+ issues.push({
2461
+ path: ["arrays", name],
2462
+ message: `inputSpec.arrays "${key}" is already mapped in inputSpec.fields`
2463
+ });
2464
+ }
2465
+ const owner = arrayOwner.get(key);
2466
+ if (owner === void 0) arrayOwner.set(key, name);
2467
+ else {
2468
+ issues.push({
2469
+ path: ["arrays", name],
2470
+ message: owner === name ? `inputSpec.arrays "${name}" lists "${key}" twice` : `inputSpec.arrays "${owner}" and "${name}" both take "${key}"`
2471
+ });
2472
+ }
2473
+ }
2474
+ }
2415
2475
  const supports = row.constraints.supports ?? [];
2416
2476
  for (const key of INPUT_SPEC_SUPPORTS_KEYS) {
2417
- if (key in spec.fields && !supports.includes(key)) {
2477
+ if (supports.includes(key)) continue;
2478
+ if (key in spec.fields) {
2418
2479
  issues.push({
2419
2480
  path: ["fields", key],
2420
2481
  message: `inputSpec.fields "${key}" needs "${key}" in constraints.supports`
2421
2482
  });
2422
2483
  }
2484
+ const arrayName = arrayOwner.get(key);
2485
+ if (arrayName !== void 0) {
2486
+ issues.push({
2487
+ path: ["arrays", arrayName],
2488
+ message: `inputSpec.arrays "${key}" needs "${key}" in constraints.supports`
2489
+ });
2490
+ }
2423
2491
  }
2424
2492
  if (issues.length > 0) return { ok: false, issues };
2425
2493
  return { ok: true, spec };
@@ -2641,6 +2709,7 @@ var CatalogCapabilitiesSchema = z3.looseObject({
2641
2709
  acceptsSourceVideo: z3.boolean().optional(),
2642
2710
  videoEdit: z3.boolean().optional(),
2643
2711
  framesExcludeReferences: z3.boolean().optional(),
2712
+ sourceVideoExcludesFrames: z3.boolean().optional(),
2644
2713
  lastFrameRequiresFirstFrame: z3.boolean().optional(),
2645
2714
  reasoning: z3.boolean().optional(),
2646
2715
  vision: z3.boolean().optional(),
@@ -4168,6 +4237,17 @@ function applyInputSpec(spec, req, refToUrl2, opts) {
4168
4237
  const mapped = spec.values?.[canonical]?.[String(value)];
4169
4238
  out[providerField] = mapped ?? serialised;
4170
4239
  }
4240
+ for (const [providerField, keys] of Object.entries(spec.arrays ?? {})) {
4241
+ const urls = [];
4242
+ for (const key of keys) {
4243
+ if (!isArrayInputSpecKey(key)) continue;
4244
+ const value = canonicalValue(req, key);
4245
+ if (value === void 0) continue;
4246
+ if (Array.isArray(value)) urls.push(...value.map(refToUrl2));
4247
+ else if (isMediaRef(value)) urls.push(refToUrl2(value));
4248
+ }
4249
+ if (urls.length > 0) out[providerField] = urls;
4250
+ }
4171
4251
  for (const [key, value] of Object.entries(spec.static ?? {})) {
4172
4252
  out[key] = value;
4173
4253
  }
@@ -8289,6 +8369,26 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
8289
8369
  });
8290
8370
  delete merged.sourceVideo;
8291
8371
  }
8372
+ const imageInputs = ["firstFrame", "lastFrame", "referenceImages"].filter(
8373
+ (field) => field === "referenceImages" ? compact(merged.referenceImages).length > 0 : merged[field] !== void 0
8374
+ );
8375
+ if (merged.sourceVideo !== void 0 && imageInputs.length > 0 && model.capabilities?.sourceVideoExcludesFrames) {
8376
+ if (onUnsupported === "error") {
8377
+ throw new ModelKitError({
8378
+ code: "unsupported_option",
8379
+ message: `${model.id} takes a source video or images, not both`,
8380
+ model: model.id
8381
+ });
8382
+ }
8383
+ for (const field of imageInputs) {
8384
+ warnings.push({
8385
+ code: "option_ignored",
8386
+ field,
8387
+ message: `${model.id} takes a source video or images, not both; ${field} dropped`
8388
+ });
8389
+ delete merged[field];
8390
+ }
8391
+ }
8292
8392
  if (merged.lastFrame !== void 0 && merged.firstFrame === void 0 && model.capabilities?.lastFrameRequiresFirstFrame) {
8293
8393
  if (onUnsupported === "error") {
8294
8394
  throw new ModelKitError({
@@ -9405,6 +9505,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
9405
9505
  export {
9406
9506
  ADAPTER_IDS,
9407
9507
  ADAPTER_KEYS,
9508
+ ARRAY_INPUT_SPEC_KEYS,
9408
9509
  AUDIO_INPUT_SPEC_KEYS,
9409
9510
  Catalog,
9410
9511
  CatalogModelSchema,
@@ -9447,6 +9548,7 @@ export {
9447
9548
  googleImageAdapter,
9448
9549
  hasAwsCredentials,
9449
9550
  higgsfieldAdapter,
9551
+ isArrayInputSpecKey,
9450
9552
  isInputSpecKey,
9451
9553
  isListed,
9452
9554
  isListedOn,