@shop-os/modelkit 0.7.1 → 0.7.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
@@ -1769,6 +1769,15 @@ declare function resolveImageOptions(model: CatalogModel, request: ImageRequest,
1769
1769
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
1770
1770
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
1771
1771
 
1772
+ /**
1773
+ * A row whose aspect ratio is the frame it renders its source into (Ray 3.2 Reframe): it
1774
+ * requires a source video and lists ratios without "adaptive", so the ratio is a target. Every
1775
+ * other edit row keeps the source's framing.
1776
+ */
1777
+ declare function takesTargetAspectRatio(model: Pick<CatalogModel, "constraints">): boolean;
1778
+ /** Whether a Luma reframe asks for a vertical target at 1080p, which Luma does not render. */
1779
+ declare function lumaReframeTooTall(req: Pick<VideoRequest, "aspectRatio" | "resolution">): boolean;
1780
+
1772
1781
  /** `generateSpeech` on a `speech` row. */
1773
1782
  declare function resolveSpeechOptions(model: CatalogModel, request: SpeechRequest, onUnsupported?: OnUnsupported): ResolveResult<SpeechRequest>;
1774
1783
  /** `changeVoice` on a `voice-change` row. */
@@ -2142,4 +2151,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
2142
2151
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
2143
2152
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
2144
2153
 
2145
- 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 AudioNodeMethods, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, 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 LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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 SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, 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, VideoResolutionSchema, 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 VoiceChangeRequest, type VoiceGender, type VoiceOption, 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, lumaAdapter, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
2154
+ 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 AudioNodeMethods, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, 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 LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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 SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, 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, VideoResolutionSchema, 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 VoiceChangeRequest, type VoiceGender, type VoiceOption, 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, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.d.ts CHANGED
@@ -1769,6 +1769,15 @@ declare function resolveImageOptions(model: CatalogModel, request: ImageRequest,
1769
1769
  declare function resolveVideoOptions(model: CatalogModel, request: VideoRequest, onUnsupported?: OnUnsupported): ResolveResult<VideoRequest>;
1770
1770
  declare function resolveAudioOptions(model: CatalogModel, request: AudioRequest, onUnsupported?: OnUnsupported): ResolveResult<AudioRequest>;
1771
1771
 
1772
+ /**
1773
+ * A row whose aspect ratio is the frame it renders its source into (Ray 3.2 Reframe): it
1774
+ * requires a source video and lists ratios without "adaptive", so the ratio is a target. Every
1775
+ * other edit row keeps the source's framing.
1776
+ */
1777
+ declare function takesTargetAspectRatio(model: Pick<CatalogModel, "constraints">): boolean;
1778
+ /** Whether a Luma reframe asks for a vertical target at 1080p, which Luma does not render. */
1779
+ declare function lumaReframeTooTall(req: Pick<VideoRequest, "aspectRatio" | "resolution">): boolean;
1780
+
1772
1781
  /** `generateSpeech` on a `speech` row. */
1773
1782
  declare function resolveSpeechOptions(model: CatalogModel, request: SpeechRequest, onUnsupported?: OnUnsupported): ResolveResult<SpeechRequest>;
1774
1783
  /** `changeVoice` on a `voice-change` row. */
@@ -2142,4 +2151,4 @@ declare function describeThrown(cause: unknown): ThrownErrorInfo;
2142
2151
  /** Add the AI SDK `GeneratedFile` accessors to adapter image bytes. base64 is computed on first read. */
2143
2152
  declare function toGeneratedImage(image: ImageBytes): GeneratedImage;
2144
2153
 
2145
- 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 AudioNodeMethods, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, 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 LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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 SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, 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, VideoResolutionSchema, 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 VoiceChangeRequest, type VoiceGender, type VoiceOption, 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, lumaAdapter, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
2154
+ 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 AudioNodeMethods, 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 DubbingOutcome, type DubbingRequest, type DubbingResult, 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 LanguageOption, type Lifecycle, type LipsyncRequest, type LipsyncResult, type LiveCatalogState, MODEL3D_IMAGE_SLOTS, MODEL3D_MODELS, MODELS, type MaskBox, type MaskPoint, type MediaJobCallContext, type MediaNodeDefaults, type MediaOutput, type MediaPart, type MediaRef, type Model3dCall, type Model3dConstraints, type Model3dEndpoints, type Model3dFamily, type Model3dInputRefusal, type Model3dPricedInputs, type Model3dPricedOptions, type Model3dRequest, type Model3dResult, type Model3dStatus, type Model3dSubmission, type Model3dTexture, type Model3dViews, type Model3dWired, 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 SpeechRequest, type SubtitleOptions, type SubtitleTextStyle, type SupportedOption, type Surface, SurfaceSchema, type TextMethods, type TextModelInstance, type TranscriptWord, type TranscriptionRequest, type TranscriptionResult, 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, VideoResolutionSchema, 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 VoiceChangeRequest, type VoiceGender, type VoiceOption, 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, lumaAdapter, lumaReframeTooTall, mergeTextProviderOptions, missingTierKeys, model3dCall, model3dConstraints, model3dInputRefusal, model3dPricingSku, model3dResolution, model3dSeedFits, model3dSkus, model3dTexture, nearestAspectRatio, normalizeExposure, openaiImageAdapter, passthroughTextModel, planVideoTool, pollUntil, prepareMediaPart, primeCatalog, prodiaAdapter, readErrorBody, replicateAdapter, resetLiveCatalog, resolutionTier, resolveAudioOptions, resolveDubbingOptions, resolveImageOptions, resolveKeys, resolveLipsyncOptions, resolveSpeechOptions, resolveTranscriptionOptions, resolveVideoOptions, resolveVoiceChangeOptions, shouldRetry, sleep, sortCatalogRows, streamObject, streamText, takesTargetAspectRatio, textUsageEvent, toGeneratedImage, validateInputSpec, videoLengthViolation, videoToolConstraints, withRetry, xaiVideoAdapter };
package/dist/index.js CHANGED
@@ -6350,6 +6350,57 @@ function applyXaiVideoRules(model, req, onUnsupported, warnings) {
6350
6350
  });
6351
6351
  req.resolution = XAI_REFERENCE_MAX_RESOLUTION;
6352
6352
  }
6353
+ function takesTargetAspectRatio(model) {
6354
+ const ratios = model.constraints.aspectRatios ?? [];
6355
+ return (model.constraints.requires ?? []).includes("sourceVideo") && ratios.length > 0 && !ratios.includes("adaptive");
6356
+ }
6357
+ var LUMA_REFRAME_VERTICAL_MAX_RESOLUTION = "720p";
6358
+ function lumaReframeTooTall(req) {
6359
+ const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
6360
+ return vertical && req.resolution === "1080p";
6361
+ }
6362
+ function applyLumaVideoRules(model, req, onUnsupported, warnings) {
6363
+ if (model.adapter !== "luma" || !takesTargetAspectRatio(model)) return;
6364
+ if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") {
6365
+ const listed2 = model.constraints.aspectRatios ?? [];
6366
+ const fallback = model.defaults.aspectRatio !== void 0 && model.defaults.aspectRatio !== "adaptive" ? model.defaults.aspectRatio : listed2[0];
6367
+ const message2 = `${model.id} needs a target aspect ratio: ${listed2.join(", ")}`;
6368
+ if (onUnsupported === "error" || fallback === void 0) {
6369
+ throw new ModelKitError({
6370
+ code: "unsupported_option",
6371
+ message: message2,
6372
+ model: model.id,
6373
+ retryable: false
6374
+ });
6375
+ }
6376
+ warnings.push({
6377
+ code: "ratio_coerced",
6378
+ field: "aspectRatio",
6379
+ from: req.aspectRatio ?? "adaptive",
6380
+ to: fallback,
6381
+ message: message2
6382
+ });
6383
+ req.aspectRatio = fallback;
6384
+ }
6385
+ if (!lumaReframeTooTall(req)) return;
6386
+ const message = `${model.id} renders 9:16 and 3:4 reframes at up to ${LUMA_REFRAME_VERTICAL_MAX_RESOLUTION}`;
6387
+ if (onUnsupported === "error") {
6388
+ throw new ModelKitError({
6389
+ code: "unsupported_option",
6390
+ message,
6391
+ model: model.id,
6392
+ retryable: false
6393
+ });
6394
+ }
6395
+ warnings.push({
6396
+ code: "resolution_coerced",
6397
+ field: "resolution",
6398
+ from: req.resolution,
6399
+ to: LUMA_REFRAME_VERTICAL_MAX_RESOLUTION,
6400
+ message
6401
+ });
6402
+ req.resolution = LUMA_REFRAME_VERTICAL_MAX_RESOLUTION;
6403
+ }
6353
6404
  var MINIMAX_H3_INSERT = "minimax/h3-max/insert-video";
6354
6405
  var INSERT_MIN = 1.625;
6355
6406
  var INSERT_MAX = 60;
@@ -13621,24 +13672,24 @@ import { z as z25 } from "zod";
13621
13672
  function mp4DurationSeconds(bytes) {
13622
13673
  const moov = findBox(bytes, 0, bytes.length, "moov");
13623
13674
  if (!moov) return void 0;
13624
- const mvhd = findBox(bytes, moov.start + 8, moov.end, "mvhd");
13675
+ const mvhd = findBox(bytes, moov.body, moov.end, "mvhd");
13625
13676
  if (!mvhd) return void 0;
13626
13677
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
13627
- const size = mvhd.end - mvhd.start;
13628
- if (size < 8 + 4) return void 0;
13629
- const version = view.getUint8(mvhd.start + 8);
13678
+ const size = mvhd.end - mvhd.body;
13679
+ if (size < 4) return void 0;
13680
+ const version = view.getUint8(mvhd.body);
13630
13681
  if (version === 0) {
13631
- if (size < 8 + 4 + 4 + 4 + 4 + 4) return void 0;
13632
- const timescale = view.getUint32(mvhd.start + 8 + 4 + 4 + 4);
13633
- const duration = view.getUint32(mvhd.start + 8 + 4 + 4 + 4 + 4);
13682
+ if (size < 4 + 4 + 4 + 4 + 4) return void 0;
13683
+ const timescale = view.getUint32(mvhd.body + 4 + 4 + 4);
13684
+ const duration = view.getUint32(mvhd.body + 4 + 4 + 4 + 4);
13634
13685
  if (timescale === 0) return void 0;
13635
13686
  return duration / timescale;
13636
13687
  }
13637
13688
  if (version === 1) {
13638
- if (size < 8 + 4 + 8 + 8 + 4 + 8) return void 0;
13639
- const timescale = view.getUint32(mvhd.start + 8 + 4 + 8 + 8);
13640
- const high = view.getUint32(mvhd.start + 8 + 4 + 8 + 8 + 4);
13641
- const low = view.getUint32(mvhd.start + 8 + 4 + 8 + 8 + 4 + 4);
13689
+ if (size < 4 + 8 + 8 + 4 + 8) return void 0;
13690
+ const timescale = view.getUint32(mvhd.body + 4 + 8 + 8);
13691
+ const high = view.getUint32(mvhd.body + 4 + 8 + 8 + 4);
13692
+ const low = view.getUint32(mvhd.body + 4 + 8 + 8 + 4 + 4);
13642
13693
  if (timescale === 0) return void 0;
13643
13694
  return (high * 2 ** 32 + low) / timescale;
13644
13695
  }
@@ -13648,15 +13699,23 @@ function findBox(bytes, from, to, type) {
13648
13699
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
13649
13700
  let offset = from;
13650
13701
  while (offset + 8 <= to) {
13651
- const size = view.getUint32(offset);
13702
+ let size = view.getUint32(offset);
13703
+ let header = 8;
13652
13704
  const name = String.fromCharCode(
13653
13705
  view.getUint8(offset + 4),
13654
13706
  view.getUint8(offset + 5),
13655
13707
  view.getUint8(offset + 6),
13656
13708
  view.getUint8(offset + 7)
13657
13709
  );
13658
- if (size < 8 || offset + size > to) return void 0;
13659
- if (name === type) return { start: offset, end: offset + size };
13710
+ if (size === 1) {
13711
+ if (offset + 16 > to) return void 0;
13712
+ size = view.getUint32(offset + 8) * 2 ** 32 + view.getUint32(offset + 12);
13713
+ header = 16;
13714
+ } else if (size === 0) {
13715
+ size = to - offset;
13716
+ }
13717
+ if (size < header || offset + size > to) return void 0;
13718
+ if (name === type) return { body: offset + header, end: offset + size };
13660
13719
  offset += size;
13661
13720
  }
13662
13721
  return void 0;
@@ -13669,6 +13728,7 @@ var IMAGE_TIMEOUT_MS = 5 * 6e4;
13669
13728
  var VIDEO_POLL_INTERVAL_MS = 5e3;
13670
13729
  var VIDEO_TIMEOUT_MS = 20 * 6e4;
13671
13730
  var PROMPT_MAX_CHARS = 6e3;
13731
+ var OUTPUT_URL_TTL_MS = 55 * 6e4;
13672
13732
  var LUMA_IMAGE_MODEL_IDS = /* @__PURE__ */ new Set(["uni-1", "uni-1-max"]);
13673
13733
  var LUMA_VIDEO_MODEL_ID = "ray-3.2";
13674
13734
  var LUMA_VIDEO_MODES = /* @__PURE__ */ new Map([
@@ -13687,6 +13747,9 @@ function lumaRowRefusal(row2) {
13687
13747
  }
13688
13748
  return `luma has no ${row2.type} rows`;
13689
13749
  }
13750
+ function lumaModel(ctx) {
13751
+ return ctx.model.providerModelId.toLowerCase();
13752
+ }
13690
13753
  function lumaBase(ctx) {
13691
13754
  return ctx.endpoints?.luma ?? DEFAULT_BASE_URL;
13692
13755
  }
@@ -13729,8 +13792,23 @@ function imageRef(ref) {
13729
13792
  if ("url" in ref) return { url: ref.url };
13730
13793
  return { data: mediaRefToBase64(ref.bytes), media_type: ref.mime };
13731
13794
  }
13795
+ var VIDEO_TYPES_BY_EXTENSION = /* @__PURE__ */ new Map([
13796
+ ["mp4", "video/mp4"],
13797
+ ["m4v", "video/mp4"],
13798
+ ["mov", "video/quicktime"],
13799
+ ["webm", "video/webm"]
13800
+ ]);
13801
+ function videoUrlType(url) {
13802
+ let path = url;
13803
+ try {
13804
+ path = new URL(url).pathname;
13805
+ } catch {
13806
+ }
13807
+ const extension = path.slice(path.lastIndexOf(".") + 1).toLowerCase();
13808
+ return VIDEO_TYPES_BY_EXTENSION.get(extension) ?? "video/mp4";
13809
+ }
13732
13810
  function videoRef(ref) {
13733
- if ("url" in ref) return { url: ref.url, media_type: "video/mp4" };
13811
+ if ("url" in ref) return { url: ref.url, media_type: videoUrlType(ref.url) };
13734
13812
  const mediaType = ref.mime.startsWith("video/") ? ref.mime : "video/mp4";
13735
13813
  return { data: mediaRefToBase64(ref.bytes), media_type: mediaType };
13736
13814
  }
@@ -13780,16 +13858,12 @@ function lumaVideoMode(ctx) {
13780
13858
  }
13781
13859
  return mode;
13782
13860
  }
13783
- function reframeTooTall(req) {
13784
- const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
13785
- return vertical && req.resolution === "1080p";
13786
- }
13787
13861
  function sentResolution(req, mode) {
13788
- return mode === "reframe" && reframeTooTall(req) ? "720p" : req.resolution;
13862
+ return mode === "reframe" && lumaReframeTooTall(req) ? "720p" : req.resolution;
13789
13863
  }
13790
13864
  function lumaReframeResolution(req, ctx) {
13791
13865
  const requested = req.resolution;
13792
- if (requested === void 0 || !reframeTooTall(req)) return requested;
13866
+ if (requested === void 0 || !lumaReframeTooTall(req)) return requested;
13793
13867
  const message = `${ctx.model.id} renders 9:16 and 3:4 reframes at up to 720p`;
13794
13868
  if ((ctx.call.onUnsupported ?? "error") === "error") {
13795
13869
  throw new ModelKitError({
@@ -13898,14 +13972,22 @@ async function lumaRequest(ctx, url, body) {
13898
13972
  }
13899
13973
  return res;
13900
13974
  }
13975
+ async function parseGeneration(res) {
13976
+ try {
13977
+ const parsed = lumaGenerationSchema.safeParse(await res.json());
13978
+ return parsed.success ? parsed.data : void 0;
13979
+ } catch {
13980
+ return "not_json";
13981
+ }
13982
+ }
13901
13983
  async function submitGeneration(ctx, body) {
13902
13984
  const retryOptions = mediaRetryOptions(ctx.call, ctx.signal);
13903
13985
  const res = await withRetry(
13904
13986
  () => lumaRequest(ctx, `${lumaBase(ctx)}/v1/generations`, JSON.stringify(body)),
13905
13987
  retryOptions
13906
13988
  );
13907
- const parsed = lumaGenerationSchema.safeParse(await res.json());
13908
- if (!parsed.success) {
13989
+ const generation = await parseGeneration(res);
13990
+ if (generation === void 0 || generation === "not_json") {
13909
13991
  throw new ModelKitError({
13910
13992
  code: "provider_rejected",
13911
13993
  message: "Luma submit returned no generation id",
@@ -13914,13 +13996,20 @@ async function submitGeneration(ctx, body) {
13914
13996
  retryable: false
13915
13997
  });
13916
13998
  }
13917
- return parsed.data;
13999
+ return generation;
13918
14000
  }
13919
14001
  async function readGeneration(ctx, id) {
13920
14002
  const res = await lumaRequest(ctx, `${lumaBase(ctx)}/v1/generations/${id}`);
13921
- const payload = JsonValueSchema.parse(await res.json());
13922
- const parsed = lumaGenerationSchema.safeParse(payload);
13923
- if (!parsed.success) {
14003
+ const generation = await parseGeneration(res);
14004
+ if (generation === "not_json") {
14005
+ throw new ModelKitError({
14006
+ code: "network",
14007
+ message: "Luma returned a poll response that is not JSON",
14008
+ provider: "luma",
14009
+ model: ctx.model.id
14010
+ });
14011
+ }
14012
+ if (generation === void 0) {
13924
14013
  throw new ModelKitError({
13925
14014
  code: "provider_rejected",
13926
14015
  message: "Luma returned an unreadable generation",
@@ -13929,14 +14018,12 @@ async function readGeneration(ctx, id) {
13929
14018
  retryable: false
13930
14019
  });
13931
14020
  }
13932
- return parsed.data;
14021
+ return generation;
13933
14022
  }
13934
14023
  function outputUrl(generation, type) {
13935
14024
  const outputs = generation.output ?? [];
13936
- const match = outputs.find((item) => item.type === type && item.url);
13937
- if (match?.url) return match.url;
13938
- const fallback = outputs.find((item) => item.url);
13939
- return fallback?.url;
14025
+ const match = outputs.find((item) => item.type === type && item.url) ?? outputs.find((item) => item.type === void 0 && item.url);
14026
+ return match?.url;
13940
14027
  }
13941
14028
  async function readGenerationOnce(ctx, id) {
13942
14029
  try {
@@ -13975,21 +14062,22 @@ async function checkGeneration(ctx, id, type) {
13975
14062
  return void 0;
13976
14063
  }
13977
14064
  async function downloadBytes(ctx, url, fallback) {
13978
- let bytes;
13979
- let header;
13980
- try {
13981
- const out = await mediaRefToBytes({ url }, ctx.fetch, {
13982
- ...ctx.signal !== void 0 && { signal: ctx.signal },
13983
- provider: "luma",
13984
- model: ctx.model.id
13985
- });
13986
- bytes = out.bytes;
13987
- header = out.mime;
13988
- } catch (cause) {
13989
- throw classifyThrown("luma", cause, ctx.model.id);
13990
- }
14065
+ const { bytes, mime: header } = await withRetry(
14066
+ async () => {
14067
+ try {
14068
+ return await mediaRefToBytes({ url }, ctx.fetch, {
14069
+ ...ctx.signal !== void 0 && { signal: ctx.signal },
14070
+ provider: "luma",
14071
+ model: ctx.model.id
14072
+ });
14073
+ } catch (cause) {
14074
+ throw classifyThrown("luma", cause, ctx.model.id);
14075
+ }
14076
+ },
14077
+ mediaRetryOptions(ctx.call, ctx.signal)
14078
+ );
13991
14079
  const kind = fallback.split("/")[0];
13992
- const usable = header !== void 0 && header.startsWith(`${kind}/`);
14080
+ const usable = header.startsWith(`${kind}/`);
13993
14081
  return { bytes, mime: usable ? header : fallback };
13994
14082
  }
13995
14083
  function imageUsage2(ctx) {
@@ -14004,15 +14092,12 @@ function imageUsage2(ctx) {
14004
14092
  }
14005
14093
  var GENERATE_SECONDS = 5;
14006
14094
  var MAX_PLAUSIBLE_SECONDS = 60;
14007
- function billedSeconds(req, mode, bytes) {
14008
- if (mode === "generate") return GENERATE_SECONDS;
14095
+ function editedSeconds(req, bytes) {
14009
14096
  const measured = mp4DurationSeconds(bytes);
14010
- const source2 = req.sourceVideo;
14011
- const length = measured !== void 0 && measured > 0 && measured <= MAX_PLAUSIBLE_SECONDS ? measured : source2 !== void 0 && "url" in source2 ? source2.durationSeconds : void 0;
14097
+ const length = measured !== void 0 && measured > 0 && measured <= MAX_PLAUSIBLE_SECONDS ? measured : req.sourceVideo?.durationSeconds;
14012
14098
  return Math.max(length ?? 0, GENERATE_SECONDS);
14013
14099
  }
14014
- function videoUsage4(ctx, req, mode, bytes) {
14015
- const seconds3 = billedSeconds(req, mode, bytes);
14100
+ function videoUsage4(ctx, req, mode, seconds3) {
14016
14101
  const event = {
14017
14102
  model: ctx.model.id,
14018
14103
  provider: "luma",
@@ -14027,7 +14112,7 @@ function videoUsage4(ctx, req, mode, bytes) {
14027
14112
  }
14028
14113
  function imageBody(req, ctx, outputFormat) {
14029
14114
  const prompt = checkPrompt(req, ctx);
14030
- const model = ctx.model.providerModelId;
14115
+ const model = lumaModel(ctx);
14031
14116
  const ratio = req.aspectRatio !== "adaptive" ? req.aspectRatio : void 0;
14032
14117
  const [source2, ...rest] = req.references ?? [];
14033
14118
  if (source2 === void 0) {
@@ -14055,7 +14140,7 @@ function imageBody(req, ctx, outputFormat) {
14055
14140
  }
14056
14141
  function videoBody(req, ctx, mode) {
14057
14142
  const prompt = checkPrompt(req, ctx);
14058
- const model = ctx.model.providerModelId;
14143
+ const model = lumaModel(ctx);
14059
14144
  const hasReferences = (req.referenceImages ?? []).length + (req.referenceVideos ?? []).length + (req.referenceAudios ?? []).length > 0;
14060
14145
  if (hasReferences) {
14061
14146
  refuseOrDrop(
@@ -14137,7 +14222,7 @@ function videoBody(req, ctx, mode) {
14137
14222
  async function generateLumaImage(req, ctx) {
14138
14223
  throwIfAborted(ctx.signal);
14139
14224
  lumaKey(ctx);
14140
- if (!LUMA_IMAGE_MODEL_IDS.has(ctx.model.providerModelId.toLowerCase())) {
14225
+ if (!LUMA_IMAGE_MODEL_IDS.has(lumaModel(ctx))) {
14141
14226
  throw new ModelKitError({
14142
14227
  code: "unsupported_option",
14143
14228
  message: `luma has no image mapping for "${ctx.model.providerModelId}"`,
@@ -14170,16 +14255,25 @@ function lumaVideoJob(ctx, req, mode, id) {
14170
14255
  return { status: "pending" };
14171
14256
  },
14172
14257
  async result(opts) {
14173
- const signal = opts?.signal ?? ctx.signal;
14174
- const url = await pollUntil(checkGeneration.bind(null, ctx, id, "video"), {
14258
+ const signal = combineSignals(ctx.signal, opts?.signal);
14259
+ const jobCtx = { ...ctx, ...signal !== void 0 && { signal } };
14260
+ const url = await pollUntil(checkGeneration.bind(null, jobCtx, id, "video"), {
14175
14261
  intervalMs: opts?.pollIntervalMs ?? VIDEO_POLL_INTERVAL_MS,
14176
14262
  timeoutMs: opts?.timeoutMs ?? VIDEO_TIMEOUT_MS,
14177
14263
  ...signal !== void 0 && { signal }
14178
14264
  });
14179
- const video = await downloadBytes(ctx, url, "video/mp4");
14265
+ if (mode === "generate") {
14266
+ const result2 = {
14267
+ video: { url, expiresAt: new Date(Date.now() + OUTPUT_URL_TTL_MS) },
14268
+ usage: videoUsage4(jobCtx, req, mode, GENERATE_SECONDS),
14269
+ raw: { id }
14270
+ };
14271
+ return result2;
14272
+ }
14273
+ const video = await downloadBytes(jobCtx, url, "video/mp4");
14180
14274
  const result = {
14181
14275
  video,
14182
- usage: videoUsage4(ctx, req, mode, video.bytes),
14276
+ usage: videoUsage4(jobCtx, req, mode, editedSeconds(req, video.bytes)),
14183
14277
  raw: { id }
14184
14278
  };
14185
14279
  return result;
@@ -14189,7 +14283,7 @@ function lumaVideoJob(ctx, req, mode, id) {
14189
14283
  async function generateLumaVideo(req, ctx) {
14190
14284
  throwIfAborted(ctx.signal);
14191
14285
  lumaKey(ctx);
14192
- if (ctx.model.providerModelId.toLowerCase() !== LUMA_VIDEO_MODEL_ID) {
14286
+ if (lumaModel(ctx) !== LUMA_VIDEO_MODEL_ID) {
14193
14287
  throw new ModelKitError({
14194
14288
  code: "unsupported_option",
14195
14289
  message: `luma has no video mapping for "${ctx.model.providerModelId}"`,
@@ -16519,6 +16613,7 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
16519
16613
  delete merged.previousInteractionId;
16520
16614
  }
16521
16615
  applyXaiVideoRules(model, merged, onUnsupported, warnings);
16616
+ applyLumaVideoRules(model, merged, onUnsupported, warnings);
16522
16617
  checkVideoRequired(model, merged);
16523
16618
  applyFalVideoRules(model, merged, request.aspectRatio, warnings);
16524
16619
  return { request: merged, warnings };
@@ -18123,6 +18218,7 @@ export {
18123
18218
  liveCatalog,
18124
18219
  liveState,
18125
18220
  lumaAdapter,
18221
+ lumaReframeTooTall,
18126
18222
  mergeTextProviderOptions,
18127
18223
  missingTierKeys,
18128
18224
  model3dCall,
@@ -18160,6 +18256,7 @@ export {
18160
18256
  sortCatalogRows,
18161
18257
  streamObject,
18162
18258
  streamText,
18259
+ takesTargetAspectRatio,
18163
18260
  textUsageEvent,
18164
18261
  toGeneratedImage,
18165
18262
  validateInputSpec,