@nodaro/shared 3.61.0 → 3.63.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 (313) hide show
  1. package/dist/{chunk-4KYLNTR7.cjs → chunk-2PU3AGGS.cjs} +27 -4
  2. package/dist/chunk-2PU3AGGS.cjs.map +1 -0
  3. package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
  4. package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
  5. package/dist/{chunk-B6BG3LV2.js → chunk-34QLPTSA.js} +3 -3
  6. package/dist/{chunk-B6BG3LV2.js.map → chunk-34QLPTSA.js.map} +1 -1
  7. package/dist/chunk-3K24DWOH.js +453 -0
  8. package/dist/chunk-3K24DWOH.js.map +1 -0
  9. package/dist/{chunk-IRQ3SPX7.js → chunk-4DVWXEB6.js} +23 -4
  10. package/dist/chunk-4DVWXEB6.js.map +1 -0
  11. package/dist/{chunk-ZES6EZC4.js → chunk-4MMZD63H.js} +3 -3
  12. package/dist/{chunk-ZES6EZC4.js.map → chunk-4MMZD63H.js.map} +1 -1
  13. package/dist/{chunk-MQZRQ5LM.cjs → chunk-63H4C56Q.cjs} +8 -8
  14. package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-63H4C56Q.cjs.map} +1 -1
  15. package/dist/{chunk-IVXSNW2B.cjs → chunk-6BZC2ZHC.cjs} +18 -332
  16. package/dist/chunk-6BZC2ZHC.cjs.map +1 -0
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-673E4KYC.js → chunk-6M563QE6.js} +134 -8
  20. package/dist/chunk-6M563QE6.js.map +1 -0
  21. package/dist/chunk-6TGB7ECA.cjs +48 -0
  22. package/dist/chunk-6TGB7ECA.cjs.map +1 -0
  23. package/dist/{chunk-XUJC6GHE.cjs → chunk-6XUG4L7X.cjs} +6 -6
  24. package/dist/{chunk-XUJC6GHE.cjs.map → chunk-6XUG4L7X.cjs.map} +1 -1
  25. package/dist/{chunk-XZKFZMRT.cjs → chunk-77WU3V3J.cjs} +6 -6
  26. package/dist/{chunk-XZKFZMRT.cjs.map → chunk-77WU3V3J.cjs.map} +1 -1
  27. package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
  28. package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
  29. package/dist/{chunk-ZDBPQBAA.js → chunk-AE3AAJ4O.js} +3 -3
  30. package/dist/{chunk-ZDBPQBAA.js.map → chunk-AE3AAJ4O.js.map} +1 -1
  31. package/dist/chunk-ALRXY4QH.cjs +13 -0
  32. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  33. package/dist/{chunk-UARGJ5IZ.js → chunk-BMJVKYVB.js} +56 -12
  34. package/dist/chunk-BMJVKYVB.js.map +1 -0
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/chunk-CZ5IQB3L.js +42 -0
  40. package/dist/chunk-CZ5IQB3L.js.map +1 -0
  41. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  42. package/dist/chunk-D34K455O.cjs.map +1 -0
  43. package/dist/chunk-EPXGG27L.js +331 -0
  44. package/dist/chunk-EPXGG27L.js.map +1 -0
  45. package/dist/{chunk-3M4BNKFJ.cjs → chunk-F6WGGYQW.cjs} +167 -3
  46. package/dist/chunk-F6WGGYQW.cjs.map +1 -0
  47. package/dist/{chunk-7FCTCWHD.js → chunk-FXGNRYQQ.js} +3 -3
  48. package/dist/{chunk-7FCTCWHD.js.map → chunk-FXGNRYQQ.js.map} +1 -1
  49. package/dist/{chunk-ZNM2LW3D.cjs → chunk-GMBDLNLD.cjs} +105 -56
  50. package/dist/chunk-GMBDLNLD.cjs.map +1 -0
  51. package/dist/{chunk-NJVOJXBS.cjs → chunk-GSKLPI3J.cjs} +104 -49
  52. package/dist/chunk-GSKLPI3J.cjs.map +1 -0
  53. package/dist/{chunk-EWS2VFO4.js → chunk-HBXF6RUU.js} +4 -4
  54. package/dist/{chunk-EWS2VFO4.js.map → chunk-HBXF6RUU.js.map} +1 -1
  55. package/dist/{chunk-MOMFX32D.js → chunk-HWQ2SYNA.js} +194 -325
  56. package/dist/chunk-HWQ2SYNA.js.map +1 -0
  57. package/dist/{chunk-SCMTN57Y.js → chunk-IY3Y462W.js} +3 -3
  58. package/dist/{chunk-SCMTN57Y.js.map → chunk-IY3Y462W.js.map} +1 -1
  59. package/dist/{chunk-ZZGQRRN7.js → chunk-KCZHQH2O.js} +6 -306
  60. package/dist/chunk-KCZHQH2O.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  64. package/dist/chunk-KL6GAYTT.js.map +1 -0
  65. package/dist/{chunk-FVII3KHN.js → chunk-KMGCHV6O.js} +163 -4
  66. package/dist/chunk-KMGCHV6O.js.map +1 -0
  67. package/dist/{chunk-FMXFHJWX.cjs → chunk-L2TVY6XN.cjs} +4 -4
  68. package/dist/{chunk-FMXFHJWX.cjs.map → chunk-L2TVY6XN.cjs.map} +1 -1
  69. package/dist/{chunk-FQXRYPCX.cjs → chunk-LH72PQO2.cjs} +505 -68
  70. package/dist/chunk-LH72PQO2.cjs.map +1 -0
  71. package/dist/chunk-LMAQUR55.cjs +506 -0
  72. package/dist/chunk-LMAQUR55.cjs.map +1 -0
  73. package/dist/{chunk-F5YEMSNK.cjs → chunk-M5OCFGHF.cjs} +571 -30
  74. package/dist/chunk-M5OCFGHF.cjs.map +1 -0
  75. package/dist/{chunk-VOWJCUMR.js → chunk-MD4XHED4.js} +3 -3
  76. package/dist/{chunk-VOWJCUMR.js.map → chunk-MD4XHED4.js.map} +1 -1
  77. package/dist/chunk-N5HH46JF.cjs +68 -0
  78. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  79. package/dist/{chunk-G4XWVWRI.js → chunk-NIAFR5EE.js} +5 -4
  80. package/dist/chunk-NIAFR5EE.js.map +1 -0
  81. package/dist/{chunk-CF4S4N5X.js → chunk-O2QOBA6Q.js} +2 -2
  82. package/dist/{chunk-CF4S4N5X.js.map → chunk-O2QOBA6Q.js.map} +1 -1
  83. package/dist/{chunk-4GGLKRYI.cjs → chunk-O6TBB4IF.cjs} +2 -2
  84. package/dist/{chunk-4GGLKRYI.cjs.map → chunk-O6TBB4IF.cjs.map} +1 -1
  85. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  86. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  87. package/dist/{chunk-LLOIAGFB.js → chunk-OV3JTKBY.js} +449 -51
  88. package/dist/chunk-OV3JTKBY.js.map +1 -0
  89. package/dist/{chunk-A3FHTSLB.js → chunk-PSKZKLDG.js} +550 -31
  90. package/dist/chunk-PSKZKLDG.js.map +1 -0
  91. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  92. package/dist/chunk-RGNHHIMN.js.map +1 -0
  93. package/dist/chunk-SMOO5FAH.js +10 -0
  94. package/dist/chunk-SMOO5FAH.js.map +1 -0
  95. package/dist/{chunk-5XRRENHD.cjs → chunk-TM5JYSJF.cjs} +170 -17
  96. package/dist/chunk-TM5JYSJF.cjs.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-RQ4F3AJH.cjs → chunk-V5EEQR2U.cjs} +21 -21
  100. package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-V5EEQR2U.cjs.map} +1 -1
  101. package/dist/chunk-WZVIBAKN.cjs +351 -0
  102. package/dist/chunk-WZVIBAKN.cjs.map +1 -0
  103. package/dist/{chunk-5M43XMRB.cjs → chunk-X5BAFW3Q.cjs} +8 -8
  104. package/dist/{chunk-5M43XMRB.cjs.map → chunk-X5BAFW3Q.cjs.map} +1 -1
  105. package/dist/{chunk-RUHKBEFF.js → chunk-XBTYGQ6Z.js} +63 -10
  106. package/dist/chunk-XBTYGQ6Z.js.map +1 -0
  107. package/dist/{chunk-JHTT2V4A.cjs → chunk-XGGZWA4A.cjs} +118 -52
  108. package/dist/chunk-XGGZWA4A.cjs.map +1 -0
  109. package/dist/{chunk-5I4T4QR5.cjs → chunk-XGVJGNZW.cjs} +5 -5
  110. package/dist/{chunk-5I4T4QR5.cjs.map → chunk-XGVJGNZW.cjs.map} +1 -1
  111. package/dist/{chunk-7ARKVJTN.cjs → chunk-Y35JQPT6.cjs} +228 -383
  112. package/dist/chunk-Y35JQPT6.cjs.map +1 -0
  113. package/dist/{chunk-AFQFGZN7.cjs → chunk-Y4GCJJPF.cjs} +8 -6
  114. package/dist/chunk-Y4GCJJPF.cjs.map +1 -0
  115. package/dist/{chunk-C77F4ZTL.js → chunk-YUER7TJG.js} +3 -3
  116. package/dist/{chunk-C77F4ZTL.js.map → chunk-YUER7TJG.js.map} +1 -1
  117. package/dist/{chunk-HGI2VKIV.js → chunk-YX6TFX7H.js} +67 -14
  118. package/dist/chunk-YX6TFX7H.js.map +1 -0
  119. package/dist/{chunk-TWF2OSH4.cjs → chunk-ZPE2ZTJ4.cjs} +4 -4
  120. package/dist/{chunk-TWF2OSH4.cjs.map → chunk-ZPE2ZTJ4.cjs.map} +1 -1
  121. package/dist/entries/apps.cjs +44 -44
  122. package/dist/entries/apps.js +9 -9
  123. package/dist/entries/credits.cjs +286 -153
  124. package/dist/entries/credits.d.cts +254 -5
  125. package/dist/entries/credits.d.ts +254 -5
  126. package/dist/entries/credits.js +14 -9
  127. package/dist/entries/entities.cjs +188 -143
  128. package/dist/entries/entities.d.cts +122 -1
  129. package/dist/entries/entities.d.ts +122 -1
  130. package/dist/entries/entities.js +2 -1
  131. package/dist/entries/llm-models.cjs +77 -57
  132. package/dist/entries/llm-models.d.cts +85 -5
  133. package/dist/entries/llm-models.d.ts +85 -5
  134. package/dist/entries/llm-models.js +2 -2
  135. package/dist/entries/media.cjs +92 -87
  136. package/dist/entries/media.d.cts +19 -1
  137. package/dist/entries/media.d.ts +19 -1
  138. package/dist/entries/media.js +3 -2
  139. package/dist/entries/model-catalog.cjs +211 -103
  140. package/dist/entries/model-catalog.d.cts +135 -19
  141. package/dist/entries/model-catalog.d.ts +135 -19
  142. package/dist/entries/model-catalog.js +5 -5
  143. package/dist/entries/models.cjs +504 -295
  144. package/dist/entries/models.d.cts +71 -4
  145. package/dist/entries/models.d.ts +71 -4
  146. package/dist/entries/models.js +7 -6
  147. package/dist/entries/nodes.cjs +249 -233
  148. package/dist/entries/nodes.d.cts +35 -6
  149. package/dist/entries/nodes.d.ts +35 -6
  150. package/dist/entries/nodes.js +10 -10
  151. package/dist/entries/pipeline.cjs +152 -152
  152. package/dist/entries/pipeline.d.cts +3 -2
  153. package/dist/entries/pipeline.d.ts +3 -2
  154. package/dist/entries/pipeline.js +3 -3
  155. package/dist/entries/runtime-config.cjs +29 -29
  156. package/dist/entries/runtime-config.d.cts +10 -7
  157. package/dist/entries/runtime-config.d.ts +10 -7
  158. package/dist/entries/runtime-config.js +1 -1
  159. package/dist/entries/social.cjs +177 -177
  160. package/dist/entries/social.js +2 -2
  161. package/dist/entries/types.d.cts +8 -0
  162. package/dist/entries/types.d.ts +8 -0
  163. package/dist/entries/ugc.cjs +71 -71
  164. package/dist/entries/ugc.js +4 -4
  165. package/dist/entries/video.cjs +316 -208
  166. package/dist/entries/video.d.cts +490 -99
  167. package/dist/entries/video.d.ts +490 -99
  168. package/dist/entries/video.js +8 -4
  169. package/dist/entries/workflow.cjs +102 -102
  170. package/dist/entries/workflow.d.cts +5 -4
  171. package/dist/entries/workflow.d.ts +5 -4
  172. package/dist/entries/workflow.js +2 -2
  173. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  174. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  175. package/dist/index.cjs +2727 -2092
  176. package/dist/index.d.cts +11 -11
  177. package/dist/index.d.ts +11 -11
  178. package/dist/index.js +30 -27
  179. package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-C_Eo35tL.d.cts} +158 -14
  180. package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-C_Eo35tL.d.ts} +158 -14
  181. package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Bg4ccSQb.d.ts} +427 -34
  182. package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-DWcxOmaY.d.cts} +427 -34
  183. package/package.json +1 -1
  184. package/src/__tests__/credit-identifiers.test.ts +29 -0
  185. package/src/__tests__/extend-providers.test.ts +194 -0
  186. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  187. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  188. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  189. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  190. package/src/__tests__/gvp-supported-providers.test.ts +32 -4
  191. package/src/__tests__/lip-sync-audio-rate.test.ts +74 -0
  192. package/src/__tests__/lip-sync-levers.test.ts +31 -0
  193. package/src/__tests__/llm-models.test.ts +132 -3
  194. package/src/__tests__/llm-price-key.test.ts +152 -1
  195. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  196. package/src/__tests__/model-makers.test.ts +49 -11
  197. package/src/__tests__/model-tree.test.ts +13 -0
  198. package/src/__tests__/nemotron-transcribe-pricing.test.ts +61 -0
  199. package/src/__tests__/normalize-node-params.test.ts +25 -0
  200. package/src/__tests__/pixverse-v6-max-catalog.test.ts +271 -0
  201. package/src/__tests__/prompt-length-limits.test.ts +4 -0
  202. package/src/__tests__/retired-video-provider.test.ts +15 -5
  203. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  204. package/src/__tests__/seedance-task-type.test.ts +188 -0
  205. package/src/__tests__/seedream-5-5.test.ts +117 -0
  206. package/src/__tests__/transcribe-capabilities.test.ts +39 -2
  207. package/src/__tests__/transcribe-preflight.test.ts +50 -1
  208. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  209. package/src/__tests__/unit-contracts.test.ts +20 -6
  210. package/src/__tests__/upscale-factors.test.ts +107 -0
  211. package/src/__tests__/video-audio-capability.test.ts +35 -6
  212. package/src/__tests__/video-character-refs.test.ts +20 -2
  213. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  214. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  215. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  216. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  217. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  218. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  219. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  220. package/src/__tests__/video-overlay.test.ts +280 -194
  221. package/src/__tests__/video-ref-limits.test.ts +2 -1
  222. package/src/__tests__/video-reference-only.test.ts +6 -2
  223. package/src/__tests__/video-resolution-billed-as-named.test.ts +30 -0
  224. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  225. package/src/__tests__/video-upscale-params.test.ts +62 -0
  226. package/src/__tests__/wired-character-names.test.ts +220 -0
  227. package/src/catalog-projection.ts +8 -0
  228. package/src/credit-estimators/index.ts +18 -0
  229. package/src/credit-estimators/nemotron-transcribe.ts +87 -0
  230. package/src/credit-estimators/video-overlay.ts +70 -0
  231. package/src/credit-identifiers.ts +183 -16
  232. package/src/entity-image-url.ts +21 -0
  233. package/src/entries/credits.ts +26 -1
  234. package/src/entries/entities.ts +14 -0
  235. package/src/entries/llm-models.ts +6 -0
  236. package/src/entries/model-catalog.ts +44 -1
  237. package/src/entries/models.ts +69 -0
  238. package/src/entries/nodes.ts +4 -0
  239. package/src/entries/video.ts +7 -1
  240. package/src/freecut-protocol.ts +8 -0
  241. package/src/generated/unit-contracts.ts +8 -1
  242. package/src/gpt-image-2-6.ts +6 -0
  243. package/src/input-image-pricing.ts +76 -0
  244. package/src/lip-sync-levers.ts +56 -0
  245. package/src/lip-sync-pricing.ts +91 -1
  246. package/src/llm-models.ts +249 -4
  247. package/src/mask-composite.ts +11 -0
  248. package/src/minimax-h3-image.ts +61 -0
  249. package/src/model-catalog.ts +604 -40
  250. package/src/model-constants.ts +860 -55
  251. package/src/model-tree.ts +2 -1
  252. package/src/nodaro-video-upscale.ts +48 -0
  253. package/src/node-default-mappings.ts +15 -2
  254. package/src/node-execution-state.ts +4 -3
  255. package/src/normalize-node-params.ts +49 -1
  256. package/src/producer-types.ts +23 -1
  257. package/src/runtime-config/contract.ts +10 -7
  258. package/src/seedance-draft.ts +2 -1
  259. package/src/seedance-task-type.ts +37 -0
  260. package/src/seedream-5-5.ts +45 -0
  261. package/src/transcribe-preflight.ts +58 -7
  262. package/src/unit-contract-compose.ts +4 -1
  263. package/src/upscale-factors.ts +111 -0
  264. package/src/video-character-refs.ts +7 -4
  265. package/src/video-duration.ts +9 -0
  266. package/src/video-overlay-geometry.ts +99 -0
  267. package/src/video-overlay-input.ts +25 -0
  268. package/src/video-overlay-layout-ids.ts +48 -0
  269. package/src/video-overlay-layouts.ts +315 -0
  270. package/src/video-overlay-validate.ts +223 -0
  271. package/src/video-overlay-video-layers.ts +304 -0
  272. package/src/video-overlay.ts +165 -297
  273. package/src/video-ui-defaults.ts +11 -7
  274. package/src/video-upscale-params.ts +67 -0
  275. package/src/wired-character-names.ts +202 -0
  276. package/dist/chunk-3M4BNKFJ.cjs.map +0 -1
  277. package/dist/chunk-4KYLNTR7.cjs.map +0 -1
  278. package/dist/chunk-5XRRENHD.cjs.map +0 -1
  279. package/dist/chunk-673E4KYC.js.map +0 -1
  280. package/dist/chunk-6XVHYD5R.js.map +0 -1
  281. package/dist/chunk-7ARKVJTN.cjs.map +0 -1
  282. package/dist/chunk-7WGKP3EU.js +0 -23
  283. package/dist/chunk-7WGKP3EU.js.map +0 -1
  284. package/dist/chunk-A3FHTSLB.js.map +0 -1
  285. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  286. package/dist/chunk-F5YEMSNK.cjs.map +0 -1
  287. package/dist/chunk-FQXRYPCX.cjs.map +0 -1
  288. package/dist/chunk-FVII3KHN.js.map +0 -1
  289. package/dist/chunk-FVVD6XY2.js.map +0 -1
  290. package/dist/chunk-G4XWVWRI.js.map +0 -1
  291. package/dist/chunk-HGI2VKIV.js.map +0 -1
  292. package/dist/chunk-IRQ3SPX7.js.map +0 -1
  293. package/dist/chunk-IVXSNW2B.cjs.map +0 -1
  294. package/dist/chunk-JHTT2V4A.cjs.map +0 -1
  295. package/dist/chunk-KHZAQGRP.js +0 -17
  296. package/dist/chunk-KHZAQGRP.js.map +0 -1
  297. package/dist/chunk-LLOIAGFB.js.map +0 -1
  298. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  299. package/dist/chunk-MOMFX32D.js.map +0 -1
  300. package/dist/chunk-NCOGGRRP.cjs +0 -27
  301. package/dist/chunk-NCOGGRRP.cjs.map +0 -1
  302. package/dist/chunk-NJVOJXBS.cjs.map +0 -1
  303. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  304. package/dist/chunk-RUHKBEFF.js.map +0 -1
  305. package/dist/chunk-SWVGHAYO.js.map +0 -1
  306. package/dist/chunk-UARGJ5IZ.js.map +0 -1
  307. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  308. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  309. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  310. package/dist/chunk-ZLDFPVVI.cjs +0 -19
  311. package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
  312. package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
  313. package/dist/chunk-ZZGQRRN7.js.map +0 -1
@@ -3,8 +3,9 @@
3
3
  * Single source of truth for model capability sets and variable pricing rules.
4
4
  */
5
5
  import { z } from "zod"
6
- import { MODEL_CATALOG } from "./model-catalog.js"
6
+ import { MODEL_CATALOG, isVideoAutoAspectToken, videoAutoAspectRunsAt, type ModelInputAdjustment } from "./model-catalog.js"
7
7
  import { isAutoVideoDuration, VIDEO_DURATION_AUTO } from "./video-duration-auto.js"
8
+ import { SEEDANCE_EDIT_REF_VIDEO_SEC, type DeclaredSeedanceTaskType } from "./seedance-task-type.js"
8
9
 
9
10
  /** Base USD value of 1 Nodaro credit. Used for cost→credit conversion. */
10
11
  export const CREDIT_BASE_USD = 0.002
@@ -56,14 +57,22 @@ export const IMAGE_ASPECT_RATIO_VALUES = [
56
57
  /** A ratio string the image routes accept (pre-snap vocabulary, not a per-model guarantee). */
57
58
  export type ImageAspectRatio = typeof IMAGE_ASPECT_RATIO_VALUES[number]
58
59
 
60
+ /**
61
+ * The K tiers of {@link IMAGE_RESOLUTION_VALUES}, smallest first. `1.5K` is
62
+ * Seedream 5.5's middle size; no other model lists it, and the catalog snap
63
+ * moves it to a size the chosen model does list.
64
+ */
65
+ export const IMAGE_K_RESOLUTION_VALUES = ["1K", "1.5K", "2K", "4K"] as const
66
+
59
67
  /**
60
68
  * The `resolution` vocabulary `/v1/generate-image` and `/v1/image-to-image`
61
- * accept: the K tiers (`1K`/`2K`/`4K`) and the Flux 2 megapixel tiers. Like
62
- * {@link IMAGE_ASPECT_RATIO_VALUES} it is a vocabulary bound, not a per-model
63
- * gate — the catalog snap corrects a value the chosen model does not declare.
64
- * One tuple for the route Zod enums and the SDK's `ImageResolution`.
69
+ * accept: the K tiers ({@link IMAGE_K_RESOLUTION_VALUES}) and the Flux 2
70
+ * megapixel tiers. Like {@link IMAGE_ASPECT_RATIO_VALUES} it is a vocabulary
71
+ * bound, not a per-model gate — the catalog snap corrects a value the chosen
72
+ * model does not declare. One tuple for the route Zod enums (the entity routes'
73
+ * too) and the SDK's `ImageResolution`.
65
74
  */
66
- export const IMAGE_RESOLUTION_VALUES = ["1K", "2K", "4K", "0.5 MP", "1 MP", "2 MP", "4 MP"] as const
75
+ export const IMAGE_RESOLUTION_VALUES = [...IMAGE_K_RESOLUTION_VALUES, "0.5 MP", "1 MP", "2 MP", "4 MP"] as const
67
76
  export type ImageResolution = typeof IMAGE_RESOLUTION_VALUES[number]
68
77
 
69
78
  /** The `quality` vocabulary of the same two routes (vocabulary bound; the catalog snap gates per model). */
@@ -174,7 +183,12 @@ export const MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
174
183
  // grok, qwen-i2i, seedream-5-pro, seedream-5-pro-i2i
175
184
  // (docs.kie.ai/market/seedream/5-pro-text-to-image + 5-pro-image-to-image),
176
185
  // seedream-5-flash, seedream-5-flash-i2i (both "4–5000 characters";
177
- // docs.kie.ai/market/seedream/5-flash-text-to-image + 5-flash-image-to-image).
186
+ // docs.kie.ai/market/seedream/5-flash-text-to-image + 5-flash-image-to-image),
187
+ // minimax-h3-image, minimax-h3-image-i2i (both "1–5000 characters";
188
+ // docs.kie.ai/market/minimax-h3/text-to-image + image-edit),
189
+ // seedream-5-5, seedream-5-5-i2i (both "5–5000 characters"; the minimum is
190
+ // MIN_IMAGE_PROMPT_CHARS_BY_PROVIDER below;
191
+ // docs.kie.ai/market/seedream/5-5-text-to-image + 5-5-image-to-image).
178
192
  // grok-i2i: doc states 390000 (78× its t2i sibling) — treated as a KIE schema
179
193
  // typo and left at the 5000 default per the sanity-cap decision.
180
194
  // UNVERIFIED (no limit stated in schema) → 5000 default: flux-kontext(-max)
@@ -189,6 +203,24 @@ export function getMaxImagePromptChars(provider: string | undefined): number {
189
203
  return (provider && MAX_IMAGE_PROMPT_CHARS_BY_PROVIDER[provider]) || IMAGE_PROMPT_MAX
190
204
  }
191
205
 
206
+ /**
207
+ * The fewest characters (after trimming) the prompt a provider is SENT may have,
208
+ * where its schema states a minimum it refuses below. Unlike the maximum, a
209
+ * short prompt cannot be fixed by the platform without writing words for the
210
+ * person, so a run whose final prompt is shorter is refused before anything is
211
+ * reserved (the image routes and the workflow run). Only a value quoted from
212
+ * the provider's schema is listed; a provider absent here has no minimum.
213
+ */
214
+ export const MIN_IMAGE_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
215
+ "seedream-5-5": 5, // docs.kie.ai/market/seedream/5-5-text-to-image ("5–5000 characters")
216
+ "seedream-5-5-i2i": 5, // docs.kie.ai/market/seedream/5-5-image-to-image
217
+ }
218
+
219
+ /** The minimum prompt length for a provider ({@link MIN_IMAGE_PROMPT_CHARS_BY_PROVIDER}), 0 when it states none. */
220
+ export function getMinImagePromptChars(provider: string | undefined): number {
221
+ return (provider && MIN_IMAGE_PROMPT_CHARS_BY_PROVIDER[provider]) || 0
222
+ }
223
+
192
224
  /**
193
225
  * Video prompt/negative cap shared by routes + editor (MCP verbs already use
194
226
  * 8000). Providers allow far more (KIE seedance-2: 20k chars) — the old
@@ -272,6 +304,19 @@ export const LLM_TEXT_INPUT_MAX = 100_000
272
304
  */
273
305
  export const LLM_STRUCTURED_SYSTEM_MAX = 200_000
274
306
 
307
+ /** Kling 4.0's prompt limit, 8000 chars on both endpoints
308
+ * (docs.kie.ai/market/kling/v4-reference-to-video and /v4-keyframe-to-video). */
309
+ const KLING_4_PROMPT_MAX = 8000
310
+
311
+ /**
312
+ * The characters a Kling 4 Extend run puts around the user's prompt on its
313
+ * way to Kling 4.0: the continuation wrapper before it, and the opening-frame
314
+ * sentence (after a blank line) that the reference endpoint adds for the
315
+ * source's last frame. Held to the text the run really sends by
316
+ * `backend/src/lib/__tests__/extend-recipe.test.ts`.
317
+ */
318
+ const KLING_4_EXTEND_PROMPT_OVERHEAD = 131
319
+
275
320
  /**
276
321
  * Per-provider maximum VIDEO prompt length (chars), VERIFIED against each model's
277
322
  * official docs.kie.ai schema (2026-06). Absent → {@link VIDEO_PROMPT_MAX} (8000)
@@ -293,7 +338,8 @@ export const MAX_VIDEO_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
293
338
  "seedance-2": 20000,
294
339
  "seedance-2-fast": 20000,
295
340
  "seedance-2-mini": 20000,
296
- "seedance-2-extend": 20000,
341
+ "seedance-2-5-extend": 20000,
342
+ "seedance-2-0-extend": 20000,
297
343
  // Seedance 2.5 raises the prompt ceiling to 30000
298
344
  // (docs.kie.ai/market/bytedance/seedance-2-5).
299
345
  "seedance-2-5": 30000,
@@ -312,8 +358,18 @@ export const MAX_VIDEO_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
312
358
  "vidu-q4": 20000,
313
359
  // Kling 4.0 — 8000 chars on both endpoints
314
360
  // (docs.kie.ai/market/kling/v4-reference-to-video and /v4-keyframe-to-video).
315
- "kling-4": 8000,
316
- "kling-4-keyframes": 8000,
361
+ "kling-4": KLING_4_PROMPT_MAX,
362
+ "kling-4-keyframes": KLING_4_PROMPT_MAX,
363
+ // Kling 4 Extend generates on Kling 4.0's reference endpoint, its user's
364
+ // prompt wrapped: the room the wrapping takes is left out, so a prompt at
365
+ // the cap (its "Avoid: …" clause last) reaches Kling 4.0 whole.
366
+ "kling-4-extend": KLING_4_PROMPT_MAX - KLING_4_EXTEND_PROMPT_OVERHEAD,
367
+ // Kling 4.0 Flash — 8000 chars on both endpoints
368
+ // (docs.kie.ai/market/kling/v4-flash-reference-to-video and /v4-flash-keyframe-to-video).
369
+ "kling-4-flash": 8000,
370
+ // PixVerse V6 Max — 1-5000 chars on both endpoints
371
+ // (docs.kie.ai/market/pixverse/v6-max-text-to-video and /v6-max-image-to-video).
372
+ "pixverse-v6-max": 5000,
317
373
  "bytedance-lite": 10000,
318
374
  "bytedance-pro": 10000,
319
375
  "bytedance-pro-fast": 10000,
@@ -339,6 +395,9 @@ export const MAX_VIDEO_PROMPT_CHARS_BY_PROVIDER: Record<string, number> = {
339
395
  "happyhorse-ref2v": 5000,
340
396
  "happyhorse-edit": 5000,
341
397
  "runway-kie": 1800,
398
+ // OmniHuman 2.0 (lip-sync) — "Up to 300 characters" (maxLength 300 in KIE's
399
+ // omnihuman-2-0 schema, read 2026-11-11). Cut to it before the request.
400
+ "omnihuman-2-0": 300,
342
401
  // NB: `wan-2.7` / `wan-2.7-pro` are IMAGE models (see the image registry), not
343
402
  // video. The motion-transfer route's prompt is capped at the motion-control
344
403
  // limit (2500) inside the route itself — its provider values are the shared
@@ -600,6 +659,8 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
600
659
  "seedream-5-lite",
601
660
  "seedream-5-pro",
602
661
  "seedream-5-flash",
662
+ "minimax-h3-image",
663
+ "seedream-5-5",
603
664
  "flux",
604
665
  "flux-flex",
605
666
  // Image editing / image-to-image (reference = source image)
@@ -624,11 +685,14 @@ export const MODELS_WITH_REFERENCE_IMAGE_SUPPORT = new Set([
624
685
  "seedream-5-lite-i2i",
625
686
  "seedream-5-pro-i2i",
626
687
  "seedream-5-flash-i2i",
688
+ "minimax-h3-image-i2i",
689
+ "seedream-5-5-i2i",
627
690
  "grok-i2i",
628
691
  // Upscale / background ops (source acts as the reference)
629
692
  "recraft-remove-bg",
630
693
  "recraft-upscale",
631
694
  "topaz-image-upscale",
695
+ "nodaro-image-upscale",
632
696
  // Wan 2.7 — accepts up to 9 optional ref images via input_urls (pure T2I when omitted)
633
697
  "wan-2.7",
634
698
  // Replicate "Open" (uncensored) image models
@@ -663,6 +727,11 @@ export const T2I_TO_I2I_VARIANT: Record<string, string> = {
663
727
  "seedream-5-lite": "seedream-5-lite-i2i",
664
728
  "seedream-5-pro": "seedream-5-pro-i2i",
665
729
  "seedream-5-flash": "seedream-5-flash-i2i",
730
+ // MiniMax H3 Image: its text-to-image endpoint takes no image at all.
731
+ "minimax-h3-image": "minimax-h3-image-i2i",
732
+ // Seedream 5.5's text-to-image endpoint takes no image at all: its edit
733
+ // endpoint is the only one that reads them (the provider swaps too).
734
+ "seedream-5-5": "seedream-5-5-i2i",
666
735
  "flux": "flux-pro-i2i",
667
736
  "flux-flex": "flux-i2i",
668
737
  }
@@ -703,6 +772,10 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
703
772
  "seedream-5-pro-i2i": 16,
704
773
  // Flash takes at most 10 `image_urls` (docs.kie.ai/market/seedream/5-flash-image-to-image) — not the family's 16.
705
774
  "seedream-5-flash-i2i": 10,
775
+ // 1 to 16 `image_urls` (docs.kie.ai/market/minimax-h3/image-edit).
776
+ "minimax-h3-image-i2i": 16,
777
+ // Seedream 5.5 takes 1–10 `image_urls` (docs.kie.ai/market/seedream/5-5-image-to-image).
778
+ "seedream-5-5-i2i": 10,
706
779
  // Single-source i2i (one input image)
707
780
  "flux-kontext": 1,
708
781
  "flux-kontext-max": 1,
@@ -714,6 +787,7 @@ export const REF_IMAGE_MAX_LIMITS: Record<string, number> = {
714
787
  "recraft-remove-bg": 1,
715
788
  "recraft-upscale": 1,
716
789
  "topaz-image-upscale": 1,
790
+ "nodaro-image-upscale": 1,
717
791
  // Replicate Open models — Klein takes an optional single ref; Kontext Multi
718
792
  // (multi-image-kontext-pro) is a two-image combiner (input_image_1/2 only);
719
793
  // Flux 2 Pro up to 4; Max up to 8.
@@ -761,14 +835,19 @@ export function imageReferenceLimit(provider: string | undefined): number {
761
835
  export const DEFAULT_REQUEST_IMAGE_LIMIT = 14
762
836
 
763
837
  /**
764
- * Models a request may give more input images than
838
+ * Models whose request may carry a different number of input images than
765
839
  * {@link DEFAULT_REQUEST_IMAGE_LIMIT}. Separate from
766
840
  * {@link REF_IMAGE_MAX_LIMITS}, the cap the canvas and the assembler honour: the
767
- * routes have their own, lower ceiling, and it rises per model only here.
841
+ * routes have their own ceiling, and it moves per model only here. GPT Image
842
+ * 2.6 takes more; a model priced per input image whose provider takes fewer
843
+ * (Seedream 5.5: 10) is held to its own, so a request is refused before it is
844
+ * reserved instead of failing at the provider.
768
845
  */
769
846
  const REQUEST_IMAGE_LIMITS: Record<string, number> = {
770
847
  "gpt-image-2-6-flare-i2i": 16,
771
848
  "gpt-image-2-6-sunburst-i2i": 16,
849
+ "minimax-h3-image-i2i": 16,
850
+ "seedream-5-5-i2i": 10,
772
851
  }
773
852
 
774
853
  /** The largest per-model limit: the outer bound of the routes' array schemas. */
@@ -806,12 +885,17 @@ export const VARIABLE_PRICING_MODELS: Record<string, "quality" | "resolution" |
806
885
  "seedream-5-lite-i2i": "quality",
807
886
  "seedream-5-pro": "quality",
808
887
  "seedream-5-pro-i2i": "quality",
888
+ "seedream-5-5": "resolution",
889
+ "seedream-5-5-i2i": "resolution",
809
890
  "topaz-image-upscale": "resolution",
810
891
  "ideogram-edit": "rendering-speed",
811
892
  "ideogram-remix": "rendering-speed",
812
893
  "ideogram-v3": "rendering-speed",
813
894
  "wan-2.7": "resolution",
814
895
  "wan-2.7-pro": "resolution",
896
+ // Also priced per reference image on an edit (`minimaxH3ImageCreditId`).
897
+ "minimax-h3-image": "resolution",
898
+ "minimax-h3-image-i2i": "resolution",
815
899
  }
816
900
 
817
901
 
@@ -873,6 +957,8 @@ export const IMAGE_GEN_PROVIDERS = [
873
957
  "seedream-5-lite",
874
958
  "seedream-5-pro",
875
959
  "seedream-5-flash",
960
+ "minimax-h3-image",
961
+ "seedream-5-5",
876
962
  "flux-flex",
877
963
  "flux-kontext",
878
964
  "flux-kontext-max",
@@ -911,6 +997,8 @@ export const IMAGE_I2I_PROVIDERS = [
911
997
  "seedream-5-lite-i2i",
912
998
  "seedream-5-pro-i2i",
913
999
  "seedream-5-flash-i2i",
1000
+ "minimax-h3-image-i2i",
1001
+ "seedream-5-5-i2i",
914
1002
  "flux-kontext",
915
1003
  "flux-kontext-max",
916
1004
  // Replicate Open (uncensored) — multi-image Kontext via Replicate
@@ -942,6 +1030,8 @@ export const IMAGE_EDIT_PROVIDERS = [
942
1030
  "recraft-remove-bg",
943
1031
  "nano-banana-edit",
944
1032
  "topaz-image-upscale",
1033
+ // Nodaro Image Upscale: 1x to 8x, priced by the output's size.
1034
+ "nodaro-image-upscale",
945
1035
  // Grok Imagine 2 task-chained ops — a prior grok-2 generation's task_id (NOT
946
1036
  // an image URL); see the edit-image route for the taskId-vs-imageUrl
947
1037
  // branching. grok-2-edit: prompt edit of a prior grok-2 generation,
@@ -981,6 +1071,7 @@ export type ModifyImageProvider = typeof MODIFY_IMAGE_PROVIDERS[number]
981
1071
  export const UPSCALE_IMAGE_PROVIDERS = [
982
1072
  "recraft-upscale",
983
1073
  "topaz-image-upscale",
1074
+ "nodaro-image-upscale",
984
1075
  ] as const
985
1076
  export type UpscaleImageProvider = typeof UPSCALE_IMAGE_PROVIDERS[number]
986
1077
 
@@ -1034,9 +1125,16 @@ export const IMAGE_TO_VIDEO_PROVIDERS = [
1034
1125
  // listed here AND in TEXT_TO_VIDEO_PROVIDERS's main section (like wan-3).
1035
1126
  "kling-4",
1036
1127
  "kling-4-keyframes",
1128
+ // Kling 4.0 Flash — one id over KIE's two Flash endpoints (picked by what is
1129
+ // wired); both run with no image, so it is listed in both arrays too.
1130
+ "kling-4-flash",
1131
+ // PixVerse V6 Max — one id over KIE's image-to-video and text-to-video
1132
+ // endpoints (picked by whether a start frame is wired), so it is listed in
1133
+ // this array AND in TEXT_TO_VIDEO_PROVIDERS's main section.
1134
+ "pixverse-v6-max",
1037
1135
  "ltx-2.3-pro",
1038
1136
  "ltx-2.3-fast",
1039
- // xAI Grok Imagine Video 1.5 — KIE i2v (image_urls required). Also listed in
1137
+ // xAI Grok Imagine Video 1.5 — KIE i2v (a start image required). Also listed in
1040
1138
  // TEXT_TO_VIDEO_PROVIDERS so it's offered everywhere in the unified node; the
1041
1139
  // t2v route guards no-image runs via VIDEO_PROVIDERS_REQUIRING_IMAGE.
1042
1140
  "grok-imagine-video-1.5",
@@ -1082,6 +1180,9 @@ export const TEXT_TO_VIDEO_PROVIDERS = [
1082
1180
  // no materials, keyframe-to-video with no frame).
1083
1181
  "kling-4",
1084
1182
  "kling-4-keyframes",
1183
+ "kling-4-flash",
1184
+ // PixVerse V6 Max — a real text-to-video endpoint runs an image-less request.
1185
+ "pixverse-v6-max",
1085
1186
  "ltx-2.3-pro",
1086
1187
  "ltx-2.3-fast",
1087
1188
  // ── i2v-only providers (image required) ──────────────────────────────────
@@ -1165,9 +1266,14 @@ export const VIDEO_MODE_ALIASES: readonly VideoModeAlias[] = [
1165
1266
  * - `seedance` (Seedance 1.5 Pro, KIE `bytedance/seedance-1.5-pro`): retired
1166
1267
  * upstream 2026-10-25 (KIE answers 410). Runs as Seedance 2 Mini, the
1167
1268
  * cheapest Seedance left (owner's decision 2026-10-25).
1269
+ * - `seedance-2-extend` (the one Seedance Extend Video provider, its model
1270
+ * chosen by the deployment): split 2026-11-11 into one provider per model.
1271
+ * Runs as `seedance-2-5-extend`, the Seedance 2.5 extend, and is priced on
1272
+ * its rows; `seedance-2-0-extend` is the Seedance 2.0 one.
1168
1273
  */
1169
1274
  export const RETIRED_VIDEO_PROVIDERS: Readonly<Record<string, string>> = {
1170
1275
  seedance: "seedance-2-mini",
1276
+ "seedance-2-extend": "seedance-2-5-extend",
1171
1277
  }
1172
1278
 
1173
1279
  /** A retired video model id becomes the id it runs as; any other value passes through unchanged. Own properties only. */
@@ -1256,12 +1362,15 @@ export function videoProviderReferenceSyntax(provider: string | undefined): Vide
1256
1362
  * Reference-capable video models whose start/end frames ride a channel of
1257
1363
  * their OWN (separate frame parameters next to the reference list), so a frame
1258
1364
  * never occupies a reference seat: `kling-3-omni` (Replicate `start_image` /
1259
- * `end_image`, no dispatch path today) and Kling 4.0 Keyframes (KIE
1260
- * `first_frame_url` / `last_frame_url` beside its in-between `keyframe_urls`).
1365
+ * `end_image`, no dispatch path today), Kling 4.0 Keyframes (KIE
1366
+ * `first_frame_url` / `last_frame_url` beside its in-between `keyframe_urls`)
1367
+ * and Grok Imagine Video 1.5 (KIE `first_frame_url` / `last_frame_url` /
1368
+ * `loop_url` beside its in-between `keyframes`).
1261
1369
  */
1262
1370
  export const VIDEO_PROVIDERS_WITH_SEPARATE_FRAME_CHANNEL: ReadonlySet<string> = new Set([
1263
1371
  "kling-3-omni",
1264
1372
  "kling-4-keyframes",
1373
+ "grok-imagine-video-1.5",
1265
1374
  ])
1266
1375
 
1267
1376
  /**
@@ -1374,6 +1483,17 @@ export const DEFAULT_VIDEO_TO_VIDEO_PROVIDER: VideoToVideoNodeProvider = "wan"
1374
1483
  */
1375
1484
  export const SEEDANCE_VIDEO_EDIT_SHAPE = { aspectRatio: "adaptive", duration: VIDEO_DURATION_AUTO } as const
1376
1485
 
1486
+ /**
1487
+ * The reference task type a purpose-built Seedance video edit requests (the
1488
+ * Video to Video route and node, MCP `modify_video`): the reference video is
1489
+ * the clip to edit, said outright instead of left to the prompt. A request, not
1490
+ * a promise: `resolveSeedanceTaskType` declares it only when the edit's
1491
+ * reference videos qualify, and otherwise the edit goes out undeclared, as
1492
+ * before. Kept apart from `SEEDANCE_VIDEO_EDIT_SHAPE`, whose exact value other
1493
+ * callers spread and pin.
1494
+ */
1495
+ export const SEEDANCE_VIDEO_EDIT_TASK_TYPE = "edit" as const satisfies DeclaredSeedanceTaskType
1496
+
1377
1497
  /** Face swap providers */
1378
1498
  export const FACE_SWAP_PROVIDERS = [
1379
1499
  "roop",
@@ -1388,6 +1508,10 @@ export const VIDEO_UPSCALE_PROVIDERS = [
1388
1508
  // Seedance 2.5 Draft finalize: re-renders a Seedance 2.5 DRAFT (by its task
1389
1509
  // id) as the same take at 1080p. See seedance-draft.ts.
1390
1510
  "seedance-2-5-hd",
1511
+ // Nodaro Video Upscale: any clip up to 60 s / 50 MB into a 1080p, 2K or 4K
1512
+ // box, priced per second. Offered only where the deployment serves it (see
1513
+ // nodaro-video-upscale.ts).
1514
+ "nodaro-video-upscale",
1391
1515
  ] as const
1392
1516
  export type VideoUpscaleProvider = typeof VIDEO_UPSCALE_PROVIDERS[number]
1393
1517
 
@@ -1396,10 +1520,51 @@ export const EXTEND_VIDEO_PROVIDERS = [
1396
1520
  "veo-extend",
1397
1521
  "runway-extend",
1398
1522
  "ltx-2.3-pro",
1399
- "seedance-2-extend",
1523
+ // Seedance extends ANY video, one provider per model: Seedance 2.5 (4–30 s
1524
+ // added) and Seedance 2.0 (4–15 s), each priced on its own rows
1525
+ // (`tailExtendCreditId`). The earlier single id `seedance-2-extend` is
1526
+ // retired (RETIRED_VIDEO_PROVIDERS) and runs as Seedance 2.5.
1527
+ "seedance-2-5-extend",
1528
+ "seedance-2-0-extend",
1529
+ // Kling 4 extends ANY video the same way (3–30 s added, 720p / 1080p, its
1530
+ // sound always on), generated on Kling 4.0 and priced on its own rows.
1531
+ "kling-4-extend",
1400
1532
  ] as const
1401
1533
  export type ExtendVideoProvider = typeof EXTEND_VIDEO_PROVIDERS[number]
1402
1534
 
1535
+ /** The Extend Video providers that run on Seedance, one per model. */
1536
+ export type SeedanceExtendProvider = Extract<ExtendVideoProvider, "seedance-2-5-extend" | "seedance-2-0-extend">
1537
+ const SEEDANCE_EXTEND_PROVIDERS: readonly SeedanceExtendProvider[] = ["seedance-2-5-extend", "seedance-2-0-extend"]
1538
+
1539
+ /**
1540
+ * Whether a value is one of the Seedance Extend Video providers. A retired id
1541
+ * answers false: pass it through {@link canonicalVideoProvider} first. It
1542
+ * decides the levers only Seedance has (reference images, the sound switch);
1543
+ * the length, the resolution and the price follow {@link isTailExtendProvider}.
1544
+ */
1545
+ export function isSeedanceExtendProvider(p: unknown): p is SeedanceExtendProvider {
1546
+ return typeof p === "string" && (SEEDANCE_EXTEND_PROVIDERS as readonly string[]).includes(p)
1547
+ }
1548
+
1549
+ /**
1550
+ * The Extend Video providers that continue a video from its tail: the
1551
+ * source's last frame opens the new footage and its last seconds ride as the
1552
+ * `@video_1` reference, then the two are stitched into one clip. Each has its
1553
+ * own catalog entry (its seconds added and resolutions) and price rows, one
1554
+ * per second and resolution (`tailExtendCreditId`).
1555
+ */
1556
+ export type TailExtendProvider = SeedanceExtendProvider | Extract<ExtendVideoProvider, "kling-4-extend">
1557
+ const TAIL_EXTEND_PROVIDERS: readonly TailExtendProvider[] = [...SEEDANCE_EXTEND_PROVIDERS, "kling-4-extend"]
1558
+
1559
+ /**
1560
+ * Whether a value is one of the tail-recipe Extend Video providers
1561
+ * ({@link TailExtendProvider}). A retired id answers false: pass it through
1562
+ * {@link canonicalVideoProvider} first.
1563
+ */
1564
+ export function isTailExtendProvider(p: unknown): p is TailExtendProvider {
1565
+ return typeof p === "string" && (TAIL_EXTEND_PROVIDERS as readonly string[]).includes(p)
1566
+ }
1567
+
1403
1568
  /** Lip sync providers */
1404
1569
  export const LIP_SYNC_PROVIDERS = [
1405
1570
  "kling-avatar",
@@ -1409,6 +1574,11 @@ export const LIP_SYNC_PROVIDERS = [
1409
1574
  // performance, per-second billed, 60s audio cap. Routes the default KIE
1410
1575
  // path (not in any replicate/fal/seedance/video-input set).
1411
1576
  "omnihuman-1-5",
1577
+ // ByteDance OmniHuman 2.0 — a different model from 1.5 (no speaker mask, no
1578
+ // resolution choice, no fast mode, no seed; 720p output). KIE image+audio
1579
+ // avatar on the default KIE path, charged per second of its audio at a rate
1580
+ // (LIP_SYNC_AUDIO_RATES), never by bucket.
1581
+ "omnihuman-2-0",
1412
1582
  "latentsync",
1413
1583
  "wav2lip",
1414
1584
  "video-retalking",
@@ -1631,12 +1801,14 @@ export function resolveMusicProvider(value: unknown): MusicProvider {
1631
1801
  * (the canvas picker re-offered the two Replicate lanes in #768 while this enum
1632
1802
  * still hid them, so a single-node Run on Whisper 400'd where the same node in a
1633
1803
  * workflow Run worked). `elevenlabs-stt` stays FIRST: several call sites take
1634
- * "the first enabled word-capable provider" from this order.
1804
+ * "the first enabled word-capable provider" from this order. A new engine goes
1805
+ * at the END (Nemotron 3.5 Transcribe, 2026-11-12), so that answer never moves.
1635
1806
  */
1636
1807
  export const TRANSCRIBE_PROVIDERS = [
1637
1808
  "elevenlabs-stt",
1638
1809
  "whisper",
1639
1810
  "incredibly-fast-whisper",
1811
+ "nemotron-3-5-transcribe",
1640
1812
  ] as const
1641
1813
  export type TranscribeProvider = typeof TRANSCRIBE_PROVIDERS[number]
1642
1814
 
@@ -1652,6 +1824,7 @@ export const TRANSCRIBE_LANES = [
1652
1824
  "whisper",
1653
1825
  "incredibly-fast-whisper",
1654
1826
  "elevenlabs-stt",
1827
+ "nemotron-3-5-transcribe",
1655
1828
  ] as const
1656
1829
  export type TranscribeLane = typeof TRANSCRIBE_LANES[number]
1657
1830
 
@@ -1660,6 +1833,22 @@ export type TranscribeLane = typeof TRANSCRIBE_LANES[number]
1660
1833
  const _TRANSCRIBE_PROVIDERS_ARE_LANES: readonly TranscribeLane[] = TRANSCRIBE_PROVIDERS
1661
1834
  void _TRANSCRIBE_PROVIDERS_ARE_LANES
1662
1835
 
1836
+ /**
1837
+ * The lanes Add Captions may transcribe on (its `transcribe_provider`, on the
1838
+ * route, MCP `add_captions` and the SDK's `media.addCaptions`). Add Captions
1839
+ * charges its own flat render price (`add-captions`, `add-captions:kinetic`)
1840
+ * and reserves nothing for the transcription it runs inside, so a lane priced
1841
+ * by the file's length (Nemotron 3.5 Transcribe, per minute) is not one of
1842
+ * them: it would run unpriced inside the render. Kept to the lanes it offered
1843
+ * before Nemotron (2026-11-12); widening it is a pricing decision, not a sync.
1844
+ */
1845
+ export const CAPTION_TRANSCRIBE_LANES = [
1846
+ "whisper",
1847
+ "incredibly-fast-whisper",
1848
+ "elevenlabs-stt",
1849
+ ] as const satisfies readonly TranscribeLane[]
1850
+ export type CaptionTranscribeLane = typeof CAPTION_TRANSCRIBE_LANES[number]
1851
+
1663
1852
  /**
1664
1853
  * What each transcription lane can actually DO. Single source of truth — never
1665
1854
  * re-derive a capability from a provider-name check.
@@ -1671,11 +1860,44 @@ void _TRANSCRIBE_PROVIDERS_ARE_LANES
1671
1860
  * for word timings yields an empty array, never an error.
1672
1861
  * - `incredibly-fast-whisper` — yes, via `timestamp: "word"`.
1673
1862
  * - `elevenlabs-stt` (direct Scribe) — always word-level, flag or not.
1863
+ * - `nemotron-3-5-transcribe` (KIE) — yes, with a speaker per word, via
1864
+ * `timestamps: true` (transcription only: never with a translation).
1865
+ *
1866
+ * `translation`: can the lane translate the speech instead of transcribing it
1867
+ * (`targetLanguage`)? Only Nemotron 3.5 Transcribe, to or from English, and
1868
+ * never together with word timings (KIE refuses the pair).
1869
+ */
1870
+ export const TRANSCRIBE_PROVIDER_CAPABILITIES: Record<TranscribeLane, { wordTimestamps: boolean; translation: boolean }> = {
1871
+ "whisper": { wordTimestamps: false, translation: false },
1872
+ "incredibly-fast-whisper": { wordTimestamps: true, translation: false },
1873
+ "elevenlabs-stt": { wordTimestamps: true, translation: false },
1874
+ "nemotron-3-5-transcribe": { wordTimestamps: true, translation: true },
1875
+ }
1876
+
1877
+ /**
1878
+ * The languages Nemotron 3.5 Transcribe translates INTO (KIE's
1879
+ * `target_language` enum, ISO 639-1). Translation is supported to or from
1880
+ * English: other speech into `en`, or English speech into any other listed
1881
+ * language. Fewer than the 40 it transcribes.
1882
+ */
1883
+ export const TRANSCRIBE_TARGET_LANGUAGES = [
1884
+ "en", "zh", "ja", "ko", "fr", "de", "es", "pt", "it", "ru", "nl", "pl", "cs", "sk", "hi", "bg",
1885
+ "hr", "da", "et", "fi", "hu", "lv", "lt", "ro", "sl", "sv", "th", "uk", "ar", "el", "he", "mt",
1886
+ ] as const
1887
+ export type TranscribeTargetLanguage = typeof TRANSCRIBE_TARGET_LANGUAGES[number]
1888
+
1889
+ /** The lanes that can translate, in declaration order. */
1890
+ export function transcribeProvidersWithTranslation(): TranscribeLane[] {
1891
+ return TRANSCRIBE_LANES.filter((p) => TRANSCRIBE_PROVIDER_CAPABILITIES[p].translation)
1892
+ }
1893
+
1894
+ /**
1895
+ * Capability question for a lane id from UNTRUSTED data (node data, an
1896
+ * imported workflow, a wire body): an unknown lane answers `false`.
1674
1897
  */
1675
- export const TRANSCRIBE_PROVIDER_CAPABILITIES: Record<TranscribeLane, { wordTimestamps: boolean }> = {
1676
- "whisper": { wordTimestamps: false },
1677
- "incredibly-fast-whisper": { wordTimestamps: true },
1678
- "elevenlabs-stt": { wordTimestamps: true },
1898
+ export function transcribeLaneSupportsTranslation(lane: string | null | undefined): boolean {
1899
+ if (!lane) return false
1900
+ return TRANSCRIBE_PROVIDER_CAPABILITIES[lane as TranscribeLane]?.translation === true
1679
1901
  }
1680
1902
 
1681
1903
  /** The lanes that can honour a word-timestamps request, in declaration order. */
@@ -1859,6 +2081,8 @@ export const IMAGE_MASK_MODE: Record<ImageGenProvider, ImageMaskMode> = {
1859
2081
  "seedream-5-lite": "prompt",
1860
2082
  "seedream-5-pro": "prompt",
1861
2083
  "seedream-5-flash": "prompt",
2084
+ "minimax-h3-image": "prompt",
2085
+ "seedream-5-5": "prompt",
1862
2086
  "qwen": "prompt",
1863
2087
  "flux-kontext": "prompt",
1864
2088
  "flux-kontext-max": "prompt",
@@ -1890,6 +2114,7 @@ export const SEED_SUPPORT = new Set([
1890
2114
  "qwen", "qwen-i2i", "qwen-edit",
1891
2115
  "flux", "flux-flex", "flux-i2i", "flux-pro-i2i", "flux-kontext", "flux-kontext-max",
1892
2116
  "flux-2-klein", "kontext-multi",
2117
+ "minimax-h3-image", "minimax-h3-image-i2i",
1893
2118
  ])
1894
2119
 
1895
2120
  /** Ideogram models that support rendering_speed selection (TURBO/BALANCED/QUALITY) */
@@ -1914,7 +2139,6 @@ export const GUIDANCE_SCALE_SUPPORT: Record<string, { min: number; max: number;
1914
2139
  * TODO: Run verification script and update costs after confirming actual KIE pricing.
1915
2140
  */
1916
2141
  export const DURATION_PRICED_PROVIDERS = new Set([
1917
- "seedance-2-extend",
1918
2142
  "kling-3.0",
1919
2143
  "kling-3-omni",
1920
2144
  "kling",
@@ -1947,10 +2171,16 @@ export const DURATION_PRICED_PROVIDERS = new Set([
1947
2171
  // video rate on `kling-4`, see VIDEO_REF_RATE_PROVIDERS).
1948
2172
  "kling-4",
1949
2173
  "kling-4-keyframes",
2174
+ // Kling 4.0 Flash — per-second billing at 720p, the same rate on both
2175
+ // endpoints, plus a reference-video rate (VIDEO_REF_RATE_PROVIDERS).
2176
+ "kling-4-flash",
1950
2177
  // Gemini Omni Flash 1.2 — per-second billing at four resolution rates. The
1951
2178
  // only Omni SKU here: the per-clip SKUs price in their own branch of
1952
2179
  // buildVideoCreditModelIdentifier.
1953
2180
  "gemini-omni-flash-1-2",
2181
+ // PixVerse V6 Max — per-second billing at four quality rates, each with and
2182
+ // without native audio (the `:audio` rows, AUDIO_ADDON_PROVIDERS).
2183
+ "pixverse-v6-max",
1954
2184
  ])
1955
2185
 
1956
2186
  /**
@@ -2141,6 +2371,140 @@ export function kling4KeyframeFrameCap(durationSec: number | string | undefined)
2141
2371
  return Math.min(10, d + 1)
2142
2372
  }
2143
2373
 
2374
+ /**
2375
+ * Kling 4.0 Flash — ONE Nodaro id over KIE's two Flash endpoints
2376
+ * (`kling-4.0/flash-reference-to-video` and `kling-4.0/flash-keyframe-to-video`),
2377
+ * picked by what is wired: a start frame alone runs on the keyframe endpoint,
2378
+ * everything else on the reference endpoint (backend `kling4.ts`).
2379
+ *
2380
+ * Deliberately NOT a member of {@link KLING_4_PROVIDERS}: that set's branches
2381
+ * carry Kling 4.0's 1080p tier, its `voices` array, its Keyframes frame table
2382
+ * and its materials rule, none of which Flash has. Every place Flash shares
2383
+ * with Kling 4.0 opts in explicitly ({@link isKling4RunnerProvider}).
2384
+ */
2385
+ export const KLING_4_FLASH_PROVIDER = "kling-4-flash"
2386
+
2387
+ export function isKling4FlashProvider(provider: string | undefined): provider is "kling-4-flash" {
2388
+ return provider === KLING_4_FLASH_PROVIDER
2389
+ }
2390
+
2391
+ /** The one resolution Kling 4.0 Flash renders (both schemas: `720p` only). */
2392
+ export const KLING_4_FLASH_RESOLUTION = "720p"
2393
+
2394
+ /**
2395
+ * Every id the bespoke Kling 4.0 runner serves — Kling 4.0, its Keyframes twin
2396
+ * and Flash. Read only where the three behave the same: the provider dispatch,
2397
+ * the image normalization, the editor's UI defaults (aspect `auto`, 720p, 5s).
2398
+ * Anything about resolutions, frames, voices or the materials budget asks
2399
+ * {@link isKling4Provider} or {@link isKling4FlashProvider} instead.
2400
+ */
2401
+ export function isKling4RunnerProvider(provider: string | undefined): provider is "kling-4" | "kling-4-keyframes" | "kling-4-flash" {
2402
+ return isKling4Provider(provider) || isKling4FlashProvider(provider)
2403
+ }
2404
+
2405
+ /**
2406
+ * Grok Imagine Video 1.5 — KIE `grok-imagine-video-1-5-preview`
2407
+ * (docs.kie.ai/market/grok-imagine/1-5-preview), built by the backend's bespoke
2408
+ * runner (`kie/grok-video-15.ts`). Image to video: the start frame is the exact
2409
+ * first frame, an end frame the exact last frame (one picture wired as both is
2410
+ * a seamless loop), and the Image References are up to
2411
+ * {@link GROK_VIDEO_15_MAX_MIDDLE_FRAMES} in-between frames, each placed at a
2412
+ * whole second inside the clip.
2413
+ */
2414
+ export const GROK_VIDEO_15_PROVIDER = "grok-imagine-video-1.5"
2415
+
2416
+ export function isGrokVideo15Provider(provider: string | undefined): provider is "grok-imagine-video-1.5" {
2417
+ return provider === GROK_VIDEO_15_PROVIDER
2418
+ }
2419
+
2420
+ /** Grok Imagine Video 1.5 resolution rendered when the param is omitted or
2421
+ * unknown — KIE's own default and the tier the bare credit identifier prices. */
2422
+ export const GROK_VIDEO_15_DEFAULT_RESOLUTION = "480p"
2423
+
2424
+ /**
2425
+ * SINGLE normalization for the Grok Imagine Video 1.5 resolution lever. The KIE
2426
+ * wire enum is lowercase (`480p` | `720p` | `1080p`), the same spelling as the
2427
+ * catalog and the credit identifiers; this folds case and collapses anything
2428
+ * else to {@link GROK_VIDEO_15_DEFAULT_RESOLUTION}. The runner sends what this
2429
+ * returns and the credit identifier bills what this returns.
2430
+ */
2431
+ export function normalizeGrokVideo15Resolution(resolution: string | undefined): "480p" | "720p" | "1080p" {
2432
+ const r = resolution?.trim().toLowerCase()
2433
+ return r === "720p" || r === "1080p" ? r : GROK_VIDEO_15_DEFAULT_RESOLUTION
2434
+ }
2435
+
2436
+ /** Most in-between frames Grok Imagine Video 1.5 takes (KIE `keyframes`). */
2437
+ export const GROK_VIDEO_15_MAX_MIDDLE_FRAMES = 4
2438
+
2439
+ /**
2440
+ * PixVerse V6 Max — ONE Nodaro id over KIE's two V6 Max endpoints
2441
+ * (`pixverse-v6-max/image-to-video` with a start frame,
2442
+ * `pixverse-v6-max/text-to-video` without one), built by the backend's bespoke
2443
+ * runner (`kie/pixverse-v6-max.ts`).
2444
+ */
2445
+ export const PIXVERSE_V6_MAX_PROVIDER = "pixverse-v6-max"
2446
+
2447
+ export function isPixverseV6MaxProvider(provider: string | undefined): provider is "pixverse-v6-max" {
2448
+ return provider === PIXVERSE_V6_MAX_PROVIDER
2449
+ }
2450
+
2451
+ /** PixVerse V6 Max quality rendered when the param is omitted or unknown — the
2452
+ * tier the bare credit identifier prices. Never `resolutions[0]`, the 360p
2453
+ * preview tier. (KIE requires a quality; it has no default of its own.) */
2454
+ export const PIXVERSE_V6_MAX_DEFAULT_QUALITY = "720p"
2455
+
2456
+ /**
2457
+ * SINGLE normalization for the PixVerse V6 Max quality lever (KIE `quality`,
2458
+ * the platform's `resolution`). The wire enum is lowercase (`360p` | `540p` |
2459
+ * `720p` | `1080p`), the same spelling as the catalog and the credit
2460
+ * identifiers; this folds case and collapses anything else to
2461
+ * {@link PIXVERSE_V6_MAX_DEFAULT_QUALITY}. The runner sends what this returns
2462
+ * and the credit identifier bills what this returns.
2463
+ */
2464
+ export function normalizePixverseV6MaxQuality(resolution: string | undefined): "360p" | "540p" | "720p" | "1080p" {
2465
+ const r = resolution?.trim().toLowerCase()
2466
+ return r === "360p" || r === "540p" || r === "1080p" ? r : PIXVERSE_V6_MAX_DEFAULT_QUALITY
2467
+ }
2468
+
2469
+ /**
2470
+ * How many in-between frames a Grok Imagine Video 1.5 clip of `durationSec`
2471
+ * seconds carries. The node has no per-frame time, so the frames sit at whole
2472
+ * seconds strictly inside the clip, no two on the same second (decided
2473
+ * 2026-11-11): a D-second clip has D − 1 such seconds, and KIE takes at most
2474
+ * {@link GROK_VIDEO_15_MAX_MIDDLE_FRAMES}. Frames past this count are left out
2475
+ * (the runner logs it), never refused.
2476
+ */
2477
+ export function grokVideo15MiddleFrameSlots(durationSec: number | string | undefined): number {
2478
+ // The length the run renders: the catalog's default when unset, else the
2479
+ // nearest legal second — the same funnel the price reads.
2480
+ const d = pricedOutputDurationSec(GROK_VIDEO_15_PROVIDER, Number.isFinite(Number(durationSec)) ? durationSec : undefined)
2481
+ return Math.max(0, Math.min(GROK_VIDEO_15_MAX_MIDDLE_FRAMES, d - 1))
2482
+ }
2483
+
2484
+ /**
2485
+ * How many in-between frames (the Image References of a catalog `keyframes`
2486
+ * model) a run takes, given its length and which end frames are wired —
2487
+ * undefined for a model whose references are not frames. The editor's handle
2488
+ * cap and panel count read this, so the two cannot disagree.
2489
+ *
2490
+ * - Kling 4.0 Keyframes: the start and end frames share the clip's frame cap
2491
+ * ({@link kling4KeyframeFrameCap}), at most {@link KLING_4_MAX_MIDDLE_FRAMES}.
2492
+ * - Grok Imagine Video 1.5: {@link grokVideo15MiddleFrameSlots}; the start and
2493
+ * end frames ride their own fields and take no slot.
2494
+ */
2495
+ export function videoKeyframesMiddleCap(
2496
+ provider: string | undefined,
2497
+ durationSec: number | string | undefined,
2498
+ frames: { readonly hasStartFrame: boolean; readonly hasEndFrame: boolean },
2499
+ ): number | undefined {
2500
+ if (isGrokVideo15Provider(provider)) return grokVideo15MiddleFrameSlots(durationSec)
2501
+ if (provider === "kling-4-keyframes") {
2502
+ const ends = (frames.hasStartFrame ? 1 : 0) + (frames.hasEndFrame ? 1 : 0)
2503
+ return Math.max(0, Math.min(KLING_4_MAX_MIDDLE_FRAMES, kling4KeyframeFrameCap(durationSec) - ends))
2504
+ }
2505
+ return undefined
2506
+ }
2507
+
2144
2508
  /**
2145
2509
  * Google Gemini Omni family — the KIE "gemini-omni-video" market model and its
2146
2510
  * faster/cheaper "google/gemini-omni-flash-1-1" sibling. Both take the SAME
@@ -2246,6 +2610,12 @@ export const GVP_DEFAULT_PROVIDER = "seedance-2"
2246
2610
  * `seedance-2-mini` re-enters selection here (it was withdrawn by hand on
2247
2611
  * 2026-07-21). It qualifies on capability and is the cheapest Seedance-2 SKU,
2248
2612
  * which makes it the natural pick for cheap iteration on long runs.
2613
+ *
2614
+ * The ONE exception to the reference-image bar is explicit, per model: a
2615
+ * catalog `gvpWithoutReferences` (PixVerse V6 Max, decided 2026-11-12) admits
2616
+ * a model that takes a start frame but no reference images, on keyframes from
2617
+ * its start anchor or text alone. The capability bar itself is unchanged, so
2618
+ * no other start-frame-only model (wan-i2v, hailuo, bytedance) rides in.
2249
2619
  */
2250
2620
  function deriveGvpSupportedProviders(): VideoGenProvider[] {
2251
2621
  const dispatchable = new Set<string>(VIDEO_GEN_PROVIDERS as readonly string[])
@@ -2254,7 +2624,7 @@ function deriveGvpSupportedProviders(): VideoGenProvider[] {
2254
2624
  (m) =>
2255
2625
  m.kind === "video" &&
2256
2626
  (m.modes as readonly string[]).includes("i2v") &&
2257
- m.features?.includes("reference-image") === true &&
2627
+ (m.features?.includes("reference-image") === true || m.gvpWithoutReferences === true) &&
2258
2628
  (m.durations?.length ?? 0) > 0 &&
2259
2629
  // Must also be dispatchable by the unified video node — the pro route
2260
2630
  // hands the provider id straight to the app's imageToVideo.
@@ -2372,19 +2742,27 @@ export type GvpAnchorWireMode = "upfront" | "progressive" | "none"
2372
2742
  * here would mean duplicating the plugin's `MAX_SEGMENTS` cap in this repo
2373
2743
  * where nothing could keep the two in step.
2374
2744
  */
2375
- export function resolveGvpAnchorWire(choice: string | undefined): GvpAnchorWireMode | undefined {
2745
+ export function resolveGvpAnchorWire(choice: string | undefined, provider?: string): GvpAnchorWireMode | undefined {
2376
2746
  switch (choice) {
2377
2747
  case "start-end":
2378
2748
  return "upfront"
2379
2749
  case "start-only":
2380
2750
  return "progressive"
2381
2751
  case "reference":
2382
- return "none"
2752
+ // A model with no reference images has nothing to carry a reference-
2753
+ // driven shot (`gvpWithoutReferences`): it runs as Auto instead.
2754
+ return gvpTakesReferenceImages(provider) ? "none" : undefined
2383
2755
  default:
2384
2756
  return undefined
2385
2757
  }
2386
2758
  }
2387
2759
 
2760
+ /** Whether a Generate Video Pro segment can send reference images to this model. */
2761
+ function gvpTakesReferenceImages(provider: string | undefined): boolean {
2762
+ if (!provider) return true // no model named: the choice is the caller's, as before
2763
+ return MODEL_CATALOG[provider]?.gvpWithoutReferences !== true
2764
+ }
2765
+
2388
2766
  // ---------------------------------------------------------------------------
2389
2767
  // SEGMENT BOUNDS — pure catalog readers. The generate-video-pro splitter (in
2390
2768
  // three places: the plugin engine, the money closed-form, the UI estimate)
@@ -2509,8 +2887,8 @@ export const SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC = 1.8
2509
2887
  export const SEEDANCE_2_CONTINUATION_REF_SEC = 2
2510
2888
 
2511
2889
  /**
2512
- * Trim-stitch parameters for the seedance-2-extend provider (spike-validated
2513
- * 2026-06-11):
2890
+ * Trim-stitch parameters for the Seedance Extend Video providers
2891
+ * (`seedance-2-5-extend`, `seedance-2-0-extend`; spike-validated 2026-06-11):
2514
2892
  * the model's extension output wobbles for its first ~3 frames and the source
2515
2893
  * tail's last ~4 frames lead into it; dropping both and butt-joining yields a
2516
2894
  * seam SMOOTHER than ordinary in-clip motion (PSNR 34.4dB vs 30.6dB
@@ -2675,6 +3053,15 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
2675
3053
  * (`videoCharacterRefProblem`).
2676
3054
  */
2677
3055
  materials?: number
3056
+ /**
3057
+ * Reference audio rides ON a character subject (its voice), not as a
3058
+ * material of its own: clip N belongs to wired character N, in the order
3059
+ * the characters arrive, and takes no seat in `materials`. A character with
3060
+ * fewer than 2 images is no subject and cannot carry a voice, so its clip
3061
+ * is dropped, as is a clip past the last character (Kling 4.0 Flash: KIE
3062
+ * `elements[].voice_url`, no standalone `voices`).
3063
+ */
3064
+ audioBindsToCharacters?: true
2678
3065
  } | undefined
2679
3066
  > = {
2680
3067
  // Seedance 2 — full multimodal caps.
@@ -2724,6 +3111,13 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
2724
3111
  // (`keyframe_urls`, max 8; the clip's duration lowers the cap, see
2725
3112
  // kling4KeyframeFrameCap). No reference videos or audio.
2726
3113
  "kling-4-keyframes": { images: KLING_4_MAX_MIDDLE_FRAMES },
3114
+ // Kling 4.0 Flash (reference endpoint) — 10 images, 5 videos, 7 subjects,
3115
+ // 15 in all (docs.kie.ai/market/kling/v4-flash-reference-to-video). No
3116
+ // standalone voices: reference audio clip N becomes wired character N's voice
3117
+ // (`voice_url`) when that character is a subject (2-4 images), so at most one
3118
+ // per character (7) and none takes a material seat. A wired start frame takes one of the 10 image slots when it
3119
+ // runs on this endpoint.
3120
+ "kling-4-flash": { images: 10, videos: 5, audio: 7, characters: 7, materials: 15, audioBindsToCharacters: true },
2727
3121
  "grok-i2v": { images: 7 }, // backend kie/models.ts maxRefImages: 7
2728
3122
  "happyhorse-ref2v": { images: 9 }, // backend kie/models.ts maxRefImages: 9
2729
3123
  // VEO 3.x — REFERENCE_2_VIDEO path caps refs at 3 (kie/video.ts slices to
@@ -2735,12 +3129,18 @@ export const VIDEO_REF_LIMITS_BY_PROVIDER: Record<
2735
3129
  // flips a Quality call to REFERENCE_2_VIDEO.
2736
3130
  "veo3.1": { images: 3 },
2737
3131
  "veo3_lite": { images: 3 },
2738
- // NOTE: wan-i2v / hailuo-2.3[-pro] / bytedance-pro[-fast] / grok-imagine-video-1.5
2739
- // are deliberately ABSENT. The 2026-06-28 audit (video-reference-features.test.ts)
2740
- // verified backend reference-forwarding paths and these i2v models have none —
2741
- // a single image_url start frame only. Advertising a ref cap would silently drop
2742
- // the user's references (the grok-imagine-video-1.5 bug). Add only with a
2743
- // verified provider path + the catalog `reference-image` feature.
3132
+ // Grok Imagine Video 1.5 — the Image References are its in-between frames
3133
+ // (KIE `keyframes`, max 4; the clip's length lowers the count, see
3134
+ // grokVideo15MiddleFrameSlots). They are frames only, never `image_urls`
3135
+ // references, and need the start frame. No reference videos or audio.
3136
+ "grok-imagine-video-1.5": { images: GROK_VIDEO_15_MAX_MIDDLE_FRAMES },
3137
+ // NOTE: wan-i2v / hailuo-2.3[-pro] / bytedance-pro[-fast] are deliberately
3138
+ // ABSENT. The 2026-06-28 audit (video-reference-features.test.ts) verified
3139
+ // backend reference-forwarding paths and these i2v models have none — a
3140
+ // single image_url start frame only. Advertising a ref cap would silently
3141
+ // drop the user's references (grok-imagine-video-1.5 had that bug before its
3142
+ // in-between frames were wired). Add only with a verified provider path + the
3143
+ // catalog `reference-image` feature.
2744
3144
  }
2745
3145
 
2746
3146
  /** Per-reference-video duration bounds, in seconds. */
@@ -2791,6 +3191,11 @@ export const VIDEO_REF_VIDEO_DURATION_LIMITS: Record<string, RefVideoDurationLim
2791
3191
  // while two 14 s ones were accepted (a production run with two 20 s
2792
3192
  // references had reached users as the generic "rejected these settings").
2793
3193
  "kling-4": { minSec: 2, maxSec: 30, maxTotalSec: 30 },
3194
+ // Kling 4.0 Flash — the reference videos' COMBINED length must be 2-20 s,
3195
+ // and KIE fails the task at completion otherwise ("video_1 duration must be
3196
+ // between 2 and 20 seconds, got 45", docs.kie.ai/market/kling/v4-flash-reference-to-video).
3197
+ // A 2 s floor per clip makes the combined floor hold too.
3198
+ "kling-4-flash": { minSec: 2, maxSec: 20, maxTotalSec: 20 },
2794
3199
  }
2795
3200
 
2796
3201
  /**
@@ -2857,11 +3262,9 @@ export const RESOLUTION_VIDEO_REF_PRICING = SEEDANCE_2_PROVIDERS
2857
3262
  * RESOLUTION_VIDEO_REF_PRICING (Seedance gen), which also adds `-ref` variants.
2858
3263
  */
2859
3264
  export const RESOLUTION_DURATION_PRICING: Record<string, readonly string[]> = {
2860
- // KIE supports only 480p/720p here; 480p is the default.
2861
- "grok-imagine-video-1.5": ["480p", "720p"],
2862
- // seedance-2-extend always uses a video ref, so pricing has no -ref
2863
- // dimension — duration tier + ":res" only (rates = seedance-2 -ref + stitch).
2864
- "seedance-2-extend": ["480p", "720p", "1080p"],
3265
+ // 480p is KIE's default and the bare id's tier; the runner and the credit
3266
+ // identifier both read normalizeGrokVideo15Resolution.
3267
+ "grok-imagine-video-1.5": ["480p", "720p", "1080p"],
2865
3268
  // HappyHorse 1.1 — per-second billing at two published resolution rates
2866
3269
  // (kie.ai/happyhorse-1-1: 22.5 cr/s @720p, 29 cr/s @1080p, uniform across
2867
3270
  // t2v/i2v/ref2v). 720p first = billing default; the KIE-side default is
@@ -2885,9 +3288,18 @@ export const RESOLUTION_DURATION_PRICING: Record<string, readonly string[]> = {
2885
3288
  // (VIDEO_REF_RATE_PROVIDERS).
2886
3289
  "kling-4": ["720p", "1080p"],
2887
3290
  "kling-4-keyframes": ["720p", "1080p"],
3291
+ // Kling 4.0 Flash — 720p only (both schemas), one rate on both endpoints,
3292
+ // plus a `-ref` rate for a run with a reference video (VIDEO_REF_RATE_PROVIDERS).
3293
+ "kling-4-flash": ["720p"],
2888
3294
  // Gemini Omni Flash 1.2 — per-second billing at four resolution rates.
2889
3295
  // Ascending; the billed default (720p) is declared in PRICING_DEFAULT_RESOLUTION.
2890
3296
  "gemini-omni-flash-1-2": ["360p", "720p", "1080p", "4k"],
3297
+ // PixVerse V6 Max — per-second billing at four quality rates on both
3298
+ // endpoints. Ascending; the billed default (720p) is declared in
3299
+ // PRICING_DEFAULT_RESOLUTION, and normalizePixverseV6MaxQuality pins the same
3300
+ // 720p at the wire. The audio state is its own `:audio` suffix
3301
+ // (AUDIO_ADDON_PROVIDERS), after the resolution.
3302
+ "pixverse-v6-max": ["360p", "540p", "720p", "1080p"],
2891
3303
  }
2892
3304
 
2893
3305
  /**
@@ -2899,6 +3311,8 @@ export const RESOLUTION_DURATION_PRICING: Record<string, readonly string[]> = {
2899
3311
  */
2900
3312
  export const VIDEO_REF_RATE_PROVIDERS = new Set<string>([
2901
3313
  "kling-4",
3314
+ // Kling 4.0 Flash — the same rule at its own with-video rate.
3315
+ "kling-4-flash",
2902
3316
  ])
2903
3317
 
2904
3318
  /**
@@ -3020,6 +3434,142 @@ export function videoProviderFoldsLoneEndFrame(provider: string): boolean {
3020
3434
  return isSeedance2Provider(provider) || isMinimaxH3Provider(provider) || isWan3Provider(provider) || isGeminiOmniPerSecondProvider(provider)
3021
3435
  }
3022
3436
 
3437
+ /**
3438
+ * True when the provider takes an end frame ALONE, with no start frame, as the
3439
+ * clip's closing frame: Kling 4.0 Keyframes (KIE `last_frame_url` without
3440
+ * `first_frame_url`) and Gemini Omni Flash 1.2. Every other model meets the
3441
+ * platform's general rule for a lone end frame: the workflow run moves it into
3442
+ * the start slot, while the editor's Run and the image-to-video route refuse
3443
+ * the run for having no start frame.
3444
+ *
3445
+ * Read by the three places that apply that rule (the route's image gate, the
3446
+ * workflow payload builder's swap, the editor's start-frame guard) so they
3447
+ * cannot disagree. A `keyframes` model qualifies only when its endpoint runs
3448
+ * with no start frame at all (it has a text-to-video mode): Grok Imagine Video
3449
+ * 1.5 declares `keyframes` but needs its start image, so a lone end frame
3450
+ * keeps the general rule there.
3451
+ */
3452
+ export function videoProviderTakesLoneEndFrame(provider: string | undefined): boolean {
3453
+ if (!provider) return false
3454
+ if (isGeminiOmniPerSecondProvider(provider)) return true
3455
+ return MODEL_CATALOG[provider]?.features?.includes("keyframes") === true && !videoProviderRequiresImage(provider)
3456
+ }
3457
+
3458
+ /**
3459
+ * True when wired reference images can stand in for a missing start frame on
3460
+ * the image-to-video lane: the provider carries image references
3461
+ * ({@link VIDEO_REF_LIMITS_BY_PROVIDER}), unless they are a `keyframes`
3462
+ * model's in-between FRAMES and its endpoint cannot run from them alone (no
3463
+ * `reference-to-video`, {@link videoProviderRunsFromReferences}) — Grok Imagine
3464
+ * Video 1.5's in-between frames need its start frame. Read by the
3465
+ * image-to-video route's gate and the editor's start-frame guard; the workflow
3466
+ * run reaches the same answer through {@link resolveVideoModeForInputs}.
3467
+ */
3468
+ export function videoProviderRefsReplaceStartFrame(provider: string | undefined): boolean {
3469
+ if (!provider || (VIDEO_REF_LIMITS_BY_PROVIDER[provider]?.images ?? 0) <= 0) return false
3470
+ const keyframes = MODEL_CATALOG[provider]?.features?.includes("keyframes") === true
3471
+ return !keyframes || videoProviderRunsFromReferences(provider)
3472
+ }
3473
+
3474
+ /** The error code of a {@link videoStartFrameOnlyProblem} refusal. */
3475
+ export const VIDEO_START_FRAME_ONLY_CODE = "start_frame_only_resolution" as const
3476
+
3477
+ /**
3478
+ * The resolution tier a run of `provider` renders for `resolution` when that
3479
+ * tier takes a start frame only (the catalog's `startFrameOnlyResolutions`),
3480
+ * else undefined. Case-folded, as the runners send it (`"1080P"` is 1080p).
3481
+ */
3482
+ export function videoStartFrameOnlyResolution(provider: string | undefined, resolution: string | undefined): string | undefined {
3483
+ const tiers = provider ? MODEL_CATALOG[provider]?.startFrameOnlyResolutions : undefined
3484
+ const r = resolution?.trim().toLowerCase()
3485
+ if (!tiers?.length || !r) return undefined
3486
+ return tiers.find((t) => t.toLowerCase() === r)
3487
+ }
3488
+
3489
+ /** The highest listed resolution of `provider` that takes every frame — the one to offer instead. */
3490
+ function videoFramesResolutionFallback(provider: string): string | undefined {
3491
+ const entry = MODEL_CATALOG[provider]
3492
+ const restricted = new Set((entry?.startFrameOnlyResolutions ?? []).map((t) => t.toLowerCase()))
3493
+ const open = (entry?.resolutions ?? []).filter((r) => !restricted.has(r.toLowerCase()))
3494
+ const height = (r: string): number => Number.parseInt(r, 10) || 0
3495
+ return [...open].sort((a, b) => height(b) - height(a))[0]
3496
+ }
3497
+
3498
+ /**
3499
+ * The sentence for a start-frame-only refusal: which tier takes a start frame
3500
+ * only, and the two ways out (the highest tier that takes every frame, or
3501
+ * removing the extra frames). `nothingCharged` adds that nothing was charged —
3502
+ * for a refusal of a run (the API, the workflow run, the editor's Run), never
3503
+ * for the editor's note beside the setting.
3504
+ */
3505
+ export function videoStartFrameOnlyMessage(
3506
+ provider: string,
3507
+ resolution: string,
3508
+ opts: { readonly nothingCharged?: boolean } = {},
3509
+ ): string {
3510
+ const label = MODEL_CATALOG[provider]?.label ?? provider
3511
+ const fallback = videoFramesResolutionFallback(provider)
3512
+ const choose = fallback ? `Choose ${fallback}, or remove` : "Remove"
3513
+ const sentence =
3514
+ `${label} takes a start frame only at ${resolution}: no end frame, loop or in-between frames. ` +
3515
+ `${choose} the end frame and the in-between frames.`
3516
+ return opts.nothingCharged ? `${sentence} Nothing was charged.` : sentence
3517
+ }
3518
+
3519
+ /** A {@link videoStartFrameOnlyProblem} refusal. */
3520
+ export interface VideoStartFrameOnlyProblem {
3521
+ readonly code: typeof VIDEO_START_FRAME_ONLY_CODE
3522
+ /** The sentence, in English — the API's `error.message`. */
3523
+ readonly message: string
3524
+ /** The tier that takes a start frame only (catalog spelling). */
3525
+ readonly resolution: string
3526
+ /** The highest tier that takes every frame, when the model has one. */
3527
+ readonly fallbackResolution?: string
3528
+ }
3529
+
3530
+ /**
3531
+ * THE rule for a resolution that takes a start frame only (decided 2026-11-12:
3532
+ * refuse up front). Given the resolution a run renders and the frames it would
3533
+ * send BESIDE its start frame, is the combination refused, and with what
3534
+ * sentence? Undefined when it runs.
3535
+ *
3536
+ * - `hasEndFrame`: an end frame is wired. The same picture as the start frame
3537
+ * (a loop) counts too — the provider refuses a loop at such a tier as well.
3538
+ * - `inBetweenFrameCount`: the in-between frames wired (a `keyframes` model's
3539
+ * image references), BEFORE the clip's cap. The cap is applied here through
3540
+ * {@link videoKeyframesMiddleCap} — the same function the provider runner
3541
+ * truncates with — so a request whose extra frames are all dropped (a
3542
+ * 1-second Grok Imagine Video 1.5 clip has no in-between second) is a
3543
+ * start-only request and runs.
3544
+ *
3545
+ * Judged only on a run that has a start frame: a run without one is refused by
3546
+ * the image-required rule first, so every caller runs this after that gate.
3547
+ * Read by `/v1/generate-video`, the workflow payload builder and the editor's
3548
+ * Run; the editor's note and resolution menus read it too.
3549
+ */
3550
+ export function videoStartFrameOnlyProblem(
3551
+ provider: string | undefined,
3552
+ args: {
3553
+ readonly resolution: string | undefined
3554
+ readonly durationSec?: number | string
3555
+ readonly hasEndFrame: boolean
3556
+ readonly inBetweenFrameCount: number
3557
+ readonly nothingCharged?: boolean
3558
+ },
3559
+ ): VideoStartFrameOnlyProblem | undefined {
3560
+ const tier = videoStartFrameOnlyResolution(provider, args.resolution)
3561
+ if (!provider || !tier) return undefined
3562
+ const cap = videoKeyframesMiddleCap(provider, args.durationSec, { hasStartFrame: true, hasEndFrame: args.hasEndFrame })
3563
+ const inBetween = Math.max(0, cap === undefined ? args.inBetweenFrameCount : Math.min(cap, args.inBetweenFrameCount))
3564
+ if (!args.hasEndFrame && inBetween === 0) return undefined
3565
+ return {
3566
+ code: VIDEO_START_FRAME_ONLY_CODE,
3567
+ message: videoStartFrameOnlyMessage(provider, tier, { nothingCharged: args.nothingCharged }),
3568
+ resolution: tier,
3569
+ fallbackResolution: videoFramesResolutionFallback(provider),
3570
+ }
3571
+ }
3572
+
3023
3573
  /**
3024
3574
  * Video models where enabling audio/sound incurs an additional cost.
3025
3575
  * The audio addon is expressed as a separate composite identifier suffix.
@@ -3027,6 +3577,9 @@ export function videoProviderFoldsLoneEndFrame(provider: string): boolean {
3027
3577
  export const AUDIO_ADDON_PROVIDERS = new Set([
3028
3578
  "kling-3.0",
3029
3579
  "kling",
3580
+ // PixVerse V6 Max — every (seconds × quality) row has an `:audio` twin at
3581
+ // the with-audio rate (`pixverse-v6-max:5s:720p:audio`).
3582
+ "pixverse-v6-max",
3030
3583
  ])
3031
3584
 
3032
3585
  /**
@@ -3066,8 +3619,9 @@ export type VideoAudioMode = "none" | "ambient" | "native_speech" | "audio_drive
3066
3619
  export interface VideoAudioCapability {
3067
3620
  mode: VideoAudioMode
3068
3621
  /** Provider-option field carrying the on/off toggle, when user-controllable.
3069
- * `audio` is Wan 3.0's own boolean lever (KIE `input.audio`, default true). */
3070
- field?: "generateAudio" | "sound" | "audio"
3622
+ * `audio` is Wan 3.0's own boolean lever (KIE `input.audio`, default true);
3623
+ * `generateAudioSwitch` is PixVerse V6 Max's (KIE `input.generate_audio_switch`). */
3624
+ field?: "generateAudio" | "sound" | "audio" | "generateAudioSwitch"
3071
3625
  /** Audio is always produced and can't be turned off by the user (VEO 3.x). */
3072
3626
  alwaysOn?: boolean
3073
3627
  /** Enabling audio raises the credit cost (Kling — see AUDIO_ADDON_PROVIDERS). */
@@ -3080,6 +3634,21 @@ export interface VideoAudioCapability {
3080
3634
  * (see buildVideoCreditModelIdentifier). Absent ⇒ default off.
3081
3635
  */
3082
3636
  defaultOn?: boolean
3637
+ /**
3638
+ * A cost-affecting model whose audio intent the `generateAudio` request field
3639
+ * also carries, after `sound` (PixVerse V6 Max, decided 2026-11-12: the
3640
+ * Generate Video Pro engine sends only `generateAudio`). Read through
3641
+ * {@link videoAudioIntent}, so the switch the model gets and the `:audio`
3642
+ * row the run is priced at follow the same fields. Absent on Kling, which
3643
+ * keeps reading `sound` alone.
3644
+ */
3645
+ readsGenerateAudio?: true
3646
+ }
3647
+
3648
+ /** The audio fields a video request carries: `sound` (canonical) and the older `generateAudio`. */
3649
+ export interface VideoAudioRequest {
3650
+ readonly sound?: boolean
3651
+ readonly generateAudio?: boolean
3083
3652
  }
3084
3653
 
3085
3654
  /**
@@ -3148,6 +3717,20 @@ export const VIDEO_AUDIO_CAPABILITY: Record<string, VideoAudioCapability> = {
3148
3717
  // dialogue; priced into the per-second rate.
3149
3718
  "kling-4": { mode: "ambient", alwaysOn: true, defaultOn: true },
3150
3719
  "kling-4-keyframes": { mode: "ambient", alwaysOn: true, defaultOn: true },
3720
+ // Kling 4.0 Flash — the same: native audio on both endpoints, no lever.
3721
+ "kling-4-flash": { mode: "ambient", alwaysOn: true, defaultOn: true },
3722
+ // PixVerse V6 Max — a boolean `generate_audio_switch` lever on both
3723
+ // endpoints. Cost-affecting: the with-audio rows bill at a higher per-second
3724
+ // rate (`:audio` suffix, AUDIO_ADDON_PROVIDERS), so — like Kling — only the
3725
+ // canonical `sound` intent turns it. `defaultOn`: a request that names no
3726
+ // audio setting renders AND bills audio (decided 2026-11-11; KIE's own default
3727
+ // is off, so the runner sends the switch explicitly). Classified "ambient" on
3728
+ // the Wan 3.0 rule: the schema mentions dialogue and lip-sync, but no live
3729
+ // probe has verified scripted speech, and `native_speech` would reroute the
3730
+ // Story→Video dialogue pipeline past its lip-sync pass. `readsGenerateAudio`:
3731
+ // the `generateAudio` field turns it too (after `sound`), and the price
3732
+ // follows the same resolved intent (videoAudioIntent).
3733
+ "pixverse-v6-max": { mode: "ambient", field: "generateAudioSwitch", affectsCost: true, defaultOn: true, readsGenerateAudio: true },
3151
3734
  // Gemini Omni Flash 1.2 — native audio with no on/off input in its schema.
3152
3735
  "gemini-omni-flash-1-2": { mode: "ambient", alwaysOn: true },
3153
3736
  // Gemini Omni (both SKUs — the pro `gemini-omni-video` and the faster
@@ -3216,6 +3799,33 @@ export function videoModelCanSpeakDialogue(model: string | undefined): boolean {
3216
3799
  return mode === "native_speech" || mode === "audio_driven"
3217
3800
  }
3218
3801
 
3802
+ /**
3803
+ * THE audio intent of a video request for one model — `undefined` when the
3804
+ * request expresses none (the model's own default then applies). The ONE
3805
+ * reading of the request's audio fields: {@link applyVideoAudioToggle} (what
3806
+ * the model is SENT) and `buildVideoCreditModelIdentifier` (the `:audio` row
3807
+ * it is PRICED at) both resolve through it, so the two cannot disagree.
3808
+ *
3809
+ * - A cost-affecting model reads `sound` alone (Kling: the field its `:audio`
3810
+ * surcharge has always keyed off), unless it declares `readsGenerateAudio`
3811
+ * (PixVerse V6 Max): then `sound`, else `generateAudio`.
3812
+ * - Every other model reads `sound`, else the `generateAudio` alias.
3813
+ */
3814
+ export function videoAudioIntent(provider: string | undefined, req: VideoAudioRequest | undefined): boolean | undefined {
3815
+ const cap = getVideoAudioCapability(provider)
3816
+ if (cap.affectsCost && cap.readsGenerateAudio !== true) return req?.sound
3817
+ return req?.sound ?? req?.generateAudio
3818
+ }
3819
+
3820
+ /**
3821
+ * Whether a request PRICES with audio on a cost-affecting model: its intent
3822
+ * ({@link videoAudioIntent}), else the model's own default (`defaultOn`). The
3823
+ * provider runner of such a model renders the same state.
3824
+ */
3825
+ export function videoAudioPricedOn(provider: string | undefined, req: VideoAudioRequest | undefined): boolean {
3826
+ return videoAudioIntent(provider, req) ?? (getVideoAudioCapability(provider).defaultOn === true)
3827
+ }
3828
+
3219
3829
  /**
3220
3830
  * Write the caller's neutral "enable native audio" intent onto a KIE provider
3221
3831
  * `input` under whichever field the chosen model actually reads, per
@@ -3227,12 +3837,12 @@ export function videoModelCanSpeakDialogue(model: string | undefined): boolean {
3227
3837
  * - `sound` is the canonical neutral name; `generateAudio` is accepted as a
3228
3838
  * legacy alias (the workflow node + some clients send that key). `sound` wins
3229
3839
  * if both are present.
3230
- * - **Cost-affecting models (Kling) honour ONLY the canonical `sound` lever** —
3231
- * the same field the `:audio` credit surcharge keys off (`AUDIO_ADDON_PROVIDERS`
3232
- * in `credit-identifiers.ts`). This makes a billed-but-not-generated (or
3233
- * generated-but-not-billed) divergence structurally impossible: the model and
3234
- * the surcharge read the same flag. Free models accept the `generateAudio`
3235
- * alias too, where mis-billing isn't possible.
3840
+ * - **The intent is {@link videoAudioIntent}'s** — the same reading the `:audio`
3841
+ * credit surcharge (`AUDIO_ADDON_PROVIDERS` in `credit-identifiers.ts`) is
3842
+ * built from. That makes a billed-but-not-generated (or generated-but-not-
3843
+ * billed) divergence structurally impossible: the model and the surcharge
3844
+ * read the same fields. Kling honours ONLY `sound`; PixVerse V6 Max
3845
+ * (`readsGenerateAudio`) and every free model also the `generateAudio` alias.
3236
3846
  * - No-op for `alwaysOn` models (VEO — audio can't be toggled) and silent /
3237
3847
  * unlisted models (no `field`), and when the caller expressed no intent
3238
3848
  * (leaves the model's own default in place).
@@ -3248,13 +3858,13 @@ export function applyVideoAudioToggle(
3248
3858
  ): void {
3249
3859
  const cap = getVideoAudioCapability(provider)
3250
3860
  if (!cap.field) return // alwaysOn (VEO) or silent/unlisted model — nothing to toggle
3251
- // Cost-affecting models stay on the canonical `sound` lever so the model and
3252
- // the credit surcharge can never read different flags; free models also accept
3253
- // the `generateAudio` alias. `sound` is canonical and wins when both are set.
3254
- const enabled = cap.affectsCost ? opts?.sound : (opts?.sound ?? opts?.generateAudio)
3861
+ // The one reading of the request's audio fields, shared with the credit
3862
+ // surcharge (see videoAudioIntent). `sound` is canonical and wins when both are set.
3863
+ const enabled = videoAudioIntent(provider, opts)
3255
3864
  if (enabled === undefined) return // no intent — keep the model's own default
3256
3865
  if (cap.field === "generateAudio") input.generate_audio = enabled
3257
3866
  else if (cap.field === "audio") input.audio = enabled
3867
+ else if (cap.field === "generateAudioSwitch") input.generate_audio_switch = enabled
3258
3868
  else input.sound = enabled
3259
3869
  }
3260
3870
 
@@ -3286,8 +3896,9 @@ export const VEO_RESOLUTION_TIERED_PROVIDERS = new Set<string>([
3286
3896
  * Video variable pricing config — which params affect credit cost per model.
3287
3897
  * "duration" = cost varies by video length
3288
3898
  * "duration+audio" = cost varies by length AND audio on/off
3899
+ * "duration+resolution+audio" = cost varies by length, resolution AND audio on/off
3289
3900
  */
3290
- export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio" | "duration+mode" | "duration+resolution+ref" | "duration+resolution"> = {
3901
+ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio" | "duration+mode" | "duration+resolution+ref" | "duration+resolution" | "duration+resolution+audio"> = {
3291
3902
  "kling-3.0": "duration+audio",
3292
3903
  "kling-3-omni": "duration",
3293
3904
  "kling": "duration+audio",
@@ -3307,7 +3918,8 @@ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio
3307
3918
  // appended for the cheaper tier); ref-video input seconds + extra input
3308
3919
  // images are billed via the dedicated compute hook, not the identifier.
3309
3920
  "minimax-h3": "duration+resolution",
3310
- // Grok Imagine Video 1.5 — per-second billing split 480p/720p (no video-ref dimension).
3921
+ // Grok Imagine Video 1.5 — per-second billing at 480p / 720p / 1080p (no
3922
+ // video-ref dimension, no per-image or per-frame part).
3311
3923
  "grok-imagine-video-1.5": "duration+resolution",
3312
3924
  // Wan 3.0 family — per-second billing at three resolution rates (no video-ref
3313
3925
  // dimension: reference runs bill output seconds only). No gemini-omni-flash
@@ -3321,9 +3933,14 @@ export const VIDEO_VARIABLE_PRICING: Record<string, "duration" | "duration+audio
3321
3933
  // reference-video rate.
3322
3934
  "kling-4": "duration+resolution+ref",
3323
3935
  "kling-4-keyframes": "duration+resolution",
3936
+ // Kling 4.0 Flash — per-second at 720p, plus the reference-video rate.
3937
+ "kling-4-flash": "duration+resolution+ref",
3324
3938
  // Gemini Omni Flash 1.2 — per-second at four resolution rates; a video edit
3325
3939
  // bills the same rates over the source clip.
3326
3940
  "gemini-omni-flash-1-2": "duration+resolution",
3941
+ // PixVerse V6 Max — per-second at four quality rates, each with and without
3942
+ // native audio.
3943
+ "pixverse-v6-max": "duration+resolution+audio",
3327
3944
  }
3328
3945
 
3329
3946
  /**
@@ -3403,6 +4020,163 @@ export function supportsAutoVideoDuration(provider: string | undefined): boolean
3403
4020
  return !!provider && MODEL_CATALOG[provider]?.autoDuration === true
3404
4021
  }
3405
4022
 
4023
+ /** Models that accept a reference task type declaration — a catalog capability
4024
+ * (`MODEL_CATALOG[id].referenceTaskTypes`, see `SEEDANCE_REFERENCE_TASK_TYPES`). */
4025
+ export function supportsReferenceTaskType(provider: string | undefined): boolean {
4026
+ return !!provider && (MODEL_CATALOG[provider]?.referenceTaskTypes?.length ?? 0) > 0
4027
+ }
4028
+
4029
+ /** What a request knows that decides its reference task type. */
4030
+ export interface SeedanceTaskTypeFacts {
4031
+ provider: string | undefined
4032
+ /** The value the request carries, unvalidated: anything but a declared value is Auto. */
4033
+ requested: unknown
4034
+ /**
4035
+ * @deprecated Not read: a draft declares exactly as any other run does. Kept
4036
+ * so a caller that still passes it compiles; leave it out.
4037
+ */
4038
+ draft?: boolean
4039
+ /** Reference images only: a start or end frame is not counted. */
4040
+ referenceImageCount: number
4041
+ referenceAudioCount: number
4042
+ /** One entry per reference video; `undefined` = its length could not be measured. */
4043
+ referenceVideoSec: ReadonlyArray<number | undefined>
4044
+ aspectRatio: string | undefined
4045
+ duration: number | undefined
4046
+ }
4047
+
4048
+ /** The declaration a request sends (if any), and the ratio and length it runs at. */
4049
+ export interface SeedanceTaskTypeResolution {
4050
+ /** `undefined`: nothing is declared and the provider guesses from the prompt. */
4051
+ taskType: DeclaredSeedanceTaskType | undefined
4052
+ aspectRatio: string | undefined
4053
+ duration: number | undefined
4054
+ /** Each change made to the ratio or length, for disclosure. Empty when nothing changed. */
4055
+ adjustments: ModelInputAdjustment[]
4056
+ }
4057
+
4058
+ /** The aspect ratio an `extend` runs at: the reference video's own (an `edit`
4059
+ * takes its whole shape from `SEEDANCE_VIDEO_EDIT_SHAPE`). */
4060
+ const SEEDANCE_EXTEND_ASPECT = "adaptive"
4061
+
4062
+ /**
4063
+ * `requested` when the model's catalog `referenceTaskTypes` lists it (strict
4064
+ * match), else `undefined`. The one membership test: the resolver below and the
4065
+ * provider adapter that writes the value both ask it.
4066
+ */
4067
+ export function listedSeedanceTaskType(provider: string | undefined, requested: unknown): DeclaredSeedanceTaskType | undefined {
4068
+ return provider ? MODEL_CATALOG[provider]?.referenceTaskTypes?.find((t) => t === requested) : undefined
4069
+ }
4070
+
4071
+ /** How many of each kind of reference media a request carries. A start or end frame is not reference media. */
4072
+ export interface SeedanceReferenceMediaCount {
4073
+ imageCount: number
4074
+ videoCount: number
4075
+ audioCount: number
4076
+ }
4077
+
4078
+ /**
4079
+ * Whether a request's reference media is what the declared type needs:
4080
+ * `reference` takes any reference media; `edit` and `extend` need a reference
4081
+ * video, since both act on one. The one media rule: the resolver below asks it
4082
+ * of the request, and the provider adapter of the body as it will be sent.
4083
+ */
4084
+ export function seedanceTaskTypeFitsMedia(type: DeclaredSeedanceTaskType, media: SeedanceReferenceMediaCount): boolean {
4085
+ return type === "reference" ? media.imageCount + media.videoCount + media.audioCount > 0 : media.videoCount > 0
4086
+ }
4087
+
4088
+ function editReferenceVideosFit(referenceVideoSec: ReadonlyArray<number | undefined>): boolean {
4089
+ const { min, max } = SEEDANCE_EDIT_REF_VIDEO_SEC
4090
+ return referenceVideoSec.every((sec) => typeof sec === "number" && sec >= min && sec <= max)
4091
+ }
4092
+
4093
+ /**
4094
+ * The ONE place that decides whether a request declares a reference task type,
4095
+ * and the aspect ratio and length that declaration forces.
4096
+ *
4097
+ * Declared only when every condition holds; otherwise the result is the input
4098
+ * unchanged (no declaration, ratio and length as given, nothing reported):
4099
+ * - the request asks for a value the model's catalog `referenceTaskTypes`
4100
+ * LISTS, matched exactly. The list is what is honoured: a model that lists
4101
+ * nothing, a value it does not list (`auto`, a wrong case, a number) and a
4102
+ * model that lists only some values are all Auto;
4103
+ * - it has the reference media the type needs
4104
+ * ({@link seedanceTaskTypeFitsMedia}): `edit` and `extend` need a
4105
+ * reference video;
4106
+ * - for `edit`, every reference video is measured and between
4107
+ * `SEEDANCE_EDIT_REF_VIDEO_SEC.min` and `.max` seconds inclusive.
4108
+ *
4109
+ * What a declaration forces:
4110
+ * - `reference` — nothing;
4111
+ * - `edit` — the edit shape, `SEEDANCE_VIDEO_EDIT_SHAPE` (`"adaptive"`
4112
+ * and Auto length): the output takes the video's own shape
4113
+ * and length;
4114
+ * - `extend` — `"adaptive"`; a fixed length is kept, and Auto or no length
4115
+ * becomes the model's catalog `defaultDuration`.
4116
+ *
4117
+ * Each value it changes is reported as one adjustment; a value it fills where
4118
+ * the request had none is not a correction and reports nothing, and neither is
4119
+ * a ratio that already runs at the forced one (`"Auto"` with a reference video
4120
+ * runs at `"adaptive"`).
4121
+ *
4122
+ * A draft (`draft: true`) is no exception: it declares, and is forced, exactly
4123
+ * as the same request without Draft (a draft and its 1080p finalize keep an
4124
+ * edit's own length and framing, measured). Pure.
4125
+ */
4126
+ export function resolveSeedanceTaskType(facts: SeedanceTaskTypeFacts): SeedanceTaskTypeResolution {
4127
+ const { provider, aspectRatio, duration, referenceVideoSec } = facts
4128
+ const unchanged: SeedanceTaskTypeResolution = { taskType: undefined, aspectRatio, duration, adjustments: [] }
4129
+ const taskType = listedSeedanceTaskType(provider, facts.requested)
4130
+ if (!taskType || !provider) return unchanged
4131
+ const media = {
4132
+ imageCount: facts.referenceImageCount,
4133
+ videoCount: referenceVideoSec.length,
4134
+ audioCount: facts.referenceAudioCount,
4135
+ }
4136
+ if (!seedanceTaskTypeFitsMedia(taskType, media)) return unchanged
4137
+ if (taskType === "edit" && !editReferenceVideosFit(referenceVideoSec)) return unchanged
4138
+ if (taskType === "reference") return { ...unchanged, taskType }
4139
+
4140
+ const verb = taskType === "edit" ? "Edit" : "Extend"
4141
+ const nextAspect = taskType === "edit" ? SEEDANCE_VIDEO_EDIT_SHAPE.aspectRatio : SEEDANCE_EXTEND_ASPECT
4142
+ const adjustments: ModelInputAdjustment[] = []
4143
+ const askedAspect = typeof aspectRatio === "string" ? aspectRatio.trim() : ""
4144
+ // A ratio that already runs at the forced one is not replaced: the forced
4145
+ // value itself, or the "Auto" token, which a request with a reference video
4146
+ // runs at "adaptive" (`videoAutoAspectRunsAt`, the adapter's own rule).
4147
+ const runsAtForced = askedAspect.toLowerCase() === nextAspect
4148
+ || (isVideoAutoAspectToken(askedAspect) && videoAutoAspectRunsAt(provider, media.videoCount > 0) === nextAspect)
4149
+ if (askedAspect !== "" && !runsAtForced) {
4150
+ adjustments.push({
4151
+ field: "aspectRatio", from: askedAspect, to: nextAspect,
4152
+ reason: `${verb} keeps the video's own shape — using "${nextAspect}" instead of "${askedAspect}".`,
4153
+ })
4154
+ }
4155
+
4156
+ let nextDuration: number
4157
+ if (taskType === "edit") {
4158
+ nextDuration = SEEDANCE_VIDEO_EDIT_SHAPE.duration
4159
+ if (duration !== undefined && !isAutoVideoDuration(duration)) {
4160
+ adjustments.push({
4161
+ field: "duration", from: duration, to: nextDuration,
4162
+ reason: `Edit keeps the video's own length — using Auto instead of ${duration}s.`,
4163
+ })
4164
+ }
4165
+ } else if (duration === undefined || isAutoVideoDuration(duration)) {
4166
+ nextDuration = videoDefaultDurationSec(provider)
4167
+ if (duration !== undefined) {
4168
+ adjustments.push({
4169
+ field: "duration", from: duration, to: nextDuration,
4170
+ reason: `Extend needs a set length — using ${nextDuration}s, the model's default, instead of Auto.`,
4171
+ })
4172
+ }
4173
+ } else {
4174
+ nextDuration = duration
4175
+ }
4176
+
4177
+ return { taskType, aspectRatio: nextAspect, duration: nextDuration, adjustments }
4178
+ }
4179
+
3406
4180
  /** The longest clip a duration-tiered provider can render (its top priced tier). */
3407
4181
  export function maxVideoDurationSec(provider: string): number | undefined {
3408
4182
  const tiers = VIDEO_DURATION_TIERS[provider]
@@ -3443,9 +4217,21 @@ export const PRICING_DEFAULT_RESOLUTION: Record<string, string> = {
3443
4217
  // normalizeKling4Resolution pins the same tier for anything unknown.
3444
4218
  "kling-4": "720p",
3445
4219
  "kling-4-keyframes": "720p",
4220
+ // Kling 4.0 Flash — 720p is its only tier.
4221
+ "kling-4-flash": "720p",
3446
4222
  // Gemini Omni Flash 1.2 — KIE renders 720p when `resolution` is omitted, and
3447
4223
  // the runner sends 720p for anything off its list.
3448
4224
  "gemini-omni-flash-1-2": "720p",
4225
+ // Grok Imagine Video 1.5 — KIE renders 480p when `resolution` is omitted, and
4226
+ // normalizeGrokVideo15Resolution pins the same tier for anything unknown. It
4227
+ // is also the cheapest tier, so the bill does not move; declared so a run
4228
+ // that names no resolution is judged at 480p by the free-tier check (decided
4229
+ // 2026-11-11) and is sent 480p by pricedVideoSelection.
4230
+ "grok-imagine-video-1.5": "480p",
4231
+ // PixVerse V6 Max — KIE requires a quality and has no default; the runner
4232
+ // sends 720p for an omitted or unknown one (normalizePixverseV6MaxQuality),
4233
+ // never the 360p preview tier.
4234
+ "pixverse-v6-max": "720p",
3449
4235
  }
3450
4236
 
3451
4237
  /** Gemini Omni Flash 1.2 per-second tiers — one per allowed duration (3–15s). */
@@ -3507,6 +4293,18 @@ const KLING_4_DURATION_TIERS: Array<{ maxSeconds: number; suffix: string }> = Ar
3507
4293
  (_, i) => ({ maxSeconds: i + 3, suffix: `${i + 3}s` }),
3508
4294
  )
3509
4295
 
4296
+ /** Kling 4.0 Flash per-second tiers — one per allowed duration (3-20s). */
4297
+ const KLING_4_FLASH_DURATION_TIERS: Array<{ maxSeconds: number; suffix: string }> = Array.from(
4298
+ { length: 18 },
4299
+ (_, i) => ({ maxSeconds: i + 3, suffix: `${i + 3}s` }),
4300
+ )
4301
+
4302
+ /** PixVerse V6 Max per-second tiers — one per allowed duration (1-15s). */
4303
+ const PIXVERSE_V6_MAX_DURATION_TIERS: Array<{ maxSeconds: number; suffix: string }> = Array.from(
4304
+ { length: 15 },
4305
+ (_, i) => ({ maxSeconds: i + 1, suffix: `${i + 1}s` }),
4306
+ )
4307
+
3510
4308
  /**
3511
4309
  * Duration tier breakpoints for variable-priced video models.
3512
4310
  * Maps provider → array of { maxSeconds, suffix } in ascending order.
@@ -3569,6 +4367,10 @@ export const VIDEO_DURATION_TIERS: Record<string, Array<{ maxSeconds: number; su
3569
4367
  { maxSeconds: 12, suffix: "12s" },
3570
4368
  { maxSeconds: 15, suffix: "15s" },
3571
4369
  ],
4370
+ // The length tiers of the earlier Seedance Extend rows
4371
+ // (`seedance-2-extend:<tier>:<res>`). No extend is priced on them any more —
4372
+ // each Seedance extend provider has a row per second (`tailExtendCreditId`)
4373
+ // — but the rows stay, and so do their tiers.
3572
4374
  "seedance-2-extend": [
3573
4375
  { maxSeconds: 4, suffix: "4s" },
3574
4376
  { maxSeconds: 8, suffix: "8s" },
@@ -3587,6 +4389,8 @@ export const VIDEO_DURATION_TIERS: Record<string, Array<{ maxSeconds: number; su
3587
4389
  "vidu-q4": VIDU_Q4_DURATION_TIERS,
3588
4390
  "kling-4": KLING_4_DURATION_TIERS,
3589
4391
  "kling-4-keyframes": KLING_4_DURATION_TIERS,
4392
+ "kling-4-flash": KLING_4_FLASH_DURATION_TIERS,
4393
+ "pixverse-v6-max": PIXVERSE_V6_MAX_DURATION_TIERS,
3590
4394
  "gemini-omni-flash-1-2": GEMINI_OMNI_12_DURATION_TIERS,
3591
4395
  // MiniMax Hailuo 3 — true per-second billing (KIE 36.5 cr/s @2K, 22.5 cr/s
3592
4396
  // @768P). One tier per allowed second (4-15s) so the composite identifier
@@ -3606,9 +4410,10 @@ export const VIDEO_DURATION_TIERS: Record<string, Array<{ maxSeconds: number; su
3606
4410
  { maxSeconds: 14, suffix: "14s" },
3607
4411
  { maxSeconds: 15, suffix: "15s" },
3608
4412
  ],
3609
- // Grok Imagine Video 1.5 — true per-second billing (KIE 14.5 cr/s @480p, 25 cr/s
3610
- // @720p, +2 cr/image). One tier per allowed second (1–15s) so the composite
3611
- // identifier maps 1:1 to the seeded price — no rounding/overcharge for any on-menu value.
4413
+ // Grok Imagine Video 1.5 — true per-second billing by resolution, with no
4414
+ // per-image or per-frame part. One tier per allowed second (1–15s) so the
4415
+ // composite identifier maps 1:1 to the seeded price — no rounding/overcharge
4416
+ // for any on-menu value.
3612
4417
  "grok-imagine-video-1.5": [
3613
4418
  { maxSeconds: 1, suffix: "1s" },
3614
4419
  { maxSeconds: 2, suffix: "2s" },