@nodaro/shared 3.70.0 → 3.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/{chunk-FMQ43SJP.cjs → chunk-4A3ITJJB.cjs} +6 -6
  2. package/dist/{chunk-FMQ43SJP.cjs.map → chunk-4A3ITJJB.cjs.map} +1 -1
  3. package/dist/{chunk-XBHDXURR.cjs → chunk-4HV3LY4A.cjs} +78 -78
  4. package/dist/chunk-4HV3LY4A.cjs.map +1 -0
  5. package/dist/{chunk-52JNQG4K.js → chunk-6FUVGATF.js} +3 -3
  6. package/dist/{chunk-52JNQG4K.js.map → chunk-6FUVGATF.js.map} +1 -1
  7. package/dist/{chunk-GC77W57T.cjs → chunk-6PEWM2B3.cjs} +9 -9
  8. package/dist/{chunk-GC77W57T.cjs.map → chunk-6PEWM2B3.cjs.map} +1 -1
  9. package/dist/{chunk-BIQ7COJP.js → chunk-BO6IKV24.js} +5 -5
  10. package/dist/{chunk-BIQ7COJP.js.map → chunk-BO6IKV24.js.map} +1 -1
  11. package/dist/{chunk-IKN54UGB.js → chunk-BQV6NV7E.js} +3 -3
  12. package/dist/{chunk-IKN54UGB.js.map → chunk-BQV6NV7E.js.map} +1 -1
  13. package/dist/{chunk-LTBM2KMY.js → chunk-BVP4M5AK.js} +235 -9
  14. package/dist/chunk-BVP4M5AK.js.map +1 -0
  15. package/dist/{chunk-OW5AXH2Y.js → chunk-CL7ECTK2.js} +5 -4
  16. package/dist/chunk-CL7ECTK2.js.map +1 -0
  17. package/dist/{chunk-R22UHRR6.js → chunk-COA2OJIH.js} +39 -23
  18. package/dist/chunk-COA2OJIH.js.map +1 -0
  19. package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
  20. package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
  21. package/dist/{chunk-EWNDK4FV.js → chunk-F3XG5J5V.js} +3 -3
  22. package/dist/{chunk-EWNDK4FV.js.map → chunk-F3XG5J5V.js.map} +1 -1
  23. package/dist/{chunk-4U7QAUV3.cjs → chunk-H52P7DD2.cjs} +61 -61
  24. package/dist/{chunk-4U7QAUV3.cjs.map → chunk-H52P7DD2.cjs.map} +1 -1
  25. package/dist/{chunk-MZ772ZXA.cjs → chunk-HUCGHMOI.cjs} +17 -17
  26. package/dist/{chunk-MZ772ZXA.cjs.map → chunk-HUCGHMOI.cjs.map} +1 -1
  27. package/dist/{chunk-PYYYBINP.cjs → chunk-I4C6ZYU4.cjs} +6 -6
  28. package/dist/{chunk-PYYYBINP.cjs.map → chunk-I4C6ZYU4.cjs.map} +1 -1
  29. package/dist/{chunk-QCVQVKCI.js → chunk-JPSKVBYB.js} +3 -3
  30. package/dist/{chunk-QCVQVKCI.js.map → chunk-JPSKVBYB.js.map} +1 -1
  31. package/dist/{chunk-QVAUBB2T.js → chunk-K2P7KOIT.js} +9 -9
  32. package/dist/{chunk-QVAUBB2T.js.map → chunk-K2P7KOIT.js.map} +1 -1
  33. package/dist/{chunk-QV32JI4L.cjs → chunk-K5WRF2F3.cjs} +4 -4
  34. package/dist/{chunk-QV32JI4L.cjs.map → chunk-K5WRF2F3.cjs.map} +1 -1
  35. package/dist/{chunk-YLDY23N2.js → chunk-KD4UUCMW.js} +5 -5
  36. package/dist/{chunk-YLDY23N2.js.map → chunk-KD4UUCMW.js.map} +1 -1
  37. package/dist/{chunk-OZHE77T3.cjs → chunk-LBKMQAXD.cjs} +9 -9
  38. package/dist/{chunk-OZHE77T3.cjs.map → chunk-LBKMQAXD.cjs.map} +1 -1
  39. package/dist/{chunk-HBRDKHIW.cjs → chunk-MI4WEFJ4.cjs} +21 -21
  40. package/dist/{chunk-HBRDKHIW.cjs.map → chunk-MI4WEFJ4.cjs.map} +1 -1
  41. package/dist/{chunk-DOY47F7S.cjs → chunk-MN7BUGXF.cjs} +7 -7
  42. package/dist/{chunk-DOY47F7S.cjs.map → chunk-MN7BUGXF.cjs.map} +1 -1
  43. package/dist/{chunk-BLGZW3UF.cjs → chunk-NNCHSLFD.cjs} +291 -20
  44. package/dist/chunk-NNCHSLFD.cjs.map +1 -0
  45. package/dist/{chunk-NS34PZ2S.js → chunk-PPXUSZJU.js} +3 -3
  46. package/dist/{chunk-NS34PZ2S.js.map → chunk-PPXUSZJU.js.map} +1 -1
  47. package/dist/{chunk-PKWRAMVB.js → chunk-QME5O4NG.js} +7 -5
  48. package/dist/chunk-QME5O4NG.js.map +1 -0
  49. package/dist/{chunk-42ICEVUN.js → chunk-SAOIGWA2.js} +3 -3
  50. package/dist/{chunk-42ICEVUN.js.map → chunk-SAOIGWA2.js.map} +1 -1
  51. package/dist/{chunk-V6TC2NDG.js → chunk-SHSDGAI4.js} +4 -4
  52. package/dist/{chunk-V6TC2NDG.js.map → chunk-SHSDGAI4.js.map} +1 -1
  53. package/dist/{chunk-JEUZNHLL.cjs → chunk-SR7WH4FX.cjs} +33 -33
  54. package/dist/{chunk-JEUZNHLL.cjs.map → chunk-SR7WH4FX.cjs.map} +1 -1
  55. package/dist/{chunk-2VOXSVIE.js → chunk-SZ7ALYPK.js} +3 -3
  56. package/dist/{chunk-2VOXSVIE.js.map → chunk-SZ7ALYPK.js.map} +1 -1
  57. package/dist/{chunk-O53P2D4V.js → chunk-T4YYUI5Q.js} +3 -3
  58. package/dist/{chunk-O53P2D4V.js.map → chunk-T4YYUI5Q.js.map} +1 -1
  59. package/dist/{chunk-HWBLZSM3.cjs → chunk-TOYWEF6E.cjs} +39 -23
  60. package/dist/chunk-TOYWEF6E.cjs.map +1 -0
  61. package/dist/{chunk-FWPGRC4X.cjs → chunk-U6APV2PO.cjs} +5 -5
  62. package/dist/{chunk-FWPGRC4X.cjs.map → chunk-U6APV2PO.cjs.map} +1 -1
  63. package/dist/{chunk-QCZYYAPZ.cjs → chunk-UJIPIVTB.cjs} +48 -48
  64. package/dist/{chunk-QCZYYAPZ.cjs.map → chunk-UJIPIVTB.cjs.map} +1 -1
  65. package/dist/{chunk-KKFFQUMM.js → chunk-VZIMLPDC.js} +5 -5
  66. package/dist/chunk-VZIMLPDC.js.map +1 -0
  67. package/dist/{chunk-PWIKUOLB.cjs → chunk-W4CJ2P3F.cjs} +8 -8
  68. package/dist/{chunk-PWIKUOLB.cjs.map → chunk-W4CJ2P3F.cjs.map} +1 -1
  69. package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
  70. package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
  71. package/dist/{chunk-POZBRZUM.cjs → chunk-WHK3HTFY.cjs} +41 -41
  72. package/dist/{chunk-POZBRZUM.cjs.map → chunk-WHK3HTFY.cjs.map} +1 -1
  73. package/dist/{chunk-H2E4QXEZ.js → chunk-X3YRSRHP.js} +3 -3
  74. package/dist/{chunk-H2E4QXEZ.js.map → chunk-X3YRSRHP.js.map} +1 -1
  75. package/dist/{chunk-HA2PVTER.js → chunk-XK75VOEH.js} +4 -4
  76. package/dist/{chunk-HA2PVTER.js.map → chunk-XK75VOEH.js.map} +1 -1
  77. package/dist/{chunk-5DRSENY3.cjs → chunk-YHZUTPZL.cjs} +14 -12
  78. package/dist/{chunk-PKWRAMVB.js.map → chunk-YHZUTPZL.cjs.map} +1 -1
  79. package/dist/{chunk-WHV7MDNC.cjs → chunk-ZJQ2L3MI.cjs} +5 -3
  80. package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
  81. package/dist/entries/apps.cjs +42 -42
  82. package/dist/entries/apps.js +7 -7
  83. package/dist/entries/credits.cjs +418 -238
  84. package/dist/entries/credits.d.cts +262 -1
  85. package/dist/entries/credits.d.ts +262 -1
  86. package/dist/entries/credits.js +9 -9
  87. package/dist/entries/edl.cjs +60 -60
  88. package/dist/entries/edl.d.cts +96 -1
  89. package/dist/entries/edl.d.ts +96 -1
  90. package/dist/entries/edl.js +1 -1
  91. package/dist/entries/model-catalog.cjs +133 -133
  92. package/dist/entries/model-catalog.js +4 -4
  93. package/dist/entries/models.cjs +404 -404
  94. package/dist/entries/models.js +5 -5
  95. package/dist/entries/nodes.cjs +212 -212
  96. package/dist/entries/nodes.js +8 -8
  97. package/dist/entries/pipeline.cjs +153 -153
  98. package/dist/entries/pipeline.js +3 -3
  99. package/dist/entries/social.cjs +195 -191
  100. package/dist/entries/social.d.cts +9 -3
  101. package/dist/entries/social.d.ts +9 -3
  102. package/dist/entries/social.js +1 -1
  103. package/dist/entries/ugc.cjs +71 -71
  104. package/dist/entries/ugc.js +4 -4
  105. package/dist/entries/video.cjs +152 -152
  106. package/dist/entries/video.js +6 -6
  107. package/dist/index.cjs +1812 -1628
  108. package/dist/index.d.cts +3 -3
  109. package/dist/index.d.ts +3 -3
  110. package/dist/index.js +20 -20
  111. package/package.json +1 -1
  112. package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
  113. package/src/__tests__/competitors.test.ts +6 -1
  114. package/src/__tests__/credit-identifiers.test.ts +9 -10
  115. package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
  116. package/src/__tests__/video-to-video-pricing.test.ts +151 -0
  117. package/src/audio-isolation-pricing.ts +80 -0
  118. package/src/competitors.ts +8 -2
  119. package/src/credit-identifiers.ts +6 -0
  120. package/src/entries/credits.ts +54 -0
  121. package/src/entries/edl.ts +2 -0
  122. package/src/entries/social.ts +1 -0
  123. package/src/model-catalog.ts +34 -18
  124. package/src/motion-transfer-pricing.ts +239 -0
  125. package/src/producer-types.ts +2 -0
  126. package/src/use-case-output.ts +102 -0
  127. package/src/video-to-video-pricing.ts +248 -0
  128. package/dist/chunk-5DRSENY3.cjs.map +0 -1
  129. package/dist/chunk-BLGZW3UF.cjs.map +0 -1
  130. package/dist/chunk-HWBLZSM3.cjs.map +0 -1
  131. package/dist/chunk-KKFFQUMM.js.map +0 -1
  132. package/dist/chunk-LTBM2KMY.js.map +0 -1
  133. package/dist/chunk-OW5AXH2Y.js.map +0 -1
  134. package/dist/chunk-R22UHRR6.js.map +0 -1
  135. package/dist/chunk-WHV7MDNC.cjs.map +0 -1
  136. package/dist/chunk-XBHDXURR.cjs.map +0 -1
@@ -0,0 +1,49 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ AUDIO_ISOLATION_MAX_SEC,
4
+ AUDIO_ISOLATION_MAX_UNITS,
5
+ AUDIO_ISOLATION_RATE_ID,
6
+ audioIsolationEstimateUnits,
7
+ audioIsolationUnits,
8
+ checkAudioIsolationLength,
9
+ } from "../audio-isolation-pricing.js"
10
+
11
+ describe("Audio Isolation pricing", () => {
12
+ it("one unit per started 10 seconds, at least one", () => {
13
+ expect(AUDIO_ISOLATION_RATE_ID).toBe("elevenlabs-isolation:per-10s")
14
+ expect(audioIsolationUnits(0.4)).toBe(1)
15
+ expect(audioIsolationUnits(8)).toBe(1)
16
+ expect(audioIsolationUnits(10)).toBe(1)
17
+ expect(audioIsolationUnits(10.2)).toBe(2)
18
+ expect(audioIsolationUnits(30)).toBe(3)
19
+ expect(audioIsolationUnits(60)).toBe(6)
20
+ expect(audioIsolationUnits(300)).toBe(30)
21
+ expect(audioIsolationUnits(1800)).toBe(180)
22
+ })
23
+
24
+ it("forgives 0.05 s past a mark", () => {
25
+ expect(audioIsolationUnits(30.05)).toBe(3)
26
+ expect(audioIsolationUnits(30.06)).toBe(4)
27
+ })
28
+
29
+ it("refuses audio past 30 minutes (a hair past forgiven), naming the limit", () => {
30
+ expect(checkAudioIsolationLength(AUDIO_ISOLATION_MAX_SEC)).toEqual({ ok: true, units: 180 })
31
+ expect(checkAudioIsolationLength(AUDIO_ISOLATION_MAX_SEC + 0.05)).toEqual({ ok: true, units: 180 })
32
+ const refused = checkAudioIsolationLength(31 * 60)
33
+ expect(refused.ok).toBe(false)
34
+ if (!refused.ok) {
35
+ expect(refused.code).toBe("audio_too_long")
36
+ expect(refused.message).toMatch(/31 min/)
37
+ expect(refused.message).toMatch(/30 minutes/)
38
+ expect(refused.message).toMatch(/split or trim/)
39
+ }
40
+ })
41
+
42
+ it("an estimate quotes the known length, else the 30-minute cap", () => {
43
+ expect(audioIsolationEstimateUnits(8)).toBe(1)
44
+ expect(audioIsolationEstimateUnits(300)).toBe(30)
45
+ expect(audioIsolationEstimateUnits(undefined)).toBe(AUDIO_ISOLATION_MAX_UNITS)
46
+ expect(audioIsolationEstimateUnits(0)).toBe(AUDIO_ISOLATION_MAX_UNITS)
47
+ expect(audioIsolationEstimateUnits(5000)).toBe(AUDIO_ISOLATION_MAX_UNITS)
48
+ })
49
+ })
@@ -4,6 +4,7 @@ import {
4
4
  COMPETITOR_SCAN_CREDIT_COSTS,
5
5
  COMPETITOR_SCAN_MAX_SEARCHES,
6
6
  COMPETITOR_SCAN_PAGE_CREDIT_ID,
7
+ COMPETITOR_SCAN_SEARCH_LIMIT,
7
8
  COMPETITOR_SEARCH_TERMS_MAX,
8
9
  SCAN_PAGE_CREDIT_COSTS,
9
10
  SOCIAL_SEARCH_CREDITS_PER_PAGE,
@@ -69,7 +70,11 @@ describe("search terms", () => {
69
70
  expect(competitorScanSearches({ ...c, termCap: 3 })).toBe(2 * 3)
70
71
  expect(competitorScanSearches({ ...c, termCap: 0 })).toBe(2)
71
72
  expect(competitorScanSearches({ ...c, termCap: null })).toBe(2 * 4)
72
- expect(competitorScanSearches({ aboutPlatforms: ["x"], searchTerms: Array.from({ length: 40 }, (_, i) => `t${i}`) })).toBe(COMPETITOR_SEARCH_TERMS_MAX)
73
+ // No cap (a platform admin): every term up to the column's ceiling, so one platform fits a hundred.
74
+ const terms = (n: number) => Array.from({ length: n }, (_, i) => `t${i}`)
75
+ expect(competitorScanSearches({ aboutPlatforms: ["x"], searchTerms: terms(40) })).toBe(40)
76
+ expect(competitorScanSearches({ aboutPlatforms: ["x"], searchTerms: terms(120) })).toBe(COMPETITOR_SEARCH_TERMS_MAX)
77
+ expect(COMPETITOR_SEARCH_TERMS_MAX).toBe(COMPETITOR_SCAN_SEARCH_LIMIT)
73
78
  })
74
79
  })
75
80
 
@@ -752,14 +752,13 @@ describe("buildMotionCreditModelIdentifier", () => {
752
752
 
753
753
  // --- Wan Animate Move ---
754
754
  describe("wan-animate-move", () => {
755
- it("480p returns base identifier (default resolution)", () => {
756
- expect(buildMotionCreditModelIdentifier("wan-animate-move", "480p")).toBe("wan-animate-move")
757
- })
758
-
759
- it("580p returns composite identifier", () => {
760
- expect(buildMotionCreditModelIdentifier("wan-animate-move", "580p")).toBe(
761
- "wan-animate-move:580p",
762
- )
755
+ it("runs at 720p only: 480p and 580p are sent and named as 720p, and say so", () => {
756
+ for (const size of ["480p", "580p"]) {
757
+ expect(buildMotionCreditModelIdentifier("wan-animate-move", size)).toBe("wan-animate-move:720p")
758
+ const sized = motionTransferResolution("wan-animate-move", size)
759
+ expect(sized.resolution).toBe("720p")
760
+ expect(sized.adjustments.map(({ field, from, to }) => ({ field, from, to }))).toEqual([{ field: "resolution", from: size, to: "720p" }])
761
+ }
763
762
  })
764
763
 
765
764
  it("720p returns composite identifier", () => {
@@ -769,8 +768,8 @@ describe("buildMotionCreditModelIdentifier", () => {
769
768
  })
770
769
 
771
770
  it("ignores videoDuration (resolution-based pricing only)", () => {
772
- expect(buildMotionCreditModelIdentifier("wan-animate-move", "580p", 30)).toBe(
773
- "wan-animate-move:580p",
771
+ expect(buildMotionCreditModelIdentifier("wan-animate-move", "720p", 30)).toBe(
772
+ "wan-animate-move:720p",
774
773
  )
775
774
  })
776
775
  })
@@ -0,0 +1,252 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ checkMotionTransferLength,
4
+ motionTransferBilledSeconds,
5
+ motionTransferEstimatePrice,
6
+ motionTransferEstimateSeconds,
7
+ motionTransferMaxSec,
8
+ motionTransferPrice,
9
+ motionTransferRateOf,
10
+ motionTransferBaseCharge,
11
+ motionTransferChargedPrice,
12
+ MOTION_TRANSFER_FLOOR_IDS,
13
+ MOTION_TRANSFER_RATE_IDS,
14
+ MOTION_TRANSFER_SECOND_RATES,
15
+ } from "../motion-transfer-pricing.js"
16
+ import { motionTransferResolution } from "../credit-identifiers.js"
17
+
18
+ /** The rows as they are seeded (migrations 668 and 670, and the flat Wan Animate rows they never change). */
19
+ const ROWS: Record<string, number> = {
20
+ "motion-transfer:720p:per-4s": 126,
21
+ "motion-transfer:1080p:per-4s": 203,
22
+ "kling-3.0-motion:720p:per-4s": 228,
23
+ "kling-3.0-motion:1080p:per-4s": 302,
24
+ "wan-animate-replace:480p:per-4s": 60,
25
+ "wan-animate-replace:580p:per-4s": 95,
26
+ "wan-animate-replace:720p:per-4s": 125,
27
+ "wan-animate-move:720p:per-4s": 125,
28
+ "wan-animate-move": 255,
29
+ "wan-animate-move:580p": 330,
30
+ "wan-animate-move:720p": 410,
31
+ "wan-animate-replace": 255,
32
+ "wan-animate-replace:580p": 330,
33
+ "wan-animate-replace:720p": 410,
34
+ }
35
+ /** The base credits and the row a run of `seconds` billed seconds is charged at the seeded rows. */
36
+ const charge = (provider: string, resolution: string, seconds: number) => motionTransferBaseCharge(motionTransferPrice(provider, resolution, seconds), (id) => ROWS[id])
37
+
38
+ describe("Motion Transfer pricing from the driving video's length", () => {
39
+ describe("billed seconds", () => {
40
+ it("rounds the measured length up to a whole second", () => {
41
+ expect(motionTransferBilledSeconds(3)).toBe(3)
42
+ expect(motionTransferBilledSeconds(3.2)).toBe(4)
43
+ expect(motionTransferBilledSeconds(9.5)).toBe(10)
44
+ })
45
+ it("forgives up to 0.05 s past a whole second", () => {
46
+ expect(motionTransferBilledSeconds(10.05)).toBe(10)
47
+ expect(motionTransferBilledSeconds(10.04)).toBe(10)
48
+ expect(motionTransferBilledSeconds(10.06)).toBe(11)
49
+ })
50
+ })
51
+
52
+ describe("limits", () => {
53
+ it("Kling 2.6 and Kling 3.0 take 10 s keeping the image's orientation (the default), 30 s following the video's", () => {
54
+ for (const provider of ["kling", "kling-3.0"]) {
55
+ expect(motionTransferMaxSec(provider, undefined)).toBe(10)
56
+ expect(motionTransferMaxSec(provider, "image")).toBe(10)
57
+ expect(motionTransferMaxSec(provider, "bogus")).toBe(10)
58
+ expect(motionTransferMaxSec(provider, "video")).toBe(30)
59
+ }
60
+ })
61
+ it("Wan Animate takes 30 s whatever the orientation", () => {
62
+ expect(motionTransferMaxSec("wan-animate-move", "image")).toBe(30)
63
+ expect(motionTransferMaxSec("wan-animate-replace", undefined)).toBe(30)
64
+ })
65
+ it("refuses a clip under 3 s", () => {
66
+ const r = checkMotionTransferLength("kling", "image", 2.9)
67
+ expect(r.ok).toBe(false)
68
+ if (!r.ok) {
69
+ expect(r.code).toBe("video_too_short")
70
+ expect(r.message).toContain("at least 3 seconds")
71
+ }
72
+ })
73
+ it("refuses a clip past the limit, naming it and asking to trim", () => {
74
+ const r = checkMotionTransferLength("kling-3.0", "image", 12)
75
+ expect(r.ok).toBe(false)
76
+ if (!r.ok) {
77
+ expect(r.code).toBe("video_too_long")
78
+ expect(r.message).toContain("at most 10 seconds")
79
+ expect(r.message).toContain("Trim the video first")
80
+ }
81
+ const v = checkMotionTransferLength("kling-3.0", "video", 31)
82
+ expect(v.ok).toBe(false)
83
+ if (!v.ok) expect(v.message).toContain("at most 30 seconds")
84
+ expect(checkMotionTransferLength("wan-animate-move", "image", 30.5).ok).toBe(false)
85
+ })
86
+ it("accepts a clip within 0.05 s past the limit and bills it at the limit", () => {
87
+ expect(checkMotionTransferLength("kling", "image", 10.05)).toEqual({ ok: true, billedSeconds: 10 })
88
+ expect(checkMotionTransferLength("kling", "image", 10.06).ok).toBe(false)
89
+ expect(checkMotionTransferLength("kling-3.0", "video", 30.04)).toEqual({ ok: true, billedSeconds: 30 })
90
+ })
91
+ it("accepts 3 s exactly", () => {
92
+ expect(checkMotionTransferLength("kling", "image", 3)).toEqual({ ok: true, billedSeconds: 3 })
93
+ })
94
+ })
95
+
96
+ describe("Kling 3.0 at 720p: a per-second rate", () => {
97
+ it("is charged its four-second row × billed seconds ÷ 4", () => {
98
+ expect(motionTransferPrice("kling-3.0", "720p", 10)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 2.5 })
99
+ expect(motionTransferPrice("kling-3.0", "720p", 3)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 0.75 })
100
+ })
101
+ it("worked examples: 10 s → 570 base credits, 3 s → 171 (the 228 row)", () => {
102
+ expect(charge("kling-3.0", "720p", 10)).toEqual({ creditId: "kling-3.0-motion:720p:per-4s", units: 2.5, baseCredits: 570 })
103
+ expect(charge("kling-3.0", "720p", 3).baseCredits).toBe(171)
104
+ })
105
+ it("any size but 1080p is charged as 720p, so it is on the rate too", () => {
106
+ expect(motionTransferRateOf("kling-3.0", "480p").rateId).toBe("kling-3.0-motion:720p:per-4s")
107
+ expect(motionTransferRateOf("kling-3.0", "580p").rateId).toBe("kling-3.0-motion:720p:per-4s")
108
+ expect(motionTransferRateOf("kling-3.0", undefined).rateId).toBe("kling-3.0-motion:720p:per-4s")
109
+ })
110
+ })
111
+
112
+ describe("every model and size is charged per second (decided 2026-11-18)", () => {
113
+ it("lists every rate row once and every floor row once", () => {
114
+ expect([...MOTION_TRANSFER_RATE_IDS].sort()).toEqual([
115
+ "kling-3.0-motion:1080p:per-4s",
116
+ "kling-3.0-motion:720p:per-4s",
117
+ "motion-transfer:1080p:per-4s",
118
+ "motion-transfer:720p:per-4s",
119
+ "wan-animate-move:720p:per-4s",
120
+ "wan-animate-replace:480p:per-4s",
121
+ "wan-animate-replace:580p:per-4s",
122
+ "wan-animate-replace:720p:per-4s",
123
+ ])
124
+ expect([...MOTION_TRANSFER_FLOOR_IDS].sort()).toEqual([
125
+ "wan-animate-move:720p",
126
+ "wan-animate-replace",
127
+ "wan-animate-replace:580p",
128
+ "wan-animate-replace:720p",
129
+ ])
130
+ })
131
+ it("every size a model runs at has a rate, and no rate is a length tier", () => {
132
+ for (const provider of ["kling", "kling-3.0", "wan-animate-move", "wan-animate-replace"]) {
133
+ for (const size of ["480p", "580p", "720p", "1080p", undefined]) {
134
+ const sized = motionTransferResolution(provider, size ?? "720p").resolution
135
+ const rate = motionTransferRateOf(provider, size)
136
+ expect(rate.rateId).toMatch(/:per-4s$/)
137
+ if (provider.startsWith("wan-")) expect(Object.prototype.hasOwnProperty.call(MOTION_TRANSFER_SECOND_RATES, `${provider}:${sized}`)).toBe(true)
138
+ }
139
+ }
140
+ })
141
+ it("a model Motion Transfer does not have is priced as its default, Kling 2.6", () => {
142
+ expect(motionTransferRateOf("bogus", "720p").rateId).toBe("motion-transfer:720p:per-4s")
143
+ expect(motionTransferRateOf(undefined, "1080p").rateId).toBe("motion-transfer:1080p:per-4s")
144
+ })
145
+ it("Kling 2.6: 126 base credits per 4 s at 720p, 203 at 1080p, no floor", () => {
146
+ expect(charge("kling", "720p", 10)).toEqual({ creditId: "motion-transfer:720p:per-4s", units: 2.5, baseCredits: 315 })
147
+ expect(charge("kling", "720p", 3).baseCredits).toBe(95)
148
+ expect(charge("kling", "1080p", 10)).toEqual({ creditId: "motion-transfer:1080p:per-4s", units: 2.5, baseCredits: 508 })
149
+ expect(charge("kling", "1080p", 30).baseCredits).toBe(1523)
150
+ expect(charge("kling", "480p", 5).creditId).toBe("motion-transfer:720p:per-4s")
151
+ })
152
+ it("Kling 3.0 at 1080p: 302 base credits per 4 s, no floor", () => {
153
+ expect(charge("kling-3.0", "1080p", 10)).toEqual({ creditId: "kling-3.0-motion:1080p:per-4s", units: 2.5, baseCredits: 755 })
154
+ expect(charge("kling-3.0", "1080p", 3).baseCredits).toBe(227)
155
+ })
156
+ it("a 10.5 s clip is billed 11 s", () => {
157
+ expect(charge("kling", "720p", motionTransferBilledSeconds(10.5)).baseCredits).toBe(Math.ceil((126 * 11) / 4))
158
+ })
159
+ })
160
+
161
+ describe("Wan Animate: per second, never below today's flat price for the size", () => {
162
+ it("Replace 720p: 3 s stays at today's 410; 30 s is ceil(125 × 30 ÷ 4) = 938", () => {
163
+ expect(charge("wan-animate-replace", "720p", 3)).toEqual({ creditId: "wan-animate-replace:720p", baseCredits: 410 })
164
+ expect(charge("wan-animate-replace", "720p", 30)).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 7.5, baseCredits: 938 })
165
+ })
166
+ // Each floored row on both sides of the length where the rate passes it.
167
+ it.each([
168
+ ["wan-animate-replace", "480p", 17, "wan-animate-replace", 255, 18, 270],
169
+ ["wan-animate-replace", "580p", 13, "wan-animate-replace:580p", 330, 14, 333],
170
+ ["wan-animate-replace", "720p", 13, "wan-animate-replace:720p", 410, 14, 438],
171
+ ["wan-animate-move", "720p", 13, "wan-animate-move:720p", 410, 14, 438],
172
+ ["wan-animate-move", "480p", 13, "wan-animate-move:720p", 410, 14, 438],
173
+ ["wan-animate-move", "580p", 13, "wan-animate-move:720p", 410, 14, 438],
174
+ ] as const)("%s %s: %d s is the floor row, %d s past it the rate", (provider, size, onFloor, floorId, floorBase, past, pastBase) => {
175
+ expect(charge(provider, size, onFloor)).toEqual({ creditId: floorId, baseCredits: floorBase })
176
+ expect(charge(provider, size, past)).toMatchObject({ creditId: motionTransferRateOf(provider, size).rateId, units: past / 4, baseCredits: pastBase })
177
+ })
178
+ it("a tie goes to the floor row: Replace 480p at 17 s is 255 either way", () => {
179
+ expect(Math.ceil((60 * 17) / 4)).toBe(255)
180
+ expect(charge("wan-animate-replace", "480p", 17).creditId).toBe("wan-animate-replace")
181
+ })
182
+ it("Move runs at 720p only: any size it names is sent and charged as 720p, floored at the 720p row", () => {
183
+ for (const size of ["480p", "580p", "720p", "1080p"]) {
184
+ expect(motionTransferResolution("wan-animate-move", size).resolution).toBe("720p")
185
+ expect(motionTransferRateOf("wan-animate-move", size)).toEqual({ rateId: "wan-animate-move:720p:per-4s", rateSeconds: 4, floorId: "wan-animate-move:720p" })
186
+ }
187
+ expect(charge("wan-animate-move", "480p", 30)).toMatchObject({ creditId: "wan-animate-move:720p:per-4s", baseCredits: 938 })
188
+ expect(charge("wan-animate-move", "480p", 5)).toEqual({ creditId: "wan-animate-move:720p", baseCredits: 410 })
189
+ })
190
+ it("Replace keeps its three sizes", () => {
191
+ for (const size of ["480p", "580p", "720p"]) expect(motionTransferResolution("wan-animate-replace", size).resolution).toBe(size)
192
+ })
193
+ it("a 1080p request runs, and is charged, as 720p", () => {
194
+ expect(motionTransferRateOf("wan-animate-replace", "1080p")).toEqual({ rateId: "wan-animate-replace:720p:per-4s", rateSeconds: 4, floorId: "wan-animate-replace:720p" })
195
+ })
196
+ it("the floor rule reads charged figures the same way (the editor's)", () => {
197
+ const price = motionTransferPrice("wan-animate-replace", "720p", 10)
198
+ expect(motionTransferChargedPrice(price, { perSecond: 360, floor: 472 })).toEqual({ creditId: "wan-animate-replace:720p" })
199
+ expect(motionTransferChargedPrice(price, { perSecond: 500, floor: 472 })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 2.5 })
200
+ })
201
+ it("a row priced nowhere leaves the rate, whose own lookup refuses it", () => {
202
+ const price = motionTransferPrice("wan-animate-replace", "720p", 3)
203
+ expect(motionTransferChargedPrice(price, { perSecond: undefined, floor: 410 })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 0.75 })
204
+ expect(motionTransferChargedPrice(price, { perSecond: 94, floor: undefined })).toEqual({ creditId: "wan-animate-replace:720p:per-4s", units: 0.75 })
205
+ })
206
+ it("the charge never falls as the clip grows, and is never below the floor", () => {
207
+ for (const [provider, size] of [["wan-animate-replace", "480p"], ["wan-animate-replace", "580p"], ["wan-animate-replace", "720p"], ["wan-animate-move", "480p"], ["wan-animate-move", "720p"]] as const) {
208
+ const floor = ROWS[motionTransferRateOf(provider, size).floorId!]!
209
+ let last = 0
210
+ for (let sec = 3; sec <= 30; sec++) {
211
+ const base = charge(provider, size, sec).baseCredits!
212
+ expect(base).toBeGreaterThanOrEqual(Math.max(last, floor))
213
+ last = base
214
+ }
215
+ }
216
+ })
217
+ })
218
+
219
+ describe("estimates", () => {
220
+ it("quote the known length, billed as a run bills it, at most the limit", () => {
221
+ expect(motionTransferEstimateSeconds("kling-3.0", "image", 6.2)).toBe(7)
222
+ expect(motionTransferEstimateSeconds("kling-3.0", "image", 25)).toBe(10)
223
+ expect(motionTransferEstimateSeconds("kling-3.0", "video", 25)).toBe(25)
224
+ })
225
+ it("quote the orientation's limit when the length is unknown", () => {
226
+ expect(motionTransferEstimateSeconds("kling-3.0", undefined, undefined)).toBe(10)
227
+ expect(motionTransferEstimateSeconds("kling-3.0", "video", null)).toBe(30)
228
+ expect(motionTransferEstimatePrice("kling-3.0", "720p", "image", undefined)).toEqual({
229
+ creditId: "kling-3.0-motion:720p:per-4s",
230
+ units: 2.5,
231
+ lengthKnown: false,
232
+ })
233
+ expect(motionTransferEstimatePrice("kling", "720p", "video", undefined)).toEqual({ creditId: "motion-transfer:720p:per-4s", units: 7.5, lengthKnown: false })
234
+ expect(motionTransferEstimatePrice("wan-animate-move", "480p", "image", undefined)).toEqual({
235
+ creditId: "wan-animate-move:720p:per-4s",
236
+ units: 7.5,
237
+ floorId: "wan-animate-move:720p",
238
+ lengthKnown: false,
239
+ })
240
+ })
241
+ it("never quotes below a run of the same clip", () => {
242
+ for (let tenth = 30; tenth <= 300; tenth++) {
243
+ const sec = tenth / 10
244
+ for (const orientation of ["image", "video"]) {
245
+ const run = checkMotionTransferLength("kling-3.0", orientation, sec)
246
+ if (!run.ok) continue
247
+ expect(motionTransferEstimateSeconds("kling-3.0", orientation, sec)).toBeGreaterThanOrEqual(run.billedSeconds)
248
+ }
249
+ }
250
+ })
251
+ })
252
+ })
@@ -0,0 +1,151 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import {
3
+ checkVideoToVideoClipLength,
4
+ isClipPricedV2vProvider,
5
+ V2V_CLIP_RATE_IDS,
6
+ videoToVideoBilledSeconds,
7
+ videoToVideoClipPrice,
8
+ videoToVideoClipRateOf,
9
+ videoToVideoEstimatePrice,
10
+ videoToVideoSentResolution,
11
+ wanVideoEditRateFromSeconds,
12
+ } from "../video-to-video-pricing.js"
13
+
14
+ /** The rows as seeded (STATIC_CREDIT_COSTS / migration 671), base credits. */
15
+ const ROWS: Readonly<Record<string, number>> = {
16
+ "wan-videoedit": 320,
17
+ "wan-videoedit:1080p:per-4s": 240,
18
+ "happyhorse-edit:720p:per-4s": 560,
19
+ "happyhorse-edit:1080p:per-4s": 960,
20
+ }
21
+ const rowOf = (id: string) => ROWS[id]
22
+ /** The base a price stands for, as every lane charges it: a rate × units rounded up once, else the flat row. */
23
+ const base = (p: { creditId: string; units?: number }) => (p.units === undefined ? ROWS[p.creditId]! : Math.ceil(ROWS[p.creditId]! * p.units))
24
+
25
+ const priceOf = (provider: "happyhorse-edit" | "wan-videoedit", resolution: unknown, clipSec: number, videoEditDuration?: unknown) => {
26
+ const check = checkVideoToVideoClipLength(provider, clipSec, videoEditDuration)
27
+ if (!check.ok) throw new Error(check.message)
28
+ return videoToVideoClipPrice(provider, resolution, check.billedSeconds, rowOf)
29
+ }
30
+
31
+ describe("Video to Video priced by the clip's length", () => {
32
+ it("only HappyHorse Edit and Wan 2.7 VideoEdit are priced by their clip", () => {
33
+ expect(isClipPricedV2vProvider("happyhorse-edit")).toBe(true)
34
+ expect(isClipPricedV2vProvider("wan-videoedit")).toBe(true)
35
+ for (const other of ["wan", "wan-flash", "runway-aleph", "luma-modify", "seedance-2-5", undefined]) {
36
+ expect(isClipPricedV2vProvider(other)).toBe(false)
37
+ expect(videoToVideoClipRateOf(other, "720p")).toBeUndefined()
38
+ }
39
+ expect(V2V_CLIP_RATE_IDS).toEqual(["happyhorse-edit:720p:per-4s", "happyhorse-edit:1080p:per-4s", "wan-videoedit:1080p:per-4s"])
40
+ })
41
+
42
+ describe("HappyHorse Edit", () => {
43
+ it("bills every started half-second of the clip, forgiving float noise only", () => {
44
+ expect(videoToVideoBilledSeconds("happyhorse-edit", 3)).toBe(3)
45
+ expect(videoToVideoBilledSeconds("happyhorse-edit", 3.0000000001)).toBe(3)
46
+ expect(videoToVideoBilledSeconds("happyhorse-edit", 3.01)).toBe(3.5)
47
+ expect(videoToVideoBilledSeconds("happyhorse-edit", 10.04)).toBe(10.5)
48
+ expect(videoToVideoBilledSeconds("happyhorse-edit", 10.5)).toBe(10.5)
49
+ })
50
+
51
+ it("worked examples: 3.00 s at 720p = 420, 10.04 s at 720p = 1,470, 3.00 s at 1080p = 720 (base)", () => {
52
+ const a = priceOf("happyhorse-edit", "720p", 3)
53
+ expect(a).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 0.75 })
54
+ expect(base(a)).toBe(420)
55
+ const b = priceOf("happyhorse-edit", undefined, 10.04)
56
+ expect(b).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 2.625 })
57
+ expect(base(b)).toBe(1470)
58
+ const c = priceOf("happyhorse-edit", "1080p", 3)
59
+ expect(c).toEqual({ creditId: "happyhorse-edit:1080p:per-4s", units: 0.75 })
60
+ expect(base(c)).toBe(720)
61
+ expect(base(priceOf("happyhorse-edit", "720p", 60))).toBe(8400)
62
+ })
63
+
64
+ it("prices and sends 720p unless the request says 1080p", () => {
65
+ expect(videoToVideoSentResolution("happyhorse-edit", undefined)).toBe("720p")
66
+ expect(videoToVideoSentResolution("happyhorse-edit", "480p")).toBe("720p")
67
+ expect(videoToVideoSentResolution("happyhorse-edit", "720p")).toBe("720p")
68
+ expect(videoToVideoSentResolution("happyhorse-edit", "1080p")).toBe("1080p")
69
+ expect(videoToVideoClipRateOf("happyhorse-edit", "480p")?.rateId).toBe("happyhorse-edit:720p:per-4s")
70
+ // Every other model's resolution is left as sent.
71
+ expect(videoToVideoSentResolution("wan", "1080p")).toBe("1080p")
72
+ expect(videoToVideoSentResolution("wan-videoedit", undefined)).toBeUndefined()
73
+ })
74
+
75
+ it("refuses a clip shorter than 3 s or longer than 60 s, with no grace", () => {
76
+ expect(checkVideoToVideoClipLength("happyhorse-edit", 2.99)).toMatchObject({ ok: false, code: "video_too_short" })
77
+ expect(checkVideoToVideoClipLength("happyhorse-edit", 3)).toEqual({ ok: true, billedSeconds: 3 })
78
+ expect(checkVideoToVideoClipLength("happyhorse-edit", 60)).toEqual({ ok: true, billedSeconds: 60 })
79
+ const long = checkVideoToVideoClipLength("happyhorse-edit", 60.02)
80
+ expect(long).toMatchObject({ ok: false, code: "video_too_long" })
81
+ expect(long.ok ? "" : long.message).toMatch(/at most 60 seconds\. Trim the video first\./)
82
+ })
83
+ })
84
+
85
+ describe("Wan 2.7 VideoEdit", () => {
86
+ it("bills the clip it delivers: the clip's length, or the shorter length asked for, whole seconds after 0.05 s", () => {
87
+ expect(videoToVideoBilledSeconds("wan-videoedit", 6, "0")).toBe(6)
88
+ expect(videoToVideoBilledSeconds("wan-videoedit", 6, undefined)).toBe(6)
89
+ expect(videoToVideoBilledSeconds("wan-videoedit", 6.05)).toBe(6)
90
+ expect(videoToVideoBilledSeconds("wan-videoedit", 6.06)).toBe(7)
91
+ expect(videoToVideoBilledSeconds("wan-videoedit", 9, "5")).toBe(5)
92
+ expect(videoToVideoBilledSeconds("wan-videoedit", 3, "5")).toBe(3)
93
+ expect(videoToVideoBilledSeconds("wan-videoedit", 10.04, "10")).toBe(10)
94
+ })
95
+
96
+ it("is charged the larger of its flat row and its rate: 3 s stays 320, 5 s 320, 6 s 360, 10 s 600 (base)", () => {
97
+ expect(priceOf("wan-videoedit", "1080p", 3)).toEqual({ creditId: "wan-videoedit" })
98
+ expect(base(priceOf("wan-videoedit", "1080p", 3))).toBe(320)
99
+ expect(base(priceOf("wan-videoedit", "1080p", 5))).toBe(320)
100
+ expect(priceOf("wan-videoedit", "1080p", 6)).toEqual({ creditId: "wan-videoedit:1080p:per-4s", units: 1.5 })
101
+ expect(base(priceOf("wan-videoedit", "1080p", 6))).toBe(360)
102
+ expect(base(priceOf("wan-videoedit", undefined, 10))).toBe(600)
103
+ // Asked for 5 s of a 10 s clip: 5 billed seconds, the flat row.
104
+ expect(base(priceOf("wan-videoedit", "1080p", 10, "5"))).toBe(320)
105
+ })
106
+
107
+ it("never costs less than the flat row, at any length it takes", () => {
108
+ for (let tenths = 20; tenths <= 100; tenths++) {
109
+ const p = priceOf("wan-videoedit", "1080p", tenths / 10)
110
+ expect(base(p)).toBeGreaterThanOrEqual(320)
111
+ expect(base(p)).toBe(Math.max(320, Math.ceil((240 * videoToVideoBilledSeconds("wan-videoedit", tenths / 10)) / 4)))
112
+ }
113
+ })
114
+
115
+ it("follows the live rows: a repriced row moves where the rate takes over", () => {
116
+ expect(wanVideoEditRateFromSeconds("1080p", rowOf)).toBe(6)
117
+ expect(wanVideoEditRateFromSeconds("1080p", (id) => (id === "wan-videoedit" ? 100 : ROWS[id]))).toBe(2)
118
+ expect(wanVideoEditRateFromSeconds("1080p", (id) => (id === "wan-videoedit" ? 10_000 : ROWS[id]))).toBeUndefined()
119
+ // A rate the table does not price never wins.
120
+ expect(videoToVideoClipPrice("wan-videoedit", "1080p", 10, (id) => (id === "wan-videoedit" ? 320 : undefined))).toEqual({ creditId: "wan-videoedit" })
121
+ })
122
+
123
+ it("720p is charged at the 1080p rate for now", () => {
124
+ expect(videoToVideoClipRateOf("wan-videoedit", "720p")?.rateId).toBe("wan-videoedit:1080p:per-4s")
125
+ expect(base(priceOf("wan-videoedit", "720p", 10))).toBe(600)
126
+ })
127
+
128
+ it("refuses a clip shorter than 2 s or past 10 s by more than 0.05 s (a clip within it is billed at 10 s)", () => {
129
+ expect(checkVideoToVideoClipLength("wan-videoedit", 1.9)).toMatchObject({ ok: false, code: "video_too_short" })
130
+ expect(checkVideoToVideoClipLength("wan-videoedit", 2)).toEqual({ ok: true, billedSeconds: 2 })
131
+ expect(checkVideoToVideoClipLength("wan-videoedit", 10.05)).toEqual({ ok: true, billedSeconds: 10 })
132
+ expect(checkVideoToVideoClipLength("wan-videoedit", 10.06)).toMatchObject({ ok: false, code: "video_too_long" })
133
+ })
134
+ })
135
+
136
+ describe("estimates", () => {
137
+ it("quote the known length as a run bills it", () => {
138
+ expect(videoToVideoEstimatePrice("happyhorse-edit", "720p", undefined, 10.04, rowOf)).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 2.625, lengthKnown: true })
139
+ expect(videoToVideoEstimatePrice("wan-videoedit", "1080p", "0", 4, rowOf)).toEqual({ creditId: "wan-videoedit", lengthKnown: true })
140
+ })
141
+
142
+ it("quote the longest clip the model takes when the length is not known — never below the hold", () => {
143
+ const hh = videoToVideoEstimatePrice("happyhorse-edit", "720p", undefined, undefined, rowOf)
144
+ expect(hh).toEqual({ creditId: "happyhorse-edit:720p:per-4s", units: 15, lengthKnown: false })
145
+ const wan = videoToVideoEstimatePrice("wan-videoedit", "1080p", "0", null, rowOf)
146
+ expect(wan).toEqual({ creditId: "wan-videoedit:1080p:per-4s", units: 2.5, lengthKnown: false })
147
+ for (let tenths = 30; tenths <= 600; tenths += 7) expect(base(hh)).toBeGreaterThanOrEqual(base(priceOf("happyhorse-edit", "720p", tenths / 10)))
148
+ for (let tenths = 20; tenths <= 100; tenths++) expect(base(wan)).toBeGreaterThanOrEqual(base(priceOf("wan-videoedit", "1080p", tenths / 10)))
149
+ })
150
+ })
151
+ })
@@ -0,0 +1,80 @@
1
+ /**
2
+ * How an Audio Isolation run is priced (decided 2026-11-18): from the length
3
+ * of its audio as the server reads it before anything is held, never a length
4
+ * the caller declares.
5
+ *
6
+ * - The run is charged {@link AUDIO_ISOLATION_RATE_ID} once per started
7
+ * {@link AUDIO_ISOLATION_RATE_SECONDS} seconds of the audio, at least once,
8
+ * after forgiving `CLIP_PRICE_GRACE_SEC` past a mark. The hold IS the charge.
9
+ * - Audio longer than {@link AUDIO_ISOLATION_MAX_SEC} (30 minutes, a hair past
10
+ * it forgiven) is refused before anything is held; so is a file larger than
11
+ * {@link AUDIO_ISOLATION_MAX_BYTES}.
12
+ *
13
+ * The route, the workflow run, the MCP verb (which calls the route) and both
14
+ * estimates read this one module.
15
+ */
16
+ import { CLIP_PRICE_GRACE_SEC, gracedMeasuredSec } from "./priced-clip-seconds.js"
17
+
18
+ /** Float noise: a length that is arithmetic can land a hair past the limit, and must not be refused for it. */
19
+ const FLOAT_NOISE_SEC = 1e-9
20
+
21
+ /** The row an Audio Isolation run reserves and is charged: the price of ten seconds of audio. */
22
+ export const AUDIO_ISOLATION_RATE_ID = "elevenlabs-isolation:per-10s"
23
+
24
+ /** The seconds of audio one unit of {@link AUDIO_ISOLATION_RATE_ID} prices. */
25
+ export const AUDIO_ISOLATION_RATE_SECONDS = 10
26
+
27
+ /** The longest audio a run takes: 30 minutes. */
28
+ export const AUDIO_ISOLATION_MAX_SEC = 1800
29
+
30
+ /** The largest file a run takes (the provider's own limit): 500 MB. */
31
+ export const AUDIO_ISOLATION_MAX_BYTES = 500 * 1024 * 1024
32
+
33
+ /** The most units a run can be charged: the 30-minute cap's. */
34
+ export const AUDIO_ISOLATION_MAX_UNITS = AUDIO_ISOLATION_MAX_SEC / AUDIO_ISOLATION_RATE_SECONDS
35
+
36
+ /**
37
+ * The units of {@link AUDIO_ISOLATION_RATE_ID} an audio of `seconds` is
38
+ * charged: every started ten seconds after the grace, at least one, at most
39
+ * the cap's. THE one rounding every lane reads.
40
+ */
41
+ export function audioIsolationUnits(seconds: number): number {
42
+ if (!Number.isFinite(seconds) || seconds <= 0) return 1
43
+ const units = Math.ceil(gracedMeasuredSec(seconds) / AUDIO_ISOLATION_RATE_SECONDS)
44
+ return Math.min(AUDIO_ISOLATION_MAX_UNITS, Math.max(1, units))
45
+ }
46
+
47
+ /** What the length check answers for an audio of a given length. */
48
+ export type AudioIsolationLengthCheck =
49
+ | { readonly ok: true; readonly units: number }
50
+ | { readonly ok: false; readonly code: "audio_too_long"; readonly message: string }
51
+
52
+ /** The refusal of an audio past the 30-minute cap: how long it is, the limit, and what to do. */
53
+ export function audioIsolationTooLongMessage(seconds: number): string {
54
+ const minutes = Math.floor(seconds / 60)
55
+ const rest = Math.round(seconds - minutes * 60)
56
+ const length = rest > 0 ? `${minutes} min ${rest} s` : `${minutes} min`
57
+ return `The audio is ${length} long. Audio Isolation takes audio up to 30 minutes: split or trim it to 30 minutes or less first.`
58
+ }
59
+
60
+ /**
61
+ * Whether an audio of `seconds` can run, and the units it is charged. Past
62
+ * the 30-minute cap by more than `CLIP_PRICE_GRACE_SEC` is refused; within
63
+ * that grace it is charged at the cap.
64
+ */
65
+ export function checkAudioIsolationLength(seconds: number): AudioIsolationLengthCheck {
66
+ if (seconds > AUDIO_ISOLATION_MAX_SEC + CLIP_PRICE_GRACE_SEC + FLOAT_NOISE_SEC) {
67
+ return { ok: false, code: "audio_too_long", message: audioIsolationTooLongMessage(seconds) }
68
+ }
69
+ return { ok: true, units: audioIsolationUnits(seconds) }
70
+ }
71
+
72
+ /**
73
+ * The units an ESTIMATE quotes before the run reads the audio: the length
74
+ * the graph gives, at most the cap; a length it does not know quotes the cap
75
+ * (the most a run can be charged), and the caller marks it as an estimate.
76
+ */
77
+ export function audioIsolationEstimateUnits(knownSec?: number | null): number {
78
+ if (knownSec == null || !Number.isFinite(knownSec) || knownSec <= 0) return AUDIO_ISOLATION_MAX_UNITS
79
+ return audioIsolationUnits(knownSec)
80
+ }
@@ -45,8 +45,14 @@ export interface CompetitorSearch {
45
45
  readonly term?: string
46
46
  }
47
47
 
48
- /** The most search terms any brand can have (the platform's own ceiling; a plan allows fewer). */
49
- export const COMPETITOR_SEARCH_TERMS_MAX = 15
48
+ /**
49
+ * The most search terms any brand can have (the platform's own ceiling; a plan
50
+ * allows fewer). A platform admin has no cap on terms, only on one scan's
51
+ * size (`COMPETITOR_SCAN_SEARCH_LIMIT`): one platform fits up to this many.
52
+ */
53
+ export const COMPETITOR_SEARCH_TERMS_MAX = 100
54
+ /** A brand whose scan would run more searches than this (each account, and each about-platform once per term) cannot be saved or scanned. */
55
+ export const COMPETITOR_SCAN_SEARCH_LIMIT = 100
50
56
  /** The longest a search term can be. */
51
57
  export const COMPETITOR_SEARCH_TERM_MAX_LENGTH = 100
52
58
  /** A brand scan is charged this id per Social Search page it runs, summed (a topic scan has its own, `TOPIC_SCAN_PAGE_CREDIT_ID`). */
@@ -1206,6 +1206,12 @@ export function pricedVideoSelection(opts: {
1206
1206
  * Compute composite model identifier for motion control with duration-tiered pricing.
1207
1207
  * Examples: "kling-3.0-motion:10s", "kling-3.0-motion:1080p:15s", "motion-transfer:5s"
1208
1208
  *
1209
+ * This is the old TIER row only, kept for older code and saved quotes: no
1210
+ * run is priced from it. A run is priced through `motionTransferPrice`
1211
+ * (motion-transfer-pricing.ts), per second of the driving video as the server
1212
+ * reads it, for every model and size (Wan Animate's flat rows below are its
1213
+ * floor).
1214
+ *
1209
1215
  * Wan Animate providers use resolution-tiered pricing (not per-second):
1210
1216
  * "wan-animate-move" (480p default), "wan-animate-move:580p", "wan-animate-move:720p"
1211
1217
  *