@nodaro/shared 3.70.0 → 3.72.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 (207) hide show
  1. package/dist/{chunk-M7LU4NTI.cjs → chunk-26GM45QE.cjs} +18 -2
  2. package/dist/chunk-26GM45QE.cjs.map +1 -0
  3. package/dist/{chunk-PWIKUOLB.cjs → chunk-32QY5AIY.cjs} +8 -8
  4. package/dist/{chunk-PWIKUOLB.cjs.map → chunk-32QY5AIY.cjs.map} +1 -1
  5. package/dist/{chunk-4U7QAUV3.cjs → chunk-4BCODXK6.cjs} +61 -61
  6. package/dist/{chunk-4U7QAUV3.cjs.map → chunk-4BCODXK6.cjs.map} +1 -1
  7. package/dist/{chunk-DOY47F7S.cjs → chunk-5WXVPPRH.cjs} +7 -7
  8. package/dist/{chunk-DOY47F7S.cjs.map → chunk-5WXVPPRH.cjs.map} +1 -1
  9. package/dist/{chunk-NS34PZ2S.js → chunk-7DMK7B3Q.js} +3 -3
  10. package/dist/{chunk-NS34PZ2S.js.map → chunk-7DMK7B3Q.js.map} +1 -1
  11. package/dist/{chunk-5DRSENY3.cjs → chunk-AIPOZKQV.cjs} +14 -12
  12. package/dist/{chunk-PKWRAMVB.js.map → chunk-AIPOZKQV.cjs.map} +1 -1
  13. package/dist/{chunk-HWBLZSM3.cjs → chunk-AXDTMRWR.cjs} +51 -28
  14. package/dist/chunk-AXDTMRWR.cjs.map +1 -0
  15. package/dist/{chunk-OW5AXH2Y.js → chunk-CL7ECTK2.js} +5 -4
  16. package/dist/chunk-CL7ECTK2.js.map +1 -0
  17. package/dist/{chunk-KKFFQUMM.js → chunk-D5NRBVUH.js} +5 -5
  18. package/dist/chunk-D5NRBVUH.js.map +1 -0
  19. package/dist/{chunk-52JNQG4K.js → chunk-D7DCDIMU.js} +3 -3
  20. package/dist/{chunk-52JNQG4K.js.map → chunk-D7DCDIMU.js.map} +1 -1
  21. package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
  22. package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
  23. package/dist/{chunk-PKWRAMVB.js → chunk-EI4V43DI.js} +7 -5
  24. package/dist/chunk-EI4V43DI.js.map +1 -0
  25. package/dist/{chunk-EWNDK4FV.js → chunk-EOYQD6DU.js} +3 -3
  26. package/dist/{chunk-EWNDK4FV.js.map → chunk-EOYQD6DU.js.map} +1 -1
  27. package/dist/{chunk-HA2PVTER.js → chunk-GCOS7CFL.js} +4 -4
  28. package/dist/{chunk-HA2PVTER.js.map → chunk-GCOS7CFL.js.map} +1 -1
  29. package/dist/{chunk-XBHDXURR.cjs → chunk-HJGL2UNQ.cjs} +78 -78
  30. package/dist/chunk-HJGL2UNQ.cjs.map +1 -0
  31. package/dist/{chunk-HBRDKHIW.cjs → chunk-HOQ4TLDW.cjs} +21 -21
  32. package/dist/{chunk-HBRDKHIW.cjs.map → chunk-HOQ4TLDW.cjs.map} +1 -1
  33. package/dist/{chunk-POZBRZUM.cjs → chunk-I2GFLOLD.cjs} +41 -41
  34. package/dist/{chunk-POZBRZUM.cjs.map → chunk-I2GFLOLD.cjs.map} +1 -1
  35. package/dist/{chunk-LTBM2KMY.js → chunk-INJP7EFI.js} +235 -9
  36. package/dist/chunk-INJP7EFI.js.map +1 -0
  37. package/dist/{chunk-BLGZW3UF.cjs → chunk-JUCWBIEE.cjs} +291 -20
  38. package/dist/chunk-JUCWBIEE.cjs.map +1 -0
  39. package/dist/{chunk-JEUZNHLL.cjs → chunk-L2WHTUBA.cjs} +40 -34
  40. package/dist/chunk-L2WHTUBA.cjs.map +1 -0
  41. package/dist/{chunk-V6TC2NDG.js → chunk-LMBHF5TZ.js} +4 -4
  42. package/dist/{chunk-V6TC2NDG.js.map → chunk-LMBHF5TZ.js.map} +1 -1
  43. package/dist/{chunk-QCVQVKCI.js → chunk-LP5KZZAF.js} +3 -3
  44. package/dist/{chunk-QCVQVKCI.js.map → chunk-LP5KZZAF.js.map} +1 -1
  45. package/dist/{chunk-42ICEVUN.js → chunk-M4MXK7RJ.js} +3 -3
  46. package/dist/{chunk-42ICEVUN.js.map → chunk-M4MXK7RJ.js.map} +1 -1
  47. package/dist/{chunk-BIQ7COJP.js → chunk-MR4KSZY3.js} +5 -5
  48. package/dist/{chunk-BIQ7COJP.js.map → chunk-MR4KSZY3.js.map} +1 -1
  49. package/dist/{chunk-OZHE77T3.cjs → chunk-NEBO32KZ.cjs} +9 -9
  50. package/dist/{chunk-OZHE77T3.cjs.map → chunk-NEBO32KZ.cjs.map} +1 -1
  51. package/dist/{chunk-MZ772ZXA.cjs → chunk-NSKH5ULV.cjs} +17 -17
  52. package/dist/{chunk-MZ772ZXA.cjs.map → chunk-NSKH5ULV.cjs.map} +1 -1
  53. package/dist/{chunk-QV32JI4L.cjs → chunk-OALWH5VV.cjs} +4 -4
  54. package/dist/{chunk-QV32JI4L.cjs.map → chunk-OALWH5VV.cjs.map} +1 -1
  55. package/dist/{chunk-IKN54UGB.js → chunk-OWNGS4DF.js} +3 -3
  56. package/dist/{chunk-IKN54UGB.js.map → chunk-OWNGS4DF.js.map} +1 -1
  57. package/dist/{chunk-FWPGRC4X.cjs → chunk-QFW25UCC.cjs} +5 -5
  58. package/dist/{chunk-FWPGRC4X.cjs.map → chunk-QFW25UCC.cjs.map} +1 -1
  59. package/dist/{chunk-FMQ43SJP.cjs → chunk-QVRAPR4D.cjs} +6 -6
  60. package/dist/{chunk-FMQ43SJP.cjs.map → chunk-QVRAPR4D.cjs.map} +1 -1
  61. package/dist/{chunk-PYYYBINP.cjs → chunk-RMDTBXYT.cjs} +6 -6
  62. package/dist/{chunk-PYYYBINP.cjs.map → chunk-RMDTBXYT.cjs.map} +1 -1
  63. package/dist/{chunk-O53P2D4V.js → chunk-SXDLBXSB.js} +9 -5
  64. package/dist/chunk-SXDLBXSB.js.map +1 -0
  65. package/dist/{chunk-YLDY23N2.js → chunk-U7PHAD2O.js} +5 -5
  66. package/dist/{chunk-YLDY23N2.js.map → chunk-U7PHAD2O.js.map} +1 -1
  67. package/dist/{chunk-TADEEG5E.js → chunk-UC3CMPDN.js} +18 -3
  68. package/dist/chunk-UC3CMPDN.js.map +1 -0
  69. package/dist/{chunk-QCZYYAPZ.cjs → chunk-UMUSJHH2.cjs} +48 -48
  70. package/dist/{chunk-QCZYYAPZ.cjs.map → chunk-UMUSJHH2.cjs.map} +1 -1
  71. package/dist/{chunk-H2E4QXEZ.js → chunk-VVLW63HD.js} +3 -3
  72. package/dist/{chunk-H2E4QXEZ.js.map → chunk-VVLW63HD.js.map} +1 -1
  73. package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
  74. package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
  75. package/dist/{chunk-QVAUBB2T.js → chunk-WXJMPWYR.js} +9 -9
  76. package/dist/{chunk-QVAUBB2T.js.map → chunk-WXJMPWYR.js.map} +1 -1
  77. package/dist/{chunk-R22UHRR6.js → chunk-X7UDZGXW.js} +51 -28
  78. package/dist/chunk-X7UDZGXW.js.map +1 -0
  79. package/dist/{chunk-2VOXSVIE.js → chunk-XEMEUKXK.js} +3 -3
  80. package/dist/{chunk-2VOXSVIE.js.map → chunk-XEMEUKXK.js.map} +1 -1
  81. package/dist/{chunk-GC77W57T.cjs → chunk-YHDTBO45.cjs} +9 -9
  82. package/dist/{chunk-GC77W57T.cjs.map → chunk-YHDTBO45.cjs.map} +1 -1
  83. package/dist/{chunk-WHV7MDNC.cjs → chunk-ZJQ2L3MI.cjs} +5 -3
  84. package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
  85. package/dist/entries/apps.cjs +42 -42
  86. package/dist/entries/apps.js +7 -7
  87. package/dist/entries/credits.cjs +418 -238
  88. package/dist/entries/credits.d.cts +263 -2
  89. package/dist/entries/credits.d.ts +263 -2
  90. package/dist/entries/credits.js +9 -9
  91. package/dist/entries/edl.cjs +60 -60
  92. package/dist/entries/edl.d.cts +96 -1
  93. package/dist/entries/edl.d.ts +96 -1
  94. package/dist/entries/edl.js +1 -1
  95. package/dist/entries/i18n.cjs +15 -11
  96. package/dist/entries/i18n.d.cts +19 -1
  97. package/dist/entries/i18n.d.ts +19 -1
  98. package/dist/entries/i18n.js +1 -1
  99. package/dist/entries/llm-models.d.cts +1 -1
  100. package/dist/entries/llm-models.d.ts +1 -1
  101. package/dist/entries/model-catalog.cjs +133 -133
  102. package/dist/entries/model-catalog.js +4 -4
  103. package/dist/entries/models.cjs +412 -404
  104. package/dist/entries/models.d.cts +2 -2
  105. package/dist/entries/models.d.ts +2 -2
  106. package/dist/entries/models.js +5 -5
  107. package/dist/entries/nodes.cjs +212 -212
  108. package/dist/entries/nodes.js +8 -8
  109. package/dist/entries/pipeline.cjs +153 -153
  110. package/dist/entries/pipeline.d.cts +1 -1
  111. package/dist/entries/pipeline.d.ts +1 -1
  112. package/dist/entries/pipeline.js +3 -3
  113. package/dist/entries/social.cjs +195 -191
  114. package/dist/entries/social.d.cts +9 -3
  115. package/dist/entries/social.d.ts +9 -3
  116. package/dist/entries/social.js +1 -1
  117. package/dist/entries/ugc.cjs +71 -71
  118. package/dist/entries/ugc.js +4 -4
  119. package/dist/entries/video.cjs +152 -152
  120. package/dist/entries/video.js +6 -6
  121. package/dist/index.cjs +1835 -1639
  122. package/dist/index.d.cts +5 -5
  123. package/dist/index.d.ts +5 -5
  124. package/dist/index.js +21 -21
  125. package/dist/{model-constants-CQr_d3Kw.d.cts → model-constants-C4RL9Xtn.d.cts} +20 -4
  126. package/dist/{model-constants-B5DNHIP8.d.ts → model-constants-kRg3YCIJ.d.ts} +20 -4
  127. package/dist/style.ar-4WUT56YH.js +63 -0
  128. package/dist/style.ar-4WUT56YH.js.map +1 -0
  129. package/dist/style.ar-ZRS6ZSSS.cjs +65 -0
  130. package/dist/style.ar-ZRS6ZSSS.cjs.map +1 -0
  131. package/dist/style.de-6543OVTB.cjs +65 -0
  132. package/dist/style.de-6543OVTB.cjs.map +1 -0
  133. package/dist/style.de-HQS4NOVN.js +63 -0
  134. package/dist/style.de-HQS4NOVN.js.map +1 -0
  135. package/dist/style.es-ADFPO6LM.cjs +65 -0
  136. package/dist/style.es-ADFPO6LM.cjs.map +1 -0
  137. package/dist/style.es-O4N36TIJ.js +63 -0
  138. package/dist/style.es-O4N36TIJ.js.map +1 -0
  139. package/dist/style.fr-A3ZO6BP3.cjs +65 -0
  140. package/dist/style.fr-A3ZO6BP3.cjs.map +1 -0
  141. package/dist/style.fr-XKYO3NOK.js +63 -0
  142. package/dist/style.fr-XKYO3NOK.js.map +1 -0
  143. package/dist/style.he-DI4PXGJG.cjs +65 -0
  144. package/dist/style.he-DI4PXGJG.cjs.map +1 -0
  145. package/dist/style.he-L4SD3G7D.js +63 -0
  146. package/dist/style.he-L4SD3G7D.js.map +1 -0
  147. package/dist/style.hi-K625E6UR.js +63 -0
  148. package/dist/style.hi-K625E6UR.js.map +1 -0
  149. package/dist/style.hi-LMDM6S3Q.cjs +65 -0
  150. package/dist/style.hi-LMDM6S3Q.cjs.map +1 -0
  151. package/dist/style.ja-3YGEMQKQ.js +63 -0
  152. package/dist/style.ja-3YGEMQKQ.js.map +1 -0
  153. package/dist/style.ja-QV4Z4B3Y.cjs +65 -0
  154. package/dist/style.ja-QV4Z4B3Y.cjs.map +1 -0
  155. package/dist/style.ko-KIKAE2WS.js +63 -0
  156. package/dist/style.ko-KIKAE2WS.js.map +1 -0
  157. package/dist/style.ko-WXYT3ZAL.cjs +65 -0
  158. package/dist/style.ko-WXYT3ZAL.cjs.map +1 -0
  159. package/dist/style.pt-BR-R6WOR67L.js +64 -0
  160. package/dist/style.pt-BR-R6WOR67L.js.map +1 -0
  161. package/dist/style.pt-BR-WWGO7RUX.cjs +66 -0
  162. package/dist/style.pt-BR-WWGO7RUX.cjs.map +1 -0
  163. package/dist/style.ru-UVLIITMR.js +63 -0
  164. package/dist/style.ru-UVLIITMR.js.map +1 -0
  165. package/dist/style.ru-ZCB4IUCW.cjs +65 -0
  166. package/dist/style.ru-ZCB4IUCW.cjs.map +1 -0
  167. package/dist/style.zh-CN-IFAAZ475.cjs +65 -0
  168. package/dist/style.zh-CN-IFAAZ475.cjs.map +1 -0
  169. package/dist/style.zh-CN-RQEZCV44.js +63 -0
  170. package/dist/style.zh-CN-RQEZCV44.js.map +1 -0
  171. package/package.json +1 -1
  172. package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
  173. package/src/__tests__/competitors.test.ts +6 -1
  174. package/src/__tests__/credit-identifiers.test.ts +9 -10
  175. package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
  176. package/src/__tests__/normalize-node-params.test.ts +9 -2
  177. package/src/__tests__/style-sidecar-loaders.test.ts +29 -0
  178. package/src/__tests__/video-catalog-totality.test.ts +37 -5
  179. package/src/__tests__/video-to-video-pricing.test.ts +151 -0
  180. package/src/audio-isolation-pricing.ts +80 -0
  181. package/src/competitors.ts +8 -2
  182. package/src/credit-identifiers.ts +6 -0
  183. package/src/entries/credits.ts +54 -0
  184. package/src/entries/edl.ts +2 -0
  185. package/src/entries/i18n.ts +1 -0
  186. package/src/entries/models.ts +2 -0
  187. package/src/entries/social.ts +1 -0
  188. package/src/i18n/style-sidecar-loaders.ts +30 -0
  189. package/src/model-catalog.ts +49 -23
  190. package/src/model-constants.ts +24 -4
  191. package/src/motion-transfer-pricing.ts +239 -0
  192. package/src/producer-types.ts +2 -0
  193. package/src/use-case-output.ts +102 -0
  194. package/src/video-to-video-pricing.ts +248 -0
  195. package/dist/chunk-5DRSENY3.cjs.map +0 -1
  196. package/dist/chunk-BLGZW3UF.cjs.map +0 -1
  197. package/dist/chunk-HWBLZSM3.cjs.map +0 -1
  198. package/dist/chunk-JEUZNHLL.cjs.map +0 -1
  199. package/dist/chunk-KKFFQUMM.js.map +0 -1
  200. package/dist/chunk-LTBM2KMY.js.map +0 -1
  201. package/dist/chunk-M7LU4NTI.cjs.map +0 -1
  202. package/dist/chunk-O53P2D4V.js.map +0 -1
  203. package/dist/chunk-OW5AXH2Y.js.map +0 -1
  204. package/dist/chunk-R22UHRR6.js.map +0 -1
  205. package/dist/chunk-TADEEG5E.js.map +0 -1
  206. package/dist/chunk-WHV7MDNC.cjs.map +0 -1
  207. package/dist/chunk-XBHDXURR.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/audio-crossfade-curves.ts","../src/smart-cut-windows.ts","../src/speaker-tracks.ts","../src/speaker-map-contract.ts","../src/camera-switch-contract.ts","../src/edit-plan-contract.ts"],"names":["normalizeTranscript","num","EDL_VERSION"],"mappings":";;;;;AAkBO,IAAM,sBAAA,GAAyD;AAAA,EACpE;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,QAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,4BACX,sBAAA,CAAuB,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE;AAEjC,IAAM,gCAAA,GAAmC;AAEhD,IAAM,eAAyD,IAAI,GAAA;AAAA,EACjE,sBAAA,CAAuB,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,CAAA,KAAM,QAAA,IAAa,gBAAsC,QAAA,CAAS,CAAC,IAAK,CAAA,GAAqB,MAAA;AAC7G;AAGO,SAAS,eAAe,CAAA,EAA0B;AACvD,EAAA,OAAO,CAAA,KAAM,SAAA,IAAa,CAAA,KAAM,SAAA,GAAY,CAAA,GAAI,UAAA;AAClD;AAkBO,SAAS,qBAAqB,UAAA,EAA8B;AACjE,EAAA,IAAI,CAAC,UAAA,IAAc,OAAO,UAAA,KAAe,UAAU,OAAO,UAAA;AAC1D,EAAA,MAAM,CAAA,GAAI,UAAA;AAEV,EAAA,IAAI,MAAM,OAAA,CAAQ,CAAA,CAAE,KAAK,CAAA,SAAU,CAAA,CAAE,KAAA;AAErC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAA,CAAE,QAAQ,CAAA,EAAG,OAAO,EAAE,OAAA,EAASC,6BAAA,EAAa,QAAA,EAAU,CAAA,CAAE,QAAA,EAAS;AAEnF,EAAA,MAAM,EAAE,cAAA,EAAgB,eAAA,EAAiB,GAAG,MAAK,GAAI,CAAA;AACrD,EAAA,OAAO,IAAA;AACT","file":"chunk-HW6TLOK4.cjs","sourcesContent":["/**\n * Curated subset of FFmpeg `acrossfade=curve=...` options for combine-videos\n * audio crossfades. We expose 5 well-understood presets out of the ~21 raw\n * curves FFmpeg supports; the rest are either visually indistinguishable to\n * non-audio-engineers or rarely useful in this context.\n *\n * Default `linear` matches today's behavior — adding this catalog is a pure\n * additive change for existing workflows.\n */\n\nexport interface AudioCrossfadeCurve {\n readonly id: string\n /** FFmpeg `acrossfade=curve=...` name. */\n readonly ffmpeg: string\n readonly label: string\n readonly description: string\n}\n\nexport const AUDIO_CROSSFADE_CURVES: readonly AudioCrossfadeCurve[] = [\n {\n id: \"linear\",\n ffmpeg: \"tri\",\n label: \"Linear\",\n description: \"Straight-line fade. Default; predictable but can dip in the middle for music.\",\n },\n {\n id: \"equal-power\",\n ffmpeg: \"qsin\",\n label: \"Equal Power\",\n description: \"Quarter-sine. Keeps perceived loudness roughly constant across the crossfade — best for music.\",\n },\n {\n id: \"smooth\",\n ffmpeg: \"hsin\",\n label: \"Smooth (Sine)\",\n description: \"Half-sine. Gentler than equal-power; good for dialogue and ambient.\",\n },\n {\n id: \"logarithmic\",\n ffmpeg: \"log\",\n label: \"Logarithmic\",\n description: \"Compensates for the ear's logarithmic loudness response. Long, slow tails.\",\n },\n {\n id: \"exponential\",\n ffmpeg: \"exp\",\n label: \"Exponential\",\n description: \"Sharp out / slow in (or vice versa). Punchy — good for impact moments.\",\n },\n]\n\nexport const AUDIO_CROSSFADE_CURVE_IDS: readonly string[] =\n AUDIO_CROSSFADE_CURVES.map((c) => c.id)\n\nexport const DEFAULT_AUDIO_CROSSFADE_CURVE_ID = \"linear\"\n\nconst CURVES_BY_ID: ReadonlyMap<string, AudioCrossfadeCurve> = new Map(\n AUDIO_CROSSFADE_CURVES.map((c) => [c.id, c]),\n)\n\nexport function getAudioCrossfadeCurve(id: string): AudioCrossfadeCurve | undefined {\n return CURVES_BY_ID.get(id)\n}\n\n/**\n * Resolve a curve id to its FFmpeg `acrossfade=curve=` name. Unknown ids fall\n * back to `tri` (linear) — this matches the route's Zod default so callers\n * downstream of validation never see undefined.\n */\nexport function resolveAudioCrossfadeCurve(id: string | undefined): string {\n if (!id) return \"tri\"\n return CURVES_BY_ID.get(id)?.ffmpeg ?? \"tri\"\n}\n","/**\n * Smart-cut SEARCH WINDOWS — the shared bound + clamp for the\n * `smartCutFramesPrev` / `smartCutFramesNext` of BOTH smart-cut nodes:\n * generate-video-pro (segment boundaries) and combine-videos (clip joins).\n *\n * They bound how much of each side of a boundary the engine considers when\n * it places the cut: N frames from the end of a segment and M from the start\n * of the next. Absent → the engine's own default, byte-identical to the\n * behavior before they were exposed. A boundary the engine cannot resolve\n * inside the window falls back to the fixed freeze-trims; recast pins 24/24.\n *\n * Why a shared clamp: the config panel, the canvas node (single-node Run) and\n * the orchestrator (workflow Run) are three independent writers/send paths into\n * the same route, whose Zod schema REJECTS out-of-range values (its `.min()` /\n * `.max()` are these very constants). Deriving all of them from this one\n * function means a stale, imported or hand-edited node value degrades to a\n * legal request instead of 400-ing an entire run — and the paths cannot drift\n * apart. An `<input type=\"number\" max={…}>` is not a substitute: the browser\n * does not stop a typed or pasted value from reaching React's onChange.\n */\n\n/** Widest window we accept anywhere — the UI's `max`, the clamp's ceiling and\n * `/v1/combine-videos`' own Zod `.max()` (the generate-video-pro engine route\n * itself accepts up to 48). Past this, added frames only cost search time and\n * invite a false match. */\nexport const SMART_CUT_WINDOW_MAX = 24\n/** Narrowest meaningful window — one frame each side. */\nexport const SMART_CUT_WINDOW_MIN = 1\n/** The engine's default when the field is absent. Documented here so the UI\n * can show it as the placeholder without hardcoding a second copy. */\nexport const SMART_CUT_WINDOW_DEFAULT = 8\n\n/**\n * Narrow an arbitrary node value to a legal window, or `undefined` to mean\n * \"let the engine use its default\". Non-numbers, NaN, and non-integers all\n * collapse to `undefined` rather than to a guessed number: a malformed value\n * should fall back to the proven default, not silently pick a different\n * search width than the user asked for.\n */\nexport function clampSmartCutWindow(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const n = Math.round(value)\n if (n < SMART_CUT_WINDOW_MIN) return SMART_CUT_WINDOW_MIN\n if (n > SMART_CUT_WINDOW_MAX) return SMART_CUT_WINDOW_MAX\n return n\n}\n","import type { Edl, EdlSource, EdlValidation } from \"./edl.js\"\n\n/**\n * Speaker tracks — where each speaker's face is, over time, per camera.\n *\n * WHY THIS EXISTS\n * A face-tracking analysis node samples each camera an edit shows, finds the\n * faces, links them into tracks and labels each track with a speaker. Its\n * result feeds the framing rung `resolveEdlSegmentSlots` reserves for a\n * per-segment resolver (D20, edl-multicam.ts). This module is the wire shape\n * of that result plus the pure functions that read it: structural vocabulary\n * only — no detector, no linking or attribution rule, no framing or follow\n * math, no thresholds. That is why it lives in the Apache-licensed\n * `@nodaro/shared` (the public contract: the API response, the SDK type and\n * the MCP output). Every published version is an irrevocable grant, so every\n * later field is optional and additive.\n *\n * TWO SHAPES, ONE PROJECTION\n * - `SpeakerTrackSet` — the full set, boxes included. At a long multi-camera\n * edit it is megabytes of JSON, so it is stored as a JSON artifact (the\n * versioned box body), never inline in a job row or a node's data.\n * - `SpeakerTrackSetDescriptor` — what the node outputs: the same set with\n * every box removed (a `boxCount` per track instead) plus the artifact's\n * `url`, `sha256` and `bytes`. Consumers fetch the body by URL, check the\n * hash, run `normalizeSpeakerTracks` + `validateSpeakerTracks` on it, and\n * can confirm it is the body the descriptor names with\n * `describeSpeakerTracks(body, artifact)` deep-equal to the descriptor.\n *\n * CLOCK (D19)\n * Boxes are per SOURCE and on that source's own clock (`clock: \"source\"`), in\n * integer ms. A consumer maps to the master clock through the EDL source's\n * offset: `masterMs = ms + offsetMs` (`remapMsThroughEdl(edl, ms, sourceId)`).\n * Nothing here applies the offset, and nothing ever rescales a time (no\n * seconds→ms guessing — an implausible value is a validation error).\n *\n * GEOMETRY\n * Box coordinates are fractions 0..1 of `frame`: the display-oriented frame\n * (after rotation, square pixels) the producer sampled.\n *\n * SAMPLING\n * `sampledSpans` say what was looked at. No box for a track outside them means\n * \"not sampled\"; inside them it means \"no face there\". Spans are half-open\n * `[startMs, endMs)`, like EDL segments.\n */\n\nexport const SPEAKER_TRACKS_VERSION = 1 as const\n\n/** How a track got its speaker. Open: a newer producer may add a method, which\n * an older validator reports as a WARNING, never an issue. */\nexport const SPEAKER_TRACK_ATTRIBUTION_METHODS = [\"source-map\", \"region\", \"mouth-motion\", \"manual\"] as const\nexport type SpeakerTrackAttributionMethod = (typeof SPEAKER_TRACK_ATTRIBUTION_METHODS)[number]\nconst KNOWN_METHODS: ReadonlySet<string> = new Set(SPEAKER_TRACK_ATTRIBUTION_METHODS)\n\n/** Default hard cap on boxes per source. The longest edit the platform plans\n * for (180 minutes) sampled at 2 per second is 21,600 samples per source; the\n * cap leaves room for several faces in every sample. Override per call with\n * `maxBoxesPerSource`. */\nexport const SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE = 100_000\n/** Default hard cap on the serialized size of a track set (UTF-8 bytes of its\n * JSON), so no consumer ever loads an unbounded body. Override per call with\n * `maxBytes`. */\nexport const SPEAKER_TRACKS_MAX_BYTES = 64 * 1024 * 1024\n\n/** One detection. `ms` on the source clock; x/y/w/h fractions 0..1 of the frame. */\nexport interface SpeakerTrackBox {\n readonly ms: number\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n /** Detector confidence 0..1, when the detector reports one. */\n readonly score?: number\n}\n\nexport interface SpeakerTrackAttribution {\n /** Known: `SPEAKER_TRACK_ATTRIBUTION_METHODS`. */\n readonly method: SpeakerTrackAttributionMethod | (string & {})\n /** 0..1. */\n readonly confidence: number\n /** The transcript's own label for this speaker, kept beside the display name\n * in `speaker` so a later rename re-maps instead of orphaning the track. */\n readonly rawSpeaker?: string\n}\n\n/** What a track says about itself, without its boxes. */\nexport interface SpeakerTrackHeader {\n /** Unique in the whole set, e.g. \"wide/t3\". */\n readonly id: string\n /** A label in the edit's speaker space. Absent = unattributed. */\n readonly speaker?: string\n readonly attribution?: SpeakerTrackAttribution\n}\n\nexport interface SpeakerTrack extends SpeakerTrackHeader {\n /** Strictly increasing `ms`, each inside one of the source's `sampledSpans`. */\n readonly boxes: readonly SpeakerTrackBox[]\n}\n\nexport interface SpeakerTrackSummary extends SpeakerTrackHeader {\n readonly boxCount: number\n}\n\nexport interface SpeakerTrackSpan {\n readonly startMs: number\n /** Exclusive, > startMs. */\n readonly endMs: number\n}\n\ninterface SpeakerTrackSourceFields {\n /** `EdlSource.id` of a video source. */\n readonly sourceId: string\n /** Boxes, spans and cuts are ms on this SOURCE's own clock (D19). */\n readonly clock: \"source\"\n /** The display-oriented frame (after rotation, square pixels), in pixels, that box fractions refer to. */\n readonly frame: { readonly w: number; readonly h: number }\n /** What was sampled: sorted, non-overlapping, half-open. */\n readonly sampledSpans: readonly SpeakerTrackSpan[]\n /** Source-clock ms of detected scene changes, ascending. No track spans one. */\n readonly cuts?: readonly number[]\n}\n\nexport interface SpeakerTrackSource extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrack[]\n}\n\nexport interface SpeakerTrackSourceSummary extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrackSummary[]\n}\n\ninterface SpeakerTrackSetFields {\n readonly version: 1\n /** Samples per second the producer looked at. */\n readonly sampleFps: number\n /** Informational: which detector produced the boxes, e.g. \"example:face-detector\". */\n readonly detector: { readonly id: string; readonly version?: string }\n}\n\n/** The full set — the versioned box body, stored as a JSON artifact. */\nexport interface SpeakerTrackSet extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSource[]\n}\n\n/** What the analysis node outputs: the set without its boxes, plus where the body is. */\nexport interface SpeakerTrackSetDescriptor extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSourceSummary[]\n /** Where the `SpeakerTrackSet` body is stored. */\n readonly url: string\n /** SHA-256 of the stored body's bytes, 64 lowercase hex characters. */\n readonly sha256: string\n /** Size of the stored body in bytes. */\n readonly bytes: number\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject — and never reinterpret)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\nconst isNum = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\nconst num = (v: unknown, fallback = 0): number => (isNum(v) ? v : fallback)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v))\n/** A readonly array field of a value that may have skipped normalization. */\nconst arr = <T,>(v: readonly T[] | undefined): readonly T[] => (Array.isArray(v) ? v : [])\n/** Integer ms; never -0 (JSON cannot carry it, so a round trip would differ). */\nconst int = (v: number): number => {\n const r = Math.round(v)\n return r === 0 ? 0 : r\n}\n\n/** One axis of a detection, cropped to the frame: the visible part of\n * `[p, p+s]` within `[0, 1]`, or undefined when none of it is visible. An\n * in-frame axis is returned untouched (so a second pass cannot drift by a\n * float ulp); an overhanging one becomes the intersection, whichever edge it\n * crosses, so its centre only ever moves toward the visible part. */\nfunction cropAxis(p: number, s: number): readonly [number, number] | undefined {\n if (!(s > 0)) return undefined\n if (p >= 0 && p + s <= 1) return [p, s]\n const lo = clamp01(p)\n const hi = clamp01(p + s)\n return hi > lo ? [lo, hi - lo] : undefined\n}\n\nfunction normalizeBox(raw: unknown): SpeakerTrackBox | undefined {\n if (!isObj(raw)) return undefined\n if (![raw.ms, raw.x, raw.y, raw.w, raw.h].every(isNum)) return undefined\n // A detection is cropped to the frame, never moved: a face at the frame edge\n // keeps only its visible part, and one entirely off-frame is dropped. This is\n // deliberately NOT `normalizeRegion`'s clamp-then-shrink (edl.ts), which is\n // fine for a region a user draws but would shift a left/top overhang and turn\n // an off-frame detection into an in-frame face.\n const xs = cropAxis(raw.x as number, raw.w as number)\n const ys = cropAxis(raw.y as number, raw.h as number)\n if (!xs || !ys) return undefined\n const [x, w] = xs\n const [y, h] = ys\n return { ms: int(raw.ms as number), x, y, w, h, ...(isNum(raw.score) ? { score: clamp01(raw.score) } : {}) }\n}\n\nfunction normalizeSpans(raw: unknown): SpeakerTrackSpan[] {\n if (!Array.isArray(raw)) return []\n const spans = raw\n .filter(isObj)\n .filter((s) => isNum(s.startMs) && isNum(s.endMs))\n .map((s) => ({ startMs: int(s.startMs as number), endMs: int(s.endMs as number) }))\n .filter((s) => s.endMs > s.startMs)\n .sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs)\n const merged: SpeakerTrackSpan[] = []\n for (const s of spans) {\n const last = merged[merged.length - 1]\n if (last && s.startMs <= last.endMs) merged[merged.length - 1] = { startMs: last.startMs, endMs: Math.max(last.endMs, s.endMs) }\n else merged.push(s)\n }\n return merged\n}\n\nfunction normalizeCuts(raw: unknown): number[] {\n if (!Array.isArray(raw)) return []\n const sorted = raw.filter(isNum).map(int).sort((a, b) => a - b)\n return sorted.filter((c, i) => i === 0 || c !== sorted[i - 1])\n}\n\nfunction normalizeAttribution(raw: unknown): SpeakerTrackAttribution | undefined {\n if (!isObj(raw)) return undefined\n const method = str(raw.method)\n if (!method) return undefined\n const rawSpeaker = str(raw.rawSpeaker)\n return { method, confidence: clamp01(num(raw.confidence)), ...(rawSpeaker ? { rawSpeaker } : {}) }\n}\n\nfunction normalizeHeader(raw: Record<string, unknown>, fallbackId: string): SpeakerTrackHeader {\n const speaker = str(raw.speaker)\n const attribution = normalizeAttribution(raw.attribution)\n return {\n id: str(raw.id) || fallbackId,\n ...(speaker ? { speaker } : {}),\n ...(attribution ? { attribution } : {}),\n }\n}\n\nfunction normalizeSetFields(o: Record<string, unknown>): SpeakerTrackSetFields {\n const detector = isObj(o.detector) ? o.detector : {}\n const detectorVersion = str(detector.version)\n return {\n // Only an ABSENT version defaults to 1. Any present value — another\n // number, \"2\", null — is kept as is so validate refuses it rather than\n // reading a newer (or broken) body as this one.\n version: (o.version === undefined ? SPEAKER_TRACKS_VERSION : o.version) as 1,\n sampleFps: num(o.sampleFps),\n detector: { id: str(detector.id) ?? \"\", ...(detectorVersion ? { version: detectorVersion } : {}) },\n }\n}\n\nfunction normalizeSources<T>(\n raw: unknown,\n track: (t: Record<string, unknown>, fallbackId: string) => T,\n): Array<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> {\n if (!Array.isArray(raw)) return []\n return raw.map((r) => {\n const s = isObj(r) ? r : {}\n const sourceId = str(s.sourceId) ?? \"\"\n const frame = isObj(s.frame) ? s.frame : {}\n const cuts = normalizeCuts(s.cuts)\n const tracks = Array.isArray(s.tracks) ? s.tracks.map((t, k) => track(isObj(t) ? t : {}, `${sourceId}/t${k + 1}`)) : []\n return {\n sourceId,\n // A clock other than \"source\" cannot be repaired: boxes on another clock\n // would land offsetMs away from their frame. Keep it for validate to refuse.\n clock: (typeof s.clock === \"string\" ? s.clock : \"source\") as \"source\",\n frame: { w: int(num(frame.w)), h: int(num(frame.h)) },\n sampledSpans: normalizeSpans(s.sampledSpans),\n tracks,\n ...(cuts.length > 0 ? { cuts } : {}),\n }\n })\n}\n\n/**\n * Coerce an unknown value into a well-formed `SpeakerTrackSet` (the box body):\n * drop unknown keys and malformed boxes, crop every box to the frame (an\n * entirely off-frame box is dropped, an overhang keeps its visible part), clamp\n * scores and confidences to 0..1, round every time to integer ms, sort each\n * track's boxes by time (box order IS time, unlike EDL segment order), sort and\n * merge sampled spans, sort and de-duplicate cuts.\n *\n * It never repairs what would change meaning: a box outside every sampled\n * span, two boxes at one instant, a track across a cut, another version or\n * another clock all survive for `validateSpeakerTracks` to report.\n */\nexport function normalizeSpeakerTracks(input: unknown): SpeakerTrackSet {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => {\n const boxes = Array.isArray(t.boxes) ? t.boxes.map(normalizeBox).filter((b): b is SpeakerTrackBox => b !== undefined) : []\n return { ...normalizeHeader(t, fallbackId), boxes: [...boxes].sort((a, b) => a.ms - b.ms) }\n }),\n }\n}\n\n/** Coerce an unknown value into a `SpeakerTrackSetDescriptor`, by the same rules\n * as `normalizeSpeakerTracks`; a missing or broken `boxCount` becomes 0. */\nexport function normalizeSpeakerTrackSetDescriptor(input: unknown): SpeakerTrackSetDescriptor {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => ({\n ...normalizeHeader(t, fallbackId),\n boxCount: Math.max(0, int(num(t.boxCount))),\n })),\n url: str(o.url) ?? \"\",\n sha256: str(o.sha256) ?? \"\",\n bytes: int(num(o.bytes)),\n }\n}\n\n/** The descriptor of a (normalized) set stored at `artifact.url`: every box\n * removed, a `boxCount` per track. Pure; the caller hashes and stores the body. */\nexport function describeSpeakerTracks(\n set: SpeakerTrackSet,\n artifact: { readonly url: string; readonly sha256: string; readonly bytes: number },\n): SpeakerTrackSetDescriptor {\n return {\n version: set.version,\n sampleFps: set.sampleFps,\n detector: { ...set.detector },\n sources: set.sources.map((s) => ({\n sourceId: s.sourceId,\n clock: s.clock,\n frame: { ...s.frame },\n sampledSpans: s.sampledSpans.map((sp) => ({ ...sp })),\n tracks: s.tracks.map((t) => ({\n id: t.id,\n ...(t.speaker !== undefined ? { speaker: t.speaker } : {}),\n ...(t.attribution ? { attribution: { ...t.attribution } } : {}),\n boxCount: t.boxes.length,\n })),\n ...(s.cuts && s.cuts.length > 0 ? { cuts: [...s.cuts] } : {}),\n })),\n url: artifact.url,\n sha256: artifact.sha256,\n bytes: artifact.bytes,\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The edit's speaker space\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The speaker labels an edit uses: the union of `sources[].speakers`,\n * `segments[].speaker` and `segments[].layout.slots[].speaker`, over every EDL\n * given (a clip pack), sorted by code unit. Tracks must be labelled in this\n * space, or no track ever matches a segment's speaker. */\nexport function edlSpeakerSpace(edl: Edl | readonly Edl[]): string[] {\n const out = new Set<string>()\n const add = (v: unknown) => {\n if (typeof v === \"string\" && v) out.add(v)\n }\n for (const e of edlList(edl)) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n for (const sp of Array.isArray(s?.speakers) ? s.speakers : []) add(sp)\n }\n for (const seg of Array.isArray(e.segments) ? e.segments : []) {\n add(seg?.speaker)\n for (const slot of Array.isArray(seg?.layout?.slots) ? seg.layout!.slots! : []) add(slot?.speaker)\n }\n }\n return [...out].sort()\n}\n\nfunction edlList(edl: Edl | readonly Edl[] | undefined): readonly Edl[] {\n if (!edl) return []\n const all: readonly unknown[] = Array.isArray(edl) ? edl : [edl]\n return all.filter((e): e is Edl => isObj(e))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerTracksValidateOptions {\n /** The edit the tracks are for — one EDL, or every clip of a pack. When given,\n * every source must resolve to one of its video sources, and attributed\n * speakers must be in its speaker space (`edlSpeakerSpace`). */\n readonly edl?: Edl | readonly Edl[]\n /** Default `SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE`. */\n readonly maxBoxesPerSource?: number\n /** Default `SPEAKER_TRACKS_MAX_BYTES`. */\n readonly maxBytes?: number\n /** `validateSpeakerTracks` only: the body's known size in bytes (e.g. the\n * fetched length), so a large body is not serialized again to measure it. */\n readonly serializedBytes?: number\n}\n\nconst SHA256_HEX = /^[0-9a-f]{64}$/\n\ntype Findings = { issues: string[]; warnings: string[] }\n\n/** The rules shared by the body and the descriptor. `perTrack` adds the body's\n * box rules and returns the track's box count. */\nfunction validateCommon<T extends SpeakerTrackHeader>(\n set: SpeakerTrackSetFields & { readonly sources: ReadonlyArray<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> },\n opts: SpeakerTracksValidateOptions,\n perTrack: (track: T, source: SpeakerTrackSourceFields, f: Findings) => number,\n): Findings {\n const f: Findings = { issues: [], warnings: [] }\n const { issues, warnings } = f\n const sources = arr(set.sources)\n const maxBoxes = opts.maxBoxesPerSource ?? SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE\n\n if (set.version !== SPEAKER_TRACKS_VERSION) issues.push(`version must be ${SPEAKER_TRACKS_VERSION}`)\n if (!(isNum(set.sampleFps) && set.sampleFps > 0)) issues.push(\"sampleFps must be a finite number > 0\")\n\n const edls = edlList(opts.edl)\n const edlSources = new Map<string, EdlSource>()\n for (const e of edls) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n if (s && typeof s.id === \"string\" && !edlSources.has(s.id)) edlSources.set(s.id, s)\n }\n }\n\n const sourceIds = new Set<string>()\n const trackIds = new Set<string>()\n sources.forEach((s, i) => {\n const sid = s.sourceId\n const at = `source \"${sid}\"`\n if (!sid) issues.push(`source[${i}]: sourceId is empty`)\n else if (sourceIds.has(sid)) issues.push(`duplicate source id \"${sid}\"`)\n sourceIds.add(sid)\n if (sid && edls.length > 0) {\n const es = edlSources.get(sid)\n if (!es) issues.push(`${at}: not a source of the EDL`)\n else if (es.kind !== \"video\") issues.push(`${at}: the EDL source is kind:\"${es.kind}\", tracks need a video source`)\n }\n if (s.clock !== \"source\") issues.push(`${at}: clock must be \"source\"`)\n if (!(isObj(s.frame) && isNum(s.frame.w) && isNum(s.frame.h) && s.frame.w > 0 && s.frame.h > 0)) {\n issues.push(`${at}: frame w/h must be positive`)\n }\n\n const spans = arr<SpeakerTrackSpan>(s.sampledSpans)\n spans.forEach((sp, j) => {\n const startMs: unknown = sp?.startMs\n const endMs: unknown = sp?.endMs\n if (!(isNum(startMs) && isNum(endMs) && endMs > startMs)) {\n issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not positive`)\n return\n }\n if (!(Number.isInteger(startMs) && Number.isInteger(endMs))) issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not integer ms`)\n if (startMs < 0) issues.push(`${at}: sampledSpans[${j}] starts before 0`)\n const prevEnd: unknown = spans[j - 1]?.endMs\n if (j > 0 && isNum(prevEnd) && startMs < prevEnd) {\n issues.push(`${at}: sampledSpans must be sorted and non-overlapping (span ${j})`)\n }\n })\n\n const cuts = s.cuts\n if (cuts !== undefined) {\n const okCuts = Array.isArray(cuts) && cuts.every((c, k) => Number.isInteger(c) && c >= 0 && (k === 0 || c > cuts[k - 1]))\n if (!okCuts) issues.push(`${at}: cuts must be ascending non-negative ms`)\n }\n\n let boxes = 0\n const tracks = arr<T>(s.tracks)\n tracks.forEach((t, k) => {\n if (!t?.id) issues.push(`${at} track[${k}]: id is empty`)\n else if (trackIds.has(t.id)) issues.push(`duplicate track id \"${t.id}\"`)\n if (t?.id) trackIds.add(t.id)\n const a = t?.attribution\n if (a) {\n if (!(isNum(a.confidence) && a.confidence >= 0 && a.confidence <= 1)) {\n issues.push(`track \"${t.id}\": attribution.confidence=${a.confidence} out of 0..1`)\n }\n if (!KNOWN_METHODS.has(a.method)) {\n warnings.push(`track \"${t.id}\": unknown attribution method \"${a.method}\" (known: ${SPEAKER_TRACK_ATTRIBUTION_METHODS.join(\", \")})`)\n }\n }\n boxes += perTrack(t, s, f)\n })\n if (boxes > maxBoxes) issues.push(`${at}: ${boxes} boxes is over the cap of ${maxBoxes}`)\n })\n\n // The speaker name space: labels from the raw transcript against an edit\n // that uses display names (or the reverse) match nothing, and every slot\n // would silently fall back to static framing.\n if (edls.length > 0) {\n const space = edlSpeakerSpace(edls)\n const attributed = sources.flatMap((s) => (Array.isArray(s.tracks) ? s.tracks : [])).filter((t) => !!t?.speaker)\n if (space.length > 0 && attributed.length > 0) {\n const inSpace = new Set(space)\n const matches = (t: T) => inSpace.has(t.speaker!) || (!!t.attribution?.rawSpeaker && inSpace.has(t.attribution.rawSpeaker))\n if (!attributed.some(matches)) {\n const labels = [...new Set(attributed.map((t) => t.speaker!))].sort()\n issues.push(\n `no tracked speaker is in the edit's speaker set: the tracks are labelled ${labels.map((l) => `\"${l}\"`).join(\", \")}` +\n ` and the edit uses ${space.map((l) => `\"${l}\"`).join(\", \")} — wire Speaker Frames to the same transcript as Camera Switch`,\n )\n } else {\n for (const t of attributed) {\n if (!matches(t)) warnings.push(`track \"${t.id}\": speaker \"${t.speaker}\" is not in the edit's speaker set`)\n }\n }\n }\n }\n return f\n}\n\n/** Per-box findings listed per track and rule before the rest are summarized\n * in one line, and the most issues a validation lists before one truncation\n * line. A systematic producer bug (a clock off by `offsetMs`, say) puts EVERY\n * box out of span; the refusal must stay readable wherever it is shown. */\nconst BOX_FINDINGS_PER_RULE = 5\nconst MAX_LISTED_FINDINGS = 100\n\n/** A per-box finding: the rule (what the per-track summary line counts, as\n * \"N more boxes <rule>\") and the message for one box. */\ntype BoxFinding = readonly [rule: string, message: string]\n\nfunction boxIssues(b: SpeakerTrackBox, at: string): BoxFinding[] {\n const out: BoxFinding[] = []\n for (const k of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const v = b?.[k]\n if (!isNum(v) || v < 0 || v > 1) out.push([`with ${k} out of 0..1`, `${at}: ${k}=${v} out of 0..1`])\n }\n if (out.length > 0) return out\n // The same edge tolerance as validateEdl's regions, so the two never disagree.\n if (b.w <= 0 || b.h <= 0) out.push([\"with a non-positive w/h\", `${at}: non-positive w/h`])\n if (b.x + b.w > 1 + 1e-9) out.push([\"extending past the right edge\", `${at}: extends past the right edge (x+w>1)`])\n if (b.y + b.h > 1 + 1e-9) out.push([\"extending past the bottom edge\", `${at}: extends past the bottom edge (y+h>1)`])\n if (b.score !== undefined && !(isNum(b.score) && b.score >= 0 && b.score <= 1)) out.push([\"with a score out of 0..1\", `${at}: score=${b.score} out of 0..1`])\n return out\n}\n\n/** Cap a findings list at `MAX_LISTED_FINDINGS`, ending in one line that counts\n * the rest. Never empties a non-empty list, so `ok` is unchanged. */\nfunction capListed(list: readonly string[], noun: \"issues\" | \"warnings\"): string[] {\n if (list.length <= MAX_LISTED_FINDINGS) return [...list]\n return [...list.slice(0, MAX_LISTED_FINDINGS), `${list.length - MAX_LISTED_FINDINGS} more ${noun} not listed`]\n}\n\n/** Is `ms` inside one of `spans` (sorted, half-open)? Binary search. */\nfunction inSpans(spans: readonly SpeakerTrackSpan[], ms: number): boolean {\n let lo = 0\n let hi = spans.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n const sp = spans[mid]\n if (ms < sp.startMs) hi = mid - 1\n else if (ms >= sp.endMs) lo = mid + 1\n else return true\n }\n return false\n}\n\n/**\n * Structural validation of a track set (the box body). Normalization is\n * `normalizeSpeakerTracks`'s job; this reports what is still wrong after it.\n * Issues are facts intrinsic to the set (or to the set against the EDL);\n * warnings are judgements an older validator must not turn into a refusal\n * (an unknown attribution method, one stray speaker label).\n *\n * Rules: version; a positive sample rate; unique source ids that resolve to\n * the EDL's video sources; the source clock; a positive frame; sorted,\n * non-overlapping, positive, integer-ms spans; ascending integer cuts; unique\n * track ids; every box in-frame, at an integer ms, strictly after the previous\n * one and inside a sampled span; no track across a cut; the speaker name\n * space; the box and byte caps.\n *\n * The listing is bounded: per track, the first few boxes breaking each rule\n * are listed and the rest counted in one line; past a fixed total, one line\n * counts the issues (or warnings) not listed. `ok` counts every finding.\n */\nexport function validateSpeakerTracks(set: SpeakerTrackSet, opts: SpeakerTracksValidateOptions = {}): EdlValidation {\n const safe = isObj(set) ? set : ({} as SpeakerTrackSet)\n const f = validateCommon(safe, opts, (t, source, { issues }) => {\n const boxes = Array.isArray(t?.boxes) ? t.boxes : []\n const spans = Array.isArray(source.sampledSpans) ? source.sampledSpans : []\n let first = Infinity\n let last = -Infinity\n // The first few findings of each rule are listed; the rest are counted.\n const seen = new Map<string, number>()\n const report = ([rule, message]: BoxFinding) => {\n const n = (seen.get(rule) ?? 0) + 1\n seen.set(rule, n)\n if (n <= BOX_FINDINGS_PER_RULE) issues.push(message)\n }\n const outside = `outside every sampled span of source \"${source.sourceId}\"`\n boxes.forEach((b, j) => {\n const at = `track \"${t.id}\" box[${j}]`\n boxIssues(b, at).forEach(report)\n if (!isNum(b?.ms)) {\n report([\"whose ms is not a number\", `${at}: ms is not a number`])\n return\n }\n if (!Number.isInteger(b.ms)) report([\"whose ms is not an integer\", `${at}: ms ${b.ms} is not an integer`])\n const prev = boxes[j - 1]?.ms\n if (j > 0 && isNum(prev) && !(b.ms > prev)) report([\"not after the previous box\", `${at}: ms ${b.ms} is not after the previous box (${prev})`])\n if (!inSpans(spans, b.ms)) report([outside, `${at}: ms ${b.ms} is ${outside}`])\n first = Math.min(first, b.ms)\n last = Math.max(last, b.ms)\n })\n for (const [rule, n] of seen) {\n if (n > BOX_FINDINGS_PER_RULE) issues.push(`track \"${t.id}\": ${n - BOX_FINDINGS_PER_RULE} more boxes ${rule}`)\n }\n const cut = (Array.isArray(source.cuts) ? source.cuts : []).find((c) => first < c && c <= last)\n if (cut !== undefined) issues.push(`track \"${t.id}\": spans the cut at ${cut} ms (boxes ${first}..${last})`)\n return boxes.length\n })\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n const bytes = opts.serializedBytes ?? new TextEncoder().encode(JSON.stringify(safe)).length\n if (bytes > maxBytes) f.issues.push(`the track set is ${bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n\n/**\n * Structural validation of a descriptor (the node's output): the same rules as\n * `validateSpeakerTracks` minus the per-box ones (it has no boxes; `boxCount`\n * feeds the per-source cap), plus a non-empty `url`, a well-formed `sha256`\n * and a positive `bytes` within the byte cap.\n */\nexport function validateSpeakerTrackSetDescriptor(\n d: SpeakerTrackSetDescriptor,\n opts: Omit<SpeakerTracksValidateOptions, \"serializedBytes\"> = {},\n): EdlValidation {\n const safe = isObj(d) ? d : ({} as SpeakerTrackSetDescriptor)\n const f = validateCommon(safe, opts, (t, _source, { issues }) => {\n if (!(Number.isInteger(t?.boxCount) && t.boxCount >= 0)) {\n issues.push(`track \"${t?.id}\": boxCount must be a non-negative integer`)\n return 0\n }\n return t.boxCount\n })\n if (!(typeof safe.url === \"string\" && safe.url.trim())) f.issues.push(\"url is empty\")\n if (!(typeof safe.sha256 === \"string\" && SHA256_HEX.test(safe.sha256))) f.issues.push(\"sha256 must be 64 lowercase hex characters\")\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n if (!(Number.isInteger(safe.bytes) && safe.bytes > 0)) f.issues.push(\"bytes must be a positive integer\")\n else if (safe.bytes > maxBytes) f.issues.push(`the track set is ${safe.bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n","/**\n * speaker-map (podcast use-case nodes, decided 2026-10-12/17) — which camera\n * each speaker is on, worked out from the cameras' own microphones: the\n * structural pieces every caller shares (the canvas engines, MCP, the SDK).\n * HOW the levels are compared is the server's. Pure, no I/O.\n */\nimport type { Edl } from \"./edl.js\"\n\nexport const SPEAKER_MAP_VERSION = 1 as const\n/** Recordings one run reads (cameras, plus the master when it also emits the edit). */\nexport const SPEAKER_MAP_MAX_SOURCES = 6\n/** Candidate cameras a comparison needs. */\nexport const SPEAKER_MAP_MIN_CAMERAS = 2\n/** How far the loudest camera must beat the next for the speaker to get it. */\nexport const SPEAKER_MAP_DEFAULT_MARGIN_DB = 3\n\nexport interface SpeakerMapConfidence {\n /** The camera the speaker got; \"\" = none clear (shown on the wide shot). */\n readonly camera: string\n /** The loudest camera's lead over the next, in dB; null when there was nothing to compare. */\n readonly marginDb: number | null\n}\n\nexport interface SpeakerMapResult {\n readonly version: typeof SPEAKER_MAP_VERSION\n /** Transcript speaker label → camera source id; \"\" = no camera of their own. Feeds Camera Switch's `speakerMap`. */\n readonly speakerMap: Readonly<Record<string, string>>\n readonly confidence: Readonly<Record<string, SpeakerMapConfidence>>\n readonly notes: readonly string[]\n /** The recordings as one edit on the master clock (offsets applied, roles and speakers set, one segment). */\n readonly edl?: Edl\n}\n\nconst parse = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\nconst isConfidence = (v: unknown): boolean =>\n isRecord(v) && typeof v.camera === \"string\" && (v.marginDb === null || (typeof v.marginDb === \"number\" && Number.isFinite(v.marginDb)))\n\n/** A Speaker Map result (an object or its JSON string), or null when it is not\n * one: every map value and confidence camera a string, every margin a finite\n * number or null, every note a string — so a reader can trust each field. */\nexport function speakerMapResultOf(raw: unknown): SpeakerMapResult | null {\n const v = parse(raw)\n if (!isRecord(v) || v.version !== SPEAKER_MAP_VERSION || !isRecord(v.speakerMap) || !isRecord(v.confidence) || !Array.isArray(v.notes)) return null\n if (!Object.values(v.speakerMap).every((c) => typeof c === \"string\")) return null\n if (!Object.values(v.confidence).every(isConfidence)) return null\n if (!v.notes.every((n) => typeof n === \"string\")) return null\n return v as unknown as SpeakerMapResult\n}\n\n/** An ordinal key: a whole number from 1, written plainly (\"1\", \"12\" — never \" 1\", \"01\", \"1.0\", \"1e0\"). */\nconst ORDINAL = /^[1-9]\\d*$/\n\n/**\n * The override keyed by ordinal (\"1\" = the first voice heard) as a map keyed\n * by the transcript's own labels. `labels` is the transcript's speakers in\n * first-heard order — the caller passes `transcriptSpeakerLabels(transcript)`,\n * so this module imports nothing from camera-switch-contract (one import\n * direction: camera-switch-contract → speaker-map-contract, no cycle for the\n * structure ratchet). An ordinal past the transcript's speakers maps nobody,\n * and so do a key that is not a plain ordinal and an override that is not an\n * object (a hand-written workflow).\n */\nexport function speakerMapByOrdinal(labels: readonly string[], byOrder: Readonly<Record<string, string>> | undefined): Record<string, string> {\n if (!isRecord(byOrder)) return {}\n const out: Record<string, string> = {}\n for (const [ordinal, camera] of Object.entries(byOrder)) {\n if (!ORDINAL.test(ordinal)) continue\n const label = labels[Number(ordinal) - 1]\n if (label !== undefined && typeof camera === \"string\") out[label] = camera\n }\n return out\n}\n","/**\n * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every\n * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on\n * screen is decided by the Cloud plugin; these only read the inputs it needs\n * and pre-fill the speaker table. Pure, no I/O.\n */\nimport { normalizeTranscript } from \"./edl.js\"\nimport { speakerMapByOrdinal, speakerMapResultOf } from \"./speaker-map-contract.js\"\n\n/** The settings and their decided defaults (the plugin holds its own copy, D13). */\nexport const CAMERA_SWITCH_DEFAULTS = Object.freeze({\n /** The shortest shot; a shorter turn (an interjection) holds the shot. */\n minShotMs: 2_500,\n /** Cut this long before the new speaker starts. */\n leadMs: 200,\n /** Delay each cut by this long — `leadMs`'s counterpart. A route setting\n * only: no node carries it (`CAMERA_SWITCH_NODE_SETTINGS`). */\n lagMs: 0,\n /** With a `wide` camera: break to it after this long on one camera. */\n maxShotMs: 20_000,\n /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */\n wideEvery: 0,\n /** Overlapping speech → a side-by-side / stacked layout hint. */\n layoutHints: false,\n})\n\n/** The flat credit id and price (decided 2026-10-03). */\nexport const CAMERA_SWITCH_CREDIT_ID = \"camera-switch\"\n\nconst parseMaybe = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\n\n/** Distinct speaker labels of a transcript (an object or its JSON string), in\n * order of first appearance in time. Read through `normalizeTranscript`\n * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no\n * usable time) names no speaker here either; a zero-width word is a point\n * and does. Empty → camera-switch refuses before charging. */\nexport function transcriptSpeakerLabels(transcript: unknown): string[] {\n const parsed = parseMaybe(transcript)\n if (!parsed || typeof parsed !== \"object\") return []\n const seen = new Set<string>()\n for (const w of normalizeTranscript(parsed).words) {\n if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)\n }\n return [...seen]\n}\n\n/** The cameras a speaker can be given: an EDL's video sources in order,\n * without the `wide` / `screen` angles (those are not anyone's close-up). */\nexport function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {\n const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources\n if (!Array.isArray(sources)) return []\n return sources\n .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === \"string\")\n .filter((s) => s.kind !== \"audio\" && s.role !== \"wide\" && s.role !== \"screen\" && s.role !== \"master-audio\")\n .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))\n}\n\n/** The settings' accepted ranges — exactly the Cloud route's (it answers 400\n * outside them), so every caller clamps to the same numbers before sending. */\nexport const CAMERA_SWITCH_BOUNDS = Object.freeze({\n minShotMs: Object.freeze({ min: 500, max: 60_000 }),\n leadMs: Object.freeze({ min: 0, max: 5_000 }),\n lagMs: Object.freeze({ min: 0, max: 5_000 }),\n maxShotMs: Object.freeze({ min: 0, max: 600_000 }),\n wideEvery: Object.freeze({ min: 0, max: 20 }),\n})\n\n/** The longest display name a speaker can be given. */\nexport const CAMERA_SWITCH_NAME_MAX = 80\n\nexport type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS\n\n/**\n * The numeric settings a Camera Switch NODE carries (its data, which the\n * canvas and the server's executor send through `cameraSwitchSettingsPayload`).\n * `lagMs` is a setting of the route alone — the API, the SDK and the CLI send\n * it; no node does — so it is not one of them.\n */\nexport const CAMERA_SWITCH_NODE_SETTINGS = Object.freeze([\"minShotMs\", \"leadMs\", \"maxShotMs\", \"wideEvery\"] as const satisfies readonly CameraSwitchNumericSetting[])\n\n/** A setting as a whole number inside its range; undefined when unset. */\nexport function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const { min, max } = CAMERA_SWITCH_BOUNDS[key]\n return Math.min(max, Math.max(min, Math.round(value)))\n}\n\n/** Display names trimmed, empty ones dropped, each cut to\n * `CAMERA_SWITCH_NAME_MAX` characters. */\nexport function cleanSpeakerNames(raw: unknown): Record<string, string> {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {\n const trimmed = typeof name === \"string\" ? name.trim() : \"\"\n if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)\n }\n return out\n}\n\n/** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),\n * or null. One edit (an object or its JSON string) on the master clock, with\n * sources and at least one segment of numeric inMs < outMs; a clip SET is\n * refused — on the canvas each clip fans out to its own run. */\nexport function cameraSwitchEdlProblem(edl: unknown): string | null {\n const v = parseMaybe(edl) as Record<string, unknown> | null | undefined\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return \"camera-switch: `edl` must be one edit (an EDL object).\"\n if (Array.isArray(v.clips)) return \"camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas).\"\n if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return \"camera-switch: `edl` needs `sources` and `segments`.\"\n if (v.segments.length === 0) return \"camera-switch: `edl` has no segments.\"\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n for (const [i, row] of (v.segments as unknown[]).entries()) {\n const seg = row as { inMs?: unknown; outMs?: unknown } | null\n const inMs = num(seg?.inMs), outMs = num(seg?.outMs)\n if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`\n }\n if (v.clock === \"output\") return \"camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's.\"\n return null\n}\n\n/** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →\n * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays\n * unmapped (the wide shows them, else any camera with picture). `existing`\n * entries are kept as the person set them — an explicit `\"\"` means \"no\n * camera of their own\" and is SENT as `\"\"`, so it also beats a source whose\n * `speakers` list names them. */\nexport function defaultSpeakerMap(\n labels: readonly string[],\n cameraIds: readonly string[],\n existing: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n const out: Record<string, string> = {}\n labels.forEach((label, i) => {\n if (Object.prototype.hasOwnProperty.call(existing, label)) {\n const kept = existing[label]\n if (typeof kept === \"string\") out[label] = kept\n return\n }\n if (i < cameraIds.length) out[label] = cameraIds[i]!\n })\n return out\n}\n\n/** What a Camera Switch node sends besides its two inputs — ONE funnel for the\n * canvas executor and the orchestrator, so both send the same clamped\n * settings and the same pre-filled speaker table. */\nexport interface CameraSwitchNodeSettings {\n readonly speakerMap?: Readonly<Record<string, string>>\n /** Who is on which camera by ordinal — \"1\" the first voice heard → a camera\n * SOURCE id, \"\" none; what a use-case node's override writes (decided\n * 2026-10-17). A label in `speakerMap` beats it. */\n readonly speakerMapByOrder?: Readonly<Record<string, string>>\n readonly speakerNames?: Readonly<Record<string, string>>\n readonly minShotMs?: number\n readonly leadMs?: number\n readonly maxShotMs?: number\n readonly wideEvery?: number\n readonly layoutHints?: boolean\n}\n/**\n * Who is on which camera — the ONE merge of the speaker table's layers\n * (decided 2026-10-17). Per speaker, the first that names them wins: an\n * explicit label in `speakerMap`, the ordinal override `speakerMapByOrder`, a\n * wired Speaker Map result, then the order default (`defaultSpeakerMap`).\n * Each layer above the default is passed as `existing`, so its \"\" (no camera\n * of their own) is SENT as \"\" and is never re-filled by the order default; an\n * explicit entry that is not a string is ignored, so it never hides a layer\n * below it. `cameraSwitchSettingsPayload` sends this; the config panel's\n * \"What the run will use\" shows this — never a second copy of the order.\n */\nexport function cameraSwitchSpeakerMap(\n data: Pick<CameraSwitchNodeSettings, \"speakerMap\" | \"speakerMapByOrder\">,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): Record<string, string> {\n const labels = transcriptSpeakerLabels(transcript)\n const explicit = data.speakerMap && typeof data.speakerMap === \"object\" && !Array.isArray(data.speakerMap)\n ? Object.fromEntries(Object.entries(data.speakerMap).filter(([, camera]) => typeof camera === \"string\"))\n : {}\n const existing = {\n ...(speakerMapResultOf(wired?.speakerMap)?.speakerMap ?? {}),\n ...speakerMapByOrdinal(labels, data.speakerMapByOrder),\n ...explicit,\n }\n return defaultSpeakerMap(labels, cameraSwitchCameras(edl).map((c) => c.id), existing)\n}\n\nexport function cameraSwitchSettingsPayload(\n data: CameraSwitchNodeSettings,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): {\n speakerMap: Record<string, string>\n speakerNames: Record<string, string>\n minShotMs?: number\n leadMs?: number\n maxShotMs?: number\n wideEvery?: number\n layoutHints: boolean\n} {\n const out: ReturnType<typeof cameraSwitchSettingsPayload> = {\n speakerMap: cameraSwitchSpeakerMap(data, edl, transcript, wired),\n speakerNames: cleanSpeakerNames(data.speakerNames),\n layoutHints: data.layoutHints === true,\n }\n for (const key of CAMERA_SWITCH_NODE_SETTINGS) {\n const v = clampCameraSwitchSetting(key, data[key])\n if (v !== undefined) out[key] = v\n }\n return out\n}\n","/**\n * The edit-plan node's credit-id scheme and output unwrap — split out of\n * `edl.ts` (which keeps the EDL shape itself) so that module stays within the\n * file-size cap. Re-exported from the package index, so importers of\n * `@nodaro/shared` are unaffected.\n */\nimport { EDL_VERSION } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// edit-plan credit-id scheme (STRUCTURE only — the per-mode/tier/bucket credit\n// VALUES live app-side in backend/ee/billing/credits.ts + migration 432, since\n// they are probe-set placeholders and the DB row wins at runtime). Lives HERE\n// so BOTH core payload-builder and ee credits.ts read one id builder — core\n// may not import ee (check-ee-imports), the same reason buildVideoAnalysisCreditId\n// is shared. Mirrors the plugin's own (D13-local) pricing.ts scheme.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `trailer` (Track D1): one short teaser EDL built from the strongest moments,\n * priced like `clips` (the per-minute rate plus the clips flat). */\nexport type EditPlanMode = \"tighten\" | \"clips\" | \"chapters\" | \"trailer\"\nexport type EditPlanTier = \"economy\" | \"standard\" | \"premium\"\nexport const EDIT_PLAN_MODES: readonly EditPlanMode[] = [\"tighten\", \"clips\", \"chapters\", \"trailer\"]\nexport const EDIT_PLAN_TIERS: readonly EditPlanTier[] = [\"economy\", \"standard\", \"premium\"]\n/** The coarse duration ladder (MINUTES) a probed source duration rounds UP to;\n * the composite credit id carries the bucket. 4 modes × 3 tiers × 6 buckets =\n * 72 composites (+ the bare `edit-plan`). */\nexport const EDIT_PLAN_BUCKET_MINUTES: readonly number[] = [15, 30, 60, 90, 120, 180]\n/** Hard duration cap (design §7.4). */\nexport const EDIT_PLAN_MAX_MINUTES = 180\n/** `clips` mode: how many clips a plan returns when the caller names no count,\n * and the most it may be asked for. One source for the credit estimate, the\n * orchestrated payload clamp and the request schema. */\nexport const EDIT_PLAN_DEFAULT_CLIP_COUNT = 8\nexport const EDIT_PLAN_MAX_CLIP_COUNT = 50\n\n/** Clamp a requested clip count into `[1, EDIT_PLAN_MAX_CLIP_COUNT]`; `undefined`\n * for anything that is not a positive number (the planner then uses its default). */\nexport function clampEditPlanClipCount(count: unknown): number | undefined {\n if (typeof count !== \"number\" || !Number.isFinite(count) || count <= 0) return undefined\n return Math.min(EDIT_PLAN_MAX_CLIP_COUNT, Math.max(1, Math.floor(count)))\n}\n/** The bare estimator / DB-down fallback id. */\nexport const EDIT_PLAN_BASE_CREDIT_ID = \"edit-plan\"\n\n/** Round a source duration (seconds) UP to the smallest covering ladder bucket\n * (capped at the max), in minutes. `undefined` / non-finite → the ceiling\n * bucket (the safe over-reserve direction). */\nexport function editPlanBucketMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n const mins = Math.max(1, Math.ceil(secs / 60))\n const capped = Math.min(mins, EDIT_PLAN_MAX_MINUTES)\n for (const b of EDIT_PLAN_BUCKET_MINUTES) if (capped <= b) return b\n return EDIT_PLAN_BUCKET_MINUTES[EDIT_PLAN_BUCKET_MINUTES.length - 1]!\n}\n\n/** `edit-plan:<mode>:<tier>:<bucket>m`. `durationSec` undefined → the ceiling\n * bucket. Single source of truth for the composite id shape. */\nexport function buildEditPlanCreditId(mode: EditPlanMode, tier: EditPlanTier, durationSec?: number): string {\n return editPlanMinutesCreditId(mode, tier, editPlanBucketMinutes(durationSec))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Per started minute (decided 2026-10-07). A plugin that declares\n// `supports().editPlanPerMinute` reserves `edit-plan:<mode>:<tier>:<N>m` with\n// N = the started minutes of the source (1..180), priced flat + rate × N from\n// ONE rate row and ONE flat row per mode × tier. The step ids above have the\n// same shape (N = a step), so one parser reads both, and the plugin's money\n// gate (`:(\\d+)m$`) accepts both.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Started minutes of a source (seconds): ceil(sec / 60), at least 1, capped at\n * the maximum. `undefined` / non-finite → the maximum (over-reserve direction). */\nexport function editPlanStartedMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n return Math.min(EDIT_PLAN_MAX_MINUTES, Math.max(1, Math.ceil(secs / 60)))\n}\n\n/** `edit-plan:<mode>:<tier>:<N>m` for N minutes (a started-minute count or a step). */\nexport function editPlanMinutesCreditId(mode: EditPlanMode, tier: EditPlanTier, minutes: number): string {\n return `edit-plan:${mode}:${tier}:${minutes}m`\n}\n\n/** The id a run of this mode/tier on a source of `durationSec` reserves: per\n * started minute when the plugin charges that way (`perMinute`), else the step\n * the length rounds up to. An unknown length → the 180-minute maximum either way. */\nexport function editPlanReserveCreditId(\n mode: EditPlanMode,\n tier: EditPlanTier,\n durationSec: number | undefined,\n perMinute: boolean,\n): string {\n return perMinute\n ? editPlanMinutesCreditId(mode, tier, editPlanStartedMinutes(durationSec))\n : buildEditPlanCreditId(mode, tier, durationSec)\n}\n\n/** The rate row: credits per started source minute for a mode/tier. Never reserved. */\nexport function editPlanRateCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:per-minute`\n}\n\n/** The flat row: credits once per plan for a mode/tier (0 for tighten and chapters). Never reserved. */\nexport function editPlanFlatCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:flat`\n}\n\n/** The mode, tier and minutes of an `edit-plan:<mode>:<tier>:<N>m` id (1 ≤ N ≤\n * the maximum), or `undefined` for anything else (the bare id, a rate or flat\n * row, an unknown mode or tier). */\nexport function parseEditPlanMinutesCreditId(\n id: string,\n): { mode: EditPlanMode; tier: EditPlanTier; minutes: number } | undefined {\n const m = /^edit-plan:([a-z]+):([a-z]+):(\\d+)m$/.exec(id)\n if (!m) return undefined\n const mode = parseEditPlanMode(m[1])\n const tier = (EDIT_PLAN_TIERS as readonly string[]).includes(m[2]!) ? (m[2] as EditPlanTier) : undefined\n const minutes = Number(m[3])\n if (!mode || !tier || !Number.isInteger(minutes) || minutes < 1 || minutes > EDIT_PLAN_MAX_MINUTES) return undefined\n return { mode, tier, minutes }\n}\n\n/** flat + rate × N, rounded up, at least 1 credit — what an\n * `edit-plan:<mode>:<tier>:<N>m` id costs from its two rows (the plugin's formula). */\nexport function editPlanMinutesBaseCredits(flat: number, rate: number, minutes: number): number {\n return Math.max(1, Math.ceil(flat + rate * minutes))\n}\n\n/** Narrow an arbitrary value to a known edit-plan mode, defaulting to \"tighten\".\n * For display and estimates only: anything that DISPATCHES a plan must use\n * {@link parseEditPlanMode} and refuse an unknown mode, or that mode is planned\n * (and charged) as tighten. */\nexport function asEditPlanMode(v: unknown): EditPlanMode {\n return parseEditPlanMode(v) ?? \"tighten\"\n}\n\n/** The strict sibling of {@link asEditPlanMode}: the mode when `v` is exactly a\n * known edit-plan mode, otherwise `undefined` — never a substitute. */\nexport function parseEditPlanMode(v: unknown): EditPlanMode | undefined {\n return typeof v === \"string\" && (EDIT_PLAN_MODES as readonly string[]).includes(v) ? (v as EditPlanMode) : undefined\n}\n\n/** Narrow an arbitrary value to a known edit-plan tier, defaulting to \"standard\". */\nexport function asEditPlanTier(v: unknown): EditPlanTier {\n return v === \"economy\" || v === \"premium\" ? v : \"standard\"\n}\n\n/**\n * Unwrap an `edit-plan` job's `output_data` into the value stored on the node's\n * `data.generatedJson`, which every output extractor then reads. This is the ONE\n * place the modes are normalized (the same rule on both engines and every\n * result-application site, so audit-dag parity can't drift):\n * - `clips` → the BARE `Edl[]` (T5: the `list` fan-out reads `Array.isArray`\n * on `generatedJson`; each element becomes one JSON-stringified\n * item a downstream `edl` input `normalizeEdl`-parses).\n * - `chapters` → the `{ version, chapters }` object.\n * - `tighten` / `trailer` → the `Edl` object at top level.\n *\n * The cloud relay object-spreads `output_data` and adds `viaNodaroCloud: true`;\n * that key (and any other bookkeeping) is stripped here. The unwrap lives HERE —\n * NEVER in `output_data` — because a bare array written into `output_data` would\n * be corrupted into numeric keys by the relay's object-spread (see `EdlClipSet`).\n */\nexport function unwrapEditPlanOutput(outputData: unknown): unknown {\n if (!outputData || typeof outputData !== \"object\") return outputData\n const o = outputData as Record<string, unknown>\n // clips: EdlClipSet { version, clips: Edl[] } → the bare Edl[].\n if (Array.isArray(o.clips)) return o.clips\n // chapters: { version, chapters: [...] } → the object, minus bookkeeping.\n if (Array.isArray(o.chapters)) return { version: EDL_VERSION, chapters: o.chapters }\n // tighten / trailer: the Edl object at top level → drop the relay's viaNodaroCloud.\n const { viaNodaroCloud: _viaNodaroCloud, ...rest } = o\n return rest\n}\n"]}
1
+ {"version":3,"sources":["../src/audio-crossfade-curves.ts","../src/smart-cut-windows.ts","../src/speaker-tracks.ts","../src/speaker-map-contract.ts","../src/camera-switch-contract.ts","../src/edit-plan-contract.ts"],"names":["normalizeTranscript","num","EDL_VERSION"],"mappings":";;;;;AAkBO,IAAM,sBAAA,GAAyD;AAAA,EACpE;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,QAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,4BACX,sBAAA,CAAuB,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE;AAEjC,IAAM,gCAAA,GAAmC;AAEhD,IAAM,eAAyD,IAAI,GAAA;AAAA,EACjE,sBAAA,CAAuB,IAAI,C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KAAM,QAAA,IAAa,gBAAsC,QAAA,CAAS,CAAC,IAAK,CAAA,GAAqB,MAAA;AAC7G;AAGO,SAAS,eAAe,CAAA,EAA0B;AACvD,EAAA,OAAO,CAAA,KAAM,SAAA,IAAa,CAAA,KAAM,SAAA,GAAY,CAAA,GAAI,UAAA;AAClD;AAkBO,SAAS,qBAAqB,UAAA,EAA8B;AACjE,EAAA,IAAI,CAAC,UAAA,IAAc,OAAO,UAAA,KAAe,UAAU,OAAO,UAAA;AAC1D,EAAA,MAAM,CAAA,GAAI,UAAA;AAEV,EAAA,IAAI,MAAM,OAAA,CAAQ,CAAA,CAAE,KAAK,CAAA,SAAU,CAAA,CAAE,KAAA;AAErC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAA,CAAE,QAAQ,CAAA,EAAG,OAAO,EAAE,OAAA,EAASC,6BAAA,EAAa,QAAA,EAAU,CAAA,CAAE,QAAA,EAAS;AAEnF,EAAA,MAAM,EAAE,cAAA,EAAgB,eAAA,EAAiB,GAAG,MAAK,GAAI,CAAA;AACrD,EAAA,OAAO,IAAA;AACT","file":"chunk-DRPHRE4J.cjs","sourcesContent":["/**\n * Curated subset of FFmpeg `acrossfade=curve=...` options for combine-videos\n * audio crossfades. We expose 5 well-understood presets out of the ~21 raw\n * curves FFmpeg supports; the rest are either visually indistinguishable to\n * non-audio-engineers or rarely useful in this context.\n *\n * Default `linear` matches today's behavior — adding this catalog is a pure\n * additive change for existing workflows.\n */\n\nexport interface AudioCrossfadeCurve {\n readonly id: string\n /** FFmpeg `acrossfade=curve=...` name. */\n readonly ffmpeg: string\n readonly label: string\n readonly description: string\n}\n\nexport const AUDIO_CROSSFADE_CURVES: readonly AudioCrossfadeCurve[] = [\n {\n id: \"linear\",\n ffmpeg: \"tri\",\n label: \"Linear\",\n description: \"Straight-line fade. Default; predictable but can dip in the middle for music.\",\n },\n {\n id: \"equal-power\",\n ffmpeg: \"qsin\",\n label: \"Equal Power\",\n description: \"Quarter-sine. Keeps perceived loudness roughly constant across the crossfade — best for music.\",\n },\n {\n id: \"smooth\",\n ffmpeg: \"hsin\",\n label: \"Smooth (Sine)\",\n description: \"Half-sine. Gentler than equal-power; good for dialogue and ambient.\",\n },\n {\n id: \"logarithmic\",\n ffmpeg: \"log\",\n label: \"Logarithmic\",\n description: \"Compensates for the ear's logarithmic loudness response. Long, slow tails.\",\n },\n {\n id: \"exponential\",\n ffmpeg: \"exp\",\n label: \"Exponential\",\n description: \"Sharp out / slow in (or vice versa). Punchy — good for impact moments.\",\n },\n]\n\nexport const AUDIO_CROSSFADE_CURVE_IDS: readonly string[] =\n AUDIO_CROSSFADE_CURVES.map((c) => c.id)\n\nexport const DEFAULT_AUDIO_CROSSFADE_CURVE_ID = \"linear\"\n\nconst CURVES_BY_ID: ReadonlyMap<string, AudioCrossfadeCurve> = new Map(\n AUDIO_CROSSFADE_CURVES.map((c) => [c.id, c]),\n)\n\nexport function getAudioCrossfadeCurve(id: string): AudioCrossfadeCurve | undefined {\n return CURVES_BY_ID.get(id)\n}\n\n/**\n * Resolve a curve id to its FFmpeg `acrossfade=curve=` name. Unknown ids fall\n * back to `tri` (linear) — this matches the route's Zod default so callers\n * downstream of validation never see undefined.\n */\nexport function resolveAudioCrossfadeCurve(id: string | undefined): string {\n if (!id) return \"tri\"\n return CURVES_BY_ID.get(id)?.ffmpeg ?? \"tri\"\n}\n","/**\n * Smart-cut SEARCH WINDOWS — the shared bound + clamp for the\n * `smartCutFramesPrev` / `smartCutFramesNext` of BOTH smart-cut nodes:\n * generate-video-pro (segment boundaries) and combine-videos (clip joins).\n *\n * They bound how much of each side of a boundary the engine considers when\n * it places the cut: N frames from the end of a segment and M from the start\n * of the next. Absent → the engine's own default, byte-identical to the\n * behavior before they were exposed. A boundary the engine cannot resolve\n * inside the window falls back to the fixed freeze-trims; recast pins 24/24.\n *\n * Why a shared clamp: the config panel, the canvas node (single-node Run) and\n * the orchestrator (workflow Run) are three independent writers/send paths into\n * the same route, whose Zod schema REJECTS out-of-range values (its `.min()` /\n * `.max()` are these very constants). Deriving all of them from this one\n * function means a stale, imported or hand-edited node value degrades to a\n * legal request instead of 400-ing an entire run — and the paths cannot drift\n * apart. An `<input type=\"number\" max={…}>` is not a substitute: the browser\n * does not stop a typed or pasted value from reaching React's onChange.\n */\n\n/** Widest window we accept anywhere — the UI's `max`, the clamp's ceiling and\n * `/v1/combine-videos`' own Zod `.max()` (the generate-video-pro engine route\n * itself accepts up to 48). Past this, added frames only cost search time and\n * invite a false match. */\nexport const SMART_CUT_WINDOW_MAX = 24\n/** Narrowest meaningful window — one frame each side. */\nexport const SMART_CUT_WINDOW_MIN = 1\n/** The engine's default when the field is absent. Documented here so the UI\n * can show it as the placeholder without hardcoding a second copy. */\nexport const SMART_CUT_WINDOW_DEFAULT = 8\n\n/**\n * Narrow an arbitrary node value to a legal window, or `undefined` to mean\n * \"let the engine use its default\". Non-numbers, NaN, and non-integers all\n * collapse to `undefined` rather than to a guessed number: a malformed value\n * should fall back to the proven default, not silently pick a different\n * search width than the user asked for.\n */\nexport function clampSmartCutWindow(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const n = Math.round(value)\n if (n < SMART_CUT_WINDOW_MIN) return SMART_CUT_WINDOW_MIN\n if (n > SMART_CUT_WINDOW_MAX) return SMART_CUT_WINDOW_MAX\n return n\n}\n","import type { Edl, EdlSource, EdlValidation } from \"./edl.js\"\n\n/**\n * Speaker tracks — where each speaker's face is, over time, per camera.\n *\n * WHY THIS EXISTS\n * A face-tracking analysis node samples each camera an edit shows, finds the\n * faces, links them into tracks and labels each track with a speaker. Its\n * result feeds the framing rung `resolveEdlSegmentSlots` reserves for a\n * per-segment resolver (D20, edl-multicam.ts). This module is the wire shape\n * of that result plus the pure functions that read it: structural vocabulary\n * only — no detector, no linking or attribution rule, no framing or follow\n * math, no thresholds. That is why it lives in the Apache-licensed\n * `@nodaro/shared` (the public contract: the API response, the SDK type and\n * the MCP output). Every published version is an irrevocable grant, so every\n * later field is optional and additive.\n *\n * TWO SHAPES, ONE PROJECTION\n * - `SpeakerTrackSet` — the full set, boxes included. At a long multi-camera\n * edit it is megabytes of JSON, so it is stored as a JSON artifact (the\n * versioned box body), never inline in a job row or a node's data.\n * - `SpeakerTrackSetDescriptor` — what the node outputs: the same set with\n * every box removed (a `boxCount` per track instead) plus the artifact's\n * `url`, `sha256` and `bytes`. Consumers fetch the body by URL, check the\n * hash, run `normalizeSpeakerTracks` + `validateSpeakerTracks` on it, and\n * can confirm it is the body the descriptor names with\n * `describeSpeakerTracks(body, artifact)` deep-equal to the descriptor.\n *\n * CLOCK (D19)\n * Boxes are per SOURCE and on that source's own clock (`clock: \"source\"`), in\n * integer ms. A consumer maps to the master clock through the EDL source's\n * offset: `masterMs = ms + offsetMs` (`remapMsThroughEdl(edl, ms, sourceId)`).\n * Nothing here applies the offset, and nothing ever rescales a time (no\n * seconds→ms guessing — an implausible value is a validation error).\n *\n * GEOMETRY\n * Box coordinates are fractions 0..1 of `frame`: the display-oriented frame\n * (after rotation, square pixels) the producer sampled.\n *\n * SAMPLING\n * `sampledSpans` say what was looked at. No box for a track outside them means\n * \"not sampled\"; inside them it means \"no face there\". Spans are half-open\n * `[startMs, endMs)`, like EDL segments.\n */\n\nexport const SPEAKER_TRACKS_VERSION = 1 as const\n\n/** How a track got its speaker. Open: a newer producer may add a method, which\n * an older validator reports as a WARNING, never an issue. */\nexport const SPEAKER_TRACK_ATTRIBUTION_METHODS = [\"source-map\", \"region\", \"mouth-motion\", \"manual\"] as const\nexport type SpeakerTrackAttributionMethod = (typeof SPEAKER_TRACK_ATTRIBUTION_METHODS)[number]\nconst KNOWN_METHODS: ReadonlySet<string> = new Set(SPEAKER_TRACK_ATTRIBUTION_METHODS)\n\n/** Default hard cap on boxes per source. The longest edit the platform plans\n * for (180 minutes) sampled at 2 per second is 21,600 samples per source; the\n * cap leaves room for several faces in every sample. Override per call with\n * `maxBoxesPerSource`. */\nexport const SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE = 100_000\n/** Default hard cap on the serialized size of a track set (UTF-8 bytes of its\n * JSON), so no consumer ever loads an unbounded body. Override per call with\n * `maxBytes`. */\nexport const SPEAKER_TRACKS_MAX_BYTES = 64 * 1024 * 1024\n\n/** One detection. `ms` on the source clock; x/y/w/h fractions 0..1 of the frame. */\nexport interface SpeakerTrackBox {\n readonly ms: number\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n /** Detector confidence 0..1, when the detector reports one. */\n readonly score?: number\n}\n\nexport interface SpeakerTrackAttribution {\n /** Known: `SPEAKER_TRACK_ATTRIBUTION_METHODS`. */\n readonly method: SpeakerTrackAttributionMethod | (string & {})\n /** 0..1. */\n readonly confidence: number\n /** The transcript's own label for this speaker, kept beside the display name\n * in `speaker` so a later rename re-maps instead of orphaning the track. */\n readonly rawSpeaker?: string\n}\n\n/** What a track says about itself, without its boxes. */\nexport interface SpeakerTrackHeader {\n /** Unique in the whole set, e.g. \"wide/t3\". */\n readonly id: string\n /** A label in the edit's speaker space. Absent = unattributed. */\n readonly speaker?: string\n readonly attribution?: SpeakerTrackAttribution\n}\n\nexport interface SpeakerTrack extends SpeakerTrackHeader {\n /** Strictly increasing `ms`, each inside one of the source's `sampledSpans`. */\n readonly boxes: readonly SpeakerTrackBox[]\n}\n\nexport interface SpeakerTrackSummary extends SpeakerTrackHeader {\n readonly boxCount: number\n}\n\nexport interface SpeakerTrackSpan {\n readonly startMs: number\n /** Exclusive, > startMs. */\n readonly endMs: number\n}\n\ninterface SpeakerTrackSourceFields {\n /** `EdlSource.id` of a video source. */\n readonly sourceId: string\n /** Boxes, spans and cuts are ms on this SOURCE's own clock (D19). */\n readonly clock: \"source\"\n /** The display-oriented frame (after rotation, square pixels), in pixels, that box fractions refer to. */\n readonly frame: { readonly w: number; readonly h: number }\n /** What was sampled: sorted, non-overlapping, half-open. */\n readonly sampledSpans: readonly SpeakerTrackSpan[]\n /** Source-clock ms of detected scene changes, ascending. No track spans one. */\n readonly cuts?: readonly number[]\n}\n\nexport interface SpeakerTrackSource extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrack[]\n}\n\nexport interface SpeakerTrackSourceSummary extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrackSummary[]\n}\n\ninterface SpeakerTrackSetFields {\n readonly version: 1\n /** Samples per second the producer looked at. */\n readonly sampleFps: number\n /** Informational: which detector produced the boxes, e.g. \"example:face-detector\". */\n readonly detector: { readonly id: string; readonly version?: string }\n}\n\n/** The full set — the versioned box body, stored as a JSON artifact. */\nexport interface SpeakerTrackSet extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSource[]\n}\n\n/** What the analysis node outputs: the set without its boxes, plus where the body is. */\nexport interface SpeakerTrackSetDescriptor extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSourceSummary[]\n /** Where the `SpeakerTrackSet` body is stored. */\n readonly url: string\n /** SHA-256 of the stored body's bytes, 64 lowercase hex characters. */\n readonly sha256: string\n /** Size of the stored body in bytes. */\n readonly bytes: number\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject — and never reinterpret)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\nconst isNum = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\nconst num = (v: unknown, fallback = 0): number => (isNum(v) ? v : fallback)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v))\n/** A readonly array field of a value that may have skipped normalization. */\nconst arr = <T,>(v: readonly T[] | undefined): readonly T[] => (Array.isArray(v) ? v : [])\n/** Integer ms; never -0 (JSON cannot carry it, so a round trip would differ). */\nconst int = (v: number): number => {\n const r = Math.round(v)\n return r === 0 ? 0 : r\n}\n\n/** One axis of a detection, cropped to the frame: the visible part of\n * `[p, p+s]` within `[0, 1]`, or undefined when none of it is visible. An\n * in-frame axis is returned untouched (so a second pass cannot drift by a\n * float ulp); an overhanging one becomes the intersection, whichever edge it\n * crosses, so its centre only ever moves toward the visible part. */\nfunction cropAxis(p: number, s: number): readonly [number, number] | undefined {\n if (!(s > 0)) return undefined\n if (p >= 0 && p + s <= 1) return [p, s]\n const lo = clamp01(p)\n const hi = clamp01(p + s)\n return hi > lo ? [lo, hi - lo] : undefined\n}\n\nfunction normalizeBox(raw: unknown): SpeakerTrackBox | undefined {\n if (!isObj(raw)) return undefined\n if (![raw.ms, raw.x, raw.y, raw.w, raw.h].every(isNum)) return undefined\n // A detection is cropped to the frame, never moved: a face at the frame edge\n // keeps only its visible part, and one entirely off-frame is dropped. This is\n // deliberately NOT `normalizeRegion`'s clamp-then-shrink (edl.ts), which is\n // fine for a region a user draws but would shift a left/top overhang and turn\n // an off-frame detection into an in-frame face.\n const xs = cropAxis(raw.x as number, raw.w as number)\n const ys = cropAxis(raw.y as number, raw.h as number)\n if (!xs || !ys) return undefined\n const [x, w] = xs\n const [y, h] = ys\n return { ms: int(raw.ms as number), x, y, w, h, ...(isNum(raw.score) ? { score: clamp01(raw.score) } : {}) }\n}\n\nfunction normalizeSpans(raw: unknown): SpeakerTrackSpan[] {\n if (!Array.isArray(raw)) return []\n const spans = raw\n .filter(isObj)\n .filter((s) => isNum(s.startMs) && isNum(s.endMs))\n .map((s) => ({ startMs: int(s.startMs as number), endMs: int(s.endMs as number) }))\n .filter((s) => s.endMs > s.startMs)\n .sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs)\n const merged: SpeakerTrackSpan[] = []\n for (const s of spans) {\n const last = merged[merged.length - 1]\n if (last && s.startMs <= last.endMs) merged[merged.length - 1] = { startMs: last.startMs, endMs: Math.max(last.endMs, s.endMs) }\n else merged.push(s)\n }\n return merged\n}\n\nfunction normalizeCuts(raw: unknown): number[] {\n if (!Array.isArray(raw)) return []\n const sorted = raw.filter(isNum).map(int).sort((a, b) => a - b)\n return sorted.filter((c, i) => i === 0 || c !== sorted[i - 1])\n}\n\nfunction normalizeAttribution(raw: unknown): SpeakerTrackAttribution | undefined {\n if (!isObj(raw)) return undefined\n const method = str(raw.method)\n if (!method) return undefined\n const rawSpeaker = str(raw.rawSpeaker)\n return { method, confidence: clamp01(num(raw.confidence)), ...(rawSpeaker ? { rawSpeaker } : {}) }\n}\n\nfunction normalizeHeader(raw: Record<string, unknown>, fallbackId: string): SpeakerTrackHeader {\n const speaker = str(raw.speaker)\n const attribution = normalizeAttribution(raw.attribution)\n return {\n id: str(raw.id) || fallbackId,\n ...(speaker ? { speaker } : {}),\n ...(attribution ? { attribution } : {}),\n }\n}\n\nfunction normalizeSetFields(o: Record<string, unknown>): SpeakerTrackSetFields {\n const detector = isObj(o.detector) ? o.detector : {}\n const detectorVersion = str(detector.version)\n return {\n // Only an ABSENT version defaults to 1. Any present value — another\n // number, \"2\", null — is kept as is so validate refuses it rather than\n // reading a newer (or broken) body as this one.\n version: (o.version === undefined ? SPEAKER_TRACKS_VERSION : o.version) as 1,\n sampleFps: num(o.sampleFps),\n detector: { id: str(detector.id) ?? \"\", ...(detectorVersion ? { version: detectorVersion } : {}) },\n }\n}\n\nfunction normalizeSources<T>(\n raw: unknown,\n track: (t: Record<string, unknown>, fallbackId: string) => T,\n): Array<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> {\n if (!Array.isArray(raw)) return []\n return raw.map((r) => {\n const s = isObj(r) ? r : {}\n const sourceId = str(s.sourceId) ?? \"\"\n const frame = isObj(s.frame) ? s.frame : {}\n const cuts = normalizeCuts(s.cuts)\n const tracks = Array.isArray(s.tracks) ? s.tracks.map((t, k) => track(isObj(t) ? t : {}, `${sourceId}/t${k + 1}`)) : []\n return {\n sourceId,\n // A clock other than \"source\" cannot be repaired: boxes on another clock\n // would land offsetMs away from their frame. Keep it for validate to refuse.\n clock: (typeof s.clock === \"string\" ? s.clock : \"source\") as \"source\",\n frame: { w: int(num(frame.w)), h: int(num(frame.h)) },\n sampledSpans: normalizeSpans(s.sampledSpans),\n tracks,\n ...(cuts.length > 0 ? { cuts } : {}),\n }\n })\n}\n\n/**\n * Coerce an unknown value into a well-formed `SpeakerTrackSet` (the box body):\n * drop unknown keys and malformed boxes, crop every box to the frame (an\n * entirely off-frame box is dropped, an overhang keeps its visible part), clamp\n * scores and confidences to 0..1, round every time to integer ms, sort each\n * track's boxes by time (box order IS time, unlike EDL segment order), sort and\n * merge sampled spans, sort and de-duplicate cuts.\n *\n * It never repairs what would change meaning: a box outside every sampled\n * span, two boxes at one instant, a track across a cut, another version or\n * another clock all survive for `validateSpeakerTracks` to report.\n */\nexport function normalizeSpeakerTracks(input: unknown): SpeakerTrackSet {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => {\n const boxes = Array.isArray(t.boxes) ? t.boxes.map(normalizeBox).filter((b): b is SpeakerTrackBox => b !== undefined) : []\n return { ...normalizeHeader(t, fallbackId), boxes: [...boxes].sort((a, b) => a.ms - b.ms) }\n }),\n }\n}\n\n/** Coerce an unknown value into a `SpeakerTrackSetDescriptor`, by the same rules\n * as `normalizeSpeakerTracks`; a missing or broken `boxCount` becomes 0. */\nexport function normalizeSpeakerTrackSetDescriptor(input: unknown): SpeakerTrackSetDescriptor {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => ({\n ...normalizeHeader(t, fallbackId),\n boxCount: Math.max(0, int(num(t.boxCount))),\n })),\n url: str(o.url) ?? \"\",\n sha256: str(o.sha256) ?? \"\",\n bytes: int(num(o.bytes)),\n }\n}\n\n/** The descriptor of a (normalized) set stored at `artifact.url`: every box\n * removed, a `boxCount` per track. Pure; the caller hashes and stores the body. */\nexport function describeSpeakerTracks(\n set: SpeakerTrackSet,\n artifact: { readonly url: string; readonly sha256: string; readonly bytes: number },\n): SpeakerTrackSetDescriptor {\n return {\n version: set.version,\n sampleFps: set.sampleFps,\n detector: { ...set.detector },\n sources: set.sources.map((s) => ({\n sourceId: s.sourceId,\n clock: s.clock,\n frame: { ...s.frame },\n sampledSpans: s.sampledSpans.map((sp) => ({ ...sp })),\n tracks: s.tracks.map((t) => ({\n id: t.id,\n ...(t.speaker !== undefined ? { speaker: t.speaker } : {}),\n ...(t.attribution ? { attribution: { ...t.attribution } } : {}),\n boxCount: t.boxes.length,\n })),\n ...(s.cuts && s.cuts.length > 0 ? { cuts: [...s.cuts] } : {}),\n })),\n url: artifact.url,\n sha256: artifact.sha256,\n bytes: artifact.bytes,\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The edit's speaker space\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The speaker labels an edit uses: the union of `sources[].speakers`,\n * `segments[].speaker` and `segments[].layout.slots[].speaker`, over every EDL\n * given (a clip pack), sorted by code unit. Tracks must be labelled in this\n * space, or no track ever matches a segment's speaker. */\nexport function edlSpeakerSpace(edl: Edl | readonly Edl[]): string[] {\n const out = new Set<string>()\n const add = (v: unknown) => {\n if (typeof v === \"string\" && v) out.add(v)\n }\n for (const e of edlList(edl)) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n for (const sp of Array.isArray(s?.speakers) ? s.speakers : []) add(sp)\n }\n for (const seg of Array.isArray(e.segments) ? e.segments : []) {\n add(seg?.speaker)\n for (const slot of Array.isArray(seg?.layout?.slots) ? seg.layout!.slots! : []) add(slot?.speaker)\n }\n }\n return [...out].sort()\n}\n\nfunction edlList(edl: Edl | readonly Edl[] | undefined): readonly Edl[] {\n if (!edl) return []\n const all: readonly unknown[] = Array.isArray(edl) ? edl : [edl]\n return all.filter((e): e is Edl => isObj(e))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerTracksValidateOptions {\n /** The edit the tracks are for — one EDL, or every clip of a pack. When given,\n * every source must resolve to one of its video sources, and attributed\n * speakers must be in its speaker space (`edlSpeakerSpace`). */\n readonly edl?: Edl | readonly Edl[]\n /** Default `SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE`. */\n readonly maxBoxesPerSource?: number\n /** Default `SPEAKER_TRACKS_MAX_BYTES`. */\n readonly maxBytes?: number\n /** `validateSpeakerTracks` only: the body's known size in bytes (e.g. the\n * fetched length), so a large body is not serialized again to measure it. */\n readonly serializedBytes?: number\n}\n\nconst SHA256_HEX = /^[0-9a-f]{64}$/\n\ntype Findings = { issues: string[]; warnings: string[] }\n\n/** The rules shared by the body and the descriptor. `perTrack` adds the body's\n * box rules and returns the track's box count. */\nfunction validateCommon<T extends SpeakerTrackHeader>(\n set: SpeakerTrackSetFields & { readonly sources: ReadonlyArray<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> },\n opts: SpeakerTracksValidateOptions,\n perTrack: (track: T, source: SpeakerTrackSourceFields, f: Findings) => number,\n): Findings {\n const f: Findings = { issues: [], warnings: [] }\n const { issues, warnings } = f\n const sources = arr(set.sources)\n const maxBoxes = opts.maxBoxesPerSource ?? SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE\n\n if (set.version !== SPEAKER_TRACKS_VERSION) issues.push(`version must be ${SPEAKER_TRACKS_VERSION}`)\n if (!(isNum(set.sampleFps) && set.sampleFps > 0)) issues.push(\"sampleFps must be a finite number > 0\")\n\n const edls = edlList(opts.edl)\n const edlSources = new Map<string, EdlSource>()\n for (const e of edls) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n if (s && typeof s.id === \"string\" && !edlSources.has(s.id)) edlSources.set(s.id, s)\n }\n }\n\n const sourceIds = new Set<string>()\n const trackIds = new Set<string>()\n sources.forEach((s, i) => {\n const sid = s.sourceId\n const at = `source \"${sid}\"`\n if (!sid) issues.push(`source[${i}]: sourceId is empty`)\n else if (sourceIds.has(sid)) issues.push(`duplicate source id \"${sid}\"`)\n sourceIds.add(sid)\n if (sid && edls.length > 0) {\n const es = edlSources.get(sid)\n if (!es) issues.push(`${at}: not a source of the EDL`)\n else if (es.kind !== \"video\") issues.push(`${at}: the EDL source is kind:\"${es.kind}\", tracks need a video source`)\n }\n if (s.clock !== \"source\") issues.push(`${at}: clock must be \"source\"`)\n if (!(isObj(s.frame) && isNum(s.frame.w) && isNum(s.frame.h) && s.frame.w > 0 && s.frame.h > 0)) {\n issues.push(`${at}: frame w/h must be positive`)\n }\n\n const spans = arr<SpeakerTrackSpan>(s.sampledSpans)\n spans.forEach((sp, j) => {\n const startMs: unknown = sp?.startMs\n const endMs: unknown = sp?.endMs\n if (!(isNum(startMs) && isNum(endMs) && endMs > startMs)) {\n issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not positive`)\n return\n }\n if (!(Number.isInteger(startMs) && Number.isInteger(endMs))) issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not integer ms`)\n if (startMs < 0) issues.push(`${at}: sampledSpans[${j}] starts before 0`)\n const prevEnd: unknown = spans[j - 1]?.endMs\n if (j > 0 && isNum(prevEnd) && startMs < prevEnd) {\n issues.push(`${at}: sampledSpans must be sorted and non-overlapping (span ${j})`)\n }\n })\n\n const cuts = s.cuts\n if (cuts !== undefined) {\n const okCuts = Array.isArray(cuts) && cuts.every((c, k) => Number.isInteger(c) && c >= 0 && (k === 0 || c > cuts[k - 1]))\n if (!okCuts) issues.push(`${at}: cuts must be ascending non-negative ms`)\n }\n\n let boxes = 0\n const tracks = arr<T>(s.tracks)\n tracks.forEach((t, k) => {\n if (!t?.id) issues.push(`${at} track[${k}]: id is empty`)\n else if (trackIds.has(t.id)) issues.push(`duplicate track id \"${t.id}\"`)\n if (t?.id) trackIds.add(t.id)\n const a = t?.attribution\n if (a) {\n if (!(isNum(a.confidence) && a.confidence >= 0 && a.confidence <= 1)) {\n issues.push(`track \"${t.id}\": attribution.confidence=${a.confidence} out of 0..1`)\n }\n if (!KNOWN_METHODS.has(a.method)) {\n warnings.push(`track \"${t.id}\": unknown attribution method \"${a.method}\" (known: ${SPEAKER_TRACK_ATTRIBUTION_METHODS.join(\", \")})`)\n }\n }\n boxes += perTrack(t, s, f)\n })\n if (boxes > maxBoxes) issues.push(`${at}: ${boxes} boxes is over the cap of ${maxBoxes}`)\n })\n\n // The speaker name space: labels from the raw transcript against an edit\n // that uses display names (or the reverse) match nothing, and every slot\n // would silently fall back to static framing.\n if (edls.length > 0) {\n const space = edlSpeakerSpace(edls)\n const attributed = sources.flatMap((s) => (Array.isArray(s.tracks) ? s.tracks : [])).filter((t) => !!t?.speaker)\n if (space.length > 0 && attributed.length > 0) {\n const inSpace = new Set(space)\n const matches = (t: T) => inSpace.has(t.speaker!) || (!!t.attribution?.rawSpeaker && inSpace.has(t.attribution.rawSpeaker))\n if (!attributed.some(matches)) {\n const labels = [...new Set(attributed.map((t) => t.speaker!))].sort()\n issues.push(\n `no tracked speaker is in the edit's speaker set: the tracks are labelled ${labels.map((l) => `\"${l}\"`).join(\", \")}` +\n ` and the edit uses ${space.map((l) => `\"${l}\"`).join(\", \")} — wire Speaker Frames to the same transcript as Camera Switch`,\n )\n } else {\n for (const t of attributed) {\n if (!matches(t)) warnings.push(`track \"${t.id}\": speaker \"${t.speaker}\" is not in the edit's speaker set`)\n }\n }\n }\n }\n return f\n}\n\n/** Per-box findings listed per track and rule before the rest are summarized\n * in one line, and the most issues a validation lists before one truncation\n * line. A systematic producer bug (a clock off by `offsetMs`, say) puts EVERY\n * box out of span; the refusal must stay readable wherever it is shown. */\nconst BOX_FINDINGS_PER_RULE = 5\nconst MAX_LISTED_FINDINGS = 100\n\n/** A per-box finding: the rule (what the per-track summary line counts, as\n * \"N more boxes <rule>\") and the message for one box. */\ntype BoxFinding = readonly [rule: string, message: string]\n\nfunction boxIssues(b: SpeakerTrackBox, at: string): BoxFinding[] {\n const out: BoxFinding[] = []\n for (const k of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const v = b?.[k]\n if (!isNum(v) || v < 0 || v > 1) out.push([`with ${k} out of 0..1`, `${at}: ${k}=${v} out of 0..1`])\n }\n if (out.length > 0) return out\n // The same edge tolerance as validateEdl's regions, so the two never disagree.\n if (b.w <= 0 || b.h <= 0) out.push([\"with a non-positive w/h\", `${at}: non-positive w/h`])\n if (b.x + b.w > 1 + 1e-9) out.push([\"extending past the right edge\", `${at}: extends past the right edge (x+w>1)`])\n if (b.y + b.h > 1 + 1e-9) out.push([\"extending past the bottom edge\", `${at}: extends past the bottom edge (y+h>1)`])\n if (b.score !== undefined && !(isNum(b.score) && b.score >= 0 && b.score <= 1)) out.push([\"with a score out of 0..1\", `${at}: score=${b.score} out of 0..1`])\n return out\n}\n\n/** Cap a findings list at `MAX_LISTED_FINDINGS`, ending in one line that counts\n * the rest. Never empties a non-empty list, so `ok` is unchanged. */\nfunction capListed(list: readonly string[], noun: \"issues\" | \"warnings\"): string[] {\n if (list.length <= MAX_LISTED_FINDINGS) return [...list]\n return [...list.slice(0, MAX_LISTED_FINDINGS), `${list.length - MAX_LISTED_FINDINGS} more ${noun} not listed`]\n}\n\n/** Is `ms` inside one of `spans` (sorted, half-open)? Binary search. */\nfunction inSpans(spans: readonly SpeakerTrackSpan[], ms: number): boolean {\n let lo = 0\n let hi = spans.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n const sp = spans[mid]\n if (ms < sp.startMs) hi = mid - 1\n else if (ms >= sp.endMs) lo = mid + 1\n else return true\n }\n return false\n}\n\n/**\n * Structural validation of a track set (the box body). Normalization is\n * `normalizeSpeakerTracks`'s job; this reports what is still wrong after it.\n * Issues are facts intrinsic to the set (or to the set against the EDL);\n * warnings are judgements an older validator must not turn into a refusal\n * (an unknown attribution method, one stray speaker label).\n *\n * Rules: version; a positive sample rate; unique source ids that resolve to\n * the EDL's video sources; the source clock; a positive frame; sorted,\n * non-overlapping, positive, integer-ms spans; ascending integer cuts; unique\n * track ids; every box in-frame, at an integer ms, strictly after the previous\n * one and inside a sampled span; no track across a cut; the speaker name\n * space; the box and byte caps.\n *\n * The listing is bounded: per track, the first few boxes breaking each rule\n * are listed and the rest counted in one line; past a fixed total, one line\n * counts the issues (or warnings) not listed. `ok` counts every finding.\n */\nexport function validateSpeakerTracks(set: SpeakerTrackSet, opts: SpeakerTracksValidateOptions = {}): EdlValidation {\n const safe = isObj(set) ? set : ({} as SpeakerTrackSet)\n const f = validateCommon(safe, opts, (t, source, { issues }) => {\n const boxes = Array.isArray(t?.boxes) ? t.boxes : []\n const spans = Array.isArray(source.sampledSpans) ? source.sampledSpans : []\n let first = Infinity\n let last = -Infinity\n // The first few findings of each rule are listed; the rest are counted.\n const seen = new Map<string, number>()\n const report = ([rule, message]: BoxFinding) => {\n const n = (seen.get(rule) ?? 0) + 1\n seen.set(rule, n)\n if (n <= BOX_FINDINGS_PER_RULE) issues.push(message)\n }\n const outside = `outside every sampled span of source \"${source.sourceId}\"`\n boxes.forEach((b, j) => {\n const at = `track \"${t.id}\" box[${j}]`\n boxIssues(b, at).forEach(report)\n if (!isNum(b?.ms)) {\n report([\"whose ms is not a number\", `${at}: ms is not a number`])\n return\n }\n if (!Number.isInteger(b.ms)) report([\"whose ms is not an integer\", `${at}: ms ${b.ms} is not an integer`])\n const prev = boxes[j - 1]?.ms\n if (j > 0 && isNum(prev) && !(b.ms > prev)) report([\"not after the previous box\", `${at}: ms ${b.ms} is not after the previous box (${prev})`])\n if (!inSpans(spans, b.ms)) report([outside, `${at}: ms ${b.ms} is ${outside}`])\n first = Math.min(first, b.ms)\n last = Math.max(last, b.ms)\n })\n for (const [rule, n] of seen) {\n if (n > BOX_FINDINGS_PER_RULE) issues.push(`track \"${t.id}\": ${n - BOX_FINDINGS_PER_RULE} more boxes ${rule}`)\n }\n const cut = (Array.isArray(source.cuts) ? source.cuts : []).find((c) => first < c && c <= last)\n if (cut !== undefined) issues.push(`track \"${t.id}\": spans the cut at ${cut} ms (boxes ${first}..${last})`)\n return boxes.length\n })\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n const bytes = opts.serializedBytes ?? new TextEncoder().encode(JSON.stringify(safe)).length\n if (bytes > maxBytes) f.issues.push(`the track set is ${bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n\n/**\n * Structural validation of a descriptor (the node's output): the same rules as\n * `validateSpeakerTracks` minus the per-box ones (it has no boxes; `boxCount`\n * feeds the per-source cap), plus a non-empty `url`, a well-formed `sha256`\n * and a positive `bytes` within the byte cap.\n */\nexport function validateSpeakerTrackSetDescriptor(\n d: SpeakerTrackSetDescriptor,\n opts: Omit<SpeakerTracksValidateOptions, \"serializedBytes\"> = {},\n): EdlValidation {\n const safe = isObj(d) ? d : ({} as SpeakerTrackSetDescriptor)\n const f = validateCommon(safe, opts, (t, _source, { issues }) => {\n if (!(Number.isInteger(t?.boxCount) && t.boxCount >= 0)) {\n issues.push(`track \"${t?.id}\": boxCount must be a non-negative integer`)\n return 0\n }\n return t.boxCount\n })\n if (!(typeof safe.url === \"string\" && safe.url.trim())) f.issues.push(\"url is empty\")\n if (!(typeof safe.sha256 === \"string\" && SHA256_HEX.test(safe.sha256))) f.issues.push(\"sha256 must be 64 lowercase hex characters\")\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n if (!(Number.isInteger(safe.bytes) && safe.bytes > 0)) f.issues.push(\"bytes must be a positive integer\")\n else if (safe.bytes > maxBytes) f.issues.push(`the track set is ${safe.bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n","/**\n * speaker-map (podcast use-case nodes, decided 2026-10-12/17) — which camera\n * each speaker is on, worked out from the cameras' own microphones: the\n * structural pieces every caller shares (the canvas engines, MCP, the SDK).\n * HOW the levels are compared is the server's. Pure, no I/O.\n */\nimport type { Edl } from \"./edl.js\"\n\nexport const SPEAKER_MAP_VERSION = 1 as const\n/** Recordings one run reads (cameras, plus the master when it also emits the edit). */\nexport const SPEAKER_MAP_MAX_SOURCES = 6\n/** Candidate cameras a comparison needs. */\nexport const SPEAKER_MAP_MIN_CAMERAS = 2\n/** How far the loudest camera must beat the next for the speaker to get it. */\nexport const SPEAKER_MAP_DEFAULT_MARGIN_DB = 3\n\nexport interface SpeakerMapConfidence {\n /** The camera the speaker got; \"\" = none clear (shown on the wide shot). */\n readonly camera: string\n /** The loudest camera's lead over the next, in dB; null when there was nothing to compare. */\n readonly marginDb: number | null\n}\n\nexport interface SpeakerMapResult {\n readonly version: typeof SPEAKER_MAP_VERSION\n /** Transcript speaker label → camera source id; \"\" = no camera of their own. Feeds Camera Switch's `speakerMap`. */\n readonly speakerMap: Readonly<Record<string, string>>\n readonly confidence: Readonly<Record<string, SpeakerMapConfidence>>\n readonly notes: readonly string[]\n /** The recordings as one edit on the master clock (offsets applied, roles and speakers set, one segment). */\n readonly edl?: Edl\n}\n\nconst parse = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\nconst isConfidence = (v: unknown): boolean =>\n isRecord(v) && typeof v.camera === \"string\" && (v.marginDb === null || (typeof v.marginDb === \"number\" && Number.isFinite(v.marginDb)))\n\n/** A Speaker Map result (an object or its JSON string), or null when it is not\n * one: every map value and confidence camera a string, every margin a finite\n * number or null, every note a string — so a reader can trust each field. */\nexport function speakerMapResultOf(raw: unknown): SpeakerMapResult | null {\n const v = parse(raw)\n if (!isRecord(v) || v.version !== SPEAKER_MAP_VERSION || !isRecord(v.speakerMap) || !isRecord(v.confidence) || !Array.isArray(v.notes)) return null\n if (!Object.values(v.speakerMap).every((c) => typeof c === \"string\")) return null\n if (!Object.values(v.confidence).every(isConfidence)) return null\n if (!v.notes.every((n) => typeof n === \"string\")) return null\n return v as unknown as SpeakerMapResult\n}\n\n/** An ordinal key: a whole number from 1, written plainly (\"1\", \"12\" — never \" 1\", \"01\", \"1.0\", \"1e0\"). */\nconst ORDINAL = /^[1-9]\\d*$/\n\n/**\n * The override keyed by ordinal (\"1\" = the first voice heard) as a map keyed\n * by the transcript's own labels. `labels` is the transcript's speakers in\n * first-heard order — the caller passes `transcriptSpeakerLabels(transcript)`,\n * so this module imports nothing from camera-switch-contract (one import\n * direction: camera-switch-contract → speaker-map-contract, no cycle for the\n * structure ratchet). An ordinal past the transcript's speakers maps nobody,\n * and so do a key that is not a plain ordinal and an override that is not an\n * object (a hand-written workflow).\n */\nexport function speakerMapByOrdinal(labels: readonly string[], byOrder: Readonly<Record<string, string>> | undefined): Record<string, string> {\n if (!isRecord(byOrder)) return {}\n const out: Record<string, string> = {}\n for (const [ordinal, camera] of Object.entries(byOrder)) {\n if (!ORDINAL.test(ordinal)) continue\n const label = labels[Number(ordinal) - 1]\n if (label !== undefined && typeof camera === \"string\") out[label] = camera\n }\n return out\n}\n","/**\n * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every\n * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on\n * screen is decided by the Cloud plugin; these only read the inputs it needs\n * and pre-fill the speaker table. Pure, no I/O.\n */\nimport { normalizeTranscript } from \"./edl.js\"\nimport { speakerMapByOrdinal, speakerMapResultOf } from \"./speaker-map-contract.js\"\n\n/** The settings and their decided defaults (the plugin holds its own copy, D13). */\nexport const CAMERA_SWITCH_DEFAULTS = Object.freeze({\n /** The shortest shot; a shorter turn (an interjection) holds the shot. */\n minShotMs: 2_500,\n /** Cut this long before the new speaker starts. */\n leadMs: 200,\n /** Delay each cut by this long — `leadMs`'s counterpart. A route setting\n * only: no node carries it (`CAMERA_SWITCH_NODE_SETTINGS`). */\n lagMs: 0,\n /** With a `wide` camera: break to it after this long on one camera. */\n maxShotMs: 20_000,\n /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */\n wideEvery: 0,\n /** Overlapping speech → a side-by-side / stacked layout hint. */\n layoutHints: false,\n})\n\n/** The flat credit id and price (decided 2026-10-03). */\nexport const CAMERA_SWITCH_CREDIT_ID = \"camera-switch\"\n\nconst parseMaybe = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\n\n/** Distinct speaker labels of a transcript (an object or its JSON string), in\n * order of first appearance in time. Read through `normalizeTranscript`\n * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no\n * usable time) names no speaker here either; a zero-width word is a point\n * and does. Empty → camera-switch refuses before charging. */\nexport function transcriptSpeakerLabels(transcript: unknown): string[] {\n const parsed = parseMaybe(transcript)\n if (!parsed || typeof parsed !== \"object\") return []\n const seen = new Set<string>()\n for (const w of normalizeTranscript(parsed).words) {\n if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)\n }\n return [...seen]\n}\n\n/** The cameras a speaker can be given: an EDL's video sources in order,\n * without the `wide` / `screen` angles (those are not anyone's close-up). */\nexport function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {\n const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources\n if (!Array.isArray(sources)) return []\n return sources\n .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === \"string\")\n .filter((s) => s.kind !== \"audio\" && s.role !== \"wide\" && s.role !== \"screen\" && s.role !== \"master-audio\")\n .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))\n}\n\n/** The settings' accepted ranges — exactly the Cloud route's (it answers 400\n * outside them), so every caller clamps to the same numbers before sending. */\nexport const CAMERA_SWITCH_BOUNDS = Object.freeze({\n minShotMs: Object.freeze({ min: 500, max: 60_000 }),\n leadMs: Object.freeze({ min: 0, max: 5_000 }),\n lagMs: Object.freeze({ min: 0, max: 5_000 }),\n maxShotMs: Object.freeze({ min: 0, max: 600_000 }),\n wideEvery: Object.freeze({ min: 0, max: 20 }),\n})\n\n/** The longest display name a speaker can be given. */\nexport const CAMERA_SWITCH_NAME_MAX = 80\n\nexport type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS\n\n/**\n * The numeric settings a Camera Switch NODE carries (its data, which the\n * canvas and the server's executor send through `cameraSwitchSettingsPayload`).\n * `lagMs` is a setting of the route alone — the API, the SDK and the CLI send\n * it; no node does — so it is not one of them.\n */\nexport const CAMERA_SWITCH_NODE_SETTINGS = Object.freeze([\"minShotMs\", \"leadMs\", \"maxShotMs\", \"wideEvery\"] as const satisfies readonly CameraSwitchNumericSetting[])\n\n/** A setting as a whole number inside its range; undefined when unset. */\nexport function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const { min, max } = CAMERA_SWITCH_BOUNDS[key]\n return Math.min(max, Math.max(min, Math.round(value)))\n}\n\n/** Display names trimmed, empty ones dropped, each cut to\n * `CAMERA_SWITCH_NAME_MAX` characters. */\nexport function cleanSpeakerNames(raw: unknown): Record<string, string> {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {\n const trimmed = typeof name === \"string\" ? name.trim() : \"\"\n if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)\n }\n return out\n}\n\n/** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),\n * or null. One edit (an object or its JSON string) on the master clock, with\n * sources and at least one segment of numeric inMs < outMs; a clip SET is\n * refused — on the canvas each clip fans out to its own run. */\nexport function cameraSwitchEdlProblem(edl: unknown): string | null {\n const v = parseMaybe(edl) as Record<string, unknown> | null | undefined\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return \"camera-switch: `edl` must be one edit (an EDL object).\"\n if (Array.isArray(v.clips)) return \"camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas).\"\n if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return \"camera-switch: `edl` needs `sources` and `segments`.\"\n if (v.segments.length === 0) return \"camera-switch: `edl` has no segments.\"\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n for (const [i, row] of (v.segments as unknown[]).entries()) {\n const seg = row as { inMs?: unknown; outMs?: unknown } | null\n const inMs = num(seg?.inMs), outMs = num(seg?.outMs)\n if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`\n }\n if (v.clock === \"output\") return \"camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's.\"\n return null\n}\n\n/** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →\n * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays\n * unmapped (the wide shows them, else any camera with picture). `existing`\n * entries are kept as the person set them — an explicit `\"\"` means \"no\n * camera of their own\" and is SENT as `\"\"`, so it also beats a source whose\n * `speakers` list names them. */\nexport function defaultSpeakerMap(\n labels: readonly string[],\n cameraIds: readonly string[],\n existing: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n const out: Record<string, string> = {}\n labels.forEach((label, i) => {\n if (Object.prototype.hasOwnProperty.call(existing, label)) {\n const kept = existing[label]\n if (typeof kept === \"string\") out[label] = kept\n return\n }\n if (i < cameraIds.length) out[label] = cameraIds[i]!\n })\n return out\n}\n\n/** What a Camera Switch node sends besides its two inputs — ONE funnel for the\n * canvas executor and the orchestrator, so both send the same clamped\n * settings and the same pre-filled speaker table. */\nexport interface CameraSwitchNodeSettings {\n readonly speakerMap?: Readonly<Record<string, string>>\n /** Who is on which camera by ordinal — \"1\" the first voice heard → a camera\n * SOURCE id, \"\" none; what a use-case node's override writes (decided\n * 2026-10-17). A label in `speakerMap` beats it. */\n readonly speakerMapByOrder?: Readonly<Record<string, string>>\n readonly speakerNames?: Readonly<Record<string, string>>\n readonly minShotMs?: number\n readonly leadMs?: number\n readonly maxShotMs?: number\n readonly wideEvery?: number\n readonly layoutHints?: boolean\n}\n/**\n * Who is on which camera — the ONE merge of the speaker table's layers\n * (decided 2026-10-17). Per speaker, the first that names them wins: an\n * explicit label in `speakerMap`, the ordinal override `speakerMapByOrder`, a\n * wired Speaker Map result, then the order default (`defaultSpeakerMap`).\n * Each layer above the default is passed as `existing`, so its \"\" (no camera\n * of their own) is SENT as \"\" and is never re-filled by the order default; an\n * explicit entry that is not a string is ignored, so it never hides a layer\n * below it. `cameraSwitchSettingsPayload` sends this; the config panel's\n * \"What the run will use\" shows this — never a second copy of the order.\n */\nexport function cameraSwitchSpeakerMap(\n data: Pick<CameraSwitchNodeSettings, \"speakerMap\" | \"speakerMapByOrder\">,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): Record<string, string> {\n const labels = transcriptSpeakerLabels(transcript)\n const explicit = data.speakerMap && typeof data.speakerMap === \"object\" && !Array.isArray(data.speakerMap)\n ? Object.fromEntries(Object.entries(data.speakerMap).filter(([, camera]) => typeof camera === \"string\"))\n : {}\n const existing = {\n ...(speakerMapResultOf(wired?.speakerMap)?.speakerMap ?? {}),\n ...speakerMapByOrdinal(labels, data.speakerMapByOrder),\n ...explicit,\n }\n return defaultSpeakerMap(labels, cameraSwitchCameras(edl).map((c) => c.id), existing)\n}\n\nexport function cameraSwitchSettingsPayload(\n data: CameraSwitchNodeSettings,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): {\n speakerMap: Record<string, string>\n speakerNames: Record<string, string>\n minShotMs?: number\n leadMs?: number\n maxShotMs?: number\n wideEvery?: number\n layoutHints: boolean\n} {\n const out: ReturnType<typeof cameraSwitchSettingsPayload> = {\n speakerMap: cameraSwitchSpeakerMap(data, edl, transcript, wired),\n speakerNames: cleanSpeakerNames(data.speakerNames),\n layoutHints: data.layoutHints === true,\n }\n for (const key of CAMERA_SWITCH_NODE_SETTINGS) {\n const v = clampCameraSwitchSetting(key, data[key])\n if (v !== undefined) out[key] = v\n }\n return out\n}\n","/**\n * The edit-plan node's credit-id scheme and output unwrap — split out of\n * `edl.ts` (which keeps the EDL shape itself) so that module stays within the\n * file-size cap. Re-exported from the package index, so importers of\n * `@nodaro/shared` are unaffected.\n */\nimport { EDL_VERSION } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// edit-plan credit-id scheme (STRUCTURE only — the per-mode/tier/bucket credit\n// VALUES live app-side in backend/ee/billing/credits.ts + migration 432, since\n// they are probe-set placeholders and the DB row wins at runtime). Lives HERE\n// so BOTH core payload-builder and ee credits.ts read one id builder — core\n// may not import ee (check-ee-imports), the same reason buildVideoAnalysisCreditId\n// is shared. Mirrors the plugin's own (D13-local) pricing.ts scheme.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `trailer` (Track D1): one short teaser EDL built from the strongest moments,\n * priced like `clips` (the per-minute rate plus the clips flat). */\nexport type EditPlanMode = \"tighten\" | \"clips\" | \"chapters\" | \"trailer\"\nexport type EditPlanTier = \"economy\" | \"standard\" | \"premium\"\nexport const EDIT_PLAN_MODES: readonly EditPlanMode[] = [\"tighten\", \"clips\", \"chapters\", \"trailer\"]\nexport const EDIT_PLAN_TIERS: readonly EditPlanTier[] = [\"economy\", \"standard\", \"premium\"]\n/** The coarse duration ladder (MINUTES) a probed source duration rounds UP to;\n * the composite credit id carries the bucket. 4 modes × 3 tiers × 6 buckets =\n * 72 composites (+ the bare `edit-plan`). */\nexport const EDIT_PLAN_BUCKET_MINUTES: readonly number[] = [15, 30, 60, 90, 120, 180]\n/** Hard duration cap (design §7.4). */\nexport const EDIT_PLAN_MAX_MINUTES = 180\n/** `clips` mode: how many clips a plan returns when the caller names no count,\n * and the most it may be asked for. One source for the credit estimate, the\n * orchestrated payload clamp and the request schema. */\nexport const EDIT_PLAN_DEFAULT_CLIP_COUNT = 8\nexport const EDIT_PLAN_MAX_CLIP_COUNT = 50\n\n/** Clamp a requested clip count into `[1, EDIT_PLAN_MAX_CLIP_COUNT]`; `undefined`\n * for anything that is not a positive number (the planner then uses its default). */\nexport function clampEditPlanClipCount(count: unknown): number | undefined {\n if (typeof count !== \"number\" || !Number.isFinite(count) || count <= 0) return undefined\n return Math.min(EDIT_PLAN_MAX_CLIP_COUNT, Math.max(1, Math.floor(count)))\n}\n/** The bare estimator / DB-down fallback id. */\nexport const EDIT_PLAN_BASE_CREDIT_ID = \"edit-plan\"\n\n/** Round a source duration (seconds) UP to the smallest covering ladder bucket\n * (capped at the max), in minutes. `undefined` / non-finite → the ceiling\n * bucket (the safe over-reserve direction). */\nexport function editPlanBucketMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n const mins = Math.max(1, Math.ceil(secs / 60))\n const capped = Math.min(mins, EDIT_PLAN_MAX_MINUTES)\n for (const b of EDIT_PLAN_BUCKET_MINUTES) if (capped <= b) return b\n return EDIT_PLAN_BUCKET_MINUTES[EDIT_PLAN_BUCKET_MINUTES.length - 1]!\n}\n\n/** `edit-plan:<mode>:<tier>:<bucket>m`. `durationSec` undefined → the ceiling\n * bucket. Single source of truth for the composite id shape. */\nexport function buildEditPlanCreditId(mode: EditPlanMode, tier: EditPlanTier, durationSec?: number): string {\n return editPlanMinutesCreditId(mode, tier, editPlanBucketMinutes(durationSec))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Per started minute (decided 2026-10-07). A plugin that declares\n// `supports().editPlanPerMinute` reserves `edit-plan:<mode>:<tier>:<N>m` with\n// N = the started minutes of the source (1..180), priced flat + rate × N from\n// ONE rate row and ONE flat row per mode × tier. The step ids above have the\n// same shape (N = a step), so one parser reads both, and the plugin's money\n// gate (`:(\\d+)m$`) accepts both.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Started minutes of a source (seconds): ceil(sec / 60), at least 1, capped at\n * the maximum. `undefined` / non-finite → the maximum (over-reserve direction). */\nexport function editPlanStartedMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n return Math.min(EDIT_PLAN_MAX_MINUTES, Math.max(1, Math.ceil(secs / 60)))\n}\n\n/** `edit-plan:<mode>:<tier>:<N>m` for N minutes (a started-minute count or a step). */\nexport function editPlanMinutesCreditId(mode: EditPlanMode, tier: EditPlanTier, minutes: number): string {\n return `edit-plan:${mode}:${tier}:${minutes}m`\n}\n\n/** The id a run of this mode/tier on a source of `durationSec` reserves: per\n * started minute when the plugin charges that way (`perMinute`), else the step\n * the length rounds up to. An unknown length → the 180-minute maximum either way. */\nexport function editPlanReserveCreditId(\n mode: EditPlanMode,\n tier: EditPlanTier,\n durationSec: number | undefined,\n perMinute: boolean,\n): string {\n return perMinute\n ? editPlanMinutesCreditId(mode, tier, editPlanStartedMinutes(durationSec))\n : buildEditPlanCreditId(mode, tier, durationSec)\n}\n\n/** The rate row: credits per started source minute for a mode/tier. Never reserved. */\nexport function editPlanRateCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:per-minute`\n}\n\n/** The flat row: credits once per plan for a mode/tier (0 for tighten and chapters). Never reserved. */\nexport function editPlanFlatCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:flat`\n}\n\n/** The mode, tier and minutes of an `edit-plan:<mode>:<tier>:<N>m` id (1 ≤ N ≤\n * the maximum), or `undefined` for anything else (the bare id, a rate or flat\n * row, an unknown mode or tier). */\nexport function parseEditPlanMinutesCreditId(\n id: string,\n): { mode: EditPlanMode; tier: EditPlanTier; minutes: number } | undefined {\n const m = /^edit-plan:([a-z]+):([a-z]+):(\\d+)m$/.exec(id)\n if (!m) return undefined\n const mode = parseEditPlanMode(m[1])\n const tier = (EDIT_PLAN_TIERS as readonly string[]).includes(m[2]!) ? (m[2] as EditPlanTier) : undefined\n const minutes = Number(m[3])\n if (!mode || !tier || !Number.isInteger(minutes) || minutes < 1 || minutes > EDIT_PLAN_MAX_MINUTES) return undefined\n return { mode, tier, minutes }\n}\n\n/** flat + rate × N, rounded up, at least 1 credit — what an\n * `edit-plan:<mode>:<tier>:<N>m` id costs from its two rows (the plugin's formula). */\nexport function editPlanMinutesBaseCredits(flat: number, rate: number, minutes: number): number {\n return Math.max(1, Math.ceil(flat + rate * minutes))\n}\n\n/** Narrow an arbitrary value to a known edit-plan mode, defaulting to \"tighten\".\n * For display and estimates only: anything that DISPATCHES a plan must use\n * {@link parseEditPlanMode} and refuse an unknown mode, or that mode is planned\n * (and charged) as tighten. */\nexport function asEditPlanMode(v: unknown): EditPlanMode {\n return parseEditPlanMode(v) ?? \"tighten\"\n}\n\n/** The strict sibling of {@link asEditPlanMode}: the mode when `v` is exactly a\n * known edit-plan mode, otherwise `undefined` — never a substitute. */\nexport function parseEditPlanMode(v: unknown): EditPlanMode | undefined {\n return typeof v === \"string\" && (EDIT_PLAN_MODES as readonly string[]).includes(v) ? (v as EditPlanMode) : undefined\n}\n\n/** Narrow an arbitrary value to a known edit-plan tier, defaulting to \"standard\". */\nexport function asEditPlanTier(v: unknown): EditPlanTier {\n return v === \"economy\" || v === \"premium\" ? v : \"standard\"\n}\n\n/**\n * Unwrap an `edit-plan` job's `output_data` into the value stored on the node's\n * `data.generatedJson`, which every output extractor then reads. This is the ONE\n * place the modes are normalized (the same rule on both engines and every\n * result-application site, so audit-dag parity can't drift):\n * - `clips` → the BARE `Edl[]` (T5: the `list` fan-out reads `Array.isArray`\n * on `generatedJson`; each element becomes one JSON-stringified\n * item a downstream `edl` input `normalizeEdl`-parses).\n * - `chapters` → the `{ version, chapters }` object.\n * - `tighten` / `trailer` → the `Edl` object at top level.\n *\n * The cloud relay object-spreads `output_data` and adds `viaNodaroCloud: true`;\n * that key (and any other bookkeeping) is stripped here. The unwrap lives HERE —\n * NEVER in `output_data` — because a bare array written into `output_data` would\n * be corrupted into numeric keys by the relay's object-spread (see `EdlClipSet`).\n */\nexport function unwrapEditPlanOutput(outputData: unknown): unknown {\n if (!outputData || typeof outputData !== \"object\") return outputData\n const o = outputData as Record<string, unknown>\n // clips: EdlClipSet { version, clips: Edl[] } → the bare Edl[].\n if (Array.isArray(o.clips)) return o.clips\n // chapters: { version, chapters: [...] } → the object, minus bookkeeping.\n if (Array.isArray(o.chapters)) return { version: EDL_VERSION, chapters: o.chapters }\n // tighten / trailer: the Edl object at top level → drop the relay's viaNodaroCloud.\n const { viaNodaroCloud: _viaNodaroCloud, ...rest } = o\n return rest\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { UGC_PRIMARY_HANDLE } from './chunk-52JNQG4K.js';
1
+ import { UGC_PRIMARY_HANDLE } from './chunk-D7DCDIMU.js';
2
2
  import { composeUnitSet, unitProducers, composeUnitRecord, unitFanOutEach, unitListPips } from './chunk-S6DXSQCV.js';
3
- import { isSeedance2Provider, isMinimaxH3Provider, isWan3Provider, isKling4RunnerProvider, isViduQ4Provider, isGeminiOmniPerSecondProvider, isPixverseV6MaxProvider, PRICING_DEFAULT_RESOLUTION, isGeminiOmniProvider } from './chunk-O53P2D4V.js';
4
- import { MODEL_CATALOG } from './chunk-R22UHRR6.js';
3
+ import { isSeedance2Provider, isMinimaxH3Provider, isWan3Provider, isKling4RunnerProvider, isViduQ4Provider, isGeminiOmniPerSecondProvider, isPixverseV6MaxProvider, PRICING_DEFAULT_RESOLUTION, isGeminiOmniProvider } from './chunk-SXDLBXSB.js';
4
+ import { MODEL_CATALOG } from './chunk-X7UDZGXW.js';
5
5
 
6
6
  // src/producer-types.ts
7
7
  var VIDEO_PRODUCER_TYPES = composeUnitSet("VIDEO_PRODUCER_TYPES", [
@@ -51,6 +51,8 @@ var VIDEO_PRODUCER_TYPES = composeUnitSet("VIDEO_PRODUCER_TYPES", [
51
51
  "video-sfx",
52
52
  "suno-music-video",
53
53
  "merge-video-audio",
54
+ // Replace Audio (Nodaro Cloud plugin): the video with its sound replaced → video.
55
+ "replace-audio",
54
56
  "add-captions",
55
57
  "resize-video",
56
58
  "social-media-format",
@@ -327,5 +329,5 @@ function uiDurationFill(provider) {
327
329
  }
328
330
 
329
331
  export { AUDIO_PRODUCER_TYPES, DYNAMIC_PRODUCER_TYPES, FAN_IN_TARGETS, FAN_OUT_ALL_OR_NOTHING_TYPES, FAN_OUT_EACH_HANDLES, FAN_OUT_EACH_TYPES, IMAGE_PRODUCER_TYPES, LIST_OUTPUT_HANDLES, OWN_LIST_NODE_TYPES, VIDEO_PRODUCER_TYPES, defaultEdgeOutputMode, isFanInEdge, isFanInNodeType, isListOutputHandle, listResultsServeHandle, ownsItsList, uiAspectRatioFill, uiDurationFill, uiResolutionFill };
330
- //# sourceMappingURL=chunk-PKWRAMVB.js.map
331
- //# sourceMappingURL=chunk-PKWRAMVB.js.map
332
+ //# sourceMappingURL=chunk-EI4V43DI.js.map
333
+ //# sourceMappingURL=chunk-EI4V43DI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/producer-types.ts","../src/video-ui-defaults.ts"],"names":[],"mappings":";;;;;;AA2BO,IAAM,oBAAA,GAA4C,eAAe,sBAAA,EAAwB;AAAA,EAC9F,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,iBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAA;AAAA;AAAA;AAAA,EAGA,cAAA;AAAA,EACA,cAAA;AAAA;AAAA;AAAA;AAAA,EAIA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EAEA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,qBAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,E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,CAAA,IAAK,cAAA,CAAe,QAAQ,CAAA,EAAG,OAAO,UAAA;AAKvG,EAAA,IAAI,sBAAA,CAAuB,QAAQ,CAAA,EAAG,OAAO,MAAA;AAC7C,EAAA,OAAO,MAAA;AACT;AAIO,SAAS,iBAAiB,QAAA,EAAsC;AACrE,EAAA,IAAI,eAAe,QAAQ,CAAA,IAAK,gBAAA,CAAiB,QAAQ,KAAK,sBAAA,CAAuB,QAAQ,CAAA,IAAK,6BAAA,CAA8B,QAAQ,CAAA,IAAK,uBAAA,CAAwB,QAAQ,CAAA,EAAG,OAAO,2BAA2B,QAAQ,CAAA;AAC1N,EAAA,IAAI,mBAAA,CAAoB,QAAQ,CAAA,EAAG,OAAO,cAAc,QAAQ,CAAA,EAAG,cAAc,CAAC,CAAA;AAClF,EAAA,OAAO,MAAA;AACT;AAWO,SAAS,eAAe,QAAA,EAAsC;AACnE,EAAA,IAAI,cAAA,CAAe,QAAQ,CAAA,IAAK,gBAAA,CAAiB,QAAQ,CAAA,IAAK,sBAAA,CAAuB,QAAQ,CAAA,IAAK,uBAAA,CAAwB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC5I,EAAA,IAAI,oBAAA,CAAqB,QAAQ,CAAA,EAAG,OAAO,CAAA;AAC3C,EAAA,OAAO,MAAA;AACT","file":"chunk-EI4V43DI.js","sourcesContent":["/**\n * Producer-type sets — single source of truth for the node types whose\n * primary output is a video URL, audio URL, etc.\n *\n * Consumed by:\n * - backend/src/services/workflow-engine/execution-graph.ts (orchestrator\n * dispatch + asset-type tagging in payload-builder, output-extractor,\n * inline-executor — re-exported there as VIDEO_SOURCE_TYPES /\n * AUDIO_SOURCE_TYPES for backwards compatibility).\n * - frontend/src/lib/generate-video-handles.ts (handle connection\n * validation on the Generate Video node).\n *\n * Lifting these here ensures the frontend handle validator can never reject\n * a connection from a node type that the backend would happily route at\n * execution time (the prior drift bug, see issue 1 of the Task 4.1 review).\n */\nimport { UGC_PRIMARY_HANDLE } from \"./ugc-node-wires.js\"\nimport { composeUnitRecord, composeUnitSet, unitFanOutEach, unitListPips, unitProducers } from \"./unit-contract-compose.js\"\n\n// Each producer set below is its hand-written members ∪ the node units\n// (tools/units/README.md) of that producer kind, from their generated contract\n// rows, in that order — a type in both throws at load (composeUnitSet).\n\n/**\n * Source node types whose primary output is a video URL.\n * Mirrors the backend execution-graph VIDEO_SOURCE_TYPES verbatim.\n */\nexport const VIDEO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"VIDEO_PRODUCER_TYPES\", [\n \"image-to-video\",\n \"video-to-video\",\n \"switchx\", // Beeble SwitchX relight/composite\n \"text-to-video\",\n // Unified video node — emits videoUrl identically to i2v/t2v (its payload-builder\n // case dispatches dynamically to \"image-to-video\" or \"text-to-video\" jobName based\n // on whether a start frame is wired). Without this, getPrimaryOutput would fall\n // through to the imageUrl/videoUrl/audioUrl/text default and downstream consumers\n // could silently misroute the output.\n \"generate-video\",\n // Generate Video Pro — Seedance-2-family multi-segment stitch variant of\n // generate-video (same \"emits videoUrl\" contract; a trimmed provider +\n // handle set). Must mirror generate-video here or its output can't connect\n // downstream (the recurring \"cannot connect the outputs\" bug class).\n \"generate-video-pro\",\n // Edit Video Pro — Seedance-2-family span-replace sibling of generate-\n // video-pro (same \"emits videoUrl\" contract; source video + prompt in,\n // ONE video out). Must mirror generate-video-pro here or its output can't\n // connect downstream (the recurring \"cannot connect the outputs\" bug class).\n \"edit-video-pro\",\n \"upload-video\",\n \"youtube-video\",\n \"combine-videos\",\n \"lip-sync\",\n \"speech-to-video\",\n \"motion-transfer\",\n \"video-upscale\",\n \"video-depth\",\n \"extend-video\",\n // face-swap output is video (writes generatedVideoUrl, per-result `url`).\n // Frontend execution-graph already includes it in VIDEO_SOURCE_TYPES; this\n // entry brings the shared set in line so canvas typed-handle validation\n // doesn't reject face-swap → video-consumer edges that the orchestrator\n // would happily route at runtime.\n \"face-swap\",\n // Speaker View (C3.2): an EDL rendered with its speakers framed — one VIDEO\n // out (no audio-only render). Registered in RENDER_NODE_TYPES as well.\n \"speaker-view\",\n \"video-retake\",\n // video-sfx: adds an SFX track to a video → emits a video URL. Belongs here so\n // canvas handle validation accepts video-sfx → video-consumer edges and the\n // backend routes its output as video (it was previously relying on a fallback).\n \"video-sfx\",\n \"suno-music-video\",\n \"merge-video-audio\",\n // Replace Audio (Nodaro Cloud plugin): the video with its sound replaced → video.\n \"replace-audio\",\n \"add-captions\",\n \"resize-video\",\n \"social-media-format\",\n \"trim-video\",\n \"render-video\",\n \"speed-ramp\",\n \"loop-video\",\n \"fade-video\",\n // Video Mask emits its mask as a video; Mask Composite its composite.\n \"video-mask\",\n \"mask-composite\",\n \"transcode-video\",\n \"manual-edit\",\n // AI Avatar (HeyGen): avatar + voice/audio → video.\n \"ai-avatar\",\n // Cinematic Avatar (HeyGen cinematic_avatar): prompt + 1–3 avatar looks → video.\n \"cinematic-avatar\",\n // Assemble Narrated Video: fits N (clip, voice) blocks into one MP4 → video.\n \"assemble-narrated-video\",\n // Still to Video: one still image + one audio track → MP4 (local FFmpeg,\n // no provider). Emits generatedVideoUrl like every other ffmpeg video node.\n \"still-to-video\",\n // Slideshow: 2-100 stills + one optional audio track → MP4 (local FFmpeg,\n // no provider). Same contract; images arrive via the image-collage lane.\n \"slideshow\",\n // 3D Render Pro: authors a scene AND exports it in one operation, settling\n // with the standard `videoUrl` field. It is a video producer as much as it\n // is a composition producer — omitting it here is the \"cannot connect the\n // outputs\" bug, and its `composition` handle is typed separately.\n \"pro-3d-render\",\n // Video Overlay: timed image layers over a video in one local FFmpeg pass\n // (the base audio copied) — emits a video URL on `video-out`.\n \"video-overlay\",\n // UGC Clip: renders one clip of a UGC video from its ticket — emits a video\n // URL on `video-out` (one per fan-out iteration).\n \"ugc-clip\",\n // UGC Finish: the video's clips, finished, as one ordered list — a registered producer, so a\n // Bundle edge into Combine Videos routes each one as a video, in order.\n \"ugc-finish-clips\",\n], unitProducers(\"video\"))\n\n/**\n * Source node types whose output media-type cannot be classified\n * statically — iterators, dynamic dispatchers, sub-workflow wrappers.\n * The orchestrator decides their actual output type at execution time\n * based on what's wired upstream (loop iterates upstream column type;\n * sub-workflow emits its leaf node's type; adjust-volume passes through\n * video or audio based on its `lastInputType` runtime field;\n * voice-changer emits audio in audio mode, video+audio in video mode).\n *\n * Typed-handle validators (frontend/src/lib/{generate-image,generate-\n * video,ffmpeg}-handles.ts) must include these as acceptors on EVERY\n * media-typed input handle — otherwise the canvas validator hard-\n * rejects edges that the orchestrator would happily route at runtime.\n *\n * Lifted here from `frontend/src/lib/ffmpeg-handles.ts` (where the\n * escape hatch was first added) so the same set drives ALL handle\n * validators uniformly. Adding a new dynamic-output node type means\n * one edit here instead of N across sibling validator files.\n *\n * Intentionally OMITTED:\n * - `webhook-trigger` / `schedule-trigger` — their outputs are\n * user-defined JSON shapes, not media URLs. Accepting them as\n * media producers creates false-positive drops at the canvas\n * that fail at execution. Users wanting trigger → media flows\n * should wire through an upload node.\n */\nexport const DYNAMIC_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"DYNAMIC_PRODUCER_TYPES\", [\n \"list\",\n \"sub-workflow\",\n \"adjust-volume\",\n // Pitch & Tempo: audio in → audio out, video in → video out (picture\n // copied). Dual-mode like adjust-volume; stays in AUDIO_PRODUCER_TYPES as\n // its default.\n \"pitch-tempo\",\n // Dual-mode: audio in → audio out; video in → video out (+ revoiced audio).\n // Listed here so canvas validators accept its output on BOTH audio and video\n // input handles (it also stays in AUDIO_PRODUCER_TYPES as its default).\n \"voice-changer\",\n // voice-changer-pro (renamed from voice-recast in #3581) is a behavioral\n // twin of voice-changer — identical dual-mode output. Must mirror it in\n // EVERY producer set or its outputs can't connect (was the \"cannot connect\n // the outputs of voice-changer-pro\" bug). Guarded by producer-types.test.ts.\n \"voice-changer-pro\",\n // Dubbing joined the dual-mode family with the full-surface upgrade:\n // audio in → dubbed audio; video in (or a video sourceUrl) → dubbed VIDEO\n // (+ audio sidecar). Same wiring contract as voice-changer; stays in\n // AUDIO_PRODUCER_TYPES as its default. Explicitly asserted in\n // producer-types.test.ts (the suite does not fail on omission).\n \"dubbing\",\n \"reduce\",\n // Dual-output time chunker (UI label \"Split into Chunks\"; type id stays\n // \"split-media\"): video in → video chunks, audio in → audio chunks — two\n // independent lanes on two output handles. Like voice-changer, the canvas\n // validator only sees the source NODE type, not which handle a wire leaves,\n // so it lives here to be accepted on BOTH audio and video input handles. The\n // backend routes the correct lane by sourceHandle in getPrimaryOutput\n // (output-extractor.ts); the frontend does so in extractNodeOutput.\n \"split-media\",\n // apply-edl renders an EDL into ONE media output whose type is decided at\n // run time by the node's `output` setting (video OR audio) — so its static\n // medium is genuinely unknown and it belongs here, letting canvas validators\n // accept its default media handle on BOTH audio and video input handles. It\n // ALSO emits a fixed `json` handle (the remapped Transcript); that half lives\n // in JSON_PRODUCER_TYPES (frontend/src/lib/data-handles.ts). The FIRST node\n // with both a dynamic media handle and a fixed json handle. Because\n // getOutputType (presentation-utils.ts) deliberately returns \"data\" for\n // DYNAMIC members, apply-edl is ALSO added to the literal VIDEO_OUTPUT_TYPES\n // there so a published app renders the cut as video, mirroring the\n // voice-changer/dubbing precedent. Asserted in producer-types.test.ts (the\n // suite does not fail on omission).\n \"apply-edl\",\n], unitProducers(\"dynamic\"))\n\n/**\n * Source node types whose primary output is an audio URL.\n * Mirrors the backend execution-graph AUDIO_SOURCE_TYPES verbatim.\n */\nexport const AUDIO_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"AUDIO_PRODUCER_TYPES\", [\n \"text-to-speech\",\n \"text-to-audio\",\n \"generate-music\",\n \"upload-audio\",\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-separate\",\n \"audio-separation\",\n \"suno-mashup\",\n \"suno-replace-section\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-convert-wav\",\n \"suno-upload-extend\",\n \"trim-audio\",\n \"mix-audio\",\n \"combine-audio\",\n \"adjust-volume\",\n \"audio-fx\",\n \"pitch-tempo\",\n \"reference-audio\",\n \"audio-isolation\",\n \"text-to-dialogue\",\n \"voice-changer\",\n // Twin of voice-changer (see DYNAMIC_PRODUCER_TYPES note). Audio is its\n // default output mode; video mode is handled via DYNAMIC membership.\n \"voice-changer-pro\",\n \"dubbing\",\n \"voice-remix\",\n \"voice-design\",\n // Extract Audio: demuxes a video's audio track to a standalone MP3.\n \"extract-audio\",\n], unitProducers(\"audio\"))\n\n/**\n * Source node types whose output is an IMAGE URL — what feeds a References\n * input. ONE set for the canvas validators (`frontend/src/lib/\n * generate-image-handles.ts` re-exports it), the backend's Generate Image\n * handle migration and the MCP edge normalizer (`llm-chat`'s legacy `in`):\n * they used to keep separate copies, and the backend's lagged by eight types.\n */\nexport const IMAGE_PRODUCER_TYPES: ReadonlySet<string> = composeUnitSet(\"IMAGE_PRODUCER_TYPES\", [\n \"upload-image\", \"generate-image\", \"edit-image\", \"image-to-image\", \"modify-image\", \"upscale-image\", \"remove-background\",\n // extract-frame produces a single still image extracted from a video source.\n \"extract-frame\",\n // generate-mask emits the source image AND a mask PNG; its `image` source\n // pip is the passthrough (the same image as the input).\n \"generate-mask\",\n // paint-mask emits the hand-painted mask PNG (a plain image at runtime).\n // Membership is what makes mask targets accept it — mask is an advisory\n // color, not a gated type.\n \"paint-mask\",\n // reference-sheet's `sheet` is one composited image and `panels` carries\n // clean reference images; both resolve to image URLs at runtime.\n \"reference-sheet\",\n // reference-board's `image` pip emits a real generated board image.\n \"reference-board\",\n // image-collage composites N images → ONE image.\n \"image-collage\",\n // image-overlay places layers on a base → ONE image.\n \"image-overlay\",\n // 3D Render Pro's `stills` handle carries one PNG per shot of the exported\n // composition (spread into referenceImageUrls like reference-sheet\n // `panels`). A validator sees only the source NODE type, so this also makes\n // its `video` pip droppable on an image input — the handle-blind trade\n // reference-sheet and split-media already make; the input resolvers route\n // by handle, so only `stills` becomes an image at runtime. Deliberately NOT\n // in IMAGE_SOURCE_TYPES on either engine: that set types the node's PRIMARY\n // asset, and 3D Render Pro's is the MP4.\n \"pro-3d-render\",\n], unitProducers(\"image\"))\n\n/**\n * Source node types whose primary output is a LIST that, by default, fans out\n * one downstream execution per element when an edge leaves them WITHOUT an\n * explicit `outputMode` (all other edges default to \"last\"). `selector` is\n * included because its picked/rest channels are lists too.\n *\n * Single source of truth for the fan-out \"each\" default, consumed by:\n * - backend/src/services/workflow-engine/input-resolver.ts (DEFAULT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/types.ts (FAN_OUT_EACH_TYPES)\n * - frontend/src/components/editor/workflow-editor/node-input-resolver.ts\n *\n * These three previously kept independent copies; the backend copy drifted\n * (missing the four list-transform types), so server-side workflow runs\n * silently dropped all-but-the-first item for filter-list / deduplicate /\n * merge-lists / sort-list sources while the canvas fanned out N ways. Lifting\n * the set here makes that drift impossible.\n */\nexport const FAN_OUT_EACH_TYPES: ReadonlySet<string> = new Set([\n \"list\",\n \"split-text\",\n \"filter-list\",\n \"deduplicate\",\n \"merge-lists\",\n \"sort-list\",\n \"selector\",\n // edit-plan `clips` mode emits a bare `Edl[]` on `data.generatedJson`, so an\n // edge leaving it defaults to \"each\" — one downstream execution (typically an\n // apply-edl render) per clip. The `tighten`/`chapters` modes emit an OBJECT,\n // for which the list extractors return undefined, so an \"each\" edge falls back\n // to the scalar `edl` value (no fan-out) — the same graceful degradation\n // web-scrape relies on. See `unwrapEditPlanOutput` in `edit-plan-contract.ts`.\n \"edit-plan\",\n // Content Ideas emits one creative brief per idea on `listResults`, so an\n // edge leaving it defaults to \"each\" — the node after it (typically\n // Generate Script) runs once per idea, on the server too.\n \"content-ideas\",\n])\n\n/**\n * Per-HANDLE \"each\" defaults, for a node whose outputs differ in kind: on the\n * `each` handles an edge without an explicit `outputMode` defaults to \"each\",\n * on its other handles to \"last\". `primary` is the handle an edge with no\n * `sourceHandle` reads (agent-written workflow JSON often omits it).\n *\n * The list an \"each\" edge reads is the node's per-iteration results\n * (`listResults`) — it exists only when the node itself ran once per item, so\n * after a single run the edge degrades to the single value, exactly like a\n * `FAN_OUT_EACH_TYPES` member with one item.\n *\n * Its hand-written rows ∪ the node units' rows (`contract.fanOutEach`,\n * generated/unit-contracts.ts); a type in both refuses to load.\n */\nexport const FAN_OUT_EACH_HANDLES: Readonly<Record<string, { readonly each: readonly string[]; readonly primary: string }>> = composeUnitRecord(\"FAN_OUT_EACH_HANDLES\", {\n // Camera Switch run once per clip (Edit Plan in clips mode): each clip's\n // switched EDL is its own Apply EDL render. Its transcript is the same for\n // every clip (the master clock, renamed), so that handle stays one value\n // (decided 2026-10-04).\n \"camera-switch\": { each: [\"edl\"], primary: \"edl\" },\n // UGC Clips: one ticket per clip on `clips` (each); `plan-out` and\n // `transcript` carry one value. Not a FAN_OUT_EACH_TYPES member — every\n // handle of such a member would fan out. Its one run writes the tickets as\n // its list (`listResults`, the editor's `__listResults`). The pip an edge\n // with no handle reads is the UGC wires' own (UGC_PRIMARY_HANDLE).\n \"ugc-clips\": { each: [\"clips\"], primary: UGC_PRIMARY_HANDLE[\"ugc-clips\"]! },\n // A node unit declares its row in unit.json (contract.fanOutEach); it is added after these.\n}, unitFanOutEach())\n\n/**\n * Fan-out nodes whose iterations must ALL succeed: one failed item fails the\n * node (today's rule tolerates a partial list). UGC Clip — a missing clip\n * silently drops a beat from the script (spec R17). Already-started items\n * finish and settle; their jobs are reused on the next run.\n */\nexport const FAN_OUT_ALL_OR_NOTHING_TYPES: ReadonlySet<string> = new Set([\"ugc-clip\"])\n\n/**\n * Nodes whose saved list is the list their last run PRODUCED — `__listResults`\n * (Extract Field's JSON value on `generatedJson`) — and never a history in\n * `generatedResults`: Extract Field, JSON Process and Site Capture. No run of the first two writes\n * one; earlier builds' server runs did (the run's text, the links of a list of\n * links), and both engines' list readers leave it out for these two (decided\n * 2026-10-05). Single source of truth for the backend engine and the editor.\n */\nexport const OWN_LIST_NODE_TYPES: ReadonlySet<string> = new Set([\n \"extract-field\",\n \"json-process\",\n // Site Capture: its stills, in page order — the last capture's, never every capture's (site-capture-node.ts).\n \"site-capture\",\n])\n\n/** Whether a node's saved list is its own `__listResults`, never a history. */\nexport function ownsItsList(nodeType: string | null | undefined): boolean {\n return typeof nodeType === \"string\" && OWN_LIST_NODE_TYPES.has(nodeType)\n}\n\n/**\n * The output pips that carry the LIST one run produced — several files on one\n * pip (a node unit's `handles.outputs[].list`: each layer of a split image). An\n * edge leaving one runs the next node once per item by default (\"each\"); a\n * Bundle hands the whole list to a node that takes several. Unlike\n * FAN_OUT_EACH_HANDLES, the list is what ONE run made on that pip, never the\n * node's per-iteration results. An edge naming no pip reads the node's primary\n * output, which is never a list pip (tools/units/json-output-rules.mjs).\n * Node units only (generated/unit-contracts.ts UNIT_LIST_PIPS).\n */\nexport const LIST_OUTPUT_HANDLES: Readonly<Record<string, readonly string[]>> = composeUnitRecord(\"LIST_OUTPUT_HANDLES\", {}, unitListPips())\n\n/** Whether an edge leaving `sourceHandle` of a `sourceType` node carries a list one run produced (LIST_OUTPUT_HANDLES). */\nexport function isListOutputHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n if (typeof sourceType !== \"string\" || typeof sourceHandle !== \"string\" || !Object.hasOwn(LIST_OUTPUT_HANDLES, sourceType)) return false\n return LIST_OUTPUT_HANDLES[sourceType]!.includes(sourceHandle)\n}\n\n/** The `outputMode` an edge has when none is set on it — the ONE rule both\n * engines, the credit estimate and the editor read. */\nexport function defaultEdgeOutputMode(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): \"each\" | \"last\" {\n if (typeof sourceType !== \"string\") return \"last\"\n if (FAN_OUT_EACH_TYPES.has(sourceType)) return \"each\"\n if (isListOutputHandle(sourceType, sourceHandle)) return \"each\"\n const entry = FAN_OUT_EACH_HANDLES[sourceType]\n if (!entry) return \"last\"\n return entry.each.includes(sourceHandle || entry.primary) ? \"each\" : \"last\"\n}\n\n/** Whether an edge from `sourceHandle` reads the node's per-iteration results\n * (`listResults` — each iteration's PRIMARY output). False on the other\n * handles of a `FAN_OUT_EACH_HANDLES` node: Camera Switch's transcript is one\n * value, never the list of switched EDLs, whatever mode its edge is set to. */\nexport function listResultsServeHandle(\n sourceType: string | null | undefined,\n sourceHandle: string | null | undefined,\n): boolean {\n const entry = typeof sourceType === \"string\" ? FAN_OUT_EACH_HANDLES[sourceType] : undefined\n return !entry || entry.each.includes(sourceHandle || entry.primary)\n}\n\n/**\n * FAN-IN targets: nodes that FOLD everything wired into them into ONE run,\n * instead of running once per upstream item. Keyed by node type; the value\n * names the target handles that fold (`\"*\"` = every handle). An edge into any\n * other handle of such a node is routed normally — Content Ideas folds its\n * recipes but reads its brand from a `field-brand` wire like any field.\n *\n * Single source of truth for both engines' input resolvers (the backend and\n * the editor each used to keep a private `new Set([\"reduce\"])`). A fan-in\n * node is never itself fanned out by an upstream list.\n */\nexport const FAN_IN_TARGETS: Readonly<Record<string, \"*\" | readonly string[]>> = {\n // Choose Best — every wire is a candidate.\n reduce: \"*\",\n // Content Ideas — one or more recipes, from several Content Recipe nodes\n // and/or one that ran once per post.\n \"content-ideas\": [\"recipes\"],\n // Telegram Reply — one message per run, whatever is wired into its text\n // input: a list (or a writer that ran once per item) arrives as one\n // message, never as a burst of sends to the owner's chat.\n \"telegram-account-send\": [\"in\"],\n // The list operators — they READ the whole list wired into them (their\n // executors collect every upstream item themselves) and emit a list. Run\n // once per item by an \"each\" wire (a Split Text, a List, a node that ran per\n // item), every iteration saw the same whole list and answered with its\n // first match: a Filter List fed 11 stories handed 11 copies of story one\n // downstream, and every paid stage after it ran 11 times on it\n // (2026-10-06). A list operator is never fanned out, on any wire.\n \"filter-list\": \"*\",\n deduplicate: \"*\",\n \"merge-lists\": \"*\",\n \"sort-list\": \"*\",\n selector: \"*\",\n // Speaker Frames on a clip pack (P3-24 (a), decided 2026-10-06): ONE run over\n // the union of the clips' spans — the pack's EDLs fold onto its `edl` wire\n // instead of running one detection job (and one minimum charge) per clip.\n \"speaker-frames\": [\"edl\"],\n // UGC Finish: ONE run over every clip of the video, in clip order — the finish plans its\n // cut and its sound over all of them at once, so it is never run once per clip.\n \"ugc-finish-clips\": [\"clips\"],\n}\n\nexport function isFanInNodeType(nodeType: string | undefined | null): boolean {\n return typeof nodeType === \"string\" && Object.prototype.hasOwnProperty.call(FAN_IN_TARGETS, nodeType)\n}\n\n/** True when an edge into `targetHandle` of a `targetType` node is folded.\n * An edge with NO target handle (workflow JSON written by an agent often\n * omits it) lands on the node's primary input, which is the folding one. */\nexport function isFanInEdge(targetType: string | undefined | null, targetHandle: string | null | undefined): boolean {\n if (!isFanInNodeType(targetType)) return false\n const spec = FAN_IN_TARGETS[targetType as string]!\n if (spec === \"*\") return true\n return targetHandle == null || targetHandle === \"\" || spec.includes(targetHandle)\n}\n","/**\n * UI-default fills for the unified video nodes — the ONE source of truth shared\n * by the backend DAG payload builder, the config-panel fail-safe snaps and the\n * node's hover/run strip.\n *\n * Several config panels RENDER a default without persisting it to node data, so\n * an untouched node submits `aspectRatio` / `resolution` undefined and the\n * enqueued job row (and the /v1/jobs echo) then disagrees with what actually\n * renders. Worse, the panels' generic snap writes `resolutions[0]` for a stale\n * value, which is the CHEAPEST tier under the repo's ascending-resolution\n * convention — not necessarily the tier the model renders and bills.\n *\n * These helpers were local to `backend/src/services/workflow-engine/payload-builder.ts`\n * until the Wan 3.0 launch gave the platform its first provider whose declared\n * billing default differs from `resolutions[0]`; three surfaces then had to\n * agree, so they live here.\n *\n * The resolution fill is per-family ON PURPOSE. Wan 3.0 (and Vidu Q4, whose\n * ascending list starts at 540p) reads its DECLARED\n * billing default (PRICING_DEFAULT_RESOLUTION = 720p) because its catalog list\n * is ascending, so an index-0 fill would write 480p — a tier both `runWan3`\n * (which renders 720P) and the credit identifier (which bills the 720p row)\n * disagree with. The Seedance family keeps its historical first-catalog-tier\n * fill, deliberately: switching it to PRICING_DEFAULT_RESOLUTION would reprice\n * live seedance-2-5 runs, whose declared default (720p) differs from the 480p\n * this has always filled. That 480p-fill vs 720p-billing-default divergence on\n * seedance-2-5 is a KNOWN pre-existing gap, out of scope here — do not \"align\"\n * the branches without repricing it deliberately.\n */\n\nimport {\n PRICING_DEFAULT_RESOLUTION,\n isSeedance2Provider,\n isMinimaxH3Provider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4RunnerProvider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isPixverseV6MaxProvider,\n} from \"./model-constants.js\"\nimport { MODEL_CATALOG } from \"./model-catalog.js\"\n\n/** `adaptive` is the aspect default for Seedance 2, MiniMax H3 and Wan 3.0. */\nexport function uiAspectRatioFill(provider: string): string | undefined {\n if (isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider)) return \"adaptive\"\n // Kling 4.0 (and Flash): `auto` follows the materials (frames / references)\n // and renders 16:9 with none — KIE's own default when the field is omitted.\n // Flash's keyframe endpoint has no `auto`, but it runs only with a start\n // frame, where the ratio is never sent (the clip follows the frame).\n if (isKling4RunnerProvider(provider)) return \"auto\"\n return undefined\n}\n\n/** See the file docstring — per-family on purpose; never a generic\n * PRICING_DEFAULT_RESOLUTION read (that would reprice seedance-2-5). */\nexport function uiResolutionFill(provider: string): string | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isGeminiOmniPerSecondProvider(provider) || isPixverseV6MaxProvider(provider)) return PRICING_DEFAULT_RESOLUTION[provider]\n if (isSeedance2Provider(provider)) return MODEL_CATALOG[provider]?.resolutions?.[0]\n return undefined\n}\n\n/**\n * Duration the node RENDERS and BILLS when `data.duration` is unset, for the\n * families whose credit identifier declares a duration fallback that is NOT\n * `durations[0]`. Wan 3.0's bare identifier is the 5s tier while its ladder\n * starts at 2s; Vidu Q4's is the 5s tier while its ladder starts at 3s;\n * PixVerse V6 Max's is the 5s tier while its ladder starts at 1s; the\n * Gemini Omni family's is the 8s tier while its ladder starts at 4s. Everyone else falls back to the first listed duration, so this returns\n * undefined and the caller keeps `durations[0]`.\n */\nexport function uiDurationFill(provider: string): number | undefined {\n if (isWan3Provider(provider) || isViduQ4Provider(provider) || isKling4RunnerProvider(provider) || isPixverseV6MaxProvider(provider)) return 5\n if (isGeminiOmniProvider(provider)) return 8\n return undefined\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { MODEL_CATALOG, normalizeModelInput } from './chunk-R22UHRR6.js';
1
+ import { MODEL_CATALOG, normalizeModelInput } from './chunk-X7UDZGXW.js';
2
2
 
3
3
  // src/image-model-roles.ts
4
4
  var IMAGE_MODEL_ROLE_DEFAULTS = {
@@ -57,5 +57,5 @@ function normalizeVideoUpscaleResolution(provider, targetResolution) {
57
57
  }
58
58
 
59
59
  export { IMAGE_MODEL_RATIO_FALLBACKS, IMAGE_MODEL_ROLE_DEFAULTS, VIDEO_UPSCALE_RESOLUTIONS, defaultImageModel, defaultImageModelForNode, imageModelDrawsRatio, normalizeVideoUpscaleResolution, videoUpscaleModelOf, videoUpscaleResolutionsFor };
60
- //# sourceMappingURL=chunk-EWNDK4FV.js.map
61
- //# sourceMappingURL=chunk-EWNDK4FV.js.map
60
+ //# sourceMappingURL=chunk-EOYQD6DU.js.map
61
+ //# sourceMappingURL=chunk-EOYQD6DU.js.map