vidspotai-shared 1.0.82 → 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 (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 +87 -243
  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
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.YouTubePublisher = void 0;
4
+ const types_1 = require("../../globals/types");
5
+ const logger_1 = require("../../utils/logger");
6
+ /**
7
+ * YouTube publisher — uploads a video via the Data API `videos.insert` resumable
8
+ * endpoint and sets visibility / native scheduling. Phase 1. See SOCIAL_SUITE_PLAN.md.
9
+ *
10
+ * Flow:
11
+ * 1. POST metadata to the resumable endpoint → get the upload session URL.
12
+ * 2. PUT the media bytes to that URL → get the video resource (with id).
13
+ *
14
+ * Scheduling: when `scheduledAt` is set, YouTube requires `privacyStatus=private`
15
+ * + `status.publishAt` (RFC3339); it auto-flips to public at that time.
16
+ *
17
+ * Quota: `videos.insert` is the expensive call against the shared 10k/day project
18
+ * quota — the worker should track burn (plan §3). Single-PUT upload is fine for
19
+ * short-form; switch to chunked upload if we publish very large long-form files.
20
+ */
21
+ const RESUMABLE_INIT = "https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status";
22
+ class YouTubePublisher {
23
+ constructor() {
24
+ this.provider = types_1.ESocialProvider.YOUTUBE;
25
+ }
26
+ async publish(input) {
27
+ const description = this.buildDescription(input);
28
+ const privacyStatus = this.resolvePrivacy(input);
29
+ const metadata = {
30
+ snippet: {
31
+ title: (input.title ?? input.caption ?? "VidSpot video").slice(0, 100),
32
+ description: description.slice(0, 5000),
33
+ },
34
+ status: {
35
+ privacyStatus,
36
+ selfDeclaredMadeForKids: false,
37
+ ...(input.scheduledAt
38
+ ? { publishAt: new Date(input.scheduledAt).toISOString() }
39
+ : {}),
40
+ },
41
+ };
42
+ // 1. Fetch the media bytes (the worker passes a public/rendered URL).
43
+ const mediaResp = await fetch(input.mediaUrl);
44
+ if (!mediaResp.ok) {
45
+ throw new Error(`YouTubePublisher: media fetch ${mediaResp.status} for ${input.mediaUrl}`);
46
+ }
47
+ const contentType = mediaResp.headers.get("content-type") ?? "video/mp4";
48
+ const bytes = Buffer.from(await mediaResp.arrayBuffer());
49
+ // 2. Init the resumable session.
50
+ const initResp = await fetch(RESUMABLE_INIT, {
51
+ method: "POST",
52
+ headers: {
53
+ Authorization: `Bearer ${input.accessToken}`,
54
+ "Content-Type": "application/json; charset=UTF-8",
55
+ "X-Upload-Content-Type": contentType,
56
+ "X-Upload-Content-Length": String(bytes.length),
57
+ },
58
+ body: JSON.stringify(metadata),
59
+ });
60
+ if (!initResp.ok) {
61
+ const text = await initResp.text();
62
+ throw new Error(`YouTubePublisher: resumable init ${initResp.status} ${text}`);
63
+ }
64
+ const uploadUrl = initResp.headers.get("location");
65
+ if (!uploadUrl) {
66
+ throw new Error("YouTubePublisher: no upload session URL returned");
67
+ }
68
+ // 3. Upload the bytes.
69
+ const uploadResp = await fetch(uploadUrl, {
70
+ method: "PUT",
71
+ headers: {
72
+ "Content-Type": contentType,
73
+ "Content-Length": String(bytes.length),
74
+ },
75
+ body: bytes,
76
+ });
77
+ const result = (await uploadResp.json());
78
+ if (!uploadResp.ok || !result.id) {
79
+ throw new Error(`YouTubePublisher: upload failed ${uploadResp.status} ${result.error?.message ?? ""}`);
80
+ }
81
+ logger_1.logger.info("YouTubePublisher: published", {
82
+ videoId: result.id,
83
+ scheduled: Boolean(input.scheduledAt),
84
+ });
85
+ return {
86
+ providerPostId: result.id,
87
+ publishedUrl: `https://www.youtube.com/watch?v=${result.id}`,
88
+ };
89
+ }
90
+ resolvePrivacy(input) {
91
+ // Native scheduling requires private until publishAt fires.
92
+ if (input.scheduledAt)
93
+ return "private";
94
+ const p = (input.privacy ?? "public").toLowerCase();
95
+ return ["public", "unlisted", "private"].includes(p) ? p : "public";
96
+ }
97
+ buildDescription(input) {
98
+ const tags = input.hashtags && input.hashtags.length
99
+ ? "\n\n" +
100
+ input.hashtags
101
+ .map((h) => (h.startsWith("#") ? h : `#${h}`))
102
+ .join(" ")
103
+ : "";
104
+ return `${input.caption ?? ""}${tags}`;
105
+ }
106
+ }
107
+ exports.YouTubePublisher = YouTubePublisher;
@@ -0,0 +1,2 @@
1
+ export * from "./realPersonSafety";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/stock/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./realPersonSafety"), exports);
@@ -0,0 +1,99 @@
1
+ /**
2
+ * S-1 — real-person safety screening for the internal stock library.
3
+ *
4
+ * The stock catalog (S-1/S-2/S-3) may surface free-tier user output as public
5
+ * "made on VidSpot" / inspiration content. Per ToS we must NEVER surface a
6
+ * video whose prompt or input imagery involves a *real, identifiable person*
7
+ * (privacy / likeness exposure). This module is the safety gate the candidate
8
+ * scanner (and later the S-2 tagger) runs before a video is even eligible for
9
+ * human review.
10
+ *
11
+ * Two independent signals, both via Gemini Flash (cheap, ~$0.00002/image):
12
+ * 1. `detectRealPersonNamesInText` — LLM scan of all prompt/title/VO text for
13
+ * proper names of real people (celebrities, politicians, public figures,
14
+ * or a specific named private individual). Generic descriptors
15
+ * ("a woman", "the CEO", "a doctor"), brand names, and clearly-fictional
16
+ * character names are NOT flagged.
17
+ * 2. `detectRealPersonInImage` — vision pass over an input/reference/poster
18
+ * image asking whether it shows a real *photographic* human person (an
19
+ * actual individual's likeness) vs. an illustration / 3D-render / clearly
20
+ * AI-generated synthetic face.
21
+ *
22
+ * Fail-safe posture: any check that errors is reported with `error` set and
23
+ * `incomplete: true` on the combined result — the caller treats "could not
24
+ * confirm safe" as NOT cleared (never silently passes a video through).
25
+ *
26
+ * Pure + side-effect-free apart from the network call to Gemini. No Firestore,
27
+ * no writes — see `scripts/scanStockCandidates.ts` for orchestration.
28
+ */
29
+ export interface RealPersonSafetyConfig {
30
+ /** Gemini / Google AI Studio API key. */
31
+ apiKey: string;
32
+ /** Override the model. Defaults to gemini-2.5-flash. */
33
+ model?: string;
34
+ /** Per-call timeout. Defaults to 30s. */
35
+ timeoutMs?: number;
36
+ }
37
+ export interface NameScanResult {
38
+ /** True when at least one real, identifiable person's name appears. */
39
+ flagged: boolean;
40
+ /** The specific real-person names found (best-effort, may be empty). */
41
+ names: string[];
42
+ /** Short rationale from the model. */
43
+ reason: string;
44
+ /** Set when the scan could not run; caller treats this as not-cleared. */
45
+ error?: string;
46
+ }
47
+ export interface ImagePersonResult {
48
+ imageUrl: string;
49
+ /** True when the image shows a real photographic human (a real likeness). */
50
+ containsRealPerson: boolean;
51
+ /** Model confidence 0..1. */
52
+ confidence: number;
53
+ reason: string;
54
+ /** Set when the check could not run; caller treats this as not-cleared. */
55
+ error?: string;
56
+ }
57
+ export interface VideoSafetyInput {
58
+ /** All free-text associated with the video: prompt, originalPrompt, title, ttsText, per-scene prompts. */
59
+ texts: string[];
60
+ /** Candidate likeness images: input/reference images + poster still. */
61
+ imageUrls: string[];
62
+ }
63
+ export interface VideoSafetyResult {
64
+ /** True once at least one screening signal actually ran. */
65
+ checked: boolean;
66
+ nameScan?: NameScanResult;
67
+ imageScans: ImagePersonResult[];
68
+ /** Final verdict: a real, identifiable person is involved → must be dropped. */
69
+ involvesRealPerson: boolean;
70
+ /** True when some signal errored, so "safe" could not be fully confirmed. */
71
+ incomplete: boolean;
72
+ /** Human-readable reasons backing the verdict / incompleteness. */
73
+ reasons: string[];
74
+ }
75
+ /**
76
+ * Scan all of a video's free text for references to real, identifiable people.
77
+ * Returns `flagged:false` for empty input. On error returns `flagged:false`
78
+ * with `error` set — the caller must treat a set `error` as not-cleared.
79
+ */
80
+ export declare function detectRealPersonNamesInText(texts: string[], config: RealPersonSafetyConfig): Promise<NameScanResult>;
81
+ /**
82
+ * Vision pass: does this single image show a real, identifiable photographic
83
+ * person? On any fetch/model error returns `containsRealPerson:false` with
84
+ * `error` set — caller treats a set `error` as not-cleared.
85
+ */
86
+ export declare function detectRealPersonInImage(imageUrl: string, config: RealPersonSafetyConfig): Promise<ImagePersonResult>;
87
+ export interface ScreenOptions {
88
+ /** Cap how many images get a (paid) vision call. Defaults to 4. */
89
+ maxImages?: number;
90
+ }
91
+ /**
92
+ * Run the full real-person screen for one video: name scan + per-image vision.
93
+ *
94
+ * `involvesRealPerson` is the OR of every positive signal. `incomplete` is true
95
+ * when any signal errored — callers must require `checked && !involvesRealPerson
96
+ * && !incomplete` before treating a video as a cleared stock candidate.
97
+ */
98
+ export declare function screenForRealPerson(input: VideoSafetyInput, config: RealPersonSafetyConfig, opts?: ScreenOptions): Promise<VideoSafetyResult>;
99
+ //# sourceMappingURL=realPersonSafety.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realPersonSafety.d.ts","sourceRoot":"","sources":["../../../src/services/stock/realPersonSafety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAQH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,kBAAkB,EAAE,OAAO,CAAC;IAC5B,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0GAA0G;IAC1G,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,wEAAwE;IACxE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,gFAAgF;IAChF,kBAAkB,EAAE,OAAO,CAAC;IAC5B,6EAA6E;IAC7E,UAAU,EAAE,OAAO,CAAC;IACpB,mEAAmE;IACnE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAuCD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,cAAc,CAAC,CA6CzB;AA4BD;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAyD5B;AAED,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,sBAAsB,EAC9B,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,iBAAiB,CAAC,CA8C5B"}
@@ -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
+ }
@@ -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);
@@ -0,0 +1,26 @@
1
+ import type { IUserSubscription } from "../models/user.model";
2
+ /**
3
+ * Whether a finished render carries the free-tier VidSpot watermark (W-1).
4
+ *
5
+ * Deliberately distinct from the model-quality `Tier` ("T0".."T3") used for
6
+ * cost estimation — this is purely a monetization/IP flag: free renders get a
7
+ * watermark, paid renders don't.
8
+ */
9
+ export type RenderTier = "free" | "paid";
10
+ /**
11
+ * True only when the user holds an *active paid* subscription. The FREE plan,
12
+ * a missing subscription, and trial / canceled / expired / inactive paid subs
13
+ * all count as not-paid — their output is watermarked.
14
+ *
15
+ * Erring toward watermark is the safe default for IP protection: a brief
16
+ * status blip (e.g. webhook lag) watermarks one render rather than leaking an
17
+ * unwatermarked one to a non-paying account.
18
+ *
19
+ * NOTE: trials are watermarked by design (W-1: "free credits / free-trial →
20
+ * watermark"). To make trials unwatermarked instead, add
21
+ * `ESUBSCRIPTION_STATUS.TRIAL` to the accepted-status check below.
22
+ */
23
+ export declare function isPaidSubscription(subscription: IUserSubscription | undefined | null): boolean;
24
+ /** Resolve the render tier (watermark flag) for a user's subscription. */
25
+ export declare function resolveRenderTier(subscription: IUserSubscription | undefined | null): RenderTier;
26
+ //# sourceMappingURL=renderTier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTier.d.ts","sourceRoot":"","sources":["../../src/utils/renderTier.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAQzC;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,GACjD,OAAO,CAIT;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,GACjD,UAAU,CAEZ"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPaidSubscription = isPaidSubscription;
4
+ exports.resolveRenderTier = resolveRenderTier;
5
+ const types_1 = require("../globals/types");
6
+ const PAID_PLANS = new Set([
7
+ types_1.ESUBSCRIPTION_PLANS.BASIC,
8
+ types_1.ESUBSCRIPTION_PLANS.PRO,
9
+ types_1.ESUBSCRIPTION_PLANS.BUSINESS,
10
+ ]);
11
+ /**
12
+ * True only when the user holds an *active paid* subscription. The FREE plan,
13
+ * a missing subscription, and trial / canceled / expired / inactive paid subs
14
+ * all count as not-paid — their output is watermarked.
15
+ *
16
+ * Erring toward watermark is the safe default for IP protection: a brief
17
+ * status blip (e.g. webhook lag) watermarks one render rather than leaking an
18
+ * unwatermarked one to a non-paying account.
19
+ *
20
+ * NOTE: trials are watermarked by design (W-1: "free credits / free-trial →
21
+ * watermark"). To make trials unwatermarked instead, add
22
+ * `ESUBSCRIPTION_STATUS.TRIAL` to the accepted-status check below.
23
+ */
24
+ function isPaidSubscription(subscription) {
25
+ if (!subscription?.planType)
26
+ return false;
27
+ if (!PAID_PLANS.has(subscription.planType))
28
+ return false;
29
+ return subscription.status === types_1.ESUBSCRIPTION_STATUS.ACTIVE;
30
+ }
31
+ /** Resolve the render tier (watermark flag) for a user's subscription. */
32
+ function resolveRenderTier(subscription) {
33
+ return isPaidSubscription(subscription) ? "paid" : "free";
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidspotai-shared",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "exports": {