@nodaro/shared 3.68.0 → 3.70.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 (205) hide show
  1. package/dist/{chunk-5IZHECUP.js → chunk-2VOXSVIE.js} +3 -3
  2. package/dist/{chunk-5IZHECUP.js.map → chunk-2VOXSVIE.js.map} +1 -1
  3. package/dist/{chunk-OXBU5AGH.js → chunk-42ICEVUN.js} +3 -3
  4. package/dist/{chunk-OXBU5AGH.js.map → chunk-42ICEVUN.js.map} +1 -1
  5. package/dist/{chunk-EFYWV2V5.cjs → chunk-4U7QAUV3.cjs} +73 -73
  6. package/dist/{chunk-EFYWV2V5.cjs.map → chunk-4U7QAUV3.cjs.map} +1 -1
  7. package/dist/{chunk-OFQ6CU6S.js → chunk-52JNQG4K.js} +3 -3
  8. package/dist/{chunk-OFQ6CU6S.js.map → chunk-52JNQG4K.js.map} +1 -1
  9. package/dist/{chunk-PERUFUVH.cjs → chunk-5B337MCI.cjs} +15 -15
  10. package/dist/{chunk-PERUFUVH.cjs.map → chunk-5B337MCI.cjs.map} +1 -1
  11. package/dist/{chunk-66QSUUB4.cjs → chunk-5DRSENY3.cjs} +24 -24
  12. package/dist/{chunk-66QSUUB4.cjs.map → chunk-5DRSENY3.cjs.map} +1 -1
  13. package/dist/{chunk-3YWZ5SOZ.js → chunk-BIQ7COJP.js} +5 -5
  14. package/dist/{chunk-3YWZ5SOZ.js.map → chunk-BIQ7COJP.js.map} +1 -1
  15. package/dist/{chunk-4XR66IWF.cjs → chunk-BLGZW3UF.cjs} +64 -23
  16. package/dist/chunk-BLGZW3UF.cjs.map +1 -0
  17. package/dist/{chunk-KSHAAPQF.cjs → chunk-BOCHNFDU.cjs} +4 -4
  18. package/dist/chunk-BOCHNFDU.cjs.map +1 -0
  19. package/dist/{chunk-Z77M7Q2R.js → chunk-C2UHX7OF.js} +3 -3
  20. package/dist/{chunk-Z77M7Q2R.js.map → chunk-C2UHX7OF.js.map} +1 -1
  21. package/dist/{chunk-Q2LEJXLZ.cjs → chunk-C32IL6RD.cjs} +2 -2
  22. package/dist/{chunk-Q2LEJXLZ.cjs.map → chunk-C32IL6RD.cjs.map} +1 -1
  23. package/dist/{chunk-5NVGKXJV.cjs → chunk-CV2BEK52.cjs} +111 -3
  24. package/dist/chunk-CV2BEK52.cjs.map +1 -0
  25. package/dist/{chunk-G2G7XGFU.cjs → chunk-DOY47F7S.cjs} +7 -7
  26. package/dist/{chunk-G2G7XGFU.cjs.map → chunk-DOY47F7S.cjs.map} +1 -1
  27. package/dist/{chunk-5GG4CG4Y.js → chunk-EWNDK4FV.js} +3 -3
  28. package/dist/{chunk-5GG4CG4Y.js.map → chunk-EWNDK4FV.js.map} +1 -1
  29. package/dist/{chunk-T4GIHHXY.cjs → chunk-FMQ43SJP.cjs} +6 -6
  30. package/dist/{chunk-T4GIHHXY.cjs.map → chunk-FMQ43SJP.cjs.map} +1 -1
  31. package/dist/{chunk-IWUW3YPM.cjs → chunk-FWPGRC4X.cjs} +5 -5
  32. package/dist/{chunk-IWUW3YPM.cjs.map → chunk-FWPGRC4X.cjs.map} +1 -1
  33. package/dist/{chunk-37ZSFS6A.cjs → chunk-GC77W57T.cjs} +18 -18
  34. package/dist/{chunk-37ZSFS6A.cjs.map → chunk-GC77W57T.cjs.map} +1 -1
  35. package/dist/{chunk-BNR5FKL5.js → chunk-H2E4QXEZ.js} +3 -3
  36. package/dist/{chunk-BNR5FKL5.js.map → chunk-H2E4QXEZ.js.map} +1 -1
  37. package/dist/{chunk-GF7ZA26H.js → chunk-HA2PVTER.js} +5 -5
  38. package/dist/{chunk-GF7ZA26H.js.map → chunk-HA2PVTER.js.map} +1 -1
  39. package/dist/{chunk-M5QY464F.cjs → chunk-HBRDKHIW.cjs} +21 -21
  40. package/dist/{chunk-M5QY464F.cjs.map → chunk-HBRDKHIW.cjs.map} +1 -1
  41. package/dist/{chunk-E62W5I6A.cjs → chunk-HWBLZSM3.cjs} +109 -7
  42. package/dist/chunk-HWBLZSM3.cjs.map +1 -0
  43. package/dist/{chunk-5LWYX4GV.js → chunk-IKN54UGB.js} +3 -3
  44. package/dist/{chunk-5LWYX4GV.js.map → chunk-IKN54UGB.js.map} +1 -1
  45. package/dist/{chunk-UVUHVY7F.js → chunk-JCYTTTM2.js} +2 -2
  46. package/dist/{chunk-UVUHVY7F.js.map → chunk-JCYTTTM2.js.map} +1 -1
  47. package/dist/{chunk-PJAJCFLP.cjs → chunk-JEUZNHLL.cjs} +168 -44
  48. package/dist/chunk-JEUZNHLL.cjs.map +1 -0
  49. package/dist/{chunk-TAPBDT47.js → chunk-JVYDKXGY.js} +4 -4
  50. package/dist/{chunk-TAPBDT47.js.map → chunk-JVYDKXGY.js.map} +1 -1
  51. package/dist/{chunk-V6OXSXIX.js → chunk-K3YGI5IW.js} +107 -4
  52. package/dist/chunk-K3YGI5IW.js.map +1 -0
  53. package/dist/{chunk-SCDE676D.js → chunk-KKFFQUMM.js} +65 -23
  54. package/dist/chunk-KKFFQUMM.js.map +1 -0
  55. package/dist/{chunk-BHL7TAQO.js → chunk-LTBM2KMY.js} +43 -10
  56. package/dist/chunk-LTBM2KMY.js.map +1 -0
  57. package/dist/{chunk-BMDOPJBP.cjs → chunk-MZ772ZXA.cjs} +17 -17
  58. package/dist/{chunk-BMDOPJBP.cjs.map → chunk-MZ772ZXA.cjs.map} +1 -1
  59. package/dist/{chunk-SW5ZD7BO.js → chunk-NS34PZ2S.js} +3 -3
  60. package/dist/{chunk-SW5ZD7BO.js.map → chunk-NS34PZ2S.js.map} +1 -1
  61. package/dist/{chunk-6Q4BS6AR.js → chunk-NT3ZFUNJ.js} +31 -3
  62. package/dist/chunk-NT3ZFUNJ.js.map +1 -0
  63. package/dist/{chunk-VBP4DH37.js → chunk-O53P2D4V.js} +130 -15
  64. package/dist/chunk-O53P2D4V.js.map +1 -0
  65. package/dist/{chunk-AT53ZQUC.js → chunk-OW5AXH2Y.js} +51 -7
  66. package/dist/chunk-OW5AXH2Y.js.map +1 -0
  67. package/dist/{chunk-F6XIH3TZ.cjs → chunk-OZHE77T3.cjs} +9 -9
  68. package/dist/{chunk-F6XIH3TZ.cjs.map → chunk-OZHE77T3.cjs.map} +1 -1
  69. package/dist/{chunk-5J2LIQYU.js → chunk-PKWRAMVB.js} +6 -6
  70. package/dist/{chunk-5J2LIQYU.js.map → chunk-PKWRAMVB.js.map} +1 -1
  71. package/dist/{chunk-BCY3A62O.cjs → chunk-POZBRZUM.cjs} +75 -60
  72. package/dist/chunk-POZBRZUM.cjs.map +1 -0
  73. package/dist/{chunk-X2YHKP4D.cjs → chunk-PWIKUOLB.cjs} +8 -8
  74. package/dist/{chunk-X2YHKP4D.cjs.map → chunk-PWIKUOLB.cjs.map} +1 -1
  75. package/dist/{chunk-OXTF4Y3P.cjs → chunk-PYYYBINP.cjs} +6 -6
  76. package/dist/{chunk-OXTF4Y3P.cjs.map → chunk-PYYYBINP.cjs.map} +1 -1
  77. package/dist/{chunk-WZG6GZIL.cjs → chunk-QCGSL4CJ.cjs} +4 -4
  78. package/dist/{chunk-WZG6GZIL.cjs.map → chunk-QCGSL4CJ.cjs.map} +1 -1
  79. package/dist/{chunk-XEPKONJC.js → chunk-QCVQVKCI.js} +3 -3
  80. package/dist/{chunk-XEPKONJC.js.map → chunk-QCVQVKCI.js.map} +1 -1
  81. package/dist/{chunk-3L7GMQ4M.cjs → chunk-QCZYYAPZ.cjs} +54 -49
  82. package/dist/chunk-QCZYYAPZ.cjs.map +1 -0
  83. package/dist/{chunk-GNLA5NTT.cjs → chunk-QV32JI4L.cjs} +4 -4
  84. package/dist/{chunk-GNLA5NTT.cjs.map → chunk-QV32JI4L.cjs.map} +1 -1
  85. package/dist/{chunk-3QJ3UR5Z.js → chunk-QVAUBB2T.js} +11 -11
  86. package/dist/{chunk-3QJ3UR5Z.js.map → chunk-QVAUBB2T.js.map} +1 -1
  87. package/dist/{chunk-MVXZP6VB.js → chunk-R22UHRR6.js} +109 -7
  88. package/dist/chunk-R22UHRR6.js.map +1 -0
  89. package/dist/{chunk-KL6GAYTT.js → chunk-S6DXSQCV.js} +5 -3
  90. package/dist/chunk-S6DXSQCV.js.map +1 -0
  91. package/dist/{chunk-V24EPI5N.cjs → chunk-U4DIGIC3.cjs} +5 -3
  92. package/dist/chunk-U4DIGIC3.cjs.map +1 -0
  93. package/dist/{chunk-H5KHWTAE.js → chunk-UY6QZX7H.js} +4 -4
  94. package/dist/chunk-UY6QZX7H.js.map +1 -0
  95. package/dist/{chunk-XNJDAW3M.js → chunk-V6TC2NDG.js} +31 -17
  96. package/dist/chunk-V6TC2NDG.js.map +1 -0
  97. package/dist/{chunk-DBD4BCGH.cjs → chunk-VDFQKLDG.cjs} +33 -2
  98. package/dist/chunk-VDFQKLDG.cjs.map +1 -0
  99. package/dist/{chunk-PGDR7CO3.cjs → chunk-WHV7MDNC.cjs} +70 -11
  100. package/dist/chunk-WHV7MDNC.cjs.map +1 -0
  101. package/dist/{chunk-HTDKEYMY.cjs → chunk-XBHDXURR.cjs} +139 -91
  102. package/dist/chunk-XBHDXURR.cjs.map +1 -0
  103. package/dist/{chunk-PAUWEWTY.js → chunk-YLDY23N2.js} +12 -7
  104. package/dist/chunk-YLDY23N2.js.map +1 -0
  105. package/dist/entries/apps.cjs +43 -43
  106. package/dist/entries/apps.js +8 -8
  107. package/dist/entries/credits.cjs +282 -226
  108. package/dist/entries/credits.d.cts +167 -66
  109. package/dist/entries/credits.d.ts +167 -66
  110. package/dist/entries/credits.js +11 -11
  111. package/dist/entries/llm-models.cjs +88 -68
  112. package/dist/entries/llm-models.d.cts +73 -6
  113. package/dist/entries/llm-models.d.ts +73 -6
  114. package/dist/entries/llm-models.js +2 -2
  115. package/dist/entries/media.cjs +87 -87
  116. package/dist/entries/media.js +1 -1
  117. package/dist/entries/model-catalog.cjs +133 -133
  118. package/dist/entries/model-catalog.js +4 -4
  119. package/dist/entries/models.cjs +458 -406
  120. package/dist/entries/models.d.cts +64 -29
  121. package/dist/entries/models.d.ts +64 -29
  122. package/dist/entries/models.js +7 -7
  123. package/dist/entries/nodes.cjs +215 -215
  124. package/dist/entries/nodes.js +11 -11
  125. package/dist/entries/pipeline.cjs +153 -153
  126. package/dist/entries/pipeline.d.cts +1 -1
  127. package/dist/entries/pipeline.d.ts +1 -1
  128. package/dist/entries/pipeline.js +3 -3
  129. package/dist/entries/social.cjs +237 -177
  130. package/dist/entries/social.d.cts +183 -6
  131. package/dist/entries/social.d.ts +183 -6
  132. package/dist/entries/social.js +2 -2
  133. package/dist/entries/ugc.cjs +71 -71
  134. package/dist/entries/ugc.js +4 -4
  135. package/dist/entries/video.cjs +153 -153
  136. package/dist/entries/video.d.cts +2 -1
  137. package/dist/entries/video.d.ts +2 -1
  138. package/dist/entries/video.js +7 -7
  139. package/dist/entries/workflow.cjs +152 -152
  140. package/dist/entries/workflow.js +4 -4
  141. package/dist/index.cjs +2034 -1846
  142. package/dist/index.d.cts +5 -5
  143. package/dist/index.d.ts +5 -5
  144. package/dist/index.js +26 -26
  145. package/dist/{model-constants-DZ3tPGFO.d.ts → model-constants-B5DNHIP8.d.ts} +156 -12
  146. package/dist/{model-constants-BstsUup6.d.cts → model-constants-CQr_d3Kw.d.cts} +156 -12
  147. package/package.json +1 -1
  148. package/src/__tests__/cast-swap-limits.test.ts +54 -20
  149. package/src/__tests__/competitors.test.ts +64 -0
  150. package/src/__tests__/extend-providers.test.ts +43 -6
  151. package/src/__tests__/fixtures/measured-input-quote-parity.json +537 -1
  152. package/src/__tests__/fixtures/planned-length-quote-parity.json +46 -1
  153. package/src/__tests__/fixtures/probed-node-quote-parity.json +132 -0
  154. package/src/__tests__/fixtures/video-utility-quote-parity.json +112 -1
  155. package/src/__tests__/gemini-omni-extend.test.ts +110 -0
  156. package/src/__tests__/gvp-supported-providers.test.ts +3 -0
  157. package/src/__tests__/lip-sync-pricing.test.ts +29 -2
  158. package/src/__tests__/llm-models.test.ts +163 -6
  159. package/src/__tests__/llm-price-key.test.ts +2 -0
  160. package/src/__tests__/seedance-2-5-flash-catalog.test.ts +194 -0
  161. package/src/__tests__/suno-separate.test.ts +32 -0
  162. package/src/__tests__/video-character-refs.test.ts +48 -0
  163. package/src/cast-swap-limits.ts +43 -25
  164. package/src/competitors.ts +80 -8
  165. package/src/credit-identifiers.ts +51 -32
  166. package/src/entries/credits.ts +19 -0
  167. package/src/entries/llm-models.ts +6 -0
  168. package/src/entries/models.ts +15 -0
  169. package/src/entries/social.ts +33 -0
  170. package/src/gemini-omni-extend-quote.ts +76 -0
  171. package/src/generated/unit-contracts.ts +1 -0
  172. package/src/lip-sync-pricing.ts +26 -1
  173. package/src/llm-models.ts +176 -5
  174. package/src/model-catalog.ts +107 -5
  175. package/src/model-constants.ts +274 -11
  176. package/src/node-default-mappings.ts +2 -0
  177. package/src/node-runtime-keys.ts +2 -2
  178. package/src/seedance-extend-rate.ts +83 -20
  179. package/src/seedance-lip-sync.ts +68 -0
  180. package/src/suno-separate.ts +51 -0
  181. package/src/topics.ts +162 -0
  182. package/src/video-character-refs.ts +26 -6
  183. package/src/video-face-mesh.ts +1 -1
  184. package/dist/chunk-3L7GMQ4M.cjs.map +0 -1
  185. package/dist/chunk-4XR66IWF.cjs.map +0 -1
  186. package/dist/chunk-5NVGKXJV.cjs.map +0 -1
  187. package/dist/chunk-6Q4BS6AR.js.map +0 -1
  188. package/dist/chunk-AT53ZQUC.js.map +0 -1
  189. package/dist/chunk-BCY3A62O.cjs.map +0 -1
  190. package/dist/chunk-BHL7TAQO.js.map +0 -1
  191. package/dist/chunk-DBD4BCGH.cjs.map +0 -1
  192. package/dist/chunk-E62W5I6A.cjs.map +0 -1
  193. package/dist/chunk-H5KHWTAE.js.map +0 -1
  194. package/dist/chunk-HTDKEYMY.cjs.map +0 -1
  195. package/dist/chunk-KL6GAYTT.js.map +0 -1
  196. package/dist/chunk-KSHAAPQF.cjs.map +0 -1
  197. package/dist/chunk-MVXZP6VB.js.map +0 -1
  198. package/dist/chunk-PAUWEWTY.js.map +0 -1
  199. package/dist/chunk-PGDR7CO3.cjs.map +0 -1
  200. package/dist/chunk-PJAJCFLP.cjs.map +0 -1
  201. package/dist/chunk-SCDE676D.js.map +0 -1
  202. package/dist/chunk-V24EPI5N.cjs.map +0 -1
  203. package/dist/chunk-V6OXSXIX.js.map +0 -1
  204. package/dist/chunk-VBP4DH37.js.map +0 -1
  205. package/dist/chunk-XNJDAW3M.js.map +0 -1
@@ -1,9 +1,11 @@
1
1
  /**
2
- * Seedance 2.5 Extend's price rows — part of the public credit-id contract:
2
+ * The price rows of the Extend Video providers priced by the seconds they
3
+ * send (Seedance 2.5 Extend, Seedance 2.5 Flash Extend) — part of the public
4
+ * credit-id contract:
3
5
  * the rows a run is charged a multiple of, and so the ids a client names to
4
6
  * ask what a run costs (`tailExtendCreditId`, `credit-identifiers.ts`).
5
7
  *
6
- * A Seedance 2.5 Extend run sends the source's last
8
+ * Such a run sends the source's last
7
9
  * {@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC} seconds (all of a shorter source)
8
10
  * and is charged per second sent and added. A per-second price is not a
9
11
  * whole credit, so each resolution's row is the price of
@@ -20,14 +22,36 @@
20
22
  * (`seedance-extend-pricing.ts`) and the backend read them from here.
21
23
  */
22
24
  import { MODEL_CATALOG } from "./model-catalog.js"
23
- import { pricedOutputDurationSec, SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC, type SeedanceExtendProvider, type TailExtendProvider } from "./model-constants.js"
25
+ import {
26
+ pricedOutputDurationSec,
27
+ SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC,
28
+ VIDEO_REF_VIDEO_DURATION_LIMITS,
29
+ type SeedanceExtendProvider,
30
+ type TailExtendProvider,
31
+ } from "./model-constants.js"
24
32
  import { CONTAINER_OVERHANG_SEC } from "./video-duration.js"
25
33
 
26
- /** The Extend Video provider priced by the seconds it sends. */
27
- export const SEEDANCE_EXTEND_SENT_PRICED_PROVIDER = "seedance-2-5-extend" satisfies SeedanceExtendProvider
34
+ /**
35
+ * The Extend Video providers priced by the seconds they send, each on its own
36
+ * rows (decided 2026-11-16: Seedance 2.5 Flash Extend beside Seedance 2.5
37
+ * Extend). The window ({@link SEEDANCE_EXTEND_CONTEXT_MAX_SEC}), the two
38
+ * seconds a row prices and the seconds rule are the same for all of them; the
39
+ * rows are each provider's own, one per resolution its catalog entry offers.
40
+ */
41
+ export const SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS = [
42
+ "seedance-2-5-extend",
43
+ "seedance-2-5-flash-extend",
44
+ ] as const satisfies readonly SeedanceExtendProvider[]
45
+
46
+ /** An Extend Video provider priced by the seconds it sends. */
47
+ export type SentPricedSeedanceExtendProvider = typeof SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS[number]
28
48
 
29
- /** The Extend Video provider priced by the seconds it sends. */
30
- export type SentPricedSeedanceExtendProvider = typeof SEEDANCE_EXTEND_SENT_PRICED_PROVIDER
49
+ /**
50
+ * The first provider priced by the seconds it sends, Seedance 2.5 Extend: what
51
+ * the helpers below price when a caller names no provider (their signatures
52
+ * before Seedance 2.5 Flash Extend joined).
53
+ */
54
+ export const SEEDANCE_EXTEND_SENT_PRICED_PROVIDER = "seedance-2-5-extend" satisfies SentPricedSeedanceExtendProvider
31
55
 
32
56
  /** The most of the source's end a run sends as `@video_1`, in seconds. */
33
57
  export const SEEDANCE_EXTEND_CONTEXT_MAX_SEC = 10
@@ -35,21 +59,41 @@ export const SEEDANCE_EXTEND_CONTEXT_MAX_SEC = 10
35
59
  /** The seconds one rate row prices. */
36
60
  export const SEEDANCE_EXTEND_RATE_SECONDS = 2
37
61
 
38
- /** The rate row of each resolution: the price of {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds. */
62
+ /** A provider's rate row at `resolution`: `<provider>:<resolution>:per-2s`. */
63
+ function rateRowId(provider: SentPricedSeedanceExtendProvider, resolution: string): string {
64
+ return `${provider}:${resolution}:per-${SEEDANCE_EXTEND_RATE_SECONDS}s`
65
+ }
66
+
67
+ /**
68
+ * Each sent-priced provider's rate rows, by resolution: one per resolution its
69
+ * catalog entry offers (Seedance 2.5 Extend 480p / 720p / 1080p; Seedance 2.5
70
+ * Flash Extend 480p / 720p), each the price of
71
+ * {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds. Read from the catalog, so a
72
+ * provider's rows and the resolutions it renders cannot differ.
73
+ */
74
+ export const SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER: Readonly<Record<SentPricedSeedanceExtendProvider, Readonly<Record<string, string>>>> =
75
+ Object.fromEntries(
76
+ SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS.map((provider) => [
77
+ provider,
78
+ Object.fromEntries((MODEL_CATALOG[provider]?.resolutions ?? []).map((resolution) => [resolution, rateRowId(provider, resolution)])),
79
+ ]),
80
+ ) as Record<SentPricedSeedanceExtendProvider, Record<string, string>>
81
+
82
+ /** Seedance 2.5 Extend's rate row of each resolution: the price of {@link SEEDANCE_EXTEND_RATE_SECONDS} seconds. */
39
83
  export const SEEDANCE_EXTEND_RATE_CREDIT_IDS: Readonly<Record<"480p" | "720p" | "1080p", string>> = {
40
84
  "480p": "seedance-2-5-extend:480p:per-2s",
41
85
  "720p": "seedance-2-5-extend:720p:per-2s",
42
86
  "1080p": "seedance-2-5-extend:1080p:per-2s",
43
87
  }
44
88
 
45
- /** Is `provider` the Extend Video provider priced by the seconds it sends? A retired id answers false: pass it through `canonicalVideoProvider` first. */
89
+ /** Is `provider` an Extend Video provider priced by the seconds it sends? A retired id answers false: pass it through `canonicalVideoProvider` first. */
46
90
  export function isSeedanceExtendPricedBySecondsSent(provider: unknown): provider is SentPricedSeedanceExtendProvider {
47
- return provider === SEEDANCE_EXTEND_SENT_PRICED_PROVIDER
91
+ return typeof provider === "string" && (SEEDANCE_EXTEND_SENT_PRICED_PROVIDERS as readonly string[]).includes(provider)
48
92
  }
49
93
 
50
- /** Is `id` one of the rate rows? */
94
+ /** Is `id` one of the rate rows (of any sent-priced provider)? */
51
95
  export function isSeedanceExtendRateCreditId(id: unknown): boolean {
52
- return typeof id === "string" && (Object.values(SEEDANCE_EXTEND_RATE_CREDIT_IDS) as string[]).includes(id)
96
+ return typeof id === "string" && Object.values(SEEDANCE_EXTEND_RATE_CREDIT_IDS_BY_PROVIDER).some((rows) => Object.values(rows).includes(id))
53
97
  }
54
98
 
55
99
  /**
@@ -67,6 +111,20 @@ export function seedanceExtendAddedSec(provider: TailExtendProvider, duration: u
67
111
  return Math.min(max, Math.max(min, Math.round(pricedOutputDurationSec(provider, requested))))
68
112
  }
69
113
 
114
+ /**
115
+ * The shortest source (its picture) each sent-priced provider continues, in
116
+ * seconds: the shortest reference video its model takes. Seedance 2.5 Extend:
117
+ * 1.8 s, measured on the 2.0 family (`SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC`; a
118
+ * nominal 2 s clip that probes a frame short still runs). Seedance 2.5 Flash
119
+ * Extend: Flash's documented 2 s (`VIDEO_REF_VIDEO_DURATION_LIMITS`, decided
120
+ * 2026-11-16). The route and a quote refuse a shorter source, and the worker
121
+ * again before it generates.
122
+ */
123
+ export const SEEDANCE_EXTEND_MIN_SOURCE_SEC: Readonly<Record<SentPricedSeedanceExtendProvider, number>> = {
124
+ "seedance-2-5-extend": SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC,
125
+ "seedance-2-5-flash-extend": VIDEO_REF_VIDEO_DURATION_LIMITS["seedance-2-5-flash"]!.minSec,
126
+ }
127
+
70
128
  /** A length the source gives, when it is one: finite and above 0. */
71
129
  function knownSec(sec: number | null | undefined): number | undefined {
72
130
  return typeof sec === "number" && Number.isFinite(sec) && sec > 0 ? sec : undefined
@@ -98,16 +156,21 @@ export function seedanceExtendSentSec(sourcePictureSec: number | null | undefine
98
156
  }
99
157
 
100
158
  /**
101
- * Whether a Seedance Extend run refuses a source of this measured picture
102
- * length: a known length (positive, finite) under the shortest source the
103
- * extend takes, `SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC`, compared as measured, as
104
- * the route refuses it before anything is reserved and the worker before it
105
- * generates. A length that is not known is never refused here (the run
106
- * measures the source itself).
159
+ * Whether a sent-priced extend on `provider` refuses a source of this measured
160
+ * picture length: a known length (positive, finite) under the shortest source
161
+ * the provider takes ({@link SEEDANCE_EXTEND_MIN_SOURCE_SEC}: 1.8 s, 2 s on
162
+ * Seedance 2.5 Flash Extend), compared as measured, as the route refuses it
163
+ * before anything is reserved and the worker before it generates. A length
164
+ * that is not known is never refused here (the run measures the source itself).
107
165
  */
108
- export function seedanceExtendRefusesSource(sourcePictureSec: number | null | undefined): boolean {
166
+ export function seedanceExtendSourceRefused(provider: SentPricedSeedanceExtendProvider, sourcePictureSec: number | null | undefined): boolean {
109
167
  const known = knownSec(sourcePictureSec)
110
- return known !== undefined && known < SEEDANCE_2_R2V_MIN_REF_VIDEO_SEC
168
+ return known !== undefined && known < SEEDANCE_EXTEND_MIN_SOURCE_SEC[provider]
169
+ }
170
+
171
+ /** Seedance 2.5 Extend's {@link seedanceExtendSourceRefused} (its 1.8 s floor). */
172
+ export function seedanceExtendRefusesSource(sourcePictureSec: number | null | undefined): boolean {
173
+ return seedanceExtendSourceRefused(SEEDANCE_EXTEND_SENT_PRICED_PROVIDER, sourcePictureSec)
111
174
  }
112
175
 
113
176
  /** The units of a rate row a run that sends `sentSec` and adds `addedSec` is charged. */
@@ -0,0 +1,68 @@
1
+ /**
2
+ * What a Seedance Lip Sync run renders and is priced at — ONE rule for the
3
+ * route, the workflow run, the editor's estimate and the worker (decided
4
+ * 2026-11-16).
5
+ *
6
+ * A Seedance Lip Sync run (the Seedance 2 family on the Lip Sync node: one
7
+ * portrait plus the voice line as reference AUDIO, no reference video) renders
8
+ * a fixed {@link SEEDANCE_LIP_SYNC_SECONDS}-second clip. The provider bills it
9
+ * at the model's plain per-second rate — a reference video is what moves a
10
+ * Seedance run onto the `-ref` rate (input + output seconds), and this run has
11
+ * none — so it is priced on the plain row `<model>:8s:<resolution>`.
12
+ *
13
+ * The resolution is the one asked when the model renders it, else the model's
14
+ * top catalog tier (a 1080p asked of Seedance 2 Fast renders and bills 720p),
15
+ * and 720p when none is asked. Every catalog tier of every family member has a
16
+ * plain 8-second row. The worker sends this same resolution, so what renders is
17
+ * what was priced.
18
+ *
19
+ * MiniMax Hailuo 3 rides the same Lip Sync lane but is no Seedance model: it is
20
+ * priced and sent on its own rule (`minimax-h3:8s`), never here.
21
+ */
22
+ import { MODEL_CATALOG } from "./model-catalog.js"
23
+ import { SEEDANCE_LIP_SYNC_PROVIDERS, isMinimaxH3Provider, isSeedance2Provider } from "./model-constants.js"
24
+
25
+ /** The length, in seconds, a Seedance Lip Sync run renders and is priced at. */
26
+ export const SEEDANCE_LIP_SYNC_SECONDS = 8
27
+
28
+ /** The resolution a Seedance Lip Sync run uses when none is asked. */
29
+ const SEEDANCE_LIP_SYNC_DEFAULT_RESOLUTION = "720p"
30
+
31
+ /** Whether this Lip Sync model is a Seedance model priced by {@link seedanceLipSyncCreditId}. */
32
+ export function isSeedanceLipSyncProvider(provider: unknown): provider is string {
33
+ return typeof provider === "string" && SEEDANCE_LIP_SYNC_PROVIDERS.has(provider) && isSeedance2Provider(provider)
34
+ }
35
+
36
+ /** The resolution a Seedance Lip Sync run renders and is priced at (see the file comment). */
37
+ export function seedanceLipSyncResolution(provider: string, resolution?: unknown): string {
38
+ const supported = MODEL_CATALOG[provider]?.resolutions ?? []
39
+ const want = typeof resolution === "string" && resolution !== "" ? resolution : SEEDANCE_LIP_SYNC_DEFAULT_RESOLUTION
40
+ if (supported.includes(want)) return want
41
+ return supported[supported.length - 1] ?? SEEDANCE_LIP_SYNC_DEFAULT_RESOLUTION
42
+ }
43
+
44
+ /** The credit id a Seedance Lip Sync run is held and charged on: its plain 8-second row. */
45
+ export function seedanceLipSyncCreditId(provider: string, resolution?: unknown): string {
46
+ return `${provider}:${SEEDANCE_LIP_SYNC_SECONDS}s:${seedanceLipSyncResolution(provider, resolution)}`
47
+ }
48
+
49
+ /**
50
+ * MiniMax Hailuo 3 on Lip Sync: the same portrait-plus-voice-line run, held on
51
+ * its 8-second 2K row on every path (decided 2026-11-16). The Lip Sync
52
+ * resolution never names H3's own 768P tier, and KIE renders 2K when none is
53
+ * sent, so the row does not follow the resolution and nothing sent changes.
54
+ */
55
+ export const MINIMAX_H3_LIP_SYNC_CREDIT_ID = `minimax-h3:${SEEDANCE_LIP_SYNC_SECONDS}s`
56
+
57
+ /**
58
+ * The credit id a Lip Sync run on a multimodal video model (the Seedance 2
59
+ * family and MiniMax Hailuo 3: a portrait plus the voice line as reference
60
+ * audio) is held and charged on — the ONE rule the route, the workflow run,
61
+ * the film pipeline and both estimates read. Undefined for every other Lip
62
+ * Sync model.
63
+ */
64
+ export function referenceAudioLipSyncCreditId(provider: unknown, resolution?: unknown): string | undefined {
65
+ if (isSeedanceLipSyncProvider(provider)) return seedanceLipSyncCreditId(provider, resolution)
66
+ if (typeof provider === "string" && isMinimaxH3Provider(provider)) return MINIMAX_H3_LIP_SYNC_CREDIT_ID
67
+ return undefined
68
+ }
@@ -159,6 +159,57 @@ export type SunoSeparateResultField = (typeof SUNO_SEPARATE_RESULT_FIELDS)[numbe
159
159
  /** Non-URL fields a run's output records about how it ran. */
160
160
  export const SUNO_SEPARATE_META_FIELDS = ["separateType", "stemName", "engineUsed", "sunoRefused", "fallbackReason"] as const
161
161
 
162
+ /**
163
+ * The Suno ids a run's output carries for its stems: `sunoTaskId`, the
164
+ * separation task, and `sunoStemIds`, each stem's or take's own id by its
165
+ * result field (`{ vocalUrl: "<id>", … }`). Suno Convert to WAV takes a stem
166
+ * by the separation's task id and the stem's id. A run that Demucs or the
167
+ * connected cloud delivered has none, and neither has an output written before
168
+ * the ids were kept.
169
+ */
170
+ export const SUNO_SEPARATE_ID_FIELDS = ["sunoTaskId", "sunoStemIds"] as const
171
+
172
+ /** The result field behind a handle (old spellings included); the primary field for any other handle, or none. */
173
+ export function sunoSeparateHandleField(
174
+ output: Readonly<Record<string, unknown>>,
175
+ handle: string | null | undefined,
176
+ ): SunoSeparateResultField | undefined {
177
+ switch (handle) {
178
+ case "vocals":
179
+ case "vocal":
180
+ case "vocal-out":
181
+ return "vocalUrl"
182
+ case "instrumental":
183
+ case "instrumental-out":
184
+ return "instrumentalUrl"
185
+ case "isolated":
186
+ return "isolatedUrl"
187
+ case "without":
188
+ return "withoutUrl"
189
+ default: {
190
+ const primary = sunoSeparatePrimaryUrl(output)
191
+ return primary === undefined ? undefined : SUNO_SEPARATE_RESULT_FIELDS.find((field) => str(output[field]) === primary)
192
+ }
193
+ }
194
+ }
195
+
196
+ /**
197
+ * The Suno ids of the stem behind one handle — the separation's task id and
198
+ * that stem's own id — or undefined when the output does not carry both (a
199
+ * Demucs or cloud run, an older output, a stem that did not come back).
200
+ */
201
+ export function sunoSeparateHandleIds(
202
+ output: Readonly<Record<string, unknown>>,
203
+ handle: string | null | undefined,
204
+ ): { readonly taskId: string; readonly audioId: string } | undefined {
205
+ const taskId = str(output.sunoTaskId)
206
+ const ids = output.sunoStemIds
207
+ if (!taskId || typeof ids !== "object" || ids === null || Array.isArray(ids)) return undefined
208
+ const field = sunoSeparateHandleField(output, handle)
209
+ const audioId = field ? str((ids as Record<string, unknown>)[field]) : undefined
210
+ return audioId ? { taskId, audioId } : undefined
211
+ }
212
+
162
213
  function str(v: unknown): string | undefined {
163
214
  return typeof v === "string" && v !== "" ? v : undefined
164
215
  }
package/src/topics.ts ADDED
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Topics — the wire contract of topic tracking.
3
+ *
4
+ * A person follows a hashtag or phrase with no brand around it ("ai video")
5
+ * on the platforms they pick. Each scan searches the term on each platform,
6
+ * 20, 40 or 60 posts per search, keeps the posts that really name it, and
7
+ * produces cards about what is spreading. Scans are kept like a tracked
8
+ * brand's, and run on a schedule or on demand.
9
+ *
10
+ * Why public: these are the shapes `/v1/topics*` answers. How a card is
11
+ * decided is not part of the contract.
12
+ */
13
+ import type { ActionCard, CompetitorSchedule } from "./competitors.js"
14
+ import { COMPETITOR_SCAN_PAGE_CREDIT_ID } from "./competitors.js"
15
+ import type { SocialPlatform, SocialPost } from "./social-search.js"
16
+ import { SOCIAL_SEARCH_CREDITS_PER_PAGE, socialSearchEffectiveCount, socialSearchPages } from "./social-search.js"
17
+
18
+ /** Where a topic can be searched. */
19
+ export const TOPIC_PLATFORMS = ["tiktok", "instagram", "youtube", "x", "reddit", "linkedin"] as const
20
+ export type TopicPlatform = (typeof TOPIC_PLATFORMS)[number]
21
+ export const TOPIC_DEFAULT_PLATFORMS: readonly TopicPlatform[] = ["tiktok", "instagram", "youtube", "x"]
22
+
23
+ /** Posts each search of a topic reads: one, two or three Social Search pages. */
24
+ export const TOPIC_POST_COUNTS = [20, 40, 60] as const
25
+ export type TopicPostCount = (typeof TOPIC_POST_COUNTS)[number]
26
+
27
+ export const TOPIC_SCAN_NODE_TYPE = "topic-scan"
28
+ /** A topic scan is charged this id per Social Search page it runs, summed. */
29
+ export const TOPIC_SCAN_PAGE_CREDIT_ID = "topic-scan:per-page"
30
+ /** The most topics any person can follow (the platform's own ceiling; a plan allows fewer). */
31
+ export const TOPICS_MAX = 200
32
+
33
+ /** The per-page scan rates (a brand's and a topic's), at their base price: one Social Search page each. */
34
+ export const SCAN_PAGE_CREDIT_COSTS: Readonly<Record<string, number>> = {
35
+ [COMPETITOR_SCAN_PAGE_CREDIT_ID]: SOCIAL_SEARCH_CREDITS_PER_PAGE,
36
+ [TOPIC_SCAN_PAGE_CREDIT_ID]: SOCIAL_SEARCH_CREDITS_PER_PAGE,
37
+ }
38
+
39
+ export interface TrackedTopic {
40
+ readonly id: string
41
+ /** Its display name. */
42
+ readonly name: string
43
+ /** The hashtag or phrase it searches. */
44
+ readonly term: string
45
+ readonly platforms: readonly TopicPlatform[]
46
+ readonly postCount: TopicPostCount
47
+ readonly schedule: CompetitorSchedule
48
+ readonly nextScanAt: string | null
49
+ readonly lastScanAt: string | null
50
+ readonly lastScanId: string | null
51
+ /** Why the last scan (or scheduled start) fell short; null when it did not. */
52
+ readonly lastScanError: string | null
53
+ /** A scan is running now. */
54
+ readonly scanning: boolean
55
+ /** Social Search pages one scan runs: the scan costs this many pages. */
56
+ readonly pages: number
57
+ readonly createdAt: string
58
+ readonly updatedAt: string
59
+ }
60
+
61
+ /** What a plan allows a person on the Topics page. */
62
+ export interface TopicLimits {
63
+ /** Topics a person can follow; 0 = none; null = no cap. */
64
+ readonly topics: number | null
65
+ }
66
+
67
+ /** `GET /v1/topics`. */
68
+ export interface TopicListResult {
69
+ readonly data: readonly TrackedTopic[]
70
+ /** Your plan's caps. Absent when the plan could not be read just now: neither locked nor unlimited, only unknown. */
71
+ readonly limits?: TopicLimits
72
+ /** How many months of scans your plan keeps. Absent when the plan could not be read just now. */
73
+ readonly historyMonths?: number
74
+ }
75
+
76
+ export interface CreateTopicInput {
77
+ readonly name: string
78
+ /** The hashtag or phrase to search. Default: the name. */
79
+ readonly term?: string
80
+ /** Default: TikTok, Instagram, YouTube and X. */
81
+ readonly platforms?: readonly TopicPlatform[]
82
+ /** Default 20. */
83
+ readonly postCount?: TopicPostCount
84
+ /** Default weekly. */
85
+ readonly schedule?: CompetitorSchedule
86
+ }
87
+
88
+ export type UpdateTopicInput = Partial<CreateTopicInput>
89
+
90
+ export interface TopicScanCounts {
91
+ /** Posts the scan kept (the ones that name the term). */
92
+ readonly posts: number
93
+ readonly searches: number
94
+ readonly failedSearches: number
95
+ /** The platforms whose search returned. */
96
+ readonly okSearches?: readonly string[]
97
+ }
98
+
99
+ export interface TopicScan {
100
+ readonly id: string
101
+ readonly at: string
102
+ readonly counts: TopicScanCounts
103
+ readonly posts: readonly SocialPost[]
104
+ readonly cards: readonly ActionCard[]
105
+ }
106
+
107
+ export interface TopicScanSummary {
108
+ readonly id: string
109
+ readonly at: string
110
+ readonly counts: TopicScanCounts
111
+ readonly cards: number
112
+ }
113
+
114
+ /** `GET /v1/topics/:id`. */
115
+ export interface TopicDetail extends TrackedTopic {
116
+ readonly latestScan: TopicScan | null
117
+ /** Newest first, at most twelve. */
118
+ readonly scans: readonly TopicScanSummary[]
119
+ }
120
+
121
+ /** One platform as one scan found it. */
122
+ export interface TopicHistoryPlatform {
123
+ readonly platform: SocialPlatform
124
+ /** Posts kept there. */
125
+ readonly posts: number
126
+ /** Their summed reach (views, plays or points); null when the platform gives none. */
127
+ readonly reach: number | null
128
+ }
129
+
130
+ export interface TopicHistoryPoint {
131
+ readonly id: string
132
+ readonly at: string
133
+ readonly platforms: readonly TopicHistoryPlatform[]
134
+ }
135
+
136
+ /** `GET /v1/topics/:id/history`: the topic's scans, oldest first. */
137
+ export interface TopicHistory {
138
+ readonly scans: readonly TopicHistoryPoint[]
139
+ }
140
+
141
+ /** `GET /v1/topics/cards`: the cards of every topic's latest scan, most urgent first, and the posts they rest on. */
142
+ export interface TopicCardsResult {
143
+ readonly cards: readonly ActionCard[]
144
+ readonly posts: Readonly<Record<string, SocialPost>>
145
+ }
146
+
147
+ /** Social Search pages a topic scan runs: each platform's search at the topic's post count (some platforms read one page only). */
148
+ export function topicScanPages(t: { readonly platforms: readonly string[]; readonly postCount: number }): number {
149
+ return t.platforms
150
+ .filter((p): p is TopicPlatform => (TOPIC_PLATFORMS as readonly string[]).includes(p))
151
+ .reduce((sum, platform) => sum + socialSearchPages(socialSearchEffectiveCount(platform, "keyword", t.postCount)), 0)
152
+ }
153
+
154
+ /** The credits a topic scan of this many pages costs, before the live price table loads. */
155
+ export function topicScanCredits(pages: number): number {
156
+ return !Number.isFinite(pages) || pages <= 0 ? 0 : Math.round(pages) * SOCIAL_SEARCH_CREDITS_PER_PAGE
157
+ }
158
+
159
+ /** Whether a value is one of the topic platforms. */
160
+ export function isTopicPlatform(value: string): value is TopicPlatform {
161
+ return (TOPIC_PLATFORMS as readonly string[]).includes(value)
162
+ }
@@ -231,6 +231,13 @@ export function videoCharacterVoiceCap(provider: string | undefined): number {
231
231
  return provider ? (VIDEO_REF_LIMITS_BY_PROVIDER[provider]?.voices ?? 0) : 0
232
232
  }
233
233
 
234
+ /** Every provider that takes a pinned voice persona (a positive `voices` cap), in declaration order. */
235
+ function videoCharacterVoiceProviders(): string[] {
236
+ return Object.entries(VIDEO_REF_LIMITS_BY_PROVIDER)
237
+ .filter(([, l]) => (l?.voices ?? 0) > 0)
238
+ .map(([id]) => id)
239
+ }
240
+
234
241
  /**
235
242
  * Identity of a voice persona — what makes two voices "the same voice". The
236
243
  * persona is minted per (preset, description, example line) AND the character's
@@ -307,7 +314,7 @@ export function videoCharacterVoiceProblem(args: {
307
314
  code: "character_voice_unsupported",
308
315
  message:
309
316
  `A character voice is not supported by ${args.provider ?? "the selected model"}. ` +
310
- "Drop the voice, or pick a model that takes characterReferences.",
317
+ `Drop the voice, or pick a model that takes one: ${videoCharacterVoiceProviders().join(", ")}.`,
311
318
  }
312
319
  }
313
320
  if (distinct > cap) {
@@ -325,7 +332,8 @@ export function videoCharacterVoiceProblem(args: {
325
332
  *
326
333
  * The shared budget: for a model that declares `characters`, its `images` cap
327
334
  * IS the total input budget (images + 2×videos + character units ≤ images cap —
328
- * 7 for Gemini Omni). Callers pass the ASSEMBLED image count, after any
335
+ * 7 for Gemini Omni), unless it declares `charactersOutsideImageBudget`
336
+ * (Gemini Omni Flash 1.2: characters spend no unit). Callers pass the ASSEMBLED image count, after any
329
337
  * `connectedReferences` expansion, so the budget is measured on what ships.
330
338
  */
331
339
  export function videoCharacterRefProblem(args: {
@@ -387,13 +395,22 @@ export function videoCharacterRefProblem(args: {
387
395
  // the upstream would take it beside `character_ids`. We reject the pair
388
396
  // because the frame / identity roles are not yet bound in the prompt
389
397
  // (and the frame would need to be budgeted against the shared input quota).
398
+ // A model whose characters sit outside its image budget (Gemini Omni Flash
399
+ // 1.2): the platform does not combine characters with a start or end frame
400
+ // on it (decided 2026-11-17, mirroring 1.1). Its upstream refuses characters
401
+ // beside a real first/last frame, but would take a frame sent as a reference
402
+ // image beside references — so the sentence names no budget and no upstream
403
+ // rule, only what the platform does.
404
+ const outsideBudget = limits?.charactersOutsideImageBudget === true
390
405
  if (args.hasStartFrame) {
391
406
  return {
392
407
  code: "character_references_with_start_frame",
393
- message:
394
- `${provider} does not yet support combining characterReferences with a start frame (imageUrl) — ` +
395
- "the frame and the characters would compete for the same input slots without a defined role. " +
396
- "Drop the start frame (the character's portrait carries the face), or drop characterReferences.",
408
+ message: outsideBudget
409
+ ? `Nodaro does not combine characterReferences with a start frame (imageUrl) on ${provider}. ` +
410
+ "Drop the start frame (the character's portrait carries the face), or drop characterReferences."
411
+ : `${provider} does not yet support combining characterReferences with a start frame (imageUrl) — ` +
412
+ "the frame and the characters would compete for the same input slots without a defined role. " +
413
+ "Drop the start frame (the character's portrait carries the face), or drop characterReferences.",
397
414
  }
398
415
  }
399
416
  // Gemini Omni has no end-frame input; without this the frame would be dropped
@@ -406,6 +423,9 @@ export function videoCharacterRefProblem(args: {
406
423
  "Drop the end frame, or drop characterReferences.",
407
424
  }
408
425
  }
426
+ // Characters outside the image budget spend nothing from it: the image +
427
+ // video quota is the request builder's, as on a run with no characters.
428
+ if (outsideBudget) return videoCharacterVoiceProblem({ provider, characterReferences })
409
429
  const budget = VIDEO_REF_LIMITS_BY_PROVIDER[provider as string]?.images ?? 7
410
430
  const used = args.imageCount + args.videoCount * 2 + videoCharacterRefUnits(characterReferences)
411
431
  if (used > budget) {
@@ -2,7 +2,7 @@
2
2
  * Video Face Mesh (`POST /v1/video-face-mesh`, job type `video-face-mesh`):
3
3
  * thin GRAY face lines — a wireframe, and darker eye and lip outlines, each a
4
4
  * tone of the picture under it — drawn on the faces of a clip, frame for
5
- * frame. An internal step of Nodaro Motion's face masking: the lines go on
5
+ * frame. An internal step of Video Remake's face masking: the lines go on
6
6
  * the masked (or depth) clip so the video model still sees where the mouth
7
7
  * and the eyes are. A request may draw only the eye and lip outlines, only
8
8
  * the lip outline, or the face's contours (`parts`).