@shop-os/modelkit 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -89,6 +89,7 @@ __export(index_exports, {
89
89
  liveCatalog: () => liveCatalog,
90
90
  liveState: () => liveState,
91
91
  lumaAdapter: () => lumaAdapter,
92
+ lumaReframeTooTall: () => lumaReframeTooTall,
92
93
  mergeTextProviderOptions: () => mergeTextProviderOptions,
93
94
  missingTierKeys: () => missingTierKeys,
94
95
  model3dCall: () => model3dCall,
@@ -126,6 +127,7 @@ __export(index_exports, {
126
127
  sortCatalogRows: () => sortCatalogRows,
127
128
  streamObject: () => streamObject,
128
129
  streamText: () => streamText,
130
+ takesTargetAspectRatio: () => takesTargetAspectRatio,
129
131
  textUsageEvent: () => textUsageEvent,
130
132
  toGeneratedImage: () => toGeneratedImage,
131
133
  validateInputSpec: () => validateInputSpec,
@@ -6486,6 +6488,57 @@ function applyXaiVideoRules(model, req, onUnsupported, warnings) {
6486
6488
  });
6487
6489
  req.resolution = XAI_REFERENCE_MAX_RESOLUTION;
6488
6490
  }
6491
+ function takesTargetAspectRatio(model) {
6492
+ const ratios = model.constraints.aspectRatios ?? [];
6493
+ return (model.constraints.requires ?? []).includes("sourceVideo") && ratios.length > 0 && !ratios.includes("adaptive");
6494
+ }
6495
+ var LUMA_REFRAME_VERTICAL_MAX_RESOLUTION = "720p";
6496
+ function lumaReframeTooTall(req) {
6497
+ const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
6498
+ return vertical && req.resolution === "1080p";
6499
+ }
6500
+ function applyLumaVideoRules(model, req, onUnsupported, warnings) {
6501
+ if (model.adapter !== "luma" || !takesTargetAspectRatio(model)) return;
6502
+ if (req.aspectRatio === void 0 || req.aspectRatio === "adaptive") {
6503
+ const listed2 = model.constraints.aspectRatios ?? [];
6504
+ const fallback = model.defaults.aspectRatio !== void 0 && model.defaults.aspectRatio !== "adaptive" ? model.defaults.aspectRatio : listed2[0];
6505
+ const message2 = `${model.id} needs a target aspect ratio: ${listed2.join(", ")}`;
6506
+ if (onUnsupported === "error" || fallback === void 0) {
6507
+ throw new ModelKitError({
6508
+ code: "unsupported_option",
6509
+ message: message2,
6510
+ model: model.id,
6511
+ retryable: false
6512
+ });
6513
+ }
6514
+ warnings.push({
6515
+ code: "ratio_coerced",
6516
+ field: "aspectRatio",
6517
+ from: req.aspectRatio ?? "adaptive",
6518
+ to: fallback,
6519
+ message: message2
6520
+ });
6521
+ req.aspectRatio = fallback;
6522
+ }
6523
+ if (!lumaReframeTooTall(req)) return;
6524
+ const message = `${model.id} renders 9:16 and 3:4 reframes at up to ${LUMA_REFRAME_VERTICAL_MAX_RESOLUTION}`;
6525
+ if (onUnsupported === "error") {
6526
+ throw new ModelKitError({
6527
+ code: "unsupported_option",
6528
+ message,
6529
+ model: model.id,
6530
+ retryable: false
6531
+ });
6532
+ }
6533
+ warnings.push({
6534
+ code: "resolution_coerced",
6535
+ field: "resolution",
6536
+ from: req.resolution,
6537
+ to: LUMA_REFRAME_VERTICAL_MAX_RESOLUTION,
6538
+ message
6539
+ });
6540
+ req.resolution = LUMA_REFRAME_VERTICAL_MAX_RESOLUTION;
6541
+ }
6489
6542
  var MINIMAX_H3_INSERT = "minimax/h3-max/insert-video";
6490
6543
  var INSERT_MIN = 1.625;
6491
6544
  var INSERT_MAX = 60;
@@ -13914,16 +13967,12 @@ function lumaVideoMode(ctx) {
13914
13967
  }
13915
13968
  return mode;
13916
13969
  }
13917
- function reframeTooTall(req) {
13918
- const vertical = req.aspectRatio === "9:16" || req.aspectRatio === "3:4";
13919
- return vertical && req.resolution === "1080p";
13920
- }
13921
13970
  function sentResolution(req, mode) {
13922
- return mode === "reframe" && reframeTooTall(req) ? "720p" : req.resolution;
13971
+ return mode === "reframe" && lumaReframeTooTall(req) ? "720p" : req.resolution;
13923
13972
  }
13924
13973
  function lumaReframeResolution(req, ctx) {
13925
13974
  const requested = req.resolution;
13926
- if (requested === void 0 || !reframeTooTall(req)) return requested;
13975
+ if (requested === void 0 || !lumaReframeTooTall(req)) return requested;
13927
13976
  const message = `${ctx.model.id} renders 9:16 and 3:4 reframes at up to 720p`;
13928
13977
  if ((ctx.call.onUnsupported ?? "error") === "error") {
13929
13978
  throw new ModelKitError({
@@ -16653,6 +16702,7 @@ function resolveVideoOptions(model, request, onUnsupported = "error") {
16653
16702
  delete merged.previousInteractionId;
16654
16703
  }
16655
16704
  applyXaiVideoRules(model, merged, onUnsupported, warnings);
16705
+ applyLumaVideoRules(model, merged, onUnsupported, warnings);
16656
16706
  checkVideoRequired(model, merged);
16657
16707
  applyFalVideoRules(model, merged, request.aspectRatio, warnings);
16658
16708
  return { request: merged, warnings };
@@ -18251,6 +18301,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
18251
18301
  liveCatalog,
18252
18302
  liveState,
18253
18303
  lumaAdapter,
18304
+ lumaReframeTooTall,
18254
18305
  mergeTextProviderOptions,
18255
18306
  missingTierKeys,
18256
18307
  model3dCall,
@@ -18288,6 +18339,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
18288
18339
  sortCatalogRows,
18289
18340
  streamObject,
18290
18341
  streamText,
18342
+ takesTargetAspectRatio,
18291
18343
  textUsageEvent,
18292
18344
  toGeneratedImage,
18293
18345
  validateInputSpec,