@nodaro/shared 3.64.0 → 3.65.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-PJJAZQVZ.js → chunk-222QM7CO.js} +3 -3
  2. package/dist/{chunk-PJJAZQVZ.js.map → chunk-222QM7CO.js.map} +1 -1
  3. package/dist/chunk-27HA6YOL.cjs +377 -0
  4. package/dist/chunk-27HA6YOL.cjs.map +1 -0
  5. package/dist/{chunk-TTGZ2L3O.js → chunk-2NKF476Z.js} +3 -3
  6. package/dist/{chunk-TTGZ2L3O.js.map → chunk-2NKF476Z.js.map} +1 -1
  7. package/dist/chunk-3AU52TSW.js +143 -0
  8. package/dist/chunk-3AU52TSW.js.map +1 -0
  9. package/dist/{chunk-7AJGUI7L.cjs → chunk-5NVGKXJV.cjs} +34 -17
  10. package/dist/chunk-5NVGKXJV.cjs.map +1 -0
  11. package/dist/{chunk-3AYM47GW.js → chunk-5SSMPYE5.js} +99 -9
  12. package/dist/chunk-5SSMPYE5.js.map +1 -0
  13. package/dist/{chunk-KHH54GRP.cjs → chunk-6ET3KDO4.cjs} +15 -338
  14. package/dist/chunk-6ET3KDO4.cjs.map +1 -0
  15. package/dist/{chunk-ACZZHHFZ.cjs → chunk-6OSIOVF7.cjs} +44 -22
  16. package/dist/chunk-6OSIOVF7.cjs.map +1 -0
  17. package/dist/{chunk-OBOOHG3N.js → chunk-6X5PBAC4.js} +3 -3
  18. package/dist/{chunk-OBOOHG3N.js.map → chunk-6X5PBAC4.js.map} +1 -1
  19. package/dist/chunk-7BN4EDIC.cjs +185 -0
  20. package/dist/chunk-7BN4EDIC.cjs.map +1 -0
  21. package/dist/{chunk-IYSOVS7O.js → chunk-7OWXHW7Z.js} +31 -13
  22. package/dist/chunk-7OWXHW7Z.js.map +1 -0
  23. package/dist/{chunk-ZI3QDUHO.js → chunk-AT53ZQUC.js} +3 -3
  24. package/dist/{chunk-ZI3QDUHO.js.map → chunk-AT53ZQUC.js.map} +1 -1
  25. package/dist/{chunk-SHH2T4CR.js → chunk-BSTAAGLY.js} +3 -3
  26. package/dist/{chunk-SHH2T4CR.js.map → chunk-BSTAAGLY.js.map} +1 -1
  27. package/dist/{chunk-DZ4IOP3Q.js → chunk-CW6MMQNO.js} +277 -3
  28. package/dist/chunk-CW6MMQNO.js.map +1 -0
  29. package/dist/{chunk-Q2Y4JHF7.js → chunk-D5Y3EYRM.js} +5 -5
  30. package/dist/{chunk-Q2Y4JHF7.js.map → chunk-D5Y3EYRM.js.map} +1 -1
  31. package/dist/{chunk-EXEVT6D2.cjs → chunk-DQ2PARNH.cjs} +5 -5
  32. package/dist/{chunk-EXEVT6D2.cjs.map → chunk-DQ2PARNH.cjs.map} +1 -1
  33. package/dist/{chunk-OOZW2MM6.cjs → chunk-E66HSC2E.cjs} +9 -9
  34. package/dist/{chunk-OOZW2MM6.cjs.map → chunk-E66HSC2E.cjs.map} +1 -1
  35. package/dist/{chunk-NIAFR5EE.js → chunk-FGBGKBML.js} +32 -3
  36. package/dist/chunk-FGBGKBML.js.map +1 -0
  37. package/dist/{chunk-5OBTGNUQ.cjs → chunk-FI3HJZWM.cjs} +294 -2
  38. package/dist/chunk-FI3HJZWM.cjs.map +1 -0
  39. package/dist/{chunk-SPAHI7DY.cjs → chunk-FJZTQTF4.cjs} +4 -4
  40. package/dist/{chunk-SPAHI7DY.cjs.map → chunk-FJZTQTF4.cjs.map} +1 -1
  41. package/dist/{chunk-J6B7J73J.cjs → chunk-GJ3D5X4X.cjs} +49 -49
  42. package/dist/{chunk-J6B7J73J.cjs.map → chunk-GJ3D5X4X.cjs.map} +1 -1
  43. package/dist/{chunk-KB2SQAR3.js → chunk-H745DQ6V.js} +3 -3
  44. package/dist/{chunk-KB2SQAR3.js.map → chunk-H745DQ6V.js.map} +1 -1
  45. package/dist/{chunk-7KQ6W5DS.js → chunk-HAH2F7LT.js} +4 -4
  46. package/dist/{chunk-7KQ6W5DS.js.map → chunk-HAH2F7LT.js.map} +1 -1
  47. package/dist/{chunk-HDPJNNMF.cjs → chunk-JQMFJAYU.cjs} +21 -21
  48. package/dist/{chunk-HDPJNNMF.cjs.map → chunk-JQMFJAYU.cjs.map} +1 -1
  49. package/dist/{chunk-D4KWNDPH.cjs → chunk-JYU5EIRM.cjs} +12 -12
  50. package/dist/{chunk-D4KWNDPH.cjs.map → chunk-JYU5EIRM.cjs.map} +1 -1
  51. package/dist/{chunk-AZNZ5WNZ.cjs → chunk-K6RIN3LW.cjs} +142 -45
  52. package/dist/chunk-K6RIN3LW.cjs.map +1 -0
  53. package/dist/{chunk-YQV53HRR.cjs → chunk-KTCEKGBJ.cjs} +7 -7
  54. package/dist/{chunk-YQV53HRR.cjs.map → chunk-KTCEKGBJ.cjs.map} +1 -1
  55. package/dist/{chunk-W6VJAUGM.cjs → chunk-KWYS4IIM.cjs} +83 -37
  56. package/dist/chunk-KWYS4IIM.cjs.map +1 -0
  57. package/dist/{chunk-GTWUS6MQ.cjs → chunk-MIT2USTS.cjs} +61 -61
  58. package/dist/{chunk-GTWUS6MQ.cjs.map → chunk-MIT2USTS.cjs.map} +1 -1
  59. package/dist/{chunk-Y4GCJJPF.cjs → chunk-NYZQOIXJ.cjs} +35 -2
  60. package/dist/chunk-NYZQOIXJ.cjs.map +1 -0
  61. package/dist/{chunk-FHGRKQVZ.cjs → chunk-PGDR7CO3.cjs} +8 -8
  62. package/dist/{chunk-FHGRKQVZ.cjs.map → chunk-PGDR7CO3.cjs.map} +1 -1
  63. package/dist/{chunk-W7KHHNZR.js → chunk-PL7AQQV7.js} +53 -9
  64. package/dist/chunk-PL7AQQV7.js.map +1 -0
  65. package/dist/chunk-Q4YOLT4M.js +164 -0
  66. package/dist/chunk-Q4YOLT4M.js.map +1 -0
  67. package/dist/{chunk-CHS2SIP6.cjs → chunk-R5ILCNCC.cjs} +90 -76
  68. package/dist/chunk-R5ILCNCC.cjs.map +1 -0
  69. package/dist/chunk-RP4KQUNU.cjs +168 -0
  70. package/dist/chunk-RP4KQUNU.cjs.map +1 -0
  71. package/dist/{chunk-CHTZZRAL.cjs → chunk-SPU7MUWE.cjs} +6 -6
  72. package/dist/{chunk-CHTZZRAL.cjs.map → chunk-SPU7MUWE.cjs.map} +1 -1
  73. package/dist/{chunk-VPTA4Z7G.js → chunk-ST7OBB5J.js} +5 -5
  74. package/dist/{chunk-VPTA4Z7G.js.map → chunk-ST7OBB5J.js.map} +1 -1
  75. package/dist/{chunk-TPQJKS7D.js → chunk-V5NLQ4L5.js} +21 -7
  76. package/dist/{chunk-CHS2SIP6.cjs.map → chunk-V5NLQ4L5.js.map} +1 -1
  77. package/dist/{chunk-QYU7J5EQ.js → chunk-V6OXSXIX.js} +29 -18
  78. package/dist/chunk-V6OXSXIX.js.map +1 -0
  79. package/dist/{chunk-T2OVDF2M.cjs → chunk-WQMPIURW.cjs} +6 -6
  80. package/dist/{chunk-T2OVDF2M.cjs.map → chunk-WQMPIURW.cjs.map} +1 -1
  81. package/dist/{chunk-67CMMTLN.cjs → chunk-WZG6GZIL.cjs} +4 -4
  82. package/dist/{chunk-67CMMTLN.cjs.map → chunk-WZG6GZIL.cjs.map} +1 -1
  83. package/dist/{chunk-36VWLB4J.js → chunk-XJANKTIL.js} +3 -3
  84. package/dist/{chunk-36VWLB4J.js.map → chunk-XJANKTIL.js.map} +1 -1
  85. package/dist/{chunk-O7RZRUMZ.js → chunk-XJWED257.js} +14 -309
  86. package/dist/chunk-XJWED257.js.map +1 -0
  87. package/dist/chunk-XSSLNINL.js +346 -0
  88. package/dist/chunk-XSSLNINL.js.map +1 -0
  89. package/dist/{chunk-O4RPXBDZ.cjs → chunk-YD4XY74W.cjs} +8 -8
  90. package/dist/{chunk-O4RPXBDZ.cjs.map → chunk-YD4XY74W.cjs.map} +1 -1
  91. package/dist/{chunk-SXHHLZ22.js → chunk-YMZUE2IX.js} +9 -9
  92. package/dist/{chunk-SXHHLZ22.js.map → chunk-YMZUE2IX.js.map} +1 -1
  93. package/dist/{chunk-4IUE2JB7.js → chunk-Z77M7Q2R.js} +3 -3
  94. package/dist/{chunk-4IUE2JB7.js.map → chunk-Z77M7Q2R.js.map} +1 -1
  95. package/dist/{chunk-3KTWYYCN.js → chunk-ZSRXY5YT.js} +3 -3
  96. package/dist/{chunk-3KTWYYCN.js.map → chunk-ZSRXY5YT.js.map} +1 -1
  97. package/dist/entries/apps.cjs +42 -42
  98. package/dist/entries/apps.js +7 -7
  99. package/dist/entries/captions.d.cts +1 -1
  100. package/dist/entries/captions.d.ts +1 -1
  101. package/dist/entries/credits.cjs +230 -214
  102. package/dist/entries/credits.d.cts +51 -14
  103. package/dist/entries/credits.d.ts +51 -14
  104. package/dist/entries/credits.js +10 -10
  105. package/dist/entries/entities.cjs +202 -193
  106. package/dist/entries/entities.d.cts +44 -9
  107. package/dist/entries/entities.d.ts +44 -9
  108. package/dist/entries/entities.js +2 -1
  109. package/dist/entries/llm-models.cjs +86 -62
  110. package/dist/entries/llm-models.d.cts +46 -15
  111. package/dist/entries/llm-models.d.ts +46 -15
  112. package/dist/entries/llm-models.js +2 -2
  113. package/dist/entries/media.cjs +79 -63
  114. package/dist/entries/media.d.cts +154 -1
  115. package/dist/entries/media.d.ts +154 -1
  116. package/dist/entries/media.js +1 -1
  117. package/dist/entries/model-catalog.cjs +175 -119
  118. package/dist/entries/model-catalog.d.cts +4 -54
  119. package/dist/entries/model-catalog.d.ts +4 -54
  120. package/dist/entries/model-catalog.js +4 -4
  121. package/dist/entries/models.cjs +491 -358
  122. package/dist/entries/models.d.cts +86 -7
  123. package/dist/entries/models.d.ts +86 -7
  124. package/dist/entries/models.js +6 -5
  125. package/dist/entries/nodes.cjs +212 -212
  126. package/dist/entries/nodes.d.cts +1 -1
  127. package/dist/entries/nodes.d.ts +1 -1
  128. package/dist/entries/nodes.js +8 -8
  129. package/dist/entries/pipeline.cjs +153 -153
  130. package/dist/entries/pipeline.d.cts +3 -3
  131. package/dist/entries/pipeline.d.ts +3 -3
  132. package/dist/entries/pipeline.js +3 -3
  133. package/dist/entries/social.cjs +177 -177
  134. package/dist/entries/social.js +2 -2
  135. package/dist/entries/ugc.cjs +71 -71
  136. package/dist/entries/ugc.js +4 -4
  137. package/dist/entries/video.cjs +174 -145
  138. package/dist/entries/video.d.cts +114 -2
  139. package/dist/entries/video.d.ts +114 -2
  140. package/dist/entries/video.js +7 -6
  141. package/dist/entries/workflow.d.cts +1 -1
  142. package/dist/entries/workflow.d.ts +1 -1
  143. package/dist/index.cjs +2074 -1793
  144. package/dist/index.d.cts +10 -9
  145. package/dist/index.d.ts +10 -9
  146. package/dist/index.js +24 -23
  147. package/dist/{model-catalog-Cf9fkEUp.d.ts → model-catalog-BoUKGFNl.d.cts} +167 -1
  148. package/dist/{model-catalog-Cf9fkEUp.d.cts → model-catalog-BoUKGFNl.d.ts} +167 -1
  149. package/dist/{model-constants-BxjiWVQ9.d.ts → model-constants-BElS3AeE.d.ts} +55 -6
  150. package/dist/{model-constants-C_Nyft_i.d.cts → model-constants-CpQz1bGa.d.cts} +55 -6
  151. package/dist/tts-capabilities-BtnDWK9K.d.ts +133 -0
  152. package/dist/tts-capabilities-C52UccTI.d.cts +133 -0
  153. package/package.json +1 -1
  154. package/src/__tests__/dialogue-capabilities.test.ts +167 -6
  155. package/src/__tests__/extend-providers.test.ts +87 -0
  156. package/src/__tests__/kling4-catalog.test.ts +1 -1
  157. package/src/__tests__/llm-models.test.ts +41 -4
  158. package/src/__tests__/speech-pricing.test.ts +62 -1
  159. package/src/__tests__/tts-capabilities.test.ts +160 -4
  160. package/src/__tests__/video-analysis-pricing.test.ts +13 -1
  161. package/src/__tests__/video-subjects.test.ts +192 -0
  162. package/src/__tests__/wired-character-names.test.ts +142 -0
  163. package/src/credit-estimators/index.ts +4 -0
  164. package/src/credit-estimators/speech.ts +57 -9
  165. package/src/credit-identifiers.ts +48 -13
  166. package/src/dialogue-capabilities.ts +220 -3
  167. package/src/dubbing-structure.ts +186 -0
  168. package/src/entries/entities.ts +2 -0
  169. package/src/entries/llm-models.ts +7 -0
  170. package/src/entries/media.ts +3 -1
  171. package/src/entries/model-catalog.ts +17 -0
  172. package/src/entries/models.ts +39 -0
  173. package/src/entries/video.ts +8 -1
  174. package/src/gemini-tts.ts +144 -0
  175. package/src/llm-models.ts +71 -21
  176. package/src/model-catalog.ts +259 -0
  177. package/src/model-constants.ts +101 -8
  178. package/src/tts-capabilities.ts +193 -1
  179. package/src/video-analysis-pricing.ts +11 -0
  180. package/src/video-character-refs.ts +160 -3
  181. package/src/wired-character-names.ts +134 -18
  182. package/src/wired-character-video-subjects.ts +63 -0
  183. package/dist/chunk-3AYM47GW.js.map +0 -1
  184. package/dist/chunk-5OBTGNUQ.cjs.map +0 -1
  185. package/dist/chunk-6YIV37V7.js +0 -31
  186. package/dist/chunk-6YIV37V7.js.map +0 -1
  187. package/dist/chunk-7AJGUI7L.cjs.map +0 -1
  188. package/dist/chunk-ACZZHHFZ.cjs.map +0 -1
  189. package/dist/chunk-AZNZ5WNZ.cjs.map +0 -1
  190. package/dist/chunk-DZ4IOP3Q.js.map +0 -1
  191. package/dist/chunk-IYSOVS7O.js.map +0 -1
  192. package/dist/chunk-KHH54GRP.cjs.map +0 -1
  193. package/dist/chunk-NIAFR5EE.js.map +0 -1
  194. package/dist/chunk-O7RZRUMZ.js.map +0 -1
  195. package/dist/chunk-QYU7J5EQ.js.map +0 -1
  196. package/dist/chunk-S3UGLZSF.js +0 -42
  197. package/dist/chunk-S3UGLZSF.js.map +0 -1
  198. package/dist/chunk-TPQJKS7D.js.map +0 -1
  199. package/dist/chunk-TQW3R44P.cjs +0 -38
  200. package/dist/chunk-TQW3R44P.cjs.map +0 -1
  201. package/dist/chunk-VZ6TE23U.cjs +0 -54
  202. package/dist/chunk-VZ6TE23U.cjs.map +0 -1
  203. package/dist/chunk-W6VJAUGM.cjs.map +0 -1
  204. package/dist/chunk-W7KHHNZR.js.map +0 -1
  205. package/dist/chunk-Y4GCJJPF.cjs.map +0 -1
@@ -18,6 +18,14 @@
18
18
  * whole number of units times a charged unit price never under-quotes the
19
19
  * charge (the same property the per-second video rows rely on).
20
20
  *
21
+ * A model whose rate is below one credit per 100 characters (a row holds
22
+ * whole credits) quotes its row per 1,000 instead — `<model>:per-1k-chars`,
23
+ * its sheet's `ratePer1kChars` (decided 2026-11-12). The count is the same
24
+ * (started 100s, at least 8), and a request costs its hundreds × the row ÷ 10,
25
+ * rounded up once (`speechRowCredits`). Its request quote keeps the one id
26
+ * shape, `<model>:per-100-chars:<N>u`, N in started hundreds, so a client
27
+ * that builds that id quotes every model alike.
28
+ *
21
29
  * Decided 2026-10-06. Every name here is a published contract.
22
30
  */
23
31
  import { canonicalTtsProvider, findTtsCapabilities } from "../tts-capabilities.js"
@@ -33,13 +41,39 @@ export const SPEECH_FLOOR_UNITS = 8
33
41
  /** Appended to a speech model's id to name its per-unit price row. */
34
42
  export const SPEECH_UNIT_CREDIT_SUFFIX = ":per-100-chars"
35
43
 
44
+ /** Appended to a speech model's id to name its rate row quoted per 1,000 characters (`TtsCapabilities.ratePer1kChars`). */
45
+ export const SPEECH_PER_1K_CREDIT_SUFFIX = ":per-1k-chars"
46
+
36
47
  /**
37
- * The price-row id of one unit for the model a request runs as. The legacy
48
+ * How many units (started 100 characters) one rate row of the model prices:
49
+ * 10 for a model whose row is quoted per 1,000 characters, else 1. The
50
+ * legacy alias resolved; an id with no speech sheet is 1.
51
+ */
52
+ export function speechRowUnits(modelId: string): 1 | 10 {
53
+ const id = canonicalTtsProvider(modelId)
54
+ return (findTtsCapabilities(id) ?? findDialogueCapabilities(id))?.ratePer1kChars ? 10 : 1
55
+ }
56
+
57
+ /**
58
+ * The price-row id of the rate the model a request runs as is charged at:
59
+ * `<model>:per-100-chars` (one unit), or `<model>:per-1k-chars` for a model
60
+ * quoted per 1,000 characters ({@link speechRowUnits}). The legacy
38
61
  * `elevenlabs` alias prices on turbo's row, as it runs on turbo; any other id
39
62
  * (including the dialogue model) is used as given.
40
63
  */
41
64
  export function speechUnitCreditId(modelId: string): string {
42
- return `${canonicalTtsProvider(modelId)}${SPEECH_UNIT_CREDIT_SUFFIX}`
65
+ const id = canonicalTtsProvider(modelId)
66
+ return `${id}${speechRowUnits(id) === 10 ? SPEECH_PER_1K_CREDIT_SUFFIX : SPEECH_UNIT_CREDIT_SUFFIX}`
67
+ }
68
+
69
+ /**
70
+ * Base credits of `units` (started hundreds) at a rate row of `rowCredits`
71
+ * that prices `rowUnits` units: `ceil(units × row ÷ rowUnits)`, in whole
72
+ * numbers so it never rounds a hair high. With `rowUnits` 1 it is exactly
73
+ * units × the row (every per-100 row is a whole number).
74
+ */
75
+ export function speechRowCredits(units: number, rowCredits: number, rowUnits: number = 1): number {
76
+ return rowUnits === 1 ? units * rowCredits : Math.ceil((units * rowCredits) / rowUnits)
43
77
  }
44
78
 
45
79
  /**
@@ -57,6 +91,16 @@ export function speechCredits(chars: number, perUnitCredits: number): number {
57
91
  return speechPriceUnits(chars) * perUnitCredits
58
92
  }
59
93
 
94
+ /**
95
+ * Base credits for `chars` characters on `modelId` at its rate row
96
+ * (`speechUnitCreditId(modelId)`, read as `rowCredits`): per-100 or per-1K,
97
+ * whichever the model is quoted in. What every seam that reserves speech, and
98
+ * every client that quotes it, computes.
99
+ */
100
+ export function speechCreditsFor(modelId: string, chars: number, rowCredits: number): number {
101
+ return speechRowCredits(speechPriceUnits(chars), rowCredits, speechRowUnits(modelId))
102
+ }
103
+
60
104
  /**
61
105
  * The id of the exact charge of a whole request of `units` units on `modelId`:
62
106
  * `<model>:per-100-chars:<N>u`. Never a row of its own — a price lookup prices
@@ -65,17 +109,20 @@ export function speechCredits(chars: number, perUnitCredits: number): number {
65
109
  * row it is priced from.
66
110
  */
67
111
  export function speechQuoteCreditId(modelId: string, units: number): string {
68
- return unitQuoteCreditId(speechUnitCreditId(modelId), units)
112
+ // Always the per-100 shape, whatever the model's rate row: N is started hundreds.
113
+ return unitQuoteCreditId(`${canonicalTtsProvider(modelId)}${SPEECH_UNIT_CREDIT_SUFFIX}`, units)
69
114
  }
70
115
 
71
116
  /** A `<model>:per-100-chars:<N>u` id, read back. */
72
117
  export interface SpeechQuoteCreditIdParts {
73
118
  /** The speech model (canonical id) the request runs as. */
74
119
  model: string
75
- /** Its `<model>:per-100-chars` unit row. */
120
+ /** Its rate row: `<model>:per-100-chars`, or `<model>:per-1k-chars` for a model quoted per 1,000. */
76
121
  unitId: string
77
122
  /** Units priced: at least the floor, at most the model's per-request cap in started hundreds. */
78
123
  units: number
124
+ /** How many units one `unitId` row prices (10 for a per-1,000 row, else 1): the request is `speechRowCredits(units, row, rowUnits)`. */
125
+ rowUnits: 1 | 10
79
126
  }
80
127
 
81
128
  const SPEECH_QUOTE_ID = /^(.+):per-100-chars:(\d{1,6})u$/
@@ -96,16 +143,17 @@ export function parseSpeechQuoteCreditId(id: string): SpeechQuoteCreditIdParts |
96
143
  if (!caps) return undefined
97
144
  const units = Number(m[2])
98
145
  if (!Number.isInteger(units) || units < SPEECH_FLOOR_UNITS || units > speechPriceUnits(caps.maxChars)) return undefined
99
- return { model, unitId: speechUnitCreditId(model), units }
146
+ return { model, unitId: speechUnitCreditId(model), units, rowUnits: speechRowUnits(model) }
100
147
  }
101
148
 
102
149
  /**
103
150
  * Whether an id is a length price of speech — a `<model>:per-100-chars` unit
104
- * row or a `<model>:per-100-chars:<N>u` request quote — by its shape alone.
105
- * Both are served only while the server prices speech by length.
151
+ * row, a `<model>:per-1k-chars` rate row or a `<model>:per-100-chars:<N>u`
152
+ * request quote — by its shape alone. All are served only while the server
153
+ * prices speech by length.
106
154
  */
107
155
  export function isSpeechLengthPriceId(id: string): boolean {
108
- return typeof id === "string" && /:per-100-chars(?::\d+u)?$/.test(id)
156
+ return typeof id === "string" && /(?::per-100-chars(?::\d+u)?|:per-1k-chars)$/.test(id)
109
157
  }
110
158
 
111
159
  /**
@@ -115,5 +163,5 @@ export function isSpeechLengthPriceId(id: string): boolean {
115
163
  */
116
164
  export function speechLengthPriceModel(id: string): string | undefined {
117
165
  if (!isSpeechLengthPriceId(id)) return undefined
118
- return id.replace(/:per-100-chars(?::\d+u)?$/, "")
166
+ return id.replace(/(?::per-100-chars(?::\d+u)?|:per-1k-chars)$/, "")
119
167
  }
@@ -1009,19 +1009,56 @@ export function grokExtendCreditId(duration?: unknown, sourceResolution?: unknow
1009
1009
  /** The video node types whose run Grok Extend can extend, set to a Grok Imagine model. */
1010
1010
  const GROK_EXTEND_SOURCE_NODE_TYPES: ReadonlySet<string> = new Set(["generate-video", "text-to-video", "image-to-video"])
1011
1011
 
1012
+ /**
1013
+ * The resolution a Grok Extend is quoted at from the clip a Grok Imagine node
1014
+ * already made — the clip the run extends: the take its task (`kieTaskId`, the
1015
+ * task the node hands on) names. The charge reads the resolution the source's
1016
+ * JOB recorded (`input_data.resolution`; with none, the KIE config's pin, else
1017
+ * Grok's own 480p default — `sourceResolution` in grok-extend-source.ts), and
1018
+ * every lane that lands a take records that value on the result row beside
1019
+ * the task (`recordedResolution`), so the quote reads the same fact: `480p`
1020
+ * (any case) → `480p`; anything else, or none → `720p`, never below the charge
1021
+ * — a take with no recorded value may have been charged at a pinned 720p. Also
1022
+ * `720p` when no result names the node's task (a result landed before results
1023
+ * recorded it, or the take was deleted while the node kept its task).
1024
+ * Undefined when the node holds neither a task nor a result (it has not run).
1025
+ */
1026
+ function grokMadeClipResolution(data: Record<string, unknown>): GrokExtendSourceResolution | undefined {
1027
+ const rows = (Array.isArray(data.generatedResults) ? (data.generatedResults as ReadonlyArray<unknown>) : []).filter(
1028
+ (r): r is Record<string, unknown> =>
1029
+ typeof r === "object" && r !== null && typeof (r as { url?: unknown }).url === "string" && (r as { url: string }).url.trim() !== "",
1030
+ )
1031
+ const task = typeof data.kieTaskId === "string" && data.kieTaskId.trim() !== "" ? data.kieTaskId.trim() : undefined
1032
+ if (task === undefined && rows.length === 0) return undefined
1033
+ const named = task !== undefined ? rows.find((r) => typeof r.kieTaskId === "string" && r.kieTaskId.trim() === task) : undefined
1034
+ const recorded = typeof named?.recordedResolution === "string" ? named.recordedResolution.trim().toLowerCase() : undefined
1035
+ return recorded === "480p" ? "480p" : "720p"
1036
+ }
1037
+
1012
1038
  /**
1013
1039
  * The source resolution a Grok Extend node is QUOTED at (its estimate, its
1014
- * editor price), read off the node wired into its `video` input: `480p` only
1015
- * when that node surely renders at 480p — a Grok Imagine video node (text- or
1016
- * image-to-video) set to 480p, which every mode sends as set — and `720p`, the
1017
- * dearer row, for anything else: nothing wired, another model, a Grok node with
1018
- * no resolution set (Grok may render it at either). The run is held and
1019
- * charged at the source's own row, read off its job.
1040
+ * editor price), read off the node wired into its `video` input — `480p` only
1041
+ * when the clip the extension continues is surely 480p; `720p`, the dearer
1042
+ * row, for anything else (nothing wired, another model, a clip whose
1043
+ * resolution is not known):
1044
+ *
1045
+ * - a Grok Imagine video node (text- or image-to-video) that already made a
1046
+ * clip and does not make a new one in the quoted run: THAT clip's
1047
+ * resolution ({@link grokMadeClipResolution}) — the run extends it, whatever
1048
+ * the node is set to now;
1049
+ * - one that has not run yet, or runs again in the quoted run (it is in
1050
+ * `rerunIds` and not frozen): its setting — `480p` when set so, which every
1051
+ * mode sends as set; unset, Grok may render it at either.
1052
+ *
1053
+ * `rerunIds`: the nodes the quoted run executes — empty for one node's own
1054
+ * price (its pill, its Run button), where nothing upstream runs again. The
1055
+ * run is held and charged at the source's own row, read off its job.
1020
1056
  */
1021
1057
  export function grokExtendWiredSourceResolution(
1022
1058
  nodeId: string | undefined,
1023
1059
  nodes: ReadonlyArray<{ readonly id?: string; readonly type?: string; readonly data?: unknown }>,
1024
1060
  edges: ReadonlyArray<{ readonly source?: string; readonly target?: string; readonly targetHandle?: string | null }> | undefined,
1061
+ rerunIds: ReadonlySet<string> = new Set(),
1025
1062
  ): GrokExtendSourceResolution {
1026
1063
  if (nodeId === undefined || !edges) return "720p"
1027
1064
  const sources = edges
@@ -1030,13 +1067,11 @@ export function grokExtendWiredSourceResolution(
1030
1067
  if (sources.length === 0) return "720p"
1031
1068
  const surely480p = sources.every((n) => {
1032
1069
  const data = (n?.data ?? {}) as Record<string, unknown>
1033
- return (
1034
- n?.type !== undefined &&
1035
- GROK_EXTEND_SOURCE_NODE_TYPES.has(n.type) &&
1036
- isGrokExtendSourceModel(data.provider) &&
1037
- typeof data.resolution === "string" &&
1038
- data.resolution.trim().toLowerCase() === "480p"
1039
- )
1070
+ if (n?.type === undefined || !GROK_EXTEND_SOURCE_NODE_TYPES.has(n.type) || !isGrokExtendSourceModel(data.provider)) return false
1071
+ const runsAgain = n.id !== undefined && rerunIds.has(n.id) && data.skipped !== true
1072
+ const made = runsAgain ? undefined : grokMadeClipResolution(data)
1073
+ if (made !== undefined) return made === "480p"
1074
+ return typeof data.resolution === "string" && data.resolution.trim().toLowerCase() === "480p"
1040
1075
  })
1041
1076
  return surely480p ? "480p" : "720p"
1042
1077
  }
@@ -4,13 +4,15 @@
4
4
  *
5
5
  * The dialogue models carry a `tts` sheet in `MODEL_CATALOG` like the
6
6
  * text-to-speech models, but each lane answers only for its own models: the
7
- * text-to-speech lookups (`tts-capabilities.ts`) treat a dialogue id as unknown,
8
- * and these treat a text-to-speech id as unknown. An unknown id here runs as
7
+ * text-to-speech lookups (`tts-capabilities.ts`) treat a dialogue-only id as
8
+ * unknown, and these treat a text-to-speech-only id as unknown (a model in both
9
+ * lanes — Gemini — has one sheet, read by either). An unknown id here runs as
9
10
  * {@link DEFAULT_DIALOGUE_PROVIDER} (v3 dialogue) — not as the text-to-speech
10
11
  * fallback (turbo), which has no dialogue form.
11
12
  */
12
13
  import { MODEL_CATALOG, type TtsCapabilities, type TtsSettingLever } from "./model-catalog.js"
13
- import { DEFAULT_DIALOGUE_PROVIDER, type DialogueProvider } from "./model-constants.js"
14
+ import { DEFAULT_DIALOGUE_PROVIDER, DEFAULT_TTS_OUTPUT_FORMAT, TTS_OUTPUT_FORMATS, type DialogueProvider, type TtsOutputFormat } from "./model-constants.js"
15
+ import { replicaOf, ttsDirectionFor, ttsDirectionProblem, ttsReplicaProblem, ttsTakesReplica, ttsVoiceForModel, type TtsDirectionValues } from "./tts-capabilities.js"
14
16
 
15
17
  /** The sheet of a dialogue model, or `undefined` when the id is not one. Own properties only; a non-string is unknown. */
16
18
  export function findDialogueCapabilities(provider: unknown): TtsCapabilities | undefined {
@@ -46,3 +48,218 @@ export function dialogueStabilityAccepted(provider: unknown, value: number): boo
46
48
  const steps = getDialogueCapabilities(provider).stabilitySteps
47
49
  return steps ? steps.includes(value) : true
48
50
  }
51
+
52
+ /** The ElevenLabs dialogue lane's own limit on distinct voices in one script (probed 2026-08-30: an 11th → 400). */
53
+ export const ELEVENLABS_DIALOGUE_MAX_VOICES = 10
54
+
55
+ /** The most speakers (distinct voices) one script on the dialogue model may have: its sheet's, else the ElevenLabs limit. */
56
+ export function dialogueMaxSpeakers(provider: unknown): number {
57
+ return getDialogueCapabilities(provider).dialogueSpeakers ?? ELEVENLABS_DIALOGUE_MAX_VOICES
58
+ }
59
+
60
+ /** The dialogue model adds filler words between two speakers on request (`TtsCapabilities.fillerWords`). */
61
+ export function dialogueTakesFillerWords(provider: unknown): boolean {
62
+ return getDialogueCapabilities(provider).fillerWords === true
63
+ }
64
+
65
+ /**
66
+ * Each line's voice on the dialogue model, when the model and the voices may
67
+ * have been chosen apart (a published app's Model card, a field mapping, the
68
+ * editor's model switch): the text-to-speech lane's `ttsVoiceForModel` rule,
69
+ * per speaker. A voice the model speaks stays. On a model with named voices
70
+ * (Gemini) every other voice moves onto one of its voices that the script does
71
+ * not use yet, its default first — so two speakers are never merged into one
72
+ * voice by the move. On an ElevenLabs model a voice only a named-voice model
73
+ * speaks becomes "" (the deployment's default voice). Returns the voices in
74
+ * line order.
75
+ */
76
+ export function dialogueVoicesForModel(provider: unknown, voices: readonly unknown[], speakers?: unknown): string[] {
77
+ const sheet = getDialogueCapabilities(provider)
78
+ const id = dialogueProviderOf(provider)
79
+ const named = sheet.voices
80
+ if (!named) return voices.map((v) => ttsVoiceForModel(id, v) ?? "")
81
+ // A speaker cloned for this request (`replica`) is the model's own voice too, on a model that clones;
82
+ // on any other model it is a foreign voice and moves (decided 2026-11-13: one rule, `dialogueReplicaVoices`).
83
+ const clones = dialogueReplicaVoices(id, speakers)
84
+ const own = (v: unknown): v is string => typeof v === "string" && (named.some((n) => n.id === v) || clones.has(v))
85
+ const used = new Set(voices.filter(own))
86
+ const pool = [sheet.defaultVoice, ...named.map((n) => n.id)].filter((v): v is string => typeof v === "string")
87
+ const moved = new Map<string, string>()
88
+ return voices.map((v) => {
89
+ if (own(v)) return v
90
+ const key = typeof v === "string" ? v : ""
91
+ const kept = moved.get(key)
92
+ if (kept !== undefined) return kept
93
+ const next = pool.find((p) => !used.has(p)) ?? sheet.defaultVoice ?? named[0]!.id
94
+ used.add(next)
95
+ moved.set(key, next)
96
+ return next
97
+ })
98
+ }
99
+
100
+ /**
101
+ * The most characters of the free-text style ONE LINE takes on the dialogue
102
+ * model (Gemini 3.8: `direction.styleMaxChars`, a style per turn), or
103
+ * undefined on a model whose style is a speaker's choice (3.1 / 2.5) or that
104
+ * takes none (ElevenLabs).
105
+ */
106
+ export function dialogueLineStyleMaxChars(provider: unknown): number | undefined {
107
+ const d = getDialogueCapabilities(provider).direction
108
+ return d && d.styles === undefined ? d.styleMaxChars : undefined
109
+ }
110
+
111
+ /** A line's style as the dialogue model is sent it: trimmed, when the model takes one per line and it fits; else undefined. */
112
+ export function dialogueLineStyleFor(provider: unknown, value: unknown): string | undefined {
113
+ const max = dialogueLineStyleMaxChars(provider)
114
+ if (max === undefined || typeof value !== "string") return undefined
115
+ const trimmed = value.trim()
116
+ return trimmed && trimmed.length <= max ? trimmed : undefined
117
+ }
118
+
119
+ /** Whether the dialogue model takes direction per SPEAKER (Gemini 3.1 / 2.5: a style, pace, accent and audio profile per voice). */
120
+ export function dialogueTakesSpeakerDirection(provider: unknown): boolean {
121
+ const d = getDialogueCapabilities(provider).direction
122
+ return d !== undefined && (d.styles !== undefined || d.paces !== undefined || d.accents !== undefined || d.audioProfileMaxChars !== undefined)
123
+ }
124
+
125
+ /** One speaker's direction as the dialogue model is sent it (`ttsDirectionFor`), or {} on a model that takes none per speaker. */
126
+ export function dialogueSpeakerDirectionFor(provider: unknown, values: Readonly<Record<string, unknown>>): TtsDirectionValues {
127
+ return dialogueTakesSpeakerDirection(provider) ? ttsDirectionFor(dialogueProviderOf(provider), values) : {}
128
+ }
129
+
130
+ /**
131
+ * The files the dialogue model delivers: every speech file format on a model
132
+ * that renders a WAV the platform keeps or encodes (Gemini,
133
+ * `dialogueAnyOutputFormat`); the default MP3 only on the ElevenLabs dialogue
134
+ * models, as the platform calls them.
135
+ */
136
+ export function dialogueOutputFormats(provider: unknown): readonly TtsOutputFormat[] {
137
+ return getDialogueCapabilities(provider).dialogueAnyOutputFormat ? TTS_OUTPUT_FORMATS : [DEFAULT_TTS_OUTPUT_FORMAT]
138
+ }
139
+
140
+ /** The file a dialogue request on `provider` asks for, when it is one the model delivers; else undefined (the default MP3). */
141
+ export function dialogueOutputFormatFor(provider: unknown, value: unknown): TtsOutputFormat | undefined {
142
+ return typeof value === "string" && (dialogueOutputFormats(provider) as readonly string[]).includes(value) ? (value as TtsOutputFormat) : undefined
143
+ }
144
+
145
+ /** A dialogue request as every lane reads it (the route's body, a node's data, the MCP verb's args mapped). */
146
+ export interface DialogueRequestShape {
147
+ readonly dialogue?: unknown
148
+ readonly speakers?: unknown
149
+ /** The file asked for; judged against `dialogueOutputFormats` when given. */
150
+ readonly outputFormat?: unknown
151
+ }
152
+
153
+ /** Why a dialogue request cannot run on its model: where, and the sentence a caller is answered with. */
154
+ export interface DialogueProblem {
155
+ readonly path: ReadonlyArray<string | number>
156
+ readonly message: string
157
+ }
158
+
159
+ /**
160
+ * The speakers a dialogue clones for this request: the voice labels whose
161
+ * `speakers` entry carries a `replica` (two https links), on a model that
162
+ * clones (`TtsCapabilities.replica`); none on any other. The ONE predicate
163
+ * every dialogue seam reads — the voice move, the check, the worker — so a
164
+ * cloned speaker is kept on a model that clones and never silently voiced by
165
+ * a stock voice in its place.
166
+ */
167
+ export function dialogueReplicaVoices(provider: unknown, speakers: unknown): Set<string> {
168
+ const id = dialogueProviderOf(provider)
169
+ if (!ttsTakesReplica(id) || !Array.isArray(speakers)) return new Set()
170
+ const out = new Set<string>()
171
+ for (const entry of speakers) {
172
+ const s = entry as { voice?: unknown; replica?: unknown } | null
173
+ if (s && typeof s.voice === "string" && s.voice && replicaOf(s.replica)) out.add(s.voice)
174
+ }
175
+ return out
176
+ }
177
+
178
+ /** A cloned speaker's recordings in a dialogue request, by voice label (`dialogueReplicaVoices`' speakers). */
179
+ export function dialogueReplicaOf(provider: unknown, speakers: unknown, voice: string): ReturnType<typeof replicaOf> {
180
+ if (!dialogueReplicaVoices(provider, speakers).has(voice) || !Array.isArray(speakers)) return undefined
181
+ const entry = speakers.find((s) => (s as { voice?: unknown } | null)?.voice === voice) as { replica?: unknown } | undefined
182
+ return replicaOf(entry?.replica)
183
+ }
184
+
185
+ /** The distinct voices of a script, in the order they first speak. */
186
+ export function dialogueVoicesOf(lines: unknown): string[] {
187
+ if (!Array.isArray(lines)) return []
188
+ const out: string[] = []
189
+ for (const line of lines) {
190
+ const voice = (line as { voice?: unknown } | null)?.voice
191
+ if (typeof voice === "string" && !out.includes(voice)) out.push(voice)
192
+ }
193
+ return out
194
+ }
195
+
196
+ /**
197
+ * The first reason a dialogue request cannot run on `provider`, or undefined.
198
+ * The ONE rule the route's schema, the workflow engine and the MCP verb read,
199
+ * so a script is refused the same way at every door and before any hold:
200
+ * at most `dialogueMaxSpeakers` distinct voices; on a model with named voices
201
+ * (Gemini) every voice one of them; a line's style within what the model takes
202
+ * per line; each speaker's direction within what the model takes per speaker.
203
+ * A field the model does not take is never sent, so it is no problem (as on
204
+ * one speaker: `ttsDirectionProblem`). The script's length is the caller's to
205
+ * judge (`dialogueTextBeforeCap`, @nodaro/prompts).
206
+ */
207
+ export function dialogueProblem(provider: unknown, request: DialogueRequestShape): DialogueProblem | undefined {
208
+ const id = dialogueProviderOf(provider)
209
+ const sheet = getDialogueCapabilities(id)
210
+ const lines = Array.isArray(request.dialogue) ? request.dialogue : []
211
+ // One entry per speaker: two entries for one voice would leave which one applies to chance.
212
+ if (Array.isArray(request.speakers)) {
213
+ const seen = new Set<string>()
214
+ for (let i = 0; i < request.speakers.length; i++) {
215
+ const voice = (request.speakers[i] as { voice?: unknown } | null)?.voice
216
+ if (typeof voice !== "string") continue
217
+ if (seen.has(voice)) return { path: ["speakers", i, "voice"], message: `speakers lists the voice "${voice}" more than once; give each speaker one entry` }
218
+ seen.add(voice)
219
+ }
220
+ }
221
+ const voices = dialogueVoicesOf(lines)
222
+ const max = dialogueMaxSpeakers(id)
223
+ if (voices.length > max) {
224
+ return { path: ["dialogue"], message: `A dialogue can use at most ${max} unique voices — reuse voices across lines or split the script into two nodes` }
225
+ }
226
+ // A one-off clone (`replica`) on a speaker: refused on a model that does not clone, never dropped.
227
+ if (Array.isArray(request.speakers)) {
228
+ for (let i = 0; i < request.speakers.length; i++) {
229
+ const replica = (request.speakers[i] as { replica?: unknown } | null)?.replica
230
+ const problem = ttsReplicaProblem(id, replica)
231
+ if (problem) return { path: ["speakers", i, "replica"], message: problem }
232
+ }
233
+ }
234
+ const clones = dialogueReplicaVoices(id, request.speakers)
235
+ const named = sheet.voices
236
+ if (named) {
237
+ for (let i = 0; i < lines.length; i++) {
238
+ const voice = (lines[i] as { voice?: unknown } | null)?.voice
239
+ if (typeof voice === "string" && !clones.has(voice) && !named.some((v) => v.id === voice)) {
240
+ return { path: ["dialogue", i, "voice"], message: `${voice} is not a voice of ${id}. Its voices: ${named.map((v) => v.id).join(", ")}` }
241
+ }
242
+ }
243
+ }
244
+ const styleMax = dialogueLineStyleMaxChars(id)
245
+ if (styleMax !== undefined) {
246
+ for (let i = 0; i < lines.length; i++) {
247
+ const style = (lines[i] as { styleDirection?: unknown } | null)?.styleDirection
248
+ if (style === undefined) continue
249
+ if (typeof style !== "string") return { path: ["dialogue", i, "styleDirection"], message: "styleDirection must be a string" }
250
+ if (style.trim().length > styleMax) return { path: ["dialogue", i, "styleDirection"], message: `styleDirection must be at most ${styleMax} characters` }
251
+ }
252
+ }
253
+ if (request.outputFormat !== undefined && dialogueOutputFormatFor(id, request.outputFormat) === undefined) {
254
+ return { path: ["outputFormat"], message: `outputFormat on ${id} must be one of: ${dialogueOutputFormats(id).join(", ")}` }
255
+ }
256
+ if (dialogueTakesSpeakerDirection(id) && Array.isArray(request.speakers)) {
257
+ for (let i = 0; i < request.speakers.length; i++) {
258
+ const speaker = request.speakers[i]
259
+ if (!speaker || typeof speaker !== "object") continue
260
+ const problem = ttsDirectionProblem(id, speaker as Record<string, unknown>)
261
+ if (problem) return { path: ["speakers", i, problem.field], message: problem.message }
262
+ }
263
+ }
264
+ return undefined
265
+ }
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Dubbing structure — the wire contract of a dub read back by its job id
3
+ * (`GET /v1/dubbing/:jobId`), and of the captions export beside it
4
+ * (`GET /v1/dubbing/:jobId/captions`).
5
+ *
6
+ * One shape whichever engine made the dub, so a client is written once. A
7
+ * field an engine does not tell is null, never absent:
8
+ * - `sourceSegmentId` names the source line a language's line translates.
9
+ * It is null where the dub's lines carry no link to the source lines; the
10
+ * two lists are then read side by side, by time.
11
+ * - `sourceText` is the original text a line translates, as the dub keeps
12
+ * it beside the line; null where the dub keeps none. Each of the two is
13
+ * told on its own: a line can carry `sourceText` and no `sourceSegmentId`.
14
+ * - a speaker's `name` and `voice` are null until they can be read.
15
+ *
16
+ * `capabilities` says what can be done to this dub now. A client offers an
17
+ * action only when its capability is true.
18
+ */
19
+
20
+ /** The caption file formats a dub exports. */
21
+ export const DUBBING_CAPTION_FORMATS = ["srt", "vtt"] as const
22
+ export type DubbingCaptionFormat = (typeof DUBBING_CAPTION_FORMATS)[number]
23
+
24
+ /** The `language` value that names the original speech in a captions request. */
25
+ export const DUBBING_SOURCE_LANGUAGE = "source"
26
+
27
+ /**
28
+ * Where a language of a dub stands:
29
+ * - `processing`: being made; its lines are not readable yet.
30
+ * - `completed`: it is made; its lines and captions are readable where the dubbing service gives them.
31
+ * - `stale`: its lines changed after its media was last made.
32
+ * - `failed`: it was not made.
33
+ */
34
+ export const DUBBING_LANGUAGE_STATUSES = ["processing", "completed", "stale", "failed"] as const
35
+ export type DubbingLanguageStatus = (typeof DUBBING_LANGUAGE_STATUSES)[number]
36
+
37
+ /** One line of the original speech. Times are seconds from the start of the media. */
38
+ export interface DubbingSourceSegment {
39
+ /** Unique within the source lines. */
40
+ id: string
41
+ speakerId: string | null
42
+ start: number
43
+ end: number
44
+ text: string
45
+ }
46
+
47
+ /** One line of a dubbed language. Times are seconds from the start of the media. */
48
+ export interface DubbingSegment {
49
+ /** Unique within this language's lines. */
50
+ id: string
51
+ speakerId: string | null
52
+ start: number
53
+ end: number
54
+ /**
55
+ * The `id` of the source line this one translates; null where the dub's
56
+ * lines carry no link to the source lines.
57
+ */
58
+ sourceSegmentId: string | null
59
+ /**
60
+ * The original text this line translates, as the dub keeps it beside the
61
+ * line; null where it keeps none. It can be told where `sourceSegmentId` is
62
+ * null.
63
+ */
64
+ sourceText: string | null
65
+ text: string
66
+ }
67
+
68
+ /** One language a dub speaks. */
69
+ export interface DubbingLanguage {
70
+ /** The language code the dub was asked for (`es`, `pt-BR`); unique within a dub. */
71
+ code: string
72
+ /**
73
+ * The job whose result is this language's dubbed media. null when the
74
+ * language was made but no job of the account holds its media: adding the
75
+ * language again delivers it, unless its status is `stale` (its lines
76
+ * changed after its media was made), when adding it is refused.
77
+ */
78
+ jobId: string | null
79
+ status: DubbingLanguageStatus
80
+ /** Empty unless `status` is `completed` or `stale`, and where the dubbing service does not give the language's lines. */
81
+ segments: DubbingSegment[]
82
+ }
83
+
84
+ /** The voice a speaker is dubbed in. */
85
+ export interface DubbingSpeakerVoice {
86
+ id: string
87
+ name: string | null
88
+ previewUrl: string | null
89
+ }
90
+
91
+ /** One speaker the dub tells apart. */
92
+ export interface DubbingSpeaker {
93
+ /** The `speakerId` its lines carry. */
94
+ id: string
95
+ name: string | null
96
+ voice: DubbingSpeakerVoice | null
97
+ /** How many source lines the speaker has (lines of the first language when the source is not readable). */
98
+ segmentCount: number
99
+ }
100
+
101
+ /** What can be done to a dub now. */
102
+ export interface DubbingCapabilities {
103
+ /** Change a line's text. */
104
+ editSegments: boolean
105
+ /** Make chosen lines again. */
106
+ regenerate: boolean
107
+ /** Replace a speaker's voice. */
108
+ setSpeakerVoice: boolean
109
+ /** Render the media again after edits. */
110
+ render: boolean
111
+ /** Add a target language (`POST /v1/dubbing/:jobId/languages`). */
112
+ addLanguage: boolean
113
+ /** Export captions (`GET /v1/dubbing/:jobId/captions`). */
114
+ captions: boolean
115
+ }
116
+
117
+ /**
118
+ * What adding a language to this dub is charged. The price is the answer of
119
+ * `POST /v1/credits/model-costs` for `creditIdByLanguage[language] ?? creditId`.
120
+ */
121
+ export interface DubbingAddLanguagePrice {
122
+ /** Whole minutes an added language is charged for; null when the length is only known once it runs. */
123
+ billableMinutes: number | null
124
+ /** The price id of an added language; null with `billableMinutes`. */
125
+ creditId: string | null
126
+ /** The languages priced by another id than `creditId`, by lowercase language code. */
127
+ creditIdByLanguage: Record<string, string>
128
+ }
129
+
130
+ /** `GET /v1/dubbing/:jobId`. */
131
+ export interface DubbingStructure {
132
+ /** The job the dub was created by. Languages added later hang off it. */
133
+ jobId: string
134
+ /** Seconds of media the dub covers; null when not known. */
135
+ durationSec: number | null
136
+ /** The original speech; null when its lines are not readable. */
137
+ source: { language: string | null; segments: DubbingSourceSegment[] } | null
138
+ languages: DubbingLanguage[]
139
+ speakers: DubbingSpeaker[]
140
+ capabilities: DubbingCapabilities
141
+ addLanguage: DubbingAddLanguagePrice
142
+ }
143
+
144
+ /** `POST /v1/dubbing/:jobId/languages` request. */
145
+ export interface DubbingAddLanguageInput {
146
+ /** The language to add (`es`, `pt-BR`). */
147
+ targetLanguage: string
148
+ /** The rights confirmation, when the dub was made from a link the deployment asks one for. */
149
+ confirmationId?: string
150
+ }
151
+
152
+ /** `POST /v1/dubbing/:jobId/languages` response: the job that delivers the added language. */
153
+ export interface DubbingAddLanguageResult {
154
+ jobId: string
155
+ }
156
+
157
+ /**
158
+ * The error codes the dubbing reads and the add-language call answer beside
159
+ * the platform's own (`not_found`, `unauthorized`, `validation_error`). Each
160
+ * is the `error.code` of the response body.
161
+ */
162
+ export const DUBBING_ERROR_CODES = [
163
+ /** 422: the job is not a dub. */
164
+ "not_a_dubbing_job",
165
+ /** 409: the dub is still being made. */
166
+ "dubbing_not_ready",
167
+ /** 422: the dub was not made. */
168
+ "dubbing_failed",
169
+ /** 410: the dub is no longer held where it was made. */
170
+ "dubbing_unavailable",
171
+ /** 404: the dub has no such language. */
172
+ "dubbing_language_not_found",
173
+ /** 409: that language is still being made. */
174
+ "dubbing_language_processing",
175
+ /** 422: that language has no captions to export. */
176
+ "dubbing_captions_unavailable",
177
+ /** 409: the dub already speaks that language. */
178
+ "dubbing_language_exists",
179
+ /** 422: the length of the dub cannot be read, so a language cannot be priced. */
180
+ "unreadable_dubbing_source",
181
+ /** 413: the dub is longer than 30 minutes, so a language cannot be added to it. */
182
+ "media_duration_exceeds_limit",
183
+ /** 502: the dubbing service did not answer. */
184
+ "dubbing_read_failed",
185
+ ] as const
186
+ export type DubbingErrorCode = (typeof DUBBING_ERROR_CODES)[number]
@@ -50,7 +50,9 @@ export {
50
50
  wiredCharacterNames,
51
51
  wiredCharacterNamesOf,
52
52
  wiredCharacterBySlug,
53
+ wiredCharacterSlug,
53
54
  wiredCharacterKey,
55
+ wiredCharacterVideoUrls,
54
56
  aliasRetiredCharacterMentions,
55
57
  RETIRED_CHARACTER_MENTION_SLUGS,
56
58
  } from "../wired-character-names.js"
@@ -45,6 +45,13 @@ export {
45
45
  getLlmModel,
46
46
  getLlmTier,
47
47
  getLlmModalityCaps,
48
+ type LlmModalityCaps,
49
+ llmAcceptsFiles,
50
+ LLM_FILE_MODELS,
51
+ LLM_REFERENCE_FILES_MAX,
52
+ LLM_REFERENCE_FILES_MAX_TOTAL_BYTES,
53
+ LLM_REFERENCE_FILES_MAX_PAGES,
54
+ LLM_REFERENCE_FILE_MIME_TYPES,
48
55
  buildLlmCreditIdentifier,
49
56
  llmCreditRung,
50
57
  resolveLlmCreditId,