vidspotai-shared 1.0.82 → 1.0.84

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 (442) hide show
  1. package/lib/globals/aiModels/enums.d.ts +11 -1
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +24 -1
  4. package/lib/globals/aiModels/index.d.ts.map +1 -1
  5. package/lib/globals/aiModels/index.js +2 -0
  6. package/lib/globals/aiModels/providers/anthropic.d.ts +12 -0
  7. package/lib/globals/aiModels/providers/anthropic.d.ts.map +1 -0
  8. package/lib/globals/aiModels/providers/anthropic.js +88 -0
  9. package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
  10. package/lib/globals/aiModels/providers/google.js +82 -0
  11. package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
  12. package/lib/globals/aiModels/providers/openai.js +63 -4
  13. package/lib/globals/aiModels/tierHelpers.d.ts +12 -0
  14. package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -1
  15. package/lib/globals/aiModels/tierHelpers.js +83 -0
  16. package/lib/globals/aiModels/types.d.ts +19 -0
  17. package/lib/globals/aiModels/types.d.ts.map +1 -1
  18. package/lib/globals/types.d.ts +120 -1
  19. package/lib/globals/types.d.ts.map +1 -1
  20. package/lib/globals/types.js +135 -1
  21. package/lib/models/agent.model.d.ts +41 -1
  22. package/lib/models/agent.model.d.ts.map +1 -1
  23. package/lib/models/index.d.ts +1 -0
  24. package/lib/models/index.d.ts.map +1 -1
  25. package/lib/models/index.js +1 -0
  26. package/lib/models/social.model.d.ts +180 -0
  27. package/lib/models/social.model.d.ts.map +1 -0
  28. package/lib/models/social.model.js +2 -0
  29. package/lib/models/user.model.d.ts +10 -0
  30. package/lib/models/user.model.d.ts.map +1 -1
  31. package/lib/models/video.model.d.ts +6 -0
  32. package/lib/models/video.model.d.ts.map +1 -1
  33. package/lib/schemas/brief.schema.d.ts +46 -0
  34. package/lib/schemas/brief.schema.d.ts.map +1 -1
  35. package/lib/schemas/brief.schema.js +72 -1
  36. package/lib/schemas/index.d.ts +1 -0
  37. package/lib/schemas/index.d.ts.map +1 -1
  38. package/lib/schemas/index.js +1 -0
  39. package/lib/schemas/project.schema.d.ts +67 -0
  40. package/lib/schemas/project.schema.d.ts.map +1 -1
  41. package/lib/schemas/project.schema.js +12 -0
  42. package/lib/schemas/social.schema.d.ts +91 -0
  43. package/lib/schemas/social.schema.d.ts.map +1 -0
  44. package/lib/schemas/social.schema.js +114 -0
  45. package/lib/schemas/videoPlan.schema.d.ts +114 -0
  46. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  47. package/lib/schemas/videoPlan.schema.js +141 -1
  48. package/lib/services/agent/chatAgent.d.ts +25 -1
  49. package/lib/services/agent/chatAgent.d.ts.map +1 -1
  50. package/lib/services/agent/chatAgent.js +145 -9
  51. package/lib/services/agent/costPreflight.d.ts +11 -1
  52. package/lib/services/agent/costPreflight.d.ts.map +1 -1
  53. package/lib/services/agent/costPreflight.js +18 -1
  54. package/lib/services/agent/covers/coverPlanner.d.ts +41 -0
  55. package/lib/services/agent/covers/coverPlanner.d.ts.map +1 -0
  56. package/lib/services/agent/covers/coverPlanner.js +278 -0
  57. package/lib/services/agent/covers/covers.schema.d.ts +158 -0
  58. package/lib/services/agent/covers/covers.schema.d.ts.map +1 -0
  59. package/lib/services/agent/covers/covers.schema.js +166 -0
  60. package/lib/services/agent/covers/index.d.ts +3 -0
  61. package/lib/services/agent/covers/index.d.ts.map +1 -0
  62. package/lib/services/agent/covers/index.js +18 -0
  63. package/lib/services/agent/critic.d.ts +10 -0
  64. package/lib/services/agent/critic.d.ts.map +1 -1
  65. package/lib/services/agent/critic.js +37 -1
  66. package/lib/services/agent/editClassifier.d.ts +2 -2
  67. package/lib/services/agent/editClassifier.js +2 -2
  68. package/lib/services/agent/editExisting/editAssembler.d.ts +78 -0
  69. package/lib/services/agent/editExisting/editAssembler.d.ts.map +1 -0
  70. package/lib/services/agent/editExisting/editAssembler.js +172 -0
  71. package/lib/services/agent/editExisting/editExisting.schema.d.ts +119 -0
  72. package/lib/services/agent/editExisting/editExisting.schema.d.ts.map +1 -0
  73. package/lib/services/agent/editExisting/editExisting.schema.js +157 -0
  74. package/lib/services/agent/editExisting/highlightPicker.d.ts +48 -0
  75. package/lib/services/agent/editExisting/highlightPicker.d.ts.map +1 -0
  76. package/lib/services/agent/editExisting/highlightPicker.js +199 -0
  77. package/lib/services/agent/editExisting/index.d.ts +4 -0
  78. package/lib/services/agent/editExisting/index.d.ts.map +1 -0
  79. package/lib/services/agent/editExisting/index.js +19 -0
  80. package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
  81. package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
  82. package/lib/services/agent/eval/seedBriefs.js +283 -3
  83. package/lib/services/agent/eval/types.d.ts +10 -0
  84. package/lib/services/agent/eval/types.d.ts.map +1 -1
  85. package/lib/services/agent/executor/core.d.ts +70 -0
  86. package/lib/services/agent/executor/core.d.ts.map +1 -0
  87. package/lib/services/agent/executor/core.js +250 -0
  88. package/lib/services/agent/executor/duration.d.ts +20 -0
  89. package/lib/services/agent/executor/duration.d.ts.map +1 -0
  90. package/lib/services/agent/executor/duration.js +46 -0
  91. package/lib/services/agent/executor/index.d.ts +15 -0
  92. package/lib/services/agent/executor/index.d.ts.map +1 -0
  93. package/lib/services/agent/executor/index.js +32 -0
  94. package/lib/services/agent/executor/types.d.ts +183 -0
  95. package/lib/services/agent/executor/types.d.ts.map +1 -0
  96. package/lib/services/agent/executor/types.js +29 -0
  97. package/lib/services/agent/executor/visual.d.ts +32 -0
  98. package/lib/services/agent/executor/visual.d.ts.map +1 -0
  99. package/lib/services/agent/executor/visual.js +400 -0
  100. package/lib/services/agent/executor/voice.d.ts +17 -0
  101. package/lib/services/agent/executor/voice.d.ts.map +1 -0
  102. package/lib/services/agent/executor/voice.js +119 -0
  103. package/lib/services/agent/extendChain.d.ts +101 -0
  104. package/lib/services/agent/extendChain.d.ts.map +1 -0
  105. package/lib/services/agent/extendChain.js +177 -0
  106. package/lib/services/agent/index.d.ts +11 -1
  107. package/lib/services/agent/index.d.ts.map +1 -1
  108. package/lib/services/agent/index.js +11 -1
  109. package/lib/services/agent/llmCaller.d.ts +7 -8
  110. package/lib/services/agent/llmCaller.d.ts.map +1 -1
  111. package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
  112. package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
  113. package/lib/services/agent/llmCallerAnthropic.js +135 -60
  114. package/lib/services/agent/llmCallerFactory.d.ts +34 -0
  115. package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
  116. package/lib/services/agent/llmCallerFactory.js +31 -0
  117. package/lib/services/agent/llmCallerGemini.d.ts +62 -0
  118. package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
  119. package/lib/services/agent/llmCallerGemini.js +235 -0
  120. package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
  121. package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
  122. package/lib/services/agent/llmCallerOpenai.js +230 -0
  123. package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
  124. package/lib/services/agent/llmCallerRegistry.js +7 -7
  125. package/lib/services/agent/llmCallerRouting.d.ts +63 -0
  126. package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
  127. package/lib/services/agent/llmCallerRouting.js +124 -0
  128. package/lib/services/agent/llmModelRegistry.d.ts +59 -0
  129. package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
  130. package/lib/services/agent/llmModelRegistry.js +168 -0
  131. package/lib/services/agent/llmRetry.d.ts +57 -0
  132. package/lib/services/agent/llmRetry.d.ts.map +1 -0
  133. package/lib/services/agent/llmRetry.js +102 -0
  134. package/lib/services/agent/modelRouter.d.ts +3 -3
  135. package/lib/services/agent/modelRouter.d.ts.map +1 -1
  136. package/lib/services/agent/modelRouter.js +27 -13
  137. package/lib/services/agent/planMutations.d.ts +54 -1
  138. package/lib/services/agent/planMutations.d.ts.map +1 -1
  139. package/lib/services/agent/planMutations.js +78 -0
  140. package/lib/services/agent/planner/Planner.d.ts +0 -17
  141. package/lib/services/agent/planner/Planner.d.ts.map +1 -1
  142. package/lib/services/agent/planner/Planner.js +67 -303
  143. package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
  144. package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
  145. package/lib/services/agent/planner/overlayRegen.js +145 -0
  146. package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
  147. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
  148. package/lib/services/agent/planner/plannerMessages.js +185 -0
  149. package/lib/services/agent/planner/promptSections.d.ts +12 -0
  150. package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
  151. package/lib/services/agent/planner/promptSections.js +57 -0
  152. package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
  153. package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
  154. package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
  155. package/lib/services/agent/planner/structuralRules.d.ts +10 -0
  156. package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
  157. package/lib/services/agent/planner/structuralRules.js +92 -9
  158. package/lib/services/agent/planner/validators.d.ts +18 -0
  159. package/lib/services/agent/planner/validators.d.ts.map +1 -1
  160. package/lib/services/agent/planner/validators.js +97 -0
  161. package/lib/services/agent/planner.d.ts +2 -1
  162. package/lib/services/agent/planner.d.ts.map +1 -1
  163. package/lib/services/agent/planner.js +5 -1
  164. package/lib/services/agent/priorProject.d.ts +26 -0
  165. package/lib/services/agent/priorProject.d.ts.map +1 -0
  166. package/lib/services/agent/priorProject.js +51 -0
  167. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  168. package/lib/services/agent/providerFallback/chains.js +27 -15
  169. package/lib/services/agent/repurpose/index.d.ts +3 -0
  170. package/lib/services/agent/repurpose/index.d.ts.map +1 -0
  171. package/lib/services/agent/repurpose/index.js +18 -0
  172. package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
  173. package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
  174. package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
  175. package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
  176. package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
  177. package/lib/services/agent/repurpose/shortsPicker.js +218 -0
  178. package/lib/services/agent/runHelpers.d.ts +21 -2
  179. package/lib/services/agent/runHelpers.d.ts.map +1 -1
  180. package/lib/services/agent/runHelpers.js +71 -2
  181. package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
  182. package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
  183. package/lib/services/agent/tools/animateImage.tool.js +12 -0
  184. package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
  185. package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
  186. package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
  187. package/lib/services/agent/tools/composeScene.tool.d.ts +63 -0
  188. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  189. package/lib/services/agent/tools/estimateCost.tool.d.ts +27 -0
  190. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  191. package/lib/services/agent/tools/estimateCost.tool.js +55 -7
  192. package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
  193. package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
  194. package/lib/services/agent/tools/extendVideo.tool.js +149 -0
  195. package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
  196. package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
  197. package/lib/services/agent/tools/generateScript.tool.js +123 -0
  198. package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
  199. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
  200. package/lib/services/agent/tools/generateVideo.tool.js +20 -1
  201. package/lib/services/agent/tools/index.d.ts +4 -0
  202. package/lib/services/agent/tools/index.d.ts.map +1 -1
  203. package/lib/services/agent/tools/index.js +4 -0
  204. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
  205. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
  206. package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
  207. package/lib/services/agent/tools/planVideo.tool.d.ts +56 -0
  208. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  209. package/lib/services/agent/tools/planVideo.tool.js +3 -3
  210. package/lib/services/agent/tools/render.tool.d.ts +21 -0
  211. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  212. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  213. package/lib/services/aiGen/aiGenFactory.service.js +18 -3
  214. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
  215. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
  216. package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
  217. package/lib/services/aiGen/providers/google/google.service.d.ts +24 -1
  218. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  219. package/lib/services/aiGen/providers/google/google.service.js +96 -244
  220. package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
  221. package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
  222. package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
  223. package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
  224. package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
  225. package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
  226. package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
  227. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
  228. package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
  229. package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
  230. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  231. package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
  232. package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
  233. package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
  234. package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
  235. package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
  236. package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
  237. package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
  238. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
  239. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
  240. package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
  241. package/lib/services/bullmq.service.d.ts +61 -0
  242. package/lib/services/bullmq.service.d.ts.map +1 -1
  243. package/lib/services/bullmq.service.js +101 -1
  244. package/lib/services/crypto/index.d.ts +2 -0
  245. package/lib/services/crypto/index.d.ts.map +1 -0
  246. package/lib/services/crypto/index.js +17 -0
  247. package/lib/services/crypto/tokenVault.d.ts +47 -0
  248. package/lib/services/crypto/tokenVault.d.ts.map +1 -0
  249. package/lib/services/crypto/tokenVault.js +179 -0
  250. package/lib/services/editor/captionStyleHint.d.ts +3 -0
  251. package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
  252. package/lib/services/editor/captionStyleHint.js +112 -0
  253. package/lib/services/editor/planToProject.d.ts +7 -66
  254. package/lib/services/editor/planToProject.d.ts.map +1 -1
  255. package/lib/services/editor/planToProject.helpers.d.ts +40 -0
  256. package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
  257. package/lib/services/editor/planToProject.helpers.js +177 -0
  258. package/lib/services/editor/planToProject.js +197 -180
  259. package/lib/services/editor/planToProject.types.d.ts +94 -0
  260. package/lib/services/editor/planToProject.types.d.ts.map +1 -0
  261. package/lib/services/editor/planToProject.types.js +2 -0
  262. package/lib/services/firestore.service.d.ts +5 -0
  263. package/lib/services/firestore.service.d.ts.map +1 -1
  264. package/lib/services/firestore.service.js +13 -0
  265. package/lib/services/index.d.ts +12 -0
  266. package/lib/services/index.d.ts.map +1 -1
  267. package/lib/services/index.js +12 -0
  268. package/lib/services/promptEnhancer/index.d.ts +18 -0
  269. package/lib/services/promptEnhancer/index.d.ts.map +1 -0
  270. package/lib/services/promptEnhancer/index.js +33 -0
  271. package/lib/services/promptEnhancer/models.d.ts +54 -0
  272. package/lib/services/promptEnhancer/models.d.ts.map +1 -0
  273. package/lib/services/promptEnhancer/models.js +37 -0
  274. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
  275. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
  276. package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
  277. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
  278. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
  279. package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
  280. package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
  281. package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
  282. package/lib/services/promptEnhancer/profiles/base.js +35 -0
  283. package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
  284. package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
  285. package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
  286. package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
  287. package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
  288. package/lib/services/promptEnhancer/profiles/index.js +33 -0
  289. package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
  290. package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
  291. package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
  292. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
  293. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
  294. package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
  295. package/lib/services/promptEnhancer/schema.d.ts +19 -0
  296. package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
  297. package/lib/services/promptEnhancer/schema.js +43 -0
  298. package/lib/services/promptEnhancer/types.d.ts +112 -0
  299. package/lib/services/promptEnhancer/types.d.ts.map +1 -0
  300. package/lib/services/promptEnhancer/types.js +2 -0
  301. package/lib/services/socialAI/captionGen.d.ts +81 -0
  302. package/lib/services/socialAI/captionGen.d.ts.map +1 -0
  303. package/lib/services/socialAI/captionGen.js +206 -0
  304. package/lib/services/socialAI/hookScore.d.ts +85 -0
  305. package/lib/services/socialAI/hookScore.d.ts.map +1 -0
  306. package/lib/services/socialAI/hookScore.js +170 -0
  307. package/lib/services/socialAI/index.d.ts +3 -0
  308. package/lib/services/socialAI/index.d.ts.map +1 -0
  309. package/lib/services/socialAI/index.js +18 -0
  310. package/lib/services/socialAccounts/index.d.ts +2 -0
  311. package/lib/services/socialAccounts/index.d.ts.map +1 -0
  312. package/lib/services/socialAccounts/index.js +17 -0
  313. package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
  314. package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
  315. package/lib/services/socialAccounts/socialAccountService.js +105 -0
  316. package/lib/services/socialEngage/factory.d.ts +7 -0
  317. package/lib/services/socialEngage/factory.d.ts.map +1 -0
  318. package/lib/services/socialEngage/factory.js +25 -0
  319. package/lib/services/socialEngage/index.d.ts +6 -0
  320. package/lib/services/socialEngage/index.d.ts.map +1 -0
  321. package/lib/services/socialEngage/index.js +21 -0
  322. package/lib/services/socialEngage/meta.engage.d.ts +17 -0
  323. package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
  324. package/lib/services/socialEngage/meta.engage.js +128 -0
  325. package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
  326. package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
  327. package/lib/services/socialEngage/metaWebhook.js +93 -0
  328. package/lib/services/socialEngage/types.d.ts +72 -0
  329. package/lib/services/socialEngage/types.d.ts.map +1 -0
  330. package/lib/services/socialEngage/types.js +10 -0
  331. package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
  332. package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
  333. package/lib/services/socialEngage/youtube.engage.js +87 -0
  334. package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
  335. package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
  336. package/lib/services/socialFormat/aspectGeometry.js +135 -0
  337. package/lib/services/socialFormat/index.d.ts +2 -0
  338. package/lib/services/socialFormat/index.d.ts.map +1 -0
  339. package/lib/services/socialFormat/index.js +19 -0
  340. package/lib/services/socialInsights/index.d.ts +3 -0
  341. package/lib/services/socialInsights/index.d.ts.map +1 -0
  342. package/lib/services/socialInsights/index.js +18 -0
  343. package/lib/services/socialInsights/recommendations.d.ts +131 -0
  344. package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
  345. package/lib/services/socialInsights/recommendations.js +277 -0
  346. package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
  347. package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
  348. package/lib/services/socialInsights/timeBuckets.js +78 -0
  349. package/lib/services/socialMetrics/factory.d.ts +5 -0
  350. package/lib/services/socialMetrics/factory.d.ts.map +1 -0
  351. package/lib/services/socialMetrics/factory.js +24 -0
  352. package/lib/services/socialMetrics/index.d.ts +6 -0
  353. package/lib/services/socialMetrics/index.d.ts.map +1 -0
  354. package/lib/services/socialMetrics/index.js +21 -0
  355. package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
  356. package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
  357. package/lib/services/socialMetrics/meta.metrics.js +137 -0
  358. package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
  359. package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
  360. package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
  361. package/lib/services/socialMetrics/types.d.ts +54 -0
  362. package/lib/services/socialMetrics/types.d.ts.map +1 -0
  363. package/lib/services/socialMetrics/types.js +2 -0
  364. package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
  365. package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
  366. package/lib/services/socialMetrics/youtube.metrics.js +43 -0
  367. package/lib/services/socialOAuth/factory.d.ts +7 -0
  368. package/lib/services/socialOAuth/factory.d.ts.map +1 -0
  369. package/lib/services/socialOAuth/factory.js +42 -0
  370. package/lib/services/socialOAuth/index.d.ts +11 -0
  371. package/lib/services/socialOAuth/index.d.ts.map +1 -0
  372. package/lib/services/socialOAuth/index.js +26 -0
  373. package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
  374. package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
  375. package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
  376. package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
  377. package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
  378. package/lib/services/socialOAuth/meta.oauth.js +214 -0
  379. package/lib/services/socialOAuth/oauthState.d.ts +14 -0
  380. package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
  381. package/lib/services/socialOAuth/oauthState.js +66 -0
  382. package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
  383. package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
  384. package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
  385. package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
  386. package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
  387. package/lib/services/socialOAuth/threads.oauth.js +129 -0
  388. package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
  389. package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
  390. package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
  391. package/lib/services/socialOAuth/types.d.ts +67 -0
  392. package/lib/services/socialOAuth/types.d.ts.map +1 -0
  393. package/lib/services/socialOAuth/types.js +2 -0
  394. package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
  395. package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
  396. package/lib/services/socialOAuth/x.oauth.js +134 -0
  397. package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
  398. package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
  399. package/lib/services/socialOAuth/youtube.oauth.js +156 -0
  400. package/lib/services/socialPublish/factory.d.ts +5 -0
  401. package/lib/services/socialPublish/factory.d.ts.map +1 -0
  402. package/lib/services/socialPublish/factory.js +32 -0
  403. package/lib/services/socialPublish/index.d.ts +10 -0
  404. package/lib/services/socialPublish/index.d.ts.map +1 -0
  405. package/lib/services/socialPublish/index.js +25 -0
  406. package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
  407. package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
  408. package/lib/services/socialPublish/linkedin.publish.js +143 -0
  409. package/lib/services/socialPublish/meta.publish.d.ts +28 -0
  410. package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
  411. package/lib/services/socialPublish/meta.publish.js +149 -0
  412. package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
  413. package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
  414. package/lib/services/socialPublish/pinterest.publish.js +130 -0
  415. package/lib/services/socialPublish/threads.publish.d.ts +12 -0
  416. package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
  417. package/lib/services/socialPublish/threads.publish.js +96 -0
  418. package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
  419. package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
  420. package/lib/services/socialPublish/tiktok.publish.js +118 -0
  421. package/lib/services/socialPublish/types.d.ts +47 -0
  422. package/lib/services/socialPublish/types.d.ts.map +1 -0
  423. package/lib/services/socialPublish/types.js +2 -0
  424. package/lib/services/socialPublish/x.publish.d.ts +12 -0
  425. package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
  426. package/lib/services/socialPublish/x.publish.js +147 -0
  427. package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
  428. package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
  429. package/lib/services/socialPublish/youtube.publish.js +107 -0
  430. package/lib/services/stock/index.d.ts +2 -0
  431. package/lib/services/stock/index.d.ts.map +1 -0
  432. package/lib/services/stock/index.js +17 -0
  433. package/lib/services/stock/realPersonSafety.d.ts +99 -0
  434. package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
  435. package/lib/services/stock/realPersonSafety.js +248 -0
  436. package/lib/utils/index.d.ts +1 -0
  437. package/lib/utils/index.d.ts.map +1 -1
  438. package/lib/utils/index.js +1 -0
  439. package/lib/utils/renderTier.d.ts +26 -0
  440. package/lib/utils/renderTier.d.ts.map +1 -0
  441. package/lib/utils/renderTier.js +34 -0
  442. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AA+NlB,qBAAa,aAAc,SAAQ,wBAAwB;IAKzD,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAK;;IAQ/C;;;;OAIG;YACW,kBAAkB;IA+B1B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiJ3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyG3C,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAiBnB,cAAc;IAwG5B;;;;;;OAMG;IACG,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAqEjC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,UAAmB,EAAE,SAAiB,EAAE,SAAa,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,MAAM;CA8BvI"}
1
+ {"version":3,"file":"google.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/google.service.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAelB,qBAAa,aAAc,SAAQ,wBAAwB;IAKzD,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAK;;IAQ/C;;;;;;;;;OASG;IACG,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAoChC;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAoCvB;;;;OAIG;YACW,kBAAkB;IA+B1B,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAiJ3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiH3C,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;YAiBnB,cAAc;IAwG5B;;;;;;OAMG;IACH;;;;OAIG;IACG,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,UAAmB,EAAE,SAAiB,EAAE,SAAa,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,MAAM;CA8BvI"}
@@ -15,199 +15,94 @@ const logger_1 = require("../../../../utils/logger");
15
15
  const errors_1 = require("../../../../utils/errors");
16
16
  const helpers_2 = require("../../helpers");
17
17
  const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
18
- const google_auth_library_1 = require("google-auth-library");
19
18
  const fs_1 = require("fs");
20
19
  const promises_2 = require("stream/promises");
20
+ const googleErrors_1 = require("./googleErrors");
21
+ const googleFetch_1 = require("./googleFetch");
22
+ const googleMusic_1 = require("./googleMusic");
21
23
  const googleApiKeys_1 = require("./googleApiKeys");
22
24
  const googleKeyPool_1 = require("./googleKeyPool");
23
- // Codes from undici / Node net layer that indicate a transient network failure
24
- // the request never reached the server, or the server hung up mid-flight.
25
- // Retrying these is safe (idempotent at the API layer for our use cases) and usually succeeds.
26
- const TRANSIENT_NETWORK_CODES = new Set([
27
- "ECONNRESET",
28
- "ECONNREFUSED",
29
- "ETIMEDOUT",
30
- "ENOTFOUND",
31
- "EAI_AGAIN",
32
- "EPIPE",
33
- "UND_ERR_SOCKET",
34
- "UND_ERR_CONNECT_TIMEOUT",
35
- "UND_ERR_HEADERS_TIMEOUT",
36
- "UND_ERR_BODY_TIMEOUT",
37
- ]);
38
- // Pick a Veo-compatible image MIME type. Veo accepts image/jpeg, image/png,
39
- // image/webp. We prefer the upstream Content-Type header (Firebase Storage
40
- // returns the type set at upload), then fall back to URL extension, then to
41
- // image/jpeg as a reasonable last resort for phone-camera uploads.
42
- const VEO_SUPPORTED_IMAGE_MIMES = new Set([
43
- "image/jpeg",
44
- "image/png",
45
- "image/webp",
46
- ]);
47
- function pickImageMimeType(contentType, url) {
48
- const normalized = contentType.split(";")[0]?.trim().toLowerCase();
49
- if (normalized && VEO_SUPPORTED_IMAGE_MIMES.has(normalized)) {
50
- return normalized;
51
- }
52
- // Map common but non-canonical types
53
- if (normalized === "image/jpg")
54
- return "image/jpeg";
55
- // Extension fallback. Strip query string first (Firebase URLs have ?alt=media).
56
- const pathOnly = url.split("?")[0]?.toLowerCase() ?? "";
57
- if (pathOnly.endsWith(".png"))
58
- return "image/png";
59
- if (pathOnly.endsWith(".webp"))
60
- return "image/webp";
61
- if (pathOnly.endsWith(".jpg") || pathOnly.endsWith(".jpeg"))
62
- return "image/jpeg";
63
- // Phone uploads default to JPEG far more often than PNG, so it's a safer
64
- // last-resort than the previous hardcoded "image/png".
65
- return "image/jpeg";
66
- }
67
- function isTransientFetchError(err) {
68
- if (!err)
69
- return false;
70
- // undici wraps low-level errors as `TypeError: fetch failed` with the real
71
- // reason on `err.cause`. Treat that exact shape as transient.
72
- if (err.message === "fetch failed")
73
- return true;
74
- const code = err.code ?? err.cause?.code;
75
- return !!code && TRANSIENT_NETWORK_CODES.has(code);
76
- }
77
25
  const VEO_3_1_MODELS = new Set([
78
26
  aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
79
27
  aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
80
28
  aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_LITE,
81
29
  ]);
82
- function inferImageMime(url) {
83
- const lower = (url.split("?")[0] ?? url).toLowerCase();
84
- if (lower.endsWith(".jpg") || lower.endsWith(".jpeg"))
85
- return "image/jpeg";
86
- if (lower.endsWith(".webp"))
87
- return "image/webp";
88
- return "image/png";
89
- }
90
- async function fetchAsImage(url) {
91
- const resp = await fetch(url);
92
- // fetch() does NOT throw on 4xx/5xx — surface the HTTP error so we don't
93
- // encode an HTML error page as image bytes (Veo silently rejects them).
94
- if (!resp.ok) {
95
- throw new errors_1.UserFacingError(`Input image could not be downloaded (HTTP ${resp.status}). The image URL may have expired or been deleted.`);
96
- }
97
- const buf = Buffer.from(await resp.arrayBuffer());
98
- // 0-byte body slips through resp.ok if the upstream wrote an empty file.
99
- // Veo treats empty bytes as content-filtered (no error, no video).
100
- if (buf.length === 0) {
101
- throw new errors_1.UserFacingError("Input image is empty (0 bytes). Please re-upload the image.");
102
- }
103
- // Prefer Content-Type from the response (authoritative — set by Firebase
104
- // Storage upload metadata) over URL-extension inference. Hardcoded
105
- // image/png caused Veo to reject JPEG bytes labelled PNG with no detail.
106
- const respContentType = resp.headers.get("content-type") ?? "";
107
- return {
108
- mimeType: pickImageMimeType(respContentType, url),
109
- imageBytes: buf.toString("base64"),
110
- };
111
- }
112
- /**
113
- * Maps `@google/genai` `ApiError` failures (whose message is a JSON string)
114
- * to a `UserFacingError` with a stable code the frontend can translate.
115
- * Returns null when the error is not a known user-facing case (re-throw as-is).
116
- */
117
- function classifyGoogleApiError(err) {
118
- const raw = err?.message ?? "";
119
- try {
120
- const parsed = JSON.parse(raw);
121
- const inner = parsed.error ?? parsed;
122
- const httpCode = inner.code;
123
- const status = inner.status;
124
- const msg = inner.message ?? raw;
125
- if (status === "RESOURCE_EXHAUSTED" || httpCode === 429) {
126
- return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_RATE_LIMITED);
127
- }
128
- // gRPC code 14 = UNAVAILABLE; Veo surfaces "high demand" failures with this.
129
- if (httpCode === 14 || /high demand/i.test(msg)) {
130
- return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_HIGH_DEMAND);
131
- }
132
- // INVALID_ARGUMENT 400 — narrow match: only the specific "use case is
133
- // currently not supported" string, which Veo returns when our request
134
- // structure doesn't match the chosen model variant's capabilities.
135
- // The pre-call guards above (duration=8 for lastFrame/refs) should
136
- // prevent the known cases; if we still hit this it's a NEW combo we
137
- // haven't profiled — surface as CAPABILITY_MISMATCH so the user gets a
138
- // useful message, AND keep the raw provider text in the error so the
139
- // next entry in PROD_FIX_LOG can identify which combo broke. Generic
140
- // 400s (other INVALID_ARGUMENT variants) still surface as `error` so
141
- // a real platform bug isn't muted.
142
- if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
143
- /use case is currently not supported/i.test(msg)) {
144
- return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.CAPABILITY_MISMATCH);
145
- }
146
- // Imagen + Nano-Banana surface Responsible-AI filter rejections as
147
- // INVALID_ARGUMENT 400 with the literal text "filtered out because they
148
- // violated Google's Responsible AI practices" (and a recommendation to
149
- // rephrase). This is user content moderation, not a system bug — show the
150
- // user the rephrase hint and skip the Slack page. Also matches the Veo
151
- // RAI message ("violated Google's content policies") for the same reason.
152
- if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
153
- /(filtered out because they violated|violated Google's (?:Responsible AI|content) (?:practices|policies))/i.test(msg)) {
154
- return new errors_1.UserFacingError("Your prompt was flagged by Google's safety filters. Please rephrase and try again.", errors_1.USER_FACING_ERROR_CODES.CONTENT_POLICY_VIOLATION);
155
- }
156
- // Generic INVALID_ARGUMENT 400 on a provided string field. Veo echoes the
157
- // offending value back ("The string value `<prompt>` ...") and the only
158
- // large free-text field we send is the prompt, so attribute this to the
159
- // prompt: it's either over the model's length limit or otherwise rejected
160
- // by the validator. Either way it's user input, not a platform bug —
161
- // surface a typed, actionable, non-retryable error (logged warn, no Slack
162
- // page) instead of leaking the echoed prompt into the error channel.
163
- if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
164
- /string value/i.test(msg)) {
165
- const tooLong = /(exceed|too long|maximum length|length limit|\blimit\b)/i.test(msg);
166
- return tooLong
167
- ? new errors_1.UserFacingError("Your prompt is too long for this model. Please shorten it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_TOO_LONG)
168
- : new errors_1.UserFacingError("Your prompt was rejected by the model. Please simplify or rephrase it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_INVALID);
169
- }
170
- // gRPC code 13 = INTERNAL. Veo returns this for transient backend failures
171
- // ("Video generation failed due to an internal server issue. Please try
172
- // again in a few minutes."). It is NOT our bug and NOT moderation — a
173
- // Google-side flake. Surface as a transient PROVIDER_UNAVAILABLE so the
174
- // user gets a "try again" message and it logs warn (Loki) instead of
175
- // paging Slack as a platform error. (Egregiously-blocked content that Veo
176
- // masks as code 13 also lands here; we can't distinguish it from a real
177
- // internal flake, and "try again" is an acceptable fallback message.)
178
- if (httpCode === 13 ||
179
- status === "INTERNAL" ||
180
- /internal (server|error)/i.test(msg)) {
181
- return new errors_1.UserFacingError("Google's video service had a temporary problem. Please try again in a few minutes.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE);
182
- }
183
- // HTTP 503 / status UNAVAILABLE — Google's video backend is temporarily
184
- // overloaded or down ("The service is currently unavailable."). Same class
185
- // as code 13 INTERNAL above: a transient provider outage, not our bug and
186
- // not moderation. Without this branch it fell through to `return null` and
187
- // got re-thrown as a raw ApiError → logged at `error` (paging Slack) with
188
- // the raw provider JSON as the scene's errorMessage. Surface it as
189
- // PROVIDER_UNAVAILABLE so the user gets a "try again" message and it logs
190
- // warn (Loki) instead.
191
- if (httpCode === 503 ||
192
- status === "UNAVAILABLE" ||
193
- /service is currently unavailable|temporarily unavailable/i.test(msg)) {
194
- return new errors_1.UserFacingError("Google's video service is temporarily unavailable. Please try again in a few minutes.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE);
195
- }
196
- }
197
- catch {
198
- // Not JSON — fall through to non-JSON checks.
199
- }
200
- if (/timeout/i.test(raw) || err?.code === "ECONNABORTED") {
201
- return new errors_1.UserFacingError(raw, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_TIMEOUT);
202
- }
203
- return null;
204
- }
205
30
  class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
206
31
  constructor() {
207
32
  super();
208
33
  this.ai = new genai_1.GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY });
209
34
  this.keyPool = (0, googleKeyPool_1.getGoogleKeyPool)();
210
35
  }
36
+ /**
37
+ * Plain text generation via Gemini (`@google/genai` generateContent) for the
38
+ * aiGen text factory (LLM_NATIVE_MIGRATION_PLAN Phase 6). Accepts the same
39
+ * `input` shape as OpenaiService.generateText — a bare prompt string or an
40
+ * OpenAI-style message array (role + string content). System messages fold
41
+ * into Gemini's `systemInstruction`; assistant turns map to the "model" role.
42
+ * `options.responseFormat` of type json_object/json_schema flips on Gemini's
43
+ * native JSON mode (responseMimeType) so callers asking OpenAI for JSON get
44
+ * the same contract here.
45
+ */
46
+ async generateText(params) {
47
+ const { input, modelKey, options } = params;
48
+ const model = aiModels_1.aiModelConfigs[modelKey];
49
+ const modelId = model?.modelId || "gemini-2.5-flash";
50
+ const { systemInstruction, contents } = this.encodeTextInput(input);
51
+ const wantsJson = options?.responseFormat?.type === "json_object" ||
52
+ options?.responseFormat?.type === "json_schema";
53
+ const temperature = model?.fields?.temperature?.default
54
+ ? options?.temperature ?? model.fields.temperature.default
55
+ : undefined;
56
+ const maxOutputTokens = model?.fields?.maxOutputTokens?.default
57
+ ? options?.maxOutputTokens ?? model.fields.maxOutputTokens.default
58
+ : undefined;
59
+ const resp = await this.withTransientRetry("generateText", () => this.ai.models.generateContent({
60
+ model: modelId,
61
+ contents,
62
+ config: {
63
+ ...(systemInstruction ? { systemInstruction } : {}),
64
+ ...(typeof temperature === "number" ? { temperature } : {}),
65
+ ...(typeof maxOutputTokens === "number" ? { maxOutputTokens } : {}),
66
+ ...(wantsJson ? { responseMimeType: "application/json" } : {}),
67
+ },
68
+ }));
69
+ const text = resp.text?.trim() || "No response";
70
+ return { text };
71
+ }
72
+ /**
73
+ * Map an OpenAI-style `input` (string | {role, content}[]) onto Gemini's
74
+ * shape: merged systemInstruction + Content[] (assistant→"model"). Array
75
+ * `content` (vision parts) is flattened to its text segments — the text
76
+ * factory is text-only; image inputs go through the agent GeminiLlmCaller.
77
+ */
78
+ encodeTextInput(input) {
79
+ if (typeof input === "string") {
80
+ return { contents: [{ role: "user", parts: [{ text: input }] }] };
81
+ }
82
+ const messages = Array.isArray(input)
83
+ ? input
84
+ : [];
85
+ let systemInstruction;
86
+ const contents = [];
87
+ for (const m of messages) {
88
+ const text = typeof m.content === "string"
89
+ ? m.content
90
+ : Array.isArray(m.content)
91
+ ? m.content
92
+ .map((p) => p?.text ?? "")
93
+ .join("")
94
+ : String(m.content ?? "");
95
+ if (m.role === "system") {
96
+ systemInstruction = systemInstruction
97
+ ? `${systemInstruction}\n\n${text}`
98
+ : text;
99
+ continue;
100
+ }
101
+ const role = m.role === "assistant" ? "model" : "user";
102
+ contents.push({ role, parts: [{ text }] });
103
+ }
104
+ return { systemInstruction, contents };
105
+ }
211
106
  /**
212
107
  * Retries `fn` on transient network errors (undici "fetch failed", ECONNRESET, ETIMEDOUT,
213
108
  * DNS hiccups, etc.) with exponential backoff: 1s → 2s → 4s. Non-network errors
@@ -221,12 +116,12 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
221
116
  }
222
117
  catch (err) {
223
118
  lastErr = err;
224
- const transient = isTransientFetchError(err);
119
+ const transient = (0, googleFetch_1.isTransientFetchError)(err);
225
120
  if (!transient || attempt === GoogleService.MAX_RETRY_ATTEMPTS) {
226
121
  // Convert known provider errors (quota, high-demand, timeout) into a
227
122
  // typed UserFacingError so the scene processor stores a translatable
228
123
  // code instead of the raw provider JSON.
229
- const userFacing = classifyGoogleApiError(err);
124
+ const userFacing = (0, googleErrors_1.classifyGoogleApiError)(err);
230
125
  if (userFacing)
231
126
  throw userFacing;
232
127
  throw err;
@@ -320,11 +215,11 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
320
215
  request.video = { uri: params.inputVideoUrl };
321
216
  }
322
217
  else if (params.inputImageUrl) {
323
- request.image = await this.withTransientRetry("input-image fetch", () => fetchAsImage(params.inputImageUrl));
218
+ request.image = await this.withTransientRetry("input-image fetch", () => (0, googleFetch_1.fetchAsImage)(params.inputImageUrl));
324
219
  }
325
220
  // Last-frame image for first-last-frame interpolation. Mutually exclusive with referenceImages.
326
221
  if (params.lastFrameImageUrl) {
327
- request.config.lastFrame = await this.withTransientRetry("last-frame fetch", () => fetchAsImage(params.lastFrameImageUrl));
222
+ request.config.lastFrame = await this.withTransientRetry("last-frame fetch", () => (0, googleFetch_1.fetchAsImage)(params.lastFrameImageUrl));
328
223
  }
329
224
  // Reference images (Veo 3.1 only — up to 3 asset images for character/scene consistency).
330
225
  // When references are provided the API requires durationSeconds=8 and forbids image/video/lastFrame.
@@ -334,7 +229,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
334
229
  }
335
230
  else {
336
231
  const refs = params.referenceImageUrls.slice(0, 3);
337
- const fetched = await Promise.all(refs.map((url) => this.withTransientRetry("reference-image fetch", () => fetchAsImage(url))));
232
+ const fetched = await Promise.all(refs.map((url) => this.withTransientRetry("reference-image fetch", () => (0, googleFetch_1.fetchAsImage)(url))));
338
233
  request.config.referenceImages = fetched.map((image) => ({
339
234
  image,
340
235
  referenceType: genai_1.VideoGenerationReferenceType.ASSET,
@@ -371,7 +266,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
371
266
  // as thrown API errors so transient INTERNAL and invalid-prompt
372
267
  // failures get a typed `{code, message}` (which sceneMonitor demotes to
373
268
  // warn) instead of leaking raw gRPC JSON that pages Slack as a bug.
374
- const classified = classifyGoogleApiError({
269
+ const classified = (0, googleErrors_1.classifyGoogleApiError)({
375
270
  message: JSON.stringify(result.error),
376
271
  });
377
272
  return {
@@ -408,7 +303,15 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
408
303
  const localPath = `${outputFilename}.mp4`; // use /tmp for cloud functions
409
304
  const filePath = `${outputFilePath}/${outputFilename}.mp4`;
410
305
  const file = (0, firebase_1.getBucket)().file(filePath);
411
- await this.withTransientRetry("files.download", () => this.ai.files.download({
306
+ // Download with the SAME key that submitted the task. The Veo output is
307
+ // stored via the Files API in the issuing key's GCP project, so it is
308
+ // project-scoped exactly like the operation — the default `this.ai`
309
+ // (legacy GOOGLE_API_KEY) client can only read files from its own
310
+ // project. With the multi-key pool, the drain-first key (k0) lives in a
311
+ // separate project, so downloading its videos via `this.ai` would 403/404.
312
+ // Use the re-selected `client` (falls back to `this.ai` for un-tagged
313
+ // legacy tasks, which were submitted on GOOGLE_API_KEY anyway).
314
+ await this.withTransientRetry("files.download", () => client.files.download({
412
315
  file: video,
413
316
  downloadPath: localPath,
414
317
  }));
@@ -451,7 +354,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
451
354
  // Responsible AI practices") become UserFacingError(CONTENT_POLICY_VIOLATION)
452
355
  // instead of leaking as raw provider JSON into the worker's Slack
453
356
  // error channel.
454
- const userFacing = classifyGoogleApiError(err);
357
+ const userFacing = (0, googleErrors_1.classifyGoogleApiError)(err);
455
358
  if (userFacing)
456
359
  throw userFacing;
457
360
  throw err;
@@ -510,7 +413,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
510
413
  ...(params.inputImageUrls ?? []),
511
414
  ];
512
415
  for (const url of refs) {
513
- const ref = await fetchAsImage(url);
416
+ const ref = await (0, googleFetch_1.fetchAsImage)(url);
514
417
  parts.push({ inlineData: { mimeType: ref.mimeType, data: ref.imageBytes } });
515
418
  }
516
419
  const resp = await this.ai.models.generateContent({
@@ -561,64 +464,13 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
561
464
  *
562
465
  * Required env: GCP_PROJECT_ID. Optional: GCP_LOCATION (default us-central1).
563
466
  */
467
+ /**
468
+ * Lyria 2 (Vertex AI) — delegates to the standalone generateGoogleMusic
469
+ * (Vertex predict endpoint via ADC, not the GoogleGenAI client). See
470
+ * ./googleMusic.
471
+ */
564
472
  async generateMusic(params) {
565
- const modelConfig = aiModels_1.aiModelConfigs[params.modelKey];
566
- const modelId = modelConfig?.modelId ?? "lyria-002";
567
- const projectId = process.env.GCP_PROJECT_ID;
568
- if (!projectId) {
569
- throw new Error("Missing GCP_PROJECT_ID env var (required for Vertex Lyria)");
570
- }
571
- const location = process.env.GCP_LOCATION ?? "us-central1";
572
- const auth = new google_auth_library_1.GoogleAuth({
573
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
574
- });
575
- const client = await auth.getClient();
576
- const tokenRes = await client.getAccessToken();
577
- const token = tokenRes?.token;
578
- if (!token)
579
- throw new Error("Failed to obtain GCP access token for Vertex Lyria");
580
- const url = `https://${location}-aiplatform.googleapis.com/v1/projects/${projectId}` +
581
- `/locations/${location}/publishers/google/models/${modelId}:predict`;
582
- const instance = { prompt: params.prompt };
583
- const parameters = {
584
- sample_count: 1,
585
- };
586
- if (params.negativePrompt) {
587
- instance.negative_prompt = params.negativePrompt;
588
- }
589
- if (params.seed !== undefined) {
590
- parameters.seed = params.seed;
591
- }
592
- const resp = await fetch(url, {
593
- method: "POST",
594
- headers: {
595
- Authorization: `Bearer ${token}`,
596
- "Content-Type": "application/json",
597
- },
598
- body: JSON.stringify({ instances: [instance], parameters }),
599
- });
600
- if (!resp.ok) {
601
- const errText = await resp.text();
602
- throw new Error(`Vertex Lyria failed (${resp.status}): ${errText}`);
603
- }
604
- const data = await resp.json();
605
- const audioB64 = data?.predictions?.[0]?.bytesBase64Encoded;
606
- if (!audioB64) {
607
- throw new Error("Vertex Lyria returned no audio data");
608
- }
609
- const buffer = Buffer.from(audioB64, "base64");
610
- const path = `music/lyria/${params.outputFilename}.wav`;
611
- const file = (0, firebase_1.getBucket)().file(path);
612
- await file.save(buffer, { contentType: "audio/wav" });
613
- const [signed] = await file.getSignedUrl({
614
- action: "read",
615
- expires: "03-09-2491",
616
- });
617
- return {
618
- audioUrl: signed,
619
- mimeType: "audio/wav",
620
- extension: "wav",
621
- };
473
+ return (0, googleMusic_1.generateGoogleMusic)(params);
622
474
  }
623
475
  getCreditUsed({ modelKey, duration = 8, resolution = "720p", multiClip = false, numImages = 1, imageSize }) {
624
476
  const modelConfig = aiModels_1.aiModelConfigs[modelKey];
@@ -0,0 +1,13 @@
1
+ import { UserFacingError } from "../../../../utils/errors";
2
+ /**
3
+ * Maps `@google/genai` `ApiError` failures (whose message is a JSON string)
4
+ * to a `UserFacingError` with a stable code the frontend can translate.
5
+ * Returns null when the error is not a known user-facing case (re-throw as-is).
6
+ *
7
+ * Used both for thrown SDK errors (generateText/Image/Video) and for
8
+ * long-running-operation `result.error` payloads (checkVideoStatus), so a
9
+ * gRPC-13 INTERNAL flake or a RAI/prompt rejection becomes a typed, log-warn
10
+ * error instead of raw provider JSON that pages Slack as a platform bug.
11
+ */
12
+ export declare function classifyGoogleApiError(err: any): UserFacingError | null;
13
+ //# sourceMappingURL=googleErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleErrors.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/googleErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA2B,MAAM,0BAA0B,CAAC;AAEpF;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,GAAG,IAAI,CAmHvE"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyGoogleApiError = classifyGoogleApiError;
4
+ const errors_1 = require("../../../../utils/errors");
5
+ /**
6
+ * Maps `@google/genai` `ApiError` failures (whose message is a JSON string)
7
+ * to a `UserFacingError` with a stable code the frontend can translate.
8
+ * Returns null when the error is not a known user-facing case (re-throw as-is).
9
+ *
10
+ * Used both for thrown SDK errors (generateText/Image/Video) and for
11
+ * long-running-operation `result.error` payloads (checkVideoStatus), so a
12
+ * gRPC-13 INTERNAL flake or a RAI/prompt rejection becomes a typed, log-warn
13
+ * error instead of raw provider JSON that pages Slack as a platform bug.
14
+ */
15
+ function classifyGoogleApiError(err) {
16
+ const raw = err?.message ?? "";
17
+ try {
18
+ const parsed = JSON.parse(raw);
19
+ const inner = parsed.error ?? parsed;
20
+ const httpCode = inner.code;
21
+ const status = inner.status;
22
+ const msg = inner.message ?? raw;
23
+ if (status === "RESOURCE_EXHAUSTED" || httpCode === 429) {
24
+ return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_RATE_LIMITED);
25
+ }
26
+ // gRPC code 14 = UNAVAILABLE; Veo surfaces "high demand" failures with this.
27
+ if (httpCode === 14 || /high demand/i.test(msg)) {
28
+ return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_HIGH_DEMAND);
29
+ }
30
+ // INVALID_ARGUMENT 400 — narrow match: only the specific "use case is
31
+ // currently not supported" string, which Veo returns when our request
32
+ // structure doesn't match the chosen model variant's capabilities.
33
+ // The pre-call guards above (duration=8 for lastFrame/refs) should
34
+ // prevent the known cases; if we still hit this it's a NEW combo we
35
+ // haven't profiled — surface as CAPABILITY_MISMATCH so the user gets a
36
+ // useful message, AND keep the raw provider text in the error so the
37
+ // next entry in PROD_FIX_LOG can identify which combo broke. Generic
38
+ // 400s (other INVALID_ARGUMENT variants) still surface as `error` so
39
+ // a real platform bug isn't muted.
40
+ if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
41
+ /use case is currently not supported/i.test(msg)) {
42
+ return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.CAPABILITY_MISMATCH);
43
+ }
44
+ // Imagen + Nano-Banana surface Responsible-AI filter rejections as
45
+ // INVALID_ARGUMENT 400 with the literal text "filtered out because they
46
+ // violated Google's Responsible AI practices" (and a recommendation to
47
+ // rephrase). This is user content moderation, not a system bug — show the
48
+ // user the rephrase hint and skip the Slack page. Also matches the Veo
49
+ // RAI message ("violated Google's content policies") for the same reason.
50
+ if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
51
+ /(filtered out because they violated|violated Google's (?:Responsible AI|content) (?:practices|policies))/i.test(msg)) {
52
+ return new errors_1.UserFacingError("Your prompt was flagged by Google's safety filters. Please rephrase and try again.", errors_1.USER_FACING_ERROR_CODES.CONTENT_POLICY_VIOLATION);
53
+ }
54
+ // Generic INVALID_ARGUMENT 400 on a provided string field. Veo echoes the
55
+ // offending value back ("The string value `<prompt>` ...") and the only
56
+ // large free-text field we send is the prompt, so attribute this to the
57
+ // prompt: it's either over the model's length limit or otherwise rejected
58
+ // by the validator. Either way it's user input, not a platform bug —
59
+ // surface a typed, actionable, non-retryable error (logged warn, no Slack
60
+ // page) instead of leaking the echoed prompt into the error channel.
61
+ if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
62
+ /string value/i.test(msg)) {
63
+ const tooLong = /(exceed|too long|maximum length|length limit|\blimit\b)/i.test(msg);
64
+ return tooLong
65
+ ? new errors_1.UserFacingError("Your prompt is too long for this model. Please shorten it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_TOO_LONG)
66
+ : new errors_1.UserFacingError("Your prompt was rejected by the model. Please simplify or rephrase it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_INVALID);
67
+ }
68
+ // gRPC code 13 = INTERNAL. Veo returns this for transient backend failures
69
+ // ("Video generation failed due to an internal server issue. Please try
70
+ // again in a few minutes."). It is NOT our bug and NOT moderation — a
71
+ // Google-side flake. Surface as a transient PROVIDER_UNAVAILABLE so the
72
+ // user gets a "try again" message and it logs warn (Loki) instead of
73
+ // paging Slack as a platform error. (Egregiously-blocked content that Veo
74
+ // masks as code 13 also lands here; we can't distinguish it from a real
75
+ // internal flake, and "try again" is an acceptable fallback message.)
76
+ if (httpCode === 13 ||
77
+ status === "INTERNAL" ||
78
+ /internal (server|error)/i.test(msg)) {
79
+ return new errors_1.UserFacingError("Google's video service had a temporary problem. Please try again in a few minutes.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE);
80
+ }
81
+ // HTTP 503 / status UNAVAILABLE — Google's video backend is temporarily
82
+ // overloaded or down ("The service is currently unavailable."). Same class
83
+ // as code 13 INTERNAL above: a transient provider outage, not our bug and
84
+ // not moderation. Without this branch it fell through to `return null` and
85
+ // got re-thrown as a raw ApiError → logged at `error` (paging Slack) with
86
+ // the raw provider JSON as the scene's errorMessage. Surface it as
87
+ // PROVIDER_UNAVAILABLE so the user gets a "try again" message and it logs
88
+ // warn (Loki) instead.
89
+ if (httpCode === 503 ||
90
+ status === "UNAVAILABLE" ||
91
+ /service is currently unavailable|temporarily unavailable/i.test(msg)) {
92
+ return new errors_1.UserFacingError("Google's video service is temporarily unavailable. Please try again in a few minutes.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE);
93
+ }
94
+ }
95
+ catch {
96
+ // Not JSON — fall through to non-JSON checks.
97
+ }
98
+ if (/timeout/i.test(raw) || err?.code === "ECONNABORTED") {
99
+ return new errors_1.UserFacingError(raw, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_TIMEOUT);
100
+ }
101
+ return null;
102
+ }
@@ -0,0 +1,8 @@
1
+ export declare function pickImageMimeType(contentType: string, url: string): string;
2
+ export declare function isTransientFetchError(err: any): boolean;
3
+ export declare function inferImageMime(url: string): string;
4
+ export declare function fetchAsImage(url: string): Promise<{
5
+ mimeType: string;
6
+ imageBytes: string;
7
+ }>;
8
+ //# sourceMappingURL=googleFetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleFetch.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/googleFetch.ts"],"names":[],"mappings":"AAkCA,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB1E;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAOvD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAyBjG"}