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,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLATFORM_COPY_HINTS = void 0;
4
+ exports.buildSuggestionPrompt = buildSuggestionPrompt;
5
+ exports.parseSocialSuggestion = parseSocialSuggestion;
6
+ exports.generateSocialSuggestionsCore = generateSocialSuggestionsCore;
7
+ const types_1 = require("../../globals/types");
8
+ exports.PLATFORM_COPY_HINTS = {
9
+ [types_1.ESocialProvider.YOUTUBE]: {
10
+ maxChars: 4900,
11
+ maxHashtags: 5,
12
+ note: "YouTube: a strong, searchable title carries the post; description can be longer and front-load the hook; 3–5 relevant hashtags.",
13
+ },
14
+ [types_1.ESocialProvider.INSTAGRAM]: {
15
+ maxChars: 2100,
16
+ maxHashtags: 12,
17
+ note: "Instagram Reels: hook in the first line (it's the only part shown collapsed); conversational; 8–12 niche, non-spammy hashtags.",
18
+ },
19
+ [types_1.ESocialProvider.TIKTOK]: {
20
+ maxChars: 2100,
21
+ maxHashtags: 6,
22
+ note: "TikTok: punchy, native, trend-aware; only ~150 chars show before the fold; 3–6 hashtags mixing broad + niche.",
23
+ },
24
+ [types_1.ESocialProvider.FACEBOOK]: {
25
+ maxChars: 4900,
26
+ maxHashtags: 3,
27
+ note: "Facebook: friendly and shareable; hashtags are sparse here — at most 1–3.",
28
+ },
29
+ [types_1.ESocialProvider.LINKEDIN]: {
30
+ maxChars: 2900,
31
+ maxHashtags: 5,
32
+ note: "LinkedIn: professional, value-first, minimal emojis; 3–5 industry hashtags.",
33
+ },
34
+ [types_1.ESocialProvider.X]: {
35
+ maxChars: 270,
36
+ maxHashtags: 2,
37
+ note: "X (Twitter): HARD 280-char limit including hashtags — keep it tight; at most 1–2 hashtags.",
38
+ },
39
+ [types_1.ESocialProvider.PINTEREST]: {
40
+ maxChars: 480,
41
+ maxHashtags: 5,
42
+ note: "Pinterest: keyword-rich and descriptive for search; 2–5 descriptive hashtags.",
43
+ },
44
+ [types_1.ESocialProvider.THREADS]: {
45
+ maxChars: 480,
46
+ maxHashtags: 3,
47
+ note: "Threads: casual and conversational; very few hashtags (Threads supports one primary topic tag).",
48
+ },
49
+ };
50
+ const VALID_PROVIDERS = new Set(Object.values(types_1.ESocialProvider));
51
+ /** Normalize a raw hashtag list: strip '#', spaces, dedupe (case-insensitive). */
52
+ function normalizeHashtags(raw, cap) {
53
+ if (!Array.isArray(raw))
54
+ return [];
55
+ const seen = new Set();
56
+ const out = [];
57
+ for (const item of raw) {
58
+ if (typeof item !== "string")
59
+ continue;
60
+ // Strip leading '#'s and all whitespace; a model sometimes returns "#a b".
61
+ const tag = item.replace(/^#+/, "").replace(/\s+/g, "").trim();
62
+ if (!tag)
63
+ continue;
64
+ const key = tag.toLowerCase();
65
+ if (seen.has(key))
66
+ continue;
67
+ seen.add(key);
68
+ out.push(tag);
69
+ if (out.length >= cap)
70
+ break;
71
+ }
72
+ return out;
73
+ }
74
+ /** Clamp to a max char length on a word boundary where possible. */
75
+ function clampText(text, maxChars) {
76
+ const t = (text ?? "").trim();
77
+ if (t.length <= maxChars)
78
+ return t;
79
+ const cut = t.slice(0, maxChars);
80
+ const lastSpace = cut.lastIndexOf(" ");
81
+ return (lastSpace > maxChars * 0.6 ? cut.slice(0, lastSpace) : cut).trim();
82
+ }
83
+ /** The loosest base limits (used for the platform-agnostic base caption). */
84
+ const BASE_CAPTION_MAX = 2200;
85
+ const BASE_HASHTAG_MAX = 15;
86
+ const TITLE_MAX = 100;
87
+ /** Build the chat prompt for a suggestion request. Pure — no I/O. */
88
+ function buildSuggestionPrompt(ctx) {
89
+ const providers = ctx.providers.filter((p) => VALID_PROVIDERS.has(p));
90
+ const lang = (ctx.language || "en").trim();
91
+ const toneLine = ctx.tone
92
+ ? `Brand voice / tone: ${ctx.tone}.`
93
+ : "Brand voice: authentic, energetic, and human — never corporate or spammy.";
94
+ const platformNotes = providers
95
+ .map((p) => `- ${p}: ${exports.PLATFORM_COPY_HINTS[p].note}`)
96
+ .join("\n");
97
+ const system = "You are an expert social media copywriter for short-form video creators. " +
98
+ "You write scroll-stopping captions, relevant non-spammy hashtags, and " +
99
+ "compelling titles that maximize reach and engagement. You always write in " +
100
+ `the requested language (${lang}) and respect each platform's norms and ` +
101
+ "character limits. You reply with ONLY a single JSON object, no prose, no " +
102
+ "code fences.";
103
+ const aboutLines = [
104
+ ctx.videoTitle ? `Working title: ${ctx.videoTitle}` : null,
105
+ ctx.videoSummary ? `What the video is about: ${ctx.videoSummary}` : null,
106
+ ].filter(Boolean);
107
+ const about = aboutLines.length
108
+ ? aboutLines.join("\n")
109
+ : "A short-form video (no further details provided — infer a generic but appealing angle).";
110
+ const user = `Write social copy in language "${lang}" for this video.\n\n${about}\n\n` +
111
+ `${toneLine}\n\n` +
112
+ `Target platforms:\n${platformNotes || "- (generic)"}\n\n` +
113
+ "Produce a platform-agnostic BASE (a strong caption, a hashtag set, and a " +
114
+ "title) AND one tailored VARIANT per target platform that respects that " +
115
+ "platform's note above (length, hashtag count, style). Hashtags must NOT " +
116
+ "include the '#' symbol and must be single words (no spaces). Do not invent " +
117
+ "facts about the video.\n\n" +
118
+ "Reply with ONLY this JSON shape:\n" +
119
+ "{\n" +
120
+ ' "title": "string (<= 100 chars, YouTube-style)",\n' +
121
+ ' "caption": "string (the base caption)",\n' +
122
+ ' "hashtags": ["tag1", "tag2"],\n' +
123
+ ' "variants": [\n' +
124
+ ' { "provider": "<one of the target platforms>", "caption": "string", "hashtags": ["tag1"] }\n' +
125
+ " ]\n" +
126
+ "}";
127
+ return [
128
+ { role: "system", content: system },
129
+ { role: "user", content: user },
130
+ ];
131
+ }
132
+ /** Strip a ```json … ``` fence the model may wrap the object in. */
133
+ function stripCodeFence(raw) {
134
+ const t = raw.trim();
135
+ if (!t.startsWith("```"))
136
+ return t;
137
+ return t
138
+ .replace(/^```(?:json)?\s*/i, "")
139
+ .replace(/\s*```$/, "")
140
+ .trim();
141
+ }
142
+ /**
143
+ * Parse + validate + clamp the model's JSON into an `ISocialSuggestion`.
144
+ * Defensive: malformed JSON degrades to a plain caption (the raw text) with no
145
+ * hashtags/variants rather than throwing, so the composer always gets something
146
+ * usable. Variants are kept only for providers the caller actually requested.
147
+ */
148
+ function parseSocialSuggestion(raw, ctx) {
149
+ const requested = new Set(ctx.providers.filter((p) => VALID_PROVIDERS.has(p)));
150
+ let obj = null;
151
+ try {
152
+ const parsed = JSON.parse(stripCodeFence(raw));
153
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
154
+ obj = parsed;
155
+ }
156
+ }
157
+ catch {
158
+ obj = null;
159
+ }
160
+ // Fallback: treat the whole response as the caption.
161
+ if (!obj) {
162
+ return {
163
+ caption: clampText(raw, BASE_CAPTION_MAX),
164
+ hashtags: [],
165
+ title: "",
166
+ variants: [],
167
+ };
168
+ }
169
+ const title = clampText(typeof obj.title === "string" ? obj.title : "", TITLE_MAX);
170
+ const caption = clampText(typeof obj.caption === "string" ? obj.caption : "", BASE_CAPTION_MAX);
171
+ const hashtags = normalizeHashtags(obj.hashtags, BASE_HASHTAG_MAX);
172
+ const variants = [];
173
+ const seenProviders = new Set();
174
+ if (Array.isArray(obj.variants)) {
175
+ for (const v of obj.variants) {
176
+ if (!v || typeof v !== "object")
177
+ continue;
178
+ const rec = v;
179
+ const provider = rec.provider;
180
+ if (typeof provider !== "string" || !requested.has(provider)) {
181
+ continue;
182
+ }
183
+ const p = provider;
184
+ if (seenProviders.has(p))
185
+ continue;
186
+ seenProviders.add(p);
187
+ const hint = exports.PLATFORM_COPY_HINTS[p];
188
+ variants.push({
189
+ provider: p,
190
+ caption: clampText(typeof rec.caption === "string" ? rec.caption : caption, hint.maxChars),
191
+ hashtags: normalizeHashtags(rec.hashtags, hint.maxHashtags),
192
+ });
193
+ }
194
+ }
195
+ return { caption, hashtags, title, variants };
196
+ }
197
+ /**
198
+ * Generate social suggestions with the LLM injected (testable). Builds the
199
+ * prompt, calls the model, parses + clamps the result. Never throws on a bad
200
+ * model response — it degrades to a usable caption (see `parseSocialSuggestion`).
201
+ */
202
+ async function generateSocialSuggestionsCore(llm, ctx) {
203
+ const messages = buildSuggestionPrompt(ctx);
204
+ const raw = await llm(messages);
205
+ return parseSocialSuggestion(raw, ctx);
206
+ }
@@ -0,0 +1,85 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ /**
3
+ * X8 Social Suite — Phase 6 E4: hook / caption score predictor.
4
+ *
5
+ * Score a hook (the caption's first line / the on-screen opener) for predicted
6
+ * engagement BEFORE posting, and hand back concrete rewrites. This is the same
7
+ * `*Core(llm,…)` convention as captionGen (E1) — pure prompt-build + defensive
8
+ * parse/clamp with the LLM injected, so it's unit-/eval-testable away from the
9
+ * OpenAI client. It is a *predictor / coach*, not a guarantee: the score is the
10
+ * model's judgement against well-known short-form hook heuristics (scroll-stop,
11
+ * clarity, curiosity gap, relevance, platform fit), surfaced so the user can
12
+ * iterate the copy. Review-before-publish — nothing posts here.
13
+ *
14
+ * Why a separate brain from E1: E1 *writes* copy from a video; E4 *grades*
15
+ * arbitrary copy the user already has (typed or AI-written) and proposes
16
+ * stronger variants. Different prompt, different output shape, shared norms.
17
+ */
18
+ /** Input for a hook score request (no secrets — safe to log). */
19
+ export interface IHookScoreContext {
20
+ /** The hook / caption opener to grade (required). */
21
+ hook: string;
22
+ /** Platform the copy targets — tunes the rubric to that surface's norms. */
23
+ provider?: ESocialProvider;
24
+ /** What the video is about — lets the model judge relevance, not just craft. */
25
+ videoSummary?: string;
26
+ /** Language the copy is written in (defaults to English). */
27
+ language?: string;
28
+ }
29
+ /** The five engagement drivers we grade a hook on (each 0–100). */
30
+ export interface IHookScoreBreakdown {
31
+ /** Scroll-stopping power — does it arrest the thumb in the first beat? */
32
+ attention: number;
33
+ /** Is the promise/topic instantly legible (no decoding)? */
34
+ clarity: number;
35
+ /** Curiosity gap — does it open a loop the viewer must close? */
36
+ curiosity: number;
37
+ /** Does it match what the video actually delivers (no bait)? */
38
+ relevance: number;
39
+ /** Native fit for the target platform's length + tone conventions. */
40
+ platformFit: number;
41
+ }
42
+ /** Coarse band derived deterministically from the overall score. */
43
+ export type HookVerdict = "weak" | "okay" | "strong";
44
+ /** The full graded result the composer renders. */
45
+ export interface IHookScore {
46
+ /** Overall 0–100 predicted-engagement score. */
47
+ score: number;
48
+ /** Band derived from `score` (not trusted from the model). */
49
+ verdict: HookVerdict;
50
+ /** Per-driver sub-scores. */
51
+ breakdown: IHookScoreBreakdown;
52
+ /** What's working (short bullets). */
53
+ strengths: string[];
54
+ /** What's holding it back (short, actionable bullets). */
55
+ issues: string[];
56
+ /** 2–3 stronger rewrites the user can adopt with one tap. */
57
+ rewrites: string[];
58
+ }
59
+ /** A minimal LLM call: take chat messages, return the raw text completion. */
60
+ export type HookScoreLlm = (messages: Array<{
61
+ role: "system" | "user";
62
+ content: string;
63
+ }>) => Promise<string>;
64
+ /** Verdict bands: <40 weak, <70 okay, ≥70 strong. */
65
+ export declare function verdictForScore(score: number): HookVerdict;
66
+ /** Build the chat prompt for a hook-score request. Pure — no I/O. */
67
+ export declare function buildHookScorePrompt(ctx: IHookScoreContext): Array<{
68
+ role: "system" | "user";
69
+ content: string;
70
+ }>;
71
+ /**
72
+ * Parse + validate + clamp the model's JSON into an `IHookScore`. Defensive:
73
+ * malformed JSON degrades to a neutral 50 with empty coaching rather than
74
+ * throwing, so the composer always renders something. The verdict is ALWAYS
75
+ * recomputed from the clamped score (never trusted from the model) so the band
76
+ * and number can't disagree.
77
+ */
78
+ export declare function parseHookScore(raw: string): IHookScore;
79
+ /**
80
+ * Score a hook with the LLM injected (testable). Builds the prompt, calls the
81
+ * model, parses + clamps. Never throws on a bad model response — degrades to a
82
+ * neutral score (see `parseHookScore`).
83
+ */
84
+ export declare function scoreHookCore(llm: HookScoreLlm, ctx: IHookScoreContext): Promise<IHookScore>;
85
+ //# sourceMappingURL=hookScore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hookScore.d.ts","sourceRoot":"","sources":["../../../src/services/socialAI/hookScore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD;;;;;;;;;;;;;;;GAeG;AAEH,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,mEAAmE;AACnE,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,oEAAoE;AACpE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,mDAAmD;AACnD,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,OAAO,EAAE,WAAW,CAAC;IACrB,6BAA6B;IAC7B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,sCAAsC;IACtC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,8EAA8E;AAC9E,MAAM,MAAM,YAAY,GAAG,CACzB,QAAQ,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,KAC1D,OAAO,CAAC,MAAM,CAAC,CAAC;AAkBrB,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAI1D;AA+BD,qEAAqE;AACrE,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,iBAAiB,GACrB,KAAK,CAAC;IAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA2CrD;AAYD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA8CtD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAAC,UAAU,CAAC,CAIrB"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verdictForScore = verdictForScore;
4
+ exports.buildHookScorePrompt = buildHookScorePrompt;
5
+ exports.parseHookScore = parseHookScore;
6
+ exports.scoreHookCore = scoreHookCore;
7
+ const types_1 = require("../../globals/types");
8
+ const captionGen_1 = require("./captionGen");
9
+ const DRIVER_KEYS = [
10
+ "attention",
11
+ "clarity",
12
+ "curiosity",
13
+ "relevance",
14
+ "platformFit",
15
+ ];
16
+ const MAX_HOOK_INPUT = 600;
17
+ const MAX_BULLET = 160;
18
+ const MAX_BULLETS = 4;
19
+ const MAX_REWRITE = 280;
20
+ const MAX_REWRITES = 3;
21
+ const VALID_PROVIDERS = new Set(Object.values(types_1.ESocialProvider));
22
+ /** Verdict bands: <40 weak, <70 okay, ≥70 strong. */
23
+ function verdictForScore(score) {
24
+ if (score < 40)
25
+ return "weak";
26
+ if (score < 70)
27
+ return "okay";
28
+ return "strong";
29
+ }
30
+ function clampScore(raw) {
31
+ const n = typeof raw === "number" ? raw : Number(raw);
32
+ if (!Number.isFinite(n))
33
+ return 0;
34
+ return Math.max(0, Math.min(100, Math.round(n)));
35
+ }
36
+ /** Clamp + trim a free-text bullet to one tidy line. */
37
+ function clampBullet(text, max) {
38
+ if (typeof text !== "string")
39
+ return "";
40
+ return text.replace(/\s+/g, " ").trim().slice(0, max);
41
+ }
42
+ /** Normalize a string list: trim, drop empties, dedupe, cap length + count. */
43
+ function normalizeList(raw, maxLen, maxCount) {
44
+ if (!Array.isArray(raw))
45
+ return [];
46
+ const seen = new Set();
47
+ const out = [];
48
+ for (const item of raw) {
49
+ const s = clampBullet(item, maxLen);
50
+ if (!s)
51
+ continue;
52
+ const key = s.toLowerCase();
53
+ if (seen.has(key))
54
+ continue;
55
+ seen.add(key);
56
+ out.push(s);
57
+ if (out.length >= maxCount)
58
+ break;
59
+ }
60
+ return out;
61
+ }
62
+ /** Build the chat prompt for a hook-score request. Pure — no I/O. */
63
+ function buildHookScorePrompt(ctx) {
64
+ const lang = (ctx.language || "en").trim();
65
+ const provider = ctx.provider && VALID_PROVIDERS.has(ctx.provider) ? ctx.provider : undefined;
66
+ const platformNote = provider
67
+ ? `Target platform: ${provider}. ${captionGen_1.PLATFORM_COPY_HINTS[provider].note}`
68
+ : "No specific platform — judge against general short-form video norms.";
69
+ const about = ctx.videoSummary
70
+ ? `What the video is actually about (judge RELEVANCE against this — penalize bait that the video can't pay off):\n${ctx.videoSummary.slice(0, 1200)}`
71
+ : "The video's content is unknown — judge relevance only on internal coherence of the hook.";
72
+ const system = "You are a short-form video growth expert who predicts how well a hook " +
73
+ "will perform. You grade hooks against proven engagement drivers: " +
74
+ "scroll-stopping ATTENTION, instant CLARITY, a CURIOSITY gap, RELEVANCE to " +
75
+ "the actual content (no clickbait the video can't deliver), and native " +
76
+ "PLATFORM FIT. You are calibrated and honest — most hooks are mediocre; " +
77
+ "reserve 80+ for genuinely scroll-stopping copy. You always respond in the " +
78
+ `requested language (${lang}) for the prose fields and rewrites. You reply ` +
79
+ "with ONLY a single JSON object — no prose, no code fences.";
80
+ const user = `Grade this hook and propose stronger rewrites. Write prose + rewrites in language "${lang}".\n\n` +
81
+ `HOOK:\n"""${ctx.hook.slice(0, MAX_HOOK_INPUT)}"""\n\n` +
82
+ `${platformNote}\n\n${about}\n\n` +
83
+ "Score the hook 0-100 overall and 0-100 on each driver. Give 1-3 short " +
84
+ "strengths, 1-3 short actionable issues, and 2-3 rewrites that keep the " +
85
+ "topic but hit harder (each a complete, ready-to-use hook). Do not invent " +
86
+ "facts the video can't support.\n\n" +
87
+ "Reply with ONLY this JSON shape:\n" +
88
+ "{\n" +
89
+ ' "score": 0,\n' +
90
+ ' "breakdown": { "attention": 0, "clarity": 0, "curiosity": 0, "relevance": 0, "platformFit": 0 },\n' +
91
+ ' "strengths": ["..."],\n' +
92
+ ' "issues": ["..."],\n' +
93
+ ' "rewrites": ["...", "..."]\n' +
94
+ "}";
95
+ return [
96
+ { role: "system", content: system },
97
+ { role: "user", content: user },
98
+ ];
99
+ }
100
+ /** Strip a ```json … ``` fence the model may wrap the object in. */
101
+ function stripCodeFence(raw) {
102
+ const t = raw.trim();
103
+ if (!t.startsWith("```"))
104
+ return t;
105
+ return t
106
+ .replace(/^```(?:json)?\s*/i, "")
107
+ .replace(/\s*```$/, "")
108
+ .trim();
109
+ }
110
+ /**
111
+ * Parse + validate + clamp the model's JSON into an `IHookScore`. Defensive:
112
+ * malformed JSON degrades to a neutral 50 with empty coaching rather than
113
+ * throwing, so the composer always renders something. The verdict is ALWAYS
114
+ * recomputed from the clamped score (never trusted from the model) so the band
115
+ * and number can't disagree.
116
+ */
117
+ function parseHookScore(raw) {
118
+ let obj = null;
119
+ try {
120
+ const parsed = JSON.parse(stripCodeFence(raw));
121
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
122
+ obj = parsed;
123
+ }
124
+ }
125
+ catch {
126
+ obj = null;
127
+ }
128
+ if (!obj) {
129
+ return {
130
+ score: 50,
131
+ verdict: verdictForScore(50),
132
+ breakdown: {
133
+ attention: 50,
134
+ clarity: 50,
135
+ curiosity: 50,
136
+ relevance: 50,
137
+ platformFit: 50,
138
+ },
139
+ strengths: [],
140
+ issues: [],
141
+ rewrites: [],
142
+ };
143
+ }
144
+ const score = clampScore(obj.score);
145
+ const rawBreakdown = obj.breakdown && typeof obj.breakdown === "object"
146
+ ? obj.breakdown
147
+ : {};
148
+ const breakdown = DRIVER_KEYS.reduce((acc, k) => {
149
+ acc[k] = clampScore(rawBreakdown[k]);
150
+ return acc;
151
+ }, {});
152
+ return {
153
+ score,
154
+ verdict: verdictForScore(score),
155
+ breakdown,
156
+ strengths: normalizeList(obj.strengths, MAX_BULLET, MAX_BULLETS),
157
+ issues: normalizeList(obj.issues, MAX_BULLET, MAX_BULLETS),
158
+ rewrites: normalizeList(obj.rewrites, MAX_REWRITE, MAX_REWRITES),
159
+ };
160
+ }
161
+ /**
162
+ * Score a hook with the LLM injected (testable). Builds the prompt, calls the
163
+ * model, parses + clamps. Never throws on a bad model response — degrades to a
164
+ * neutral score (see `parseHookScore`).
165
+ */
166
+ async function scoreHookCore(llm, ctx) {
167
+ const messages = buildHookScorePrompt(ctx);
168
+ const raw = await llm(messages);
169
+ return parseHookScore(raw);
170
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./captionGen";
2
+ export * from "./hookScore";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/socialAI/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,18 @@
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("./captionGen"), exports);
18
+ __exportStar(require("./hookScore"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./socialAccountService";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/socialAccounts/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,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("./socialAccountService"), exports);
@@ -0,0 +1,25 @@
1
+ import { ESocialAccountStatus, ESocialProvider } from "../../globals/types";
2
+ import { ISocialTokenBundle } from "../../models/social.model";
3
+ import { OAuthTokens } from "../socialOAuth/types";
4
+ /** Encrypt cleartext OAuth tokens into the persisted bundle shape. */
5
+ export declare function toEncryptedTokenBundle(tokens: OAuthTokens): ISocialTokenBundle;
6
+ /**
7
+ * Return a valid CLEARTEXT access token for an account, refreshing + persisting
8
+ * it first if it's expired or near expiry. Throws (and flags the account as
9
+ * NEEDS_RECONNECT) if refresh fails — callers should surface a reconnect nudge.
10
+ */
11
+ export declare function getValidAccessToken(accountId: string): Promise<string>;
12
+ /** Persist a freshly-refreshed token bundle + mark the account healthy. */
13
+ export declare function persistRefreshedTokens(accountId: string, refreshed: OAuthTokens): Promise<void>;
14
+ /** Update only the health sub-document (status + optional error). */
15
+ export declare function markAccountHealth(accountId: string, status: ESocialAccountStatus, lastError?: string): Promise<void>;
16
+ /**
17
+ * Find accounts whose access token expires within `withinMs` so the refresh
18
+ * daemon can proactively refresh them (Meta 60-day / YT short-lived). Scoped to
19
+ * ACTIVE accounts that actually have a refresh token.
20
+ */
21
+ export declare function findAccountsNeedingRefresh(withinMs: number, limit?: number): Promise<Array<{
22
+ id: string;
23
+ provider: ESocialProvider;
24
+ }>>;
25
+ //# sourceMappingURL=socialAccountService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"socialAccountService.d.ts","sourceRoot":"","sources":["../../../src/services/socialAccounts/socialAccountService.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAanD,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,kBAAkB,CAS9E;AAWD;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC5E;AAED,2EAA2E;AAC3E,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC,CASf;AAED,qEAAqE;AACrE,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,oBAAoB,EAC5B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAM,GACV,OAAO,CAAC,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,CAAC,CAQ3D"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toEncryptedTokenBundle = toEncryptedTokenBundle;
4
+ exports.getValidAccessToken = getValidAccessToken;
5
+ exports.persistRefreshedTokens = persistRefreshedTokens;
6
+ exports.markAccountHealth = markAccountHealth;
7
+ exports.findAccountsNeedingRefresh = findAccountsNeedingRefresh;
8
+ const firebase_1 = require("../../libs/firebase");
9
+ const types_1 = require("../../globals/types");
10
+ const logger_1 = require("../../utils/logger");
11
+ const firestore_service_1 = require("../firestore.service");
12
+ const factory_1 = require("../socialOAuth/factory");
13
+ const tokenVault_1 = require("../crypto/tokenVault");
14
+ /**
15
+ * X8 Social Suite — connected-account token lifecycle. Centralizes the
16
+ * encrypt-on-write / decrypt-on-read + refresh-if-expiring logic so the publish
17
+ * worker, metrics poller, and refresh daemon never touch raw ciphertext or the
18
+ * refresh wire directly. See notes/SOCIAL_SUITE_PLAN.md §4.
19
+ */
20
+ /** Refresh the access token when it's within this window of expiry. */
21
+ const REFRESH_BUFFER_MS = 5 * 60 * 1000;
22
+ /** Encrypt cleartext OAuth tokens into the persisted bundle shape. */
23
+ function toEncryptedTokenBundle(tokens) {
24
+ return {
25
+ accessToken: (0, tokenVault_1.encryptToken)(tokens.accessToken),
26
+ refreshToken: tokens.refreshToken
27
+ ? (0, tokenVault_1.encryptToken)(tokens.refreshToken)
28
+ : undefined,
29
+ expiresAt: tokens.expiresAt,
30
+ refreshExpiresAt: tokens.refreshExpiresAt,
31
+ };
32
+ }
33
+ async function loadAccount(accountId) {
34
+ const snap = await firestore_service_1.FirestoreService.socialAccountsCol.doc(accountId).get();
35
+ const data = snap.data();
36
+ if (!data)
37
+ throw new Error(`socialAccount ${accountId} not found`);
38
+ return { id: accountId, data };
39
+ }
40
+ /**
41
+ * Return a valid CLEARTEXT access token for an account, refreshing + persisting
42
+ * it first if it's expired or near expiry. Throws (and flags the account as
43
+ * NEEDS_RECONNECT) if refresh fails — callers should surface a reconnect nudge.
44
+ */
45
+ async function getValidAccessToken(accountId) {
46
+ const { data } = await loadAccount(accountId);
47
+ const { tokens } = data;
48
+ const fresh = tokens.expiresAt - Date.now() > REFRESH_BUFFER_MS;
49
+ if (fresh) {
50
+ return (0, tokenVault_1.decryptToken)(tokens.accessToken);
51
+ }
52
+ if (!tokens.refreshToken) {
53
+ await markAccountHealth(accountId, types_1.ESocialAccountStatus.NEEDS_RECONNECT, "access token expired and no refresh token on file");
54
+ throw new Error(`socialAccount ${accountId}: expired, no refresh token`);
55
+ }
56
+ try {
57
+ const provider = (0, factory_1.getSocialOAuthProvider)(data.provider);
58
+ const refreshToken = (0, tokenVault_1.decryptToken)(tokens.refreshToken);
59
+ const refreshed = await provider.refresh(refreshToken);
60
+ await persistRefreshedTokens(accountId, refreshed);
61
+ return refreshed.accessToken;
62
+ }
63
+ catch (err) {
64
+ const message = err instanceof Error ? err.message : String(err);
65
+ logger_1.logger.warn("socialAccount: token refresh failed", { accountId, message });
66
+ await markAccountHealth(accountId, types_1.ESocialAccountStatus.NEEDS_RECONNECT, message);
67
+ throw new Error(`socialAccount ${accountId}: refresh failed — ${message}`);
68
+ }
69
+ }
70
+ /** Persist a freshly-refreshed token bundle + mark the account healthy. */
71
+ async function persistRefreshedTokens(accountId, refreshed) {
72
+ await firestore_service_1.FirestoreService.socialAccountsCol.doc(accountId).update({
73
+ tokens: toEncryptedTokenBundle(refreshed),
74
+ health: {
75
+ status: types_1.ESocialAccountStatus.ACTIVE,
76
+ lastRefreshAt: Date.now(),
77
+ },
78
+ updatedAt: firebase_1.FieldValue.serverTimestamp(),
79
+ });
80
+ }
81
+ /** Update only the health sub-document (status + optional error). */
82
+ async function markAccountHealth(accountId, status, lastError) {
83
+ await firestore_service_1.FirestoreService.socialAccountsCol.doc(accountId).update({
84
+ health: {
85
+ status,
86
+ ...(lastError ? { lastError } : {}),
87
+ lastRefreshAt: Date.now(),
88
+ },
89
+ updatedAt: firebase_1.FieldValue.serverTimestamp(),
90
+ });
91
+ }
92
+ /**
93
+ * Find accounts whose access token expires within `withinMs` so the refresh
94
+ * daemon can proactively refresh them (Meta 60-day / YT short-lived). Scoped to
95
+ * ACTIVE accounts that actually have a refresh token.
96
+ */
97
+ async function findAccountsNeedingRefresh(withinMs, limit = 100) {
98
+ const cutoff = Date.now() + withinMs;
99
+ const snap = await firestore_service_1.FirestoreService.socialAccountsCol
100
+ .where("health.status", "==", types_1.ESocialAccountStatus.ACTIVE)
101
+ .where("tokens.expiresAt", "<=", cutoff)
102
+ .limit(limit)
103
+ .get();
104
+ return snap.docs.map((d) => ({ id: d.id, provider: d.data().provider }));
105
+ }
@@ -0,0 +1,7 @@
1
+ import { ESocialProvider } from "../../globals/types";
2
+ import { ISocialEngageClient } from "./types";
3
+ export declare function getSocialEngageClient(provider: ESocialProvider): ISocialEngageClient;
4
+ export declare function isSocialEngageSupported(provider: ESocialProvider): boolean;
5
+ /** Providers whose comments must be PULLED (no webhook) by the poll sweep. */
6
+ export declare const ENGAGE_POLL_PROVIDERS: ESocialProvider[];
7
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/services/socialEngage/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAS9C,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,GACxB,mBAAmB,CAMrB;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAE1E;AAED,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,EAAE,eAAe,EAA8B,CAAC"}