@shop-os/modelkit 0.4.3 → 0.4.5

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
@@ -1057,12 +1057,30 @@ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages",
1057
1057
  type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
1058
1058
  type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
1059
1059
  declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
1060
+ /**
1061
+ * Sends `{ width, height }` in one provider field, computed from the request's
1062
+ * aspect ratio and size. `areas` is the target pixel count per size tier; the
1063
+ * long side is capped at `maxSide` and both sides round down to `multipleOf`.
1064
+ */
1065
+ declare const DimensionsSchema: z.ZodObject<{
1066
+ field: z.ZodString;
1067
+ areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
1068
+ maxSide: z.ZodOptional<z.ZodNumber>;
1069
+ multipleOf: z.ZodOptional<z.ZodNumber>;
1070
+ }, z.core.$strict>;
1071
+ type InputSpecDimensions = z.infer<typeof DimensionsSchema>;
1060
1072
  declare const InputSpecSchema: z.ZodObject<{
1061
1073
  fields: z.ZodRecord<z.ZodString, z.ZodString>;
1062
1074
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
1063
1075
  static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1064
1076
  arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
1065
1077
  editEndpoint: z.ZodOptional<z.ZodString>;
1078
+ dimensions: z.ZodOptional<z.ZodObject<{
1079
+ field: z.ZodString;
1080
+ areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
1081
+ maxSide: z.ZodOptional<z.ZodNumber>;
1082
+ multipleOf: z.ZodOptional<z.ZodNumber>;
1083
+ }, z.core.$strict>>;
1066
1084
  }, z.core.$strict>;
1067
1085
  type InputSpec = z.infer<typeof InputSpecSchema>;
1068
1086
  interface InputSpecIssue {
@@ -1473,4 +1491,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1473
1491
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1474
1492
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1475
1493
 
1476
- 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 };
1494
+ 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 InputSpecDimensions, 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
@@ -1057,12 +1057,30 @@ declare const ARRAY_INPUT_SPEC_KEYS: readonly ["firstFrame", "referenceImages",
1057
1057
  type ArrayInputSpecKey = (typeof ARRAY_INPUT_SPEC_KEYS)[number];
1058
1058
  type InputSpecKey = (typeof VIDEO_INPUT_SPEC_KEYS)[number] | (typeof IMAGE_INPUT_SPEC_KEYS)[number] | (typeof AUDIO_INPUT_SPEC_KEYS)[number];
1059
1059
  declare const INPUT_SPEC_SUPPORTS_KEYS: readonly SupportedOption[];
1060
+ /**
1061
+ * Sends `{ width, height }` in one provider field, computed from the request's
1062
+ * aspect ratio and size. `areas` is the target pixel count per size tier; the
1063
+ * long side is capped at `maxSide` and both sides round down to `multipleOf`.
1064
+ */
1065
+ declare const DimensionsSchema: z.ZodObject<{
1066
+ field: z.ZodString;
1067
+ areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
1068
+ maxSide: z.ZodOptional<z.ZodNumber>;
1069
+ multipleOf: z.ZodOptional<z.ZodNumber>;
1070
+ }, z.core.$strict>;
1071
+ type InputSpecDimensions = z.infer<typeof DimensionsSchema>;
1060
1072
  declare const InputSpecSchema: z.ZodObject<{
1061
1073
  fields: z.ZodRecord<z.ZodString, z.ZodString>;
1062
1074
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
1063
1075
  static: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1064
1076
  arrays: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
1065
1077
  editEndpoint: z.ZodOptional<z.ZodString>;
1078
+ dimensions: z.ZodOptional<z.ZodObject<{
1079
+ field: z.ZodString;
1080
+ areas: z.ZodRecord<z.ZodString, z.ZodNumber>;
1081
+ maxSide: z.ZodOptional<z.ZodNumber>;
1082
+ multipleOf: z.ZodOptional<z.ZodNumber>;
1083
+ }, z.core.$strict>>;
1066
1084
  }, z.core.$strict>;
1067
1085
  type InputSpec = z.infer<typeof InputSpecSchema>;
1068
1086
  interface InputSpecIssue {
@@ -1473,4 +1491,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
1473
1491
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
1474
1492
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
1475
1493
 
1476
- 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 };
1494
+ 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 InputSpecDimensions, 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
@@ -2498,16 +2498,26 @@ var ArraysSchema = z2.record(z2.string().min(1), z2.array(z2.string()).min(1)).s
2498
2498
  }
2499
2499
  }
2500
2500
  });
2501
+ var DimensionsSchema = z2.strictObject({
2502
+ field: z2.string().min(1),
2503
+ areas: z2.record(z2.string(), z2.number().int().positive()).refine((a) => Object.keys(a).length > 0, {
2504
+ message: "inputSpec.dimensions.areas must name at least one size"
2505
+ }),
2506
+ maxSide: z2.number().int().positive().optional(),
2507
+ multipleOf: z2.number().int().positive().optional()
2508
+ });
2501
2509
  var InputSpecSchema = z2.strictObject({
2502
2510
  fields: FieldsSchema,
2503
2511
  values: ValuesSchema.optional(),
2504
2512
  static: StaticSchema.optional(),
2505
2513
  arrays: ArraysSchema.optional(),
2506
- editEndpoint: z2.string().min(1).optional()
2514
+ editEndpoint: z2.string().min(1).optional(),
2515
+ dimensions: DimensionsSchema.optional()
2507
2516
  }).superRefine((spec, ctx) => {
2508
2517
  const mappedNames = /* @__PURE__ */ new Set([
2509
2518
  ...Object.values(spec.fields),
2510
- ...Object.keys(spec.arrays ?? {})
2519
+ ...Object.keys(spec.arrays ?? {}),
2520
+ ...spec.dimensions ? [spec.dimensions.field] : []
2511
2521
  ]);
2512
2522
  for (const key of Object.keys(spec.static ?? {})) {
2513
2523
  if (mappedNames.has(key)) {
@@ -2542,7 +2552,10 @@ function validateInputSpec(raw, row) {
2542
2552
  return {
2543
2553
  ok: false,
2544
2554
  issues: [
2545
- { path: [], message: "inputSpec is only supported on replicate and fal rows" }
2555
+ {
2556
+ path: [],
2557
+ message: "inputSpec is only supported on replicate and fal rows"
2558
+ }
2546
2559
  ]
2547
2560
  };
2548
2561
  }
@@ -2635,6 +2648,29 @@ function validateInputSpec(raw, row) {
2635
2648
  }
2636
2649
  }
2637
2650
  }
2651
+ if (spec.dimensions !== void 0) {
2652
+ if (row.type !== "image") {
2653
+ issues.push({
2654
+ path: ["dimensions"],
2655
+ message: "inputSpec.dimensions is only supported on image rows"
2656
+ });
2657
+ }
2658
+ for (const key of ["aspectRatio", "size"]) {
2659
+ if (key in spec.fields) {
2660
+ issues.push({
2661
+ path: ["fields", key],
2662
+ message: `inputSpec.fields "${key}" cannot be set with inputSpec.dimensions, which sends it`
2663
+ });
2664
+ }
2665
+ }
2666
+ const owner = seenNames.get(spec.dimensions.field);
2667
+ if (owner !== void 0 || spec.dimensions.field in (spec.arrays ?? {})) {
2668
+ issues.push({
2669
+ path: ["dimensions", "field"],
2670
+ message: `inputSpec.dimensions.field "${spec.dimensions.field}" is already a mapped provider field`
2671
+ });
2672
+ }
2673
+ }
2638
2674
  const supports = row.constraints.supports ?? [];
2639
2675
  for (const key of INPUT_SPEC_SUPPORTS_KEYS) {
2640
2676
  if (supports.includes(key)) continue;
@@ -4096,6 +4132,20 @@ import { z as z11 } from "zod";
4096
4132
 
4097
4133
  // src/catalog/video-tools-spec.ts
4098
4134
  import { z as z10 } from "zod";
4135
+
4136
+ // src/video-length.ts
4137
+ function tenths(seconds2) {
4138
+ return Math.round(seconds2 * 10) / 10;
4139
+ }
4140
+ function overMax(seconds2, max) {
4141
+ return seconds2 > max && tenths(seconds2) > max;
4142
+ }
4143
+ function overTotal(lengths, total) {
4144
+ const sum = (values) => values.reduce((acc, len) => acc + len, 0);
4145
+ return sum(lengths) > total && tenths(sum(lengths.map(tenths))) > total;
4146
+ }
4147
+
4148
+ // src/catalog/video-tools-spec.ts
4099
4149
  var RangeSchema2 = z10.object({ min: z10.number(), max: z10.number() });
4100
4150
  var ToolSchema = z10.object({
4101
4151
  kind: z10.enum(["upscale", "interpolate", "hdr"]),
@@ -4139,7 +4189,7 @@ function planVideoTool(row, req) {
4139
4189
  return fail("The source video's width, height and duration are required");
4140
4190
  }
4141
4191
  const maxSeconds = row.constraints.sourceVideoSeconds?.max;
4142
- if (maxSeconds !== void 0 && durationSeconds > maxSeconds) {
4192
+ if (maxSeconds !== void 0 && overMax(durationSeconds, maxSeconds)) {
4143
4193
  return fail(`${row.label} takes source videos up to ${maxSeconds} seconds.`);
4144
4194
  }
4145
4195
  const base = {
@@ -4451,11 +4501,37 @@ function applyInputSpec(spec, req, refToUrl2, opts) {
4451
4501
  }
4452
4502
  if (urls.length > 0) out[providerField] = urls;
4453
4503
  }
4504
+ if (spec.dimensions !== void 0) {
4505
+ const dims = dimensionsFor(spec.dimensions, req);
4506
+ if (dims !== void 0) out[spec.dimensions.field] = dims;
4507
+ }
4454
4508
  for (const [key, value] of Object.entries(spec.static ?? {})) {
4455
4509
  out[key] = value;
4456
4510
  }
4457
4511
  return out;
4458
4512
  }
4513
+ function dimensionsFor(dims, req) {
4514
+ const ratio = req.aspectRatio;
4515
+ const size = req.size;
4516
+ if (ratio === void 0 || ratio === "adaptive" || size === void 0) return void 0;
4517
+ const area = dims.areas[size];
4518
+ const match = /^(\d+):(\d+)$/.exec(ratio);
4519
+ if (area === void 0 || match === null) return void 0;
4520
+ const r = Number(match[1]) / Number(match[2]);
4521
+ let width = Math.sqrt(area * r);
4522
+ let height = width / r;
4523
+ const longest = Math.max(width, height);
4524
+ if (dims.maxSide !== void 0 && longest > dims.maxSide) {
4525
+ const scale = dims.maxSide / longest;
4526
+ width *= scale;
4527
+ height *= scale;
4528
+ }
4529
+ const step = dims.multipleOf ?? 1;
4530
+ return {
4531
+ width: Math.max(step, Math.floor(width / step) * step),
4532
+ height: Math.max(step, Math.floor(height / step) * step)
4533
+ };
4534
+ }
4459
4535
  function resolveRowInputSpec(req, ctx) {
4460
4536
  const raw = ctx.model.providerOptions?.["modelkit"]?.["inputSpec"];
4461
4537
  if (raw === void 0) return { kind: "absent" };
@@ -8517,7 +8593,7 @@ function videoLengthViolation(model, input) {
8517
8593
  const lengths = (input.referenceVideos ?? []).map(knownLength);
8518
8594
  if (limits?.max !== void 0) {
8519
8595
  const max = limits.max;
8520
- const i = lengths.findIndex((len) => len !== void 0 && len > max);
8596
+ const i = lengths.findIndex((len) => len !== void 0 && overMax(len, max));
8521
8597
  if (i >= 0)
8522
8598
  return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
8523
8599
  }
@@ -8529,14 +8605,17 @@ function videoLengthViolation(model, input) {
8529
8605
  const source = knownLength(input.sourceVideo);
8530
8606
  const sourceLimits = model.constraints.sourceVideoSeconds;
8531
8607
  if (limits?.total !== void 0) {
8532
- const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
8533
- const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
8534
- if (sum > limits.total)
8608
+ const counted = [
8609
+ ...lengths.filter((len) => len !== void 0),
8610
+ ...sourceLimits?.inReferenceTotal && source !== void 0 ? [source] : []
8611
+ ];
8612
+ const sum = counted.reduce((acc, len) => acc + len, 0);
8613
+ if (overTotal(counted, limits.total))
8535
8614
  return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
8536
8615
  }
8537
8616
  if (source === void 0) return void 0;
8538
8617
  const sourceMin = effectiveMin(sourceLimits, input.taskType);
8539
- if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
8618
+ if (sourceLimits?.max !== void 0 && overMax(source, sourceLimits.max))
8540
8619
  return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
8541
8620
  if (sourceMin !== void 0 && source < sourceMin)
8542
8621
  return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;