@nodaro/shared 3.61.0 → 3.62.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 (254) hide show
  1. package/dist/{chunk-IVXSNW2B.cjs → chunk-2D5LQFV4.cjs} +18 -332
  2. package/dist/chunk-2D5LQFV4.cjs.map +1 -0
  3. package/dist/{chunk-XUJC6GHE.cjs → chunk-2HZGDZZN.cjs} +6 -6
  4. package/dist/{chunk-XUJC6GHE.cjs.map → chunk-2HZGDZZN.cjs.map} +1 -1
  5. package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
  6. package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
  7. package/dist/{chunk-7ARKVJTN.cjs → chunk-2W745U4A.cjs} +228 -355
  8. package/dist/chunk-2W745U4A.cjs.map +1 -0
  9. package/dist/{chunk-673E4KYC.js → chunk-3OYO3XCC.js} +70 -6
  10. package/dist/chunk-3OYO3XCC.js.map +1 -0
  11. package/dist/{chunk-FMXFHJWX.cjs → chunk-4ZEFP2FQ.cjs} +4 -4
  12. package/dist/{chunk-FMXFHJWX.cjs.map → chunk-4ZEFP2FQ.cjs.map} +1 -1
  13. package/dist/{chunk-A3FHTSLB.js → chunk-5YYN5X57.js} +302 -27
  14. package/dist/chunk-5YYN5X57.js.map +1 -0
  15. package/dist/{chunk-4KYLNTR7.cjs → chunk-6CSXMWL4.cjs} +4 -4
  16. package/dist/{chunk-4KYLNTR7.cjs.map → chunk-6CSXMWL4.cjs.map} +1 -1
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-G4XWVWRI.js → chunk-6G7NN4S4.js} +5 -4
  20. package/dist/chunk-6G7NN4S4.js.map +1 -0
  21. package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
  22. package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
  23. package/dist/{chunk-JHTT2V4A.cjs → chunk-AFYTX4AI.cjs} +52 -43
  24. package/dist/chunk-AFYTX4AI.cjs.map +1 -0
  25. package/dist/chunk-ALRXY4QH.cjs +13 -0
  26. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  27. package/dist/chunk-AOJ6B7K4.cjs +351 -0
  28. package/dist/chunk-AOJ6B7K4.cjs.map +1 -0
  29. package/dist/{chunk-ZDBPQBAA.js → chunk-C7POAYFE.js} +3 -3
  30. package/dist/{chunk-ZDBPQBAA.js.map → chunk-C7POAYFE.js.map} +1 -1
  31. package/dist/{chunk-B6BG3LV2.js → chunk-CC4V2B7S.js} +3 -3
  32. package/dist/{chunk-B6BG3LV2.js.map → chunk-CC4V2B7S.js.map} +1 -1
  33. package/dist/{chunk-XZKFZMRT.cjs → chunk-CIPPPT7E.cjs} +6 -6
  34. package/dist/{chunk-XZKFZMRT.cjs.map → chunk-CIPPPT7E.cjs.map} +1 -1
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  40. package/dist/chunk-D34K455O.cjs.map +1 -0
  41. package/dist/chunk-E2HZTGYX.js +331 -0
  42. package/dist/chunk-E2HZTGYX.js.map +1 -0
  43. package/dist/{chunk-RQ4F3AJH.cjs → chunk-G3KVK7OU.cjs} +21 -21
  44. package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-G3KVK7OU.cjs.map} +1 -1
  45. package/dist/chunk-G4U3HW6W.js +453 -0
  46. package/dist/chunk-G4U3HW6W.js.map +1 -0
  47. package/dist/{chunk-IRQ3SPX7.js → chunk-GSFB537T.js} +3 -3
  48. package/dist/{chunk-IRQ3SPX7.js.map → chunk-GSFB537T.js.map} +1 -1
  49. package/dist/chunk-HRY7KGAE.cjs +506 -0
  50. package/dist/chunk-HRY7KGAE.cjs.map +1 -0
  51. package/dist/{chunk-VOWJCUMR.js → chunk-I2RQB7VG.js} +3 -3
  52. package/dist/{chunk-VOWJCUMR.js.map → chunk-I2RQB7VG.js.map} +1 -1
  53. package/dist/chunk-IDTKF5EX.cjs +48 -0
  54. package/dist/chunk-IDTKF5EX.cjs.map +1 -0
  55. package/dist/{chunk-5XRRENHD.cjs → chunk-IWWVPR3W.cjs} +88 -11
  56. package/dist/chunk-IWWVPR3W.cjs.map +1 -0
  57. package/dist/{chunk-SCMTN57Y.js → chunk-JJNNM23P.js} +3 -3
  58. package/dist/{chunk-SCMTN57Y.js.map → chunk-JJNNM23P.js.map} +1 -1
  59. package/dist/{chunk-ZZGQRRN7.js → chunk-JZGZ26YB.js} +6 -306
  60. package/dist/chunk-JZGZ26YB.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-NJVOJXBS.cjs → chunk-KJSRPHJ2.cjs} +48 -47
  64. package/dist/chunk-KJSRPHJ2.cjs.map +1 -0
  65. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  66. package/dist/chunk-KL6GAYTT.js.map +1 -0
  67. package/dist/{chunk-AFQFGZN7.cjs → chunk-KYMHFVAZ.cjs} +8 -6
  68. package/dist/chunk-KYMHFVAZ.cjs.map +1 -0
  69. package/dist/{chunk-F5YEMSNK.cjs → chunk-MYJQELFN.cjs} +320 -26
  70. package/dist/chunk-MYJQELFN.cjs.map +1 -0
  71. package/dist/chunk-N5HH46JF.cjs +68 -0
  72. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  73. package/dist/{chunk-MQZRQ5LM.cjs → chunk-N7OUQK7E.cjs} +8 -8
  74. package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-N7OUQK7E.cjs.map} +1 -1
  75. package/dist/{chunk-UARGJ5IZ.js → chunk-NGKKNSK6.js} +30 -7
  76. package/dist/chunk-NGKKNSK6.js.map +1 -0
  77. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  78. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  79. package/dist/{chunk-C77F4ZTL.js → chunk-PTD6EDUU.js} +3 -3
  80. package/dist/{chunk-C77F4ZTL.js.map → chunk-PTD6EDUU.js.map} +1 -1
  81. package/dist/{chunk-ZNM2LW3D.cjs → chunk-QWYFHQYK.cjs} +78 -53
  82. package/dist/chunk-QWYFHQYK.cjs.map +1 -0
  83. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  84. package/dist/chunk-RGNHHIMN.js.map +1 -0
  85. package/dist/{chunk-MOMFX32D.js → chunk-S24ZBUB4.js} +194 -299
  86. package/dist/chunk-S24ZBUB4.js.map +1 -0
  87. package/dist/{chunk-EWS2VFO4.js → chunk-S5TMRJMX.js} +4 -4
  88. package/dist/{chunk-EWS2VFO4.js.map → chunk-S5TMRJMX.js.map} +1 -1
  89. package/dist/chunk-SMOO5FAH.js +10 -0
  90. package/dist/chunk-SMOO5FAH.js.map +1 -0
  91. package/dist/{chunk-RUHKBEFF.js → chunk-SYWR5G3T.js} +16 -7
  92. package/dist/chunk-SYWR5G3T.js.map +1 -0
  93. package/dist/{chunk-FQXRYPCX.cjs → chunk-TRVWMKNE.cjs} +337 -52
  94. package/dist/chunk-TRVWMKNE.cjs.map +1 -0
  95. package/dist/{chunk-LLOIAGFB.js → chunk-UDDVDQMF.js} +292 -35
  96. package/dist/chunk-UDDVDQMF.js.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-5I4T4QR5.cjs → chunk-VACPZPUA.cjs} +5 -5
  100. package/dist/{chunk-5I4T4QR5.cjs.map → chunk-VACPZPUA.cjs.map} +1 -1
  101. package/dist/{chunk-HGI2VKIV.js → chunk-Y6X7UJSD.js} +10 -9
  102. package/dist/chunk-Y6X7UJSD.js.map +1 -0
  103. package/dist/chunk-YCXRSWCQ.js +42 -0
  104. package/dist/chunk-YCXRSWCQ.js.map +1 -0
  105. package/dist/entries/apps.cjs +44 -44
  106. package/dist/entries/apps.js +9 -9
  107. package/dist/entries/credits.cjs +217 -152
  108. package/dist/entries/credits.d.cts +105 -3
  109. package/dist/entries/credits.d.ts +105 -3
  110. package/dist/entries/credits.js +13 -8
  111. package/dist/entries/entities.cjs +188 -143
  112. package/dist/entries/entities.d.cts +122 -1
  113. package/dist/entries/entities.d.ts +122 -1
  114. package/dist/entries/entities.js +2 -1
  115. package/dist/entries/llm-models.d.cts +2 -1
  116. package/dist/entries/llm-models.d.ts +2 -1
  117. package/dist/entries/media.cjs +92 -87
  118. package/dist/entries/media.d.cts +11 -1
  119. package/dist/entries/media.d.ts +11 -1
  120. package/dist/entries/media.js +3 -2
  121. package/dist/entries/model-catalog.cjs +195 -103
  122. package/dist/entries/model-catalog.d.cts +90 -4
  123. package/dist/entries/model-catalog.d.ts +90 -4
  124. package/dist/entries/model-catalog.js +5 -5
  125. package/dist/entries/models.cjs +407 -294
  126. package/dist/entries/models.d.cts +4 -3
  127. package/dist/entries/models.d.ts +4 -3
  128. package/dist/entries/models.js +6 -5
  129. package/dist/entries/nodes.cjs +241 -233
  130. package/dist/entries/nodes.d.cts +15 -2
  131. package/dist/entries/nodes.d.ts +15 -2
  132. package/dist/entries/nodes.js +10 -10
  133. package/dist/entries/pipeline.cjs +152 -152
  134. package/dist/entries/pipeline.d.cts +2 -1
  135. package/dist/entries/pipeline.d.ts +2 -1
  136. package/dist/entries/pipeline.js +3 -3
  137. package/dist/entries/ugc.cjs +71 -71
  138. package/dist/entries/ugc.js +4 -4
  139. package/dist/entries/video.cjs +308 -204
  140. package/dist/entries/video.d.cts +480 -98
  141. package/dist/entries/video.d.ts +480 -98
  142. package/dist/entries/video.js +8 -4
  143. package/dist/entries/workflow.cjs +102 -102
  144. package/dist/entries/workflow.d.cts +5 -4
  145. package/dist/entries/workflow.d.ts +5 -4
  146. package/dist/entries/workflow.js +2 -2
  147. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  148. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  149. package/dist/index.cjs +2309 -1886
  150. package/dist/index.d.cts +9 -9
  151. package/dist/index.d.ts +9 -9
  152. package/dist/index.js +26 -23
  153. package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-CCEcv08q.d.cts} +128 -14
  154. package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-CCEcv08q.d.ts} +128 -14
  155. package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-B88p6XR0.d.ts} +299 -19
  156. package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Cf3zaITt.d.cts} +299 -19
  157. package/package.json +1 -1
  158. package/src/__tests__/extend-providers.test.ts +114 -0
  159. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  160. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  161. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  162. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  163. package/src/__tests__/gvp-supported-providers.test.ts +5 -2
  164. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  165. package/src/__tests__/model-makers.test.ts +49 -11
  166. package/src/__tests__/model-tree.test.ts +13 -0
  167. package/src/__tests__/retired-video-provider.test.ts +15 -5
  168. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  169. package/src/__tests__/seedance-task-type.test.ts +178 -0
  170. package/src/__tests__/seedream-5-5.test.ts +117 -0
  171. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  172. package/src/__tests__/unit-contracts.test.ts +20 -6
  173. package/src/__tests__/upscale-factors.test.ts +107 -0
  174. package/src/__tests__/video-character-refs.test.ts +20 -2
  175. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  176. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  177. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  178. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  179. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  180. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  181. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  182. package/src/__tests__/video-overlay.test.ts +280 -194
  183. package/src/__tests__/video-ref-limits.test.ts +2 -1
  184. package/src/__tests__/video-reference-only.test.ts +6 -2
  185. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  186. package/src/__tests__/wired-character-names.test.ts +220 -0
  187. package/src/credit-estimators/index.ts +8 -0
  188. package/src/credit-estimators/video-overlay.ts +70 -0
  189. package/src/credit-identifiers.ts +94 -1
  190. package/src/entity-image-url.ts +21 -0
  191. package/src/entries/credits.ts +14 -0
  192. package/src/entries/entities.ts +14 -0
  193. package/src/entries/model-catalog.ts +35 -1
  194. package/src/entries/models.ts +34 -0
  195. package/src/entries/nodes.ts +2 -0
  196. package/src/entries/video.ts +6 -0
  197. package/src/generated/unit-contracts.ts +8 -1
  198. package/src/gpt-image-2-6.ts +6 -0
  199. package/src/input-image-pricing.ts +76 -0
  200. package/src/mask-composite.ts +11 -0
  201. package/src/minimax-h3-image.ts +61 -0
  202. package/src/model-catalog.ts +355 -37
  203. package/src/model-constants.ts +590 -32
  204. package/src/node-default-mappings.ts +12 -2
  205. package/src/node-execution-state.ts +4 -3
  206. package/src/producer-types.ts +23 -1
  207. package/src/seedance-task-type.ts +37 -0
  208. package/src/seedream-5-5.ts +45 -0
  209. package/src/unit-contract-compose.ts +4 -1
  210. package/src/upscale-factors.ts +111 -0
  211. package/src/video-character-refs.ts +7 -4
  212. package/src/video-overlay-geometry.ts +99 -0
  213. package/src/video-overlay-input.ts +25 -0
  214. package/src/video-overlay-layout-ids.ts +48 -0
  215. package/src/video-overlay-layouts.ts +315 -0
  216. package/src/video-overlay-validate.ts +223 -0
  217. package/src/video-overlay-video-layers.ts +304 -0
  218. package/src/video-overlay.ts +165 -297
  219. package/src/video-ui-defaults.ts +8 -6
  220. package/src/wired-character-names.ts +202 -0
  221. package/dist/chunk-5XRRENHD.cjs.map +0 -1
  222. package/dist/chunk-673E4KYC.js.map +0 -1
  223. package/dist/chunk-6XVHYD5R.js.map +0 -1
  224. package/dist/chunk-7ARKVJTN.cjs.map +0 -1
  225. package/dist/chunk-7WGKP3EU.js +0 -23
  226. package/dist/chunk-7WGKP3EU.js.map +0 -1
  227. package/dist/chunk-A3FHTSLB.js.map +0 -1
  228. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  229. package/dist/chunk-F5YEMSNK.cjs.map +0 -1
  230. package/dist/chunk-FQXRYPCX.cjs.map +0 -1
  231. package/dist/chunk-FVVD6XY2.js.map +0 -1
  232. package/dist/chunk-G4XWVWRI.js.map +0 -1
  233. package/dist/chunk-HGI2VKIV.js.map +0 -1
  234. package/dist/chunk-IVXSNW2B.cjs.map +0 -1
  235. package/dist/chunk-JHTT2V4A.cjs.map +0 -1
  236. package/dist/chunk-KHZAQGRP.js +0 -17
  237. package/dist/chunk-KHZAQGRP.js.map +0 -1
  238. package/dist/chunk-LLOIAGFB.js.map +0 -1
  239. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  240. package/dist/chunk-MOMFX32D.js.map +0 -1
  241. package/dist/chunk-NCOGGRRP.cjs +0 -27
  242. package/dist/chunk-NCOGGRRP.cjs.map +0 -1
  243. package/dist/chunk-NJVOJXBS.cjs.map +0 -1
  244. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  245. package/dist/chunk-RUHKBEFF.js.map +0 -1
  246. package/dist/chunk-SWVGHAYO.js.map +0 -1
  247. package/dist/chunk-UARGJ5IZ.js.map +0 -1
  248. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  249. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  250. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  251. package/dist/chunk-ZLDFPVVI.cjs +0 -19
  252. package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
  253. package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
  254. package/dist/chunk-ZZGQRRN7.js.map +0 -1
@@ -0,0 +1,98 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import { MODEL_CATALOG } from "../model-catalog.js"
3
+ import {
4
+ GROK_VIDEO_15_PROVIDER,
5
+ grokVideo15MiddleFrameSlots,
6
+ VIDEO_START_FRAME_ONLY_CODE,
7
+ videoStartFrameOnlyMessage,
8
+ videoStartFrameOnlyProblem,
9
+ videoStartFrameOnlyResolution,
10
+ } from "../model-constants.js"
11
+
12
+ const GROK = GROK_VIDEO_15_PROVIDER
13
+
14
+ const SENTENCE =
15
+ "Grok Imagine Video 1.5 takes a start frame only at 1080p: no end frame, loop or in-between frames. " +
16
+ "Choose 720p, or remove the end frame and the in-between frames."
17
+
18
+ describe("start-frame-only resolutions are declared in the catalog", () => {
19
+ it("Grok Imagine Video 1.5 takes a start frame only at 1080p", () => {
20
+ expect(MODEL_CATALOG[GROK]!.startFrameOnlyResolutions).toEqual(["1080p"])
21
+ })
22
+
23
+ it("every declared tier is one of the model's own resolutions", () => {
24
+ for (const [id, entry] of Object.entries(MODEL_CATALOG)) {
25
+ for (const tier of entry.startFrameOnlyResolutions ?? []) {
26
+ expect(entry.resolutions ?? [], `${id} declares ${tier}`).toContain(tier)
27
+ }
28
+ }
29
+ })
30
+
31
+ it("a model that declares none is never refused", () => {
32
+ expect(videoStartFrameOnlyResolution("kling-4-keyframes", "1080p")).toBeUndefined()
33
+ expect(videoStartFrameOnlyProblem("kling-4-keyframes", { resolution: "1080p", hasEndFrame: true, inBetweenFrameCount: 3 })).toBeUndefined()
34
+ expect(videoStartFrameOnlyProblem(undefined, { resolution: "1080p", hasEndFrame: true, inBetweenFrameCount: 3 })).toBeUndefined()
35
+ })
36
+
37
+ it("reads the resolution case-folded, as the runner sends it", () => {
38
+ expect(videoStartFrameOnlyResolution(GROK, "1080P")).toBe("1080p")
39
+ expect(videoStartFrameOnlyResolution(GROK, " 1080p ")).toBe("1080p")
40
+ expect(videoStartFrameOnlyResolution(GROK, "720p")).toBeUndefined()
41
+ expect(videoStartFrameOnlyResolution(GROK, undefined)).toBeUndefined()
42
+ })
43
+ })
44
+
45
+ describe("videoStartFrameOnlyProblem — every combination at 480p, 720p and 1080p", () => {
46
+ const RESOLUTIONS = ["480p", "720p", "1080p"] as const
47
+ const DURATIONS = Array.from({ length: 15 }, (_, i) => i + 1)
48
+
49
+ for (const resolution of RESOLUTIONS) {
50
+ for (const hasEndFrame of [false, true]) {
51
+ for (let wired = 0; wired <= 6; wired++) {
52
+ it(`${resolution}, end frame ${hasEndFrame ? "(or loop) " : "none, "}${wired} in-between frame(s) wired, 1–15s`, () => {
53
+ for (const durationSec of DURATIONS) {
54
+ const sent = Math.min(wired, grokVideo15MiddleFrameSlots(durationSec))
55
+ const refused = resolution === "1080p" && (hasEndFrame || sent > 0)
56
+ const problem = videoStartFrameOnlyProblem(GROK, { resolution, durationSec, hasEndFrame, inBetweenFrameCount: wired })
57
+ expect(problem !== undefined, `${durationSec}s`).toBe(refused)
58
+ if (problem) {
59
+ expect(problem.code).toBe(VIDEO_START_FRAME_ONLY_CODE)
60
+ expect(problem.message).toBe(SENTENCE)
61
+ }
62
+ }
63
+ })
64
+ }
65
+ }
66
+ }
67
+
68
+ it("a start frame alone runs at 1080p", () => {
69
+ expect(videoStartFrameOnlyProblem(GROK, { resolution: "1080p", durationSec: 8, hasEndFrame: false, inBetweenFrameCount: 0 })).toBeUndefined()
70
+ })
71
+
72
+ it("in-between frames all dropped by the clip's cap leave a start-only run, which runs at 1080p", () => {
73
+ // A 1-second clip has no whole second inside it: every in-between frame is dropped.
74
+ expect(grokVideo15MiddleFrameSlots(1)).toBe(0)
75
+ expect(videoStartFrameOnlyProblem(GROK, { resolution: "1080p", durationSec: 1, hasEndFrame: false, inBetweenFrameCount: 4 })).toBeUndefined()
76
+ // ...but an end frame beside it is still sent, so that run is refused.
77
+ expect(videoStartFrameOnlyProblem(GROK, { resolution: "1080p", durationSec: 1, hasEndFrame: true, inBetweenFrameCount: 4 })).toBeDefined()
78
+ // A 2-second clip keeps one of them, so it is refused.
79
+ expect(videoStartFrameOnlyProblem(GROK, { resolution: "1080p", durationSec: 2, hasEndFrame: false, inBetweenFrameCount: 4 })).toBeDefined()
80
+ })
81
+
82
+ it("an unset duration is judged at the length the run renders (the 8s default)", () => {
83
+ expect(videoStartFrameOnlyProblem(GROK, { resolution: "1080p", hasEndFrame: false, inBetweenFrameCount: 1 })).toBeDefined()
84
+ })
85
+ })
86
+
87
+ describe("the refusal sentence", () => {
88
+ it("says the tier takes a start frame only, and offers 720p or removing the frames", () => {
89
+ expect(videoStartFrameOnlyMessage(GROK, "1080p")).toBe(SENTENCE)
90
+ })
91
+
92
+ it("says nothing was charged only for a refused run", () => {
93
+ expect(videoStartFrameOnlyMessage(GROK, "1080p", { nothingCharged: true })).toBe(`${SENTENCE} Nothing was charged.`)
94
+ expect(
95
+ videoStartFrameOnlyProblem(GROK, { resolution: "1080p", hasEndFrame: true, inBetweenFrameCount: 0, nothingCharged: true })!.message,
96
+ ).toBe(`${SENTENCE} Nothing was charged.`)
97
+ })
98
+ })
@@ -0,0 +1,220 @@
1
+ import { describe, it, expect } from "vitest"
2
+ import {
3
+ CHARACTER_NODE_DEFAULT_LABEL,
4
+ CHARACTER_NODE_RETIRED_DEFAULT_LABELS,
5
+ characterOwnName,
6
+ wiredCharacterNames,
7
+ wiredCharacterNamesOf,
8
+ wiredCharacterBySlug,
9
+ wiredCharacterKey,
10
+ aliasRetiredCharacterMentions,
11
+ entityImageUrl,
12
+ type WiredCharacterSource,
13
+ } from "../entries/entities.js"
14
+
15
+ const unnamed = (key: string, extra: Record<string, unknown> = {}): WiredCharacterSource => ({
16
+ key,
17
+ type: "character",
18
+ sourceHandle: "characterRef",
19
+ data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "", ...extra },
20
+ })
21
+ const named = (key: string, characterName: string): WiredCharacterSource => ({
22
+ key,
23
+ type: "character",
24
+ sourceHandle: "characterRef",
25
+ data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName },
26
+ })
27
+ const names = (sources: WiredCharacterSource[]) =>
28
+ [...wiredCharacterNames(sources)].map(([key, n]) => [key, n.name, n.slug])
29
+
30
+ describe("characterOwnName — the name a Character node was given", () => {
31
+ it("is its characterName, trimmed", () => {
32
+ expect(characterOwnName({ characterName: " Maya Lee ", label: CHARACTER_NODE_DEFAULT_LABEL })).toBe("Maya Lee")
33
+ })
34
+
35
+ it("is a label someone typed when it has no characterName", () => {
36
+ expect(characterOwnName({ characterName: "", label: "Hero" })).toBe("Hero")
37
+ })
38
+
39
+ it("is empty for the default label, a retired default, a label or name of only spaces, or no data", () => {
40
+ for (const data of [
41
+ { characterName: "", label: CHARACTER_NODE_DEFAULT_LABEL },
42
+ { characterName: " ", label: ` ${CHARACTER_NODE_DEFAULT_LABEL} ` },
43
+ { characterName: "", label: "Character" },
44
+ { characterName: "", label: " " },
45
+ { characterName: 42, label: undefined },
46
+ {},
47
+ null,
48
+ undefined,
49
+ ]) {
50
+ expect(characterOwnName(data)).toBe("")
51
+ }
52
+ })
53
+
54
+ it("the retired default is exactly the February–June 2026 one", () => {
55
+ // "Character" was the node's default label from 2026-02-03 until
56
+ // 2026-06-21; graphs saved then still carry it on unnamed nodes.
57
+ expect(CHARACTER_NODE_RETIRED_DEFAULT_LABELS).toEqual(["Character"])
58
+ })
59
+ })
60
+
61
+ describe("wiredCharacterNames — what each wired Character node is called by the node it feeds", () => {
62
+ it("one unnamed node is Character 1, never the node's type name", () => {
63
+ expect(names([unnamed("a")])).toEqual([["a", "Character 1", "character-1"]])
64
+ })
65
+
66
+ it("two unnamed nodes are two characters, numbered in wire order", () => {
67
+ expect(names([unnamed("a"), unnamed("b")])).toEqual([
68
+ ["a", "Character 1", "character-1"],
69
+ ["b", "Character 2", "character-2"],
70
+ ])
71
+ })
72
+
73
+ it("a typed label is the name", () => {
74
+ expect(names([unnamed("a", { label: "Hero" })])).toEqual([["a", "Hero", "hero"]])
75
+ })
76
+
77
+ it("an unnamed node beside a node NAMED Character 1 becomes Character 2, in either order", () => {
78
+ expect(names([named("n", "Character 1"), unnamed("a")])).toEqual([
79
+ ["n", "Character 1", "character-1"],
80
+ ["a", "Character 2", "character-2"],
81
+ ])
82
+ expect(names([unnamed("a"), named("n", "character 1")])).toEqual([
83
+ ["a", "Character 2", "character-2"],
84
+ ["n", "character 1", "character-1"],
85
+ ])
86
+ })
87
+
88
+ it("the same typed name on two nodes is one character, as before", () => {
89
+ expect(names([named("a", "Maya"), named("b", "Maya")])).toEqual([
90
+ ["a", "Maya", "maya"],
91
+ ["b", "Maya", "maya"],
92
+ ])
93
+ })
94
+
95
+ it("a mixed list (named, unnamed, named, unnamed)", () => {
96
+ expect(names([named("a", "Maya"), unnamed("b"), named("c", "Leo"), unnamed("d")])).toEqual([
97
+ ["a", "Maya", "maya"],
98
+ ["b", "Character 1", "character-1"],
99
+ ["c", "Leo", "leo"],
100
+ ["d", "Character 2", "character-2"],
101
+ ])
102
+ })
103
+
104
+ it("only a wire that delivers a character counts, and a node wired twice counts once", () => {
105
+ const viaImage: WiredCharacterSource = { ...unnamed("img"), sourceHandle: "image" }
106
+ const notCharacter: WiredCharacterSource = { key: "up", type: "upload-image", sourceHandle: "image", data: { label: "Character Asset" } }
107
+ expect(names([viaImage, notCharacter, unnamed("a"), unnamed("a")])).toEqual([["a", "Character 1", "character-1"]])
108
+ })
109
+
110
+ it("a typed name the slug cannot spell is a real name, keyed by the next number of the unnamed sequence", () => {
111
+ for (const [locale, typed] of [["he", "מאיה"], ["ja", "マヤ"], ["ko", "마야"]] as const) {
112
+ expect(names([unnamed("a"), named("b", typed), named("c", "Leo"), unnamed("d")]), locale).toEqual([
113
+ ["a", "Character 1", "character-1"],
114
+ ["b", typed, "character-2"],
115
+ ["c", "Leo", "leo"],
116
+ ["d", "Character 3", "character-3"],
117
+ ])
118
+ }
119
+ expect(names([named("a", "!!!"), unnamed("b")])).toEqual([
120
+ ["a", "!!!", "character-1"],
121
+ ["b", "Character 2", "character-2"],
122
+ ])
123
+ })
124
+
125
+ it("a numbered key skips a number a Latin name already has", () => {
126
+ expect(names([named("n", "Character 1"), named("m", "マヤ")])).toEqual([
127
+ ["n", "Character 1", "character-1"],
128
+ ["m", "マヤ", "character-2"],
129
+ ])
130
+ })
131
+
132
+ it("unnamed flags the nodes with no name of their own (a slug-less typed name is not one)", () => {
133
+ const m = wiredCharacterNames([named("a", "Maya"), unnamed("b"), named("c", "マヤ")])
134
+ expect(m.get("a")?.unnamed).toBe(false)
135
+ expect(m.get("b")?.unnamed).toBe(true)
136
+ expect(m.get("c")?.unnamed).toBe(false)
137
+ })
138
+ })
139
+
140
+ describe("wiredCharacterNamesOf — the same rule over a graph", () => {
141
+ it("reads the consumer's incoming wires in edge order, keyed by node id", () => {
142
+ const nodes = [
143
+ { id: "u1", type: "character", data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "" } },
144
+ { id: "u2", type: "character", data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "" } },
145
+ { id: "gi", type: "generate-image", data: {} },
146
+ { id: "other", type: "generate-image", data: {} },
147
+ ]
148
+ const edges = [
149
+ { source: "u2", target: "gi", sourceHandle: "characterRef" },
150
+ { source: "u1", target: "other", sourceHandle: "characterRef" },
151
+ { source: "u1", target: "gi", sourceHandle: "characterRef" },
152
+ ]
153
+ const m = wiredCharacterNamesOf("gi", nodes, edges)
154
+ expect([...m].map(([k, n]) => [k, n.name])).toEqual([["u2", "Character 1"], ["u1", "Character 2"]])
155
+ expect(wiredCharacterBySlug(m, "character-2")?.key).toBe("u1")
156
+ expect(wiredCharacterBySlug(m, "")).toBeUndefined()
157
+ })
158
+ })
159
+
160
+ describe("wiredCharacterKey — where a Character node's own elements are filed", () => {
161
+ const m = wiredCharacterNames([named("a", "Maya"), unnamed("b")])
162
+ it("a wired character: its slug", () => {
163
+ expect(wiredCharacterKey(m, "a", { characterName: "Maya" })).toBe("maya")
164
+ expect(wiredCharacterKey(m, "b", { characterName: "" })).toBe("character-1")
165
+ })
166
+ it("a node wired only as a plain image: its own name's slug, else a key of its own", () => {
167
+ expect(wiredCharacterKey(m, "c", { characterName: "Maya" })).toBe("maya")
168
+ expect(wiredCharacterKey(m, "d", { label: CHARACTER_NODE_DEFAULT_LABEL })).toBe("node:d")
169
+ })
170
+ })
171
+
172
+ describe("aliasRetiredCharacterMentions — a mention saved before unnamed characters were numbered", () => {
173
+ const prompt = "@character-asset:1 waves at @character:1:smile~lock while @character-asset:2:face watches"
174
+ it("with exactly one unnamed character wired, @character-asset and @character (any suffix) read as its slug", () => {
175
+ const m = wiredCharacterNames([unnamed("a"), named("b", "Leo")])
176
+ expect(aliasRetiredCharacterMentions(prompt, m)).toBe(
177
+ "@character-1:1 waves at @character-1:1:smile~lock while @character-1:2:face watches",
178
+ )
179
+ })
180
+
181
+ it("it follows the one unnamed node's number", () => {
182
+ const m = wiredCharacterNames([named("n", "Character 1"), unnamed("a")])
183
+ expect(aliasRetiredCharacterMentions("@character-asset:1", m)).toBe("@character-2:1")
184
+ })
185
+
186
+ it("with two unnamed characters, or none, the text is left as it is", () => {
187
+ expect(aliasRetiredCharacterMentions(prompt, wiredCharacterNames([unnamed("a"), unnamed("b")]))).toBe(prompt)
188
+ expect(aliasRetiredCharacterMentions(prompt, wiredCharacterNames([named("b", "Leo")]))).toBe(prompt)
189
+ expect(aliasRetiredCharacterMentions(prompt, wiredCharacterNames([named("b", "マヤ")]))).toBe(prompt)
190
+ })
191
+
192
+ it("a node labelled 'Character' (the retired default) is the one unnamed character too", () => {
193
+ const m = wiredCharacterNames([{ ...unnamed("a"), data: { label: "Character", characterName: "" } }])
194
+ expect(aliasRetiredCharacterMentions("@character:1 and @character-asset:1", m)).toBe("@character-1:1 and @character-1:1")
195
+ })
196
+
197
+ it("a retired slug a wired character really goes by is never rewritten", () => {
198
+ const m = wiredCharacterNames([named("c", "Character"), unnamed("a")])
199
+ expect(aliasRetiredCharacterMentions("@character:1 and @character-asset:1", m)).toBe("@character:1 and @character-1:1")
200
+ })
201
+
202
+ it("only whole mentions: not a numbered slug, a longer slug, an email-like token or one without an index", () => {
203
+ const m = wiredCharacterNames([unnamed("a")])
204
+ const text = "@character-1:1 @characters:1 x@character:1 @character-asset @character"
205
+ expect(aliasRetiredCharacterMentions(text, m)).toBe(text)
206
+ expect(aliasRetiredCharacterMentions(undefined, m)).toBeUndefined()
207
+ })
208
+ })
209
+
210
+ describe("entityImageUrl — the image an entity node gives out, and a Character's portrait", () => {
211
+ it("the starred default asset, else the active generated result, else the source image", () => {
212
+ const results = [{ url: "r0" }, { url: "r1" }]
213
+ expect(entityImageUrl({ defaultAssetUrl: "d", generatedResults: results, activeResultIndex: 1, sourceImageUrl: "s" })).toBe("d")
214
+ expect(entityImageUrl({ defaultAssetUrl: "", generatedResults: results, activeResultIndex: 1, sourceImageUrl: "s" })).toBe("r1")
215
+ expect(entityImageUrl({ generatedResults: results, sourceImageUrl: "s" })).toBe("r0")
216
+ expect(entityImageUrl({ generatedResults: [], sourceImageUrl: "s" })).toBe("s")
217
+ expect(entityImageUrl({})).toBeUndefined()
218
+ expect(entityImageUrl(null)).toBeUndefined()
219
+ })
220
+ })
@@ -81,3 +81,11 @@ export {
81
81
  pitchTempoBaseCredits,
82
82
  semitonesToPitchRatio,
83
83
  } from "./pitch-tempo.js"
84
+
85
+ export {
86
+ VIDEO_OVERLAY_PRICING,
87
+ VIDEO_OVERLAY_REMEASURE_SLACK_SEC,
88
+ videoOverlayCreditId,
89
+ videoOverlayVideoUnits,
90
+ videoOverlayBaseTooLong,
91
+ } from "./video-overlay.js"
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Video Overlay pricing — which row a run is charged from, and how many units
3
+ * of it. One mapping for every place that names the price: the route
4
+ * (`POST /v1/video-overlay`), the workflow run's reservation, the node's Run
5
+ * button and the workflow estimates.
6
+ *
7
+ * An image-only run is the flat `video-overlay` row, whatever its layers or
8
+ * the base's length; its base is never measured for the price. A run with any
9
+ * video layer is charged the `video-overlay:video` row once per started 5
10
+ * seconds of the output — the base's length, which is the output's — the unit
11
+ * Mask Composite is charged by. The route and the workflow run measure the
12
+ * base before anything is reserved, and refuse one they cannot read or one
13
+ * past {@link VIDEO_OVERLAY_PRICING.MAX_BASE_SEC}. Before a run, a base whose
14
+ * length is not known yet is quoted at that cap, so a quote is never below
15
+ * what the run is charged.
16
+ *
17
+ * Worked examples, in units of the `video-overlay:video` row:
18
+ * 10 s → 2, 23 s → 5, 60 s → 12, unknown → 12, 61 s → refused.
19
+ */
20
+ import { pricedClipSeconds } from "../priced-clip-seconds.js"
21
+ import { VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC } from "../video-overlay.js"
22
+
23
+ export const VIDEO_OVERLAY_PRICING = {
24
+ /** An image-only run: one flat row. */
25
+ IMAGE_CREDIT_ID: "video-overlay",
26
+ /** A run with a video layer: one row per started {@link VIDEO_OVERLAY_PRICING.UNIT_SEC} seconds of the output. */
27
+ VIDEO_CREDIT_ID: "video-overlay:video",
28
+ /** Seconds of output one unit of the video row covers. */
29
+ UNIT_SEC: 5,
30
+ /** The longest base a run with a video layer accepts, in seconds. */
31
+ MAX_BASE_SEC: VIDEO_OVERLAY_VIDEO_MAX_BASE_SEC,
32
+ } as const
33
+
34
+ /**
35
+ * How much longer, in seconds, the base the worker downloads may run than the
36
+ * base measured before the run was charged, before the worker refuses it as
37
+ * changed: a re-measure can read a hair longer (a re-encode, a container's
38
+ * rounding), and that is not a different file. Applied to the seconds, never
39
+ * to the units: a base billed for 10 s renders at up to 10.5 s.
40
+ */
41
+ export const VIDEO_OVERLAY_REMEASURE_SLACK_SEC = 0.5
42
+
43
+ /** The row a run is charged from: the flat image row, or the per-5-second video row when any layer is a video. */
44
+ export function videoOverlayCreditId(hasVideoLayer: boolean): string {
45
+ return hasVideoLayer ? VIDEO_OVERLAY_PRICING.VIDEO_CREDIT_ID : VIDEO_OVERLAY_PRICING.IMAGE_CREDIT_ID
46
+ }
47
+
48
+ /**
49
+ * Units of the video row for a base `baseSec` long: one per started 5
50
+ * seconds, at least one, after `pricedClipSeconds` (up to 0.05 s past a whole
51
+ * second is ignored, so a 10.01 s base is 2 units). An unknown length counts
52
+ * the cap — the pre-run quote for a base not measured yet — and so does a
53
+ * length past it (such a base is refused before anything is reserved).
54
+ */
55
+ export function videoOverlayVideoUnits(baseSec: number | null | undefined): number {
56
+ const sec =
57
+ typeof baseSec === "number" && Number.isFinite(baseSec) && baseSec > 0
58
+ ? Math.min(baseSec, VIDEO_OVERLAY_PRICING.MAX_BASE_SEC)
59
+ : VIDEO_OVERLAY_PRICING.MAX_BASE_SEC
60
+ return Math.ceil(pricedClipSeconds(sec) / VIDEO_OVERLAY_PRICING.UNIT_SEC)
61
+ }
62
+
63
+ /**
64
+ * Whether a measured base is past the cap for a run with a video layer. Read
65
+ * on the priced seconds the units use, so a base the price counts as 60 s
66
+ * (60.04 s, a whole-second cut of a 29.97 fps clip) is accepted at 12 units.
67
+ */
68
+ export function videoOverlayBaseTooLong(baseSec: number): boolean {
69
+ return pricedClipSeconds(baseSec) > VIDEO_OVERLAY_PRICING.MAX_BASE_SEC
70
+ }
@@ -28,12 +28,18 @@ import {
28
28
  isViduQ4Provider,
29
29
  isKling4Provider,
30
30
  normalizeKling4Resolution,
31
+ isKling4FlashProvider,
32
+ KLING_4_FLASH_RESOLUTION,
33
+ isGrokVideo15Provider,
34
+ normalizeGrokVideo15Resolution,
31
35
  VIDEO_REF_RATE_PROVIDERS,
32
36
  normalizeMinimaxH3Resolution,
33
37
  normalizeWan3Resolution,
34
38
  normalizeViduQ4Resolution,
35
39
  getVideoAudioCapability,
36
40
  canonicalVideoProvider,
41
+ isSeedanceExtendProvider,
42
+ type SeedanceExtendProvider,
37
43
  } from "./model-constants.js"
38
44
  import { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from "./flux2-pricing.js"
39
45
  import {
@@ -48,6 +54,15 @@ import {
48
54
  type GptImage26TieredModel,
49
55
  type ImageFormatLevers,
50
56
  } from "./gpt-image-2-6.js"
57
+ import { isMinimaxH3Image, minimaxH3ImageCreditId } from "./minimax-h3-image.js"
58
+ import {
59
+ SEEDREAM_5_5_I2I,
60
+ SEEDREAM_5_5_MAX_INPUT_IMAGES,
61
+ isSeedream55,
62
+ isSeedream55I2i,
63
+ seedream55Resolution,
64
+ type Seedream55Model,
65
+ } from "./seedream-5-5.js"
51
66
  import { VIDEO_DURATION_AUTO } from "./video-duration-auto.js"
52
67
  import { uiResolutionFill } from "./video-ui-defaults.js"
53
68
  import { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from "./model-catalog.js"
@@ -127,6 +142,31 @@ function gptImage26CreditId(
127
142
  return `${base}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`
128
143
  }
129
144
 
145
+ /**
146
+ * The price id of a Seedream 5.5 run: `seedream-5-5:<size>`, and on an edit
147
+ * `seedream-5-5-i2i:<size>:<N>ref`, N being the input images (1 to 10). Each
148
+ * size has its own id, 1K and 1.5K at the same price.
149
+ *
150
+ * A size off its list (a stored node, the multi-provider preview pricing one
151
+ * node's data against every model) or none lands on the default, 2K, which is
152
+ * what the provider renders with none. A text-to-image id sent input images
153
+ * runs on the edit endpoint (the provider swaps it), so a caller that does not
154
+ * swap the model first (the entity routes, a pipeline pin) is priced there too.
155
+ * An edit always has at least its source, and is priced for at most the images
156
+ * the provider takes (what a request holds past it is not sent).
157
+ */
158
+ function seedream55CreditId(
159
+ provider: Seedream55Model,
160
+ resolution: string | undefined,
161
+ referenceImageCount: number | undefined,
162
+ ): string {
163
+ const size = seedream55Resolution(resolution)
164
+ const images = Math.trunc(referenceImageCount ?? 0)
165
+ const model = !isSeedream55I2i(provider) && images > 0 ? SEEDREAM_5_5_I2I : provider
166
+ if (!isSeedream55I2i(model)) return `${model}:${size}`
167
+ return `${model}:${size}:${Math.min(Math.max(1, images), SEEDREAM_5_5_MAX_INPUT_IMAGES)}ref`
168
+ }
169
+
130
170
  /**
131
171
  * Compute composite model identifier for variable credit pricing.
132
172
  * Examples: "gpt-image:high", "flux:2K", "nano-banana-pro:4K", "ideogram:TURBO",
@@ -158,6 +198,14 @@ export function buildCreditModelIdentifier(
158
198
  if (isGptImage26Tiered(provider)) {
159
199
  return gptImage26CreditId(provider, quality, resolution, referenceImageCount, imageFormat)
160
200
  }
201
+ // MiniMax H3 Image: by size, and on an edit by its reference images
202
+ // (`minimax-h3-image:2K`, `minimax-h3-image-i2i:4K:3ref`).
203
+ if (isMinimaxH3Image(provider)) {
204
+ return minimaxH3ImageCreditId(provider, resolution, referenceImageCount)
205
+ }
206
+ if (isSeedream55(provider)) {
207
+ return seedream55CreditId(provider, resolution, referenceImageCount)
208
+ }
161
209
  if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === "high") {
162
210
  return `${provider}:high`
163
211
  }
@@ -458,6 +506,9 @@ function wireNormalizedResolution(provider: string, resolution: string | undefin
458
506
  if (isWan3Provider(provider)) return normalizeWan3Resolution(resolution).toLowerCase()
459
507
  if (isViduQ4Provider(provider)) return normalizeViduQ4Resolution(resolution)
460
508
  if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution)
509
+ // Kling 4.0 Flash renders 720p whatever it is asked (its runner sends 720p).
510
+ if (isKling4FlashProvider(provider)) return KLING_4_FLASH_RESOLUTION
511
+ if (isGrokVideo15Provider(provider)) return normalizeGrokVideo15Resolution(resolution)
461
512
  return resolution
462
513
  }
463
514
 
@@ -472,6 +523,9 @@ export function buildVideoCreditModelIdentifier(
472
523
  ): string {
473
524
  // A retired model (RETIRED_VIDEO_PROVIDERS) is priced as the model it runs as.
474
525
  const provider = canonicalVideoProvider(rawProvider) as string
526
+ // A Seedance Extend Video provider is priced on its own rows — the one
527
+ // builder every surface that prices an extend reads.
528
+ if (isSeedanceExtendProvider(provider)) return seedanceExtendCreditId(provider, duration, resolution)
475
529
  // T2V overrides: some providers have different base costs for text-to-video
476
530
  let effectiveProvider = provider
477
531
  if (nodeType === "text-to-video") {
@@ -606,7 +660,7 @@ export function buildVideoCreditModelIdentifier(
606
660
  // Collapsing through the SAME normalizer the runner uses makes render == billed
607
661
  // by construction for every spelling, including garbage (→ the declared 720p).
608
662
  // Scoped to the families whose runner normalizes on purpose (Wan 3.0, Vidu
609
- // Q4): the other RESOLUTION_DURATION_PRICING members pass `resolution` to
663
+ // Q4, Kling 4.0, Grok Imagine Video 1.5): the other RESOLUTION_DURATION_PRICING members pass `resolution` to
610
664
  // their wire verbatim, so case-folding their billing without probing their
611
665
  // wire would reprice live models.
612
666
  const requested = wireNormalizedResolution(effectiveProvider, resolution)
@@ -703,6 +757,45 @@ export function seedanceVideoEditCreditId(provider: string, resolution?: string,
703
757
  })
704
758
  }
705
759
 
760
+ /** The resolution a Seedance extend that names none, or one it does not offer, is priced and run at. */
761
+ const SEEDANCE_EXTEND_DEFAULT_RESOLUTION = "720p"
762
+
763
+ /**
764
+ * The resolution a Seedance Extend Video run is priced at, and so the one it
765
+ * must render at: the requested one when it is among the provider's catalog
766
+ * `resolutions`, else 720p (also when none is named). The workflow run queues
767
+ * it and the worker holds the job to it, so a stored or sent resolution the
768
+ * model does not offer (`4k`) can never render above the row it reserved.
769
+ */
770
+ export function seedanceExtendResolution(provider: SeedanceExtendProvider, resolution?: unknown): string {
771
+ return typeof resolution === "string" && MODEL_CATALOG[provider]?.resolutions?.includes(resolution)
772
+ ? resolution
773
+ : SEEDANCE_EXTEND_DEFAULT_RESOLUTION
774
+ }
775
+
776
+ /**
777
+ * The credit identifier one Seedance Extend Video run is priced at — the one
778
+ * builder every surface that prices it reads (the route's guard and
779
+ * reservation, the workflow reservation and estimate, the editor), so none of
780
+ * them can name a different row.
781
+ *
782
+ * The seconds added snap into the provider's catalog `durations` (its catalog
783
+ * `defaultDuration` when unset, through {@link pricedOutputDurationSec}); the
784
+ * resolution is {@link seedanceExtendResolution}'s. Each provider has its own
785
+ * rows, one per second of its window and resolution: `<provider>:<N>s:<res>`
786
+ * (`seedance-2-5-extend` 4–30 s, `seedance-2-0-extend` 4–15 s).
787
+ *
788
+ * A retired id (`seedance-2-extend`) is not a {@link SeedanceExtendProvider}:
789
+ * pass a stored or sent provider through `canonicalVideoProvider` first.
790
+ */
791
+ export function seedanceExtendCreditId(
792
+ provider: SeedanceExtendProvider,
793
+ duration?: number | string,
794
+ resolution?: string,
795
+ ): string {
796
+ return `${provider}:${pricedOutputDurationSec(provider, duration)}s:${seedanceExtendResolution(provider, resolution)}`
797
+ }
798
+
706
799
  /** What the video credit identifier PRICES for a request, for the levers whose
707
800
  * priced value must also be the value we SEND. */
708
801
  export interface PricedVideoSelection {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The image an entity node (character / face / object / creature / location)
3
+ * gives out: the asset the user starred as its default, else its active
4
+ * generated result, else its source image — the image its card shows. It is
5
+ * the node's output on both run paths, and it is a wired Character's portrait
6
+ * (its identity reference, a Kling subject's first image), so the character
7
+ * and its output are one image and one image goes out. `||`, so an empty
8
+ * string falls through.
9
+ */
10
+ export function entityImageUrl(data: unknown): string | undefined {
11
+ const d = (data ?? {}) as {
12
+ readonly defaultAssetUrl?: unknown
13
+ readonly generatedResults?: unknown
14
+ readonly activeResultIndex?: unknown
15
+ readonly sourceImageUrl?: unknown
16
+ }
17
+ const str = (v: unknown): string | undefined => (typeof v === "string" && v ? v : undefined)
18
+ const results = Array.isArray(d.generatedResults) ? (d.generatedResults as ReadonlyArray<{ readonly url?: unknown } | null | undefined>) : []
19
+ const active = typeof d.activeResultIndex === "number" ? d.activeResultIndex : 0
20
+ return str(d.defaultAssetUrl) || str(results[active]?.url) || str(d.sourceImageUrl)
21
+ }
@@ -24,6 +24,8 @@ export {
24
24
  imageGenAutoAspectNeedsSourceImage,
25
25
  buildVideoCreditModelIdentifier,
26
26
  seedanceVideoEditCreditId,
27
+ seedanceExtendCreditId,
28
+ seedanceExtendResolution,
27
29
  videoGenerationCreditId,
28
30
  pricedVideoSelection,
29
31
  buildMotionCreditModelIdentifier,
@@ -49,6 +51,18 @@ export {
49
51
  type TopazUpscaleAdjustment,
50
52
  type TopazUpscaleResolution,
51
53
  } from "../topaz-upscale.js"
54
+ export {
55
+ NODARO_IMAGE_UPSCALE_MODEL_ID,
56
+ NODARO_IMAGE_UPSCALE_FACTORS,
57
+ NODARO_IMAGE_UPSCALE_DEFAULT_FACTOR,
58
+ UPSCALE_FACTORS,
59
+ resolveNodaroImageUpscaleFactor,
60
+ resolveUpscaleFactor,
61
+ snappedUpscaleFactor,
62
+ upscaleFactorsFor,
63
+ type NodaroImageUpscaleFactor,
64
+ type UpscaleFactor,
65
+ } from "../upscale-factors.js"
52
66
  export { calculateMonetizationMarkup, calculateMonetizedCost } from "../monetization.js"
53
67
  export {
54
68
  LIP_SYNC_DURATION_BUCKETS,
@@ -42,6 +42,20 @@ export {
42
42
  parseCharacterMentionToken,
43
43
  findCharacterMentionTokens,
44
44
  } from "../character-mention-slug.js"
45
+ export {
46
+ CHARACTER_NODE_DEFAULT_LABEL,
47
+ CHARACTER_NODE_RETIRED_DEFAULT_LABELS,
48
+ UNNAMED_CHARACTER_NAME_PREFIX,
49
+ characterOwnName,
50
+ wiredCharacterNames,
51
+ wiredCharacterNamesOf,
52
+ wiredCharacterBySlug,
53
+ wiredCharacterKey,
54
+ aliasRetiredCharacterMentions,
55
+ RETIRED_CHARACTER_MENTION_SLUGS,
56
+ } from "../wired-character-names.js"
57
+ export { entityImageUrl } from "../entity-image-url.js"
58
+ export type { WiredCharacterSource, WiredCharacterName } from "../wired-character-names.js"
45
59
  export type { CharacterMentionTokenInfo } from "../character-mention-slug.js"
46
60
  export {
47
61
  CHARACTER_VARIANT_ASSET_BUCKETS,