@nodaro/shared 3.64.0 → 3.66.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.
- package/dist/{chunk-J6B7J73J.cjs → chunk-23IKLMRL.cjs} +49 -49
- package/dist/{chunk-J6B7J73J.cjs.map → chunk-23IKLMRL.cjs.map} +1 -1
- package/dist/chunk-27HA6YOL.cjs +377 -0
- package/dist/chunk-27HA6YOL.cjs.map +1 -0
- package/dist/{chunk-OOZW2MM6.cjs → chunk-37ZSFS6A.cjs} +9 -9
- package/dist/{chunk-OOZW2MM6.cjs.map → chunk-37ZSFS6A.cjs.map} +1 -1
- package/dist/{chunk-AZNZ5WNZ.cjs → chunk-3L7GMQ4M.cjs} +142 -45
- package/dist/chunk-3L7GMQ4M.cjs.map +1 -0
- package/dist/{chunk-SXHHLZ22.js → chunk-3QJ3UR5Z.js} +9 -9
- package/dist/{chunk-SXHHLZ22.js.map → chunk-3QJ3UR5Z.js.map} +1 -1
- package/dist/chunk-3YWZ5SOZ.js +164 -0
- package/dist/chunk-3YWZ5SOZ.js.map +1 -0
- package/dist/{chunk-TTGZ2L3O.js → chunk-5GG4CG4Y.js} +3 -3
- package/dist/{chunk-TTGZ2L3O.js.map → chunk-5GG4CG4Y.js.map} +1 -1
- package/dist/{chunk-3KTWYYCN.js → chunk-5IZHECUP.js} +3 -3
- package/dist/{chunk-3KTWYYCN.js.map → chunk-5IZHECUP.js.map} +1 -1
- package/dist/{chunk-Q2Y4JHF7.js → chunk-5J2LIQYU.js} +5 -5
- package/dist/{chunk-Q2Y4JHF7.js.map → chunk-5J2LIQYU.js.map} +1 -1
- package/dist/{chunk-SHH2T4CR.js → chunk-5LWYX4GV.js} +3 -3
- package/dist/{chunk-SHH2T4CR.js.map → chunk-5LWYX4GV.js.map} +1 -1
- package/dist/{chunk-7AJGUI7L.cjs → chunk-5NVGKXJV.cjs} +34 -17
- package/dist/chunk-5NVGKXJV.cjs.map +1 -0
- package/dist/{chunk-D4KWNDPH.cjs → chunk-66QSUUB4.cjs} +12 -12
- package/dist/{chunk-D4KWNDPH.cjs.map → chunk-66QSUUB4.cjs.map} +1 -1
- package/dist/{chunk-KHH54GRP.cjs → chunk-6ET3KDO4.cjs} +15 -338
- package/dist/chunk-6ET3KDO4.cjs.map +1 -0
- package/dist/{chunk-ZI3QDUHO.js → chunk-AT53ZQUC.js} +3 -3
- package/dist/{chunk-ZI3QDUHO.js.map → chunk-AT53ZQUC.js.map} +1 -1
- package/dist/chunk-BMDOPJBP.cjs +185 -0
- package/dist/chunk-BMDOPJBP.cjs.map +1 -0
- package/dist/{chunk-PJJAZQVZ.js → chunk-BNR5FKL5.js} +3 -3
- package/dist/{chunk-PJJAZQVZ.js.map → chunk-BNR5FKL5.js.map} +1 -1
- package/dist/{chunk-5OBTGNUQ.cjs → chunk-E62W5I6A.cjs} +298 -2
- package/dist/chunk-E62W5I6A.cjs.map +1 -0
- package/dist/{chunk-GTWUS6MQ.cjs → chunk-EFYWV2V5.cjs} +61 -61
- package/dist/{chunk-GTWUS6MQ.cjs.map → chunk-EFYWV2V5.cjs.map} +1 -1
- package/dist/chunk-F6XIH3TZ.cjs +168 -0
- package/dist/chunk-F6XIH3TZ.cjs.map +1 -0
- package/dist/{chunk-NIAFR5EE.js → chunk-FGBGKBML.js} +32 -3
- package/dist/chunk-FGBGKBML.js.map +1 -0
- package/dist/{chunk-YQV53HRR.cjs → chunk-G2G7XGFU.cjs} +7 -7
- package/dist/{chunk-YQV53HRR.cjs.map → chunk-G2G7XGFU.cjs.map} +1 -1
- package/dist/{chunk-7KQ6W5DS.js → chunk-GF7ZA26H.js} +4 -4
- package/dist/{chunk-7KQ6W5DS.js.map → chunk-GF7ZA26H.js.map} +1 -1
- package/dist/{chunk-SPAHI7DY.cjs → chunk-GNLA5NTT.cjs} +4 -4
- package/dist/{chunk-SPAHI7DY.cjs.map → chunk-GNLA5NTT.cjs.map} +1 -1
- package/dist/{chunk-VPTA4Z7G.js → chunk-GTBW2KAY.js} +5 -5
- package/dist/{chunk-VPTA4Z7G.js.map → chunk-GTBW2KAY.js.map} +1 -1
- package/dist/{chunk-CHS2SIP6.cjs → chunk-HTDKEYMY.cjs} +90 -76
- package/dist/chunk-HTDKEYMY.cjs.map +1 -0
- package/dist/{chunk-EXEVT6D2.cjs → chunk-IWUW3YPM.cjs} +5 -5
- package/dist/{chunk-EXEVT6D2.cjs.map → chunk-IWUW3YPM.cjs.map} +1 -1
- package/dist/{chunk-ACZZHHFZ.cjs → chunk-JTYCJ5OL.cjs} +44 -22
- package/dist/chunk-JTYCJ5OL.cjs.map +1 -0
- package/dist/{chunk-HDPJNNMF.cjs → chunk-M5QY464F.cjs} +21 -21
- package/dist/{chunk-HDPJNNMF.cjs.map → chunk-M5QY464F.cjs.map} +1 -1
- package/dist/{chunk-DZ4IOP3Q.js → chunk-MVXZP6VB.js} +281 -3
- package/dist/chunk-MVXZP6VB.js.map +1 -0
- package/dist/{chunk-Y4GCJJPF.cjs → chunk-NYZQOIXJ.cjs} +35 -2
- package/dist/chunk-NYZQOIXJ.cjs.map +1 -0
- package/dist/{chunk-KB2SQAR3.js → chunk-OFQ6CU6S.js} +3 -3
- package/dist/{chunk-KB2SQAR3.js.map → chunk-OFQ6CU6S.js.map} +1 -1
- package/dist/{chunk-36VWLB4J.js → chunk-OXBU5AGH.js} +3 -3
- package/dist/{chunk-36VWLB4J.js.map → chunk-OXBU5AGH.js.map} +1 -1
- package/dist/{chunk-CHTZZRAL.cjs → chunk-OXTF4Y3P.cjs} +6 -6
- package/dist/{chunk-CHTZZRAL.cjs.map → chunk-OXTF4Y3P.cjs.map} +1 -1
- package/dist/{chunk-3AYM47GW.js → chunk-PAUWEWTY.js} +99 -9
- package/dist/chunk-PAUWEWTY.js.map +1 -0
- package/dist/{chunk-FHGRKQVZ.cjs → chunk-PGDR7CO3.cjs} +8 -8
- package/dist/{chunk-FHGRKQVZ.cjs.map → chunk-PGDR7CO3.cjs.map} +1 -1
- package/dist/{chunk-W6VJAUGM.cjs → chunk-PJAJCFLP.cjs} +94 -37
- package/dist/chunk-PJAJCFLP.cjs.map +1 -0
- package/dist/{chunk-IYSOVS7O.js → chunk-RVQW623D.js} +31 -13
- package/dist/chunk-RVQW623D.js.map +1 -0
- package/dist/{chunk-TPQJKS7D.js → chunk-SCDE676D.js} +21 -7
- package/dist/{chunk-CHS2SIP6.cjs.map → chunk-SCDE676D.js.map} +1 -1
- package/dist/chunk-SW5ZD7BO.js +143 -0
- package/dist/chunk-SW5ZD7BO.js.map +1 -0
- package/dist/{chunk-T2OVDF2M.cjs → chunk-T4GIHHXY.cjs} +6 -6
- package/dist/{chunk-T2OVDF2M.cjs.map → chunk-T4GIHHXY.cjs.map} +1 -1
- package/dist/{chunk-QYU7J5EQ.js → chunk-V6OXSXIX.js} +29 -18
- package/dist/chunk-V6OXSXIX.js.map +1 -0
- package/dist/{chunk-W7KHHNZR.js → chunk-VBP4DH37.js} +61 -9
- package/dist/chunk-VBP4DH37.js.map +1 -0
- package/dist/{chunk-67CMMTLN.cjs → chunk-WZG6GZIL.cjs} +4 -4
- package/dist/{chunk-67CMMTLN.cjs.map → chunk-WZG6GZIL.cjs.map} +1 -1
- package/dist/{chunk-O4RPXBDZ.cjs → chunk-X2YHKP4D.cjs} +8 -8
- package/dist/{chunk-O4RPXBDZ.cjs.map → chunk-X2YHKP4D.cjs.map} +1 -1
- package/dist/{chunk-OBOOHG3N.js → chunk-XEPKONJC.js} +3 -3
- package/dist/{chunk-OBOOHG3N.js.map → chunk-XEPKONJC.js.map} +1 -1
- package/dist/{chunk-O7RZRUMZ.js → chunk-XJWED257.js} +14 -309
- package/dist/chunk-XJWED257.js.map +1 -0
- package/dist/chunk-XSSLNINL.js +346 -0
- package/dist/chunk-XSSLNINL.js.map +1 -0
- package/dist/{chunk-4IUE2JB7.js → chunk-Z77M7Q2R.js} +3 -3
- package/dist/{chunk-4IUE2JB7.js.map → chunk-Z77M7Q2R.js.map} +1 -1
- package/dist/entries/apps.cjs +42 -42
- package/dist/entries/apps.js +7 -7
- package/dist/entries/captions.d.cts +1 -1
- package/dist/entries/captions.d.ts +1 -1
- package/dist/entries/credits.cjs +230 -214
- package/dist/entries/credits.d.cts +51 -14
- package/dist/entries/credits.d.ts +51 -14
- package/dist/entries/credits.js +10 -10
- package/dist/entries/entities.cjs +202 -193
- package/dist/entries/entities.d.cts +44 -9
- package/dist/entries/entities.d.ts +44 -9
- package/dist/entries/entities.js +2 -1
- package/dist/entries/llm-models.cjs +86 -62
- package/dist/entries/llm-models.d.cts +46 -15
- package/dist/entries/llm-models.d.ts +46 -15
- package/dist/entries/llm-models.js +2 -2
- package/dist/entries/media.cjs +79 -63
- package/dist/entries/media.d.cts +154 -1
- package/dist/entries/media.d.ts +154 -1
- package/dist/entries/media.js +1 -1
- package/dist/entries/model-catalog.cjs +175 -119
- package/dist/entries/model-catalog.d.cts +4 -54
- package/dist/entries/model-catalog.d.ts +4 -54
- package/dist/entries/model-catalog.js +4 -4
- package/dist/entries/models.cjs +503 -358
- package/dist/entries/models.d.cts +86 -7
- package/dist/entries/models.d.ts +86 -7
- package/dist/entries/models.js +6 -5
- package/dist/entries/nodes.cjs +212 -212
- package/dist/entries/nodes.d.cts +1 -1
- package/dist/entries/nodes.d.ts +1 -1
- package/dist/entries/nodes.js +8 -8
- package/dist/entries/pipeline.cjs +153 -153
- package/dist/entries/pipeline.d.cts +3 -3
- package/dist/entries/pipeline.d.ts +3 -3
- package/dist/entries/pipeline.js +3 -3
- package/dist/entries/social.cjs +177 -177
- package/dist/entries/social.js +2 -2
- package/dist/entries/ugc.cjs +71 -71
- package/dist/entries/ugc.js +4 -4
- package/dist/entries/video.cjs +174 -145
- package/dist/entries/video.d.cts +119 -2
- package/dist/entries/video.d.ts +119 -2
- package/dist/entries/video.js +7 -6
- package/dist/entries/workflow.d.cts +1 -1
- package/dist/entries/workflow.d.ts +1 -1
- package/dist/index.cjs +2086 -1793
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +24 -23
- package/dist/{model-catalog-Cf9fkEUp.d.ts → model-catalog-B-aQnUS8.d.cts} +186 -2
- package/dist/{model-catalog-Cf9fkEUp.d.cts → model-catalog-B-aQnUS8.d.ts} +186 -2
- package/dist/{model-constants-C_Nyft_i.d.cts → model-constants-BstsUup6.d.cts} +105 -6
- package/dist/{model-constants-BxjiWVQ9.d.ts → model-constants-DZ3tPGFO.d.ts} +105 -6
- package/dist/tts-capabilities-BJ4N8MIB.d.ts +133 -0
- package/dist/tts-capabilities-Cf_4nu1Z.d.cts +133 -0
- package/package.json +1 -1
- package/src/__tests__/dialogue-capabilities.test.ts +167 -6
- package/src/__tests__/extend-providers.test.ts +87 -0
- package/src/__tests__/flux-3-klein.test.ts +51 -3
- package/src/__tests__/image-run-limit.test.ts +96 -0
- package/src/__tests__/kling4-catalog.test.ts +1 -1
- package/src/__tests__/llm-models.test.ts +41 -4
- package/src/__tests__/seedream-5-5.test.ts +17 -0
- package/src/__tests__/speech-pricing.test.ts +62 -1
- package/src/__tests__/tts-capabilities.test.ts +160 -4
- package/src/__tests__/video-analysis-pricing.test.ts +13 -1
- package/src/__tests__/video-subjects.test.ts +209 -0
- package/src/__tests__/wired-character-names.test.ts +142 -0
- package/src/credit-estimators/index.ts +4 -0
- package/src/credit-estimators/speech.ts +57 -9
- package/src/credit-identifiers.ts +48 -13
- package/src/dialogue-capabilities.ts +220 -3
- package/src/dubbing-structure.ts +186 -0
- package/src/entries/entities.ts +2 -0
- package/src/entries/llm-models.ts +7 -0
- package/src/entries/media.ts +3 -1
- package/src/entries/model-catalog.ts +17 -0
- package/src/entries/models.ts +43 -0
- package/src/entries/video.ts +8 -1
- package/src/gemini-tts.ts +144 -0
- package/src/llm-models.ts +71 -21
- package/src/model-catalog.ts +283 -2
- package/src/model-constants.ts +167 -8
- package/src/tts-capabilities.ts +193 -1
- package/src/video-analysis-pricing.ts +11 -0
- package/src/video-character-refs.ts +165 -3
- package/src/wired-character-names.ts +134 -18
- package/src/wired-character-video-subjects.ts +63 -0
- package/dist/chunk-3AYM47GW.js.map +0 -1
- package/dist/chunk-5OBTGNUQ.cjs.map +0 -1
- package/dist/chunk-6YIV37V7.js +0 -31
- package/dist/chunk-6YIV37V7.js.map +0 -1
- package/dist/chunk-7AJGUI7L.cjs.map +0 -1
- package/dist/chunk-ACZZHHFZ.cjs.map +0 -1
- package/dist/chunk-AZNZ5WNZ.cjs.map +0 -1
- package/dist/chunk-DZ4IOP3Q.js.map +0 -1
- package/dist/chunk-IYSOVS7O.js.map +0 -1
- package/dist/chunk-KHH54GRP.cjs.map +0 -1
- package/dist/chunk-NIAFR5EE.js.map +0 -1
- package/dist/chunk-O7RZRUMZ.js.map +0 -1
- package/dist/chunk-QYU7J5EQ.js.map +0 -1
- package/dist/chunk-S3UGLZSF.js +0 -42
- package/dist/chunk-S3UGLZSF.js.map +0 -1
- package/dist/chunk-TPQJKS7D.js.map +0 -1
- package/dist/chunk-TQW3R44P.cjs +0 -38
- package/dist/chunk-TQW3R44P.cjs.map +0 -1
- package/dist/chunk-VZ6TE23U.cjs +0 -54
- package/dist/chunk-VZ6TE23U.cjs.map +0 -1
- package/dist/chunk-W6VJAUGM.cjs.map +0 -1
- package/dist/chunk-W7KHHNZR.js.map +0 -1
- package/dist/chunk-Y4GCJJPF.cjs.map +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
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 and
|
|
23
|
+
* counts them with the reference videos (5 in all, one total length) — so the
|
|
24
|
+
* clip is SEATED among the reference videos, and every reference-video seam
|
|
25
|
+
* measures and caps it. Neither model bills it as a reference video (decided
|
|
26
|
+
* 2026-11-14), so the price leaves it out (`pricedReferenceVideoUrls`).
|
|
27
|
+
*/
|
|
28
|
+
const clip = (n: number) => `https://cdn.example/clip-${n}.mp4`
|
|
29
|
+
const ref = (n: number) => `https://cdn.example/ref-${n}.mp4`
|
|
30
|
+
const character = (videoUrl?: string) => ({ imageUrl: "https://cdn.example/p.png", description: "d", ...(videoUrl ? { videoUrl } : {}) })
|
|
31
|
+
|
|
32
|
+
describe("which models take video subjects (data)", () => {
|
|
33
|
+
it("Kling 4.0 and Kling 4.0 Flash, 3 each; nothing else", () => {
|
|
34
|
+
expect(videoCharacterVideoProviders()).toEqual(["kling-4", "kling-4-flash"])
|
|
35
|
+
expect(videoCharacterVideoCap("kling-4")).toBe(3)
|
|
36
|
+
expect(videoCharacterVideoCap("kling-4-flash")).toBe(3)
|
|
37
|
+
expect(videoCharacterVideoCap("gemini-omni-video")).toBe(0)
|
|
38
|
+
expect(videoCharacterVideoCap("seedance-2")).toBe(0)
|
|
39
|
+
expect(videoCharacterVideoCap(undefined)).toBe(0)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("a model that takes video subjects bills reference-video seconds and bounds a clip at 3-8 s", () => {
|
|
43
|
+
for (const id of videoCharacterVideoProviders()) {
|
|
44
|
+
expect(VIDEO_REF_VIDEO_DURATION_LIMITS[id], id).toBeDefined()
|
|
45
|
+
expect(VIDEO_CHARACTER_CLIP_DURATION_LIMITS[id], id).toEqual({ minSec: 3, maxSec: 8 })
|
|
46
|
+
expect(VIDEO_REF_LIMITS_BY_PROVIDER[id]?.videos, id).toBe(5)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// Decided 2026-11-14, from measured runs: Kling 4.0 and Kling 4.0 Flash both
|
|
52
|
+
// bill a video subject like an image subject. The flag stays, unset, for a
|
|
53
|
+
// model whose provider bills the clip as reference video.
|
|
54
|
+
describe("how a video subject is priced, per model (data)", () => {
|
|
55
|
+
it("no model bills it as reference video today: Kling 4.0 and Kling 4.0 Flash price it like an image subject", () => {
|
|
56
|
+
expect(videoCharacterClipsBilledAsReferenceVideo("kling-4")).toBe(false)
|
|
57
|
+
expect(videoCharacterClipsBilledAsReferenceVideo("kling-4-flash")).toBe(false)
|
|
58
|
+
expect(videoCharacterClipsBilledAsReferenceVideo(undefined)).toBe(false)
|
|
59
|
+
for (const [id, limits] of Object.entries(VIDEO_REF_LIMITS_BY_PROVIDER)) {
|
|
60
|
+
expect(limits?.videoCharactersBillAsReferenceVideo, id).toBeUndefined()
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it("pricedReferenceVideoUrls: a character's clip leaves the priced list on both Kling 4.0 ids; plain reference videos stay", () => {
|
|
65
|
+
const seated = [ref(1), clip(1)]
|
|
66
|
+
const characters = [character(clip(1)), character()]
|
|
67
|
+
for (const provider of ["kling-4", "kling-4-flash"]) {
|
|
68
|
+
expect(pricedReferenceVideoUrls({ provider, referenceVideoUrls: seated, characterReferences: characters }), provider).toEqual([ref(1)])
|
|
69
|
+
expect(pricedReferenceVideoUrls({ provider, referenceVideoUrls: [clip(1)], characterReferences: characters }), provider).toEqual([])
|
|
70
|
+
// Nothing to leave out: the same value.
|
|
71
|
+
const plain = [ref(1)]
|
|
72
|
+
expect(pricedReferenceVideoUrls({ provider, referenceVideoUrls: plain, characterReferences: characters }), provider).toBe(plain)
|
|
73
|
+
}
|
|
74
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4-flash", referenceVideoUrls: undefined, characterReferences: undefined })).toBeUndefined()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("a model that declares the flag keeps the clip in the priced list, as sent", () => {
|
|
78
|
+
const row = VIDEO_REF_LIMITS_BY_PROVIDER["kling-4"]!
|
|
79
|
+
VIDEO_REF_LIMITS_BY_PROVIDER["kling-4"] = { ...row, videoCharactersBillAsReferenceVideo: true }
|
|
80
|
+
try {
|
|
81
|
+
expect(videoCharacterClipsBilledAsReferenceVideo("kling-4")).toBe(true)
|
|
82
|
+
const seated = [ref(1), clip(1)]
|
|
83
|
+
expect(pricedReferenceVideoUrls({ provider: "kling-4", referenceVideoUrls: seated, characterReferences: [character(clip(1))] })).toBe(seated)
|
|
84
|
+
} finally {
|
|
85
|
+
VIDEO_REF_LIMITS_BY_PROVIDER["kling-4"] = row
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
describe("seatCharacterVideos — a character's clip rides as one more reference video", () => {
|
|
91
|
+
it("no clip: the list as it came, the same value — within the model's cap", () => {
|
|
92
|
+
const refs = [ref(1)]
|
|
93
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: refs, characterReferences: [character()] })
|
|
94
|
+
expect(out).toEqual({ ok: true, referenceVideoUrls: refs })
|
|
95
|
+
expect(out.ok && out.referenceVideoUrls).toBe(refs)
|
|
96
|
+
expect(seatCharacterVideos({ provider: "seedance-2", referenceVideoUrls: undefined, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: undefined })
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it("clips follow the reference videos, in character order", () => {
|
|
100
|
+
expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: [ref(1)], characterReferences: [character(clip(1)), character(), character(clip(2))] }))
|
|
101
|
+
.toEqual({ ok: true, referenceVideoUrls: [ref(1), clip(1), clip(2)] })
|
|
102
|
+
expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: undefined, characterReferences: [character(` ${clip(1)} `)] }))
|
|
103
|
+
.toEqual({ ok: true, referenceVideoUrls: [clip(1)] })
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it("a clip already wired as a reference video keeps its seat (it is the subject only)", () => {
|
|
107
|
+
expect(seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [clip(1), ref(1)], characterReferences: [character(clip(1))] }))
|
|
108
|
+
.toEqual({ ok: true, referenceVideoUrls: [clip(1), ref(1)] })
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it("refused on a model that takes none, naming the ones that do", () => {
|
|
112
|
+
const out = seatCharacterVideos({ provider: "gemini-omni-video", referenceVideoUrls: [], characterReferences: [character(clip(1))] })
|
|
113
|
+
expect(out.ok).toBe(false)
|
|
114
|
+
if (!out.ok) {
|
|
115
|
+
expect(out.code).toBe("character_video_unsupported")
|
|
116
|
+
expect(out.message).toContain("kling-4, kling-4-flash")
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it("refused past 3 characters made from a video", () => {
|
|
121
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [1, 2, 3, 4].map((n) => character(clip(n))) })
|
|
122
|
+
expect(out.ok === false && out.code).toBe("character_videos_over_limit")
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it("refused when two characters carry the same clip", () => {
|
|
126
|
+
const out = seatCharacterVideos({ provider: "kling-4", referenceVideoUrls: [], characterReferences: [character(clip(1)), character(clip(1))] })
|
|
127
|
+
expect(out.ok === false && out.code).toBe("character_video_shared")
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it("refused when reference videos and clips together pass the model's 5 videos", () => {
|
|
131
|
+
const four = [1, 2, 3, 4].map(ref)
|
|
132
|
+
expect(seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1))] }).ok).toBe(true)
|
|
133
|
+
const out = seatCharacterVideos({ provider: "kling-4-flash", referenceVideoUrls: four, characterReferences: [character(clip(1)), character(clip(2))] })
|
|
134
|
+
expect(out.ok === false && out.code).toBe("reference_videos_over_limit")
|
|
135
|
+
if (!out.ok) expect(out.message).toContain("This run has 6")
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// Decided 2026-11-13: on a model whose reference videos and video subjects
|
|
139
|
+
// share one cap, plain reference videos past it are refused, never left out.
|
|
140
|
+
it("plain reference videos alone past 5 are refused on Kling 4.0 and Flash; another model's list is not judged", () => {
|
|
141
|
+
const six = [1, 2, 3, 4, 5, 6].map(ref)
|
|
142
|
+
for (const provider of ["kling-4", "kling-4-flash"]) {
|
|
143
|
+
const out = seatCharacterVideos({ provider, referenceVideoUrls: six, characterReferences: undefined })
|
|
144
|
+
expect(out.ok === false && out.code, provider).toBe("reference_videos_over_limit")
|
|
145
|
+
if (!out.ok) {
|
|
146
|
+
expect(out.message).toContain("This run has 6")
|
|
147
|
+
expect(out.message).not.toContain("from a character")
|
|
148
|
+
}
|
|
149
|
+
expect(seatCharacterVideos({ provider, referenceVideoUrls: six.slice(0, 5), characterReferences: [] }).ok).toBe(true)
|
|
150
|
+
}
|
|
151
|
+
expect(seatCharacterVideos({ provider: "seedance-2-5", referenceVideoUrls: six, characterReferences: undefined })).toEqual({ ok: true, referenceVideoUrls: six })
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it("characterVideoUrls reads only non-empty string clips", () => {
|
|
155
|
+
expect(characterVideoUrls([character(clip(1)), character(), { videoUrl: " " }, { videoUrl: 7 }, null])).toEqual([clip(1)])
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
describe("checkCharacterClipDurations — 3-8 s, measured", () => {
|
|
160
|
+
it("in bounds passes; outside is refused with the clip's length", () => {
|
|
161
|
+
expect(checkCharacterClipDurations("kling-4", [3, 8, 5.5])).toEqual({ ok: true })
|
|
162
|
+
const short = checkCharacterClipDurations("kling-4-flash", [2.4])
|
|
163
|
+
expect(short.ok === false && short.code).toBe("video_too_long")
|
|
164
|
+
if (!short.ok) expect(short.message).toContain("one is 2.40 s")
|
|
165
|
+
expect(checkCharacterClipDurations("kling-4", [8.6]).ok).toBe(false)
|
|
166
|
+
// The measured length, rounded up to hundredths: 8.03 s never reads as 8.0.
|
|
167
|
+
const justOver = checkCharacterClipDurations("kling-4", [8.0281])
|
|
168
|
+
expect(justOver.ok === false && justOver.message).toContain("one is 8.03 s")
|
|
169
|
+
const tiny = checkCharacterClipDurations("kling-4", [8.001])
|
|
170
|
+
expect(tiny.ok === false && tiny.message).toContain("one is 8.01 s")
|
|
171
|
+
expect(checkCharacterClipDurations("seedance-2", [30])).toEqual({ ok: true })
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// Decided 2026-11-13: a character's clip must be measured to be accepted.
|
|
175
|
+
it("a clip the probe could not read (NaN, 0) is refused, unlike a reference video", () => {
|
|
176
|
+
for (const d of [Number.NaN, 0]) {
|
|
177
|
+
const out = checkCharacterClipDurations("kling-4", [5, d])
|
|
178
|
+
expect(out.ok === false && out.code).toBe("character_video_unreadable")
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
describe("a wired Character node's clip reaches its character reference", () => {
|
|
184
|
+
const characterNode = (id: string, data: Record<string, unknown>) => ({ id, type: "character", data: { label: CHARACTER_NODE_DEFAULT_LABEL, characterName: "", ...data } })
|
|
185
|
+
const wire = (source: string) => ({ source, target: "gv", sourceHandle: "characterRef" })
|
|
186
|
+
|
|
187
|
+
it("wiredCharacterVideoUrls: by the slug the node goes by; the first clip of a merged name wins; a plain image wire gives none", () => {
|
|
188
|
+
const nodes = [
|
|
189
|
+
characterNode("a", { characterName: "Maya", subjectVideoUrl: clip(1) }),
|
|
190
|
+
characterNode("b", { characterName: "Maya", subjectVideoUrl: clip(2) }),
|
|
191
|
+
characterNode("u", { subjectVideoUrl: ` ${clip(3)} ` }),
|
|
192
|
+
characterNode("i", { characterName: "Leo", subjectVideoUrl: clip(4) }),
|
|
193
|
+
characterNode("n", { characterName: "Noa" }),
|
|
194
|
+
]
|
|
195
|
+
const edges = [wire("a"), wire("b"), wire("u"), { source: "i", target: "gv", sourceHandle: "image" }, wire("n")]
|
|
196
|
+
expect([...wiredCharacterVideoUrls("gv", nodes, edges)]).toEqual([["maya", clip(1)], ["character-1", clip(3)]])
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it("characterReferencesFromWired carries the clip of the character it names", () => {
|
|
200
|
+
const entry = (slug: string, name: string): ConnectedReference => ({
|
|
201
|
+
id: `char_${slug}`, defaultName: name, source: "wired-character", url: `https://cdn.example/${slug}.png`, characterSlug: slug,
|
|
202
|
+
})
|
|
203
|
+
const refs = characterReferencesFromWired([entry("maya", "Maya"), entry("leo", "Leo")], new Map([["maya", clip(1)]]))
|
|
204
|
+
expect(refs.map((r) => [r.name, r.videoUrl])).toEqual([["Maya", clip(1)], ["Leo", undefined]])
|
|
205
|
+
expect("videoUrl" in refs[1]!).toBe(false)
|
|
206
|
+
// Without the map (a model that takes no video subjects): no clip at all.
|
|
207
|
+
expect(characterReferencesFromWired([entry("maya", "Maya")]).every((r) => !("videoUrl" in r))).toBe(true)
|
|
208
|
+
})
|
|
209
|
+
})
|
|
@@ -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,
|
|
@@ -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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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`
|
|
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`
|
|
105
|
-
*
|
|
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" &&
|
|
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(
|
|
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
|
|
1015
|
-
* when
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
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
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
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
|
}
|