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