@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
@@ -1,6 +1,7 @@
1
+ import { replicaConsentProblem, replicaModels, replicaOf, ttsReplicaProblem, ttsTakesReplica } from "../tts-capabilities.js"
1
2
  import { describe, it, expect } from "vitest"
2
3
  import { MODEL_CATALOG, SPEECH_UNIT_PRICE_NOTE } from "../model-catalog.js"
3
- import { TTS_PROVIDERS, MAX_TTS_CHARS_BY_PROVIDER, getMaxTtsChars, TTS_TEXT_MAX } from "../model-constants.js"
4
+ import { TTS_PROVIDERS, MAX_TTS_CHARS_BY_PROVIDER, getMaxTtsChars, TTS_TEXT_MAX, DEFAULT_TTS_PROVIDER } from "../model-constants.js"
4
5
  import {
5
6
  TTS_PROVIDER_ALIASES,
6
7
  TTS_FALLBACK_PROVIDER,
@@ -13,6 +14,14 @@ import {
13
14
  ttsHasLever,
14
15
  ttsLanguageCodes,
15
16
  ttsSupportsTimestamps,
17
+ ttsNamedVoices,
18
+ ttsAcceptsVoice,
19
+ ttsNamedVoiceFor,
20
+ ttsAngleTags,
21
+ ttsDirection,
22
+ ttsDirectionFor,
23
+ ttsDirectionProblem,
24
+ ttsVoiceForModel,
16
25
  } from "../tts-capabilities.js"
17
26
 
18
27
  describe("speech-model capability sheets — totality", () => {
@@ -48,9 +57,12 @@ describe("speech-model capability sheets — totality", () => {
48
57
  for (const m of Object.values(MODEL_CATALOG)) {
49
58
  if (!m.tts) continue
50
59
  expect(Number.isInteger(m.tts.maxChars) && m.tts.maxChars > 0, `${m.id} maxChars`).toBe(true)
51
- expect(m.tts.levers, `${m.id} must honour stability`).toContain("stability")
60
+ // An ElevenLabs model honours stability; a named-voice model (Gemini) takes no ElevenLabs setting at all.
61
+ if (m.tts.voices) expect(m.tts.levers, `${m.id} takes no ElevenLabs lever`).toEqual([])
62
+ else expect(m.tts.levers, `${m.id} must honour stability`).toContain("stability")
52
63
  expect(new Set(m.tts.levers).size, `${m.id} duplicate lever`).toBe(m.tts.levers.length)
53
- expect(m.tts.languages.length, `${m.id} languages`).toBeGreaterThan(0)
64
+ // No language picker only where no language is ever sent (the text decides).
65
+ if (m.tts.languageCode) expect(m.tts.languages.length, `${m.id} languages`).toBeGreaterThan(0)
54
66
  expect(new Set(m.tts.languages).size, `${m.id} duplicate language`).toBe(m.tts.languages.length)
55
67
  // The `features` flag other packages already read must agree with the sheet.
56
68
  expect(m.features?.includes("audio-tags") ?? false, `${m.id} audio-tags feature`).toBe(m.tts.audioTags)
@@ -313,7 +325,7 @@ describe("elevenlabs-v4-turbo — the fast v4, added beside v4 (decided 2026-10-
313
325
  expect(getTtsCapabilities("elevenlabs-v3").maxChars).toBe(5000)
314
326
  expect(getTtsCapabilities("elevenlabs-turbo").maxChars).toBe(40000)
315
327
  expect(getTtsCapabilities("elevenlabs-multilingual").maxChars).toBe(10000)
316
- expect(TTS_PROVIDERS.filter((id) => id !== "elevenlabs-v4-turbo")).toEqual(["elevenlabs-v3", "elevenlabs-v4", "elevenlabs-turbo", "elevenlabs-multilingual", "elevenlabs"])
328
+ expect(TTS_PROVIDERS.filter((id) => id !== "elevenlabs-v4-turbo" && !id.startsWith("gemini-"))).toEqual(["elevenlabs-v3", "elevenlabs-v4", "elevenlabs-turbo", "elevenlabs-multilingual", "elevenlabs"])
317
329
  })
318
330
 
319
331
  it("the narration recommendation keeps v4 first and places v4 Turbo after v3, before Turbo v2.5", async () => {
@@ -373,3 +385,147 @@ describe("field mappings — the neighbour text fields are mappable", () => {
373
385
  expect(NODE_MAPPABLE_FIELDS["text-to-speech"]).toEqual(["directText", "previousText", "nextText"])
374
386
  })
375
387
  })
388
+
389
+ describe("Gemini speech — four models beside ElevenLabs (decided 2026-11-12)", () => {
390
+ const GEMINI_3_8 = ["gemini-3-8-flash-lite-tts", "gemini-3-8-flash-tts"]
391
+ const GEMINI_3_1 = ["gemini-3-1-flash-tts", "gemini-2-5-pro-tts"]
392
+
393
+ it("each is a text-to-speech model of Google's, priced per 1,000 characters; ElevenLabs v4 stays the default", () => {
394
+ for (const id of [...GEMINI_3_8, ...GEMINI_3_1]) {
395
+ expect(TTS_PROVIDERS as readonly string[]).toContain(id)
396
+ expect(MODEL_CATALOG[id]?.maker).toBe("google")
397
+ expect(MODEL_CATALOG[id]?.modes).toEqual(["tts", "dialogue"]) // one id for one speaker and two: dialogue priced on the one-speaker row by construction
398
+ expect(getTtsCapabilities(id).ratePer1kChars).toBe(true)
399
+ expect(MODEL_CATALOG[id]!.pricing.map((p) => p.identifier)).toEqual([id, `${id}:per-1k-chars`])
400
+ }
401
+ expect(DEFAULT_TTS_PROVIDER).toBe("elevenlabs-v4")
402
+ })
403
+
404
+ it("named voices only: 70 grouped by use on 3.8, the same 30 on 3.1 and 2.5; a voice of one list is not a voice of the other", () => {
405
+ for (const id of GEMINI_3_8) {
406
+ const voices = ttsNamedVoices(id)!
407
+ expect(voices).toHaveLength(70)
408
+ expect(voices.every((v) => v.group !== undefined)).toBe(true)
409
+ expect(new Set(voices.map((v) => v.id)).size).toBe(70)
410
+ expect(getTtsCapabilities(id).defaultVoice).toBe("Fola")
411
+ expect(ttsAcceptsVoice(id, "Fola")).toBe(true)
412
+ }
413
+ for (const id of GEMINI_3_1) {
414
+ expect(ttsNamedVoices(id)).toHaveLength(30)
415
+ expect(getTtsCapabilities(id).defaultVoice).toBe("Kore")
416
+ expect(ttsAcceptsVoice(id, "Fola")).toBe(false) // a 3.8 voice (KIE refuses it: 422)
417
+ expect(ttsAcceptsVoice(id, "Kore")).toBe(true)
418
+ }
419
+ // Every default is on its own list, and an ElevenLabs model takes any voice id (its own checks apply).
420
+ for (const id of [...GEMINI_3_8, ...GEMINI_3_1]) expect(ttsAcceptsVoice(id, getTtsCapabilities(id).defaultVoice!)).toBe(true)
421
+ expect(ttsNamedVoices("elevenlabs-v4")).toBeUndefined()
422
+ expect(ttsAcceptsVoice("elevenlabs-v4", "Rachel")).toBe(true)
423
+ })
424
+
425
+ it("ttsNamedVoiceFor: the voice asked for when the model speaks it, else the model's default; nothing on ElevenLabs", () => {
426
+ expect(ttsNamedVoiceFor("gemini-3-8-flash-tts", "Zephyr")).toBe("Zephyr")
427
+ expect(ttsNamedVoiceFor("gemini-3-8-flash-tts", "Rachel")).toBe("Fola")
428
+ expect(ttsNamedVoiceFor("gemini-3-1-flash-tts", undefined)).toBe("Kore")
429
+ expect(ttsNamedVoiceFor("elevenlabs-v4", "Rachel")).toBeUndefined()
430
+ })
431
+
432
+ it("no ElevenLabs lever, no language field, no timings, no neighbour text, a 10,000-character cap", () => {
433
+ for (const id of [...GEMINI_3_8, ...GEMINI_3_1]) {
434
+ const c = getTtsCapabilities(id)
435
+ expect(c).toMatchObject({ levers: [], languageCode: false, languages: [], timestamps: false, stitching: false, ssmlBreaks: false, maxChars: 10000, audioTags: true })
436
+ expect(getMaxTtsChars(id)).toBe(10000)
437
+ }
438
+ })
439
+
440
+ it("tags: 3.8 writes its own <angle> tags from a closed list; 3.1 / 2.5 take [square] tags as written", () => {
441
+ for (const id of GEMINI_3_8) {
442
+ expect(ttsAngleTags(id)).toContain("laugh")
443
+ expect(ttsAngleTags(id)).toContain("short pause")
444
+ expect(ttsAngleTags(id)).toHaveLength(40)
445
+ }
446
+ for (const id of [...GEMINI_3_1, "elevenlabs-v4"]) expect(ttsAngleTags(id)).toBeUndefined()
447
+ })
448
+
449
+ it("direction: free text per line on 3.8; style, pace, accent and audio profile on 3.1 / 2.5; none on ElevenLabs", () => {
450
+ for (const id of GEMINI_3_8) expect(ttsDirection(id)).toEqual({ styleMaxChars: 1000 })
451
+ for (const id of GEMINI_3_1) {
452
+ const d = ttsDirection(id)!
453
+ expect(d.styles).toContain("Deadpan")
454
+ expect(d.paces).toContain("Staccato")
455
+ expect(d.accents).toContain("British (RP)")
456
+ expect(d.audioProfileMaxChars).toBe(1000)
457
+ expect(d.styleMaxChars).toBeUndefined()
458
+ }
459
+ expect(ttsDirection("elevenlabs-v4")).toBeUndefined()
460
+ })
461
+
462
+ it("ttsDirectionFor keeps only what the model takes, trimmed; ttsDirectionProblem judges only that", () => {
463
+ const all = { styleDirection: " slow and dry ", pace: "Staccato", accent: "Australian", audioProfile: "A narrator" }
464
+ expect(ttsDirectionFor("gemini-3-8-flash-lite-tts", all)).toEqual({ styleDirection: "slow and dry" })
465
+ expect(ttsDirectionFor("gemini-3-1-flash-tts", { ...all, styleDirection: "Deadpan" })).toEqual({ styleDirection: "Deadpan", pace: "Staccato", accent: "Australian", audioProfile: "A narrator" })
466
+ expect(ttsDirectionFor("gemini-3-1-flash-tts", all)).toEqual({ pace: "Staccato", accent: "Australian", audioProfile: "A narrator" })
467
+ expect(ttsDirectionFor("elevenlabs-v4", all)).toEqual({})
468
+ expect(ttsDirectionProblem("gemini-3-8-flash-tts", all)).toBeUndefined()
469
+ expect(ttsDirectionProblem("gemini-3-8-flash-tts", { styleDirection: "x".repeat(1001) })).toMatchObject({ field: "styleDirection" })
470
+ expect(ttsDirectionProblem("gemini-3-1-flash-tts", all)).toMatchObject({ field: "styleDirection" })
471
+ expect(ttsDirectionProblem("gemini-3-1-flash-tts", { pace: "Slow" })).toMatchObject({ field: "pace" })
472
+ expect(ttsDirectionProblem("gemini-2-5-pro-tts", { accent: "" })).toBeUndefined()
473
+ expect(ttsDirectionProblem("elevenlabs-v4", { pace: "Slow" })).toBeUndefined()
474
+ })
475
+ })
476
+
477
+ describe("ttsVoiceForModel — the editor's model-switch rule where the editor is not there (decided 2026-11-13)", () => {
478
+ it("an ElevenLabs voice on a Gemini model becomes the model's default; a voice of its own list stays", () => {
479
+ expect(ttsVoiceForModel("gemini-3-8-flash-tts", "Rachel")).toBe("Fola")
480
+ expect(ttsVoiceForModel("gemini-3-1-flash-tts", "Fola")).toBe("Kore") // a 3.8 voice is not on 3.1's list
481
+ expect(ttsVoiceForModel("gemini-3-8-flash-tts", "Zephyr")).toBe("Zephyr")
482
+ expect(ttsVoiceForModel("gemini-2-5-pro-tts", "")).toBeUndefined()
483
+ expect(ttsVoiceForModel("gemini-2-5-pro-tts", undefined)).toBeUndefined()
484
+ })
485
+
486
+ it("a Gemini voice on an ElevenLabs model becomes no voice (the deployment's default); an ElevenLabs voice stays", () => {
487
+ expect(ttsVoiceForModel("elevenlabs-v4", "Fola")).toBeUndefined()
488
+ expect(ttsVoiceForModel("elevenlabs-turbo", "Kore")).toBeUndefined()
489
+ expect(ttsVoiceForModel("elevenlabs-v4", "Rachel")).toBe("Rachel")
490
+ expect(ttsVoiceForModel("elevenlabs-v4", "21m00Tcm4TlvDq8ikWAM")).toBe("21m00Tcm4TlvDq8ikWAM")
491
+ expect(ttsVoiceForModel(undefined, "Puck")).toBeUndefined() // no model: the fallback model, ElevenLabs
492
+ })
493
+
494
+ it("no Gemini voice name is also an ElevenLabs premade name", () => {
495
+ const premade = ["Rachel", "Aria", "Roger", "Sarah", "Laura", "Charlie", "George", "Callum", "River", "Liam", "Charlotte", "Alice", "Matilda", "Will", "Jessica", "Eric", "Chris", "Brian", "Daniel", "Lily", "Bill"]
496
+ for (const id of ["gemini-3-8-flash-tts", "gemini-3-1-flash-tts"]) {
497
+ for (const v of ttsNamedVoices(id)!) expect(premade, v.id).not.toContain(v.id)
498
+ }
499
+ })
500
+ })
501
+
502
+ describe("a one-off clone (replica, decided 2026-11-13)", () => {
503
+ it("3.8 Flash takes it; 3.8 Flash-Lite (KIE refuses it), 3.1, 2.5 and every ElevenLabs model do not", () => {
504
+ expect(ttsTakesReplica("gemini-3-8-flash-tts")).toBe(true)
505
+ for (const id of ["gemini-3-8-flash-lite-tts", "gemini-3-1-flash-tts", "gemini-2-5-pro-tts", "elevenlabs-v4", undefined]) expect(ttsTakesReplica(id), String(id)).toBe(false)
506
+ expect(replicaModels()).toEqual(["gemini-3-8-flash-tts"])
507
+ })
508
+
509
+ it("replicaOf reads two https links; ttsReplicaProblem refuses one on a model that does not clone, and a malformed one", () => {
510
+ const ok = { sourceAudioUrl: "https://a.example/s.wav", consentAudioUrl: "https://a.example/c.wav" }
511
+ expect(replicaOf(ok)).toEqual(ok)
512
+ expect(replicaOf({ ...ok, sourceAudioUrl: "http://a.example/s.wav" })).toBeUndefined()
513
+ expect(replicaOf({ sourceAudioUrl: "https://a" })).toBeUndefined()
514
+ expect(ttsReplicaProblem("gemini-3-8-flash-tts", ok)).toBeUndefined()
515
+ expect(ttsReplicaProblem("gemini-3-8-flash-tts", undefined)).toBeUndefined()
516
+ expect(ttsReplicaProblem("gemini-3-8-flash-lite-tts", ok)).toBe("gemini-3-8-flash-lite-tts does not clone a voice; a one-off clone runs on gemini-3-8-flash-tts")
517
+ expect(ttsReplicaProblem("gemini-3-8-flash-tts", { sourceAudioUrl: "file:///etc/passwd", consentAudioUrl: ok.consentAudioUrl })).toMatch(/https link/)
518
+ })
519
+ })
520
+
521
+ describe("a one-off clone's consent on the API and MCP (decided 2026-11-13)", () => {
522
+ it("a clone must say consent: true; none asked is no problem", () => {
523
+ const links = { sourceAudioUrl: "https://a.example/s.wav", consentAudioUrl: "https://a.example/c.wav" }
524
+ expect(replicaConsentProblem(undefined)).toBeUndefined()
525
+ expect(replicaConsentProblem({ ...links, consent: true })).toBeUndefined()
526
+ for (const replica of [links, { ...links, consent: false }, { ...links, consent: "yes" }]) {
527
+ expect(replicaConsentProblem(replica)).toMatch(/^replica\.consent must be true: it confirms "I confirm the voice in these recordings is my own/)
528
+ }
529
+ })
530
+ })
531
+
@@ -60,7 +60,7 @@ describe("video-analysis-pricing", () => {
60
60
  })
61
61
 
62
62
  it("model SSOT is capability-derived and Gemini-only today", () => {
63
- expect(VIDEO_ANALYSIS_LLM_MODELS).toEqual(["gemini-3-flash", "gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.1-pro"])
63
+ expect(VIDEO_ANALYSIS_LLM_MODELS).toEqual(["gemini-3-flash", "gemini-3.6-flash", "gemini-3.8-flash", "gemini-3.1-pro", "gemini-4-carbon"])
64
64
  })
65
65
 
66
66
  it("tier layer: every model-backed tier maps to a real model AND every model is tier-reachable or explicitly legacy (no vendor leak)", () => {
@@ -107,6 +107,8 @@ describe("video-analysis-pricing", () => {
107
107
  // channel (2026-11-13); gemini-3-flash is now a legacy fast backing.
108
108
  expect(resolveVideoAnalysisModel("fast")).toBe("gemini-3.8-flash")
109
109
  expect(VIDEO_ANALYSIS_LEGACY_MODELS["gemini-3-flash"]).toBe("fast")
110
+ // `ultra` (2026-11-13) is model-backed like fast and pro.
111
+ expect(resolveVideoAnalysisModel("ultra")).toBe("gemini-4-carbon")
110
112
  expect(resolveVideoAnalysisModel("mixed")).toBe("mixed") // roll-plan sentinel passthrough
111
113
  expect(resolveVideoAnalysisModel("mixed-fast")).toBe("mixed-fast")
112
114
  // `smart` is a sentinel too — it names an engine plan, never a model id, so the
@@ -121,6 +123,16 @@ describe("video-analysis-pricing", () => {
121
123
  expect(resolveVideoAnalysisModel("nonsense")).toBe("gemini-3.1-pro") // unknown → default, never throws
122
124
  })
123
125
 
126
+ it("ultra prices under its own model's family, above mixed and below smart in every bucket", () => {
127
+ for (const bucketSec of VIDEO_ANALYSIS_DURATION_BUCKETS) {
128
+ const id = buildVideoAnalysisCreditId(resolveVideoAnalysisModel("ultra"), bucketSec)
129
+ expect(id).toBe(`video-analysis:gemini-4-carbon:${bucketSec}s`)
130
+ const ultra = VIDEO_ANALYSIS_BUCKET_CREDITS[id]!
131
+ expect(ultra, `ultra <= mixed at ${bucketSec}s`).toBeGreaterThan(VIDEO_ANALYSIS_BUCKET_CREDITS[`video-analysis:mixed:${bucketSec}s`]!)
132
+ expect(ultra, `ultra >= smart at ${bucketSec}s`).toBeLessThan(VIDEO_ANALYSIS_BUCKET_CREDITS[`video-analysis:smart:${bucketSec}s`]!)
133
+ }
134
+ })
135
+
124
136
  it("mixed tiers price under ONE shared credit family (video-analysis:mixed:*)", () => {
125
137
  // Both variants are the identical compute plan — a per-variant price split
126
138
  // would be a phantom distinction and double the admin surface.
@@ -0,0 +1,192 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ characterReferencesFromWired,
4
+ characterVideoUrls,
5
+ pricedReferenceVideoUrls,
6
+ seatCharacterVideos,
7
+ videoCharacterClipsBilledAsReferenceVideo,
8
+ videoCharacterVideoCap,
9
+ videoCharacterVideoProviders,
10
+ } from "../entries/video.js"
11
+ import {
12
+ VIDEO_CHARACTER_CLIP_DURATION_LIMITS,
13
+ VIDEO_REF_LIMITS_BY_PROVIDER,
14
+ VIDEO_REF_VIDEO_DURATION_LIMITS,
15
+ checkCharacterClipDurations,
16
+ } from "../entries/models.js"
17
+ import { CHARACTER_NODE_DEFAULT_LABEL, wiredCharacterVideoUrls } from "../entries/entities.js"
18
+ import type { ConnectedReference } from "../types.js"
19
+
20
+ /**
21
+ * Video subjects on Kling 4.0 / Kling 4.0 Flash (decided 2026-11-13): a
22
+ * character made from a short clip of itself. KIE takes at most 3 of them,
23
+ * counts them with the reference videos (5 in all) and bills their seconds as
24
+ * reference-video seconds — so the clip is SEATED among the reference videos,
25
+ * and every reference-video seam measures and prices it.
26
+ */
27
+ const clip = (n: number) => `https://cdn.example/clip-${n}.mp4`
28
+ const ref = (n: number) => `https://cdn.example/ref-${n}.mp4`
29
+ const character = (videoUrl?: string) => ({ imageUrl: "https://cdn.example/p.png", description: "d", ...(videoUrl ? { videoUrl } : {}) })
30
+
31
+ describe("which models take video subjects (data)", () => {
32
+ it("Kling 4.0 and Kling 4.0 Flash, 3 each; nothing else", () => {
33
+ expect(videoCharacterVideoProviders()).toEqual(["kling-4", "kling-4-flash"])
34
+ expect(videoCharacterVideoCap("kling-4")).toBe(3)
35
+ expect(videoCharacterVideoCap("kling-4-flash")).toBe(3)
36
+ expect(videoCharacterVideoCap("gemini-omni-video")).toBe(0)
37
+ expect(videoCharacterVideoCap("seedance-2")).toBe(0)
38
+ expect(videoCharacterVideoCap(undefined)).toBe(0)
39
+ })
40
+
41
+ it("a model that takes video subjects bills reference-video seconds and bounds a clip at 3-8 s", () => {
42
+ for (const id of videoCharacterVideoProviders()) {
43
+ expect(VIDEO_REF_VIDEO_DURATION_LIMITS[id], id).toBeDefined()
44
+ expect(VIDEO_CHARACTER_CLIP_DURATION_LIMITS[id], id).toEqual({ minSec: 3, maxSec: 8 })
45
+ expect(VIDEO_REF_LIMITS_BY_PROVIDER[id]?.videos, id).toBe(5)
46
+ }
47
+ })
48
+ })
49
+
50
+ // Decided 2026-11-14, from a measured run: Kling 4.0 Flash bills a video subject
51
+ // like an image subject; Kling 4.0 keeps pricing it as a reference video.
52
+ describe("how a video subject is priced, per model (data)", () => {
53
+ it("Kling 4.0 bills it as reference video; Kling 4.0 Flash does not", () => {
54
+ expect(videoCharacterClipsBilledAsReferenceVideo("kling-4")).toBe(true)
55
+ expect(videoCharacterClipsBilledAsReferenceVideo("kling-4-flash")).toBe(false)
56
+ expect(videoCharacterClipsBilledAsReferenceVideo(undefined)).toBe(false)
57
+ })
58
+
59
+ it("pricedReferenceVideoUrls: a character's clip leaves the priced list on Flash only; plain reference videos stay", () => {
60
+ const seated = [ref(1), clip(1)]
61
+ const characters = [character(clip(1)), character()]
62
+ expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: seated, characterReferences: characters })).toEqual([ref(1)])
63
+ expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: [clip(1)], characterReferences: characters })).toEqual([])
64
+ const asSent = pricedReferenceVideoUrls({ provider: "kling-4", referenceVideoUrls: seated, characterReferences: characters })
65
+ expect(asSent).toBe(seated)
66
+ // Nothing to leave out: the same value.
67
+ const plain = [ref(1)]
68
+ expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: plain, characterReferences: characters })).toBe(plain)
69
+ expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: undefined, characterReferences: undefined })).toBeUndefined()
70
+ })
71
+ })
72
+
73
+ describe("seatCharacterVideos — a character's clip rides as one more reference video", () => {
74
+ it("no clip: the list as it came, the same value — within the model's cap", () => {
75
+ const refs = [ref(1)]
76
+ const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: refs, characterReferences: [character()] })
77
+ expect(out).toEqual({ ok: true, referenceVideoUrls: refs })
78
+ expect(out.ok && out.referenceVideoUrls).toBe(refs)
79
+ expect(seatCharacterVideos({ provider: "seedance-2", referenceVideoUrls: undefined, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: undefined })
80
+ })
81
+
82
+ it("clips follow the reference videos, in character order", () => {
83
+ expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: [ref(1)], characterReferences: [character(clip(1)), character(), character(clip(2))] }))
84
+ .toEqual({ ok: true, referenceVideoUrls: [ref(1), clip(1), clip(2)] })
85
+ expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: undefined, characterReferences: [character(` ${clip(1)} `)] }))
86
+ .toEqual({ ok: true, referenceVideoUrls: [clip(1)] })
87
+ })
88
+
89
+ it("a clip already wired as a reference video keeps its seat (it is the subject only)", () => {
90
+ expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [clip(1), ref(1)], characterReferences: [character(clip(1))] }))
91
+ .toEqual({ ok: true, referenceVideoUrls: [clip(1), ref(1)] })
92
+ })
93
+
94
+ it("refused on a model that takes none, naming the ones that do", () => {
95
+ const out = seatCharacterVideos({ provider: "gemini-omni-video", referenceVideoUrls: [], characterReferences: [character(clip(1))] })
96
+ expect(out.ok).toBe(false)
97
+ if (!out.ok) {
98
+ expect(out.code).toBe("character_video_unsupported")
99
+ expect(out.message).toContain("kling-4, kling-4-flash")
100
+ }
101
+ })
102
+
103
+ it("refused past 3 characters made from a video", () => {
104
+ const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [1, 2, 3, 4].map((n) => character(clip(n))) })
105
+ expect(out.ok === false && out.code).toBe("character_videos_over_limit")
106
+ })
107
+
108
+ it("refused when two characters carry the same clip", () => {
109
+ const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [character(clip(1)), character(clip(1))] })
110
+ expect(out.ok === false && out.code).toBe("character_video_shared")
111
+ })
112
+
113
+ it("refused when reference videos and clips together pass the model's 5 videos", () => {
114
+ const four = [1, 2, 3, 4].map(ref)
115
+ expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1))] }).ok).toBe(true)
116
+ const out = seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1)), character(clip(2))] })
117
+ expect(out.ok === false && out.code).toBe("reference_videos_over_limit")
118
+ if (!out.ok) expect(out.message).toContain("This run has 6")
119
+ })
120
+
121
+ // Decided 2026-11-13: on a model whose reference videos and video subjects
122
+ // share one cap, plain reference videos past it are refused, never left out.
123
+ it("plain reference videos alone past 5 are refused on Kling 4.0 and Flash; another model's list is not judged", () => {
124
+ const six = [1, 2, 3, 4, 5, 6].map(ref)
125
+ for (const provider of ["kling-4", "kling-4-flash"]) {
126
+ const out = seatCharacterVideos({ provider, referenceVideoUrls: six, characterReferences: undefined })
127
+ expect(out.ok === false && out.code, provider).toBe("reference_videos_over_limit")
128
+ if (!out.ok) {
129
+ expect(out.message).toContain("This run has 6")
130
+ expect(out.message).not.toContain("from a character")
131
+ }
132
+ expect(seatCharacterVideos({ provider, referenceVideoUrls: six.slice(0, 5), characterReferences: [] }).ok).toBe(true)
133
+ }
134
+ expect(seatCharacterVideos({ provider: "seedance-2-5", referenceVideoUrls: six, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: six })
135
+ })
136
+
137
+ it("characterVideoUrls reads only non-empty string clips", () => {
138
+ expect(characterVideoUrls([character(clip(1)), character(), { videoUrl: " " }, { videoUrl: 7 }, null])).toEqual([clip(1)])
139
+ })
140
+ })
141
+
142
+ describe("checkCharacterClipDurations — 3-8 s, measured", () => {
143
+ it("in bounds passes; outside is refused with the clip's length", () => {
144
+ expect(checkCharacterClipDurations("kling-4", [3, 8, 5.5])).toEqual({ ok: true })
145
+ const short = checkCharacterClipDurations("kling-4-flash", [2.4])
146
+ expect(short.ok === false && short.code).toBe("video_too_long")
147
+ if (!short.ok) expect(short.message).toContain("one is 2.40 s")
148
+ expect(checkCharacterClipDurations("kling-4", [8.6]).ok).toBe(false)
149
+ // The measured length, rounded up to hundredths: 8.03 s never reads as 8.0.
150
+ const justOver = checkCharacterClipDurations("kling-4", [8.0281])
151
+ expect(justOver.ok === false && justOver.message).toContain("one is 8.03 s")
152
+ const tiny = checkCharacterClipDurations("kling-4", [8.001])
153
+ expect(tiny.ok === false && tiny.message).toContain("one is 8.01 s")
154
+ expect(checkCharacterClipDurations("seedance-2", [30])).toEqual({ ok: true })
155
+ })
156
+
157
+ // Decided 2026-11-13: a character's clip must be measured to be accepted.
158
+ it("a clip the probe could not read (NaN, 0) is refused, unlike a reference video", () => {
159
+ for (const d of [Number.NaN, 0]) {
160
+ const out = checkCharacterClipDurations("kling-4", [5, d])
161
+ expect(out.ok === false && out.code).toBe("character_video_unreadable")
162
+ }
163
+ })
164
+ })
165
+
166
+ describe("a wired Character node's clip reaches its character reference", () => {
167
+ const characterNode = (id: string, data: Record<string, unknown>) => ({ id, type: "character", data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "", ...data } })
168
+ const wire = (source: string) => ({ source, target: "gv", sourceHandle: "characterRef" })
169
+
170
+ it("wiredCharacterVideoUrls: by the slug the node goes by; the first clip of a merged name wins; a plain image wire gives none", () => {
171
+ const nodes = [
172
+ characterNode("a", { characterName: "Maya", subjectVideoUrl: clip(1) }),
173
+ characterNode("b", { characterName: "Maya", subjectVideoUrl: clip(2) }),
174
+ characterNode("u", { subjectVideoUrl: ` ${clip(3)} ` }),
175
+ characterNode("i", { characterName: "Leo", subjectVideoUrl: clip(4) }),
176
+ characterNode("n", { characterName: "Noa" }),
177
+ ]
178
+ const edges = [wire("a"), wire("b"), wire("u"), { source: "i", target: "gv", sourceHandle: "image" }, wire("n")]
179
+ expect([...wiredCharacterVideoUrls("gv", nodes, edges)]).toEqual([["maya", clip(1)], ["character-1", clip(3)]])
180
+ })
181
+
182
+ it("characterReferencesFromWired carries the clip of the character it names", () => {
183
+ const entry = (slug: string, name: string): ConnectedReference => ({
184
+ id: `char_${slug}`, defaultName: name, source: "wired-character", url: `https://cdn.example/${slug}.png`, characterSlug: slug,
185
+ })
186
+ const refs = characterReferencesFromWired([entry("maya", "Maya"), entry("leo", "Leo")], new Map([["maya", clip(1)]]))
187
+ expect(refs.map((r) => [r.name, r.videoUrl])).toEqual([["Maya", clip(1)], ["Leo", undefined]])
188
+ expect("videoUrl" in refs[1]!).toBe(false)
189
+ // Without the map (a model that takes no video subjects): no clip at all.
190
+ expect(characterReferencesFromWired([entry("maya", "Maya")]).every((r) => !("videoUrl" in r))).toBe(true)
191
+ })
192
+ })
@@ -7,6 +7,7 @@ import {
7
7
  wiredCharacterNamesOf,
8
8
  wiredCharacterBySlug,
9
9
  wiredCharacterKey,
10
+ wiredCharacterSlug,
10
11
  aliasRetiredCharacterMentions,
11
12
  entityImageUrl,
12
13
  type WiredCharacterSource,
@@ -129,6 +130,125 @@ describe("wiredCharacterNames — what each wired Character node is called by th
129
130
  ])
130
131
  })
131
132
 
133
+ // Decided 2026-11-12: the same-name rule holds in every script, as for Latin.
134
+ describe("the same typed name in any script is one character", () => {
135
+ for (const [locale, typed] of [["en", "Maya"], ["ja", "マヤ"], ["he", "מאיה"], ["ko", "마야"]] as const) {
136
+ it(`${locale}: two "${typed}" nodes share one key; the next unnamed node takes the next number`, () => {
137
+ const m = wiredCharacterNames([named("a", typed), unnamed("u"), named("b", typed)])
138
+ expect(m.get("a")?.slug).toBe(m.get("b")?.slug)
139
+ expect([m.get("a")?.name, m.get("b")?.name]).toEqual([typed, typed])
140
+ expect(new Set([...m.values()].map((n) => n.slug)).size).toBe(2)
141
+ expect(m.get("u")?.name).toBe(locale === "en" ? "Character 1" : "Character 2")
142
+ })
143
+ }
144
+
145
+ it("non-Latin: the duplicate takes no number of its own", () => {
146
+ expect(names([named("a", "マヤ"), unnamed("u"), named("b", "マヤ")])).toEqual([
147
+ ["a", "マヤ", "character-1"],
148
+ ["u", "Character 2", "character-2"],
149
+ ["b", "マヤ", "character-1"],
150
+ ])
151
+ })
152
+
153
+ it("Latin is unchanged: Maya / maya / MAYA and 'Maya Lee' / 'maya-lee' are one by their slug", () => {
154
+ expect(names([named("a", "Maya"), named("b", "maya"), named("c", "MAYA")])).toEqual([
155
+ ["a", "Maya", "maya"],
156
+ ["b", "maya", "maya"],
157
+ ["c", "MAYA", "maya"],
158
+ ])
159
+ expect(names([named("a", "Maya Lee"), named("b", "maya-lee")])).toEqual([
160
+ ["a", "Maya Lee", "maya-lee"],
161
+ ["b", "maya-lee", "maya-lee"],
162
+ ])
163
+ })
164
+
165
+ it("two different non-Latin names stay two (he / ja / ko)", () => {
166
+ for (const [x, y] of [["מאיה", "נועה"], ["マヤ", "レオ"], ["마야", "레오"]] as const) {
167
+ expect(names([named("a", x), named("b", y)])).toEqual([
168
+ ["a", x, "character-1"],
169
+ ["b", y, "character-2"],
170
+ ])
171
+ }
172
+ })
173
+
174
+ it("the same name as Unicode reads it: half-width katakana, decomposed Hangul, letter case, spacing", () => {
175
+ const same = (x: string, y: string) => {
176
+ const m = wiredCharacterNames([named("a", x), named("b", y)])
177
+ return m.get("a")?.slug === m.get("b")?.slug
178
+ }
179
+ expect(same("マヤ", "マヤ")).toBe(true)
180
+ expect(same("마야", "마야".normalize("NFD"))).toBe(true)
181
+ expect(same("Мая", "мая")).toBe(true)
182
+ expect(same("マヤ・リー", "マヤ リー")).toBe(true)
183
+ // A combining mark is part of the name: ガ (ga) is not カ (ka).
184
+ expect(same("ガク", "カク")).toBe(false)
185
+ })
186
+
187
+ // Decided 2026-11-13: a name with a letter of another script is the WHOLE
188
+ // name, never its Latin remainder.
189
+ it("mixed-script names that share a Latin remainder are different characters, on their own keys", () => {
190
+ expect(names([named("a", "マヤ1"), named("b", "レオ1")])).toEqual([
191
+ ["a", "マヤ1", "character-1"],
192
+ ["b", "レオ1", "character-2"],
193
+ ])
194
+ expect(names([named("a", "マヤ A"), named("b", "A")])).toEqual([
195
+ ["a", "マヤ A", "character-1"],
196
+ ["b", "A", "a"],
197
+ ])
198
+ expect(names([named("b", "A"), unnamed("u"), named("a", "マヤ A")])).toEqual([
199
+ ["b", "A", "a"],
200
+ ["u", "Character 1", "character-1"],
201
+ ["a", "マヤ A", "character-2"],
202
+ ])
203
+ })
204
+
205
+ it("the same mixed-script name twice is one character", () => {
206
+ expect(names([named("a", "マヤ1"), named("b", "マヤ1")])).toEqual([
207
+ ["a", "マヤ1", "1"],
208
+ ["b", "マヤ1", "1"],
209
+ ])
210
+ const m = wiredCharacterNames([named("a", "マヤ A"), named("b", "マヤ a"), named("c", "レオ1"), named("d", "レオ1"), named("e", "ハナ1")])
211
+ expect(m.get("a")?.slug).toBe(m.get("b")?.slug)
212
+ expect(m.get("c")?.slug).toBe(m.get("d")?.slug)
213
+ expect(new Set([...m.values()].map((n) => n.slug)).size).toBe(3)
214
+ })
215
+
216
+ it("a mixed-script name no other character claims keeps its old mention key", () => {
217
+ expect(names([named("a", "マヤ A"), named("b", "Leo"), unnamed("u")])).toEqual([
218
+ ["a", "マヤ A", "a"],
219
+ ["b", "Leo", "leo"],
220
+ ["u", "Character 1", "character-1"],
221
+ ])
222
+ })
223
+
224
+ it("a name whose letters are all Latin, accents included, keeps its slug as before", () => {
225
+ expect(names([named("a", "José"), named("b", "Ana-María")])).toEqual([
226
+ ["a", "José", "jos"],
227
+ ["b", "Ana-María", "ana-mar-a"],
228
+ ])
229
+ })
230
+
231
+ // An all-Latin name the slug cannot spell follows the same-name rule (decided 2026-11-13).
232
+ it("all-Latin names the slug cannot spell: the same one twice is one character, two different ones stay two", () => {
233
+ expect(names([named("a", "Ñ"), named("b", "Ñ")])).toEqual([
234
+ ["a", "Ñ", "character-1"],
235
+ ["b", "Ñ", "character-1"],
236
+ ])
237
+ expect(names([named("a", "Ñ"), named("b", "Ö")])).toEqual([
238
+ ["a", "Ñ", "character-1"],
239
+ ["b", "Ö", "character-2"],
240
+ ])
241
+ expect(names([named("a", "Ö"), named("b", "ö")]).map(([, , slug]) => slug)).toEqual(["character-1", "character-1"])
242
+ })
243
+
244
+ it("a name with no letter or digit never matches another", () => {
245
+ expect(names([named("a", "!!!"), named("b", "!!!")])).toEqual([
246
+ ["a", "!!!", "character-1"],
247
+ ["b", "!!!", "character-2"],
248
+ ])
249
+ })
250
+ })
251
+
132
252
  it("unnamed flags the nodes with no name of their own (a slug-less typed name is not one)", () => {
133
253
  const m = wiredCharacterNames([named("a", "Maya"), unnamed("b"), named("c", "マヤ")])
134
254
  expect(m.get("a")?.unnamed).toBe(false)
@@ -167,6 +287,28 @@ describe("wiredCharacterKey — where a Character node's own elements are filed"
167
287
  expect(wiredCharacterKey(m, "c", { characterName: "Maya" })).toBe("maya")
168
288
  expect(wiredCharacterKey(m, "d", { label: CHARACTER_NODE_DEFAULT_LABEL })).toBe("node:d")
169
289
  })
290
+ it("a non-Latin name wired only as a plain image: the key of the wired character with the same name", () => {
291
+ const withMaya = wiredCharacterNames([unnamed("b"), named("a", "マヤ")])
292
+ expect(wiredCharacterKey(withMaya, "c", { characterName: "マヤ" })).toBe("character-2")
293
+ expect(wiredCharacterSlug(withMaya, "c", { characterName: "マヤ" })).toBe("character-2")
294
+ // No wired character has it: a key of its own, never an unnamed node's.
295
+ expect(wiredCharacterKey(withMaya, "d", { characterName: "レオ" })).toBe("node:d")
296
+ expect(wiredCharacterSlug(withMaya, "d", { characterName: "レオ" })).toBe("")
297
+ })
298
+ it("a mixed-script name wired only as a plain image is never filed under a Latin character sharing its remainder", () => {
299
+ const withA = wiredCharacterNames([named("b", "A"), named("m", "マヤ A")])
300
+ expect(wiredCharacterKey(withA, "c", { characterName: "マヤ A" })).toBe(withA.get("m")!.slug)
301
+ expect(wiredCharacterKey(withA, "c", { characterName: "レオ A" })).toBe("node:c")
302
+ expect(wiredCharacterKey(withA, "d", { characterName: "A" })).toBe("a")
303
+ })
304
+ it("a Latin name wired only as a plain image is never filed under a mixed-script character that goes by its slug", () => {
305
+ const onlyMaya = wiredCharacterNames([named("m", "マヤ A")])
306
+ expect(onlyMaya.get("m")?.slug).toBe("a")
307
+ expect(wiredCharacterKey(onlyMaya, "c", { characterName: "A" })).toBe("node:c")
308
+ expect(wiredCharacterSlug(onlyMaya, "c", { characterName: "A" })).toBe("")
309
+ // With no wired character on its slug, a Latin name keeps its own, as before.
310
+ expect(wiredCharacterKey(onlyMaya, "d", { characterName: "Leo" })).toBe("leo")
311
+ })
170
312
  })
171
313
 
172
314
  describe("aliasRetiredCharacterMentions — a mention saved before unnamed characters were numbered", () => {
@@ -46,9 +46,13 @@ export {
46
46
  SPEECH_PRICE_UNIT_CHARS,
47
47
  SPEECH_FLOOR_UNITS,
48
48
  SPEECH_UNIT_CREDIT_SUFFIX,
49
+ SPEECH_PER_1K_CREDIT_SUFFIX,
49
50
  speechUnitCreditId,
51
+ speechRowUnits,
52
+ speechRowCredits,
50
53
  speechPriceUnits,
51
54
  speechCredits,
55
+ speechCreditsFor,
52
56
  speechQuoteCreditId,
53
57
  parseSpeechQuoteCreditId,
54
58
  isSpeechLengthPriceId,