vidspotai-shared 1.0.68 → 1.0.69-dev.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 (502) hide show
  1. package/lib/globals/aiModels/enums.d.ts +63 -6
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +78 -9
  4. package/lib/globals/aiModels/index.d.ts +2 -30
  5. package/lib/globals/aiModels/index.d.ts.map +1 -1
  6. package/lib/globals/aiModels/index.js +7 -35
  7. package/lib/globals/aiModels/providers/alibaba.d.ts +4 -0
  8. package/lib/globals/aiModels/providers/alibaba.d.ts.map +1 -0
  9. package/lib/globals/aiModels/providers/alibaba.js +194 -0
  10. package/lib/globals/aiModels/providers/bytedance.d.ts.map +1 -1
  11. package/lib/globals/aiModels/providers/bytedance.js +19 -0
  12. package/lib/globals/aiModels/providers/elevenlabs.d.ts +14 -0
  13. package/lib/globals/aiModels/providers/elevenlabs.d.ts.map +1 -0
  14. package/lib/globals/aiModels/providers/elevenlabs.js +29 -0
  15. package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
  16. package/lib/globals/aiModels/providers/google.js +150 -2
  17. package/lib/globals/aiModels/providers/kling.d.ts.map +1 -1
  18. package/lib/globals/aiModels/providers/kling.js +280 -37
  19. package/lib/globals/aiModels/providers/minimax.d.ts.map +1 -1
  20. package/lib/globals/aiModels/providers/minimax.js +76 -11
  21. package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
  22. package/lib/globals/aiModels/providers/openai.js +90 -6
  23. package/lib/globals/aiModels/providers/pixverse.d.ts.map +1 -1
  24. package/lib/globals/aiModels/providers/pixverse.js +111 -29
  25. package/lib/globals/aiModels/providers/pixverseTemplates.d.ts +36 -0
  26. package/lib/globals/aiModels/providers/pixverseTemplates.d.ts.map +1 -0
  27. package/lib/globals/aiModels/providers/pixverseTemplates.js +42 -0
  28. package/lib/globals/aiModels/providers/runway.d.ts.map +1 -1
  29. package/lib/globals/aiModels/providers/runway.js +64 -2
  30. package/lib/globals/aiModels/tierHelpers.d.ts +33 -0
  31. package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -0
  32. package/lib/globals/aiModels/tierHelpers.js +109 -0
  33. package/lib/globals/aiModels/types.d.ts +20 -1
  34. package/lib/globals/aiModels/types.d.ts.map +1 -1
  35. package/lib/globals/ttsModels/index.d.ts +2 -0
  36. package/lib/globals/ttsModels/index.d.ts.map +1 -1
  37. package/lib/globals/ttsModels/index.js +9 -1
  38. package/lib/globals/ttsModels/providers/minimax.d.ts +8 -0
  39. package/lib/globals/ttsModels/providers/minimax.d.ts.map +1 -0
  40. package/lib/globals/ttsModels/providers/minimax.js +18 -0
  41. package/lib/globals/ttsModels/providers/openai.d.ts +12 -0
  42. package/lib/globals/ttsModels/providers/openai.d.ts.map +1 -0
  43. package/lib/globals/ttsModels/providers/openai.js +22 -0
  44. package/lib/globals/ttsModels/types.d.ts +1 -1
  45. package/lib/globals/ttsModels/types.d.ts.map +1 -1
  46. package/lib/globals/ttsModels/voices.d.ts +39 -4
  47. package/lib/globals/ttsModels/voices.d.ts.map +1 -1
  48. package/lib/globals/ttsModels/voices.js +273 -26
  49. package/lib/globals/types.d.ts +59 -1
  50. package/lib/globals/types.d.ts.map +1 -1
  51. package/lib/globals/types.js +81 -2
  52. package/lib/index.d.ts +1 -0
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +1 -0
  55. package/lib/models/agent.model.d.ts +357 -0
  56. package/lib/models/agent.model.d.ts.map +1 -0
  57. package/lib/models/agent.model.js +21 -0
  58. package/lib/models/cachedAsset.model.d.ts +18 -0
  59. package/lib/models/cachedAsset.model.d.ts.map +1 -0
  60. package/lib/models/cachedAsset.model.js +2 -0
  61. package/lib/models/cachedRawAsset.model.d.ts +20 -0
  62. package/lib/models/cachedRawAsset.model.d.ts.map +1 -0
  63. package/lib/models/cachedRawAsset.model.js +2 -0
  64. package/lib/models/image.model.d.ts +47 -0
  65. package/lib/models/image.model.d.ts.map +1 -0
  66. package/lib/models/image.model.js +2 -0
  67. package/lib/models/index.d.ts +6 -0
  68. package/lib/models/index.d.ts.map +1 -1
  69. package/lib/models/index.js +6 -0
  70. package/lib/models/notification.model.d.ts +25 -0
  71. package/lib/models/notification.model.d.ts.map +1 -0
  72. package/lib/models/notification.model.js +2 -0
  73. package/lib/models/ref.model.d.ts +80 -0
  74. package/lib/models/ref.model.d.ts.map +1 -0
  75. package/lib/models/ref.model.js +13 -0
  76. package/lib/models/share.model.d.ts +29 -0
  77. package/lib/models/share.model.d.ts.map +1 -0
  78. package/lib/models/share.model.js +2 -0
  79. package/lib/models/user.model.d.ts +12 -1
  80. package/lib/models/user.model.d.ts.map +1 -1
  81. package/lib/models/video.model.d.ts +120 -8
  82. package/lib/models/video.model.d.ts.map +1 -1
  83. package/lib/models/video.model.js +10 -0
  84. package/lib/schemas/agentPersona.schema.d.ts +10 -0
  85. package/lib/schemas/agentPersona.schema.d.ts.map +1 -0
  86. package/lib/schemas/agentPersona.schema.js +11 -0
  87. package/lib/schemas/agentRunJob.schema.d.ts +105 -0
  88. package/lib/schemas/agentRunJob.schema.d.ts.map +1 -0
  89. package/lib/schemas/agentRunJob.schema.js +88 -0
  90. package/lib/schemas/brandKit.schema.d.ts +113 -0
  91. package/lib/schemas/brandKit.schema.d.ts.map +1 -0
  92. package/lib/schemas/brandKit.schema.js +46 -0
  93. package/lib/schemas/brief.schema.d.ts +263 -0
  94. package/lib/schemas/brief.schema.d.ts.map +1 -0
  95. package/lib/schemas/brief.schema.js +157 -0
  96. package/lib/schemas/index.d.ts +7 -0
  97. package/lib/schemas/index.d.ts.map +1 -0
  98. package/lib/schemas/index.js +22 -0
  99. package/lib/schemas/project.schema.d.ts +1025 -0
  100. package/lib/schemas/project.schema.d.ts.map +1 -0
  101. package/lib/schemas/project.schema.js +256 -0
  102. package/lib/schemas/videoPlan.schema.d.ts +590 -0
  103. package/lib/schemas/videoPlan.schema.d.ts.map +1 -0
  104. package/lib/schemas/videoPlan.schema.js +412 -0
  105. package/lib/services/agent/beatSnap.d.ts +10 -0
  106. package/lib/services/agent/beatSnap.d.ts.map +1 -0
  107. package/lib/services/agent/beatSnap.js +128 -0
  108. package/lib/services/agent/bibleBuilder.d.ts +43 -0
  109. package/lib/services/agent/bibleBuilder.d.ts.map +1 -0
  110. package/lib/services/agent/bibleBuilder.js +102 -0
  111. package/lib/services/agent/bibleImageVision.d.ts +45 -0
  112. package/lib/services/agent/bibleImageVision.d.ts.map +1 -0
  113. package/lib/services/agent/bibleImageVision.js +169 -0
  114. package/lib/services/agent/chatAgent.d.ts +79 -0
  115. package/lib/services/agent/chatAgent.d.ts.map +1 -0
  116. package/lib/services/agent/chatAgent.js +136 -0
  117. package/lib/services/agent/costPreflight.d.ts +61 -0
  118. package/lib/services/agent/costPreflight.d.ts.map +1 -0
  119. package/lib/services/agent/costPreflight.js +143 -0
  120. package/lib/services/agent/critic.d.ts +103 -0
  121. package/lib/services/agent/critic.d.ts.map +1 -0
  122. package/lib/services/agent/critic.js +139 -0
  123. package/lib/services/agent/editClassifier.d.ts +262 -0
  124. package/lib/services/agent/editClassifier.d.ts.map +1 -0
  125. package/lib/services/agent/editClassifier.js +186 -0
  126. package/lib/services/agent/eval/index.d.ts +5 -0
  127. package/lib/services/agent/eval/index.d.ts.map +1 -0
  128. package/lib/services/agent/eval/index.js +20 -0
  129. package/lib/services/agent/eval/judge.d.ts +14 -0
  130. package/lib/services/agent/eval/judge.d.ts.map +1 -0
  131. package/lib/services/agent/eval/judge.js +96 -0
  132. package/lib/services/agent/eval/recorder.d.ts +28 -0
  133. package/lib/services/agent/eval/recorder.d.ts.map +1 -0
  134. package/lib/services/agent/eval/recorder.js +100 -0
  135. package/lib/services/agent/eval/seedBriefs.d.ts +16 -0
  136. package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -0
  137. package/lib/services/agent/eval/seedBriefs.js +1188 -0
  138. package/lib/services/agent/eval/types.d.ts +230 -0
  139. package/lib/services/agent/eval/types.d.ts.map +1 -0
  140. package/lib/services/agent/eval/types.js +73 -0
  141. package/lib/services/agent/executor.d.ts +141 -0
  142. package/lib/services/agent/executor.d.ts.map +1 -0
  143. package/lib/services/agent/executor.js +561 -0
  144. package/lib/services/agent/globalActions.d.ts +49 -0
  145. package/lib/services/agent/globalActions.d.ts.map +1 -0
  146. package/lib/services/agent/globalActions.js +328 -0
  147. package/lib/services/agent/index.d.ts +38 -0
  148. package/lib/services/agent/index.d.ts.map +1 -0
  149. package/lib/services/agent/index.js +53 -0
  150. package/lib/services/agent/llmCaller.d.ts +144 -0
  151. package/lib/services/agent/llmCaller.d.ts.map +1 -0
  152. package/lib/services/agent/llmCaller.js +16 -0
  153. package/lib/services/agent/llmCallerAnthropic.d.ts +90 -0
  154. package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -0
  155. package/lib/services/agent/llmCallerAnthropic.js +255 -0
  156. package/lib/services/agent/llmCallerGateway.d.ts +61 -0
  157. package/lib/services/agent/llmCallerGateway.d.ts.map +1 -0
  158. package/lib/services/agent/llmCallerGateway.js +360 -0
  159. package/lib/services/agent/llmCallerRegistry.d.ts +6 -0
  160. package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -0
  161. package/lib/services/agent/llmCallerRegistry.js +39 -0
  162. package/lib/services/agent/modelQualityNotes.d.ts +100 -0
  163. package/lib/services/agent/modelQualityNotes.d.ts.map +1 -0
  164. package/lib/services/agent/modelQualityNotes.js +248 -0
  165. package/lib/services/agent/modelRouter.d.ts +41 -0
  166. package/lib/services/agent/modelRouter.d.ts.map +1 -0
  167. package/lib/services/agent/modelRouter.js +65 -0
  168. package/lib/services/agent/musicSelect.d.ts +23 -0
  169. package/lib/services/agent/musicSelect.d.ts.map +1 -0
  170. package/lib/services/agent/musicSelect.js +109 -0
  171. package/lib/services/agent/overlayRenderer.d.ts +67 -0
  172. package/lib/services/agent/overlayRenderer.d.ts.map +1 -0
  173. package/lib/services/agent/overlayRenderer.js +253 -0
  174. package/lib/services/agent/perSceneCritic.d.ts +90 -0
  175. package/lib/services/agent/perSceneCritic.d.ts.map +1 -0
  176. package/lib/services/agent/perSceneCritic.js +125 -0
  177. package/lib/services/agent/personas.d.ts +78 -0
  178. package/lib/services/agent/personas.d.ts.map +1 -0
  179. package/lib/services/agent/personas.js +177 -0
  180. package/lib/services/agent/planDiff.d.ts +76 -0
  181. package/lib/services/agent/planDiff.d.ts.map +1 -0
  182. package/lib/services/agent/planDiff.js +182 -0
  183. package/lib/services/agent/planMutations.d.ts +46 -0
  184. package/lib/services/agent/planMutations.d.ts.map +1 -0
  185. package/lib/services/agent/planMutations.js +120 -0
  186. package/lib/services/agent/planner/Planner.d.ts +107 -0
  187. package/lib/services/agent/planner/Planner.d.ts.map +1 -0
  188. package/lib/services/agent/planner/Planner.js +591 -0
  189. package/lib/services/agent/planner/overlaySanity.d.ts +7 -0
  190. package/lib/services/agent/planner/overlaySanity.d.ts.map +1 -0
  191. package/lib/services/agent/planner/overlaySanity.js +86 -0
  192. package/lib/services/agent/planner/promptSections.d.ts +25 -0
  193. package/lib/services/agent/planner/promptSections.d.ts.map +1 -0
  194. package/lib/services/agent/planner/promptSections.js +174 -0
  195. package/lib/services/agent/planner/repair.d.ts +16 -0
  196. package/lib/services/agent/planner/repair.d.ts.map +1 -0
  197. package/lib/services/agent/planner/repair.js +51 -0
  198. package/lib/services/agent/planner/structuralRules.d.ts +10 -0
  199. package/lib/services/agent/planner/structuralRules.d.ts.map +1 -0
  200. package/lib/services/agent/planner/structuralRules.js +111 -0
  201. package/lib/services/agent/planner/validators.d.ts +65 -0
  202. package/lib/services/agent/planner/validators.d.ts.map +1 -0
  203. package/lib/services/agent/planner/validators.js +284 -0
  204. package/lib/services/agent/planner.d.ts +3 -0
  205. package/lib/services/agent/planner.d.ts.map +1 -0
  206. package/lib/services/agent/planner.js +14 -0
  207. package/lib/services/agent/providerFallback/chains.d.ts +100 -0
  208. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -0
  209. package/lib/services/agent/providerFallback/chains.js +198 -0
  210. package/lib/services/agent/providerFallback/classifier.d.ts +36 -0
  211. package/lib/services/agent/providerFallback/classifier.d.ts.map +1 -0
  212. package/lib/services/agent/providerFallback/classifier.js +103 -0
  213. package/lib/services/agent/providerFallback/index.d.ts +4 -0
  214. package/lib/services/agent/providerFallback/index.d.ts.map +1 -0
  215. package/lib/services/agent/providerFallback/index.js +19 -0
  216. package/lib/services/agent/providerFallback/withFallback.d.ts +60 -0
  217. package/lib/services/agent/providerFallback/withFallback.d.ts.map +1 -0
  218. package/lib/services/agent/providerFallback/withFallback.js +93 -0
  219. package/lib/services/agent/providerTaskCache.d.ts +50 -0
  220. package/lib/services/agent/providerTaskCache.d.ts.map +1 -0
  221. package/lib/services/agent/providerTaskCache.js +98 -0
  222. package/lib/services/agent/qualityGate.d.ts +82 -0
  223. package/lib/services/agent/qualityGate.d.ts.map +1 -0
  224. package/lib/services/agent/qualityGate.js +232 -0
  225. package/lib/services/agent/referenceImageRenderer.d.ts +37 -0
  226. package/lib/services/agent/referenceImageRenderer.d.ts.map +1 -0
  227. package/lib/services/agent/referenceImageRenderer.js +92 -0
  228. package/lib/services/agent/regenCore.d.ts +60 -0
  229. package/lib/services/agent/regenCore.d.ts.map +1 -0
  230. package/lib/services/agent/regenCore.js +487 -0
  231. package/lib/services/agent/runHelpers.d.ts +44 -0
  232. package/lib/services/agent/runHelpers.d.ts.map +1 -0
  233. package/lib/services/agent/runHelpers.js +196 -0
  234. package/lib/services/agent/sceneLayoutVision.d.ts +90 -0
  235. package/lib/services/agent/sceneLayoutVision.d.ts.map +1 -0
  236. package/lib/services/agent/sceneLayoutVision.js +212 -0
  237. package/lib/services/agent/stitchedVideoCritic.d.ts +136 -0
  238. package/lib/services/agent/stitchedVideoCritic.d.ts.map +1 -0
  239. package/lib/services/agent/stitchedVideoCritic.gemini.d.ts +26 -0
  240. package/lib/services/agent/stitchedVideoCritic.gemini.d.ts.map +1 -0
  241. package/lib/services/agent/stitchedVideoCritic.gemini.js +198 -0
  242. package/lib/services/agent/stitchedVideoCritic.js +162 -0
  243. package/lib/services/agent/taskPoller.d.ts +65 -0
  244. package/lib/services/agent/taskPoller.d.ts.map +1 -0
  245. package/lib/services/agent/taskPoller.js +176 -0
  246. package/lib/services/agent/textOverlayStyles.d.ts +60 -0
  247. package/lib/services/agent/textOverlayStyles.d.ts.map +1 -0
  248. package/lib/services/agent/textOverlayStyles.js +174 -0
  249. package/lib/services/agent/toolRegistry.d.ts +73 -0
  250. package/lib/services/agent/toolRegistry.d.ts.map +1 -0
  251. package/lib/services/agent/toolRegistry.js +95 -0
  252. package/lib/services/agent/tools/analyzeReference.tool.d.ts +36 -0
  253. package/lib/services/agent/tools/analyzeReference.tool.d.ts.map +1 -0
  254. package/lib/services/agent/tools/analyzeReference.tool.js +44 -0
  255. package/lib/services/agent/tools/animateImage.tool.d.ts +24 -0
  256. package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -0
  257. package/lib/services/agent/tools/animateImage.tool.js +115 -0
  258. package/lib/services/agent/tools/animateImageWithMotionBrush.tool.d.ts +32 -0
  259. package/lib/services/agent/tools/animateImageWithMotionBrush.tool.d.ts.map +1 -0
  260. package/lib/services/agent/tools/animateImageWithMotionBrush.tool.js +135 -0
  261. package/lib/services/agent/tools/composeScene.tool.d.ts +978 -0
  262. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -0
  263. package/lib/services/agent/tools/composeScene.tool.js +90 -0
  264. package/lib/services/agent/tools/estimateCost.tool.d.ts +352 -0
  265. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -0
  266. package/lib/services/agent/tools/estimateCost.tool.js +62 -0
  267. package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts +32 -0
  268. package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts.map +1 -0
  269. package/lib/services/agent/tools/generateAvatarVideo.tool.js +143 -0
  270. package/lib/services/agent/tools/generateCaptions.tool.d.ts +42 -0
  271. package/lib/services/agent/tools/generateCaptions.tool.d.ts.map +1 -0
  272. package/lib/services/agent/tools/generateCaptions.tool.js +196 -0
  273. package/lib/services/agent/tools/generateImage.tool.d.ts +74 -0
  274. package/lib/services/agent/tools/generateImage.tool.d.ts.map +1 -0
  275. package/lib/services/agent/tools/generateImage.tool.js +206 -0
  276. package/lib/services/agent/tools/generateVideo.tool.d.ts +31 -0
  277. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -0
  278. package/lib/services/agent/tools/generateVideo.tool.js +153 -0
  279. package/lib/services/agent/tools/generateVoiceover.tool.d.ts +44 -0
  280. package/lib/services/agent/tools/generateVoiceover.tool.d.ts.map +1 -0
  281. package/lib/services/agent/tools/generateVoiceover.tool.js +206 -0
  282. package/lib/services/agent/tools/index.d.ts +20 -0
  283. package/lib/services/agent/tools/index.d.ts.map +1 -0
  284. package/lib/services/agent/tools/index.js +35 -0
  285. package/lib/services/agent/tools/planVideo.tool.d.ts +343 -0
  286. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -0
  287. package/lib/services/agent/tools/planVideo.tool.js +46 -0
  288. package/lib/services/agent/tools/render.tool.d.ts +367 -0
  289. package/lib/services/agent/tools/render.tool.d.ts.map +1 -0
  290. package/lib/services/agent/tools/render.tool.js +48 -0
  291. package/lib/services/agent/tools/searchMusic.tool.d.ts +49 -0
  292. package/lib/services/agent/tools/searchMusic.tool.d.ts.map +1 -0
  293. package/lib/services/agent/tools/searchMusic.tool.js +74 -0
  294. package/lib/services/agent/tools/searchStock.tool.d.ts +41 -0
  295. package/lib/services/agent/tools/searchStock.tool.d.ts.map +1 -0
  296. package/lib/services/agent/tools/searchStock.tool.js +314 -0
  297. package/lib/services/agent/tools/searchUserLibrary.tool.d.ts +59 -0
  298. package/lib/services/agent/tools/searchUserLibrary.tool.d.ts.map +1 -0
  299. package/lib/services/agent/tools/searchUserLibrary.tool.js +58 -0
  300. package/lib/services/agent/ttsDuration.d.ts +29 -0
  301. package/lib/services/agent/ttsDuration.d.ts.map +1 -0
  302. package/lib/services/agent/ttsDuration.js +60 -0
  303. package/lib/services/aiGen/aiGenFactory.service.d.ts +21 -1
  304. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  305. package/lib/services/aiGen/aiGenFactory.service.js +84 -21
  306. package/lib/services/aiGen/canonicalAdapters/cameraControl.types.d.ts +31 -0
  307. package/lib/services/aiGen/canonicalAdapters/cameraControl.types.d.ts.map +1 -0
  308. package/lib/services/aiGen/canonicalAdapters/cameraControl.types.js +2 -0
  309. package/lib/services/aiGen/canonicalAdapters/index.d.ts +3 -0
  310. package/lib/services/aiGen/canonicalAdapters/index.d.ts.map +1 -0
  311. package/lib/services/aiGen/canonicalAdapters/index.js +18 -0
  312. package/lib/services/aiGen/canonicalAdapters/multiShot.types.d.ts +23 -0
  313. package/lib/services/aiGen/canonicalAdapters/multiShot.types.d.ts.map +1 -0
  314. package/lib/services/aiGen/canonicalAdapters/multiShot.types.js +12 -0
  315. package/lib/services/aiGen/helpers.d.ts.map +1 -1
  316. package/lib/services/aiGen/helpers.js +10 -0
  317. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +14 -3
  318. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -1
  319. package/lib/services/aiGen/providers/alibaba/alibaba.js +155 -22
  320. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts +22 -4
  321. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts.map +1 -1
  322. package/lib/services/aiGen/providers/baseAiGenProvider.service.js +32 -0
  323. package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
  324. package/lib/services/aiGen/providers/bytedance/bytedance.service.js +13 -19
  325. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts +18 -0
  326. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts.map +1 -0
  327. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.js +102 -0
  328. package/lib/services/aiGen/providers/fal/falImage.service.d.ts +15 -0
  329. package/lib/services/aiGen/providers/fal/falImage.service.d.ts.map +1 -0
  330. package/lib/services/aiGen/providers/fal/falImage.service.js +141 -0
  331. package/lib/services/aiGen/providers/fal/index.d.ts +2 -0
  332. package/lib/services/aiGen/providers/fal/index.d.ts.map +1 -0
  333. package/lib/services/aiGen/providers/fal/index.js +17 -0
  334. package/lib/services/aiGen/providers/google/google.service.d.ts +11 -2
  335. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  336. package/lib/services/aiGen/providers/google/google.service.js +245 -28
  337. package/lib/services/aiGen/providers/index.d.ts +3 -0
  338. package/lib/services/aiGen/providers/index.d.ts.map +1 -1
  339. package/lib/services/aiGen/providers/index.js +3 -0
  340. package/lib/services/aiGen/providers/kling/cameraAdapter.d.ts +4 -0
  341. package/lib/services/aiGen/providers/kling/cameraAdapter.d.ts.map +1 -0
  342. package/lib/services/aiGen/providers/kling/cameraAdapter.js +53 -0
  343. package/lib/services/aiGen/providers/kling/index.d.ts +1 -0
  344. package/lib/services/aiGen/providers/kling/index.d.ts.map +1 -1
  345. package/lib/services/aiGen/providers/kling/index.js +1 -0
  346. package/lib/services/aiGen/providers/kling/kling.service.d.ts +12 -1
  347. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  348. package/lib/services/aiGen/providers/kling/kling.service.js +357 -26
  349. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts +21 -0
  350. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts.map +1 -0
  351. package/lib/services/aiGen/providers/kling/klingImage.service.js +208 -0
  352. package/lib/services/aiGen/providers/kling/types.d.ts +105 -0
  353. package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -1
  354. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +15 -2
  355. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
  356. package/lib/services/aiGen/providers/minimax/minimax.service.js +128 -5
  357. package/lib/services/aiGen/providers/minimax/types.d.ts +10 -1
  358. package/lib/services/aiGen/providers/minimax/types.d.ts.map +1 -1
  359. package/lib/services/aiGen/providers/openai/openai.service.d.ts +8 -2
  360. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
  361. package/lib/services/aiGen/providers/openai/openai.service.js +184 -7
  362. package/lib/services/aiGen/providers/pexels/index.d.ts +2 -0
  363. package/lib/services/aiGen/providers/pexels/index.d.ts.map +1 -0
  364. package/lib/services/aiGen/providers/{azure → pexels}/index.js +1 -1
  365. package/lib/services/aiGen/providers/pexels/pexels.service.d.ts +11 -0
  366. package/lib/services/aiGen/providers/pexels/pexels.service.d.ts.map +1 -0
  367. package/lib/services/aiGen/providers/pexels/pexels.service.js +150 -0
  368. package/lib/services/aiGen/providers/pixabay/index.d.ts +2 -0
  369. package/lib/services/aiGen/providers/pixabay/index.d.ts.map +1 -0
  370. package/lib/services/aiGen/providers/pixabay/index.js +17 -0
  371. package/lib/services/aiGen/providers/pixabay/pixabay.service.d.ts +12 -0
  372. package/lib/services/aiGen/providers/pixabay/pixabay.service.d.ts.map +1 -0
  373. package/lib/services/aiGen/providers/pixabay/pixabay.service.js +156 -0
  374. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  375. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +125 -2
  376. package/lib/services/aiGen/providers/runway/cameraAdapter.d.ts +3 -0
  377. package/lib/services/aiGen/providers/runway/cameraAdapter.d.ts.map +1 -0
  378. package/lib/services/aiGen/providers/runway/cameraAdapter.js +46 -0
  379. package/lib/services/aiGen/providers/runway/runway.service.d.ts +12 -2
  380. package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
  381. package/lib/services/aiGen/providers/runway/runway.service.js +224 -21
  382. package/lib/services/aiGen/providers/types.d.ts +263 -6
  383. package/lib/services/aiGen/providers/types.d.ts.map +1 -1
  384. package/lib/services/aiGen/providers/unsplash/index.d.ts +2 -0
  385. package/lib/services/aiGen/providers/unsplash/index.d.ts.map +1 -0
  386. package/lib/services/aiGen/providers/unsplash/index.js +17 -0
  387. package/lib/services/aiGen/providers/unsplash/unsplash.service.d.ts +16 -0
  388. package/lib/services/aiGen/providers/unsplash/unsplash.service.d.ts.map +1 -0
  389. package/lib/services/aiGen/providers/unsplash/unsplash.service.js +131 -0
  390. package/lib/services/analytics.service.js +2 -4
  391. package/lib/services/apiUsageCounter.service.d.ts +20 -0
  392. package/lib/services/apiUsageCounter.service.d.ts.map +1 -0
  393. package/lib/services/apiUsageCounter.service.js +84 -0
  394. package/lib/services/asr/assemblyai.service.d.ts +72 -0
  395. package/lib/services/asr/assemblyai.service.d.ts.map +1 -0
  396. package/lib/services/asr/assemblyai.service.js +89 -0
  397. package/lib/services/asr/index.d.ts +3 -0
  398. package/lib/services/asr/index.d.ts.map +1 -0
  399. package/lib/services/asr/index.js +18 -0
  400. package/lib/services/asr/whisper.service.d.ts +18 -0
  401. package/lib/services/asr/whisper.service.d.ts.map +1 -0
  402. package/lib/services/asr/whisper.service.js +151 -0
  403. package/lib/services/assetCache.service.d.ts +54 -0
  404. package/lib/services/assetCache.service.d.ts.map +1 -0
  405. package/lib/services/assetCache.service.js +109 -0
  406. package/lib/services/audioAnalysis/index.d.ts +2 -0
  407. package/lib/services/audioAnalysis/index.d.ts.map +1 -0
  408. package/lib/services/audioAnalysis/index.js +17 -0
  409. package/lib/services/audioAnalysis/onsetDetection.service.d.ts +50 -0
  410. package/lib/services/audioAnalysis/onsetDetection.service.d.ts.map +1 -0
  411. package/lib/services/audioAnalysis/onsetDetection.service.js +140 -0
  412. package/lib/services/bullmq.service.d.ts +6 -1
  413. package/lib/services/bullmq.service.d.ts.map +1 -1
  414. package/lib/services/bullmq.service.js +62 -14
  415. package/lib/services/credit.service.d.ts.map +1 -1
  416. package/lib/services/credit.service.js +45 -7
  417. package/lib/services/credits/pricing.d.ts +58 -0
  418. package/lib/services/credits/pricing.d.ts.map +1 -0
  419. package/lib/services/credits/pricing.js +111 -0
  420. package/lib/services/editor/designToProject.d.ts +75 -0
  421. package/lib/services/editor/designToProject.d.ts.map +1 -0
  422. package/lib/services/editor/designToProject.js +295 -0
  423. package/lib/services/editor/planToProject.d.ts +84 -0
  424. package/lib/services/editor/planToProject.d.ts.map +1 -0
  425. package/lib/services/editor/planToProject.js +395 -0
  426. package/lib/services/editor/projectToDesign.d.ts +4 -0
  427. package/lib/services/editor/projectToDesign.d.ts.map +1 -0
  428. package/lib/services/editor/projectToDesign.js +186 -0
  429. package/lib/services/firestore.service.d.ts +17 -0
  430. package/lib/services/firestore.service.d.ts.map +1 -1
  431. package/lib/services/firestore.service.js +30 -0
  432. package/lib/services/gcp/index.d.ts +1 -0
  433. package/lib/services/gcp/index.d.ts.map +1 -1
  434. package/lib/services/gcp/index.js +1 -0
  435. package/lib/services/gcp/uploadAudioBuffer.d.ts +13 -0
  436. package/lib/services/gcp/uploadAudioBuffer.d.ts.map +1 -0
  437. package/lib/services/gcp/uploadAudioBuffer.js +28 -0
  438. package/lib/services/index.d.ts +13 -0
  439. package/lib/services/index.d.ts.map +1 -1
  440. package/lib/services/index.js +13 -0
  441. package/lib/services/musicGen/index.d.ts +6 -0
  442. package/lib/services/musicGen/index.d.ts.map +1 -0
  443. package/lib/services/musicGen/index.js +26 -0
  444. package/lib/services/musicGen/musicSearchFactory.service.d.ts +14 -0
  445. package/lib/services/musicGen/musicSearchFactory.service.d.ts.map +1 -0
  446. package/lib/services/musicGen/musicSearchFactory.service.js +59 -0
  447. package/lib/services/musicGen/providers/curated.service.d.ts +24 -0
  448. package/lib/services/musicGen/providers/curated.service.d.ts.map +1 -0
  449. package/lib/services/musicGen/providers/curated.service.js +173 -0
  450. package/lib/services/musicGen/providers/jamendo.service.d.ts +8 -0
  451. package/lib/services/musicGen/providers/jamendo.service.d.ts.map +1 -0
  452. package/lib/services/musicGen/providers/jamendo.service.js +113 -0
  453. package/lib/services/musicGen/providers/mubert.service.d.ts +10 -0
  454. package/lib/services/musicGen/providers/mubert.service.d.ts.map +1 -0
  455. package/lib/services/musicGen/providers/mubert.service.js +128 -0
  456. package/lib/services/musicGen/types.d.ts +46 -0
  457. package/lib/services/musicGen/types.d.ts.map +1 -0
  458. package/lib/services/musicGen/types.js +10 -0
  459. package/lib/services/notification.service.d.ts +22 -0
  460. package/lib/services/notification.service.d.ts.map +1 -0
  461. package/lib/services/notification.service.js +76 -0
  462. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts +78 -0
  463. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts.map +1 -0
  464. package/lib/services/rateLimiter/distributedRateLimiter.service.js +269 -0
  465. package/lib/services/rateLimiter/index.d.ts +2 -0
  466. package/lib/services/rateLimiter/index.d.ts.map +1 -0
  467. package/lib/services/rateLimiter/index.js +17 -0
  468. package/lib/services/redis.service.d.ts +9 -0
  469. package/lib/services/redis.service.d.ts.map +1 -1
  470. package/lib/services/redis.service.js +20 -11
  471. package/lib/services/redisOptions.d.ts +22 -0
  472. package/lib/services/redisOptions.d.ts.map +1 -0
  473. package/lib/services/redisOptions.js +51 -0
  474. package/lib/services/tts/index.d.ts +2 -0
  475. package/lib/services/tts/index.d.ts.map +1 -1
  476. package/lib/services/tts/index.js +2 -0
  477. package/lib/services/tts/providers/elevenlabs.service.d.ts.map +1 -1
  478. package/lib/services/tts/providers/elevenlabs.service.js +91 -24
  479. package/lib/services/tts/providers/minimax.service.d.ts +14 -0
  480. package/lib/services/tts/providers/minimax.service.d.ts.map +1 -0
  481. package/lib/services/tts/providers/minimax.service.js +78 -0
  482. package/lib/services/tts/providers/openai.service.d.ts +14 -0
  483. package/lib/services/tts/providers/openai.service.d.ts.map +1 -0
  484. package/lib/services/tts/providers/openai.service.js +73 -0
  485. package/lib/services/tts/ttsFactory.service.d.ts.map +1 -1
  486. package/lib/services/tts/ttsFactory.service.js +6 -0
  487. package/lib/services/tts/types.d.ts +33 -0
  488. package/lib/services/tts/types.d.ts.map +1 -1
  489. package/lib/utils/errors.d.ts +8 -0
  490. package/lib/utils/errors.d.ts.map +1 -1
  491. package/lib/utils/errors.js +8 -0
  492. package/lib/utils/helpers.d.ts +13 -0
  493. package/lib/utils/helpers.d.ts.map +1 -1
  494. package/lib/utils/helpers.js +48 -11
  495. package/lib/utils/logger.d.ts.map +1 -1
  496. package/lib/utils/logger.js +37 -1
  497. package/package.json +5 -1
  498. package/lib/services/aiGen/providers/azure/azure.service.d.ts +0 -14
  499. package/lib/services/aiGen/providers/azure/azure.service.d.ts.map +0 -1
  500. package/lib/services/aiGen/providers/azure/azure.service.js +0 -108
  501. package/lib/services/aiGen/providers/azure/index.d.ts +0 -2
  502. package/lib/services/aiGen/providers/azure/index.d.ts.map +0 -1
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkDurationContract = checkDurationContract;
4
+ exports.checkCaptionsContract = checkCaptionsContract;
5
+ exports.checkNarrationDensityContract = checkNarrationDensityContract;
6
+ exports.checkSceneTtsBudget = checkSceneTtsBudget;
7
+ exports.checkSceneDurationCapability = checkSceneDurationCapability;
8
+ exports.collectSceneVoClipWarnings = collectSceneVoClipWarnings;
9
+ exports.collectSceneTrailingSilenceWarnings = collectSceneTrailingSilenceWarnings;
10
+ exports.collectPlanWarnings = collectPlanWarnings;
11
+ const tierHelpers_1 = require("../../../globals/aiModels/tierHelpers");
12
+ const ttsDuration_1 = require("../ttsDuration");
13
+ /**
14
+ * Single threshold for the trailing-silence warning. The executor pads
15
+ * scene-tail audio with a brief release (≈250ms); anything beyond ~1200ms
16
+ * of empty audio over a continuing visual reads as dead air on UGC, social,
17
+ * and explainer formats. Visual-led moments (real-estate panning, product
18
+ * close-ups) can opt out per-scene via `allowTrailingSilence`.
19
+ *
20
+ * Tunable. Not niche-gated by design — single threshold per the OD note.
21
+ */
22
+ const TRAILING_SILENCE_WARN_MS = 1200;
23
+ /**
24
+ * AG-9: hard duration contract. Returns null if the plan honours the brief's
25
+ * requested duration within 10%, otherwise returns a correction message to
26
+ * feed back to the planner on retry.
27
+ */
28
+ function checkDurationContract(plan, brief) {
29
+ if (!brief.durationSec)
30
+ return null;
31
+ const target = brief.durationSec * 1000;
32
+ const actual = plan.scenes.reduce((sum, s) => sum + s.durationMs, 0);
33
+ const ratio = actual / target;
34
+ if (ratio >= 0.9 && ratio <= 1.1)
35
+ return null;
36
+ const direction = ratio < 0.9 ? "under" : "over";
37
+ if (direction === "under") {
38
+ // Math hint: at the chosen pacing band, suggest the per-scene avg the
39
+ // planner should target so it doesn't keep shipping the same N-scene plan
40
+ // on retry. Mirrors the bands in buildStructuralRulesSection.
41
+ const missingMs = target - actual;
42
+ const fastCutNiches = ["ugc-ad", "social-recap", "fitness"];
43
+ const effectivePacing = brief.pacing ??
44
+ ((brief.niche && fastCutNiches.includes(brief.niche)) ? "fast" : "medium");
45
+ const avgMsByPacing = {
46
+ "very-fast": 2500,
47
+ fast: 3500,
48
+ medium: 5000,
49
+ slow: 8000,
50
+ };
51
+ const perSceneMs = avgMsByPacing[effectivePacing];
52
+ const extraScenes = Math.max(1, Math.ceil(missingMs / perSceneMs));
53
+ return `Plan duration ${Math.round(actual / 1000)}s under-delivers vs brief.durationSec=${brief.durationSec}s (ratio ${ratio.toFixed(2)}). You currently have ${plan.scenes.length} scenes; ADD approximately ${extraScenes} more scenes (B-roll, transitions, product close-ups, lifestyle inserts) at ~${perSceneMs}ms each (pacing="${effectivePacing}"). Do NOT shorten existing scenes below the pacing band — add new scenes OR extend existing scenes within the band instead.`;
54
+ }
55
+ return `Plan duration ${Math.round(actual / 1000)}s over-delivers vs brief.durationSec=${brief.durationSec}s (ratio ${ratio.toFixed(2)}). Drop low-value scenes or shorten the hook to land within ±10% of ${brief.durationSec}s.`;
56
+ }
57
+ /**
58
+ * Captions contract. Faceless-YT explainers / TikTok shorts / any brief that
59
+ * mentions "captions" or "subtitles" MUST ship with at least one overlay per
60
+ * scene (the audience is sound-off by default). Returns a correction directive
61
+ * when the contract is broken; null when satisfied or N/A.
62
+ *
63
+ * Talking-head-avatar scenes are exempt — the avatar IS the on-screen text
64
+ * substitute and burned-in captions on top of a presenter feel cluttered.
65
+ */
66
+ function checkCaptionsContract(plan, brief) {
67
+ const captionRequiredNiches = new Set(["faceless-yt", "social-recap", "fitness"]);
68
+ const mentionsCaptions = /\b(caption|subtitle|on-screen text|burned-in text)\b/i.test(brief.rawPrompt ?? "");
69
+ const required = (brief.niche && captionRequiredNiches.has(brief.niche)) || mentionsCaptions;
70
+ if (!required)
71
+ return null;
72
+ const missing = [];
73
+ for (const s of plan.scenes) {
74
+ if (s.strategy === "talking-head-avatar")
75
+ continue;
76
+ const hasOverlay = (s.overlays?.length ?? 0) > 0;
77
+ const hasLegacyText = !!s.onScreenText?.trim();
78
+ if (!hasOverlay && !hasLegacyText)
79
+ missing.push(s.sceneIndex);
80
+ }
81
+ if (missing.length === 0)
82
+ return null;
83
+ return (`Captions contract violation: brief requires burned-in captions ` +
84
+ `(niche=${brief.niche ?? "?"}, mentionsCaptions=${mentionsCaptions}) but ` +
85
+ `${missing.length} scene(s) ship with no overlays AND no onScreenText: ` +
86
+ `sceneIndex ${missing.join(", ")}. For EACH missing scene, add an overlays[] ` +
87
+ `entry: usually role='headline' (max 6 words, the literal key phrase) or ` +
88
+ `role='body' (max 14 words, the literal supporting sentence). The overlay ` +
89
+ `text field is what users will read on screen — NOT a description of font/ ` +
90
+ `color/position. The last scene MUST also include role='cta'. Watermark on ` +
91
+ `scene 0 only with persistAcrossScenes:true. Do NOT ship a faceless-YT ` +
92
+ `plan with empty overlays.`);
93
+ }
94
+ /**
95
+ * Narration-density contract. When a plan is narration-driven (>50% of scenes
96
+ * carry a voiceoverLine) AND brief.pacing is "medium" or "slow", every scene
97
+ * MUST be >= 3500ms. Sub-3.5s narration scenes produce telegraphic 3-4 word
98
+ * lines that read like a TikTok listicle instead of an informational explainer
99
+ * — the failure mode the user hit with 15×2s scenes for a 30s faceless-yt
100
+ * brief at medium pacing. Returns null when the plan satisfies the contract
101
+ * or the contract doesn't apply (fast/very-fast pacing, or VO-light plans).
102
+ */
103
+ function checkNarrationDensityContract(plan, brief) {
104
+ if (brief.pacing !== "medium" && brief.pacing !== "slow")
105
+ return null;
106
+ const scenesWithVo = plan.scenes.filter((s) => !!s.voiceoverLine?.trim());
107
+ if (scenesWithVo.length <= plan.scenes.length / 2)
108
+ return null; // not narration-driven
109
+ const tooShort = plan.scenes
110
+ .filter((s) => !!s.voiceoverLine?.trim() && s.durationMs < 3500)
111
+ .map((s) => ({ sceneIndex: s.sceneIndex, durationMs: s.durationMs }));
112
+ if (tooShort.length === 0)
113
+ return null;
114
+ const list = tooShort
115
+ .map((s) => `scene ${s.sceneIndex} (${s.durationMs}ms)`)
116
+ .join(", ");
117
+ return (`Narration-density violation: brief.pacing="${brief.pacing}" with a ` +
118
+ `narration-driven plan (${scenesWithVo.length}/${plan.scenes.length} ` +
119
+ `scenes carry voiceoverLine), but ${tooShort.length} scene(s) are ` +
120
+ `shorter than 3500ms: ${list}. At medium/slow pacing each narrated ` +
121
+ `scene needs at least one full sentence (~3.5s minimum) — telegraphic ` +
122
+ `2-3s cuts feel like a TikTok listicle, not an informational explainer. ` +
123
+ `CONSOLIDATE: merge consecutive short scenes into longer ones (each ` +
124
+ `4000-6000ms for medium, 6000-10000ms for slow) and keep one full ` +
125
+ `sentence of voiceover per scene. Fewer scenes is correct here — aim ` +
126
+ `for ${Math.max(1, Math.round((brief.durationSec ?? 30) * 1000 / (brief.pacing === "slow" ? 8000 : 5000)))} scenes total at this pacing.`);
127
+ }
128
+ /**
129
+ * AG-28: per-scene voiceover-budget validator. Estimates TTS duration from the
130
+ * VO line's word count + punctuation. If the estimate exceeds the scene's
131
+ * durationMs by >10%, return a correction directive listing the offending
132
+ * scenes + the max word count that would fit. The planner can either shorten
133
+ * the line or merge with the next scene on retry.
134
+ */
135
+ function checkSceneTtsBudget(plan) {
136
+ const offending = [];
137
+ for (const s of plan.scenes) {
138
+ if (!s.voiceoverLine)
139
+ continue;
140
+ if (s.strategy === "talking-head-avatar")
141
+ continue; // avatar bakes VO into the clip
142
+ const estMs = (0, ttsDuration_1.estimateTtsMs)(s.voiceoverLine);
143
+ if (estMs <= s.durationMs * 1.1)
144
+ continue;
145
+ const words = s.voiceoverLine.trim().split(/\s+/).filter(Boolean).length;
146
+ offending.push({
147
+ sceneIndex: s.sceneIndex,
148
+ durationMs: s.durationMs,
149
+ estimateMs: estMs,
150
+ words,
151
+ maxWords: (0, ttsDuration_1.maxVoWordsForMs)(s.durationMs),
152
+ line: s.voiceoverLine,
153
+ });
154
+ }
155
+ if (offending.length === 0)
156
+ return null;
157
+ const details = offending
158
+ .map((o) => `scene ${o.sceneIndex} (${o.durationMs}ms): "${o.line}" — ${o.words} words ≈ ${o.estimateMs}ms VO (max ${o.maxWords} words for this scene duration)`)
159
+ .join("; ");
160
+ return `Voiceover budget violation on ${offending.length} scene(s): ${details}. Either (a) shorten each offending voiceoverLine to <= the listed max-word count, or (b) extend scene.durationMs to >= the estimated VO ms (respecting the duration contract — if that pushes you over total, drop another scene's VO entirely or shorten a different scene). Do NOT ship the plan as-is — the audio will be clipped mid-sentence.`;
161
+ }
162
+ /**
163
+ * AG-15: per-scene duration-capability validator. For each scene using an AI
164
+ * video provider (ai-image-to-video / ai-text-to-video), confirm that
165
+ * scene.durationMs/1000 is in the preferredModel's allowed-durations list. On
166
+ * mismatch, build a directive correction the planner can act on: name the
167
+ * offending scenes + suggest a model whose `dur:` range actually accepts the
168
+ * requested duration. Root cause for Test-1 burning $0 of useful work: planner
169
+ * picked minimax-hailuo-02 (6s / 10s only) for 1.7s scenes — fallback chain
170
+ * exhausted because every fallback was also a ≥6s model.
171
+ */
172
+ function checkSceneDurationCapability(plan) {
173
+ const offending = [];
174
+ const aiVideoStrategies = new Set(["ai-image-to-video", "ai-text-to-video"]);
175
+ for (const scene of plan.scenes) {
176
+ if (!aiVideoStrategies.has(scene.strategy))
177
+ continue;
178
+ if (!scene.preferredModel)
179
+ continue;
180
+ const allowed = (0, tierHelpers_1.getModelAllowedDurations)(scene.preferredModel);
181
+ if (!allowed)
182
+ continue; // model has no declared constraint
183
+ const seconds = scene.durationMs / 1000;
184
+ // Allow ±0.25s wiggle so 1.8s → 2 floor doesn't trip on rounding.
185
+ const matches = allowed.some((v) => Math.abs(v - seconds) < 0.25);
186
+ if (!matches) {
187
+ offending.push({
188
+ sceneIndex: scene.sceneIndex,
189
+ seconds: Math.round(seconds * 100) / 100,
190
+ modelKey: scene.preferredModel,
191
+ allowed,
192
+ });
193
+ }
194
+ }
195
+ if (offending.length === 0)
196
+ return null;
197
+ const details = offending
198
+ .map((o) => `scene ${o.sceneIndex} (${o.seconds}s) → ${o.modelKey} only accepts [${o.allowed.join(", ")}]s`)
199
+ .join("; ");
200
+ return (`AG-15 duration-capability mismatch: ${details}. ` +
201
+ `Fix BY EITHER: (a) merging too-short scenes into a single ≥${offending[0].allowed[0]}s clip so the cut count drops but the total duration stays the same, OR ` +
202
+ `(b) re-picking preferredModel from a provider whose dur: range INCLUDES the scene's duration. ` +
203
+ `Short-duration capable models: bytedance-seedance-1.0-pro-fast (2-12s), bytedance-seedance-1.0-pro (2-12s), runway-gen4.5 (2-10s), kling-v3.0 (3-15s), google-veo-3.1-lite (4-8s). ` +
204
+ `Do NOT pick minimax-hailuo for any scene shorter than 6s.`);
205
+ }
206
+ /**
207
+ * Warning-channel siblings of the rejection validators above. These run on
208
+ * an already-approved plan (or after a sceneEdit patch) and produce
209
+ * PlannerWarning entries the UI can surface — never rejection strings.
210
+ */
211
+ /** Demote vo-clip rejections to warnings after the planner has exhausted retries. */
212
+ function collectSceneVoClipWarnings(plan) {
213
+ const warnings = [];
214
+ for (const s of plan.scenes) {
215
+ if (!s.voiceoverLine)
216
+ continue;
217
+ if (s.strategy === "talking-head-avatar")
218
+ continue;
219
+ const estMs = (0, ttsDuration_1.estimateTtsMs)(s.voiceoverLine);
220
+ // Mirror executor's 1.15× speedup cap: VO actually clips only when
221
+ // est / 1.15 still exceeds scene.durationMs * 1.05.
222
+ const adjustedEstMs = estMs / 1.15;
223
+ const budgetMs = s.durationMs * 1.05;
224
+ if (adjustedEstMs <= budgetMs)
225
+ continue;
226
+ const overrunMs = Math.round(adjustedEstMs - budgetMs);
227
+ warnings.push({
228
+ sceneIndex: s.sceneIndex,
229
+ kind: "vo-clip",
230
+ message: `Voiceover will overrun this scene by ~${overrunMs}ms even after the ` +
231
+ `1.15× speedup. Audio will clip mid-sentence. Extend the scene ` +
232
+ `duration or shorten the voiceover line (max ~${(0, ttsDuration_1.maxVoWordsForMs)(s.durationMs)} words).`,
233
+ meta: {
234
+ voEstimateMs: Math.round(estMs),
235
+ sceneDurationMs: s.durationMs,
236
+ overrunMs,
237
+ },
238
+ });
239
+ }
240
+ return warnings;
241
+ }
242
+ /**
243
+ * Warn when a scene's VO ends notably before the scene itself ends — that
244
+ * extra time renders as silence over a continuing visual, which reads as
245
+ * dead air on most formats. Suppressed when `scene.allowTrailingSilence`
246
+ * is set (visual-led moments). Scenes without VO are exempt (silence by
247
+ * design — handled by music / ambience tracks).
248
+ */
249
+ function collectSceneTrailingSilenceWarnings(plan) {
250
+ const warnings = [];
251
+ for (const s of plan.scenes) {
252
+ if (!s.voiceoverLine?.trim())
253
+ continue;
254
+ if (s.strategy === "talking-head-avatar")
255
+ continue; // VO is baked into avatar clip
256
+ if (s.allowTrailingSilence)
257
+ continue;
258
+ const estMs = (0, ttsDuration_1.estimateTtsMs)(s.voiceoverLine);
259
+ const silenceMs = s.durationMs - estMs;
260
+ if (silenceMs <= TRAILING_SILENCE_WARN_MS)
261
+ continue;
262
+ warnings.push({
263
+ sceneIndex: s.sceneIndex,
264
+ kind: "trailing-silence",
265
+ message: `Voiceover ends ~${Math.round(silenceMs / 100) / 10}s before this ` +
266
+ `scene ends — the visual will play in silence. Shorten the scene ` +
267
+ `duration, lengthen the voiceover, or toggle "Allow trailing silence" ` +
268
+ `if this is an intentional showcase moment.`,
269
+ meta: {
270
+ voEstimateMs: Math.round(estMs),
271
+ sceneDurationMs: s.durationMs,
272
+ silenceMs: Math.round(silenceMs),
273
+ },
274
+ });
275
+ }
276
+ return warnings;
277
+ }
278
+ /** One-shot helper: returns the full warning set for a plan + scene overrides. */
279
+ function collectPlanWarnings(plan) {
280
+ return [
281
+ ...collectSceneVoClipWarnings(plan),
282
+ ...collectSceneTrailingSilenceWarnings(plan),
283
+ ];
284
+ }
@@ -0,0 +1,3 @@
1
+ export { Planner, type PlannerOptions } from "./planner/Planner";
2
+ export { checkSceneTtsBudget, checkSceneDurationCapability, collectPlanWarnings, collectSceneVoClipWarnings, collectSceneTrailingSilenceWarnings, } from "./planner/validators";
3
+ //# sourceMappingURL=planner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../../src/services/agent/planner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,0BAA0B,EAC1B,mCAAmC,GACpC,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectSceneTrailingSilenceWarnings = exports.collectSceneVoClipWarnings = exports.collectPlanWarnings = exports.checkSceneDurationCapability = exports.checkSceneTtsBudget = exports.Planner = void 0;
4
+ // Barrel — planner was split into per-concern modules under `planner/`.
5
+ // Public surface (`Planner`, `PlannerOptions`) is preserved byte-for-byte
6
+ // for npm consumers of `vidspotai-shared`.
7
+ var Planner_1 = require("./planner/Planner");
8
+ Object.defineProperty(exports, "Planner", { enumerable: true, get: function () { return Planner_1.Planner; } });
9
+ var validators_1 = require("./planner/validators");
10
+ Object.defineProperty(exports, "checkSceneTtsBudget", { enumerable: true, get: function () { return validators_1.checkSceneTtsBudget; } });
11
+ Object.defineProperty(exports, "checkSceneDurationCapability", { enumerable: true, get: function () { return validators_1.checkSceneDurationCapability; } });
12
+ Object.defineProperty(exports, "collectPlanWarnings", { enumerable: true, get: function () { return validators_1.collectPlanWarnings; } });
13
+ Object.defineProperty(exports, "collectSceneVoClipWarnings", { enumerable: true, get: function () { return validators_1.collectSceneVoClipWarnings; } });
14
+ Object.defineProperty(exports, "collectSceneTrailingSilenceWarnings", { enumerable: true, get: function () { return validators_1.collectSceneTrailingSilenceWarnings; } });
@@ -0,0 +1,100 @@
1
+ import { EVideoGenModels, EMusicGenModels, ESfxGenModels, type GenerationType } from "../../../globals/aiModels";
2
+ /**
3
+ * Provider-chain configuration per modality (F3.3).
4
+ * Ordered primary → fallback. The wrapper walks the chain on recoverable
5
+ * failures (transient / rate-limit / capability / quota / unknown).
6
+ *
7
+ * Ordering rationale: perceived quality + reliability first. Tier downgrades
8
+ * happen at the AGENT layer (re-plan), not at the chain layer — within a
9
+ * single chain we stay at the same tier.
10
+ *
11
+ * Capability matrix (`videoCapabilities`) filters chains pre-flight so we
12
+ * don't fall back to a model that physically can't do the requested
13
+ * aspect / duration / lastFrame / etc.
14
+ */
15
+ export declare const T3_TEXT_TO_VIDEO_CHAIN: readonly EVideoGenModels[];
16
+ export declare const T2_TEXT_TO_VIDEO_CHAIN: readonly EVideoGenModels[];
17
+ export declare const T2_IMAGE_TO_VIDEO_CHAIN: readonly EVideoGenModels[];
18
+ export declare const T3_IMAGE_TO_VIDEO_CHAIN: readonly EVideoGenModels[];
19
+ export declare const AVATAR_VIDEO_CHAIN: readonly EVideoGenModels[];
20
+ export declare const MUSIC_CHAIN: readonly EMusicGenModels[];
21
+ export declare const SFX_CHAIN: readonly ESfxGenModels[];
22
+ /**
23
+ * AG-16: schema-driven capability gate. We no longer maintain a parallel
24
+ * `VIDEO_CAPABILITIES` table — that drifted from the actual model schemas
25
+ * (e.g. it set `maxDurationSec` but had no concept of a *minimum*, so a 2s
26
+ * request for minimax-hailuo-02 (allowed [6,10]) passed the gate, the call
27
+ * fired, the provider rejected, and the fallback chain wasted attempts on
28
+ * five more models that all had the same minimum). Source of truth is now
29
+ * `aiModelConfigs[modelKey].fields` + `.type`. Pixel-format aspect ratios
30
+ * (Runway's "1280:720" etc.) are normalised to canonical "W:H" before
31
+ * comparison so callers can always pass "9:16" / "16:9" / etc.
32
+ */
33
+ export interface VideoCapabilityRequest {
34
+ aspect: string;
35
+ durationSec: number;
36
+ /** Generation type the chain is being walked for. */
37
+ type?: GenerationType;
38
+ /** Caller wants last-frame anchoring (gen4_turbo / Kling / Veo support it). */
39
+ lastFrame?: boolean;
40
+ /** Caller wants native audio output. */
41
+ audio?: boolean;
42
+ /**
43
+ * AG-21: whether the caller is supplying a source still. Used to filter out
44
+ * providers whose schema marks `inputImageUrl: { required: true }` from a
45
+ * text-to-video chain (e.g. runway-gen4-turbo) — otherwise the call would
46
+ * fire and the provider would reject for missing input image, wasting a
47
+ * fallback slot. Default false (text-to-video assumption); animate_image /
48
+ * image-to-video tools pass true.
49
+ */
50
+ hasInputImage?: boolean;
51
+ }
52
+ export declare function isVideoModelCapable(model: EVideoGenModels, req: VideoCapabilityRequest): boolean;
53
+ /**
54
+ * Build a chain that puts the planner's pick first, then the rest of the
55
+ * tier-appropriate chain (deduped). Honors the planner's intent while still
56
+ * providing fallback when the pick fails.
57
+ */
58
+ export declare function buildVideoChain(plannerPick: EVideoGenModels, fallbackChain: readonly EVideoGenModels[]): EVideoGenModels[];
59
+ /**
60
+ * OD-T7 / AG-42 — snap-or-throw resolver for `preferredModel` duration
61
+ * conflicts.
62
+ *
63
+ * Today the chain layer silently drops a planner-picked model when its
64
+ * duration constraint doesn't match the scene (e.g. pixverse-v6 wants
65
+ * [5, 8, 10, 15]s, scene is 2s → model dropped, fallback picks a different
66
+ * provider, planner intent lost). This helper gives the executor a chance
67
+ * to RESCUE the planner's pick by snapping the scene duration to the
68
+ * nearest legal value when the drift is small.
69
+ *
70
+ * Semantics:
71
+ * - Already legal (±0.25s): return { snapped: durationSec, drift: 0 }
72
+ * - No duration constraint: return { snapped: durationSec, drift: 0 }
73
+ * - Within tolerance: return { snapped: nearest, drift: |Δ| }
74
+ * - Outside tolerance: return null — caller falls back per chain
75
+ *
76
+ * Default tolerance: snap is accepted if the nearest legal value is within
77
+ * ±2s AND within ±50% of the requested duration. The 50% cap protects
78
+ * short clips (1.5s asking for 5s would be a >3x stretch — too much). The
79
+ * 2s cap protects long clips (12s asking for 15s is +25% but only 3s of
80
+ * absolute drift — borderline; rejected by 2s cap which is the stricter
81
+ * one for long values). Callers can tune via `maxDriftSec` / `maxDriftRel`.
82
+ */
83
+ export interface SnapDurationOptions {
84
+ /** Absolute cap in seconds. Default 2.0. */
85
+ maxDriftSec?: number;
86
+ /** Relative cap (fraction of requested duration). Default 0.5 (50%). */
87
+ maxDriftRel?: number;
88
+ }
89
+ export interface SnapDurationResult {
90
+ /** Original requested duration in seconds. */
91
+ requestedSec: number;
92
+ /** Duration to use for the actual provider call (snapped if needed). */
93
+ snappedSec: number;
94
+ /** |snappedSec - requestedSec|. 0 when already legal. */
95
+ driftSec: number;
96
+ /** True when the model declared no duration constraint (anything goes). */
97
+ unconstrained: boolean;
98
+ }
99
+ export declare function snapDurationForModel(model: string | EVideoGenModels, durationSec: number, opts?: SnapDurationOptions): SnapDurationResult | null;
100
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/providerFallback/chains.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,eAAe,EACf,aAAa,EAEb,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;GAYG;AAGH,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAM5D,CAAC;AAKF,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAQ5D,CAAC;AAQF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAQ7D,CAAC;AAKF,eAAO,MAAM,uBAAuB,EAAE,SAAS,eAAe,EAM7D,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAExD,CAAC;AAGF,eAAO,MAAM,WAAW,EAAE,SAAS,eAAe,EAGjD,CAAC;AAGF,eAAO,MAAM,SAAS,EAAE,SAAS,aAAa,EAE7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,sBAAsB,GAC1B,OAAO,CAuCT;AA8CD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,SAAS,eAAe,EAAE,GACxC,eAAe,EAAE,CAMnB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,eAAe,EAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,mBAAwB,GAC7B,kBAAkB,GAAG,IAAI,CAyB3B"}
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SFX_CHAIN = exports.MUSIC_CHAIN = exports.AVATAR_VIDEO_CHAIN = exports.T3_IMAGE_TO_VIDEO_CHAIN = exports.T2_IMAGE_TO_VIDEO_CHAIN = exports.T2_TEXT_TO_VIDEO_CHAIN = exports.T3_TEXT_TO_VIDEO_CHAIN = void 0;
4
+ exports.isVideoModelCapable = isVideoModelCapable;
5
+ exports.buildVideoChain = buildVideoChain;
6
+ exports.snapDurationForModel = snapDurationForModel;
7
+ const aiModels_1 = require("../../../globals/aiModels");
8
+ /**
9
+ * Provider-chain configuration per modality (F3.3).
10
+ * Ordered primary → fallback. The wrapper walks the chain on recoverable
11
+ * failures (transient / rate-limit / capability / quota / unknown).
12
+ *
13
+ * Ordering rationale: perceived quality + reliability first. Tier downgrades
14
+ * happen at the AGENT layer (re-plan), not at the chain layer — within a
15
+ * single chain we stay at the same tier.
16
+ *
17
+ * Capability matrix (`videoCapabilities`) filters chains pre-flight so we
18
+ * don't fall back to a model that physically can't do the requested
19
+ * aspect / duration / lastFrame / etc.
20
+ */
21
+ // ── Video: text-to-video, T3 (cinematic) ──────────────────────────────
22
+ exports.T3_TEXT_TO_VIDEO_CHAIN = [
23
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
24
+ aiModels_1.EVideoGenModels.KLING_V2_6,
25
+ aiModels_1.EVideoGenModels.RUNWAY_GEN4_5,
26
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0,
27
+ aiModels_1.EVideoGenModels.MINIMAX_HAILUO_2_3,
28
+ ];
29
+ // ── Video: text-to-video, T2 (balanced) ───────────────────────────────
30
+ // AG-16: seedance-1.0-pro-fast added to cover 2-3s clips; pixverse-v6 added
31
+ // for 15s coverage (rest of T2 T2V tops out at 12s).
32
+ exports.T2_TEXT_TO_VIDEO_CHAIN = [
33
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_1_0_PRO_FAST,
34
+ aiModels_1.EVideoGenModels.KLING_V2_5_TURBO,
35
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
36
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_1_5_PRO,
37
+ aiModels_1.EVideoGenModels.PIXVERSE_V6,
38
+ aiModels_1.EVideoGenModels.PIXVERSE_V5_6,
39
+ aiModels_1.EVideoGenModels.MINIMAX_HAILUO_2_3_FAST,
40
+ ];
41
+ // ── Video: image-to-video, T2 (most common path) ──────────────────────
42
+ // AG-16: bytedance-seedance-1.0-pro-fast prepended — only T2 I2V model that
43
+ // accepts sub-4s clips (2-12s range). Without it, any short-clip plan (e.g.
44
+ // 2s scenes for a fast-cut 10s UGC) has zero capable fallbacks and the chain
45
+ // exhausts when the primary fails. pixverse-v6 added for 15s long-clip
46
+ // coverage (rest of T2 I2V tops out at 12s).
47
+ exports.T2_IMAGE_TO_VIDEO_CHAIN = [
48
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_1_0_PRO_FAST,
49
+ aiModels_1.EVideoGenModels.KLING_V2_5_TURBO,
50
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
51
+ aiModels_1.EVideoGenModels.RUNWAY_GEN4_TURBO,
52
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_1_5_PRO,
53
+ aiModels_1.EVideoGenModels.PIXVERSE_V6,
54
+ aiModels_1.EVideoGenModels.MINIMAX_HAILUO_02,
55
+ ];
56
+ // ── Video: image-to-video, T3 (premium) ───────────────────────────────
57
+ // AG-16: kling-v3.0 added (broadest I2V range 3-15s in T3 tier). runway-gen4.5
58
+ // kept — I2V branch in runway.service.ts now implemented per Runway docs.
59
+ exports.T3_IMAGE_TO_VIDEO_CHAIN = [
60
+ aiModels_1.EVideoGenModels.KLING_V2_6,
61
+ aiModels_1.EVideoGenModels.KLING_V3_0,
62
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
63
+ aiModels_1.EVideoGenModels.RUNWAY_GEN4_5,
64
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0,
65
+ ];
66
+ // ── Video: avatar / talking-head (Kling-only today) ───────────────────
67
+ exports.AVATAR_VIDEO_CHAIN = [
68
+ aiModels_1.EVideoGenModels.KLING_AVATAR,
69
+ ];
70
+ // ── Music: search/gen ─────────────────────────────────────────────────
71
+ exports.MUSIC_CHAIN = [
72
+ aiModels_1.EMusicGenModels.GOOGLE_LYRIA_2,
73
+ aiModels_1.EMusicGenModels.MINIMAX_MUSIC_1_5,
74
+ ];
75
+ // ── SFX: ElevenLabs only ──────────────────────────────────────────────
76
+ exports.SFX_CHAIN = [
77
+ aiModels_1.ESfxGenModels.ELEVENLABS_SOUND_EFFECTS,
78
+ ];
79
+ function isVideoModelCapable(model, req) {
80
+ const cfg = aiModels_1.aiModelConfigs[model];
81
+ if (!cfg)
82
+ return true; // unknown model → optimistic
83
+ // Type gate (text-to-video vs image-to-video).
84
+ if (req.type && cfg.type && !cfg.type.includes(req.type))
85
+ return false;
86
+ // AG-21: required-field gate. If the model schema marks `inputImageUrl` as
87
+ // required and the caller isn't supplying one (text-to-video without source
88
+ // still), this model cannot serve the request — skip rather than burning a
89
+ // chain slot and getting rejected.
90
+ const requiresInputImage = cfg.fields?.inputImageUrl?.required === true;
91
+ if (requiresInputImage && req.hasInputImage === false)
92
+ return false;
93
+ // Duration gate: exact match (±0.25s rounding) against allowedValues.
94
+ const allowedDur = cfg.fields?.duration?.allowedValues;
95
+ if (allowedDur?.length && allowedDur.every((v) => typeof v === "number")) {
96
+ const match = allowedDur.some((v) => Math.abs(v - req.durationSec) < 0.25);
97
+ if (!match)
98
+ return false;
99
+ }
100
+ // Aspect gate: normalise both sides to canonical "W:H" reduced form so
101
+ // Runway-style "1280:720" matches a request for "16:9".
102
+ const allowedAspects = cfg.fields?.aspectRatio?.allowedValues;
103
+ if (allowedAspects?.length) {
104
+ const normReq = normalizeAspect(req.aspect);
105
+ const normAllowed = allowedAspects.map(normalizeAspect);
106
+ if (!normAllowed.includes(normReq))
107
+ return false;
108
+ }
109
+ // lastFrame / audio support is currently encoded ad-hoc per provider; treat
110
+ // as optimistic until we surface those flags on the schema. Most models
111
+ // either support both or neither, so a wrong-positive is rare and the
112
+ // provider will reject + reclassify as capability.
113
+ if (req.lastFrame && !supportsEndFrame(model))
114
+ return false;
115
+ if (req.audio && !supportsAudio(model))
116
+ return false;
117
+ return true;
118
+ }
119
+ /** Reduce a "W:H" or "WxH" ratio to lowest terms, e.g. "1280:720" → "16:9". */
120
+ function normalizeAspect(a) {
121
+ if (!a)
122
+ return a;
123
+ const m = a.match(/^(\d+)[:x](\d+)$/);
124
+ if (!m)
125
+ return a;
126
+ const w = parseInt(m[1], 10);
127
+ const h = parseInt(m[2], 10);
128
+ if (!w || !h)
129
+ return a;
130
+ const g = gcd(w, h);
131
+ return `${w / g}:${h / g}`;
132
+ }
133
+ function gcd(a, b) {
134
+ return b === 0 ? a : gcd(b, a % b);
135
+ }
136
+ // AG-16: small allow-lists for capabilities not yet on the schema. Conservative
137
+ // — extend as we wire native audio / lastFrame as proper schema fields.
138
+ const END_FRAME_MODELS = new Set([
139
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
140
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
141
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_LITE,
142
+ aiModels_1.EVideoGenModels.KLING_V2_6,
143
+ aiModels_1.EVideoGenModels.KLING_V2_5_TURBO,
144
+ aiModels_1.EVideoGenModels.KLING_V3_0,
145
+ aiModels_1.EVideoGenModels.RUNWAY_GEN4_TURBO,
146
+ aiModels_1.EVideoGenModels.RUNWAY_GEN4_5,
147
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0,
148
+ aiModels_1.EVideoGenModels.PIXVERSE_V5_6,
149
+ ]);
150
+ const AUDIO_MODELS = new Set([
151
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3,
152
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
153
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
154
+ aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_LITE,
155
+ aiModels_1.EVideoGenModels.BYTEDANCE_SEEDANCE_2_0,
156
+ aiModels_1.EVideoGenModels.KLING_AVATAR,
157
+ ]);
158
+ function supportsEndFrame(m) {
159
+ return END_FRAME_MODELS.has(m);
160
+ }
161
+ function supportsAudio(m) {
162
+ return AUDIO_MODELS.has(m);
163
+ }
164
+ /**
165
+ * Build a chain that puts the planner's pick first, then the rest of the
166
+ * tier-appropriate chain (deduped). Honors the planner's intent while still
167
+ * providing fallback when the pick fails.
168
+ */
169
+ function buildVideoChain(plannerPick, fallbackChain) {
170
+ const chain = [plannerPick];
171
+ for (const m of fallbackChain) {
172
+ if (m !== plannerPick)
173
+ chain.push(m);
174
+ }
175
+ return chain;
176
+ }
177
+ function snapDurationForModel(model, durationSec, opts = {}) {
178
+ const allowed = (0, aiModels_1.getModelAllowedDurations)(model);
179
+ if (!allowed) {
180
+ return { requestedSec: durationSec, snappedSec: durationSec, driftSec: 0, unconstrained: true };
181
+ }
182
+ // Already within rounding tolerance of a legal value.
183
+ const inRange = allowed.some((v) => Math.abs(v - durationSec) < 0.25);
184
+ if (inRange) {
185
+ const exact = allowed.reduce((best, v) => Math.abs(v - durationSec) < Math.abs(best - durationSec) ? v : best, allowed[0]);
186
+ return { requestedSec: durationSec, snappedSec: exact, driftSec: Math.abs(exact - durationSec), unconstrained: false };
187
+ }
188
+ // Find the nearest legal value and see whether the drift is acceptable.
189
+ const nearest = allowed.reduce((best, v) => Math.abs(v - durationSec) < Math.abs(best - durationSec) ? v : best, allowed[0]);
190
+ const driftSec = Math.abs(nearest - durationSec);
191
+ const maxDriftSec = opts.maxDriftSec ?? 2.0;
192
+ const maxDriftRel = opts.maxDriftRel ?? 0.5;
193
+ const driftRel = durationSec > 0 ? driftSec / durationSec : Infinity;
194
+ if (driftSec <= maxDriftSec && driftRel <= maxDriftRel) {
195
+ return { requestedSec: durationSec, snappedSec: nearest, driftSec, unconstrained: false };
196
+ }
197
+ return null;
198
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Classifies a provider error into one of these classes to drive the
3
+ * `withProviderFallback` decision tree:
4
+ *
5
+ * - "transient" : retry / fall back (network blip, 5xx, generic timeout)
6
+ * - "rate_limit" : fall back (429, quota-on-window)
7
+ * - "capability" : fall back (provider can't do this aspect/duration/feature)
8
+ * - "safety" : DO NOT fall back; escalate to agent (next provider will also block)
9
+ * - "auth" : DO NOT fall back; fail fast (deploy bug, missing key)
10
+ * - "quota" : fall back; account-level quota exhausted for this provider
11
+ * - "input" : DO NOT fall back; bad user input (prompt invalid, image rejected)
12
+ * - "unknown" : treat as transient — better to try next provider than fail
13
+ *
14
+ * Inputs:
15
+ * - structured `UserFacingError` (preferred — read `.code`)
16
+ * - raw `Error` — regex-match common provider error message patterns
17
+ *
18
+ * F3.6 (not in this pass) standardizes raw-throwing providers to use
19
+ * `UserFacingError` so the regex path becomes unnecessary.
20
+ */
21
+ export type ProviderFailureClass = "transient" | "rate_limit" | "capability" | "safety" | "auth" | "quota" | "input" | "unknown";
22
+ export interface ProviderFailureClassification {
23
+ classification: ProviderFailureClass;
24
+ /** True if no provider fallback should be tried (auth / safety / input). */
25
+ isTerminal: boolean;
26
+ /** True if this is a recoverable failure the AGENT should re-plan (safety/input). */
27
+ needsReplan: boolean;
28
+ /** Original UserFacingError code, if present, for tracing. */
29
+ originalCode?: string;
30
+ /** Original error message, truncated. */
31
+ message: string;
32
+ }
33
+ export declare function classifyProviderError(err: unknown): ProviderFailureClassification;
34
+ /** Decide whether to try the next provider in a chain for a given class. */
35
+ export declare function shouldFallback(c: ProviderFailureClass): boolean;
36
+ //# sourceMappingURL=classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/providerFallback/classifier.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,WAAW,6BAA6B;IAC5C,cAAc,EAAE,oBAAoB,CAAC;IACrC,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,WAAW,EAAE,OAAO,CAAC;IACrB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;CACjB;AA8FD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,6BAA6B,CAsBjF;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAAC,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAI/D"}