@shop-os/modelkit 0.4.4 → 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/CHANGELOG.md CHANGED
@@ -9,6 +9,11 @@ header in the release PR.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.4.5] - Unreleased
13
+
14
+ ### Fixed
15
+ - Video length maximums and combined totals forgive ffprobe's container over-read. ffprobe reads a clip a few hundredths over its nominal length (a 10 s clip reads 10.04 s), so a clip at the limit was refused. A length is now over a maximum only when it and its tenth are both over: a source that reads 10.04 s passes Gemini Omni's 10 s cap, one that reads 10.05 s or more is still refused, and a limit that is not a whole tenth (Kling O1's 10.05 s) still takes a clip at it. A combined total adds each clip's tenth, so three 5.04 s references fit a 15 s total. The rule is never stricter than the old raw comparison. It applies to the reference maximum and total and the source maximum in `videoLengthViolation`, and to the source cap in `planVideoTool`. Minimums stay raw: the over-read makes a clip that reads short shorter still, so 3.96 s is still under a 4 s minimum.
16
+
12
17
  ## [0.4.4] - Unreleased
13
18
 
14
19
  ### Added
package/dist/catalog.cjs CHANGED
@@ -3324,6 +3324,20 @@ function resetLiveCatalog() {
3324
3324
 
3325
3325
  // src/catalog/video-tools-spec.ts
3326
3326
  var import_zod6 = require("zod");
3327
+
3328
+ // src/video-length.ts
3329
+ function tenths(seconds2) {
3330
+ return Math.round(seconds2 * 10) / 10;
3331
+ }
3332
+ function overMax(seconds2, max) {
3333
+ return seconds2 > max && tenths(seconds2) > max;
3334
+ }
3335
+ function overTotal(lengths, total) {
3336
+ const sum = (values) => values.reduce((acc, len) => acc + len, 0);
3337
+ return sum(lengths) > total && tenths(sum(lengths.map(tenths))) > total;
3338
+ }
3339
+
3340
+ // src/catalog/video-tools-spec.ts
3327
3341
  var RangeSchema2 = import_zod6.z.object({ min: import_zod6.z.number(), max: import_zod6.z.number() });
3328
3342
  var ToolSchema = import_zod6.z.object({
3329
3343
  kind: import_zod6.z.enum(["upscale", "interpolate", "hdr"]),
@@ -3367,7 +3381,7 @@ function planVideoTool(row, req) {
3367
3381
  return fail("The source video's width, height and duration are required");
3368
3382
  }
3369
3383
  const maxSeconds = row.constraints.sourceVideoSeconds?.max;
3370
- if (maxSeconds !== void 0 && durationSeconds > maxSeconds) {
3384
+ if (maxSeconds !== void 0 && overMax(durationSeconds, maxSeconds)) {
3371
3385
  return fail(`${row.label} takes source videos up to ${maxSeconds} seconds.`);
3372
3386
  }
3373
3387
  const base = {
@@ -3564,7 +3578,7 @@ function videoLengthViolation(model, input) {
3564
3578
  const lengths = (input.referenceVideos ?? []).map(knownLength);
3565
3579
  if (limits?.max !== void 0) {
3566
3580
  const max = limits.max;
3567
- const i = lengths.findIndex((len) => len !== void 0 && len > max);
3581
+ const i = lengths.findIndex((len) => len !== void 0 && overMax(len, max));
3568
3582
  if (i >= 0)
3569
3583
  return `${model.label} takes reference videos up to ${String(max)} s each; video ${i + 1} is ${seconds(lengths[i], max)} s.`;
3570
3584
  }
@@ -3576,14 +3590,17 @@ function videoLengthViolation(model, input) {
3576
3590
  const source = knownLength(input.sourceVideo);
3577
3591
  const sourceLimits = model.constraints.sourceVideoSeconds;
3578
3592
  if (limits?.total !== void 0) {
3579
- const refSum = lengths.reduce((acc, len) => acc + (len ?? 0), 0);
3580
- const sum = refSum + (sourceLimits?.inReferenceTotal ? source ?? 0 : 0);
3581
- if (sum > limits.total)
3593
+ const counted = [
3594
+ ...lengths.filter((len) => len !== void 0),
3595
+ ...sourceLimits?.inReferenceTotal && source !== void 0 ? [source] : []
3596
+ ];
3597
+ const sum = counted.reduce((acc, len) => acc + len, 0);
3598
+ if (overTotal(counted, limits.total))
3582
3599
  return `${model.label} takes reference videos up to ${String(limits.total)} s combined; these add up to ${seconds(sum, limits.total)} s.`;
3583
3600
  }
3584
3601
  if (source === void 0) return void 0;
3585
3602
  const sourceMin = effectiveMin(sourceLimits, input.taskType);
3586
- if (sourceLimits?.max !== void 0 && source > sourceLimits.max)
3603
+ if (sourceLimits?.max !== void 0 && overMax(source, sourceLimits.max))
3587
3604
  return `${model.label} takes a source video up to ${String(sourceLimits.max)} s; this one is ${seconds(source, sourceLimits.max)} s.`;
3588
3605
  if (sourceMin !== void 0 && source < sourceMin)
3589
3606
  return `${model.label} takes a source video of at least ${String(sourceMin)} s; this one is ${seconds(source, sourceMin)} s.`;