@shop-os/modelkit 0.7.3 → 0.7.6

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/catalog.js CHANGED
@@ -6318,14 +6318,14 @@ function xaiReferenceMode(model, req) {
6318
6318
  const takesLastFrame = (model.constraints.supports ?? []).includes("lastFrame");
6319
6319
  return (req.referenceImages ?? []).length > 0 || takesLastFrame && req.lastFrame !== void 0;
6320
6320
  }
6321
- function applyXaiVideoRules(model, req, onUnsupported, warnings) {
6322
- if (model.adapter !== "xai-video" || req.resolution !== "1080p") return;
6323
- if (!xaiReferenceMode(model, req)) return;
6321
+ function xaiReferenceResolution(model, req, onUnsupported, warnings, provider) {
6322
+ if (req.resolution !== "1080p" || !xaiReferenceMode(model, req)) return void 0;
6324
6323
  const message = xaiReferenceResolutionMessage(model.id);
6325
6324
  if (onUnsupported === "error") {
6326
6325
  throw new ModelKitError({
6327
6326
  code: "unsupported_option",
6328
6327
  message,
6328
+ ...provider === void 0 ? {} : { provider },
6329
6329
  model: model.id,
6330
6330
  retryable: false
6331
6331
  });
@@ -6337,7 +6337,12 @@ function applyXaiVideoRules(model, req, onUnsupported, warnings) {
6337
6337
  to: XAI_REFERENCE_MAX_RESOLUTION,
6338
6338
  message
6339
6339
  });
6340
- req.resolution = XAI_REFERENCE_MAX_RESOLUTION;
6340
+ return XAI_REFERENCE_MAX_RESOLUTION;
6341
+ }
6342
+ function applyXaiVideoRules(model, req, onUnsupported, warnings) {
6343
+ if (model.adapter !== "xai-video") return;
6344
+ const lowered = xaiReferenceResolution(model, req, onUnsupported, warnings);
6345
+ if (lowered !== void 0) req.resolution = lowered;
6341
6346
  }
6342
6347
  function takesTargetAspectRatio(model) {
6343
6348
  const ratios = model.constraints.aspectRatios ?? [];
@@ -6550,6 +6555,161 @@ var MODEL3D_IMAGE_SLOTS = {
6550
6555
  ordered: ["image", "left", "back", "right"],
6551
6556
  unordered: ["image", "back", "left", "right", "top"]
6552
6557
  };
6558
+ var MODEL3D_FAMILY_RULES = {
6559
+ trellis: {
6560
+ textPath: false,
6561
+ views: ["none"],
6562
+ multiImage: false,
6563
+ texture: null,
6564
+ pbr: false,
6565
+ seed: true,
6566
+ textureRef: false,
6567
+ resolutions: "integer"
6568
+ },
6569
+ hunyuan: {
6570
+ textPath: true,
6571
+ views: ["none", "named"],
6572
+ multiImage: false,
6573
+ // generate_type
6574
+ texture: { none: "Geometry", standard: "Normal" },
6575
+ pbr: true,
6576
+ seed: false,
6577
+ textureRef: false,
6578
+ resolutions: null
6579
+ },
6580
+ tripo: {
6581
+ textPath: true,
6582
+ views: ["none", "ordered"],
6583
+ multiImage: true,
6584
+ // texture_quality; null sends an untextured model.
6585
+ texture: { none: null, standard: "standard", detailed: "detailed" },
6586
+ pbr: true,
6587
+ seed: true,
6588
+ textureRef: false,
6589
+ resolutions: null
6590
+ },
6591
+ rodin: {
6592
+ textPath: true,
6593
+ views: ["none", "unordered"],
6594
+ multiImage: false,
6595
+ texture: null,
6596
+ pbr: false,
6597
+ seed: true,
6598
+ textureRef: false,
6599
+ resolutions: null
6600
+ },
6601
+ meshy: {
6602
+ textPath: true,
6603
+ views: ["none", "unordered"],
6604
+ multiImage: true,
6605
+ // The text endpoint's mode; the image endpoints take should_texture.
6606
+ texture: { none: "preview", standard: "full" },
6607
+ pbr: true,
6608
+ seed: true,
6609
+ textureRef: true,
6610
+ resolutions: null
6611
+ },
6612
+ hi3d: {
6613
+ textPath: false,
6614
+ views: ["none", "named"],
6615
+ multiImage: true,
6616
+ // enable_texture
6617
+ texture: { none: false, standard: true },
6618
+ pbr: true,
6619
+ seed: false,
6620
+ textureRef: false,
6621
+ resolutions: { quality: "2048quality", master: "2048master" }
6622
+ },
6623
+ sam: {
6624
+ textPath: false,
6625
+ views: ["none"],
6626
+ multiImage: false,
6627
+ texture: null,
6628
+ pbr: false,
6629
+ seed: true,
6630
+ textureRef: false,
6631
+ resolutions: null
6632
+ }
6633
+ };
6634
+ function model3dSpecIssues(spec) {
6635
+ const issues = [];
6636
+ const add = (path, message) => issues.push({ path, message });
6637
+ const rules = MODEL3D_FAMILY_RULES[spec.family];
6638
+ const promptOnly = spec.text && !spec.imageRequired;
6639
+ if (spec.endpoints.image === void 0)
6640
+ add(["endpoints", "image"], "every row needs an image endpoint");
6641
+ if (promptOnly && !rules.textPath) {
6642
+ add(
6643
+ ["imageRequired"],
6644
+ `${spec.family} has no text-to-3D endpoint; a text row needs an image`
6645
+ );
6646
+ }
6647
+ if (promptOnly && spec.endpoints.text === void 0) {
6648
+ add(["endpoints", "text"], "a text row needs a text endpoint");
6649
+ }
6650
+ if (!rules.views.includes(spec.views)) {
6651
+ add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
6652
+ }
6653
+ if (spec.views === "none" && spec.maxImages !== 1) {
6654
+ add(["maxImages"], "a row without views takes 1 image");
6655
+ }
6656
+ if (spec.views === "unordered" && spec.maxImages < 2) {
6657
+ add(["maxImages"], "a row with views takes at least 2 images");
6658
+ }
6659
+ const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
6660
+ if (spec.views !== "none" && spec.maxImages > slots) {
6661
+ add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
6662
+ }
6663
+ if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
6664
+ add(
6665
+ ["maxImages"],
6666
+ `a row with ${spec.views} views takes ${slots} images (front and three sides)`
6667
+ );
6668
+ }
6669
+ if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
6670
+ add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
6671
+ }
6672
+ if (rules.texture === null) {
6673
+ if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
6674
+ } else {
6675
+ const allowed = rules.texture;
6676
+ if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
6677
+ if (new Set(spec.texture).size !== spec.texture.length)
6678
+ add(["texture"], "texture options repeat");
6679
+ for (const t of spec.texture) {
6680
+ if (!Object.hasOwn(allowed, t))
6681
+ add(["texture"], `${spec.family} has no "${t}" texture`);
6682
+ }
6683
+ }
6684
+ if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
6685
+ if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
6686
+ add(["pbr"], "PBR needs a textured option");
6687
+ }
6688
+ if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
6689
+ if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
6690
+ if (spec.textureRef && !rules.textureRef)
6691
+ add(["textureRef"], `${spec.family} takes no texture reference`);
6692
+ const res = spec.resolutions;
6693
+ if (rules.resolutions === null) {
6694
+ if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
6695
+ } else if (res === void 0) {
6696
+ add(["resolutions"], `${spec.family} needs its resolution options`);
6697
+ } else {
6698
+ if (!res.options.includes(res.default)) {
6699
+ add(["resolutions", "default"], "default must be an option");
6700
+ }
6701
+ if (new Set(res.options).size !== res.options.length) {
6702
+ add(["resolutions", "options"], "resolution options repeat");
6703
+ }
6704
+ const allowed = rules.resolutions;
6705
+ for (const option of res.options) {
6706
+ const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : Object.hasOwn(allowed, option);
6707
+ if (!ok)
6708
+ add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
6709
+ }
6710
+ }
6711
+ return issues;
6712
+ }
6553
6713
  function model3dInputRefusal(spec, wired) {
6554
6714
  const top = spec.views === "unordered" && wired.top === true;
6555
6715
  const anyView = spec.views !== "none" && (wired.back || wired.left || wired.right || top);
@@ -7131,156 +7291,6 @@ var LanguageOptionSchema = z3.looseObject({
7131
7291
  code: z3.string().min(1),
7132
7292
  name: z3.string().min(1)
7133
7293
  });
7134
- var MODEL3D_FAMILY_RULES = {
7135
- trellis: {
7136
- textPath: false,
7137
- views: ["none"],
7138
- multiImage: false,
7139
- texture: null,
7140
- pbr: false,
7141
- seed: true,
7142
- textureRef: false,
7143
- resolutions: "integer"
7144
- },
7145
- hunyuan: {
7146
- textPath: true,
7147
- views: ["none", "named"],
7148
- multiImage: false,
7149
- texture: ["none", "standard"],
7150
- pbr: true,
7151
- seed: false,
7152
- textureRef: false,
7153
- resolutions: null
7154
- },
7155
- tripo: {
7156
- textPath: true,
7157
- views: ["none", "ordered"],
7158
- multiImage: true,
7159
- texture: ["none", "standard", "detailed"],
7160
- pbr: true,
7161
- seed: true,
7162
- textureRef: false,
7163
- resolutions: null
7164
- },
7165
- rodin: {
7166
- textPath: true,
7167
- views: ["none", "unordered"],
7168
- multiImage: false,
7169
- texture: null,
7170
- pbr: false,
7171
- seed: true,
7172
- textureRef: false,
7173
- resolutions: null
7174
- },
7175
- meshy: {
7176
- textPath: true,
7177
- views: ["none", "unordered"],
7178
- multiImage: true,
7179
- texture: ["none", "standard"],
7180
- pbr: true,
7181
- seed: true,
7182
- textureRef: true,
7183
- resolutions: null
7184
- },
7185
- hi3d: {
7186
- textPath: false,
7187
- views: ["none", "named"],
7188
- multiImage: true,
7189
- texture: ["none", "standard"],
7190
- pbr: true,
7191
- seed: false,
7192
- textureRef: false,
7193
- resolutions: ["quality", "master"]
7194
- },
7195
- sam: {
7196
- textPath: false,
7197
- views: ["none"],
7198
- multiImage: false,
7199
- texture: null,
7200
- pbr: false,
7201
- seed: true,
7202
- textureRef: false,
7203
- resolutions: null
7204
- }
7205
- };
7206
- function model3dSpecIssues(spec) {
7207
- const issues = [];
7208
- const add = (path, message) => issues.push({ path, message });
7209
- const rules = MODEL3D_FAMILY_RULES[spec.family];
7210
- const promptOnly = spec.text && !spec.imageRequired;
7211
- if (spec.endpoints.image === void 0)
7212
- add(["endpoints", "image"], "every row needs an image endpoint");
7213
- if (promptOnly && !rules.textPath) {
7214
- add(
7215
- ["imageRequired"],
7216
- `${spec.family} has no text-to-3D endpoint; a text row needs an image`
7217
- );
7218
- }
7219
- if (promptOnly && spec.endpoints.text === void 0) {
7220
- add(["endpoints", "text"], "a text row needs a text endpoint");
7221
- }
7222
- if (!rules.views.includes(spec.views)) {
7223
- add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
7224
- }
7225
- if (spec.views === "none" && spec.maxImages !== 1) {
7226
- add(["maxImages"], "a row without views takes 1 image");
7227
- }
7228
- if (spec.views === "unordered" && spec.maxImages < 2) {
7229
- add(["maxImages"], "a row with views takes at least 2 images");
7230
- }
7231
- const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
7232
- if (spec.views !== "none" && spec.maxImages > slots) {
7233
- add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
7234
- }
7235
- if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
7236
- add(
7237
- ["maxImages"],
7238
- `a row with ${spec.views} views takes ${slots} images (front and three sides)`
7239
- );
7240
- }
7241
- if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
7242
- add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
7243
- }
7244
- if (rules.texture === null) {
7245
- if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
7246
- } else {
7247
- const allowed = rules.texture;
7248
- if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
7249
- if (new Set(spec.texture).size !== spec.texture.length)
7250
- add(["texture"], "texture options repeat");
7251
- for (const t of spec.texture) {
7252
- if (!allowed.includes(t)) add(["texture"], `${spec.family} has no "${t}" texture`);
7253
- }
7254
- }
7255
- if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
7256
- if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
7257
- add(["pbr"], "PBR needs a textured option");
7258
- }
7259
- if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
7260
- if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
7261
- if (spec.textureRef && !rules.textureRef)
7262
- add(["textureRef"], `${spec.family} takes no texture reference`);
7263
- const res = spec.resolutions;
7264
- if (rules.resolutions === null) {
7265
- if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
7266
- } else if (res === void 0) {
7267
- add(["resolutions"], `${spec.family} needs its resolution options`);
7268
- } else {
7269
- if (!res.options.includes(res.default)) {
7270
- add(["resolutions", "default"], "default must be an option");
7271
- }
7272
- if (new Set(res.options).size !== res.options.length) {
7273
- add(["resolutions", "options"], "resolution options repeat");
7274
- }
7275
- const allowed = rules.resolutions;
7276
- for (const option of res.options) {
7277
- const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : allowed.includes(option);
7278
- if (!ok)
7279
- add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
7280
- }
7281
- }
7282
- return issues;
7283
- }
7284
7294
  var VideoToolConstraintsSchema = z3.looseObject({
7285
7295
  kind: z3.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles"]),
7286
7296
  upscaleFactor: RangeSchema.optional(),