@nodaro/shared 3.53.0 → 3.54.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.
Files changed (132) hide show
  1. package/dist/{chunk-NR5IFEYC.js → chunk-25KAGSPT.js} +3 -3
  2. package/dist/{chunk-NR5IFEYC.js.map → chunk-25KAGSPT.js.map} +1 -1
  3. package/dist/{chunk-FBLMWA2R.cjs → chunk-2OYV6K7D.cjs} +4 -4
  4. package/dist/{chunk-FBLMWA2R.cjs.map → chunk-2OYV6K7D.cjs.map} +1 -1
  5. package/dist/{chunk-HDXAM5JW.cjs → chunk-2R74OU76.cjs} +19 -20
  6. package/dist/chunk-2R74OU76.cjs.map +1 -0
  7. package/dist/{chunk-WGXTTQNT.cjs → chunk-3633VD2M.cjs} +8 -8
  8. package/dist/{chunk-WGXTTQNT.cjs.map → chunk-3633VD2M.cjs.map} +1 -1
  9. package/dist/{chunk-DLSJTVS5.js → chunk-3CHOZ573.js} +19 -20
  10. package/dist/chunk-3CHOZ573.js.map +1 -0
  11. package/dist/{chunk-IORF5UGR.cjs → chunk-3GMTGX3D.cjs} +27 -27
  12. package/dist/{chunk-IORF5UGR.cjs.map → chunk-3GMTGX3D.cjs.map} +1 -1
  13. package/dist/{chunk-L6IGNCIV.js → chunk-5DVDHL7Y.js} +5 -5
  14. package/dist/{chunk-L6IGNCIV.js.map → chunk-5DVDHL7Y.js.map} +1 -1
  15. package/dist/{chunk-GJTRQOH6.cjs → chunk-5R6LTKE5.cjs} +5 -5
  16. package/dist/{chunk-GJTRQOH6.cjs.map → chunk-5R6LTKE5.cjs.map} +1 -1
  17. package/dist/{chunk-ZGPLTM5Y.js → chunk-6UR5UE5G.js} +9 -9
  18. package/dist/{chunk-ZGPLTM5Y.js.map → chunk-6UR5UE5G.js.map} +1 -1
  19. package/dist/{chunk-YCKHGHXN.js → chunk-6XVHYD5R.js} +11 -8
  20. package/dist/chunk-6XVHYD5R.js.map +1 -0
  21. package/dist/{chunk-A7RJOQXI.js → chunk-ADWIAQQS.js} +3 -3
  22. package/dist/{chunk-A7RJOQXI.js.map → chunk-ADWIAQQS.js.map} +1 -1
  23. package/dist/{chunk-EC4ZSWEN.cjs → chunk-AGTCHDG5.cjs} +6 -6
  24. package/dist/{chunk-EC4ZSWEN.cjs.map → chunk-AGTCHDG5.cjs.map} +1 -1
  25. package/dist/{chunk-LVXGMXJJ.cjs → chunk-ATWLKUAI.cjs} +4 -4
  26. package/dist/{chunk-LVXGMXJJ.cjs.map → chunk-ATWLKUAI.cjs.map} +1 -1
  27. package/dist/{chunk-NUFQFQ7C.js → chunk-C5S75476.js} +5 -5
  28. package/dist/{chunk-NUFQFQ7C.js.map → chunk-C5S75476.js.map} +1 -1
  29. package/dist/{chunk-6UHXNHKT.cjs → chunk-C6IQCKJT.cjs} +4 -4
  30. package/dist/{chunk-6UHXNHKT.cjs.map → chunk-C6IQCKJT.cjs.map} +1 -1
  31. package/dist/{chunk-RGXOHQWY.js → chunk-CZCOL3M5.js} +9 -5
  32. package/dist/chunk-CZCOL3M5.js.map +1 -0
  33. package/dist/{chunk-IVXWKDQ3.js → chunk-DUL5ZLTJ.js} +3 -3
  34. package/dist/{chunk-IVXWKDQ3.js.map → chunk-DUL5ZLTJ.js.map} +1 -1
  35. package/dist/{chunk-PRW25YSJ.js → chunk-E4YES25K.js} +4 -4
  36. package/dist/{chunk-PRW25YSJ.js.map → chunk-E4YES25K.js.map} +1 -1
  37. package/dist/{chunk-7MSA476R.cjs → chunk-FIYVKW7F.cjs} +12 -12
  38. package/dist/{chunk-7MSA476R.cjs.map → chunk-FIYVKW7F.cjs.map} +1 -1
  39. package/dist/{chunk-CQJYKSXF.js → chunk-FVVD6XY2.js} +5 -3
  40. package/dist/chunk-FVVD6XY2.js.map +1 -0
  41. package/dist/chunk-HD45Y7QU.cjs +27 -0
  42. package/dist/{chunk-WLQGTQC6.cjs.map → chunk-HD45Y7QU.cjs.map} +1 -1
  43. package/dist/{chunk-3YRH7UC5.js → chunk-HEF4BIMA.js} +4 -4
  44. package/dist/{chunk-3YRH7UC5.js.map → chunk-HEF4BIMA.js.map} +1 -1
  45. package/dist/{chunk-QPSEC6UO.js → chunk-HG3KKCJJ.js} +3 -3
  46. package/dist/{chunk-QPSEC6UO.js.map → chunk-HG3KKCJJ.js.map} +1 -1
  47. package/dist/{chunk-YYERNMW4.cjs → chunk-IPCWYKX5.cjs} +45 -45
  48. package/dist/{chunk-YYERNMW4.cjs.map → chunk-IPCWYKX5.cjs.map} +1 -1
  49. package/dist/{chunk-NC4IMS67.cjs → chunk-KM35K2M5.cjs} +21 -21
  50. package/dist/{chunk-NC4IMS67.cjs.map → chunk-KM35K2M5.cjs.map} +1 -1
  51. package/dist/{chunk-YOFBLLVD.js → chunk-KMSEU6FK.js} +3 -3
  52. package/dist/{chunk-YOFBLLVD.js.map → chunk-KMSEU6FK.js.map} +1 -1
  53. package/dist/{chunk-2LNQ2MDO.js → chunk-LYWJAXPT.js} +3 -3
  54. package/dist/{chunk-2LNQ2MDO.js.map → chunk-LYWJAXPT.js.map} +1 -1
  55. package/dist/{chunk-GZXQ4T2W.cjs → chunk-M3SXUUWC.cjs} +12 -7
  56. package/dist/chunk-M3SXUUWC.cjs.map +1 -0
  57. package/dist/{chunk-YCUFXCWH.js → chunk-MGJR5OXO.js} +5 -5
  58. package/dist/{chunk-YCUFXCWH.js.map → chunk-MGJR5OXO.js.map} +1 -1
  59. package/dist/{chunk-5HNJLFCZ.cjs → chunk-MTUNORQB.cjs} +11 -11
  60. package/dist/{chunk-5HNJLFCZ.cjs.map → chunk-MTUNORQB.cjs.map} +1 -1
  61. package/dist/{chunk-3SU2DRME.js → chunk-N3WL6IOJ.js} +3 -3
  62. package/dist/{chunk-3SU2DRME.js.map → chunk-N3WL6IOJ.js.map} +1 -1
  63. package/dist/{chunk-HG5VWCZV.cjs → chunk-ND3IE3IB.cjs} +47 -47
  64. package/dist/{chunk-HG5VWCZV.cjs.map → chunk-ND3IE3IB.cjs.map} +1 -1
  65. package/dist/{chunk-JKVCAEIZ.cjs → chunk-NEIWY6CC.cjs} +6 -6
  66. package/dist/{chunk-JKVCAEIZ.cjs.map → chunk-NEIWY6CC.cjs.map} +1 -1
  67. package/dist/{chunk-7NRDX3KL.js → chunk-NMX6HQC3.js} +5 -5
  68. package/dist/{chunk-7NRDX3KL.js.map → chunk-NMX6HQC3.js.map} +1 -1
  69. package/dist/{chunk-KADUPASC.cjs → chunk-OVIIJVXH.cjs} +21 -21
  70. package/dist/{chunk-KADUPASC.cjs.map → chunk-OVIIJVXH.cjs.map} +1 -1
  71. package/dist/{chunk-5PCI6M44.cjs → chunk-PONP5J5E.cjs} +5 -3
  72. package/dist/chunk-PONP5J5E.cjs.map +1 -0
  73. package/dist/{chunk-NTSGMX23.cjs → chunk-QP5JLSCJ.cjs} +9 -5
  74. package/dist/chunk-QP5JLSCJ.cjs.map +1 -0
  75. package/dist/{chunk-GLED2FVJ.cjs → chunk-SEEQ3H22.cjs} +5 -5
  76. package/dist/{chunk-GLED2FVJ.cjs.map → chunk-SEEQ3H22.cjs.map} +1 -1
  77. package/dist/{chunk-3WYOLP35.cjs → chunk-SZUDEFX2.cjs} +41 -41
  78. package/dist/{chunk-3WYOLP35.cjs.map → chunk-SZUDEFX2.cjs.map} +1 -1
  79. package/dist/{chunk-HT6PACYO.js → chunk-YBZQXZ6A.js} +3 -3
  80. package/dist/{chunk-HT6PACYO.js.map → chunk-YBZQXZ6A.js.map} +1 -1
  81. package/dist/{chunk-DS4QUPGZ.js → chunk-ZKHQSG76.js} +4 -4
  82. package/dist/{chunk-DS4QUPGZ.js.map → chunk-ZKHQSG76.js.map} +1 -1
  83. package/dist/{chunk-6XYLFTLI.js → chunk-ZWB3NG4M.js} +3 -3
  84. package/dist/{chunk-6XYLFTLI.js.map → chunk-ZWB3NG4M.js.map} +1 -1
  85. package/dist/entries/apps.cjs +43 -43
  86. package/dist/entries/apps.js +8 -8
  87. package/dist/entries/credits.cjs +150 -150
  88. package/dist/entries/credits.js +7 -7
  89. package/dist/entries/media.cjs +81 -73
  90. package/dist/entries/media.d.cts +51 -84
  91. package/dist/entries/media.d.ts +51 -84
  92. package/dist/entries/media.js +2 -2
  93. package/dist/entries/model-catalog.cjs +66 -66
  94. package/dist/entries/model-catalog.js +4 -4
  95. package/dist/entries/models.cjs +277 -277
  96. package/dist/entries/models.js +5 -5
  97. package/dist/entries/nodes.cjs +207 -207
  98. package/dist/entries/nodes.js +9 -9
  99. package/dist/entries/pipeline.cjs +149 -149
  100. package/dist/entries/pipeline.js +3 -3
  101. package/dist/entries/ugc.cjs +71 -71
  102. package/dist/entries/ugc.js +4 -4
  103. package/dist/entries/video.cjs +117 -117
  104. package/dist/entries/video.js +4 -4
  105. package/dist/entries/workflow.cjs +99 -99
  106. package/dist/entries/workflow.js +2 -2
  107. package/dist/index.cjs +1233 -1225
  108. package/dist/index.d.cts +1 -1
  109. package/dist/index.d.ts +1 -1
  110. package/dist/index.js +21 -21
  111. package/package.json +1 -1
  112. package/src/__tests__/priced-clip-seconds.test.ts +193 -0
  113. package/src/__tests__/video-depth.test.ts +28 -16
  114. package/src/__tests__/video-face-mesh.test.ts +3 -2
  115. package/src/__tests__/video-mask.test.ts +1 -1
  116. package/src/entries/media.ts +1 -0
  117. package/src/generated/unit-contracts.ts +1 -0
  118. package/src/mask-composite.ts +6 -5
  119. package/src/model-catalog.ts +17 -18
  120. package/src/priced-clip-seconds.ts +28 -0
  121. package/src/video-depth.ts +21 -19
  122. package/src/video-face-mesh.ts +5 -2
  123. package/src/video-mask.ts +12 -7
  124. package/dist/chunk-5PCI6M44.cjs.map +0 -1
  125. package/dist/chunk-CQJYKSXF.js.map +0 -1
  126. package/dist/chunk-DLSJTVS5.js.map +0 -1
  127. package/dist/chunk-GZXQ4T2W.cjs.map +0 -1
  128. package/dist/chunk-HDXAM5JW.cjs.map +0 -1
  129. package/dist/chunk-NTSGMX23.cjs.map +0 -1
  130. package/dist/chunk-RGXOHQWY.js.map +0 -1
  131. package/dist/chunk-WLQGTQC6.cjs +0 -27
  132. package/dist/chunk-YCKHGHXN.js.map +0 -1
@@ -27,6 +27,7 @@
27
27
  *
28
28
  * Wire contract only — no I/O.
29
29
  */
30
+ import { pricedClipSeconds } from "./priced-clip-seconds.js"
30
31
 
31
32
  /** How the background is fitted to the foreground's frame. */
32
33
  export const MASK_COMPOSITE_BACKGROUND_FITS = ["cover", "contain", "stretch"] as const
@@ -68,17 +69,17 @@ export const MASK_COMPOSITE_UNIT_SEC = 5
68
69
 
69
70
  /**
70
71
  * Pricing units for a result `durationSec` long: one per started 5 seconds,
71
- * at least one. An unknown length counts the longest result a run accepts
72
- * (an upper bound — the pre-run quote for a clip whose length is not known
73
- * yet; every run measures its foreground).
72
+ * at least one, after `pricedClipSeconds` (up to 0.05 s past a whole second is
73
+ * ignored, so a 10.01 s result is 2 units, not 3). An unknown length counts the
74
+ * longest result a run accepts (an upper bound — the pre-run quote for a clip
75
+ * whose length is not known yet; every run measures its foreground).
74
76
  */
75
77
  export function maskCompositeUnits(durationSec: number | null | undefined): number {
76
78
  const sec =
77
79
  typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0
78
80
  ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC)
79
81
  : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC
80
- // The epsilon absorbs float noise (a 10.0000001 s probe is 2 units, not 3).
81
- return Math.max(1, Math.ceil(sec / MASK_COMPOSITE_UNIT_SEC - 1e-6))
82
+ return Math.ceil(pricedClipSeconds(sec) / MASK_COMPOSITE_UNIT_SEC)
82
83
  }
83
84
 
84
85
  export const MASK_COMPOSITE_DEFAULTS = {
@@ -838,8 +838,8 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
838
838
  resolutions: ["1K", "2K", "4K"],
839
839
  pricing: [
840
840
  { identifier: "gpt-image-2", credits: 15, note: "1K default" },
841
- { identifier: "gpt-image-2:2K", credits: 30, note: "2K" },
842
- { identifier: "gpt-image-2:4K", credits: 60, note: "4K" },
841
+ { identifier: "gpt-image-2:2K", credits: 25, note: "2K" },
842
+ { identifier: "gpt-image-2:4K", credits: 40, note: "4K" },
843
843
  ],
844
844
  safetyFilter: { stochastic: true, fallback: "nano-banana-pro" },
845
845
  featured: true,
@@ -860,8 +860,8 @@ const IMAGE_MODELS: Record<string, ModelCatalogEntry> = {
860
860
  resolutions: ["1K", "2K", "4K"],
861
861
  pricing: [
862
862
  { identifier: "gpt-image-2-i2i", credits: 15, note: "1K default" },
863
- { identifier: "gpt-image-2-i2i:2K", credits: 30, note: "2K" },
864
- { identifier: "gpt-image-2-i2i:4K", credits: 60, note: "4K" },
863
+ { identifier: "gpt-image-2-i2i:2K", credits: 25, note: "2K" },
864
+ { identifier: "gpt-image-2-i2i:4K", credits: 40, note: "4K" },
865
865
  ],
866
866
  },
867
867
 
@@ -2029,13 +2029,13 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2029
2029
  { identifier: "seedance-2-5", credits: 1260, note: "default 8s 720p — see :Ns:res variants for exact" },
2030
2030
  { identifier: "seedance-2-5:8s:480p", credits: 560, note: "8s 480p" },
2031
2031
  { identifier: "seedance-2-5:8s:720p", credits: 1260, note: "8s 720p" },
2032
- { identifier: "seedance-2-5:8s:1080p", credits: 2280, note: "8s 1080p" },
2032
+ { identifier: "seedance-2-5:8s:1080p", credits: 3160, note: "8s 1080p" },
2033
2033
  { identifier: "seedance-2-5:8s:480p-ref", credits: 340, note: "8s 480p with reference video" },
2034
2034
  { identifier: "seedance-2-5:8s:720p-ref", credits: 760, note: "8s 720p with reference video" },
2035
- { identifier: "seedance-2-5:8s:1080p-ref", credits: 1370, note: "8s 1080p with reference video" },
2035
+ { identifier: "seedance-2-5:8s:1080p-ref", credits: 1900, note: "8s 1080p with reference video" },
2036
2036
  { identifier: "seedance-2-5:30s:480p", credits: 2100, note: "30s 480p (max)" },
2037
2037
  { identifier: "seedance-2-5:30s:720p", credits: 4730, note: "30s 720p (max)" },
2038
- { identifier: "seedance-2-5:30s:1080p", credits: 8550, note: "30s 1080p (max)" },
2038
+ { identifier: "seedance-2-5:30s:1080p", credits: 11850, note: "30s 1080p (max)" },
2039
2039
  ],
2040
2040
  },
2041
2041
 
@@ -2817,10 +2817,10 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2817
2817
  ],
2818
2818
  },
2819
2819
  // ── Video Depth ── (video-depth node; priced by the input clip's length via
2820
- // videoDepthCreditId in video-depth.ts — `<provider>:<n>s`, bare row = the
2821
- // 300 s ceiling. Video Depth Anything: one row per whole second of the clip
2822
- // (`:1s` … `:300s`, rounded up), representative rows below; Depth Anything
2823
- // per frame: one row per length bucket, same shape as volcengine-lipsync.)
2820
+ // videoDepthCreditId in video-depth.ts — `<provider>:<n>s`, one row per whole
2821
+ // second of the clip (`pricedClipSeconds`), representative rows below: `:1s` …
2822
+ // `:300s` on Video Depth Anything, `:1s` … `:80s` on Depth Anything per frame.
2823
+ // Bare row = the provider's longest clip: 300 s and 80 s.)
2824
2824
  "video-depth-anything": {
2825
2825
  id: "video-depth-anything",
2826
2826
  kind: "video",
@@ -2833,7 +2833,7 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2833
2833
  useCases: ["depth", "video-to-video", "compositing"],
2834
2834
  pricing: [
2835
2835
  { identifier: "video-depth-anything", credits: 6000, note: "5-min ceiling (no duration given)" },
2836
- { identifier: "video-depth-anything:1s", credits: 20, note: "1s (min) — priced per second of the clip at this row's credits, the length rounded up" },
2836
+ { identifier: "video-depth-anything:1s", credits: 20, note: "1s (min) — priced per second of the clip at this row's credits, the length rounded up after ignoring up to 0.05 s past a whole second" },
2837
2837
  { identifier: "video-depth-anything:15s", credits: 300, note: "15s" },
2838
2838
  { identifier: "video-depth-anything:60s", credits: 1200, note: "1 min" },
2839
2839
  { identifier: "video-depth-anything:300s", credits: 6000, note: "5-min ceiling (max)" },
@@ -2850,12 +2850,11 @@ const VIDEO_MODELS: Record<string, ModelCatalogEntry> = {
2850
2850
  description: "Depth Anything v1 run on each frame. Grayscale or inferno colormap; may flicker between frames. Up to 80 s.",
2851
2851
  useCases: ["depth", "video-to-video"],
2852
2852
  pricing: [
2853
- { identifier: "depth-anything-frames", credits: 600, note: "5-min ceiling (no duration given)" },
2854
- { identifier: "depth-anything-frames:15s", credits: 30 },
2855
- { identifier: "depth-anything-frames:30s", credits: 60 },
2856
- { identifier: "depth-anything-frames:60s", credits: 120 },
2857
- { identifier: "depth-anything-frames:120s", credits: 240 },
2858
- { identifier: "depth-anything-frames:300s", credits: 600, note: "5-min ceiling" },
2853
+ { identifier: "depth-anything-frames", credits: 160, note: "80s ceiling (no duration given)" },
2854
+ { identifier: "depth-anything-frames:1s", credits: 2, note: "1s (min) — priced per second of the clip at this row's credits, the length rounded up after ignoring up to 0.05 s past a whole second" },
2855
+ { identifier: "depth-anything-frames:15s", credits: 30, note: "15s" },
2856
+ { identifier: "depth-anything-frames:60s", credits: 120, note: "1 min" },
2857
+ { identifier: "depth-anything-frames:80s", credits: 160, note: "80s ceiling (max)" },
2859
2858
  ],
2860
2859
  },
2861
2860
  // ── Gemini video analysis ── (Gemini-only; billed per duration bucket — the
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The whole seconds a clip is PRICED at by Video Depth (both providers), Video
3
+ * Mask, Mask Composite and the face mesh: its length rounded up, after ignoring
4
+ * up to {@link CLIP_PRICE_GRACE_SEC} past a whole second.
5
+ *
6
+ * A whole-second cut of a 29.97 or 23.976 fps clip can come out a little long:
7
+ * 12 s is 360 frames, a 12.012 s file. A quote reads the cut, a run measures the
8
+ * file, and both land on the same row through this one rule, wherever those steps
9
+ * are reserved, charged or quoted.
10
+ *
11
+ * It decides the price only. Each step's limits (the 300 s cap, the frame cap)
12
+ * read the clip's real length. Other models round as they always have.
13
+ */
14
+
15
+ /** How far past a whole second a clip is still priced as that second. */
16
+ export const CLIP_PRICE_GRACE_SEC = 0.05
17
+
18
+ /**
19
+ * Float noise: a length that is arithmetic can land a hair past the edge, and
20
+ * must not round up for it. 1.35 s at 90 fps, priced at the 30 fps basis, is
21
+ * 4.050000000000001: 4, not 5.
22
+ */
23
+ const FLOAT_NOISE_SEC = 1e-9
24
+
25
+ /** At least one second. The caller has checked that `sec` is a real length. */
26
+ export function pricedClipSeconds(sec: number): number {
27
+ return Math.max(1, Math.ceil(sec - CLIP_PRICE_GRACE_SEC - FLOAT_NOISE_SEC))
28
+ }
@@ -9,13 +9,15 @@
9
9
  * produces from the inferno output (`videoDepthNeedsGrayscalePass`).
10
10
  *
11
11
  * Price rows are `model_pricing` rows (`<provider>:<n>s`); the credit amounts
12
- * live there, never here. Video Depth Anything has one row per whole second of
13
- * the clip, Depth Anything (per frame) one per length bucket. Worked examples
14
- * (repeated in docs/nodes/processing-video/video-depth.md):
15
- * video-depth-anything: 0.4 s → `:1s`, 9 s → `:9s`, 9.2 s → `:10s`, 15.01 s → `:16s`.
16
- * depth-anything-frames: 5 s → `:15s`, 15 s → `:15s`, 15.01 s → `:30s`, 61 s → `:120s`.
12
+ * live there, never here. Both providers have one row per whole second of the
13
+ * clip, up to the longest clip each accepts. Worked examples (repeated in
14
+ * docs/nodes/processing-video/video-depth.md):
15
+ * video-depth-anything: 0.4 s → `:1s`, 9 s → `:9s`, 9.2 s → `:10s`, 15.015 s → `:15s`, 15.06 s → `:16s`.
16
+ * depth-anything-frames: 0.4 s → `:1s`, 4 s → `:4s`, 4.1 s → `:5s`, 15.015 s → `:15s`, 15.06 s → `:16s`, 80 s → `:80s`.
17
17
  */
18
18
 
19
+ import { pricedClipSeconds } from "./priced-clip-seconds.js"
20
+
19
21
  export const VIDEO_DEPTH_PROVIDERS = ["video-depth-anything", "depth-anything-frames"] as const
20
22
  export type VideoDepthProvider = (typeof VIDEO_DEPTH_PROVIDERS)[number]
21
23
 
@@ -127,7 +129,13 @@ export function checkVideoDepthLength(
127
129
  }
128
130
  }
129
131
 
130
- /** The length buckets, in seconds, the Replicate lane (Depth Anything per frame) is priced in. */
132
+ /**
133
+ * The length buckets, in seconds, both providers were priced in before their
134
+ * per-second rows. A row is no longer picked from these: a clip's whole seconds
135
+ * name its row, so a `:15s` is the 15-second row and a `:120s` on Depth Anything
136
+ * per frame is past its limit. Each per-second row took its admin switches from
137
+ * the bucket that priced it (migrations 590 and 595).
138
+ */
131
139
  export const VIDEO_DEPTH_BUCKETS = [15, 30, 60, 120, 300] as const
132
140
 
133
141
  /** The longest clip `provider` accepts (`checkVideoDepthLength`); the fal limit for anything else. */
@@ -140,23 +148,17 @@ function videoDepthMaxSeconds(provider: string): number {
140
148
  /**
141
149
  * The price row for a clip of `durationSec`.
142
150
  *
143
- * The fal lane (Video Depth Anything) has one row per whole second of the clip
144
- * (`video-depth-anything:1s` … `:300s`, decided 2026-11-03): the length rounded
145
- * UP, so a clip under one second is priced as one. The Replicate lane (Depth
146
- * Anything per frame) has one row per length bucket (`VIDEO_DEPTH_BUCKETS`,
147
- * boundaries inclusive).
151
+ * One row per whole second of the clip on both lanes: the clip's length rounded
152
+ * UP (`pricedClipSeconds`: up to 0.05 s past a whole second is ignored first), so
153
+ * a clip under one second is priced as one. `video-depth-anything:1s` … `:300s`
154
+ * (decided 2026-11-03), `depth-anything-frames:1s` … `:80s` (decided 2026-11-04).
148
155
  *
149
156
  * Unknown, non-positive or longer than the provider accepts → the provider's
150
- * highest REACHABLE row: fal's longest clip (300 s → `:300s`), Replicate's
151
- * smallest bucket at or above its longest clip (80 s → `:120s`) — the most a
152
- * run on it can be charged, never a row a run could not reach.
157
+ * longest clip (fal `:300s`, Replicate `:80s`), its highest REACHABLE row — the
158
+ * most a run on it can be charged, never a row a run could not reach.
153
159
  */
154
160
  export function videoDepthCreditId(provider: string, durationSec: number | null | undefined): string {
155
161
  const maxSec = videoDepthMaxSeconds(provider)
156
162
  const known = typeof durationSec === "number" && Number.isFinite(durationSec) && durationSec > 0 && durationSec <= maxSec
157
- if (FAL_VIDEO_DEPTH_PROVIDERS.has(provider)) return `${provider}:${known ? Math.ceil(durationSec) : maxSec}s`
158
- const top = VIDEO_DEPTH_BUCKETS[VIDEO_DEPTH_BUCKETS.length - 1]
159
- const reachableCeiling = VIDEO_DEPTH_BUCKETS.find((b) => b >= maxSec) ?? top
160
- const bucket = known ? (VIDEO_DEPTH_BUCKETS.find((b) => durationSec <= b) ?? top) : reachableCeiling
161
- return `${provider}:${bucket}s`
163
+ return `${provider}:${known ? pricedClipSeconds(durationSec) : maxSec}s`
162
164
  }
@@ -10,6 +10,7 @@
10
10
  * Priced by the clip's length at the 30 fps basis Video Mask uses
11
11
  * (`videoMaskBilledSeconds`), one row per length bucket.
12
12
  */
13
+ import { pricedClipSeconds } from "./priced-clip-seconds.js"
13
14
  import { VIDEO_MASK_LIMITS, type VideoMaskZone } from "./video-mask.js"
14
15
  import type { VideoDepthColormap } from "./video-depth.js"
15
16
 
@@ -63,14 +64,16 @@ export function videoFaceMeshCreditIds(): string[] {
63
64
 
64
65
  /**
65
66
  * The price row for a clip priced at `billedSec` seconds: the smallest bucket
66
- * that holds it. An unknown or non-positive length, or one past the cap,
67
+ * that holds it, after `pricedClipSeconds` (up to 0.05 s past a bucket's length
68
+ * stays in that bucket). An unknown or non-positive length, or one past the cap,
67
69
  * prices the LONGEST row (the route measures every clip and refuses one past
68
70
  * the cap, so this is only ever a ceiling).
69
71
  */
70
72
  export function videoFaceMeshCreditId(billedSec: number | null | undefined): string {
71
73
  const ids = videoFaceMeshCreditIds()
72
74
  if (typeof billedSec !== "number" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!
73
- const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => billedSec <= b)
75
+ const priced = pricedClipSeconds(billedSec)
76
+ const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => priced <= b)
74
77
  return ids[i === -1 ? ids.length - 1 : i]!
75
78
  }
76
79
 
package/src/video-mask.ts CHANGED
@@ -10,12 +10,13 @@
10
10
  * charged from. The credit amounts live in the rows, never here.
11
11
  *
12
12
  * Worked examples (repeated in docs/nodes/ai-video/video-mask.md):
13
- * 4 s at 30 fps → `sam-3.1-video:5s`, 12 s at 24 fps → `sam-3.1-video:15s`,
13
+ * 4 s at 30 fps → `sam-3.1-video:5s`, 5.005 s at 29.97 fps → `sam-3.1-video:5s`, 12 s at 24 fps → `sam-3.1-video:15s`,
14
14
  * 10 s at 60 fps (priced as 20 s) → `sam-3.1-video:30s`, 45 s at 30 fps → `sam-3.1-video:60s`,
15
15
  * 100 s at 30 fps → `sam-3.1-video:120s`, 4 min at 30 fps on SAM 3 → `sam-3-video:240s`.
16
16
  *
17
17
  * Wire contract only — no I/O.
18
18
  */
19
+ import { pricedClipSeconds } from "./priced-clip-seconds.js"
19
20
 
20
21
  /** Segmentation models a Video Mask run can use. SAM 3.1 (the default)
21
22
  * tracks several objects in one pass and runs faster; SAM 3 costs half. */
@@ -166,7 +167,8 @@ export function videoMaskCreditIds(provider: VideoMaskProvider = DEFAULT_VIDEO_M
166
167
  /**
167
168
  * The length a clip is priced at: its duration at the 30 fps basis. A clip
168
169
  * at or under 30 fps is priced at its own length; a 60 fps clip at twice it.
169
- * An unknown frame rate counts as the basis.
170
+ * An unknown frame rate counts as the basis. The cap reads this figure; the
171
+ * price row reads it through `pricedClipSeconds`.
170
172
  */
171
173
  export function videoMaskBilledSeconds(durationSec: number, fps?: number | null): number {
172
174
  const rate = typeof fps === "number" && Number.isFinite(fps) && fps > 0 ? fps : VIDEO_MASK_LIMITS.FPS_BASIS
@@ -174,10 +176,12 @@ export function videoMaskBilledSeconds(durationSec: number, fps?: number | null)
174
176
  }
175
177
 
176
178
  /**
177
- * The price row for a clip priced at `billedSec` seconds. An unknown or
178
- * non-positive length prices the LONGEST row (a clip the route could not
179
- * measure is refused, so this is only the pre-run quote for a clip whose
180
- * length is not known yet); anything past the cap prices the last row.
179
+ * The price row for a clip priced at `billedSec` seconds: the smallest that
180
+ * holds it, after `pricedClipSeconds` (up to 0.05 s past a row's length stays in
181
+ * that row). An unknown or non-positive length prices the LONGEST row (a clip
182
+ * the route could not measure is refused, so this is only the pre-run quote for
183
+ * a clip whose length is not known yet); anything past the cap prices the last
184
+ * row.
181
185
  */
182
186
  export function videoMaskCreditId(
183
187
  billedSec: number | null | undefined,
@@ -185,7 +189,8 @@ export function videoMaskCreditId(
185
189
  ): string {
186
190
  const ids = videoMaskCreditIds(provider)
187
191
  if (typeof billedSec !== "number" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!
188
- const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => billedSec <= b)
192
+ const priced = pricedClipSeconds(billedSec)
193
+ const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => priced <= b)
189
194
  return ids[i === -1 ? ids.length - 1 : i]!
190
195
  }
191
196
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generated/unit-contracts.ts","../src/unit-contract-compose.ts"],"names":[],"mappings":";;;AAQO,IAAM,cAAA,GAA4G;AAAA,EACvH,CAAC,mBAAmB,SAAS,CAAA;AAAA;AAAA,EAC7B,CAAC,mBAAmB,OAAO,CAAA;AAAA;AAAA,EAC3B,CAAC,aAAa,SAAS,CAAA;AAAA;AAAA,EACvB,CAAC,kBAAkB,OAAO,CAAA;AAAA;AAAA,EAC1B,CAAC,gBAAgB,OAAO,CAAA;AAAA;AAAA,EACxB,CAAC,gBAAgB,OAAO;AAAA;AAC1B,CAAA;AAGO,IAAM,mBAAA,GAAsB;AAAA,EACjC,iBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,iBAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA;AAAA;AACF;AAGO,IAAM,cAAA,GAAyH;AAAA,EACpI,CAAC,iBAAA,EAAmB,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EACrC,CAAC,kBAAA,EAAoB,EAAE,MAAA,EAAQ,SAAS,CAAA;AAAA;AAAA,EACxC,CAAC,iBAAA,EAAmB,EAAE,MAAA,EAA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;AAGzE,IAAM,eAAe,MAAkG;AAGvH,IAAM,sBAAsB,MAA+D;AAG3F,IAAM,kBAAkB,MAAyB;AAGjD,IAAM,iBAAiB,MAA4G","file":"chunk-5PCI6M44.cjs","sourcesContent":["// GENERATED by tools/units/gen.mjs — do not edit; run npm run gen:units\n// The unit contract published in @nodaro/shared (decided 2026-10-16, widened 2026-10-18): node type\n// ids with closed vocabularies — each unit's producer kind, the use-case types, what each JSON pip\n// carries, the input pips that are never a prompt lane, the review holds, how a published app\n// presents the result and which outputs fan out item by item. Never a price, credit id, number,\n// prompt or doctrine string. Each block feeds a published table that composes its rows with the\n// hand-written ones (unit-contract-compose.ts); every row is an irrevocable Apache grant.\n\nexport const UNIT_CONTRACTS: ReadonlyArray<readonly [type: string, producer: \"audio\" | \"video\" | \"image\" | \"dynamic\"]> = [\n [\"tighten-episode\", \"dynamic\"], // unit:tighten-episode\n [\"episode-trailer\", \"video\"], // unit:episode-trailer\n [\"clip-pack\", \"dynamic\"], // unit:clip-pack\n [\"speaker-layout\", \"video\"], // unit:speaker-layout\n [\"remove-audio\", \"video\"], // unit:remove-audio\n [\"gif-to-video\", \"video\"], // unit:gif-to-video\n]\n\n// The use-case node units (execution.kind \"use-case\"), in position order — each a route POST /v1/<type> (+ /estimate, /continue).\nexport const UNIT_USE_CASE_TYPES = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-chapters\", // unit:episode-chapters\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n] as const\n\n// What each JSON (look) output pip carries (contract.jsonPips) — json-kinds.ts composes these.\nexport const UNIT_JSON_PIPS: ReadonlyArray<readonly [type: string, pips: Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> = [\n [\"tighten-episode\", { \"json\": \"edl\" }], // unit:tighten-episode\n [\"episode-chapters\", { \"json\": \"other\" }], // unit:episode-chapters\n [\"episode-trailer\", { \"json\": \"edl\" }], // unit:episode-trailer\n [\"clip-pack\", { \"json\": \"edl\" }], // unit:clip-pack\n [\"speaker-layout\", { \"json\": \"edl\" }], // unit:speaker-layout\n [\"speaker-map\", { \"edl\": \"edl\", \"json\": \"other\" }], // unit:speaker-map\n]\n\n// Input pips that are never a prompt lane (contract.nonPromptInputs) — fan-out-rows.ts composes these.\nexport const UNIT_NON_PROMPT_INPUTS: ReadonlyArray<readonly [type: string, handles: ReadonlyArray<string>]> = [\n [\"tighten-episode\", [\"music\", \"masterAudio\"]], // unit:tighten-episode\n [\"episode-trailer\", [\"introCard\", \"masterAudio\"]], // unit:episode-trailer\n [\"clip-pack\", [\"masterAudio\"]], // unit:clip-pack\n [\"speaker-layout\", [\"masterAudio\"]], // unit:speaker-layout\n]\n\n// Use-case units whose review-on run ends at a Preview that holds what follows (contract.reviewHold) — preview-gate.ts.\nexport const UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n]\n\n// How a published app shows each unit's result where the producer sets do not decide it (contract.presents) — presentation-utils.ts.\nexport const UNIT_PRESENTS: ReadonlyArray<readonly [type: string, presents: \"image\" | \"video\" | \"audio\" | \"text\"]> = [\n [\"tighten-episode\", \"video\"], // unit:tighten-episode\n [\"episode-chapters\", \"text\"], // unit:episode-chapters\n [\"clip-pack\", \"video\"], // unit:clip-pack\n]\n\n// The outputs an \"each\" edge reads item by item when the unit ran once per item, and the pip an edge naming none reads (contract.fanOutEach) — producer-types.ts.\nexport const UNIT_FAN_OUT_EACH: ReadonlyArray<readonly [type: string, handles: { readonly each: ReadonlyArray<string>; readonly primary: string }]> = [\n [\"episode-trailer\", { \"each\": [\"media\"], \"primary\": \"media\" }], // unit:episode-trailer\n [\"clip-pack\", { \"each\": [\"clips\"], \"primary\": \"clips\" }], // unit:clip-pack\n]\n","/**\n * The node units' rows in @nodaro/shared (tools/units/README.md): the readers\n * of `generated/unit-contracts.ts` and the one rule every table that composes\n * them keeps — a type is hand-written or a node unit, never both. Internal:\n * no entry exports this module, so it adds nothing to the published surface;\n * the tables that compose its rows (producer-types, presentation-utils,\n * json-kinds, fan-out-rows, preview-gate) are what consumers read.\n */\nimport { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS } from \"./generated/unit-contracts.js\"\n\n/**\n * `legacy ∪ units` as a set, `legacy` first, refusing a type that is in both —\n * a type lives in one place (G1; the editor's and the server's composeSet keep\n * the same rule). Throws at module load, so any import of the set fails.\n */\nexport function composeUnitSet(what: string, legacy: readonly string[], units: readonly string[]): ReadonlySet<string> {\n const clash = units.filter((t) => legacy.includes(t))\n if (clash.length > 0) throw new Error(`${what}: ${clash.join(\", \")} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n return new Set([...legacy, ...units])\n}\n\n/**\n * `legacy` with each unit row added after it, refusing a type that is in both\n * or a unit row given twice — the record twin of `composeUnitSet`. Throws at\n * module load, so any import of the record fails.\n */\nexport function composeUnitRecord<V>(what: string, legacy: Readonly<Record<string, V>>, units: ReadonlyArray<readonly [string, V]>): Readonly<Record<string, V>> {\n const out: Record<string, V> = { ...legacy }\n for (const [type, value] of units) {\n if (Object.hasOwn(legacy, type)) throw new Error(`${what}: ${type} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n if (Object.hasOwn(out, type)) throw new Error(`${what}: node unit ${type} has more than one row`)\n out[type] = value\n }\n return out\n}\n\n/** The node units of one producer kind (`contract.producer`), in generated order. */\nexport const unitProducers = (kind: \"audio\" | \"video\" | \"image\" | \"dynamic\"): string[] =>\n UNIT_CONTRACTS.filter(([, producer]) => producer === kind).map(([type]) => type)\n\n/** The node units a published app shows as `kind` (`contract.presents`). */\nexport const unitsPresenting = (kind: \"image\" | \"video\" | \"audio\" | \"text\"): string[] =>\n UNIT_PRESENTS.filter(([, presents]) => presents === kind).map(([type]) => type)\n\n/** What each node unit's JSON (look) output pips carry (`contract.jsonPips`). */\nexport const unitJsonPips = (): ReadonlyArray<readonly [string, Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> => UNIT_JSON_PIPS\n\n/** Each node unit's input pips that are never a prompt lane (`contract.nonPromptInputs`). */\nexport const unitNonPromptInputs = (): ReadonlyArray<readonly [string, ReadonlyArray<string>]> => UNIT_NON_PROMPT_INPUTS\n\n/** The use-case units whose review-on run ends at a Preview that holds what follows (`contract.reviewHold`). */\nexport const unitReviewHolds = (): readonly string[] => UNIT_REVIEW_HOLDS\n\n/** Each node unit's fan-out \"each\" outputs and primary pip (`contract.fanOutEach`), in generated order. */\nexport const unitFanOutEach = (): ReadonlyArray<readonly [string, { readonly each: ReadonlyArray<string>; readonly primary: string }]> => UNIT_FAN_OUT_EACH\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generated/unit-contracts.ts","../src/unit-contract-compose.ts"],"names":[],"mappings":";AAQO,IAAM,cAAA,GAA4G;AAAA,EACvH,CAAC,mBAAmB,SAAS,CAAA;AAAA;AAAA,EAC7B,CAAC,mBAAmB,OAAO,CAAA;AAAA;AAAA,EAC3B,CAAC,aAAa,SAAS,CAAA;AAAA;AAAA,EACvB,CAAC,kBAAkB,OAAO,CAAA;AAAA;AAAA,EAC1B,CAAC,gBAAgB,OAAO,CAAA;AAAA;AAAA,EACxB,CAAC,gBAAgB,OAAO;AAAA;AAC1B,CAAA;AAGO,IAAM,mBAAA,GAAsB;AAAA,EACjC,iBAAA;AAAA;AAAA,EACA,kBAAA;AAAA;AAAA,EACA,iBAAA;AAAA;AAAA,EACA,WAAA;AAAA;AAAA,EACA;AAAA;AACF;AAGO,IAAM,cAAA,GAAyH;AAAA,EACpI,CAAC,iBAAA,EAAmB,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA;AAAA,EACrC,CAAC,kBAAA,EAAoB,EAAE,MAAA,EAAQ,SAAS,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,IAAI,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,IAAI,MAAM,IAAI;AAGzE,IAAM,eAAe,MAAkG;AAGvH,IAAM,sBAAsB,MAA+D;AAG3F,IAAM,kBAAkB,MAAyB;AAGjD,IAAM,iBAAiB,MAA4G","file":"chunk-CQJYKSXF.js","sourcesContent":["// GENERATED by tools/units/gen.mjs — do not edit; run npm run gen:units\n// The unit contract published in @nodaro/shared (decided 2026-10-16, widened 2026-10-18): node type\n// ids with closed vocabularies — each unit's producer kind, the use-case types, what each JSON pip\n// carries, the input pips that are never a prompt lane, the review holds, how a published app\n// presents the result and which outputs fan out item by item. Never a price, credit id, number,\n// prompt or doctrine string. Each block feeds a published table that composes its rows with the\n// hand-written ones (unit-contract-compose.ts); every row is an irrevocable Apache grant.\n\nexport const UNIT_CONTRACTS: ReadonlyArray<readonly [type: string, producer: \"audio\" | \"video\" | \"image\" | \"dynamic\"]> = [\n [\"tighten-episode\", \"dynamic\"], // unit:tighten-episode\n [\"episode-trailer\", \"video\"], // unit:episode-trailer\n [\"clip-pack\", \"dynamic\"], // unit:clip-pack\n [\"speaker-layout\", \"video\"], // unit:speaker-layout\n [\"remove-audio\", \"video\"], // unit:remove-audio\n [\"gif-to-video\", \"video\"], // unit:gif-to-video\n]\n\n// The use-case node units (execution.kind \"use-case\"), in position order — each a route POST /v1/<type> (+ /estimate, /continue).\nexport const UNIT_USE_CASE_TYPES = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-chapters\", // unit:episode-chapters\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n] as const\n\n// What each JSON (look) output pip carries (contract.jsonPips) — json-kinds.ts composes these.\nexport const UNIT_JSON_PIPS: ReadonlyArray<readonly [type: string, pips: Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> = [\n [\"tighten-episode\", { \"json\": \"edl\" }], // unit:tighten-episode\n [\"episode-chapters\", { \"json\": \"other\" }], // unit:episode-chapters\n [\"episode-trailer\", { \"json\": \"edl\" }], // unit:episode-trailer\n [\"clip-pack\", { \"json\": \"edl\" }], // unit:clip-pack\n [\"speaker-layout\", { \"json\": \"edl\" }], // unit:speaker-layout\n [\"speaker-map\", { \"edl\": \"edl\", \"json\": \"other\" }], // unit:speaker-map\n]\n\n// Input pips that are never a prompt lane (contract.nonPromptInputs) — fan-out-rows.ts composes these.\nexport const UNIT_NON_PROMPT_INPUTS: ReadonlyArray<readonly [type: string, handles: ReadonlyArray<string>]> = [\n [\"tighten-episode\", [\"music\", \"masterAudio\"]], // unit:tighten-episode\n [\"episode-trailer\", [\"introCard\", \"masterAudio\"]], // unit:episode-trailer\n [\"clip-pack\", [\"masterAudio\"]], // unit:clip-pack\n [\"speaker-layout\", [\"masterAudio\"]], // unit:speaker-layout\n]\n\n// Use-case units whose review-on run ends at a Preview that holds what follows (contract.reviewHold) — preview-gate.ts.\nexport const UNIT_REVIEW_HOLDS: ReadonlyArray<string> = [\n \"tighten-episode\", // unit:tighten-episode\n \"episode-trailer\", // unit:episode-trailer\n \"clip-pack\", // unit:clip-pack\n \"speaker-layout\", // unit:speaker-layout\n]\n\n// How a published app shows each unit's result where the producer sets do not decide it (contract.presents) — presentation-utils.ts.\nexport const UNIT_PRESENTS: ReadonlyArray<readonly [type: string, presents: \"image\" | \"video\" | \"audio\" | \"text\"]> = [\n [\"tighten-episode\", \"video\"], // unit:tighten-episode\n [\"episode-chapters\", \"text\"], // unit:episode-chapters\n [\"clip-pack\", \"video\"], // unit:clip-pack\n]\n\n// The outputs an \"each\" edge reads item by item when the unit ran once per item, and the pip an edge naming none reads (contract.fanOutEach) — producer-types.ts.\nexport const UNIT_FAN_OUT_EACH: ReadonlyArray<readonly [type: string, handles: { readonly each: ReadonlyArray<string>; readonly primary: string }]> = [\n [\"episode-trailer\", { \"each\": [\"media\"], \"primary\": \"media\" }], // unit:episode-trailer\n [\"clip-pack\", { \"each\": [\"clips\"], \"primary\": \"clips\" }], // unit:clip-pack\n]\n","/**\n * The node units' rows in @nodaro/shared (tools/units/README.md): the readers\n * of `generated/unit-contracts.ts` and the one rule every table that composes\n * them keeps — a type is hand-written or a node unit, never both. Internal:\n * no entry exports this module, so it adds nothing to the published surface;\n * the tables that compose its rows (producer-types, presentation-utils,\n * json-kinds, fan-out-rows, preview-gate) are what consumers read.\n */\nimport { UNIT_CONTRACTS, UNIT_FAN_OUT_EACH, UNIT_JSON_PIPS, UNIT_NON_PROMPT_INPUTS, UNIT_PRESENTS, UNIT_REVIEW_HOLDS } from \"./generated/unit-contracts.js\"\n\n/**\n * `legacy ∪ units` as a set, `legacy` first, refusing a type that is in both —\n * a type lives in one place (G1; the editor's and the server's composeSet keep\n * the same rule). Throws at module load, so any import of the set fails.\n */\nexport function composeUnitSet(what: string, legacy: readonly string[], units: readonly string[]): ReadonlySet<string> {\n const clash = units.filter((t) => legacy.includes(t))\n if (clash.length > 0) throw new Error(`${what}: ${clash.join(\", \")} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n return new Set([...legacy, ...units])\n}\n\n/**\n * `legacy` with each unit row added after it, refusing a type that is in both\n * or a unit row given twice — the record twin of `composeUnitSet`. Throws at\n * module load, so any import of the record fails.\n */\nexport function composeUnitRecord<V>(what: string, legacy: Readonly<Record<string, V>>, units: ReadonlyArray<readonly [string, V]>): Readonly<Record<string, V>> {\n const out: Record<string, V> = { ...legacy }\n for (const [type, value] of units) {\n if (Object.hasOwn(legacy, type)) throw new Error(`${what}: ${type} is both hand-written and a node unit — a type lives in one place (tools/units/README.md)`)\n if (Object.hasOwn(out, type)) throw new Error(`${what}: node unit ${type} has more than one row`)\n out[type] = value\n }\n return out\n}\n\n/** The node units of one producer kind (`contract.producer`), in generated order. */\nexport const unitProducers = (kind: \"audio\" | \"video\" | \"image\" | \"dynamic\"): string[] =>\n UNIT_CONTRACTS.filter(([, producer]) => producer === kind).map(([type]) => type)\n\n/** The node units a published app shows as `kind` (`contract.presents`). */\nexport const unitsPresenting = (kind: \"image\" | \"video\" | \"audio\" | \"text\"): string[] =>\n UNIT_PRESENTS.filter(([, presents]) => presents === kind).map(([type]) => type)\n\n/** What each node unit's JSON (look) output pips carry (`contract.jsonPips`). */\nexport const unitJsonPips = (): ReadonlyArray<readonly [string, Readonly<Record<string, \"transcript\" | \"edl\" | \"other\">>]> => UNIT_JSON_PIPS\n\n/** Each node unit's input pips that are never a prompt lane (`contract.nonPromptInputs`). */\nexport const unitNonPromptInputs = (): ReadonlyArray<readonly [string, ReadonlyArray<string>]> => UNIT_NON_PROMPT_INPUTS\n\n/** The use-case units whose review-on run ends at a Preview that holds what follows (`contract.reviewHold`). */\nexport const unitReviewHolds = (): readonly string[] => UNIT_REVIEW_HOLDS\n\n/** Each node unit's fan-out \"each\" outputs and primary pip (`contract.fanOutEach`), in generated order. */\nexport const unitFanOutEach = (): ReadonlyArray<readonly [string, { readonly each: ReadonlyArray<string>; readonly primary: string }]> => UNIT_FAN_OUT_EACH\n"]}