@shop-os/modelkit 0.13.0 → 0.15.0

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
@@ -136,6 +136,7 @@ __export(index_exports, {
136
136
  toGeneratedImage: () => toGeneratedImage,
137
137
  validateInputSpec: () => validateInputSpec,
138
138
  videoLengthViolation: () => videoLengthViolation,
139
+ videoSizeViolation: () => videoSizeViolation,
139
140
  videoToolConstraints: () => videoToolConstraints,
140
141
  withRetry: () => withRetry,
141
142
  xaiVideoAdapter: () => xaiVideoAdapter
@@ -5235,6 +5236,7 @@ function klingMotionControl(tier) {
5235
5236
  videos: 1,
5236
5237
  audios: 0,
5237
5238
  videoSeconds: { min: 3, max: 30.05 },
5239
+ videoPixels: { minWidth: 340, minHeight: 340 },
5238
5240
  min: { images: 1, videos: 1 }
5239
5241
  },
5240
5242
  requires: ["references"],
@@ -5301,6 +5303,7 @@ var VIDEO_FAMILY_MODELS = [
5301
5303
  references: { ...NO_REFERENCES, images: 4 },
5302
5304
  requires: ["sourceVideo"],
5303
5305
  sourceVideoSeconds: { min: 3, max: 15.05 },
5306
+ sourceVideoPixels: { minWidth: 720, minHeight: 720 },
5304
5307
  // generateAudio keeps (true) or drops (false) the source soundtrack.
5305
5308
  supports: ["generateAudio"],
5306
5309
  prompt: KLING_PROMPT,
@@ -5341,7 +5344,8 @@ var VIDEO_FAMILY_MODELS = [
5341
5344
  ...NO_REFERENCES,
5342
5345
  images: 10,
5343
5346
  videos: 5,
5344
- videoSeconds: { min: 3, max: 30.05, total: 30 }
5347
+ videoSeconds: { min: 3, max: 30.05, total: 30 },
5348
+ videoPixels: { minWidth: 700, minHeight: 700 }
5345
5349
  },
5346
5350
  supports: ["lastFrame"],
5347
5351
  prompt: KLING_V4_PROMPT,
@@ -5375,6 +5379,7 @@ var VIDEO_FAMILY_MODELS = [
5375
5379
  references: { ...NO_REFERENCES, images: 10 },
5376
5380
  requires: ["sourceVideo"],
5377
5381
  sourceVideoSeconds: { min: 3, max: 30.05 },
5382
+ sourceVideoPixels: { minWidth: 700, minHeight: 700 },
5378
5383
  supports: [],
5379
5384
  prompt: KLING_V4_PROMPT,
5380
5385
  audio: KLING_V4_AUDIO
@@ -6711,6 +6716,33 @@ var VIDEO_TOOL_MODELS = [
6711
6716
  description: "Topaz Hyperion 2.5 SDR to HDR: a 10-bit HDR master in H.265 (HDR10) or ProRes 422 HQ, at the source's size and frame rate."
6712
6717
  }
6713
6718
  },
6719
+ {
6720
+ // https://fal.ai/models/fal-ai/depth-anything-video/api: greyscale depth (white = near)
6721
+ // at the source's frame rate, short edge capped at 1080 px (a 2160x3840 source came
6722
+ // back 1080x1920), at most 2400 frames; one fal price of $0.04 per second for every
6723
+ // model size. The adapter always sends VDA-Small, the only Apache-2.0 size. 100 s is
6724
+ // 2400 frames at 24 fps; the frame check refuses faster clips sooner.
6725
+ id: "depth-anything-video",
6726
+ aliases: [],
6727
+ label: "Video Depth Anything",
6728
+ type: "video-tool",
6729
+ adapter: "fal",
6730
+ providerModelId: "fal-ai/depth-anything-video",
6731
+ lifecycle: "active",
6732
+ exposure: ["cowork"],
6733
+ constraints: {
6734
+ supports: [],
6735
+ sourceVideoSeconds: { max: 100 },
6736
+ tool: { kind: "depth", maxOutputShortEdge: 1080, maxOutputFrames: 2400 }
6737
+ },
6738
+ defaults: {},
6739
+ usage: SECONDS_USAGE,
6740
+ pricingKind: "video_per_second",
6741
+ display: {
6742
+ provider: "depth-anything",
6743
+ description: "Video Depth Anything: a greyscale depth map of the clip (near is white), frame for frame, for motion and camera control."
6744
+ }
6745
+ },
6714
6746
  {
6715
6747
  id: "flux-video-upscale-precise",
6716
6748
  aliases: [],
@@ -7892,6 +7924,10 @@ var VideoSecondsLimitsSchema = import_zod3.z.looseObject({
7892
7924
  total: import_zod3.z.number().optional(),
7893
7925
  editMin: import_zod3.z.number().optional()
7894
7926
  });
7927
+ var VideoPixelLimitsSchema = import_zod3.z.looseObject({
7928
+ minWidth: import_zod3.z.number().int().positive().optional(),
7929
+ minHeight: import_zod3.z.number().int().positive().optional()
7930
+ });
7895
7931
  var ReferenceLimitsSchema = import_zod3.z.looseObject({
7896
7932
  images: import_zod3.z.number().optional(),
7897
7933
  imagesWithVideo: import_zod3.z.number().optional(),
@@ -7900,6 +7936,7 @@ var ReferenceLimitsSchema = import_zod3.z.looseObject({
7900
7936
  total: import_zod3.z.number().optional(),
7901
7937
  audioOnly: import_zod3.z.boolean().optional(),
7902
7938
  videoSeconds: VideoSecondsLimitsSchema.optional(),
7939
+ videoPixels: VideoPixelLimitsSchema.optional(),
7903
7940
  audioSeconds: import_zod3.z.looseObject({
7904
7941
  min: import_zod3.z.number().optional(),
7905
7942
  max: import_zod3.z.number().optional(),
@@ -7928,7 +7965,7 @@ var LanguageOptionSchema = import_zod3.z.looseObject({
7928
7965
  name: import_zod3.z.string().min(1)
7929
7966
  });
7930
7967
  var VideoToolConstraintsSchema = import_zod3.z.looseObject({
7931
- kind: import_zod3.z.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles"]),
7968
+ kind: import_zod3.z.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles", "depth"]),
7932
7969
  upscaleFactor: RangeSchema.optional(),
7933
7970
  maxOutputLongEdge: import_zod3.z.number().positive().optional(),
7934
7971
  prompt: import_zod3.z.boolean().optional(),
@@ -7989,6 +8026,7 @@ var ModelConstraintsSchema = import_zod3.z.looseObject({
7989
8026
  }).optional(),
7990
8027
  languages: import_zod3.z.array(LanguageOptionSchema).optional(),
7991
8028
  outputFormats: import_zod3.z.array(import_zod3.z.string().min(1)).min(1).optional(),
8029
+ sourceVideoPixels: VideoPixelLimitsSchema.optional(),
7992
8030
  sourceVideoSeconds: VideoSecondsLimitsSchema.omit({ total: true }).extend({ inReferenceTotal: import_zod3.z.boolean().optional() }).optional(),
7993
8031
  // segmentSeconds/maxTotalSeconds stay required: a kit before 0.3.0 drops a row whose
7994
8032
  // extension lacks them, so every extension block keeps them.
@@ -9698,7 +9736,7 @@ function checkedQueueUrl(ctx, url, what) {
9698
9736
  var import_zod12 = require("zod");
9699
9737
  var RangeSchema2 = import_zod12.z.object({ min: import_zod12.z.number(), max: import_zod12.z.number() });
9700
9738
  var ToolSchema = import_zod12.z.object({
9701
- kind: import_zod12.z.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles"]),
9739
+ kind: import_zod12.z.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles", "depth"]),
9702
9740
  upscaleFactor: RangeSchema2.optional(),
9703
9741
  maxOutputLongEdge: import_zod12.z.number().positive().optional(),
9704
9742
  prompt: import_zod12.z.boolean().optional(),
@@ -9836,6 +9874,25 @@ function planVideoTool(row2, req) {
9836
9874
  }
9837
9875
  };
9838
9876
  }
9877
+ if (tool.kind === "depth") {
9878
+ const limit = tool.maxOutputFrames;
9879
+ if (limit !== void 0) {
9880
+ if (fps === void 0) return fail("The source video's frame rate is required");
9881
+ if (durationSeconds * fps > limit) {
9882
+ return fail(`${row2.label} renders up to ${limit} frames (${seconds(limit, fps)}).`);
9883
+ }
9884
+ }
9885
+ const out2 = shrinkToShortEdge(width, height, tool.maxOutputShortEdge);
9886
+ return {
9887
+ ok: true,
9888
+ output: {
9889
+ ...base,
9890
+ ...out2,
9891
+ resolution: resolutionTier(out2.width, out2.height),
9892
+ format: "h264"
9893
+ }
9894
+ };
9895
+ }
9839
9896
  if (tool.kind === "subtitles") {
9840
9897
  const resolution = resolutionTier(width, height);
9841
9898
  const problem = subtitleProblem(
@@ -9932,12 +9989,15 @@ function toolInput(ctx, req, output) {
9932
9989
  input["output_codec"] = "vp9";
9933
9990
  } else if (tool?.kind === "subtitles") {
9934
9991
  Object.assign(input, subtitleFields(tool, req.subtitles));
9992
+ } else if (tool?.kind === "depth") {
9993
+ input["model"] = "VDA-Small";
9994
+ input["colormap"] = "grayscale";
9935
9995
  } else if (output.format === "exr") {
9936
9996
  const prompt = tool?.prompt === true ? req.prompt?.trim() : void 0;
9937
9997
  input["prompt"] = prompt || EXR_DEFAULT_PROMPT;
9938
9998
  if (output.fps !== void 0) input["frames_per_second"] = output.fps;
9939
9999
  if (output.frames !== void 0) input["num_frames"] = output.frames;
9940
- } else {
10000
+ } else if (tool?.kind === "hdr") {
9941
10001
  input["output_format"] = output.format === "prores" ? "prores" : "mp4";
9942
10002
  }
9943
10003
  return input;
@@ -17707,6 +17767,28 @@ function videoLengthViolation(model, input) {
17707
17767
  return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds2(source2, sourceMin)} s.`;
17708
17768
  return void 0;
17709
17769
  }
17770
+ function undersizedSide(frame, limits) {
17771
+ if (!frame || !limits) return void 0;
17772
+ const { width, height } = frame;
17773
+ if (limits.minWidth !== void 0 && width !== void 0 && width > 0 && width < limits.minWidth)
17774
+ return { side: "wide", min: limits.minWidth, actual: width };
17775
+ if (limits.minHeight !== void 0 && height !== void 0 && height > 0 && height < limits.minHeight)
17776
+ return { side: "tall", min: limits.minHeight, actual: height };
17777
+ return void 0;
17778
+ }
17779
+ function videoSizeViolation(model, input) {
17780
+ const refLimits = model.constraints.references?.videoPixels;
17781
+ const refs = input.referenceVideos ?? [];
17782
+ for (let i = 0; i < refs.length; i++) {
17783
+ const under2 = undersizedSide(refs[i], refLimits);
17784
+ if (under2)
17785
+ return `${model.label} takes reference videos at least ${String(under2.min)} px ${under2.side}; video ${i + 1} is ${String(under2.actual)} px.`;
17786
+ }
17787
+ const under = undersizedSide(input.sourceVideo, model.constraints.sourceVideoPixels);
17788
+ if (under)
17789
+ return `${model.label} takes a source video at least ${String(under.min)} px ${under.side}; this one is ${String(under.actual)} px.`;
17790
+ return void 0;
17791
+ }
17710
17792
  function resolveImageOptions(model, request, onUnsupported = "error") {
17711
17793
  const warnings = [];
17712
17794
  const c = model.constraints;
@@ -19820,6 +19902,7 @@ var describe = (modelId) => createDefaultModelKit().describe(modelId);
19820
19902
  toGeneratedImage,
19821
19903
  validateInputSpec,
19822
19904
  videoLengthViolation,
19905
+ videoSizeViolation,
19823
19906
  videoToolConstraints,
19824
19907
  withRetry,
19825
19908
  xaiVideoAdapter,