vidspotai-shared 1.0.82-dev.0 → 1.0.83

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 (468) 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 +115 -10
  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 +70 -3
  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 +117 -3
  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 +4 -4
  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/recorder.d.ts +13 -1
  81. package/lib/services/agent/eval/recorder.d.ts.map +1 -1
  82. package/lib/services/agent/eval/recorder.js +59 -0
  83. package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
  84. package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
  85. package/lib/services/agent/eval/seedBriefs.js +283 -3
  86. package/lib/services/agent/eval/types.d.ts +10 -0
  87. package/lib/services/agent/eval/types.d.ts.map +1 -1
  88. package/lib/services/agent/executor/core.d.ts +70 -0
  89. package/lib/services/agent/executor/core.d.ts.map +1 -0
  90. package/lib/services/agent/executor/core.js +250 -0
  91. package/lib/services/agent/executor/duration.d.ts +20 -0
  92. package/lib/services/agent/executor/duration.d.ts.map +1 -0
  93. package/lib/services/agent/executor/duration.js +46 -0
  94. package/lib/services/agent/executor/index.d.ts +15 -0
  95. package/lib/services/agent/executor/index.d.ts.map +1 -0
  96. package/lib/services/agent/executor/index.js +32 -0
  97. package/lib/services/agent/executor/types.d.ts +183 -0
  98. package/lib/services/agent/executor/types.d.ts.map +1 -0
  99. package/lib/services/agent/executor/types.js +29 -0
  100. package/lib/services/agent/executor/visual.d.ts +32 -0
  101. package/lib/services/agent/executor/visual.d.ts.map +1 -0
  102. package/lib/services/agent/executor/visual.js +400 -0
  103. package/lib/services/agent/executor/voice.d.ts +17 -0
  104. package/lib/services/agent/executor/voice.d.ts.map +1 -0
  105. package/lib/services/agent/executor/voice.js +119 -0
  106. package/lib/services/agent/extendChain.d.ts +101 -0
  107. package/lib/services/agent/extendChain.d.ts.map +1 -0
  108. package/lib/services/agent/extendChain.js +177 -0
  109. package/lib/services/agent/index.d.ts +11 -1
  110. package/lib/services/agent/index.d.ts.map +1 -1
  111. package/lib/services/agent/index.js +11 -1
  112. package/lib/services/agent/llmCaller.d.ts +7 -8
  113. package/lib/services/agent/llmCaller.d.ts.map +1 -1
  114. package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
  115. package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
  116. package/lib/services/agent/llmCallerAnthropic.js +135 -60
  117. package/lib/services/agent/llmCallerFactory.d.ts +34 -0
  118. package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
  119. package/lib/services/agent/llmCallerFactory.js +31 -0
  120. package/lib/services/agent/llmCallerGemini.d.ts +62 -0
  121. package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
  122. package/lib/services/agent/llmCallerGemini.js +235 -0
  123. package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
  124. package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
  125. package/lib/services/agent/llmCallerOpenai.js +230 -0
  126. package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
  127. package/lib/services/agent/llmCallerRegistry.js +7 -7
  128. package/lib/services/agent/llmCallerRouting.d.ts +63 -0
  129. package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
  130. package/lib/services/agent/llmCallerRouting.js +124 -0
  131. package/lib/services/agent/llmModelRegistry.d.ts +59 -0
  132. package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
  133. package/lib/services/agent/llmModelRegistry.js +168 -0
  134. package/lib/services/agent/llmRetry.d.ts +57 -0
  135. package/lib/services/agent/llmRetry.d.ts.map +1 -0
  136. package/lib/services/agent/llmRetry.js +102 -0
  137. package/lib/services/agent/modelRouter.d.ts +3 -3
  138. package/lib/services/agent/modelRouter.d.ts.map +1 -1
  139. package/lib/services/agent/modelRouter.js +27 -13
  140. package/lib/services/agent/planMutations.d.ts +54 -1
  141. package/lib/services/agent/planMutations.d.ts.map +1 -1
  142. package/lib/services/agent/planMutations.js +78 -0
  143. package/lib/services/agent/planner/Planner.d.ts +0 -17
  144. package/lib/services/agent/planner/Planner.d.ts.map +1 -1
  145. package/lib/services/agent/planner/Planner.js +67 -303
  146. package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
  147. package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
  148. package/lib/services/agent/planner/overlayRegen.js +145 -0
  149. package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
  150. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
  151. package/lib/services/agent/planner/plannerMessages.js +185 -0
  152. package/lib/services/agent/planner/promptSections.d.ts +12 -0
  153. package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
  154. package/lib/services/agent/planner/promptSections.js +57 -0
  155. package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
  156. package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
  157. package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
  158. package/lib/services/agent/planner/structuralRules.d.ts +10 -0
  159. package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
  160. package/lib/services/agent/planner/structuralRules.js +92 -9
  161. package/lib/services/agent/planner/validators.d.ts +18 -0
  162. package/lib/services/agent/planner/validators.d.ts.map +1 -1
  163. package/lib/services/agent/planner/validators.js +97 -0
  164. package/lib/services/agent/planner.d.ts +2 -1
  165. package/lib/services/agent/planner.d.ts.map +1 -1
  166. package/lib/services/agent/planner.js +5 -1
  167. package/lib/services/agent/priorProject.d.ts +26 -0
  168. package/lib/services/agent/priorProject.d.ts.map +1 -0
  169. package/lib/services/agent/priorProject.js +51 -0
  170. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  171. package/lib/services/agent/providerFallback/chains.js +27 -15
  172. package/lib/services/agent/repurpose/index.d.ts +3 -0
  173. package/lib/services/agent/repurpose/index.d.ts.map +1 -0
  174. package/lib/services/agent/repurpose/index.js +18 -0
  175. package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
  176. package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
  177. package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
  178. package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
  179. package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
  180. package/lib/services/agent/repurpose/shortsPicker.js +218 -0
  181. package/lib/services/agent/runHelpers.d.ts +21 -2
  182. package/lib/services/agent/runHelpers.d.ts.map +1 -1
  183. package/lib/services/agent/runHelpers.js +71 -2
  184. package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
  185. package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
  186. package/lib/services/agent/tools/animateImage.tool.js +12 -0
  187. package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
  188. package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
  189. package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
  190. package/lib/services/agent/tools/composeScene.tool.d.ts +65 -2
  191. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  192. package/lib/services/agent/tools/estimateCost.tool.d.ts +28 -1
  193. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  194. package/lib/services/agent/tools/estimateCost.tool.js +55 -7
  195. package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
  196. package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
  197. package/lib/services/agent/tools/extendVideo.tool.js +149 -0
  198. package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
  199. package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
  200. package/lib/services/agent/tools/generateScript.tool.js +123 -0
  201. package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
  202. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
  203. package/lib/services/agent/tools/generateVideo.tool.js +20 -1
  204. package/lib/services/agent/tools/index.d.ts +4 -0
  205. package/lib/services/agent/tools/index.d.ts.map +1 -1
  206. package/lib/services/agent/tools/index.js +4 -0
  207. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
  208. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
  209. package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
  210. package/lib/services/agent/tools/planVideo.tool.d.ts +57 -1
  211. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  212. package/lib/services/agent/tools/planVideo.tool.js +3 -3
  213. package/lib/services/agent/tools/render.tool.d.ts +22 -1
  214. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  215. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  216. package/lib/services/aiGen/aiGenFactory.service.js +18 -3
  217. package/lib/services/aiGen/helpers.d.ts +8 -0
  218. package/lib/services/aiGen/helpers.d.ts.map +1 -1
  219. package/lib/services/aiGen/helpers.js +12 -0
  220. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
  221. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
  222. package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
  223. package/lib/services/aiGen/providers/google/google.service.d.ts +25 -1
  224. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  225. package/lib/services/aiGen/providers/google/google.service.js +136 -237
  226. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts +71 -0
  227. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts.map +1 -0
  228. package/lib/services/aiGen/providers/google/googleApiKeys.js +137 -0
  229. package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
  230. package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
  231. package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
  232. package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
  233. package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
  234. package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
  235. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts +52 -0
  236. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts.map +1 -0
  237. package/lib/services/aiGen/providers/google/googleKeyPool.js +129 -0
  238. package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
  239. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
  240. package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
  241. package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
  242. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  243. package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
  244. package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
  245. package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
  246. package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
  247. package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
  248. package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
  249. package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
  250. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
  251. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
  252. package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
  253. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  254. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +7 -1
  255. package/lib/services/bullmq.service.d.ts +61 -0
  256. package/lib/services/bullmq.service.d.ts.map +1 -1
  257. package/lib/services/bullmq.service.js +124 -2
  258. package/lib/services/crypto/index.d.ts +2 -0
  259. package/lib/services/crypto/index.d.ts.map +1 -0
  260. package/lib/services/crypto/index.js +17 -0
  261. package/lib/services/crypto/tokenVault.d.ts +47 -0
  262. package/lib/services/crypto/tokenVault.d.ts.map +1 -0
  263. package/lib/services/crypto/tokenVault.js +179 -0
  264. package/lib/services/editor/captionStyleHint.d.ts +3 -0
  265. package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
  266. package/lib/services/editor/captionStyleHint.js +112 -0
  267. package/lib/services/editor/planToProject.d.ts +7 -66
  268. package/lib/services/editor/planToProject.d.ts.map +1 -1
  269. package/lib/services/editor/planToProject.helpers.d.ts +40 -0
  270. package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
  271. package/lib/services/editor/planToProject.helpers.js +177 -0
  272. package/lib/services/editor/planToProject.js +197 -180
  273. package/lib/services/editor/planToProject.types.d.ts +94 -0
  274. package/lib/services/editor/planToProject.types.d.ts.map +1 -0
  275. package/lib/services/editor/planToProject.types.js +2 -0
  276. package/lib/services/firestore.service.d.ts +5 -0
  277. package/lib/services/firestore.service.d.ts.map +1 -1
  278. package/lib/services/firestore.service.js +13 -0
  279. package/lib/services/index.d.ts +13 -0
  280. package/lib/services/index.d.ts.map +1 -1
  281. package/lib/services/index.js +13 -0
  282. package/lib/services/promptEnhancer/index.d.ts +18 -0
  283. package/lib/services/promptEnhancer/index.d.ts.map +1 -0
  284. package/lib/services/promptEnhancer/index.js +33 -0
  285. package/lib/services/promptEnhancer/models.d.ts +54 -0
  286. package/lib/services/promptEnhancer/models.d.ts.map +1 -0
  287. package/lib/services/promptEnhancer/models.js +37 -0
  288. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
  289. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
  290. package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
  291. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
  292. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
  293. package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
  294. package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
  295. package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
  296. package/lib/services/promptEnhancer/profiles/base.js +35 -0
  297. package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
  298. package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
  299. package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
  300. package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
  301. package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
  302. package/lib/services/promptEnhancer/profiles/index.js +33 -0
  303. package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
  304. package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
  305. package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
  306. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
  307. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
  308. package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
  309. package/lib/services/promptEnhancer/schema.d.ts +19 -0
  310. package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
  311. package/lib/services/promptEnhancer/schema.js +43 -0
  312. package/lib/services/promptEnhancer/types.d.ts +112 -0
  313. package/lib/services/promptEnhancer/types.d.ts.map +1 -0
  314. package/lib/services/promptEnhancer/types.js +2 -0
  315. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts +60 -5
  316. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts.map +1 -1
  317. package/lib/services/rateLimiter/distributedRateLimiter.service.js +184 -16
  318. package/lib/services/socialAI/captionGen.d.ts +81 -0
  319. package/lib/services/socialAI/captionGen.d.ts.map +1 -0
  320. package/lib/services/socialAI/captionGen.js +206 -0
  321. package/lib/services/socialAI/hookScore.d.ts +85 -0
  322. package/lib/services/socialAI/hookScore.d.ts.map +1 -0
  323. package/lib/services/socialAI/hookScore.js +170 -0
  324. package/lib/services/socialAI/index.d.ts +3 -0
  325. package/lib/services/socialAI/index.d.ts.map +1 -0
  326. package/lib/services/socialAI/index.js +18 -0
  327. package/lib/services/socialAccounts/index.d.ts +2 -0
  328. package/lib/services/socialAccounts/index.d.ts.map +1 -0
  329. package/lib/services/socialAccounts/index.js +17 -0
  330. package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
  331. package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
  332. package/lib/services/socialAccounts/socialAccountService.js +105 -0
  333. package/lib/services/socialEngage/factory.d.ts +7 -0
  334. package/lib/services/socialEngage/factory.d.ts.map +1 -0
  335. package/lib/services/socialEngage/factory.js +25 -0
  336. package/lib/services/socialEngage/index.d.ts +6 -0
  337. package/lib/services/socialEngage/index.d.ts.map +1 -0
  338. package/lib/services/socialEngage/index.js +21 -0
  339. package/lib/services/socialEngage/meta.engage.d.ts +17 -0
  340. package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
  341. package/lib/services/socialEngage/meta.engage.js +128 -0
  342. package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
  343. package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
  344. package/lib/services/socialEngage/metaWebhook.js +93 -0
  345. package/lib/services/socialEngage/types.d.ts +72 -0
  346. package/lib/services/socialEngage/types.d.ts.map +1 -0
  347. package/lib/services/socialEngage/types.js +10 -0
  348. package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
  349. package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
  350. package/lib/services/socialEngage/youtube.engage.js +87 -0
  351. package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
  352. package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
  353. package/lib/services/socialFormat/aspectGeometry.js +135 -0
  354. package/lib/services/socialFormat/index.d.ts +2 -0
  355. package/lib/services/socialFormat/index.d.ts.map +1 -0
  356. package/lib/services/socialFormat/index.js +19 -0
  357. package/lib/services/socialInsights/index.d.ts +3 -0
  358. package/lib/services/socialInsights/index.d.ts.map +1 -0
  359. package/lib/services/socialInsights/index.js +18 -0
  360. package/lib/services/socialInsights/recommendations.d.ts +131 -0
  361. package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
  362. package/lib/services/socialInsights/recommendations.js +277 -0
  363. package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
  364. package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
  365. package/lib/services/socialInsights/timeBuckets.js +78 -0
  366. package/lib/services/socialMetrics/factory.d.ts +5 -0
  367. package/lib/services/socialMetrics/factory.d.ts.map +1 -0
  368. package/lib/services/socialMetrics/factory.js +24 -0
  369. package/lib/services/socialMetrics/index.d.ts +6 -0
  370. package/lib/services/socialMetrics/index.d.ts.map +1 -0
  371. package/lib/services/socialMetrics/index.js +21 -0
  372. package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
  373. package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
  374. package/lib/services/socialMetrics/meta.metrics.js +137 -0
  375. package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
  376. package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
  377. package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
  378. package/lib/services/socialMetrics/types.d.ts +54 -0
  379. package/lib/services/socialMetrics/types.d.ts.map +1 -0
  380. package/lib/services/socialMetrics/types.js +2 -0
  381. package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
  382. package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
  383. package/lib/services/socialMetrics/youtube.metrics.js +43 -0
  384. package/lib/services/socialOAuth/factory.d.ts +7 -0
  385. package/lib/services/socialOAuth/factory.d.ts.map +1 -0
  386. package/lib/services/socialOAuth/factory.js +42 -0
  387. package/lib/services/socialOAuth/index.d.ts +11 -0
  388. package/lib/services/socialOAuth/index.d.ts.map +1 -0
  389. package/lib/services/socialOAuth/index.js +26 -0
  390. package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
  391. package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
  392. package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
  393. package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
  394. package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
  395. package/lib/services/socialOAuth/meta.oauth.js +214 -0
  396. package/lib/services/socialOAuth/oauthState.d.ts +14 -0
  397. package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
  398. package/lib/services/socialOAuth/oauthState.js +66 -0
  399. package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
  400. package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
  401. package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
  402. package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
  403. package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
  404. package/lib/services/socialOAuth/threads.oauth.js +129 -0
  405. package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
  406. package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
  407. package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
  408. package/lib/services/socialOAuth/types.d.ts +67 -0
  409. package/lib/services/socialOAuth/types.d.ts.map +1 -0
  410. package/lib/services/socialOAuth/types.js +2 -0
  411. package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
  412. package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
  413. package/lib/services/socialOAuth/x.oauth.js +134 -0
  414. package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
  415. package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
  416. package/lib/services/socialOAuth/youtube.oauth.js +156 -0
  417. package/lib/services/socialPublish/factory.d.ts +5 -0
  418. package/lib/services/socialPublish/factory.d.ts.map +1 -0
  419. package/lib/services/socialPublish/factory.js +32 -0
  420. package/lib/services/socialPublish/index.d.ts +10 -0
  421. package/lib/services/socialPublish/index.d.ts.map +1 -0
  422. package/lib/services/socialPublish/index.js +25 -0
  423. package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
  424. package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
  425. package/lib/services/socialPublish/linkedin.publish.js +143 -0
  426. package/lib/services/socialPublish/meta.publish.d.ts +28 -0
  427. package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
  428. package/lib/services/socialPublish/meta.publish.js +149 -0
  429. package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
  430. package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
  431. package/lib/services/socialPublish/pinterest.publish.js +130 -0
  432. package/lib/services/socialPublish/threads.publish.d.ts +12 -0
  433. package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
  434. package/lib/services/socialPublish/threads.publish.js +96 -0
  435. package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
  436. package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
  437. package/lib/services/socialPublish/tiktok.publish.js +118 -0
  438. package/lib/services/socialPublish/types.d.ts +47 -0
  439. package/lib/services/socialPublish/types.d.ts.map +1 -0
  440. package/lib/services/socialPublish/types.js +2 -0
  441. package/lib/services/socialPublish/x.publish.d.ts +12 -0
  442. package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
  443. package/lib/services/socialPublish/x.publish.js +147 -0
  444. package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
  445. package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
  446. package/lib/services/socialPublish/youtube.publish.js +107 -0
  447. package/lib/services/stock/index.d.ts +2 -0
  448. package/lib/services/stock/index.d.ts.map +1 -0
  449. package/lib/services/stock/index.js +17 -0
  450. package/lib/services/stock/realPersonSafety.d.ts +99 -0
  451. package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
  452. package/lib/services/stock/realPersonSafety.js +248 -0
  453. package/lib/services/translation/index.d.ts +2 -0
  454. package/lib/services/translation/index.d.ts.map +1 -0
  455. package/lib/services/translation/index.js +9 -0
  456. package/lib/services/translation/translation.service.d.ts +50 -0
  457. package/lib/services/translation/translation.service.d.ts.map +1 -0
  458. package/lib/services/translation/translation.service.js +211 -0
  459. package/lib/utils/helpers.d.ts +2 -4
  460. package/lib/utils/helpers.d.ts.map +1 -1
  461. package/lib/utils/helpers.js +9 -63
  462. package/lib/utils/index.d.ts +1 -0
  463. package/lib/utils/index.d.ts.map +1 -1
  464. package/lib/utils/index.js +1 -0
  465. package/lib/utils/renderTier.d.ts +26 -0
  466. package/lib/utils/renderTier.d.ts.map +1 -0
  467. package/lib/utils/renderTier.js +34 -0
  468. package/package.json +1 -1
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ /**
3
+ * S-1 — real-person safety screening for the internal stock library.
4
+ *
5
+ * The stock catalog (S-1/S-2/S-3) may surface free-tier user output as public
6
+ * "made on VidSpot" / inspiration content. Per ToS we must NEVER surface a
7
+ * video whose prompt or input imagery involves a *real, identifiable person*
8
+ * (privacy / likeness exposure). This module is the safety gate the candidate
9
+ * scanner (and later the S-2 tagger) runs before a video is even eligible for
10
+ * human review.
11
+ *
12
+ * Two independent signals, both via Gemini Flash (cheap, ~$0.00002/image):
13
+ * 1. `detectRealPersonNamesInText` — LLM scan of all prompt/title/VO text for
14
+ * proper names of real people (celebrities, politicians, public figures,
15
+ * or a specific named private individual). Generic descriptors
16
+ * ("a woman", "the CEO", "a doctor"), brand names, and clearly-fictional
17
+ * character names are NOT flagged.
18
+ * 2. `detectRealPersonInImage` — vision pass over an input/reference/poster
19
+ * image asking whether it shows a real *photographic* human person (an
20
+ * actual individual's likeness) vs. an illustration / 3D-render / clearly
21
+ * AI-generated synthetic face.
22
+ *
23
+ * Fail-safe posture: any check that errors is reported with `error` set and
24
+ * `incomplete: true` on the combined result — the caller treats "could not
25
+ * confirm safe" as NOT cleared (never silently passes a video through).
26
+ *
27
+ * Pure + side-effect-free apart from the network call to Gemini. No Firestore,
28
+ * no writes — see `scripts/scanStockCandidates.ts` for orchestration.
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.detectRealPersonNamesInText = detectRealPersonNamesInText;
32
+ exports.detectRealPersonInImage = detectRealPersonInImage;
33
+ exports.screenForRealPerson = screenForRealPerson;
34
+ const genai_1 = require("@google/genai");
35
+ const logger_1 = require("../../utils/logger");
36
+ const DEFAULT_MODEL = "gemini-2.5-flash";
37
+ const DEFAULT_TIMEOUT_MS = 30000;
38
+ /** Strip ```json fences / prose and parse the first JSON object in a model reply. */
39
+ function parseJsonLoose(raw) {
40
+ if (!raw)
41
+ return null;
42
+ const fenced = raw.replace(/```(?:json)?/gi, "").trim();
43
+ const start = fenced.indexOf("{");
44
+ const end = fenced.lastIndexOf("}");
45
+ if (start === -1 || end === -1 || end < start)
46
+ return null;
47
+ try {
48
+ return JSON.parse(fenced.slice(start, end + 1));
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ function newClient(config) {
55
+ return {
56
+ ai: new genai_1.GoogleGenAI({ apiKey: config.apiKey }),
57
+ model: config.model ?? DEFAULT_MODEL,
58
+ timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,
59
+ };
60
+ }
61
+ const NAME_SCAN_PROMPT = [
62
+ "You are a content-safety classifier for a stock-video library.",
63
+ "Given the combined text written for a generated video, decide whether it references a REAL, IDENTIFIABLE PERSON.",
64
+ "Flag ONLY proper names of real people: celebrities, athletes, musicians, politicians, business figures,",
65
+ "other public figures, or a specific named private individual.",
66
+ "Do NOT flag: generic role/descriptor phrases (e.g. 'a woman', 'the CEO', 'a doctor', 'a young man'),",
67
+ "company/brand/product names, place names, or clearly fictional or generic character names.",
68
+ 'Reply with STRICT JSON only, no prose: {"flagged": boolean, "names": string[], "reason": string}.',
69
+ "names = the exact real-person names you found (empty array if none).",
70
+ ].join(" ");
71
+ /**
72
+ * Scan all of a video's free text for references to real, identifiable people.
73
+ * Returns `flagged:false` for empty input. On error returns `flagged:false`
74
+ * with `error` set — the caller must treat a set `error` as not-cleared.
75
+ */
76
+ async function detectRealPersonNamesInText(texts, config) {
77
+ const joined = texts
78
+ .map((t) => (t ?? "").trim())
79
+ .filter(Boolean)
80
+ .join("\n---\n")
81
+ .slice(0, 12000);
82
+ if (!joined) {
83
+ return { flagged: false, names: [], reason: "no text to scan" };
84
+ }
85
+ const { ai, model, timeoutMs } = newClient(config);
86
+ const controller = new AbortController();
87
+ const t = setTimeout(() => controller.abort(), timeoutMs);
88
+ try {
89
+ const resp = await ai.models.generateContent({
90
+ model,
91
+ contents: [
92
+ {
93
+ role: "user",
94
+ parts: [{ text: `${NAME_SCAN_PROMPT}\n\nTEXT:\n${joined}` }],
95
+ },
96
+ ],
97
+ config: { abortSignal: controller.signal },
98
+ });
99
+ const parsed = parseJsonLoose(resp.text ?? "");
100
+ if (!parsed || typeof parsed.flagged !== "boolean") {
101
+ return {
102
+ flagged: false,
103
+ names: [],
104
+ reason: "unparseable model reply",
105
+ error: "parse_failed",
106
+ };
107
+ }
108
+ return {
109
+ flagged: parsed.flagged,
110
+ names: Array.isArray(parsed.names) ? parsed.names.filter(Boolean) : [],
111
+ reason: typeof parsed.reason === "string" ? parsed.reason : "",
112
+ };
113
+ }
114
+ catch (err) {
115
+ const message = err instanceof Error ? err.message : String(err);
116
+ logger_1.logger.warn("detectRealPersonNamesInText: failed", { error: message });
117
+ return { flagged: false, names: [], reason: "scan failed", error: message };
118
+ }
119
+ finally {
120
+ clearTimeout(t);
121
+ }
122
+ }
123
+ const IMAGE_SCAN_PROMPT = [
124
+ "You are a content-safety classifier for a stock-video library.",
125
+ "Decide whether this image shows a REAL, IDENTIFIABLE HUMAN PERSON — i.e. a genuine photograph of a real",
126
+ "individual whose likeness is recognizable (a real face).",
127
+ "Answer containsRealPerson=true ONLY for photographic real humans whose face is visible/identifiable.",
128
+ "Answer false for: illustrations, cartoons, 3D renders, clearly AI-generated or synthetic faces,",
129
+ "mannequins, statues, silhouettes, heavily-obscured faces, distant crowds with no identifiable face,",
130
+ "or images with no person at all.",
131
+ 'Reply with STRICT JSON only, no prose: {"containsRealPerson": boolean, "confidence": number, "reason": string}.',
132
+ "confidence is 0..1.",
133
+ ].join(" ");
134
+ function pickImageMimeType(contentType, url) {
135
+ if (contentType && contentType.startsWith("image/")) {
136
+ return contentType.split(";")[0].trim();
137
+ }
138
+ const lower = url.toLowerCase();
139
+ if (lower.endsWith(".png"))
140
+ return "image/png";
141
+ if (lower.endsWith(".webp"))
142
+ return "image/webp";
143
+ if (lower.endsWith(".gif"))
144
+ return "image/gif";
145
+ return "image/jpeg";
146
+ }
147
+ /**
148
+ * Vision pass: does this single image show a real, identifiable photographic
149
+ * person? On any fetch/model error returns `containsRealPerson:false` with
150
+ * `error` set — caller treats a set `error` as not-cleared.
151
+ */
152
+ async function detectRealPersonInImage(imageUrl, config) {
153
+ const { ai, model, timeoutMs } = newClient(config);
154
+ const controller = new AbortController();
155
+ const t = setTimeout(() => controller.abort(), timeoutMs);
156
+ try {
157
+ const r = await fetch(imageUrl, { signal: controller.signal });
158
+ if (!r.ok)
159
+ throw new Error(`fetch ${r.status} ${r.statusText}`);
160
+ const bytes = Buffer.from(await r.arrayBuffer());
161
+ const mimeType = pickImageMimeType(r.headers.get("content-type"), imageUrl);
162
+ const resp = await ai.models.generateContent({
163
+ model,
164
+ contents: [
165
+ {
166
+ role: "user",
167
+ parts: [
168
+ { text: IMAGE_SCAN_PROMPT },
169
+ { inlineData: { mimeType, data: bytes.toString("base64") } },
170
+ ],
171
+ },
172
+ ],
173
+ config: { abortSignal: controller.signal },
174
+ });
175
+ const parsed = parseJsonLoose(resp.text ?? "");
176
+ if (!parsed || typeof parsed.containsRealPerson !== "boolean") {
177
+ return {
178
+ imageUrl,
179
+ containsRealPerson: false,
180
+ confidence: 0,
181
+ reason: "unparseable model reply",
182
+ error: "parse_failed",
183
+ };
184
+ }
185
+ return {
186
+ imageUrl,
187
+ containsRealPerson: parsed.containsRealPerson,
188
+ confidence: typeof parsed.confidence === "number" ? parsed.confidence : 0,
189
+ reason: typeof parsed.reason === "string" ? parsed.reason : "",
190
+ };
191
+ }
192
+ catch (err) {
193
+ const message = err instanceof Error ? err.message : String(err);
194
+ logger_1.logger.warn("detectRealPersonInImage: failed", { imageUrl, error: message });
195
+ return {
196
+ imageUrl,
197
+ containsRealPerson: false,
198
+ confidence: 0,
199
+ reason: "image check failed",
200
+ error: message,
201
+ };
202
+ }
203
+ finally {
204
+ clearTimeout(t);
205
+ }
206
+ }
207
+ /**
208
+ * Run the full real-person screen for one video: name scan + per-image vision.
209
+ *
210
+ * `involvesRealPerson` is the OR of every positive signal. `incomplete` is true
211
+ * when any signal errored — callers must require `checked && !involvesRealPerson
212
+ * && !incomplete` before treating a video as a cleared stock candidate.
213
+ */
214
+ async function screenForRealPerson(input, config, opts = {}) {
215
+ const maxImages = opts.maxImages ?? 4;
216
+ const images = Array.from(new Set(input.imageUrls.filter(Boolean))).slice(0, maxImages);
217
+ const [nameScan, imageScans] = await Promise.all([
218
+ detectRealPersonNamesInText(input.texts, config),
219
+ Promise.all(images.map((url) => detectRealPersonInImage(url, config))),
220
+ ]);
221
+ const reasons = [];
222
+ if (nameScan.flagged) {
223
+ reasons.push(`prompt references real person(s): ${nameScan.names.join(", ") || nameScan.reason}`);
224
+ }
225
+ for (const scan of imageScans) {
226
+ if (scan.containsRealPerson) {
227
+ reasons.push(`image shows a real person (${scan.confidence.toFixed(2)}): ${scan.imageUrl}`);
228
+ }
229
+ }
230
+ const incomplete = Boolean(nameScan.error) || imageScans.some((s) => Boolean(s.error));
231
+ if (incomplete) {
232
+ if (nameScan.error)
233
+ reasons.push(`name scan incomplete: ${nameScan.error}`);
234
+ for (const scan of imageScans) {
235
+ if (scan.error)
236
+ reasons.push(`image check incomplete: ${scan.imageUrl}`);
237
+ }
238
+ }
239
+ const involvesRealPerson = nameScan.flagged || imageScans.some((s) => s.containsRealPerson);
240
+ return {
241
+ checked: true,
242
+ nameScan,
243
+ imageScans,
244
+ involvesRealPerson,
245
+ incomplete,
246
+ reasons,
247
+ };
248
+ }
@@ -0,0 +1,2 @@
1
+ export { translationService } from "./translation.service";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/translation/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translationService = void 0;
4
+ // Only the new API is exported from the services barrel. The legacy aliases
5
+ // (getTranslationWrapper / detectLang / TRANSLATION_FAILED) are re-exported via
6
+ // utils/helpers instead, so each name reaches the package root through exactly
7
+ // one star-export path (no ambiguous duplicate re-export).
8
+ var translation_service_1 = require("./translation.service");
9
+ Object.defineProperty(exports, "translationService", { enumerable: true, get: function () { return translation_service_1.translationService; } });
@@ -0,0 +1,50 @@
1
+ import { ELANGUAGE_CODE, IDetectLang } from "../../globals/types";
2
+ /**
3
+ * Translation service — single abstraction over language detection + translation.
4
+ *
5
+ * WHY THIS EXISTS
6
+ * ---------------
7
+ * Translation used to be a bare axios call to a custom Cloud Function
8
+ * (`translation-service-3931b`). That endpoint times out constantly
9
+ * (`timeout of 8000ms exceeded`, ~24s of retries), and every exhaustion threw
10
+ * `TRANSLATION_FAILED` — which broke /v1/video and /v1/text prompt generation
11
+ * AND flooded Slack with `error`-level alerts.
12
+ *
13
+ * Now there are TWO layers behind one interface:
14
+ * 1. PRIMARY — the existing Cloud Function (free; just flaky).
15
+ * 2. FALLBACK — a cheap, reliable LLM (gpt-4o-mini) via our own provider
16
+ * factory. It is NOT on the Google quota that the video pipeline competes
17
+ * for, costs a fraction of a cent per short prompt, and is a single API we
18
+ * already operate.
19
+ *
20
+ * A primary timeout that the LLM recovers from logs at WARN (Console + Loki, no
21
+ * Slack) — so the common flaky-primary case no longer floods the channel. Only
22
+ * when BOTH layers fail do we log ERROR (→ Slack) and throw, so the alert that
23
+ * survives is a real, rare outage rather than noise.
24
+ *
25
+ * Callers should use `translationService.translate()` / `.detectLanguage()`.
26
+ * The legacy `getTranslationWrapper` / `detectLang` names are kept as thin
27
+ * aliases (re-exported from utils/helpers) so existing callsites keep working.
28
+ */
29
+ export declare const TRANSLATION_FAILED = "TRANSLATION_FAILED";
30
+ /**
31
+ * Translate `text` from → to (default English). Primary CF first (with a couple
32
+ * of quick retries), then a cheap LLM. Throws Error(TRANSLATION_FAILED) only if
33
+ * BOTH layers fail; `.cause` carries the last error.
34
+ */
35
+ declare function translate(text: string, from: ELANGUAGE_CODE, to?: ELANGUAGE_CODE, version?: "v1" | "v2"): Promise<string>;
36
+ /**
37
+ * Detect the language of `text`. Primary CF; on failure fails OPEN to English
38
+ * (matches prior behavior — language detection must never block generation).
39
+ */
40
+ declare function detectLanguage(text: string): Promise<IDetectLang>;
41
+ export declare const translationService: {
42
+ translate: typeof translate;
43
+ detectLanguage: typeof detectLanguage;
44
+ };
45
+ /** @deprecated use `translationService.translate` */
46
+ export declare const getTranslationWrapper: typeof translate;
47
+ /** @deprecated use `translationService.detectLanguage` */
48
+ export declare const detectLang: typeof detectLanguage;
49
+ export {};
50
+ //# sourceMappingURL=translation.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AA+EvD;;;;GAIG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAED;;;GAGG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwBhE;AAOD,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.detectLang = exports.getTranslationWrapper = exports.translationService = exports.TRANSLATION_FAILED = void 0;
40
+ const axios_1 = __importDefault(require("axios"));
41
+ const enums_1 = require("../../globals/aiModels/enums");
42
+ const types_1 = require("../../globals/types");
43
+ const logger_1 = require("../../utils/logger");
44
+ /**
45
+ * Translation service — single abstraction over language detection + translation.
46
+ *
47
+ * WHY THIS EXISTS
48
+ * ---------------
49
+ * Translation used to be a bare axios call to a custom Cloud Function
50
+ * (`translation-service-3931b`). That endpoint times out constantly
51
+ * (`timeout of 8000ms exceeded`, ~24s of retries), and every exhaustion threw
52
+ * `TRANSLATION_FAILED` — which broke /v1/video and /v1/text prompt generation
53
+ * AND flooded Slack with `error`-level alerts.
54
+ *
55
+ * Now there are TWO layers behind one interface:
56
+ * 1. PRIMARY — the existing Cloud Function (free; just flaky).
57
+ * 2. FALLBACK — a cheap, reliable LLM (gpt-4o-mini) via our own provider
58
+ * factory. It is NOT on the Google quota that the video pipeline competes
59
+ * for, costs a fraction of a cent per short prompt, and is a single API we
60
+ * already operate.
61
+ *
62
+ * A primary timeout that the LLM recovers from logs at WARN (Console + Loki, no
63
+ * Slack) — so the common flaky-primary case no longer floods the channel. Only
64
+ * when BOTH layers fail do we log ERROR (→ Slack) and throw, so the alert that
65
+ * survives is a real, rare outage rather than noise.
66
+ *
67
+ * Callers should use `translationService.translate()` / `.detectLanguage()`.
68
+ * The legacy `getTranslationWrapper` / `detectLang` names are kept as thin
69
+ * aliases (re-exported from utils/helpers) so existing callsites keep working.
70
+ */
71
+ exports.TRANSLATION_FAILED = "TRANSLATION_FAILED";
72
+ const PRIMARY_BASE = "https://us-central1-translation-service-3931b.cloudfunctions.net";
73
+ // Shorter than the old 8s so we fail over to the LLM faster (the old 3×8s =
74
+ // 24s user-facing stall was itself part of the problem).
75
+ const PRIMARY_TIMEOUT_MS = 6000;
76
+ const PRIMARY_MAX_ATTEMPTS = 2;
77
+ // gpt-4o-mini: cheap (~$0.15/1M in, $0.60/1M out → fractions of a cent per
78
+ // prompt), reliable, and independent of the Google video quota. Swap here if a
79
+ // cheaper effective model becomes available.
80
+ const FALLBACK_MODEL = enums_1.ETextGenModels.OPENAI_GPT_4O_MINI;
81
+ /** Human-readable target name for the LLM prompt; falls back to the raw code. */
82
+ const LANGUAGE_NAMES = {
83
+ en: "English",
84
+ };
85
+ function languageLabel(code) {
86
+ return LANGUAGE_NAMES[code] ?? `the language with ISO code "${code}"`;
87
+ }
88
+ /** PRIMARY: one POST to the custom translation Cloud Function. Throws on error. */
89
+ async function callPrimaryTranslate(text, from, to, version) {
90
+ const res = await axios_1.default.post(`${PRIMARY_BASE}/translate`, { text, from, to, version }, {
91
+ headers: { "internal-key": process.env.TRANSLATION_SERVICE_KEY || "" },
92
+ timeout: PRIMARY_TIMEOUT_MS,
93
+ });
94
+ const translated = res.data?.translated;
95
+ if (typeof translated !== "string" || !translated.length) {
96
+ throw new Error("primary translation returned empty payload");
97
+ }
98
+ return translated;
99
+ }
100
+ /**
101
+ * FALLBACK: translate via a cheap LLM. Lazy-imports the provider factory so this
102
+ * module stays light (utils/helpers re-exports it) and to avoid an import cycle
103
+ * with the aiGen layer.
104
+ */
105
+ async function callLlmTranslate(text, from, to) {
106
+ const { getAiGenProviderService } = await Promise.resolve().then(() => __importStar(require("../aiGen/aiGenFactory.service")));
107
+ const service = getAiGenProviderService(FALLBACK_MODEL);
108
+ const target = languageLabel(to);
109
+ const system = `You are a professional translation engine. Translate the user's text into ${target}. ` +
110
+ `Preserve meaning, tone, names, numbers, hashtags, emojis and line breaks. ` +
111
+ `Output ONLY the translated text — no quotes, no language labels, no commentary. ` +
112
+ `If the text is already in ${target}, return it unchanged.`;
113
+ const { text: out } = await service.generateText({
114
+ input: [
115
+ { role: "system", content: system },
116
+ { role: "user", content: text },
117
+ ],
118
+ modelKey: FALLBACK_MODEL,
119
+ options: { temperature: 0 },
120
+ });
121
+ const trimmed = (out ?? "").trim();
122
+ if (!trimmed || trimmed === "No response") {
123
+ throw new Error("LLM fallback returned empty translation");
124
+ }
125
+ return trimmed;
126
+ }
127
+ /**
128
+ * Translate `text` from → to (default English). Primary CF first (with a couple
129
+ * of quick retries), then a cheap LLM. Throws Error(TRANSLATION_FAILED) only if
130
+ * BOTH layers fail; `.cause` carries the last error.
131
+ */
132
+ async function translate(text, from, to = types_1.ELANGUAGE_CODE.en, version = "v2") {
133
+ if (!text || !text.trim())
134
+ return text;
135
+ // ── Layer 1: primary Cloud Function ──────────────────────────────────────
136
+ let primaryErr;
137
+ for (let attempt = 1; attempt <= PRIMARY_MAX_ATTEMPTS; attempt++) {
138
+ try {
139
+ return await callPrimaryTranslate(text, from, to, version);
140
+ }
141
+ catch (err) {
142
+ primaryErr = err;
143
+ if (attempt < PRIMARY_MAX_ATTEMPTS) {
144
+ await new Promise((r) => setTimeout(r, 200 * attempt));
145
+ }
146
+ }
147
+ }
148
+ // ── Layer 2: LLM fallback (the common recovery path — WARN, not Slack) ────
149
+ logger_1.logger.warn("translation: primary failed, falling back to LLM", {
150
+ sourceLang: from,
151
+ targetLang: to,
152
+ primaryAttempts: PRIMARY_MAX_ATTEMPTS,
153
+ fallbackModel: FALLBACK_MODEL,
154
+ err: errMsg(primaryErr),
155
+ });
156
+ try {
157
+ return await callLlmTranslate(text, from, to);
158
+ }
159
+ catch (fallbackErr) {
160
+ // Both layers down — this is the only case worth a Slack alert.
161
+ logger_1.logger.error("translation failed on BOTH primary and LLM fallback", {
162
+ sourceLang: from,
163
+ targetLang: to,
164
+ primaryErr: errMsg(primaryErr),
165
+ fallbackErr: errMsg(fallbackErr),
166
+ });
167
+ const e = new Error(exports.TRANSLATION_FAILED);
168
+ e.cause = fallbackErr;
169
+ throw e;
170
+ }
171
+ }
172
+ /**
173
+ * Detect the language of `text`. Primary CF; on failure fails OPEN to English
174
+ * (matches prior behavior — language detection must never block generation).
175
+ */
176
+ async function detectLanguage(text) {
177
+ try {
178
+ const res = await axios_1.default.post(`${PRIMARY_BASE}/detectLang`, { text }, {
179
+ headers: { "internal-key": process.env.TRANSLATION_SERVICE_KEY || "" },
180
+ timeout: PRIMARY_TIMEOUT_MS,
181
+ });
182
+ return res.data;
183
+ }
184
+ catch (err) {
185
+ logger_1.logger.warn("translation: detectLang failed, defaulting to en", {
186
+ err: errMsg(err),
187
+ });
188
+ return {
189
+ reliable: false,
190
+ textBytes: 0,
191
+ languages: [
192
+ { name: "English", code: types_1.ELANGUAGE_CODE.en, percent: 100, score: 0 },
193
+ ],
194
+ chunks: [],
195
+ };
196
+ }
197
+ }
198
+ function errMsg(err) {
199
+ if (err instanceof Error)
200
+ return err.stack ?? err.message;
201
+ return String(err);
202
+ }
203
+ exports.translationService = {
204
+ translate,
205
+ detectLanguage,
206
+ };
207
+ // ── Legacy aliases (kept so existing callsites need no change) ──────────────
208
+ /** @deprecated use `translationService.translate` */
209
+ exports.getTranslationWrapper = translate;
210
+ /** @deprecated use `translationService.detectLanguage` */
211
+ exports.detectLang = detectLanguage;
@@ -1,4 +1,4 @@
1
- import { ELANGUAGE_CODE, ERENEWAL_FREQUENCY, ESUBSCRIPTION_PLANS, EVideoDurationType, IDetectLang } from "../globals/types";
1
+ import { ERENEWAL_FREQUENCY, ESUBSCRIPTION_PLANS, EVideoDurationType } from "../globals/types";
2
2
  import z from "zod";
3
3
  import { ETextGenModels } from "../globals";
4
4
  export declare const getPlanTypeById: (priceId: string) => ESUBSCRIPTION_PLANS | null;
@@ -32,9 +32,7 @@ export declare const assertCostFound: (modelKey: string, cost: number | undefine
32
32
  */
33
33
  export declare const MULTI_CLIP_DISCOUNT_FACTORS: Partial<Record<EVideoDurationType, number>>;
34
34
  export declare function getMultiClipDiscountFactor(durationType: EVideoDurationType): number;
35
- export declare const TRANSLATION_FAILED = "TRANSLATION_FAILED";
36
- export declare const getTranslationWrapper: (text: string, from: ELANGUAGE_CODE, to?: ELANGUAGE_CODE, version?: "v1" | "v2") => Promise<string>;
37
- export declare const detectLang: (text: string) => Promise<IDetectLang>;
35
+ export { TRANSLATION_FAILED, getTranslationWrapper, detectLang, } from "../services/translation/translation.service";
38
36
  export declare function waitForFile(path: string, timeout?: number, interval?: number): Promise<boolean>;
39
37
  export declare function generateAndValidate<T extends z.ZodSchema<any>>(args: {
40
38
  userPrompt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAElB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,mBAAmB,GAAG,IASxB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,kBAAkB,GAAG,IASlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,MAAM,mBAAmB,EACzB,OAAM,kBAA+C,WAgBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,oBAAiB,KAAG,MAQpE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,MAAM,MAAM,GAAG,SAAS,EACxB,UAAU,MAAM,KACf,MASF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAInF,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,kBAAkB,GAAG,MAAM,CAEnF;AAED,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,eAAO,MAAM,qBAAqB,GAChC,MAAM,MAAM,EACZ,MAAM,cAAc,EACpB,KAAI,cAAkC,EACtC,UAAS,IAAI,GAAG,IAAW,KAC1B,OAAO,CAAC,MAAM,CAwChB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,WAAW,CAuBlE,CAAC;AAEF,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ,EACf,QAAQ,SAAM,oBAQf;AAGD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAGxB,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AA0DrB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,KACd,mBAAmB,GAAG,IASxB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,kBAAkB,GAAG,IASlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,MAAM,mBAAmB,EACzB,OAAM,kBAA+C,WAgBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,oBAAiB,KAAG,MAQpE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,MAAM,MAAM,GAAG,SAAS,EACxB,UAAU,MAAM,KACf,MASF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAInF,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,kBAAkB,GAAG,MAAM,CAEnF;AAOD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,GACX,MAAM,6CAA6C,CAAC;AAErD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,SAAQ,EACf,QAAQ,SAAM,oBAQf;AAGD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,EAAE,CAAC,CAAC;IACb,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAGxB,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AA0DrB,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAatE"}
@@ -8,7 +8,6 @@ exports.getMultiClipDiscountFactor = getMultiClipDiscountFactor;
8
8
  exports.waitForFile = waitForFile;
9
9
  exports.generateAndValidate = generateAndValidate;
10
10
  exports.getVideoDurationRangeText = getVideoDurationRangeText;
11
- const axios_1 = __importDefault(require("axios"));
12
11
  const logger_1 = require("./logger");
13
12
  const plans_1 = require("../globals/plans");
14
13
  const types_1 = require("../globals/types");
@@ -104,68 +103,15 @@ exports.MULTI_CLIP_DISCOUNT_FACTORS = {
104
103
  function getMultiClipDiscountFactor(durationType) {
105
104
  return exports.MULTI_CLIP_DISCOUNT_FACTORS[durationType] ?? 1.0;
106
105
  }
107
- exports.TRANSLATION_FAILED = "TRANSLATION_FAILED";
108
- const getTranslationWrapper = async (text, from, to = types_1.ELANGUAGE_CODE.en, version = "v2") => {
109
- const MAX_ATTEMPTS = 3;
110
- const PER_ATTEMPT_TIMEOUT_MS = 8000;
111
- let lastErr;
112
- for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
113
- try {
114
- const res = await axios_1.default.post("https://us-central1-translation-service-3931b.cloudfunctions.net/translate", { text, from, to, version }, {
115
- headers: {
116
- "internal-key": process.env.TRANSLATION_SERVICE_KEY || "",
117
- },
118
- timeout: PER_ATTEMPT_TIMEOUT_MS,
119
- });
120
- return res.data.translated;
121
- }
122
- catch (err) {
123
- lastErr = err;
124
- const isLast = attempt === MAX_ATTEMPTS;
125
- if (isLast) {
126
- logger_1.logger.error("translation retry exhausted", {
127
- sourceLang: from,
128
- targetLang: to,
129
- attempts: attempt,
130
- err: lastErr?.stack ?? lastErr?.message ?? String(lastErr),
131
- });
132
- break;
133
- }
134
- logger_1.logger.warn("getTranslationWrapper attempt failed, retrying", {
135
- attempt,
136
- maxAttempts: MAX_ATTEMPTS,
137
- err: err?.stack ?? err?.message ?? String(err),
138
- });
139
- await new Promise((r) => setTimeout(r, 200 * attempt));
140
- }
141
- }
142
- const e = new Error(exports.TRANSLATION_FAILED);
143
- e.cause = lastErr;
144
- throw e;
145
- };
146
- exports.getTranslationWrapper = getTranslationWrapper;
147
- const detectLang = async (text) => {
148
- try {
149
- const res = await axios_1.default.post("https://us-central1-translation-service-3931b.cloudfunctions.net/detectLang", { text }, {
150
- headers: { "internal-key": process.env.TRANSLATION_SERVICE_KEY || "" },
151
- timeout: 8000,
152
- });
153
- return res.data;
154
- }
155
- catch (err) {
156
- // External service failure — default to English so video generation is not blocked
157
- logger_1.logger.warn("detectLang: failed, defaulting to en", {
158
- err: err?.stack ?? err?.message ?? String(err),
159
- });
160
- return {
161
- reliable: false,
162
- textBytes: 0,
163
- languages: [{ name: "English", code: types_1.ELANGUAGE_CODE.en, percent: 100, score: 0 }],
164
- chunks: [],
165
- };
166
- }
167
- };
168
- exports.detectLang = detectLang;
106
+ // Translation + language detection moved into a dedicated, fallback-capable
107
+ // service (primary Cloud Function cheap LLM). Re-exported here so existing
108
+ // callers importing `getTranslationWrapper` / `detectLang` / `TRANSLATION_FAILED`
109
+ // from the package root keep working unchanged. New code should prefer
110
+ // `translationService` from the services barrel.
111
+ var translation_service_1 = require("../services/translation/translation.service");
112
+ Object.defineProperty(exports, "TRANSLATION_FAILED", { enumerable: true, get: function () { return translation_service_1.TRANSLATION_FAILED; } });
113
+ Object.defineProperty(exports, "getTranslationWrapper", { enumerable: true, get: function () { return translation_service_1.getTranslationWrapper; } });
114
+ Object.defineProperty(exports, "detectLang", { enumerable: true, get: function () { return translation_service_1.detectLang; } });
169
115
  async function waitForFile(path, timeout = 10000, interval = 300) {
170
116
  const start = Date.now();
171
117
  while (Date.now() - start < timeout) {
@@ -1,5 +1,6 @@
1
1
  export * from "./errors";
2
2
  export * from "./helpers";
3
3
  export * from "./logger";
4
+ export * from "./renderTier";
4
5
  export * from "./ttsUtils";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./errors"), exports);
18
18
  __exportStar(require("./helpers"), exports);
19
19
  __exportStar(require("./logger"), exports);
20
+ __exportStar(require("./renderTier"), exports);
20
21
  __exportStar(require("./ttsUtils"), exports);