@nodaro/shared 3.30.0 → 3.32.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 (388) hide show
  1. package/README.md +17 -0
  2. package/dist/chunk-2NIQO2J3.cjs +54 -0
  3. package/dist/chunk-2NIQO2J3.cjs.map +1 -0
  4. package/dist/chunk-2OJIVO7R.cjs +32 -0
  5. package/dist/chunk-2OJIVO7R.cjs.map +1 -0
  6. package/dist/chunk-2RF4Z7KG.cjs +803 -0
  7. package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
  8. package/dist/chunk-3CUFITU7.js +1905 -0
  9. package/dist/chunk-3CUFITU7.js.map +1 -0
  10. package/dist/chunk-3RYKIUAE.js +86 -0
  11. package/dist/chunk-3RYKIUAE.js.map +1 -0
  12. package/dist/chunk-44I73CQS.cjs +194 -0
  13. package/dist/chunk-44I73CQS.cjs.map +1 -0
  14. package/dist/chunk-5AUSSJIM.cjs +3372 -0
  15. package/dist/chunk-5AUSSJIM.cjs.map +1 -0
  16. package/dist/chunk-5PC6JBGJ.cjs +1419 -0
  17. package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
  18. package/dist/chunk-5RU2HCW2.js +30 -0
  19. package/dist/chunk-5RU2HCW2.js.map +1 -0
  20. package/dist/chunk-5THUHJ3E.js +46 -0
  21. package/dist/chunk-5THUHJ3E.js.map +1 -0
  22. package/dist/chunk-5U7VLG43.js +141 -0
  23. package/dist/chunk-5U7VLG43.js.map +1 -0
  24. package/dist/chunk-6DAWSVX2.cjs +103 -0
  25. package/dist/chunk-6DAWSVX2.cjs.map +1 -0
  26. package/dist/chunk-6DKDOWBL.js +1567 -0
  27. package/dist/chunk-6DKDOWBL.js.map +1 -0
  28. package/dist/chunk-6IJOPRZP.cjs +197 -0
  29. package/dist/chunk-6IJOPRZP.cjs.map +1 -0
  30. package/dist/chunk-7G7G42KS.js +86 -0
  31. package/dist/chunk-7G7G42KS.js.map +1 -0
  32. package/dist/chunk-AINCI23X.js +2171 -0
  33. package/dist/chunk-AINCI23X.js.map +1 -0
  34. package/dist/chunk-AROWPFO2.js +773 -0
  35. package/dist/chunk-AROWPFO2.js.map +1 -0
  36. package/dist/chunk-AVQK77G6.cjs +2000 -0
  37. package/dist/chunk-AVQK77G6.cjs.map +1 -0
  38. package/dist/chunk-C57NEO3X.js +3327 -0
  39. package/dist/chunk-C57NEO3X.js.map +1 -0
  40. package/dist/chunk-CK3GK34R.js +1381 -0
  41. package/dist/chunk-CK3GK34R.js.map +1 -0
  42. package/dist/chunk-E2TGXG6X.cjs +1770 -0
  43. package/dist/chunk-E2TGXG6X.cjs.map +1 -0
  44. package/dist/chunk-EK362Q45.cjs +38 -0
  45. package/dist/chunk-EK362Q45.cjs.map +1 -0
  46. package/dist/chunk-FBV5DF6D.js +95 -0
  47. package/dist/chunk-FBV5DF6D.js.map +1 -0
  48. package/dist/chunk-FG4E7MTG.cjs +4 -0
  49. package/dist/chunk-FG4E7MTG.cjs.map +1 -0
  50. package/dist/chunk-G6IIVKMO.js +26 -0
  51. package/dist/chunk-G6IIVKMO.js.map +1 -0
  52. package/dist/chunk-HGC5JNVA.cjs +1503 -0
  53. package/dist/chunk-HGC5JNVA.cjs.map +1 -0
  54. package/dist/chunk-HSHCCBIV.js +255 -0
  55. package/dist/chunk-HSHCCBIV.js.map +1 -0
  56. package/dist/chunk-IEBZHTPE.js +254 -0
  57. package/dist/chunk-IEBZHTPE.js.map +1 -0
  58. package/dist/chunk-ISJDAFKS.js +1604 -0
  59. package/dist/chunk-ISJDAFKS.js.map +1 -0
  60. package/dist/chunk-J6KHW2E5.cjs +1963 -0
  61. package/dist/chunk-J6KHW2E5.cjs.map +1 -0
  62. package/dist/chunk-J7BMO73N.cjs +114 -0
  63. package/dist/chunk-J7BMO73N.cjs.map +1 -0
  64. package/dist/chunk-JL4C5VJ7.cjs +488 -0
  65. package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
  66. package/dist/chunk-JSGIEF6Z.cjs +1087 -0
  67. package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
  68. package/dist/chunk-JSNV5O2F.cjs +34 -0
  69. package/dist/chunk-JSNV5O2F.cjs.map +1 -0
  70. package/dist/chunk-JWA5SGCS.js +203 -0
  71. package/dist/chunk-JWA5SGCS.js.map +1 -0
  72. package/dist/chunk-JX5YZ4DH.cjs +430 -0
  73. package/dist/chunk-JX5YZ4DH.cjs.map +1 -0
  74. package/dist/chunk-KHCBJ7KD.js +42 -0
  75. package/dist/chunk-KHCBJ7KD.js.map +1 -0
  76. package/dist/chunk-KU6S7IYV.cjs +210 -0
  77. package/dist/chunk-KU6S7IYV.cjs.map +1 -0
  78. package/dist/chunk-LKAIXWK3.js +181 -0
  79. package/dist/chunk-LKAIXWK3.js.map +1 -0
  80. package/dist/chunk-LPW3XNC2.js +471 -0
  81. package/dist/chunk-LPW3XNC2.js.map +1 -0
  82. package/dist/chunk-M36G6SRP.js +447 -0
  83. package/dist/chunk-M36G6SRP.js.map +1 -0
  84. package/dist/chunk-MRXGWL42.cjs +4 -0
  85. package/dist/chunk-MRXGWL42.cjs.map +1 -0
  86. package/dist/chunk-NB72XWXQ.cjs +54 -0
  87. package/dist/chunk-NB72XWXQ.cjs.map +1 -0
  88. package/dist/chunk-NEJ2PV4C.cjs +211 -0
  89. package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
  90. package/dist/chunk-NT6IJH4L.cjs +273 -0
  91. package/dist/chunk-NT6IJH4L.cjs.map +1 -0
  92. package/dist/chunk-O5MP52U2.cjs +526 -0
  93. package/dist/chunk-O5MP52U2.cjs.map +1 -0
  94. package/dist/chunk-O7PUQLJ3.cjs +818 -0
  95. package/dist/chunk-O7PUQLJ3.cjs.map +1 -0
  96. package/dist/chunk-PQHS255G.js +1369 -0
  97. package/dist/chunk-PQHS255G.js.map +1 -0
  98. package/dist/chunk-PRYE7AZQ.cjs +1227 -0
  99. package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
  100. package/dist/chunk-Q4CDQ2KO.js +21 -0
  101. package/dist/chunk-Q4CDQ2KO.js.map +1 -0
  102. package/dist/chunk-QELDJGDK.cjs +1714 -0
  103. package/dist/chunk-QELDJGDK.cjs.map +1 -0
  104. package/dist/chunk-QJRP44ZO.js +769 -0
  105. package/dist/chunk-QJRP44ZO.js.map +1 -0
  106. package/dist/chunk-QNGNOU4Z.js +29 -0
  107. package/dist/chunk-QNGNOU4Z.js.map +1 -0
  108. package/dist/chunk-RJL7RCEM.cjs +159 -0
  109. package/dist/chunk-RJL7RCEM.cjs.map +1 -0
  110. package/dist/chunk-RN3RMBJZ.js +1164 -0
  111. package/dist/chunk-RN3RMBJZ.js.map +1 -0
  112. package/dist/chunk-S5DMKUWK.cjs +1273 -0
  113. package/dist/chunk-S5DMKUWK.cjs.map +1 -0
  114. package/dist/chunk-SES6GDBQ.cjs +624 -0
  115. package/dist/chunk-SES6GDBQ.cjs.map +1 -0
  116. package/dist/chunk-TNPDV7I4.cjs +2346 -0
  117. package/dist/chunk-TNPDV7I4.cjs.map +1 -0
  118. package/dist/chunk-TZBIY5C3.js +187 -0
  119. package/dist/chunk-TZBIY5C3.js.map +1 -0
  120. package/dist/chunk-TZE673G6.js +3 -0
  121. package/dist/chunk-TZE673G6.js.map +1 -0
  122. package/dist/chunk-ULXI7A6Q.cjs +1047 -0
  123. package/dist/chunk-ULXI7A6Q.cjs.map +1 -0
  124. package/dist/chunk-VIWSWVAW.js +1782 -0
  125. package/dist/chunk-VIWSWVAW.js.map +1 -0
  126. package/dist/chunk-VWGNPMJZ.cjs +19 -0
  127. package/dist/chunk-VWGNPMJZ.cjs.map +1 -0
  128. package/dist/chunk-WDIBOWAA.js +1054 -0
  129. package/dist/chunk-WDIBOWAA.js.map +1 -0
  130. package/dist/chunk-WNG7HRVA.cjs +25 -0
  131. package/dist/chunk-WNG7HRVA.cjs.map +1 -0
  132. package/dist/chunk-WNVQ3SMB.cjs +96 -0
  133. package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
  134. package/dist/chunk-WRSWH7US.cjs +285 -0
  135. package/dist/chunk-WRSWH7US.cjs.map +1 -0
  136. package/dist/chunk-XAMC4S53.js +17 -0
  137. package/dist/chunk-XAMC4S53.js.map +1 -0
  138. package/dist/chunk-XNISPHTZ.js +1039 -0
  139. package/dist/chunk-XNISPHTZ.js.map +1 -0
  140. package/dist/chunk-Y2PM3FFL.js +3 -0
  141. package/dist/chunk-Y2PM3FFL.js.map +1 -0
  142. package/dist/chunk-YBPBK5KI.js +1030 -0
  143. package/dist/chunk-YBPBK5KI.js.map +1 -0
  144. package/dist/chunk-YHRG7UOC.js +31 -0
  145. package/dist/chunk-YHRG7UOC.js.map +1 -0
  146. package/dist/chunk-YWNYGYI7.cjs +31 -0
  147. package/dist/chunk-YWNYGYI7.cjs.map +1 -0
  148. package/dist/chunk-YYV35XOS.js +122 -0
  149. package/dist/chunk-YYV35XOS.js.map +1 -0
  150. package/dist/chunk-Z2OL5AJD.cjs +133 -0
  151. package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
  152. package/dist/chunk-Z4AZW6FY.js +920 -0
  153. package/dist/chunk-Z4AZW6FY.js.map +1 -0
  154. package/dist/chunk-ZDFHA2EC.js +572 -0
  155. package/dist/chunk-ZDFHA2EC.js.map +1 -0
  156. package/dist/chunk-ZNZDQAXN.js +175 -0
  157. package/dist/chunk-ZNZDQAXN.js.map +1 -0
  158. package/dist/chunk-ZRL2UFTH.cjs +1073 -0
  159. package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
  160. package/dist/chunk-ZT77RY6R.js +404 -0
  161. package/dist/chunk-ZT77RY6R.js.map +1 -0
  162. package/dist/entries/apps.cjs +155 -0
  163. package/dist/entries/apps.cjs.map +1 -0
  164. package/dist/entries/apps.d.cts +283 -0
  165. package/dist/entries/apps.d.ts +283 -0
  166. package/dist/entries/apps.js +10 -0
  167. package/dist/entries/apps.js.map +1 -0
  168. package/dist/entries/captions.cjs +124 -0
  169. package/dist/entries/captions.cjs.map +1 -0
  170. package/dist/entries/captions.d.cts +354 -0
  171. package/dist/entries/captions.d.ts +354 -0
  172. package/dist/entries/captions.js +3 -0
  173. package/dist/entries/captions.js.map +1 -0
  174. package/dist/entries/catalogs.cjs +165 -0
  175. package/dist/entries/catalogs.cjs.map +1 -0
  176. package/dist/entries/catalogs.d.cts +385 -0
  177. package/dist/entries/catalogs.d.ts +385 -0
  178. package/dist/entries/catalogs.js +4 -0
  179. package/dist/entries/catalogs.js.map +1 -0
  180. package/dist/entries/credits.cjs +592 -0
  181. package/dist/entries/credits.cjs.map +1 -0
  182. package/dist/entries/credits.d.cts +1429 -0
  183. package/dist/entries/credits.d.ts +1429 -0
  184. package/dist/entries/credits.js +11 -0
  185. package/dist/entries/credits.js.map +1 -0
  186. package/dist/entries/edl.cjs +409 -0
  187. package/dist/entries/edl.cjs.map +1 -0
  188. package/dist/entries/edl.d.cts +1199 -0
  189. package/dist/entries/edl.d.ts +1199 -0
  190. package/dist/entries/edl.js +4 -0
  191. package/dist/entries/edl.js.map +1 -0
  192. package/dist/entries/entities.cjs +530 -0
  193. package/dist/entries/entities.cjs.map +1 -0
  194. package/dist/entries/entities.d.cts +1371 -0
  195. package/dist/entries/entities.d.ts +1371 -0
  196. package/dist/entries/entities.js +5 -0
  197. package/dist/entries/entities.js.map +1 -0
  198. package/dist/entries/i18n.cjs +48 -0
  199. package/dist/entries/i18n.cjs.map +1 -0
  200. package/dist/entries/i18n.d.cts +69 -0
  201. package/dist/entries/i18n.d.ts +69 -0
  202. package/dist/entries/i18n.js +3 -0
  203. package/dist/entries/i18n.js.map +1 -0
  204. package/dist/entries/llm-models.cjs +177 -0
  205. package/dist/entries/llm-models.cjs.map +1 -0
  206. package/dist/entries/llm-models.d.cts +435 -0
  207. package/dist/entries/llm-models.d.ts +435 -0
  208. package/dist/entries/llm-models.js +4 -0
  209. package/dist/entries/llm-models.js.map +1 -0
  210. package/dist/entries/media.cjs +335 -0
  211. package/dist/entries/media.cjs.map +1 -0
  212. package/dist/entries/media.d.cts +518 -0
  213. package/dist/entries/media.d.ts +518 -0
  214. package/dist/entries/media.js +6 -0
  215. package/dist/entries/media.js.map +1 -0
  216. package/dist/entries/model-catalog.cjs +247 -0
  217. package/dist/entries/model-catalog.cjs.map +1 -0
  218. package/dist/entries/model-catalog.d.cts +202 -0
  219. package/dist/entries/model-catalog.d.ts +202 -0
  220. package/dist/entries/model-catalog.js +6 -0
  221. package/dist/entries/model-catalog.js.map +1 -0
  222. package/dist/entries/models.cjs +833 -0
  223. package/dist/entries/models.cjs.map +1 -0
  224. package/dist/entries/models.d.cts +287 -0
  225. package/dist/entries/models.d.ts +287 -0
  226. package/dist/entries/models.js +8 -0
  227. package/dist/entries/models.js.map +1 -0
  228. package/dist/entries/nodes.cjs +789 -0
  229. package/dist/entries/nodes.cjs.map +1 -0
  230. package/dist/entries/nodes.d.cts +1600 -0
  231. package/dist/entries/nodes.d.ts +1600 -0
  232. package/dist/entries/nodes.js +16 -0
  233. package/dist/entries/nodes.js.map +1 -0
  234. package/dist/entries/organizations.cjs +80 -0
  235. package/dist/entries/organizations.cjs.map +1 -0
  236. package/dist/entries/organizations.d.cts +466 -0
  237. package/dist/entries/organizations.d.ts +466 -0
  238. package/dist/entries/organizations.js +3 -0
  239. package/dist/entries/organizations.js.map +1 -0
  240. package/dist/entries/pipeline.cjs +594 -0
  241. package/dist/entries/pipeline.cjs.map +1 -0
  242. package/dist/entries/pipeline.d.cts +2617 -0
  243. package/dist/entries/pipeline.d.ts +2617 -0
  244. package/dist/entries/pipeline.js +5 -0
  245. package/dist/entries/pipeline.js.map +1 -0
  246. package/dist/entries/scene3d.cjs +704 -0
  247. package/dist/entries/scene3d.cjs.map +1 -0
  248. package/dist/entries/scene3d.d.cts +4284 -0
  249. package/dist/entries/scene3d.d.ts +4284 -0
  250. package/dist/entries/scene3d.js +3 -0
  251. package/dist/entries/scene3d.js.map +1 -0
  252. package/dist/entries/social.cjs +714 -0
  253. package/dist/entries/social.cjs.map +1 -0
  254. package/dist/entries/social.d.cts +1366 -0
  255. package/dist/entries/social.d.ts +1366 -0
  256. package/dist/entries/social.js +5 -0
  257. package/dist/entries/social.js.map +1 -0
  258. package/dist/entries/types.cjs +13 -0
  259. package/dist/entries/types.cjs.map +1 -0
  260. package/dist/entries/types.d.cts +162 -0
  261. package/dist/entries/types.d.ts +162 -0
  262. package/dist/entries/types.js +4 -0
  263. package/dist/entries/types.js.map +1 -0
  264. package/dist/entries/ugc.cjs +279 -0
  265. package/dist/entries/ugc.cjs.map +1 -0
  266. package/dist/entries/ugc.d.cts +575 -0
  267. package/dist/entries/ugc.d.ts +575 -0
  268. package/dist/entries/ugc.js +6 -0
  269. package/dist/entries/ugc.js.map +1 -0
  270. package/dist/entries/video.cjs +549 -0
  271. package/dist/entries/video.cjs.map +1 -0
  272. package/dist/entries/video.d.cts +1791 -0
  273. package/dist/entries/video.d.ts +1791 -0
  274. package/dist/entries/video.js +8 -0
  275. package/dist/entries/video.js.map +1 -0
  276. package/dist/entries/workflow.cjs +574 -0
  277. package/dist/entries/workflow.cjs.map +1 -0
  278. package/dist/entries/workflow.d.cts +1733 -0
  279. package/dist/entries/workflow.d.ts +1733 -0
  280. package/dist/entries/workflow.js +5 -0
  281. package/dist/entries/workflow.js.map +1 -0
  282. package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
  283. package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
  284. package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
  285. package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
  286. package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
  287. package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
  288. package/dist/index.cjs +7731 -26444
  289. package/dist/index.cjs.map +1 -1
  290. package/dist/index.d.cts +32 -23733
  291. package/dist/index.d.ts +32 -23733
  292. package/dist/index.js +40 -24641
  293. package/dist/index.js.map +1 -1
  294. package/dist/model-catalog-flJYaa-g.d.cts +561 -0
  295. package/dist/model-catalog-flJYaa-g.d.ts +561 -0
  296. package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
  297. package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
  298. package/dist/presentation-utils-BIqiCzSA.d.cts +90 -0
  299. package/dist/presentation-utils-BdiObtwq.d.ts +90 -0
  300. package/dist/scene-node-types-DjenYFLO.d.cts +1949 -0
  301. package/dist/scene-node-types-DjenYFLO.d.ts +1949 -0
  302. package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
  303. package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
  304. package/dist/types-BRlFPEru.d.cts +511 -0
  305. package/dist/types-BRlFPEru.d.ts +511 -0
  306. package/dist/types-DffyGSy5.d.cts +67 -0
  307. package/dist/types-DffyGSy5.d.ts +67 -0
  308. package/package.json +102 -1
  309. package/src/__tests__/add-captions-plan.test.ts +6 -2
  310. package/src/__tests__/caption-edge-dash.test.ts +23 -0
  311. package/src/__tests__/entity-image-handle.test.ts +61 -1
  312. package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
  313. package/src/__tests__/input-field-extra-keys.test.ts +1 -0
  314. package/src/__tests__/json-kinds.test.ts +10 -0
  315. package/src/__tests__/model-seed-capability.test.ts +34 -0
  316. package/src/__tests__/no-internal-imports.test.ts +1 -1
  317. package/src/__tests__/node-aspect-ratio.test.ts +25 -0
  318. package/src/__tests__/node-preset-extract.test.ts +8 -0
  319. package/src/__tests__/node-run-routes.test.ts +63 -0
  320. package/src/__tests__/node-runtime-keys.test.ts +70 -0
  321. package/src/__tests__/package-entries.test.ts +50 -0
  322. package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
  323. package/src/__tests__/presentation-utils.test.ts +14 -0
  324. package/src/__tests__/preview-gate-use-case.test.ts +151 -0
  325. package/src/__tests__/producer-types.test.ts +15 -0
  326. package/src/__tests__/run-continuation.test.ts +7 -1
  327. package/src/__tests__/seedance-draft.test.ts +74 -0
  328. package/src/__tests__/site-capture-node.test.ts +58 -0
  329. package/src/__tests__/ugc-clip-saved-list.test.ts +19 -0
  330. package/src/__tests__/ugc-lane-wires.test.ts +228 -0
  331. package/src/__tests__/ugc-node-wires.test.ts +606 -0
  332. package/src/__tests__/ugc-run-state.test.ts +85 -7
  333. package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
  334. package/src/__tests__/video-analysis-pricing.test.ts +6 -6
  335. package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
  336. package/src/__tests__/workflow-export-strip.test.ts +14 -0
  337. package/src/add-captions-plan.ts +9 -3
  338. package/src/caption-edge-dash.ts +33 -0
  339. package/src/credit-estimators/index.ts +22 -1
  340. package/src/credit-estimators/pitch-tempo.ts +15 -1
  341. package/src/credit-estimators/speech.ts +72 -4
  342. package/src/credit-estimators/unit-quote.ts +52 -0
  343. package/src/credit-estimators/video-sfx.ts +15 -0
  344. package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
  345. package/src/entity-image-handle.ts +50 -1
  346. package/src/entries/apps.ts +63 -0
  347. package/src/entries/captions.ts +34 -0
  348. package/src/entries/catalogs.ts +65 -0
  349. package/src/entries/credits.ts +104 -0
  350. package/src/entries/edl.ts +42 -0
  351. package/src/entries/entities.ts +144 -0
  352. package/src/entries/i18n.ts +31 -0
  353. package/src/entries/llm-models.ts +63 -0
  354. package/src/entries/media.ts +36 -0
  355. package/src/entries/model-catalog.ts +89 -0
  356. package/src/entries/models.ts +266 -0
  357. package/src/entries/nodes.ts +245 -0
  358. package/src/entries/organizations.ts +9 -0
  359. package/src/entries/pipeline.ts +43 -0
  360. package/src/entries/scene3d.ts +27 -0
  361. package/src/entries/social.ts +297 -0
  362. package/src/entries/types.ts +26 -0
  363. package/src/entries/ugc.ts +14 -0
  364. package/src/entries/video.ts +59 -0
  365. package/src/entries/workflow.ts +172 -0
  366. package/src/fan-out-rows.ts +2 -0
  367. package/src/index.ts +25 -1838
  368. package/src/json-kinds.ts +13 -0
  369. package/src/model-catalog.ts +97 -36
  370. package/src/model-constants.ts +3 -0
  371. package/src/node-mappable-fields.ts +1 -0
  372. package/src/node-preset-export.ts +2 -2
  373. package/src/node-preset-extract.ts +6 -4
  374. package/src/node-run-routes.ts +78 -0
  375. package/src/node-runtime-keys.ts +50 -1
  376. package/src/normalize-node-params.ts +30 -0
  377. package/src/presentation-utils.ts +8 -0
  378. package/src/preview-gate.ts +92 -14
  379. package/src/producer-types.ts +26 -2
  380. package/src/run-continuation.ts +21 -0
  381. package/src/seedance-draft.ts +64 -0
  382. package/src/site-capture-node.ts +82 -0
  383. package/src/social-post.ts +13 -0
  384. package/src/ugc-lane-wires.ts +246 -0
  385. package/src/ugc-node-wires.ts +653 -0
  386. package/src/ugc-run-state.ts +65 -8
  387. package/src/video-analysis-pricing.ts +31 -29
  388. package/src/workflow-export.ts +3 -1
@@ -0,0 +1,1429 @@
1
+ import { d as ModelInputAdjustment, l as SourceImageSize } from '../model-catalog-flJYaa-g.cjs';
2
+
3
+ /** Milli-credits per credit — the intermediate rounding resolution. */
4
+ declare const CREDIT_ROUNDING_RESOLUTION = 1000;
5
+ /** A USD amount → whole credits at the current base. Rounds up. */
6
+ declare function usdToCredits(usd: number): number;
7
+ /** Whole credits → their USD value at the current base. Display/reporting only. */
8
+ declare function creditsToUsd(credits: number): number;
9
+
10
+ /**
11
+ * Film cost ESTIMATION for the studio preview.
12
+ *
13
+ * This is display guidance only — it produces an approximate "this film will
14
+ * cost ≈ N credits" number so the user can see cost before committing to a
15
+ * length + model. The ACTUAL charge is still computed at generation time from
16
+ * `STATIC_CREDIT_COSTS` / the `model_pricing` table per job; this module never
17
+ * bills.
18
+ *
19
+ * Numbers are grounded in the KIE-calibrated per-clip credit costs in
20
+ * `backend/src/ee/billing/credits.ts` (each entry there is annotated with its
21
+ * KIE-credit + USD source). A backend test cross-checks `VIDEO_CLIP_CREDITS`
22
+ * against that source so the estimate can't silently drift from reality.
23
+ *
24
+ * Cost structure of a Story→Video film:
25
+ * total = BASE (duration-independent planning + assembly)
26
+ * + perShot × shotCount (the variable, model-driven bulk)
27
+ * where a shot = one keyframe image + one video clip + one video-critic pass,
28
+ * and shotCount ≈ ceil(duration / clipSeconds) for the chosen model.
29
+ */
30
+ /**
31
+ * Duration-independent overhead, in credits:
32
+ * script/showrunner LLM chain ~30 · music timeline 4 · editor LLM 3 ·
33
+ * final merge 3 · storyboard-cohesion critic 5 ≈ 45.
34
+ * Mirrors the fixed line items in `estimateUpfrontCredits`
35
+ * (backend/src/ee/pipelines/credits.ts).
36
+ */
37
+ declare const FILM_BASE_CREDITS = 45;
38
+ /** Per-shot keyframe image (nano-banana class) — see STATIC_CREDIT_COSTS. */
39
+ declare const KEYFRAME_CREDITS_PER_SHOT = 2;
40
+ /** Per-shot Video Critic pass (first_last frame mode) — see credits.ts. */
41
+ declare const VIDEO_CRITIC_CREDITS_PER_SHOT = 2;
42
+ interface VideoClipCost {
43
+ /** Representative per-clip credit cost at the studio's default config
44
+ * (720p; for the Seedance 2 family this is the ref-image variant the
45
+ * studio uses for identity). Sourced from STATIC_CREDIT_COSTS. */
46
+ readonly credits: number;
47
+ /** Representative clip length in seconds for shot-count estimation. */
48
+ readonly clipSeconds: number;
49
+ }
50
+ /**
51
+ * Representative per-clip credit cost for each user-pinnable video model.
52
+ * Values are the KIE-calibrated credits from STATIC_CREDIT_COSTS at the
53
+ * studio's typical settings (720p; Seedance 2 = 8s 720p +ref). Keep in sync
54
+ * with that table — the backend cross-check test guards drift.
55
+ */
56
+ declare const VIDEO_CLIP_CREDITS: Record<string, VideoClipCost>;
57
+ /**
58
+ * Fallback when no model is pinned (Auto — the Scene Director picks per scene)
59
+ * or the model isn't in the table. kling-turbo is the cheap, common default
60
+ * the engine gravitates to, so it's a reasonable "≈" anchor.
61
+ */
62
+ declare const DEFAULT_VIDEO_CLIP_COST: VideoClipCost;
63
+ interface FilmCreditEstimate {
64
+ /** Total estimated credits for the whole film. */
65
+ readonly totalCredits: number;
66
+ /** Fixed base portion (planning + assembly). */
67
+ readonly baseCredits: number;
68
+ /** Variable portion (shots × per-shot). */
69
+ readonly variableCredits: number;
70
+ /** Estimated number of shots (clips) generated. */
71
+ readonly shotCount: number;
72
+ /** Average credits per second of film (totalCredits / duration). */
73
+ readonly creditsPerSecond: number;
74
+ /** Whether a known model drove the estimate (false = Auto/fallback). */
75
+ readonly modelKnown: boolean;
76
+ }
77
+ /**
78
+ * Estimate the credit cost of a Story→Video film of `durationSeconds` rendered
79
+ * with `videoModel`. Approximate, for the studio's cost preview only.
80
+ */
81
+ declare function estimateFilmCredits(durationSeconds: number, videoModel?: string): FilmCreditEstimate;
82
+
83
+ /**
84
+ * Build composite credit model identifiers for variable pricing.
85
+ * Shared between frontend and backend.
86
+ */
87
+
88
+ /**
89
+ * Compute composite model identifier for variable credit pricing.
90
+ * Examples: "gpt-image:high", "flux:2K", "nano-banana-pro:4K", "ideogram:TURBO",
91
+ * "flux-2-pro:2MP", "flux-2-max:2MP:1ref" (Flux 2 — billed per megapixel).
92
+ *
93
+ * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output
94
+ * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.
95
+ * For video models, uses duration/sound params when the model has variable pricing.
96
+ */
97
+ declare function buildCreditModelIdentifier(provider: string, quality?: string, resolution?: string, renderingSpeed?: string, targetResolution?: string, referenceImageCount?: number): string;
98
+ /**
99
+ * An image request's catalog-snapped parameters PLUS the credit identifier
100
+ * priced off them.
101
+ *
102
+ * `adjustments` is the disclosure channel: every lever this changed, why, and
103
+ * to what. Routes return it in the 200 body so a caller learns their value was
104
+ * corrected instead of silently getting something else.
105
+ */
106
+ interface NormalizedImageGen {
107
+ /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */
108
+ identifier: string;
109
+ /** The catalog model id the params were snapped against (post T2I→I2I swap). */
110
+ modelId: string;
111
+ aspectRatio?: string;
112
+ resolution?: string;
113
+ quality?: string;
114
+ /** Empty when the caller's values were already valid for `modelId`. */
115
+ adjustments: ModelInputAdjustment[];
116
+ }
117
+ /**
118
+ * The catalog model `resolveNormalizedImageGen` snaps against: the provider
119
+ * (Nano Banana when none is named), or — with `swapToI2i` and references
120
+ * attached — its i2i sibling, the model the generate-image route and the
121
+ * workflow payload builder then send. That sibling has its OWN catalog entry
122
+ * and lever lists. Exported so a caller that has to decide something about
123
+ * those lists before the snap (whether a photo's size is worth reading) asks
124
+ * about the same model the snap will use.
125
+ */
126
+ declare function normalizedImageGenModelId(opts: {
127
+ provider: unknown;
128
+ refCount: number;
129
+ swapToI2i?: boolean;
130
+ }): string;
131
+ /**
132
+ * Whether "auto" on a Generate Image request can need its photo's size: the
133
+ * model the snap runs against (`normalizedImageGenModelId` with the swap on)
134
+ * has no native auto. Given the ASSEMBLED reference count, it asks about exactly
135
+ * that model; without one — a write boundary, or a run before its references
136
+ * assemble — about both the provider and its i2i sibling, since references may
137
+ * yet attach.
138
+ */
139
+ declare function imageGenAutoAspectNeedsSourceImage(opts: {
140
+ provider: unknown;
141
+ aspectRatio: unknown;
142
+ refCount?: number;
143
+ }): boolean;
144
+ /**
145
+ * Snap an image request's catalog-governed levers to a combination the model
146
+ * actually accepts, and price the credit identifier off the SNAPPED values.
147
+ *
148
+ * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute
149
+ * their credit identifier TWICE — once in the `creditGuard` preHandler (the
150
+ * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a
151
+ * dedicated test asserts the two stay byte-identical (see
152
+ * `backend/src/routes/__tests__/generate-image.test.ts`, "CHECK === DEBIT").
153
+ * `resolution` and `quality` are pricing dimensions, so a snap applied at only
154
+ * one of those sites breaks that invariant, and `commit_credits` never collects
155
+ * an upward delta — the reserve IS the charge. Putting the snap inside the
156
+ * primitive makes CHECK, DEBIT and the workflow orchestrator agree by
157
+ * construction rather than by everyone remembering to call a normalizer.
158
+ *
159
+ * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a
160
+ * caller can put a number or an object in `resolution`. Non-strings become
161
+ * `undefined` rather than reaching `normalizeModelInput` as a lie.
162
+ *
163
+ * Unknown model ids pass through untouched (same contract as
164
+ * `normalizeModelInput`) — the route's provider enum is the gate for those.
165
+ *
166
+ * `sourceImage` is the size of the photo the request transforms or is drawn
167
+ * from (an image-to-image / edit source, or Generate Image's first wired
168
+ * reference). It only decides "auto" on a model without a native auto, and the
169
+ * ratio is not a pricing dimension on any such model (pinned across the catalog
170
+ * by `auto-aspect-source.test.ts`), so a CHECK that runs before the size is
171
+ * known prices the same identifier as the DEBIT that knows it.
172
+ */
173
+ declare function resolveNormalizedImageGen(opts: {
174
+ provider: string | undefined;
175
+ aspectRatio?: unknown;
176
+ quality?: unknown;
177
+ resolution?: unknown;
178
+ renderingSpeed?: unknown;
179
+ refCount: number;
180
+ swapToI2i?: boolean;
181
+ sourceImage?: SourceImageSize;
182
+ }): NormalizedImageGen;
183
+ /**
184
+ * Reference-aware image-generation credit identifier — the SINGLE source of
185
+ * truth shared by the single-node routes (`/v1/generate-image`,
186
+ * `/v1/image-to-image`) and the workflow orchestrator
187
+ * (`payload-builder.ts`). It centralises the two pricing dimensions that must
188
+ * match across both paths or a Flux 2 generation is billed the wrong tier
189
+ * (Flux 2 commits non-metered / has no upward true-up, so the reserved
190
+ * identifier IS the final charge):
191
+ * - `refCount`: the number of reference images sent to the provider (Flux 2
192
+ * bills per ref). generate-image passes the assembled count (0 for pure
193
+ * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.
194
+ * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i
195
+ * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id
196
+ * matches the variant actually invoked. image-to-image is already an i2i
197
+ * provider → pass `false`.
198
+ *
199
+ * The LoRA short-circuit (`flux-lora-character`) stays at the call site because
200
+ * the routing decision needs a DB lookup the routes/orchestrator own.
201
+ */
202
+ declare function resolveImageGenCreditIdentifier(opts: {
203
+ provider: string | undefined;
204
+ quality?: string;
205
+ resolution?: string;
206
+ renderingSpeed?: string;
207
+ refCount: number;
208
+ swapToI2i?: boolean;
209
+ }): string;
210
+ declare function buildVideoCreditModelIdentifier(provider: string, duration?: number | string, sound?: boolean, nodeType?: "image-to-video" | "text-to-video", mode?: string, resolution?: string, hasVideoRef?: boolean): string;
211
+ /**
212
+ * The credit identifier a Video to Video node's Seedance EDIT lane reserves
213
+ * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit
214
+ * shape with the source clip as reference video 1 — so it prices on the
215
+ * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the
216
+ * measured settlement refunds down to what was actually delivered.
217
+ *
218
+ * It exists because that is a 7-positional-argument call with four
219
+ * easy-to-transpose slots, and FOUR surfaces must agree on it exactly: the
220
+ * orchestrator's reservation (payload-builder.ts), the backend pre-run
221
+ * estimator (ee/billing/credits.ts), the node's cost pill, and the frontend
222
+ * run-level estimate (config-panels/helpers.ts). A quote that disagrees with
223
+ * the reserve is the documented `price_not_configured` / blank-pill trap.
224
+ *
225
+ * `resolution` is the node's one `v2vResolution` field; when unset the model's
226
+ * own UI fill is priced, which is what the lane will send.
227
+ */
228
+ declare function seedanceVideoEditCreditId(provider: string, resolution?: string): string;
229
+ /** What the video credit identifier PRICES for a request, for the levers whose
230
+ * priced value must also be the value we SEND. */
231
+ interface PricedVideoSelection {
232
+ /** The resolution band the reservation is priced at when the request omitted
233
+ * one — and only where the platform DECLARES that band as the provider's own
234
+ * default. `undefined` means "leave `resolution` exactly as the request had
235
+ * it": either the caller supplied one, or the provider's real default is not
236
+ * known to be the band the identifier assumes. */
237
+ resolution?: string;
238
+ /** The length the reservation is priced at and the wire carries, for a
239
+ * provider whose price follows the clip length (LTX's seeded tier, the KIE
240
+ * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:
241
+ * their duration passes through. */
242
+ duration?: number;
243
+ /** Non-empty only for a lever the caller ASKED for and did not get (a 7s
244
+ * request snapped to the 6s tier). Filling an omitted lever is a disclosure of
245
+ * the price already being charged, not a correction, so it reports nothing. */
246
+ adjustments: ModelInputAdjustment[];
247
+ }
248
+ /**
249
+ * The other half of the video money path: `normalizeVideoRequestParams` snaps a
250
+ * value the CATALOG governs; this returns the value the PRICE ladder governs.
251
+ *
252
+ * Two defects it closes, both of the same shape — the identifier prices one
253
+ * thing and the wire carries another, and `commit_credits` (migration 176) only
254
+ * ever refunds a surplus, so the reservation is the final charge:
255
+ *
256
+ * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted
257
+ * `resolution` as a concrete band (LTX → 1080p; a
258
+ * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving
259
+ * the key unset then lets the provider pick — documented for the KIE members
260
+ * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on
261
+ * Replicate. Sending the band we priced makes the two agree by construction.
262
+ *
263
+ * The fill is deliberately limited to providers with a DECLARED default.
264
+ * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the
265
+ * cheapest tier for a resolution-priced provider with no
266
+ * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified
267
+ * provider default: seedance-2 / -fast / -mini pin `resolution: "720p"`
268
+ * KIE-side while the identifier prices 480p, so filling 480p would downgrade
269
+ * the render to match a price we already know is wrong. That mismatch is a
270
+ * pre-existing identifier bug and is fixed by seeding the row, not here.
271
+ *
272
+ * 2. **Duration.** Every provider whose price follows the clip length is
273
+ * charged at the length it RENDERS: its own default when the request named
274
+ * none (catalog `defaultDuration`), the nearest length it offers otherwise
275
+ * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is
276
+ * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;
277
+ * sending 7s would bill six and render seven. The same value is returned for
278
+ * the other length-priced providers (the KIE ladders, Gemini Omni), so what
279
+ * is priced is what is sent. Auto (-1) is the model's call and is untouched.
280
+ *
281
+ * Pure, and IDEMPOTENT against the identifier: feeding its output back in
282
+ * cannot move the reserved tier. `video-request-normalize.test.ts` proves that
283
+ * over every provider × resolution × duration.
284
+ */
285
+ declare function pricedVideoSelection(opts: {
286
+ provider: string;
287
+ resolution?: string;
288
+ duration?: number | string;
289
+ }): PricedVideoSelection;
290
+ /**
291
+ * Compute composite model identifier for motion control with duration-tiered pricing.
292
+ * Examples: "kling-3.0-motion:10s", "kling-3.0-motion:1080p:15s", "motion-transfer:5s"
293
+ *
294
+ * Wan Animate providers use resolution-tiered pricing (not per-second):
295
+ * "wan-animate-move" (480p default), "wan-animate-move:580p", "wan-animate-move:720p"
296
+ *
297
+ * @param provider - Motion control provider key ("kling" for 2.6, "kling-3.0", "wan-animate-move", "wan-animate-replace")
298
+ * @param resolution - "720p" or "1080p" (Kling), "480p" or "580p" or "720p" (Wan Animate)
299
+ * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)
300
+ */
301
+ declare function buildMotionCreditModelIdentifier(provider: string, resolution: string, videoDuration?: number): string;
302
+ /**
303
+ * The Suno operations whose credit key depends on the model VERSION.
304
+ *
305
+ * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard
306
+ * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts
307
+ * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat
308
+ * per-operation key and ignores the version the node carries — mashup (:648),
309
+ * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),
310
+ * replace-section (:710), style-boost (:771), convert-wav (:962),
311
+ * lyrics (:482), music-video (:594), voice (:1218).
312
+ *
313
+ * Anything that QUOTES a Suno price — a dropdown row, a node badge, the
314
+ * workflow-credit estimator — must follow the same split, or it displays a
315
+ * credit key the route never charges.
316
+ */
317
+ declare const SUNO_VERSION_PRICED_OPERATIONS: readonly ["suno-generate", "suno-cover", "suno-extend"];
318
+ /**
319
+ * The seven Suno operations that appear behind a select/dropdown UI (model
320
+ * pickers, node badges, the credit estimator) — the three version-priced
321
+ * operations above, plus the four flat-key operations exercised by
322
+ * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the
323
+ * model dropdowns, node badges) can iterate or count it without redeclaring
324
+ * the list and drifting from this one.
325
+ */
326
+ declare const SUNO_SELECT_OPERATIONS: readonly ["suno-generate", "suno-cover", "suno-extend", "suno-mashup", "suno-add-instrumental", "suno-add-vocals", "suno-upload-extend"];
327
+ /**
328
+ * Adjust Speed's price id: motion-compensated ("smooth") interpolation is its
329
+ * own, dearer tier. The route, the workflow run, and the editor's badge and
330
+ * run estimate all price through this, so none of them can quote the fast tier
331
+ * for a smooth run.
332
+ */
333
+ declare function speedRampCreditId(quality: unknown): "speed-ramp" | "speed-ramp:smooth";
334
+ /**
335
+ * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,
336
+ * cheaper per-output-minute row; a `final` render keeps the bare id. One id per
337
+ * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything
338
+ * that is not exactly "proxy" is the final, as the route and the node default
339
+ * it. The route, the workflow run, and the editor's badge and run estimate all
340
+ * price through this; the job itself is always named `apply-edl`.
341
+ */
342
+ declare function applyEdlCreditId(quality: unknown): "apply-edl" | "apply-edl:proxy";
343
+ /**
344
+ * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by
345
+ * how many speakers it composites at once. `standard` — at most two tiles on
346
+ * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which
347
+ * tier a render is in is the render rule's to say (the app's
348
+ * `@nodaro/render-rules`), never this vocabulary's.
349
+ */
350
+ declare const SPEAKER_VIEW_PRICE_TIERS: readonly ["standard", "complex"];
351
+ type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number];
352
+ type SpeakerViewCreditId = "speaker-view" | "speaker-view:proxy" | "speaker-view:complex" | "speaker-view:complex:proxy";
353
+ /** Every id `speakerViewCreditId` can name. */
354
+ declare const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[];
355
+ /**
356
+ * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers
357
+ * decided 2026-10-10): a Preview (`quality` "proxy") reserves on its own row,
358
+ * anything else on the final's, and each in its price tier — `standard` on
359
+ * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /
360
+ * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent
361
+ * included) names the `complex` row: a caller that cannot tell quotes high,
362
+ * never low. The job is always named `speaker-view`; only its credit id
363
+ * follows the quality and the tier.
364
+ */
365
+ declare function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId;
366
+ /**
367
+ * OUR Nodaro credit key for a Suno operation, given the model version and the
368
+ * operation (which is also the node type and the BullMQ job name).
369
+ *
370
+ * This is the single source of truth for the Suno pricing contract, shared by
371
+ * the reservation path (routes/suno.ts creditGuard), the egress seam
372
+ * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),
373
+ * both workflow-credit estimators (ee/billing/credits.ts and the frontend
374
+ * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno
375
+ * node badges. It is a billing key — NEVER a KIE provider id — which is what
376
+ * satisfies the B3 egress invariant.
377
+ *
378
+ * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no
379
+ * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a
380
+ * non-version-priced operation is returned unchanged.
381
+ */
382
+ declare function sunoCreditType(model: string | undefined, operation: string): string;
383
+ /**
384
+ * Suno version → Nodaro credit key for the version-priced operations. One row
385
+ * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`
386
+ * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version
387
+ * without touching code. Every ACTIVE version MUST have a row here — guarded
388
+ * by `__tests__/suno-credit-type.test.ts` (a new active version with no key
389
+ * would silently bill at the operation key).
390
+ */
391
+ declare const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>>;
392
+
393
+ /**
394
+ * Pure credit estimators for video-utility nodes (loop-video, trim-video,
395
+ * combine-videos, assemble-narrated-video). Used by frontend (Run-button
396
+ * display + API call) AND backend (creditGuard reservation, the workflow
397
+ * run's reservation, the workflow estimate) so the displayed cost equals
398
+ * what gets debited.
399
+ *
400
+ * Every estimate counts pricing UNITS and returns units × CREDIT_UNIT base
401
+ * credits: a unit is 5 seconds of output, ~24 frames a smart loop cut
402
+ * searches, each combine input beyond two, and each step of Assemble Narrated
403
+ * Video (3 + 1 per 6 blocks).
404
+ */
405
+ declare const VIDEO_UTIL_PRICING: {
406
+ /** Base credits per pricing unit. The node's own `model_pricing` row is one unit. */
407
+ readonly CREDIT_UNIT: 10;
408
+ /** Base credits per 5 seconds of output (one unit), ceiling. */
409
+ readonly CREDITS_PER_5_SEC: 10;
410
+ /** Smart-loop-cut work scales at one unit per ~24 frames searched. */
411
+ readonly FRAMES_PER_CREDIT: 24;
412
+ /** Used when an upstream node hasn't produced a measurable duration yet. */
413
+ readonly FALLBACK_DURATION_SECONDS: 8;
414
+ };
415
+ interface LoopVideoEstimatorInput {
416
+ mode?: "repeat" | "duration";
417
+ repeatCount?: number;
418
+ targetDuration?: number;
419
+ smartLoopCutBeforeRepeat?: boolean;
420
+ smartLoopCutLookback?: number;
421
+ }
422
+ interface TrimVideoEstimatorInput {
423
+ trimMode?: "time" | "seconds" | "keep-first-seconds" | "keep-last-seconds" | "frames" | "smart-loop-cut";
424
+ startTime?: number;
425
+ endTime?: number;
426
+ /** Seconds-mirror of frames mode: trim N seconds from start AND/OR end. */
427
+ trimStartSeconds?: number;
428
+ trimEndSeconds?: number;
429
+ /** Keep only the first/last N seconds (probes duration at runtime). */
430
+ keepFirstSeconds?: number;
431
+ keepLastSeconds?: number;
432
+ trimStartFrames?: number;
433
+ trimEndFrames?: number;
434
+ smartLoopCutLookback?: number;
435
+ }
436
+ interface CombineVideosEstimatorInput {
437
+ /** Any id from `COMBINE_TRANSITIONS`. The estimator only branches on
438
+ * `cut` vs non-cut, so accepting the full string keeps the catalog as
439
+ * the single source of truth. */
440
+ transition?: string;
441
+ transitionDuration?: number;
442
+ trimStartFrames?: number;
443
+ trimEndFrames?: number;
444
+ }
445
+ declare function estimateLoopVideoCredits(data: LoopVideoEstimatorInput, upstreamDuration?: number): number;
446
+ declare function estimateTrimVideoCredits(data: TrimVideoEstimatorInput, upstreamDuration?: number): number;
447
+ declare function estimateCombineVideosCredits(data: CombineVideosEstimatorInput, upstreamDurations: ReadonlyArray<number | undefined>): number;
448
+ interface LoopTrimEstimatorInput {
449
+ enabled?: boolean;
450
+ framesToTest?: number;
451
+ }
452
+ /** Add-on credits charged for the smart-loop-cut post-process applied to an
453
+ * image-to-video output. Returns 0 when loopTrim is undefined or disabled.
454
+ * Formula: CREDIT_UNIT × (ceil(duration / 5) + ceil(framesToTest / 24)) —
455
+ * the same units as Trim Video's smart loop cut, so 8 s at 16 frames → 30. */
456
+ declare function estimateLoopTrimAddonCredits(loopTrim: LoopTrimEstimatorInput | undefined, outputDurationSeconds: number): number;
457
+ /** BASE credits for assemble-narrated-video: 3 units flat + 1 per 6
458
+ * blocks. 6→40, 24→70, 60→130. Single source of truth shared by the backend
459
+ * route/creditGuard (`backend/src/providers/video/narrated-block-fit.ts`
460
+ * re-exports this), the workflow run's reservation and the frontend pre-run
461
+ * estimate (`frontend/src/hooks/use-estimated-credits.ts`). */
462
+ declare function assembleNarratedVideoCredits(blockCount: number): number;
463
+
464
+ /**
465
+ * Image Overlay pricing — one formula shared by the backend route
466
+ * (creditGuard computeCredits), the orchestrator's reservation override, the
467
+ * workflow estimator and the canvas Run button, so every surface quotes and
468
+ * charges the same number.
469
+ *
470
+ * credits = BASE + PER_VARIANT × (number of distinct, valid platform ids)
471
+ *
472
+ * The base covers the composite and its mask; every extra platform render is
473
+ * one more resize + encode + upload. Worked examples (pinned by the tests and
474
+ * repeated in docs/nodes/processing-video/image-overlay.md — keep them equal):
475
+ * 0 variants → 10, 2 → 14, 12 (every platform) → 34.
476
+ */
477
+ declare const IMAGE_OVERLAY_BASE_CREDITS = 10;
478
+ declare const IMAGE_OVERLAY_VARIANT_CREDITS = 2;
479
+ /** Distinct platform ids the registry knows — the count the price is built from. */
480
+ declare function imageOverlayBillableVariants(variants: ReadonlyArray<unknown> | undefined): string[];
481
+ declare function imageOverlayCredits(variants: ReadonlyArray<unknown> | undefined): number;
482
+
483
+ /**
484
+ * Video SFX pricing — which price row a run is charged from, by the length of
485
+ * the input video. One mapping for every place that names the row: the route
486
+ * (`POST /v1/video-sfx`), the workflow run's reservation, the node's Run
487
+ * button and the workflow estimates.
488
+ *
489
+ * Each bucket is a `model_pricing` row (`replicate-mmaudio:<n>s`); the credit
490
+ * amounts live there, never here. Worked examples (repeated in
491
+ * docs/nodes/ai-video/video-sfx.md):
492
+ * 5 s → `:8s`, 12 s → `:15s`, 31 s → `:60s`, 180 s → `:300s`.
493
+ */
494
+ declare const VIDEO_SFX_PRICING: {
495
+ /** The longest input video a run accepts, in seconds. */
496
+ readonly MAX_DURATION_SEC: 300;
497
+ /** The length priced (and generated) when the input video cannot be measured. */
498
+ readonly FALLBACK_DURATION_SEC: 8;
499
+ };
500
+ /**
501
+ * The price row for an input video of `durationSec` seconds. An unknown or
502
+ * non-positive length prices the fallback length; anything past the cap prices
503
+ * the last bucket (the route refuses such a video before it gets here).
504
+ */
505
+ declare function videoSfxCreditId(durationSec: number | null | undefined): string;
506
+ /**
507
+ * The price row a QUOTE names for an input video of `durationSec` seconds —
508
+ * every estimate before a run (the node's Run button, the workflow estimate,
509
+ * the server's run estimate, a listing). A known length is the row its run is
510
+ * charged ({@link videoSfxCreditId}). An UNKNOWN length is the last row, 300
511
+ * seconds (decided 2026-10-13): a run measures the clip before it reserves and
512
+ * refuses one over 300 s, so that row is the most any run can be charged —
513
+ * the quote is never below the charge, as Video Mask and Video Depth quote an
514
+ * unknown clip at their highest row.
515
+ */
516
+ declare function videoSfxQuoteCreditId(durationSec: number | null | undefined): string;
517
+
518
+ /**
519
+ * Text to Audio (sound effects) pricing — which price row a run is charged
520
+ * from, by the length of the clip it asks for. One mapping for every place
521
+ * that names the row: the route (`POST /v1/text-to-audio`), the workflow run's
522
+ * reservation, the node's Run button and the workflow estimates.
523
+ *
524
+ * `elevenlabs-sfx` is priced per second: one `model_pricing` row per whole
525
+ * second (`elevenlabs-sfx:1s` … `elevenlabs-sfx:30s`); the credit amounts live
526
+ * there, never here. The requested length is rounded UP to whole seconds, and
527
+ * a request that names no length is priced as 5 seconds. Worked examples
528
+ * (repeated in docs/nodes/ai-audio/text-to-audio.md):
529
+ * 0.5 s → `:1s`, 6 s → `:6s`, 22.3 s → `:23s`, no duration → `:5s`.
530
+ */
531
+ declare const TEXT_TO_AUDIO_PRICING: {
532
+ /** The engine priced per second of requested audio. */
533
+ readonly PER_SECOND_PROVIDER: "elevenlabs-sfx";
534
+ /** The longest clip a request may ask for, in seconds. */
535
+ readonly MAX_DURATION_SEC: 30;
536
+ /** The length priced when a request names none (the model picks the length). */
537
+ readonly DEFAULT_BILLED_SEC: 5;
538
+ };
539
+ /** Every per-second price row, shortest first: `elevenlabs-sfx:1s` … `:30s`. */
540
+ declare const TEXT_TO_AUDIO_SFX_CREDIT_IDS: readonly string[];
541
+ /**
542
+ * The whole seconds a request of `duration` seconds is billed for: rounded up,
543
+ * at most the 30 s cap. No usable length (absent, empty, non-numeric, zero or
544
+ * negative) bills the 5 s default. A numeric string counts — a field mapping
545
+ * can deliver the length as text.
546
+ */
547
+ declare function textToAudioBilledSeconds(duration: unknown): number;
548
+ /**
549
+ * The price row for a Text to Audio request. A request with no provider runs
550
+ * (and is priced as) the default engine. An engine that is not priced per
551
+ * second keeps its own flat row.
552
+ */
553
+ declare function textToAudioCreditId(provider: string | null | undefined, duration: unknown): string;
554
+
555
+ /**
556
+ * LTX 2.3 Pro Extend pricing — a per-second price row times the seconds added.
557
+ *
558
+ * `ltxExtendDurationSec` is the one reading of the requested length, and the
559
+ * value it returns is the one SENT to the model: the route, the workflow run
560
+ * and the worker all pass it on, so the seconds priced are the seconds
561
+ * rendered. An absent length is the model's own default (6 seconds).
562
+ *
563
+ * The per-second amount lives in the `model_pricing` row, never here. Worked
564
+ * examples at the row's listed price of 40 (repeated in
565
+ * docs/nodes/ai-video/extend-video.md):
566
+ * 2 s → 80, 6 s (or no length) → 240, 20 s → 800.
567
+ */
568
+ declare const LTX_EXTEND_PER_SECOND_CREDIT_ID = "ltx-2.3-pro-extend:per-second";
569
+ declare const LTX_EXTEND_DURATION: {
570
+ readonly MIN_SEC: 1;
571
+ readonly MAX_SEC: 20;
572
+ readonly DEFAULT_SEC: 6;
573
+ };
574
+ /**
575
+ * The seconds an LTX extend adds: a whole number from 1 to 20, the default
576
+ * when none (or nothing readable) was given. Accepts a numeric string, which a
577
+ * workflow field mapping can deliver.
578
+ */
579
+ declare function ltxExtendDurationSec(raw: unknown): number;
580
+
581
+ /**
582
+ * LTX 2.3 Pro Retake pricing — a per-second price row times the seconds of
583
+ * the replaced window.
584
+ *
585
+ * `ltxRetakeDurationSec` is the one reading of the window's length, and the
586
+ * value it returns is the one SENT to the model: the route, the workflow run
587
+ * and the worker all pass it on. The window is at least 2 seconds (the
588
+ * route's own floor) and may be fractional — the editor's range picker sets
589
+ * it to the frame.
590
+ *
591
+ * The per-second amount lives in the `model_pricing` row, never here; a run
592
+ * is the row × these seconds, rounded up to a whole credit.
593
+ */
594
+ declare const LTX_RETAKE_PER_SECOND_CREDIT_ID = "ltx-2.3-pro-retake:per-second";
595
+ /** The shortest window a retake replaces, in seconds. */
596
+ declare const LTX_RETAKE_MIN_DURATION_SEC = 2;
597
+ /**
598
+ * The seconds a retake replaces: the requested window, never below 2; 2 when
599
+ * none (or nothing readable) was given. Accepts a numeric string, which a
600
+ * workflow field mapping can deliver.
601
+ */
602
+ declare function ltxRetakeDurationSec(raw: unknown): number;
603
+
604
+ /** Characters per price unit. */
605
+ declare const SPEECH_PRICE_UNIT_CHARS = 100;
606
+ /** The minimum units a request is priced at, however short its text. */
607
+ declare const SPEECH_FLOOR_UNITS = 8;
608
+ /** Appended to a speech model's id to name its per-unit price row. */
609
+ declare const SPEECH_UNIT_CREDIT_SUFFIX = ":per-100-chars";
610
+ /**
611
+ * The price-row id of one unit for the model a request runs as. The legacy
612
+ * `elevenlabs` alias prices on turbo's row, as it runs on turbo; any other id
613
+ * (including the dialogue model) is used as given.
614
+ */
615
+ declare function speechUnitCreditId(modelId: string): string;
616
+ /**
617
+ * Units a text of `chars` characters is priced at: every started 100, and
618
+ * never fewer than the floor. A count that is not a finite non-negative
619
+ * number (node data written straight into workflow JSON) is the floor.
620
+ */
621
+ declare function speechPriceUnits(chars: number): number;
622
+ /** Base credits for `chars` characters at `perUnitCredits` per unit (the model's `:per-100-chars` row). */
623
+ declare function speechCredits(chars: number, perUnitCredits: number): number;
624
+ /**
625
+ * The id of the exact charge of a whole request of `units` units on `modelId`:
626
+ * `<model>:per-100-chars:<N>u`. Never a row of its own — a price lookup prices
627
+ * it from the model's unit row × N as one whole, exactly as a request of that
628
+ * length is reserved. Served only while length pricing is on, like the unit
629
+ * row it is priced from.
630
+ */
631
+ declare function speechQuoteCreditId(modelId: string, units: number): string;
632
+ /** A `<model>:per-100-chars:<N>u` id, read back. */
633
+ interface SpeechQuoteCreditIdParts {
634
+ /** The speech model (canonical id) the request runs as. */
635
+ model: string;
636
+ /** Its `<model>:per-100-chars` unit row. */
637
+ unitId: string;
638
+ /** Units priced: at least the floor, at most the model's per-request cap in started hundreds. */
639
+ units: number;
640
+ }
641
+ /**
642
+ * The parts of a `<model>:per-100-chars:<N>u` id, or undefined for any other id
643
+ * — including a model that is not a speech model under its canonical id, and a
644
+ * unit count no request on that model can be priced at (below the floor, or
645
+ * above the model's cap in started hundreds).
646
+ */
647
+ declare function parseSpeechQuoteCreditId(id: string): SpeechQuoteCreditIdParts | undefined;
648
+ /**
649
+ * Whether an id is a length price of speech — a `<model>:per-100-chars` unit
650
+ * row or a `<model>:per-100-chars:<N>u` request quote — by its shape alone.
651
+ * Both are served only while the server prices speech by length.
652
+ */
653
+ declare function isSpeechLengthPriceId(id: string): boolean;
654
+ /**
655
+ * The speech model a length price id is priced for — the id a request of
656
+ * that model is reserved at, so the two are priced under the same id — or
657
+ * undefined for any other id.
658
+ */
659
+ declare function speechLengthPriceModel(id: string): string | undefined;
660
+
661
+ /**
662
+ * The price of a whole run priced per unit, as ONE id.
663
+ *
664
+ * Some runs are charged a multiple of a one-unit price row: minutes of an
665
+ * Apply EDL or Speaker View render, 5-second steps of a Trim / Loop / Combine
666
+ * / Mask Composite result, seconds of an LTX extend or retake, started
667
+ * hundreds of a speech text. The server prices such a run as a whole — the
668
+ * row's base × the units, marked up ONCE and rounded up once — so a client
669
+ * that multiplies the served one-unit price (already rounded up) by the units
670
+ * can quote more than the run is charged.
671
+ *
672
+ * `unitQuoteCreditId(rateId, units)` names that whole price:
673
+ * `<rateId>:<units>u`. `POST /v1/credits/model-costs` and
674
+ * `GET /v1/credits/model-cost` answer it with the figure the run is charged,
675
+ * for a rate the server charges per unit and a unit count a run can have;
676
+ * any other id lands in `missing`. A client quotes that answer rather than
677
+ * multiplying. (A speech request's id, `<model>:per-100-chars:<N>u`, is this
678
+ * id on the model's per-100-characters row.)
679
+ *
680
+ * Units may be fractional — a retake window is set to the frame — and are
681
+ * written exactly as JavaScript prints the number, so the server reads back
682
+ * the same value the client priced.
683
+ */
684
+ /** `<rateId>:<units>u` — the id of the whole price of `units` of `rateId`. */
685
+ declare function unitQuoteCreditId(rateId: string, units: number): string;
686
+ /** A `<rateId>:<units>u` id, read back. */
687
+ interface UnitQuoteCreditIdParts {
688
+ /** The one-unit price row. */
689
+ rateId: string;
690
+ /** How many of it the run is priced at (a positive number, possibly fractional). */
691
+ units: number;
692
+ }
693
+ /**
694
+ * The parts of a `<rateId>:<units>u` id by its shape alone, or undefined. Which
695
+ * rates the server prices this way, and at how many units, is the server's to
696
+ * say: an id it does not price lands in `missing`.
697
+ */
698
+ declare function parseUnitQuoteCreditId(id: string): UnitQuoteCreditIdParts | undefined;
699
+
700
+ /**
701
+ * The price of a whole Voice Changer Pro convert, as ONE id.
702
+ *
703
+ * A convert is charged as one whole: every changed speaker's slot is priced in
704
+ * base credits (a recast slot by the length of its stem, a Re-speak slot by
705
+ * its characters on its engine's row), the slots are summed, and the sum is
706
+ * marked up ONCE at `voice-changer-pro`. A client that prices each slot on the
707
+ * served (already marked-up, already rounded) rows and adds them up cannot
708
+ * reach that figure: the rounding happens in a different place.
709
+ *
710
+ * `voiceChangerProQuoteCreditId(slots)` names the whole price:
711
+ * `voice-changer-pro:<slot>,<slot>,…`, one slot per changed speaker, where a
712
+ * slot is
713
+ *
714
+ * - `sts-<seconds>` — a recast (speech-to-speech) slot whose stem is that
715
+ * many seconds long (the speaker's last utterance end); `sts` alone when
716
+ * the length is unknown (priced as one minute, as the convert reserves it);
717
+ * - `respeak-<chars>` — a Re-speak slot on the default engine (v3) that
718
+ * re-speaks that many characters; `respeak` alone when the count is unknown;
719
+ * - `respeak-v4-<chars>` — a Re-speak slot on the v4 engine (`respeak-v4`
720
+ * when the count is unknown); `respeak-v3-<chars>` names v3 explicitly
721
+ * and is the same price as `respeak-<chars>`;
722
+ * - `respeak-v4t-<chars>` — a v4 slot speaking a TRANSLATION of its
723
+ * `<chars>` transcript characters. The convert reserves such a slot for more
724
+ * speech than its transcript holds (a line may be re-rendered once,
725
+ * shorter); the server applies that allowance, so the client sends the
726
+ * transcript's own count and never the arithmetic. Only v4 speaks a
727
+ * translation, so there is no `v3t`.
728
+ *
729
+ * `POST /v1/credits/model-costs` and `GET /v1/credits/model-cost` answer it
730
+ * with the figure the convert reserves; an id the server does not price
731
+ * (a malformed slot, more slots than a convert takes, a count out of range)
732
+ * lands in `missing`. Numbers are written exactly as JavaScript prints them,
733
+ * so the server reads back the value the client priced.
734
+ */
735
+ /** The id a convert is reserved (and marked up) at. */
736
+ declare const VOICE_CHANGER_PRO_QUOTE_RATE_ID = "voice-changer-pro";
737
+ /** A Re-speak engine, as the quote names it. */
738
+ type VoiceChangerProQuoteRespeakEngine = "v3" | "v4";
739
+ /** One changed speaker of a convert, as the quote prices it. */
740
+ type VoiceChangerProQuoteSlot =
741
+ /** A recast slot: the stem's length in seconds; `null` (or not a positive number) = unknown. */
742
+ {
743
+ readonly kind: "sts";
744
+ readonly seconds: number | null;
745
+ }
746
+ /**
747
+ * A Re-speak slot: the characters of its transcript; `null` (or not a
748
+ * positive number) = unknown. `engine` absent = the default engine (v3).
749
+ * `translated` = the slot speaks the plan's target language — read only on
750
+ * v4, the one engine that speaks a translation (the convert route reads it
751
+ * the same way).
752
+ */
753
+ | {
754
+ readonly kind: "respeak";
755
+ readonly chars: number | null;
756
+ readonly engine?: VoiceChangerProQuoteRespeakEngine;
757
+ readonly translated?: boolean;
758
+ };
759
+ /** A `voice-changer-pro:<slots>` id, read back into the convert's pricing inputs (slot order kept per kind). */
760
+ interface VoiceChangerProQuoteCreditIdParts {
761
+ /** Stem seconds per recast slot; `null` = unknown. */
762
+ readonly stsSlotSeconds: ReadonlyArray<number | null>;
763
+ /** Transcript characters per Re-speak slot; `null` = unknown. */
764
+ readonly respeakChars: ReadonlyArray<number | null>;
765
+ /** The engine of each Re-speak slot, index-aligned with `respeakChars`; `null` = not named (the default engine). */
766
+ readonly respeakEngines: ReadonlyArray<VoiceChangerProQuoteRespeakEngine | null>;
767
+ /** Whether each Re-speak slot speaks a translation, index-aligned with `respeakChars` (only ever true on v4). */
768
+ readonly respeakTranslated: ReadonlyArray<boolean>;
769
+ }
770
+ /** `voice-changer-pro:<slot>,…` — the id of the whole price of a convert with these changed speakers. */
771
+ declare function voiceChangerProQuoteCreditId(slots: ReadonlyArray<VoiceChangerProQuoteSlot>): string;
772
+ /**
773
+ * The parts of a `voice-changer-pro:<slots>` id by its shape alone, or
774
+ * undefined (not such an id, an empty or malformed slot). How many slots and
775
+ * what counts the server prices is the server's to say: an id it does not
776
+ * price lands in `missing`.
777
+ */
778
+ declare function parseVoiceChangerProQuoteCreditId(id: string): VoiceChangerProQuoteCreditIdParts | undefined;
779
+
780
+ /**
781
+ * Pitch & Tempo pricing — per STARTED minute of the input media (decided
782
+ * 2026-10-12), at least one minute, at most 30.
783
+ *
784
+ * One `model_pricing` row, `pitch-tempo`, holds the credits per minute; a run
785
+ * reserves `pitch-tempo:<N>m` (N = started minutes), which billing prices as
786
+ * that row × N — never a row of its own, so a retune of the rate row moves the
787
+ * route, the workflow run, the node's Run button and every estimate together.
788
+ * The same id is built by the route (from the probed length), the workflow run
789
+ * (the same probe) and the editor (the upstream length it knows).
790
+ *
791
+ * Worked examples at the row's listed rate of 20 (repeated in
792
+ * docs/nodes/processing-audio/pitch-tempo.md):
793
+ * 0:45 → 20, 1:00 → 20, 1:01 → 40, 3:10 → 80, 30:00 → 600.
794
+ */
795
+ declare const PITCH_TEMPO_PRICING: {
796
+ /** The rate row: credits per started minute. Never reserved by itself. */
797
+ readonly RATE_CREDIT_ID: "pitch-tempo";
798
+ /** The longest input a run accepts, in seconds (the route refuses longer). */
799
+ readonly MAX_DURATION_SEC: 1800;
800
+ /** The most minutes a `pitch-tempo:<N>m` id can carry. */
801
+ readonly MAX_MINUTES: 30;
802
+ /** The rate row's launch value (admin-retunable in /admin/models). */
803
+ readonly CREDITS_PER_MINUTE_DEFAULT: 20;
804
+ };
805
+ /** The control ranges every surface validates against. */
806
+ declare const PITCH_TEMPO_LIMITS: {
807
+ readonly SEMITONES_MIN: -12;
808
+ readonly SEMITONES_MAX: 12;
809
+ readonly TEMPO_MIN: 0.5;
810
+ readonly TEMPO_MAX: 2;
811
+ };
812
+ /**
813
+ * Started minutes of an input of `durationSec` seconds: ceil(sec / 60), at
814
+ * least 1, at most 30. An unknown or non-positive length counts as one minute
815
+ * here; a quote of an unknown length names 30 instead
816
+ * ({@link pitchTempoQuoteCreditId}), and a run always measures.
817
+ */
818
+ declare function pitchTempoStartedMinutes(durationSec: number | null | undefined): number;
819
+ /** `pitch-tempo:<N>m` — the id a run on an input of `durationSec` seconds reserves. */
820
+ declare function pitchTempoCreditId(durationSec: number | null | undefined): string;
821
+ /**
822
+ * The id a QUOTE names for an input of `durationSec` seconds — every estimate
823
+ * before a run. A known length is the id its run reserves
824
+ * ({@link pitchTempoCreditId}). An UNKNOWN length is the 30-minute id
825
+ * (decided 2026-10-13): a run measures the file before it reserves and refuses
826
+ * one it cannot measure or one over 30 minutes, so 30 minutes is the most any
827
+ * run can be charged and the quote is never below the charge.
828
+ */
829
+ declare function pitchTempoQuoteCreditId(durationSec: number | null | undefined): string;
830
+ /** The minutes of a `pitch-tempo:<N>m` id (1 ≤ N ≤ 30), or `undefined` for any other id. */
831
+ declare function parsePitchTempoCreditId(id: string): {
832
+ minutes: number;
833
+ } | undefined;
834
+ /** rate × minutes, rounded up, at least 1 credit — what a `pitch-tempo:<N>m` id costs. */
835
+ declare function pitchTempoBaseCredits(ratePerMinute: number, minutes: number): number;
836
+ /** The frequency ratio for a shift of `semitones` (12 = one octave up = ×2). */
837
+ declare function semitonesToPitchRatio(semitones: number): number;
838
+
839
+ /**
840
+ * Topaz image upscale — the single authority for "which lever did the user
841
+ * pull, what do we send, and what do we charge".
842
+ *
843
+ * KIE's `topaz/image-upscale` takes exactly ONE quality lever:
844
+ * upscale_factor: "1" | "2" | "4" (default "2")
845
+ * There is no target-resolution parameter (docs.kie.ai/market/topaz/image-upscale,
846
+ * verified 2026-09-02). The editor nevertheless shipped TWO controls — an
847
+ * `upscaleFactor` select AND a `targetResolution` select (2K/4K/8K) — and billed
848
+ * on the second one, which never reached the worker. Everyone who bought 4K or
849
+ * 8K got a 2x render at 2x/4x the price (app-reports triage 2026-09-01 §4.3).
850
+ *
851
+ * So: the FACTOR is the lever. `targetResolution` survives only as a legacy
852
+ * input (stored node data, old API/MCP callers) and is mapped forward here.
853
+ * The credit tier is derived from the SAME resolution, which is why callers
854
+ * must pass `creditTier` into `buildCreditModelIdentifier` rather than the raw
855
+ * request value — that is what makes CHECK = DEBIT = SENT.
856
+ *
857
+ * The composite `topaz-image-upscale:4K` is retained as the id of the 4x tier
858
+ * (migration 288 wrote that row; renaming it would need a pricing migration for
859
+ * zero user-visible gain). Read it as "the top Topaz tier", not as a promise of
860
+ * 4096 pixels. `topaz-image-upscale:8K` stays priced in STATIC_CREDIT_COSTS so
861
+ * historical usage_logs still resolve, but nothing can reserve it any more.
862
+ *
863
+ * Resolution order (fix round 1, 2026-09-02 review):
864
+ * 1. Resolve the WINNING factor first — a valid `upscaleFactor` always wins;
865
+ * an invalid one falls through to `targetResolution` exactly as if it had
866
+ * never been sent, rather than freezing the default before the legacy
867
+ * tier gets a chance to raise it (an invalid factor + a stored 4K/8K tier
868
+ * must still resolve — and bill — at the tier's factor, not the default).
869
+ * 2. Only THEN build `adjustments`, so every `to` reflects the resolved
870
+ * factor rather than an intermediate guess, and every `from` is the raw,
871
+ * untransformed input string (never the trimmed/uppercased copy used
872
+ * internally to match).
873
+ * 3. A valid `upscaleFactor` alongside a `targetResolution` it disagrees
874
+ * with emits an informational (not corrective) adjustment — the stored
875
+ * legacy choice is being overridden, not silently dropped — with
876
+ * `to: undefined` because nothing was actually sent for that field.
877
+ * Agreement (they resolve to the same factor) is reported as nothing:
878
+ * there is no override to disclose.
879
+ */
880
+ type TopazUpscaleFactor = "1" | "2" | "4";
881
+ declare const TOPAZ_UPSCALE_FACTORS: readonly TopazUpscaleFactor[];
882
+ /** KIE's own default when `upscale_factor` is omitted (providers/kie/models.ts). */
883
+ declare const TOPAZ_DEFAULT_UPSCALE_FACTOR: TopazUpscaleFactor;
884
+ interface TopazUpscaleAdjustment {
885
+ field: "upscaleFactor" | "targetResolution";
886
+ /** The raw, untransformed value as received — never trimmed or case-normalized. */
887
+ from: string;
888
+ /**
889
+ * The resolved factor this adjustment corresponds to, or `undefined` for the
890
+ * informational "your stored targetResolution was overridden" notice, which
891
+ * names nothing to switch TO — `upscaleFactor` already won.
892
+ */
893
+ to: string | undefined;
894
+ reason: string;
895
+ }
896
+ interface TopazUpscaleResolution {
897
+ /** Sent to KIE as `upscale_factor`. Always set — never rely on the model default. */
898
+ upscaleFactor: TopazUpscaleFactor;
899
+ /**
900
+ * Passed VERBATIM as `buildCreditModelIdentifier`'s `targetResolution` arg.
901
+ * `undefined` = the bare id (1x / 2x); `"4K"` = the 4x tier.
902
+ */
903
+ creditTier: "4K" | undefined;
904
+ /** Non-empty when a legacy or out-of-enum value was coerced or overridden. */
905
+ adjustments: TopazUpscaleAdjustment[];
906
+ }
907
+ declare function resolveTopazUpscale(input: {
908
+ upscaleFactor?: string | null;
909
+ targetResolution?: string | null;
910
+ }): TopazUpscaleResolution;
911
+
912
+ /**
913
+ * Calculate the creator's monetization markup on a base credit cost.
914
+ * Returns the markup amount (not the total).
915
+ */
916
+ declare function calculateMonetizationMarkup(baseCost: number, flatFee: number, percent: number): number;
917
+ /**
918
+ * Calculate the total cost a runner pays (base + markup).
919
+ */
920
+ declare function calculateMonetizedCost(baseCost: number, flatFee: number, percent: number): number;
921
+
922
+ /**
923
+ * Lip-sync per-second pricing helpers.
924
+ *
925
+ * KIE.ai Kling AI Avatar 2.0 (May 2026) raised the max input audio from 15s
926
+ * to 5 minutes and bills per-second. We bucket the requested audio duration
927
+ * into discrete tiers and use composite credit identifiers
928
+ * (e.g. `kling-avatar:60s`) so credit reservation scales with input length.
929
+ *
930
+ * InfiniTalk still enforces a 15s upstream cap.
931
+ */
932
+ declare const LIP_SYNC_DURATION_BUCKETS: readonly [15, 30, 60, 120, 300];
933
+ type LipSyncDurationBucket = typeof LIP_SYNC_DURATION_BUCKETS[number];
934
+ /** Round a measured audio duration up to the next supported bucket. */
935
+ declare function pickLipSyncBucket(seconds: number): LipSyncDurationBucket;
936
+ /**
937
+ * Upper audio-duration limit per lip-sync provider, in seconds.
938
+ * Anything longer must be trimmed (server-side) before sending upstream.
939
+ */
940
+ declare const LIP_SYNC_MAX_AUDIO_SECONDS: Record<string, number>;
941
+ declare function getLipSyncMaxAudioSeconds(provider: string): number;
942
+ declare function isPerSecondLipSyncProvider(provider: string): boolean;
943
+ /**
944
+ * Build the credit identifier for a lip-sync request.
945
+ *
946
+ * For kling-avatar / kling-avatar-pro, returns `<provider>:<bucket>s`.
947
+ * For other providers, returns the bare provider name (caller appends
948
+ * any extra dimensions like resolution).
949
+ *
950
+ * If `audioDurationSec` is missing, defaults to the provider's max cap so
951
+ * credit reservation covers the worst case and any overage is refunded
952
+ * after the worker reconciles the actual KIE cost.
953
+ */
954
+ declare function buildLipSyncCreditId(provider: string, audioDurationSec: number | undefined): string;
955
+
956
+ /**
957
+ * AI Avatar (HeyGen) duration-bucketing + credit-identifier helpers.
958
+ * Single source of truth for the NON-monetary side of ai-avatar billing
959
+ * (duration estimation, bucket selection, composite credit-id construction) —
960
+ * imported by the frontend node UI (to build the id it hands to the
961
+ * `/v1/credits/model-cost` display lookup) AND the backend route/orchestrator
962
+ * (to resolve the credit-guard reservation id pre-Zod).
963
+ *
964
+ * The provider-$ rate table and the USD/credit cost FORMULAS derived from it
965
+ * live in `backend/src/lib/pricing/ai-avatar-cost.ts` (core, not ee/ — the
966
+ * HeyGen provider integration needs them regardless of edition). They were
967
+ * moved out of this package (published Apache-2.0 on npm — an irrevocable
968
+ * grant) per the 2026-07-06 public-flip IP audit, S5.
969
+ */
970
+ type AiAvatarEngine = "avatar-v" | "avatar-iv";
971
+ type AiAvatarResolution = "720p" | "1080p" | "4k";
972
+ /**
973
+ * Worst-case clip duration used as the credit-reserve ceiling.
974
+ * A 5000-character script at voiceSpeed 0.5 ≈ 5000/12/0.5 ≈ 833s → top bucket 900s.
975
+ */
976
+ declare const AI_AVATAR_MAX_DURATION_SEC = 900;
977
+ /**
978
+ * Duration buckets (seconds) used to pick a reserve ceiling at creditGuard
979
+ * time, when the actual clip length is unknown (text-mode scripts) or only
980
+ * known via a server-side ffprobe (audio mode).
981
+ *
982
+ * The low end is FINE-GRAINED (5/10/15/30/60s) so short clips — the common
983
+ * case — don't over-reserve. A 15s clip lands in the 15s bucket, not the old
984
+ * coarse 30s floor (which doubled the hold). The high end stays coarse because
985
+ * long-form scripts are rare and the bucket-up is a one-time refundable surplus.
986
+ *
987
+ * Bucket selection:
988
+ * - Text mode: bucket = pickAiAvatarBucket(ceil(scriptChars / 12 / voiceSpeed)).
989
+ * - Audio mode: bucket = pickAiAvatarBucket(ceil(probedDurationSec)) when the
990
+ * ffprobe preHandler stashed `__probedDurationSec` on the body; otherwise a
991
+ * MODEST 120s default (NOT the 900s top bucket — that was the bug: it
992
+ * reserved ~4000+ credits for a sub-minute clip).
993
+ *
994
+ * Worst-case derivation: 5000 chars at voiceSpeed=0.5 → ceil(5000/12/0.5) = 834s
995
+ * → fits in 900s bucket. The 900s top bucket covers all legal text inputs.
996
+ *
997
+ * Note: audio >900s (no probe) would undercharge against the 120s default, but
998
+ * the commit-time metered true-up CANNOT charge more than reserved — so a long
999
+ * un-probed audio clip is a (small) revenue leak, not an over-charge. The probe
1000
+ * closes it for the normal path. The 900s bucket remains available for the
1001
+ * probed long-audio case.
1002
+ */
1003
+ declare const AI_AVATAR_DURATION_BUCKETS: readonly [5, 10, 15, 30, 60, 120, 240, 360, 600, 900];
1004
+ /**
1005
+ * Hard cap (seconds) on AUDIO-mode clip length. HeyGen has no natural length
1006
+ * limit on an audio-driven avatar, so a long audio = an expensive / possibly
1007
+ * rejected generation and a bounded under-reserve window. We cap it here:
1008
+ * - The worker TRIMS incoming audio longer than this down to AI_AVATAR_MAX_AUDIO_SEC
1009
+ * (and warns the user, non-fatal).
1010
+ * - The credit RESERVE is capped at this bucket too: even a 30-min probed
1011
+ * audio buckets at 600s, never the 900s top bucket. Because the worker
1012
+ * trims the actual clip to ≤600s, the metered true-up can only refund.
1013
+ *
1014
+ * Text mode (5000-char script) and cinematic (4–15s) are bounded elsewhere and
1015
+ * are NOT affected by this cap.
1016
+ */
1017
+ declare const AI_AVATAR_MAX_AUDIO_SEC = 600;
1018
+ type AiAvatarDurationBucket = (typeof AI_AVATAR_DURATION_BUCKETS)[number];
1019
+ /**
1020
+ * Estimate script duration in seconds from character count and voice speed.
1021
+ *
1022
+ * Uses ~12 chars/sec at normal speed (voiceSpeed=1) — deliberately generous
1023
+ * (biased high) so the credit hold covers TTS pacing variations. Slower speech
1024
+ * (voiceSpeed < 1) produces a longer clip and thus a higher estimate.
1025
+ * Minimum 1s.
1026
+ *
1027
+ * @param script Script text (undefined treated as empty).
1028
+ * @param voiceSpeed HeyGen voice speed parameter, range 0.5–1.5 (default 1).
1029
+ * Slower speed → more seconds → higher hold.
1030
+ */
1031
+ declare function estimateScriptDurationSec(script: string | undefined, voiceSpeed?: number): number;
1032
+ /**
1033
+ * Pick the smallest duration bucket that is ≥ sec.
1034
+ * Falls back to the maximum bucket (900s) when sec exceeds all buckets.
1035
+ */
1036
+ declare function pickAiAvatarBucket(sec: number): AiAvatarDurationBucket;
1037
+ /**
1038
+ * Composite credit identifier for a duration-bucketed reserve.
1039
+ *
1040
+ * Format: `"heygen-<engine>:<resolution>:<bucketSec>s"`
1041
+ * e.g. `"heygen-avatar-iv:720p:60s"`.
1042
+ */
1043
+ declare function aiAvatarReserveCreditId(engine: AiAvatarEngine, resolution: AiAvatarResolution, bucketSec: number): string;
1044
+ /**
1045
+ * Resolve the credit identifier from a raw request body BEFORE Zod validation.
1046
+ * Called at creditGuard preHandler time — mirrors how `resolveLipSyncIdentifier`
1047
+ * reads the raw body in `backend/src/routes/lip-sync.ts`.
1048
+ *
1049
+ * - `speechMode === "text"`: bucket by estimated script duration, accounting for
1050
+ * voiceSpeed (slower → longer clip → larger bucket). Surplus is refunded at commit.
1051
+ * - Any other speechMode (audio / missing): bucket by `__probedDurationSec` when
1052
+ * the ffprobe preHandler stashed it on the raw body; otherwise a MODEST 120s
1053
+ * default (AI_AVATAR_AUDIO_FALLBACK_SEC) — NOT the 900s top bucket. Reserving
1054
+ * the 900s ceiling for a sub-minute audio clip was the over-reservation bug
1055
+ * (~4000+ credits held for a clip that costs ~40). The commit-time metered
1056
+ * true-up is refund-only, so a modest reserve never over-charges. The effective
1057
+ * seconds are ALSO capped at AI_AVATAR_MAX_AUDIO_SEC (600s) — the worker trims
1058
+ * audio longer than that, so a 30-min audio reserves the 600s bucket, never 900s.
1059
+ *
1060
+ * - `avatarSource === "image"`: image-source mode is IV-class (HeyGen's own
1061
+ * engine, no avatar_id) — bill at the avatar-iv rate regardless of the
1062
+ * (ignored) `engine` field, reusing the existing heygen-avatar-iv:* ids.
1063
+ *
1064
+ * Falls back to ("avatar-iv", "720p", 120s) when fields are missing or invalid.
1065
+ */
1066
+ declare function resolveAiAvatarCreditId(body: Record<string, unknown> | undefined): string;
1067
+ /**
1068
+ * All 60 reserve credit IDs — every (engine × resolution × bucket) combination.
1069
+ * 2 engines × 3 resolutions × 10 buckets (5/10/15/30/60/120/240/360/600/900s) = 60.
1070
+ * Seeded in STATIC_CREDIT_COSTS and the model_pricing migration so
1071
+ * getModelCreditBaseCost never hard-fails (503 price_not_configured) for any
1072
+ * legal creditGuard input.
1073
+ */
1074
+ declare const AI_AVATAR_RESERVE_IDS: string[];
1075
+
1076
+ declare const SWITCHX_FRAME_TIERS: readonly [30, 60, 90, 120, 150, 180, 210, 240];
1077
+ /** Beeble's metering granularity: frames per billed block. */
1078
+ declare const SWITCHX_BLOCK_FRAMES = 30;
1079
+ declare function pickSwitchXFrameTier(frames?: number): number;
1080
+ declare function resolveSwitchXCreditId(body: Record<string, unknown>): string;
1081
+
1082
+ /**
1083
+ * Cinematic Avatar (HeyGen `type:"cinematic_avatar"`) duration-clamping +
1084
+ * credit-identifier helpers. Single source of truth for the NON-monetary side
1085
+ * of cinematic-avatar billing — imported by the frontend node UI and the
1086
+ * backend route/orchestrator.
1087
+ *
1088
+ * The provider-$ rate table and the USD/credit cost FORMULAS derived from it
1089
+ * live in `backend/src/lib/pricing/cinematic-avatar-cost.ts` (core, not ee/ —
1090
+ * the HeyGen provider integration needs them regardless of edition). They
1091
+ * were moved out of this package (published Apache-2.0 on npm — an
1092
+ * irrevocable grant) per the 2026-07-06 public-flip IP audit, S5.
1093
+ *
1094
+ * ─── How this differs from ai-avatar pricing ────────────────────────────────
1095
+ * Cinematic Avatar is a generative clip (Seedance-style pipeline) driven by a
1096
+ * prompt + 1–3 avatar look ids. Crucially, `duration` is a USER PARAMETER
1097
+ * (4–15s, clamped) and is therefore KNOWN at submit time — unlike ai-avatar's
1098
+ * text/audio script whose clip length is only estimated. So the reserve here is
1099
+ * EXACT (no duration-bucket estimation): the credit id encodes the exact
1100
+ * requested duration, and the metered true-up at commit refunds nothing in the
1101
+ * common case (provider returns the requested duration).
1102
+ * ────────────────────────────────────────────────────────────────────────────
1103
+ */
1104
+ type CinematicResolution = "720p" | "1080p";
1105
+ /** Minimum / maximum / default user-selectable duration (seconds). */
1106
+ declare const CINEMATIC_MIN_DURATION_SEC = 4;
1107
+ declare const CINEMATIC_MAX_DURATION_SEC = 15;
1108
+ declare const CINEMATIC_DEFAULT_DURATION_SEC = 10;
1109
+ declare const CINEMATIC_DEFAULT_RESOLUTION: CinematicResolution;
1110
+ /**
1111
+ * Clamp a (possibly invalid) duration to the legal 4–15s range, rounding to a
1112
+ * whole second. Falls back to the default (10s) for non-finite input.
1113
+ */
1114
+ declare function clampCinematicDuration(durationSec: number | undefined): number;
1115
+ /**
1116
+ * Composite credit identifier for an EXACT-duration reserve.
1117
+ *
1118
+ * Format: `cinematic-avatar:<resolution>:<durationSec>s`
1119
+ * e.g. `cinematic-avatar:720p:10s`.
1120
+ */
1121
+ declare function cinematicCreditId(resolution: CinematicResolution, durationSec: number): string;
1122
+ /**
1123
+ * Resolve the credit identifier from a raw request body BEFORE Zod validation.
1124
+ * Called at creditGuard preHandler time — mirrors resolveAiAvatarCreditId.
1125
+ *
1126
+ * Reads `resolution` (default 720p) and `duration` (default 10, clamped 4–15)
1127
+ * straight off the raw body. Because duration is a user parameter known at
1128
+ * submit time, the reserve id is EXACT — no bucketing.
1129
+ *
1130
+ * ─── autoDuration → reserve at the MAX-duration ceiling ──────────────────────
1131
+ * When `autoDuration` is true, the provider DROPS `duration` and HeyGen picks
1132
+ * the clip length itself, so the actual metered length is UNKNOWN at submit
1133
+ * time and can exceed the requested/default `duration`. The metered true-up at
1134
+ * commit (commit_credits) can ONLY refund a surplus — it never charges more
1135
+ * when the actual exceeds the reserved hold. Reserving under the default-10s
1136
+ * hold therefore silently undercharges any auto clip longer than 10s (a revenue
1137
+ * leak). To preserve the refund-only invariant, reserve under the MAXIMUM
1138
+ * possible hold (`cinematic-avatar:<res>:15s`) so the true-up can only refund.
1139
+ */
1140
+ declare function resolveCinematicCreditId(body: Record<string, unknown> | undefined): string;
1141
+ /**
1142
+ * All 24 reserve credit IDs — every (resolution × duration) combination.
1143
+ * 2 resolutions × 12 durations (4..15s) = 24.
1144
+ * Seeded in STATIC_CREDIT_COSTS and the model_pricing migration so
1145
+ * getModelCreditBaseCost never hard-fails (503 price_not_configured) for any
1146
+ * legal creditGuard input.
1147
+ */
1148
+ declare const CINEMATIC_RESERVE_IDS: string[];
1149
+
1150
+ /**
1151
+ * Shared structural validators for the ai-avatar and cinematic-avatar payloads.
1152
+ *
1153
+ * ─── Why this exists ─────────────────────────────────────────────────────────
1154
+ * The route Zod schemas (`aiAvatarBody` / `cinematicAvatarBody`) only protect the
1155
+ * single-node Run path. Workflow runs, published-app runs, MCP run_workflow, and
1156
+ * imported/crafted workflow JSON all assemble a payload in
1157
+ * `payload-builder.ts` and forward it straight to the worker → provider →
1158
+ * HeyGen with NO Zod parse in between. That structural gap is the root cause of
1159
+ * the avatar edge-case findings: missing/over-count avatarLooks, reference caps,
1160
+ * source/speech-conditional requireds, and voice-param ranges all reach HeyGen
1161
+ * unvalidated on those paths.
1162
+ *
1163
+ * These validators reproduce the route Zod's invariants (minus the userId /
1164
+ * workflow wrapper and minus the URL-host allowlist — orchestrated URLs come
1165
+ * from trusted upstream R2 outputs). They run inside the `ai-avatar` /
1166
+ * `cinematic-avatar` cases of `payload-builder.ts` on the ASSEMBLED payload,
1167
+ * throwing `AvatarPayloadError` BEFORE credit reservation + enqueue. The
1168
+ * node-executor catches the throw and deletes the orphaned pending job, so both
1169
+ * entry points are correct-by-construction rather than relying on the route as
1170
+ * the only gate.
1171
+ *
1172
+ * Keep these in sync with `backend/src/routes/ai-avatar.ts` and
1173
+ * `backend/src/routes/cinematic-avatar.ts`.
1174
+ */
1175
+ /** Thrown by the avatar payload validators on a structurally-invalid payload. */
1176
+ declare class AvatarPayloadError extends Error {
1177
+ constructor(message: string);
1178
+ }
1179
+ /**
1180
+ * Validate an assembled ai-avatar payload (post-default-application).
1181
+ * Mirrors `aiAvatarBody` (`backend/src/routes/ai-avatar.ts`): enum bounds,
1182
+ * source/speech-conditional requireds, script length, and voice-param ranges.
1183
+ *
1184
+ * @throws AvatarPayloadError on any violation.
1185
+ */
1186
+ declare function validateAiAvatarPayload(payload: Record<string, unknown>): void;
1187
+ declare const CINEMATIC_PROMPT_MAX = 10000;
1188
+ /** HeyGen combined reference caps: ≤3 videos and ≤9 images across avatar looks + references. */
1189
+ declare const CINEMATIC_MAX_REFERENCE_VIDEOS = 3;
1190
+ declare const CINEMATIC_MAX_REFERENCE_IMAGES = 9;
1191
+ declare const CINEMATIC_MIN_LOOKS = 1;
1192
+ declare const CINEMATIC_MAX_LOOKS = 3;
1193
+ /**
1194
+ * Validate an assembled cinematic-avatar payload.
1195
+ * Mirrors `cinematicAvatarBody` (`backend/src/routes/cinematic-avatar.ts`):
1196
+ * prompt presence/length, avatarLooks count (1–3), enum bounds, and the
1197
+ * combined reference caps (≤3 videos; avatarLooks + image refs ≤ 9).
1198
+ *
1199
+ * @throws AvatarPayloadError on any violation.
1200
+ */
1201
+ declare function validateCinematicAvatarPayload(payload: Record<string, unknown>): void;
1202
+
1203
+ /**
1204
+ * Effective-tier resolution — the payg derivation.
1205
+ *
1206
+ * "payg" is a DERIVED tier, never stored: a user whose stored tier resolves
1207
+ * to "free" but who has NET lifetime top-up credits (granted − refunded,
1208
+ * clamped ≥ 0 by every SQL writer) is treated as "payg" by entitlement
1209
+ * checks. Stored tier stays untouched, so subscription webhooks never learn
1210
+ * about payg and a cancel→free transition re-derives it automatically.
1211
+ *
1212
+ * Lives in @nodaro/shared because the pipeline tier maps already do, and
1213
+ * both backend (credit gates, workers) and read surfaces need one source.
1214
+ *
1215
+ * The profile fields are REQUIRED (non-optional) on purpose: a call site
1216
+ * whose SELECT forgot to fetch `lifetime_topup_credits` becomes a compile
1217
+ * error instead of a silent `?? 0` that quietly deactivates payg — that is
1218
+ * the failure mode this shape exists to prevent.
1219
+ */
1220
+ /** Stored-tier resolution — mirrors SQL COALESCE(tier, subscription_tier, 'free'). */
1221
+ declare function resolveStoredTier(p: {
1222
+ tier: string | null;
1223
+ subscription_tier: string | null;
1224
+ }): string;
1225
+ /**
1226
+ * Effective tier: stored "free" with NET lifetime top-ups > 0 derives "payg".
1227
+ * Every other stored tier passes through untouched.
1228
+ */
1229
+ declare function resolveEffectiveTier(p: {
1230
+ tier: string | null;
1231
+ subscription_tier: string | null;
1232
+ lifetime_topup_credits: number;
1233
+ }): string;
1234
+ /** Media-retention activity window for payg users (design 2026-07-05 §4.6). */
1235
+ declare const PAYG_RETENTION_DAYS = 90;
1236
+ /**
1237
+ * Is this payg user inside their retention-activity window?
1238
+ *
1239
+ * Activity = credit SPEND (callers supply MAX(usage_logs.created_at) — never
1240
+ * `last_daily_reset`, which read-only balance polls bump) OR a top-up
1241
+ * PURCHASE (`last_topup_at`). Within PAYG_RETENTION_DAYS of either → the
1242
+ * nightly reaper leaves their media alone; past it, the standard free-tier
1243
+ * reaper rules apply. A user with no lifetime purchases is never
1244
+ * retention-active (they are not payg).
1245
+ */
1246
+ declare function isPaygRetentionActive(p: {
1247
+ lifetimeTopupCredits: number;
1248
+ lastTopupAt: string | Date | null;
1249
+ lastSpendAt: string | Date | null;
1250
+ }, now: Date): boolean;
1251
+
1252
+ /**
1253
+ * Video-analysis pricing — shared duration-bucket credit model.
1254
+ *
1255
+ * Single source of truth for the video-analysis node's NON-monetary credit
1256
+ * math: duration bucketing, the window-batching constants (also consumed by
1257
+ * the backend workers for real chunking, not just pricing), and the
1258
+ * composite credit-id builder. The route (charge at generate-time), the
1259
+ * worker (re-check + settle), and the frontend node UI (via
1260
+ * `buildVideoAnalysisCreditId` + `/v1/credits/model-cost`) all derive from
1261
+ * these.
1262
+ *
1263
+ * The rate constants and the formula that GENERATE these numbers live
1264
+ * PRIVATELY in the `@nodaroai/cloud-plugins` package — never in this public
1265
+ * repo. They were first moved out of this package (published Apache-2.0 on
1266
+ * npm), then out of the app repo entirely alongside the rest of the
1267
+ * video-analysis node. A cross-check test in that private package guards
1268
+ * this table so the public numbers can't silently drift from the formula.
1269
+ *
1270
+ * `VIDEO_ANALYSIS_BUCKET_CREDITS` below is the precomputed OUTPUT of that
1271
+ * private formula for every (model × bucket) combination — a plain credit
1272
+ * lookup table, not a formula, mirroring the same wire-contract pattern
1273
+ * `VIDEO_CLIP_CREDITS` uses in `film-pricing.ts`. It is what the frontend's
1274
+ * client-side cost preview (`estimateNodeCredits` in
1275
+ * workflow-editor/types.ts) reads instead of calling the formula directly.
1276
+ * The formula's own test in `@nodaroai/cloud-plugins` cross-checks this
1277
+ * table against it and fails on drift. There is deliberately NO app-side formula to
1278
+ * check against — it was moved private in 2026-07 and the old backend test
1279
+ * went with it.
1280
+ *
1281
+ * `VIDEO_AUDIT_BUCKET_CREDITS` further down is the sibling table for the
1282
+ * `video-audit` node ("AI Audit") — same module, same bucket ladder, same
1283
+ * generator-authoritative pattern, its own two credit families.
1284
+ */
1285
+ declare const VIDEO_ANALYSIS_DURATION_BUCKETS: readonly [60, 180, 360, 600];
1286
+ /** Pricing grace: a clip at most this far past a bucket edge is priced at that
1287
+ * bucket. A part chosen as 1:00 in the Video URL chooser downloads at about
1288
+ * 1:03 (the cut lands on keyframes), and must cost a minute, not three. Read
1289
+ * by pickVideoAnalysisBucket — the ONE bucket picker every price reads (the
1290
+ * editor estimate, the orchestrator reserve, the cloud routes). */
1291
+ declare const VIDEO_ANALYSIS_BUCKET_GRACE_SEC = 3;
1292
+ /** Worker re-check grace: route metadata is integer-rounded, provider durations nominal;
1293
+ * ffprobe floats run 0.05–2 s over. Zero tolerance fails legit videos at 1:00/3:00/6:00/10:00.
1294
+ * It sits ON TOP of the pricing grace: a clip the grace priced into a bucket
1295
+ * (probe 63 s → 60 s) must still pass the worker gate (bucket + tolerance) at
1296
+ * its float length (63.4 s). The cloud plugin reads this constant from the
1297
+ * host app at run time, so its gate moves with it. */
1298
+ declare const VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC: number;
1299
+ declare const VIDEO_ANALYSIS_MAX_DURATION_SEC = 600;
1300
+ declare const VIDEO_ANALYSIS_WINDOW: {
1301
+ readonly LEN: 150;
1302
+ readonly STRIDE: 145;
1303
+ readonly OVERLAP: 5;
1304
+ readonly SINGLE_MAX: 180;
1305
+ };
1306
+ /**
1307
+ * Precomputed credit cost per (model, bucket) — the OUTPUT of the private
1308
+ * `videoAnalysisBucketCredits` formula (in `@nodaroai/cloud-plugins`), not a
1309
+ * formula itself. Regenerate by running that function for every
1310
+ * `VIDEO_ANALYSIS_LLM_MODELS` × duration bucket combination whenever the
1311
+ * underlying rate/token constants change (the plugin's cost test guards drift).
1312
+ * Keep in sync with
1313
+ * `docs/nodes/processing-video/video-analysis.md`.
1314
+ */
1315
+ declare const VIDEO_ANALYSIS_BUCKET_CREDITS: Record<string, number>;
1316
+ /**
1317
+ * The credit-id MODEL SEGMENT for an engine identifier: both mixed-tier
1318
+ * sentinels share the `mixed` price family (same engine plan); everything
1319
+ * else prices under its own identifier. Single source of truth — used by
1320
+ * `buildVideoAnalysisCreditId` below, so route/orchestrator/UI callers can
1321
+ * never diverge on where a sentinel prices.
1322
+ */
1323
+ declare function videoAnalysisCreditSegment(modelOrSentinel: string): string;
1324
+ declare function pickVideoAnalysisBucket(durationSec: number): number;
1325
+ declare function buildVideoAnalysisCreditId(model: string, durationSec?: number): string;
1326
+ declare function bucketSecondsFromCreditId(creditId: string): number | null;
1327
+ declare function videoAnalysisNumWindows(bucketSec: number): number;
1328
+ /**
1329
+ * Precomputed credit cost for the `video-audit` node ("AI Audit") — the same
1330
+ * pattern as `VIDEO_ANALYSIS_BUCKET_CREDITS` above: the OUTPUT of the private
1331
+ * `videoAuditBucketCredits` formula in `@nodaroai/cloud-plugins`
1332
+ * (in the plugin repo), a plain lookup table never a
1333
+ * formula, cross-checked against that package's own cost test. Shares the
1334
+ * SAME duration-bucket ladder as video-analysis (`VIDEO_ANALYSIS_DURATION_BUCKETS`
1335
+ * / `pickVideoAnalysisBucket`) — the audit re-watches the same clip, so it
1336
+ * buckets identically.
1337
+ *
1338
+ * Two credit families, selected by whether an analysis was wired into the
1339
+ * node (see `buildVideoAuditCreditId`):
1340
+ * - `video-audit:<bucket>s` — an analysis was provided; the audit re-watches
1341
+ * the clip against it directly (native watcher roll + reasoner pass, at a
1342
+ * safety margin — internals stay private in the plugin).
1343
+ * - `video-audit:auto:<bucket>s` — no analysis wired; the node auto-runs a
1344
+ * fast-tier analysis first. Exactly the base family's price PLUS the
1345
+ * `gemini-3-flash` (legacy fast tier) row from `VIDEO_ANALYSIS_BUCKET_CREDITS`
1346
+ * at the SAME bucket — summed in the plugin's generator/formula, never
1347
+ * hand-added here (see the single-source assertion in
1348
+ * video-analysis-pricing.test.ts).
1349
+ *
1350
+ * Bare ids (`video-audit`, `video-audit:auto` — they live in
1351
+ * `model-catalog.ts`'s pricing rows, not as keys in this table) equal their
1352
+ * family's 600s ceiling, the same "unknown duration → ceiling" convention
1353
+ * `VIDEO_ANALYSIS_BUCKET_CREDITS`'s bare per-model catalog rows use.
1354
+ * `buildVideoAuditCreditId` never returns a bare id itself — an
1355
+ * unknown/invalid duration resolves to the bucketed 600s id, matching
1356
+ * `buildVideoAnalysisCreditId`.
1357
+ *
1358
+ * Values pasted verbatim from the plugin generator's output
1359
+ * (the plugin repo's bucket generator) —
1360
+ * never hand computed. The plugin's cost test cross-checks every row.
1361
+ */
1362
+ declare const VIDEO_AUDIT_BUCKET_CREDITS: Record<string, number>;
1363
+ /**
1364
+ * Composite credit-id builder for `video-audit`. Mirrors
1365
+ * `buildVideoAnalysisCreditId`'s bucket selection and unknown/invalid-duration
1366
+ * ceiling fallback exactly (same ladder, same rounding — `durationSec <=
1367
+ * bucket`, clamped to the 600s max), but selects the FAMILY by whether an
1368
+ * analysis was already provided instead of by model: `analysisProvided:
1369
+ * true` prices under the cheaper `video-audit` family (re-audits an existing
1370
+ * analysis); `false` prices under `video-audit:auto` (the node auto-runs a
1371
+ * fast analysis first, hence that family's built-in fast-tier addition).
1372
+ */
1373
+ declare function buildVideoAuditCreditId(args: {
1374
+ analysisProvided: boolean;
1375
+ durationSec?: number;
1376
+ }): string;
1377
+ /**
1378
+ * Table lookup for a resolved bucket + family. Snaps `bucketSec` onto the
1379
+ * ladder via `pickVideoAnalysisBucket` first, so a raw duration (not just an
1380
+ * exact 60/180/360/600) is safe to pass — mirrors `buildVideoAuditCreditId`'s
1381
+ * own rounding rather than requiring the caller to pre-round.
1382
+ */
1383
+ declare function videoAuditCreditsForBucket(bucketSec: number, auto: boolean): number;
1384
+ /**
1385
+ * Parses a `video-audit:*` credit id back to its bucket seconds — both
1386
+ * families (`video-audit:<n>s` and `video-audit:auto:<n>s`); null on
1387
+ * anything else (a bare id with no bucket, a `video-analysis:*` id, or
1388
+ * garbage). Deliberately a SEPARATE parser from `bucketSecondsFromCreditId`
1389
+ * (anchored to the `video-analysis:` prefix and a mandatory model segment) —
1390
+ * mirrors the plugin-local audit parser so app code can never mis-parse an
1391
+ * audit id with the VA-anchored parser, or vice versa.
1392
+ */
1393
+ declare function bucketSecondsFromAuditCreditId(id: string): number | null;
1394
+
1395
+ /**
1396
+ * Pricing vocabulary for the "steal the format" nodes — Content Recipe and
1397
+ * Content Ideas. Public prices only: the credit ids a run is billed under and
1398
+ * the count rule that picks between them. One copy for the editor's credit
1399
+ * badge, the workflow orchestrator's reservation and the pre-run estimate;
1400
+ * the cloud plugin that runs the nodes computes the same ids.
1401
+ *
1402
+ * Content Ideas is charged per batch of up to five ideas: a run of 1–5 ideas
1403
+ * bills `content-ideas[:economy|:premium|:premium-direct]`, a run of 6–10 bills
1404
+ * `content-ideas:10[:economy|:premium|:premium-direct]`, priced at two batches.
1405
+ */
1406
+ declare const CONTENT_IDEAS_MAX_COUNT = 10;
1407
+ declare const CONTENT_IDEAS_DEFAULT_COUNT = 5;
1408
+ declare const CONTENT_IDEAS_PER_CHARGE = 5;
1409
+ /** Request limits the cloud routes enforce — the orchestrator trims to the
1410
+ * same bounds, since its payload never passes the route's validation. */
1411
+ declare const CONTENT_RECIPE_SOURCE_MAX = 300000;
1412
+ declare const CONTENT_IDEAS_MAX_RECIPE_INPUTS = 20;
1413
+ declare const CONTENT_IDEAS_BRAND_MAX = 6000;
1414
+ declare const CONTENT_IDEAS_LANGUAGE_MAX = 40;
1415
+ /** A whole number of ideas in 1..10; anything but a finite number is the
1416
+ * default. (The plugin reads `count` the same way — numbers only.) */
1417
+ declare function clampContentIdeasCount(raw: unknown): number;
1418
+ /** The billing feature for a run of `count` ideas. */
1419
+ declare function contentIdeasCreditFeature(count: number): "content-ideas" | "content-ideas:10";
1420
+ /** The model a node runs: its own pick when the registry can return
1421
+ * structured output, else the feature default. Billing uses THIS — a missing
1422
+ * model must never bill the bare (standard) id while running economy. */
1423
+ declare function effectiveContentModel(feature: "content-recipe" | "content-ideas", llmModel: unknown): string;
1424
+ declare function contentRecipeCreditId(llmModel?: unknown, reasoningEffort?: string): string;
1425
+ declare function contentIdeasCreditId(count: unknown, llmModel?: unknown, reasoningEffort?: string): string;
1426
+ /** Every credit id the two nodes can bill — for price tables and guards. */
1427
+ declare const CONTENT_RECIPE_IDEAS_CREDIT_IDS: readonly ["content-recipe:economy", "content-recipe", "content-recipe:premium", "content-recipe:premium-direct", "content-ideas:economy", "content-ideas", "content-ideas:premium", "content-ideas:premium-direct", "content-ideas:10:economy", "content-ideas:10", "content-ideas:10:premium", "content-ideas:10:premium-direct"];
1428
+
1429
+ export { AI_AVATAR_DURATION_BUCKETS, AI_AVATAR_MAX_AUDIO_SEC, AI_AVATAR_MAX_DURATION_SEC, AI_AVATAR_RESERVE_IDS, type AiAvatarDurationBucket, type AiAvatarEngine, type AiAvatarResolution, AvatarPayloadError, CINEMATIC_DEFAULT_DURATION_SEC, CINEMATIC_DEFAULT_RESOLUTION, CINEMATIC_MAX_DURATION_SEC, CINEMATIC_MAX_LOOKS, CINEMATIC_MAX_REFERENCE_IMAGES, CINEMATIC_MAX_REFERENCE_VIDEOS, CINEMATIC_MIN_DURATION_SEC, CINEMATIC_MIN_LOOKS, CINEMATIC_PROMPT_MAX, CINEMATIC_RESERVE_IDS, CONTENT_IDEAS_BRAND_MAX, CONTENT_IDEAS_DEFAULT_COUNT, CONTENT_IDEAS_LANGUAGE_MAX, CONTENT_IDEAS_MAX_COUNT, CONTENT_IDEAS_MAX_RECIPE_INPUTS, CONTENT_IDEAS_PER_CHARGE, CONTENT_RECIPE_IDEAS_CREDIT_IDS, CONTENT_RECIPE_SOURCE_MAX, CREDIT_ROUNDING_RESOLUTION, type CinematicResolution, type CombineVideosEstimatorInput, DEFAULT_VIDEO_CLIP_COST, FILM_BASE_CREDITS, type FilmCreditEstimate, IMAGE_OVERLAY_BASE_CREDITS, IMAGE_OVERLAY_VARIANT_CREDITS, KEYFRAME_CREDITS_PER_SHOT, LIP_SYNC_DURATION_BUCKETS, LIP_SYNC_MAX_AUDIO_SECONDS, LTX_EXTEND_DURATION, LTX_EXTEND_PER_SECOND_CREDIT_ID, LTX_RETAKE_MIN_DURATION_SEC, LTX_RETAKE_PER_SECOND_CREDIT_ID, type LipSyncDurationBucket, type LoopTrimEstimatorInput, type LoopVideoEstimatorInput, type NormalizedImageGen, PAYG_RETENTION_DAYS, PITCH_TEMPO_LIMITS, PITCH_TEMPO_PRICING, type PricedVideoSelection, SPEAKER_VIEW_CREDIT_IDS, SPEAKER_VIEW_PRICE_TIERS, SPEECH_FLOOR_UNITS, SPEECH_PRICE_UNIT_CHARS, SPEECH_UNIT_CREDIT_SUFFIX, SUNO_SELECT_OPERATIONS, SUNO_VERSION_CREDIT_KEYS, SUNO_VERSION_PRICED_OPERATIONS, SWITCHX_BLOCK_FRAMES, SWITCHX_FRAME_TIERS, type SpeakerViewCreditId, type SpeakerViewPriceTier, type SpeechQuoteCreditIdParts, TEXT_TO_AUDIO_PRICING, TEXT_TO_AUDIO_SFX_CREDIT_IDS, TOPAZ_DEFAULT_UPSCALE_FACTOR, TOPAZ_UPSCALE_FACTORS, type TopazUpscaleAdjustment, type TopazUpscaleFactor, type TopazUpscaleResolution, type TrimVideoEstimatorInput, type UnitQuoteCreditIdParts, VIDEO_ANALYSIS_BUCKET_CREDITS, VIDEO_ANALYSIS_BUCKET_GRACE_SEC, VIDEO_ANALYSIS_DURATION_BUCKETS, VIDEO_ANALYSIS_DURATION_TOLERANCE_SEC, VIDEO_ANALYSIS_MAX_DURATION_SEC, VIDEO_ANALYSIS_WINDOW, VIDEO_AUDIT_BUCKET_CREDITS, VIDEO_CLIP_CREDITS, VIDEO_CRITIC_CREDITS_PER_SHOT, VIDEO_SFX_PRICING, VIDEO_UTIL_PRICING, VOICE_CHANGER_PRO_QUOTE_RATE_ID, type VideoClipCost, type VoiceChangerProQuoteCreditIdParts, type VoiceChangerProQuoteRespeakEngine, type VoiceChangerProQuoteSlot, aiAvatarReserveCreditId, applyEdlCreditId, assembleNarratedVideoCredits, bucketSecondsFromAuditCreditId, bucketSecondsFromCreditId, buildCreditModelIdentifier, buildLipSyncCreditId, buildMotionCreditModelIdentifier, buildVideoAnalysisCreditId, buildVideoAuditCreditId, buildVideoCreditModelIdentifier, calculateMonetizationMarkup, calculateMonetizedCost, cinematicCreditId, clampCinematicDuration, clampContentIdeasCount, contentIdeasCreditFeature, contentIdeasCreditId, contentRecipeCreditId, creditsToUsd, effectiveContentModel, estimateCombineVideosCredits, estimateFilmCredits, estimateLoopTrimAddonCredits, estimateLoopVideoCredits, estimateScriptDurationSec, estimateTrimVideoCredits, getLipSyncMaxAudioSeconds, imageGenAutoAspectNeedsSourceImage, imageOverlayBillableVariants, imageOverlayCredits, isPaygRetentionActive, isPerSecondLipSyncProvider, isSpeechLengthPriceId, ltxExtendDurationSec, ltxRetakeDurationSec, normalizedImageGenModelId, parsePitchTempoCreditId, parseSpeechQuoteCreditId, parseUnitQuoteCreditId, parseVoiceChangerProQuoteCreditId, pickAiAvatarBucket, pickLipSyncBucket, pickSwitchXFrameTier, pickVideoAnalysisBucket, pitchTempoBaseCredits, pitchTempoCreditId, pitchTempoQuoteCreditId, pitchTempoStartedMinutes, pricedVideoSelection, resolveAiAvatarCreditId, resolveCinematicCreditId, resolveEffectiveTier, resolveImageGenCreditIdentifier, resolveNormalizedImageGen, resolveStoredTier, resolveSwitchXCreditId, resolveTopazUpscale, seedanceVideoEditCreditId, semitonesToPitchRatio, speakerViewCreditId, speechCredits, speechLengthPriceModel, speechPriceUnits, speechQuoteCreditId, speechUnitCreditId, speedRampCreditId, sunoCreditType, textToAudioBilledSeconds, textToAudioCreditId, unitQuoteCreditId, usdToCredits, validateAiAvatarPayload, validateCinematicAvatarPayload, videoAnalysisCreditSegment, videoAnalysisNumWindows, videoAuditCreditsForBucket, videoSfxCreditId, videoSfxQuoteCreditId, voiceChangerProQuoteCreditId };