vidspotai-shared 1.0.82-dev.0 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (468) hide show
  1. package/lib/globals/aiModels/enums.d.ts +11 -1
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +24 -1
  4. package/lib/globals/aiModels/index.d.ts.map +1 -1
  5. package/lib/globals/aiModels/index.js +2 -0
  6. package/lib/globals/aiModels/providers/anthropic.d.ts +12 -0
  7. package/lib/globals/aiModels/providers/anthropic.d.ts.map +1 -0
  8. package/lib/globals/aiModels/providers/anthropic.js +88 -0
  9. package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
  10. package/lib/globals/aiModels/providers/google.js +115 -10
  11. package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
  12. package/lib/globals/aiModels/providers/openai.js +63 -4
  13. package/lib/globals/aiModels/tierHelpers.d.ts +12 -0
  14. package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -1
  15. package/lib/globals/aiModels/tierHelpers.js +83 -0
  16. package/lib/globals/aiModels/types.d.ts +19 -0
  17. package/lib/globals/aiModels/types.d.ts.map +1 -1
  18. package/lib/globals/types.d.ts +120 -1
  19. package/lib/globals/types.d.ts.map +1 -1
  20. package/lib/globals/types.js +135 -1
  21. package/lib/models/agent.model.d.ts +41 -1
  22. package/lib/models/agent.model.d.ts.map +1 -1
  23. package/lib/models/index.d.ts +1 -0
  24. package/lib/models/index.d.ts.map +1 -1
  25. package/lib/models/index.js +1 -0
  26. package/lib/models/social.model.d.ts +180 -0
  27. package/lib/models/social.model.d.ts.map +1 -0
  28. package/lib/models/social.model.js +2 -0
  29. package/lib/models/user.model.d.ts +10 -0
  30. package/lib/models/user.model.d.ts.map +1 -1
  31. package/lib/models/video.model.d.ts +6 -0
  32. package/lib/models/video.model.d.ts.map +1 -1
  33. package/lib/schemas/brief.schema.d.ts +46 -0
  34. package/lib/schemas/brief.schema.d.ts.map +1 -1
  35. package/lib/schemas/brief.schema.js +72 -1
  36. package/lib/schemas/index.d.ts +1 -0
  37. package/lib/schemas/index.d.ts.map +1 -1
  38. package/lib/schemas/index.js +1 -0
  39. package/lib/schemas/project.schema.d.ts +70 -3
  40. package/lib/schemas/project.schema.d.ts.map +1 -1
  41. package/lib/schemas/project.schema.js +12 -0
  42. package/lib/schemas/social.schema.d.ts +91 -0
  43. package/lib/schemas/social.schema.d.ts.map +1 -0
  44. package/lib/schemas/social.schema.js +114 -0
  45. package/lib/schemas/videoPlan.schema.d.ts +117 -3
  46. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  47. package/lib/schemas/videoPlan.schema.js +141 -1
  48. package/lib/services/agent/chatAgent.d.ts +25 -1
  49. package/lib/services/agent/chatAgent.d.ts.map +1 -1
  50. package/lib/services/agent/chatAgent.js +145 -9
  51. package/lib/services/agent/costPreflight.d.ts +11 -1
  52. package/lib/services/agent/costPreflight.d.ts.map +1 -1
  53. package/lib/services/agent/costPreflight.js +18 -1
  54. package/lib/services/agent/covers/coverPlanner.d.ts +41 -0
  55. package/lib/services/agent/covers/coverPlanner.d.ts.map +1 -0
  56. package/lib/services/agent/covers/coverPlanner.js +278 -0
  57. package/lib/services/agent/covers/covers.schema.d.ts +158 -0
  58. package/lib/services/agent/covers/covers.schema.d.ts.map +1 -0
  59. package/lib/services/agent/covers/covers.schema.js +166 -0
  60. package/lib/services/agent/covers/index.d.ts +3 -0
  61. package/lib/services/agent/covers/index.d.ts.map +1 -0
  62. package/lib/services/agent/covers/index.js +18 -0
  63. package/lib/services/agent/critic.d.ts +10 -0
  64. package/lib/services/agent/critic.d.ts.map +1 -1
  65. package/lib/services/agent/critic.js +37 -1
  66. package/lib/services/agent/editClassifier.d.ts +4 -4
  67. package/lib/services/agent/editClassifier.js +2 -2
  68. package/lib/services/agent/editExisting/editAssembler.d.ts +78 -0
  69. package/lib/services/agent/editExisting/editAssembler.d.ts.map +1 -0
  70. package/lib/services/agent/editExisting/editAssembler.js +172 -0
  71. package/lib/services/agent/editExisting/editExisting.schema.d.ts +119 -0
  72. package/lib/services/agent/editExisting/editExisting.schema.d.ts.map +1 -0
  73. package/lib/services/agent/editExisting/editExisting.schema.js +157 -0
  74. package/lib/services/agent/editExisting/highlightPicker.d.ts +48 -0
  75. package/lib/services/agent/editExisting/highlightPicker.d.ts.map +1 -0
  76. package/lib/services/agent/editExisting/highlightPicker.js +199 -0
  77. package/lib/services/agent/editExisting/index.d.ts +4 -0
  78. package/lib/services/agent/editExisting/index.d.ts.map +1 -0
  79. package/lib/services/agent/editExisting/index.js +19 -0
  80. package/lib/services/agent/eval/recorder.d.ts +13 -1
  81. package/lib/services/agent/eval/recorder.d.ts.map +1 -1
  82. package/lib/services/agent/eval/recorder.js +59 -0
  83. package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
  84. package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
  85. package/lib/services/agent/eval/seedBriefs.js +283 -3
  86. package/lib/services/agent/eval/types.d.ts +10 -0
  87. package/lib/services/agent/eval/types.d.ts.map +1 -1
  88. package/lib/services/agent/executor/core.d.ts +70 -0
  89. package/lib/services/agent/executor/core.d.ts.map +1 -0
  90. package/lib/services/agent/executor/core.js +250 -0
  91. package/lib/services/agent/executor/duration.d.ts +20 -0
  92. package/lib/services/agent/executor/duration.d.ts.map +1 -0
  93. package/lib/services/agent/executor/duration.js +46 -0
  94. package/lib/services/agent/executor/index.d.ts +15 -0
  95. package/lib/services/agent/executor/index.d.ts.map +1 -0
  96. package/lib/services/agent/executor/index.js +32 -0
  97. package/lib/services/agent/executor/types.d.ts +183 -0
  98. package/lib/services/agent/executor/types.d.ts.map +1 -0
  99. package/lib/services/agent/executor/types.js +29 -0
  100. package/lib/services/agent/executor/visual.d.ts +32 -0
  101. package/lib/services/agent/executor/visual.d.ts.map +1 -0
  102. package/lib/services/agent/executor/visual.js +400 -0
  103. package/lib/services/agent/executor/voice.d.ts +17 -0
  104. package/lib/services/agent/executor/voice.d.ts.map +1 -0
  105. package/lib/services/agent/executor/voice.js +119 -0
  106. package/lib/services/agent/extendChain.d.ts +101 -0
  107. package/lib/services/agent/extendChain.d.ts.map +1 -0
  108. package/lib/services/agent/extendChain.js +177 -0
  109. package/lib/services/agent/index.d.ts +11 -1
  110. package/lib/services/agent/index.d.ts.map +1 -1
  111. package/lib/services/agent/index.js +11 -1
  112. package/lib/services/agent/llmCaller.d.ts +7 -8
  113. package/lib/services/agent/llmCaller.d.ts.map +1 -1
  114. package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
  115. package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
  116. package/lib/services/agent/llmCallerAnthropic.js +135 -60
  117. package/lib/services/agent/llmCallerFactory.d.ts +34 -0
  118. package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
  119. package/lib/services/agent/llmCallerFactory.js +31 -0
  120. package/lib/services/agent/llmCallerGemini.d.ts +62 -0
  121. package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
  122. package/lib/services/agent/llmCallerGemini.js +235 -0
  123. package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
  124. package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
  125. package/lib/services/agent/llmCallerOpenai.js +230 -0
  126. package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
  127. package/lib/services/agent/llmCallerRegistry.js +7 -7
  128. package/lib/services/agent/llmCallerRouting.d.ts +63 -0
  129. package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
  130. package/lib/services/agent/llmCallerRouting.js +124 -0
  131. package/lib/services/agent/llmModelRegistry.d.ts +59 -0
  132. package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
  133. package/lib/services/agent/llmModelRegistry.js +168 -0
  134. package/lib/services/agent/llmRetry.d.ts +57 -0
  135. package/lib/services/agent/llmRetry.d.ts.map +1 -0
  136. package/lib/services/agent/llmRetry.js +102 -0
  137. package/lib/services/agent/modelRouter.d.ts +3 -3
  138. package/lib/services/agent/modelRouter.d.ts.map +1 -1
  139. package/lib/services/agent/modelRouter.js +27 -13
  140. package/lib/services/agent/planMutations.d.ts +54 -1
  141. package/lib/services/agent/planMutations.d.ts.map +1 -1
  142. package/lib/services/agent/planMutations.js +78 -0
  143. package/lib/services/agent/planner/Planner.d.ts +0 -17
  144. package/lib/services/agent/planner/Planner.d.ts.map +1 -1
  145. package/lib/services/agent/planner/Planner.js +67 -303
  146. package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
  147. package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
  148. package/lib/services/agent/planner/overlayRegen.js +145 -0
  149. package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
  150. package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
  151. package/lib/services/agent/planner/plannerMessages.js +185 -0
  152. package/lib/services/agent/planner/promptSections.d.ts +12 -0
  153. package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
  154. package/lib/services/agent/planner/promptSections.js +57 -0
  155. package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
  156. package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
  157. package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
  158. package/lib/services/agent/planner/structuralRules.d.ts +10 -0
  159. package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
  160. package/lib/services/agent/planner/structuralRules.js +92 -9
  161. package/lib/services/agent/planner/validators.d.ts +18 -0
  162. package/lib/services/agent/planner/validators.d.ts.map +1 -1
  163. package/lib/services/agent/planner/validators.js +97 -0
  164. package/lib/services/agent/planner.d.ts +2 -1
  165. package/lib/services/agent/planner.d.ts.map +1 -1
  166. package/lib/services/agent/planner.js +5 -1
  167. package/lib/services/agent/priorProject.d.ts +26 -0
  168. package/lib/services/agent/priorProject.d.ts.map +1 -0
  169. package/lib/services/agent/priorProject.js +51 -0
  170. package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
  171. package/lib/services/agent/providerFallback/chains.js +27 -15
  172. package/lib/services/agent/repurpose/index.d.ts +3 -0
  173. package/lib/services/agent/repurpose/index.d.ts.map +1 -0
  174. package/lib/services/agent/repurpose/index.js +18 -0
  175. package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
  176. package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
  177. package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
  178. package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
  179. package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
  180. package/lib/services/agent/repurpose/shortsPicker.js +218 -0
  181. package/lib/services/agent/runHelpers.d.ts +21 -2
  182. package/lib/services/agent/runHelpers.d.ts.map +1 -1
  183. package/lib/services/agent/runHelpers.js +71 -2
  184. package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
  185. package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
  186. package/lib/services/agent/tools/animateImage.tool.js +12 -0
  187. package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
  188. package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
  189. package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
  190. package/lib/services/agent/tools/composeScene.tool.d.ts +65 -2
  191. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  192. package/lib/services/agent/tools/estimateCost.tool.d.ts +28 -1
  193. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  194. package/lib/services/agent/tools/estimateCost.tool.js +55 -7
  195. package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
  196. package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
  197. package/lib/services/agent/tools/extendVideo.tool.js +149 -0
  198. package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
  199. package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
  200. package/lib/services/agent/tools/generateScript.tool.js +123 -0
  201. package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
  202. package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
  203. package/lib/services/agent/tools/generateVideo.tool.js +20 -1
  204. package/lib/services/agent/tools/index.d.ts +4 -0
  205. package/lib/services/agent/tools/index.d.ts.map +1 -1
  206. package/lib/services/agent/tools/index.js +4 -0
  207. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
  208. package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
  209. package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
  210. package/lib/services/agent/tools/planVideo.tool.d.ts +57 -1
  211. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  212. package/lib/services/agent/tools/planVideo.tool.js +3 -3
  213. package/lib/services/agent/tools/render.tool.d.ts +22 -1
  214. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  215. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  216. package/lib/services/aiGen/aiGenFactory.service.js +18 -3
  217. package/lib/services/aiGen/helpers.d.ts +8 -0
  218. package/lib/services/aiGen/helpers.d.ts.map +1 -1
  219. package/lib/services/aiGen/helpers.js +12 -0
  220. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
  221. package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
  222. package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
  223. package/lib/services/aiGen/providers/google/google.service.d.ts +25 -1
  224. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  225. package/lib/services/aiGen/providers/google/google.service.js +136 -237
  226. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts +71 -0
  227. package/lib/services/aiGen/providers/google/googleApiKeys.d.ts.map +1 -0
  228. package/lib/services/aiGen/providers/google/googleApiKeys.js +137 -0
  229. package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
  230. package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
  231. package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
  232. package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
  233. package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
  234. package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
  235. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts +52 -0
  236. package/lib/services/aiGen/providers/google/googleKeyPool.d.ts.map +1 -0
  237. package/lib/services/aiGen/providers/google/googleKeyPool.js +129 -0
  238. package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
  239. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
  240. package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
  241. package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
  242. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  243. package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
  244. package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
  245. package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
  246. package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
  247. package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
  248. package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
  249. package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
  250. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
  251. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
  252. package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
  253. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  254. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +7 -1
  255. package/lib/services/bullmq.service.d.ts +61 -0
  256. package/lib/services/bullmq.service.d.ts.map +1 -1
  257. package/lib/services/bullmq.service.js +124 -2
  258. package/lib/services/crypto/index.d.ts +2 -0
  259. package/lib/services/crypto/index.d.ts.map +1 -0
  260. package/lib/services/crypto/index.js +17 -0
  261. package/lib/services/crypto/tokenVault.d.ts +47 -0
  262. package/lib/services/crypto/tokenVault.d.ts.map +1 -0
  263. package/lib/services/crypto/tokenVault.js +179 -0
  264. package/lib/services/editor/captionStyleHint.d.ts +3 -0
  265. package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
  266. package/lib/services/editor/captionStyleHint.js +112 -0
  267. package/lib/services/editor/planToProject.d.ts +7 -66
  268. package/lib/services/editor/planToProject.d.ts.map +1 -1
  269. package/lib/services/editor/planToProject.helpers.d.ts +40 -0
  270. package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
  271. package/lib/services/editor/planToProject.helpers.js +177 -0
  272. package/lib/services/editor/planToProject.js +197 -180
  273. package/lib/services/editor/planToProject.types.d.ts +94 -0
  274. package/lib/services/editor/planToProject.types.d.ts.map +1 -0
  275. package/lib/services/editor/planToProject.types.js +2 -0
  276. package/lib/services/firestore.service.d.ts +5 -0
  277. package/lib/services/firestore.service.d.ts.map +1 -1
  278. package/lib/services/firestore.service.js +13 -0
  279. package/lib/services/index.d.ts +13 -0
  280. package/lib/services/index.d.ts.map +1 -1
  281. package/lib/services/index.js +13 -0
  282. package/lib/services/promptEnhancer/index.d.ts +18 -0
  283. package/lib/services/promptEnhancer/index.d.ts.map +1 -0
  284. package/lib/services/promptEnhancer/index.js +33 -0
  285. package/lib/services/promptEnhancer/models.d.ts +54 -0
  286. package/lib/services/promptEnhancer/models.d.ts.map +1 -0
  287. package/lib/services/promptEnhancer/models.js +37 -0
  288. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
  289. package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
  290. package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
  291. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
  292. package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
  293. package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
  294. package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
  295. package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
  296. package/lib/services/promptEnhancer/profiles/base.js +35 -0
  297. package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
  298. package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
  299. package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
  300. package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
  301. package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
  302. package/lib/services/promptEnhancer/profiles/index.js +33 -0
  303. package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
  304. package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
  305. package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
  306. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
  307. package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
  308. package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
  309. package/lib/services/promptEnhancer/schema.d.ts +19 -0
  310. package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
  311. package/lib/services/promptEnhancer/schema.js +43 -0
  312. package/lib/services/promptEnhancer/types.d.ts +112 -0
  313. package/lib/services/promptEnhancer/types.d.ts.map +1 -0
  314. package/lib/services/promptEnhancer/types.js +2 -0
  315. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts +60 -5
  316. package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts.map +1 -1
  317. package/lib/services/rateLimiter/distributedRateLimiter.service.js +184 -16
  318. package/lib/services/socialAI/captionGen.d.ts +81 -0
  319. package/lib/services/socialAI/captionGen.d.ts.map +1 -0
  320. package/lib/services/socialAI/captionGen.js +206 -0
  321. package/lib/services/socialAI/hookScore.d.ts +85 -0
  322. package/lib/services/socialAI/hookScore.d.ts.map +1 -0
  323. package/lib/services/socialAI/hookScore.js +170 -0
  324. package/lib/services/socialAI/index.d.ts +3 -0
  325. package/lib/services/socialAI/index.d.ts.map +1 -0
  326. package/lib/services/socialAI/index.js +18 -0
  327. package/lib/services/socialAccounts/index.d.ts +2 -0
  328. package/lib/services/socialAccounts/index.d.ts.map +1 -0
  329. package/lib/services/socialAccounts/index.js +17 -0
  330. package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
  331. package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
  332. package/lib/services/socialAccounts/socialAccountService.js +105 -0
  333. package/lib/services/socialEngage/factory.d.ts +7 -0
  334. package/lib/services/socialEngage/factory.d.ts.map +1 -0
  335. package/lib/services/socialEngage/factory.js +25 -0
  336. package/lib/services/socialEngage/index.d.ts +6 -0
  337. package/lib/services/socialEngage/index.d.ts.map +1 -0
  338. package/lib/services/socialEngage/index.js +21 -0
  339. package/lib/services/socialEngage/meta.engage.d.ts +17 -0
  340. package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
  341. package/lib/services/socialEngage/meta.engage.js +128 -0
  342. package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
  343. package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
  344. package/lib/services/socialEngage/metaWebhook.js +93 -0
  345. package/lib/services/socialEngage/types.d.ts +72 -0
  346. package/lib/services/socialEngage/types.d.ts.map +1 -0
  347. package/lib/services/socialEngage/types.js +10 -0
  348. package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
  349. package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
  350. package/lib/services/socialEngage/youtube.engage.js +87 -0
  351. package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
  352. package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
  353. package/lib/services/socialFormat/aspectGeometry.js +135 -0
  354. package/lib/services/socialFormat/index.d.ts +2 -0
  355. package/lib/services/socialFormat/index.d.ts.map +1 -0
  356. package/lib/services/socialFormat/index.js +19 -0
  357. package/lib/services/socialInsights/index.d.ts +3 -0
  358. package/lib/services/socialInsights/index.d.ts.map +1 -0
  359. package/lib/services/socialInsights/index.js +18 -0
  360. package/lib/services/socialInsights/recommendations.d.ts +131 -0
  361. package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
  362. package/lib/services/socialInsights/recommendations.js +277 -0
  363. package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
  364. package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
  365. package/lib/services/socialInsights/timeBuckets.js +78 -0
  366. package/lib/services/socialMetrics/factory.d.ts +5 -0
  367. package/lib/services/socialMetrics/factory.d.ts.map +1 -0
  368. package/lib/services/socialMetrics/factory.js +24 -0
  369. package/lib/services/socialMetrics/index.d.ts +6 -0
  370. package/lib/services/socialMetrics/index.d.ts.map +1 -0
  371. package/lib/services/socialMetrics/index.js +21 -0
  372. package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
  373. package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
  374. package/lib/services/socialMetrics/meta.metrics.js +137 -0
  375. package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
  376. package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
  377. package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
  378. package/lib/services/socialMetrics/types.d.ts +54 -0
  379. package/lib/services/socialMetrics/types.d.ts.map +1 -0
  380. package/lib/services/socialMetrics/types.js +2 -0
  381. package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
  382. package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
  383. package/lib/services/socialMetrics/youtube.metrics.js +43 -0
  384. package/lib/services/socialOAuth/factory.d.ts +7 -0
  385. package/lib/services/socialOAuth/factory.d.ts.map +1 -0
  386. package/lib/services/socialOAuth/factory.js +42 -0
  387. package/lib/services/socialOAuth/index.d.ts +11 -0
  388. package/lib/services/socialOAuth/index.d.ts.map +1 -0
  389. package/lib/services/socialOAuth/index.js +26 -0
  390. package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
  391. package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
  392. package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
  393. package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
  394. package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
  395. package/lib/services/socialOAuth/meta.oauth.js +214 -0
  396. package/lib/services/socialOAuth/oauthState.d.ts +14 -0
  397. package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
  398. package/lib/services/socialOAuth/oauthState.js +66 -0
  399. package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
  400. package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
  401. package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
  402. package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
  403. package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
  404. package/lib/services/socialOAuth/threads.oauth.js +129 -0
  405. package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
  406. package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
  407. package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
  408. package/lib/services/socialOAuth/types.d.ts +67 -0
  409. package/lib/services/socialOAuth/types.d.ts.map +1 -0
  410. package/lib/services/socialOAuth/types.js +2 -0
  411. package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
  412. package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
  413. package/lib/services/socialOAuth/x.oauth.js +134 -0
  414. package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
  415. package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
  416. package/lib/services/socialOAuth/youtube.oauth.js +156 -0
  417. package/lib/services/socialPublish/factory.d.ts +5 -0
  418. package/lib/services/socialPublish/factory.d.ts.map +1 -0
  419. package/lib/services/socialPublish/factory.js +32 -0
  420. package/lib/services/socialPublish/index.d.ts +10 -0
  421. package/lib/services/socialPublish/index.d.ts.map +1 -0
  422. package/lib/services/socialPublish/index.js +25 -0
  423. package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
  424. package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
  425. package/lib/services/socialPublish/linkedin.publish.js +143 -0
  426. package/lib/services/socialPublish/meta.publish.d.ts +28 -0
  427. package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
  428. package/lib/services/socialPublish/meta.publish.js +149 -0
  429. package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
  430. package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
  431. package/lib/services/socialPublish/pinterest.publish.js +130 -0
  432. package/lib/services/socialPublish/threads.publish.d.ts +12 -0
  433. package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
  434. package/lib/services/socialPublish/threads.publish.js +96 -0
  435. package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
  436. package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
  437. package/lib/services/socialPublish/tiktok.publish.js +118 -0
  438. package/lib/services/socialPublish/types.d.ts +47 -0
  439. package/lib/services/socialPublish/types.d.ts.map +1 -0
  440. package/lib/services/socialPublish/types.js +2 -0
  441. package/lib/services/socialPublish/x.publish.d.ts +12 -0
  442. package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
  443. package/lib/services/socialPublish/x.publish.js +147 -0
  444. package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
  445. package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
  446. package/lib/services/socialPublish/youtube.publish.js +107 -0
  447. package/lib/services/stock/index.d.ts +2 -0
  448. package/lib/services/stock/index.d.ts.map +1 -0
  449. package/lib/services/stock/index.js +17 -0
  450. package/lib/services/stock/realPersonSafety.d.ts +99 -0
  451. package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
  452. package/lib/services/stock/realPersonSafety.js +248 -0
  453. package/lib/services/translation/index.d.ts +2 -0
  454. package/lib/services/translation/index.d.ts.map +1 -0
  455. package/lib/services/translation/index.js +9 -0
  456. package/lib/services/translation/translation.service.d.ts +50 -0
  457. package/lib/services/translation/translation.service.d.ts.map +1 -0
  458. package/lib/services/translation/translation.service.js +211 -0
  459. package/lib/utils/helpers.d.ts +2 -4
  460. package/lib/utils/helpers.d.ts.map +1 -1
  461. package/lib/utils/helpers.js +9 -63
  462. package/lib/utils/index.d.ts +1 -0
  463. package/lib/utils/index.d.ts.map +1 -1
  464. package/lib/utils/index.js +1 -0
  465. package/lib/utils/renderTier.d.ts +26 -0
  466. package/lib/utils/renderTier.d.ts.map +1 -0
  467. package/lib/utils/renderTier.js +34 -0
  468. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- import type { Project } from "../../schemas/project.schema";
1
+ import type { Clip, Project } from "../../schemas/project.schema";
2
+ import type { RegenComponent } from "../credits/pricing";
2
3
  /**
3
4
  * planMutations — Stage 7-prep helper for the agent permission flow.
4
5
  *
@@ -43,4 +44,56 @@ export declare function findClipsNeedingPermission(currentProject: Project | nul
43
44
  * straight through.
44
45
  */
45
46
  export declare function requiresUserConfirmation(currentProject: Project | null | undefined): boolean;
47
+ /**
48
+ * Stage 7 (lock enforcement) — the clips from `currentProject` that a
49
+ * regeneration must NOT overwrite: every protected clip (locked or
50
+ * user-placed) whose id the user did NOT explicitly approve to mutate.
51
+ *
52
+ * `allowedMutations` is the set of clip ids the user OK'd in the
53
+ * confirmation modal (echoed back through /execute-confirmed → the run
54
+ * doc → the job payload). A protected clip absent from that set is frozen:
55
+ * planToProject reuses it verbatim instead of rebuilding it from
56
+ * plan+outcome, because the user's edits (trim, volume, text, position)
57
+ * live only on the clip object — they're nowhere in the plan, so a rebuild
58
+ * would silently discard them.
59
+ *
60
+ * Returns `[]` when there's no prior project (first run on an empty canvas)
61
+ * or nothing is protected — the common path, a clean no-op.
62
+ */
63
+ export declare function computePreservedClips(currentProject: Project | null | undefined, allowedMutations?: readonly string[]): Clip[];
64
+ /** Per-scene sets of asset kinds whose generation can be skipped on regen. */
65
+ export interface FrozenScenes {
66
+ /** Scene indices whose visual clip(s) are preserved — skip provider gen. */
67
+ visual: Set<number>;
68
+ /** Scene indices whose voiceover clip is preserved — skip TTS. */
69
+ voiceover: Set<number>;
70
+ }
71
+ /**
72
+ * Gap #1 follow-up (skip-generation) — derive, from the preserved clips, which
73
+ * scenes don't need their assets regenerated at all. A preserved visual means
74
+ * the user froze that scene's footage, so re-running the (expensive) provider
75
+ * gen just to discard the result is pure waste; same for a preserved VO and
76
+ * the TTS call. The executor consults these sets to short-circuit the tool
77
+ * dispatch, and planToProject uses `visual` to skip building a placeholder twin
78
+ * (the real preserved clip is injected verbatim instead).
79
+ *
80
+ * Keyed off the deterministic clip-id contract so it stays in lockstep with the
81
+ * ids planToProject emits (and the ids the preserve-override matches on).
82
+ */
83
+ /**
84
+ * Gap #5 (diff-based bulk regen, lock-safety) — true if a regen target would
85
+ * overwrite a frozen (locked / user-edited) scene asset, so callers can drop it
86
+ * before charging or executing. The bulk diff (`diffPlans`) is plan-field based
87
+ * and lock-blind: a re-plan that rewrote a locked scene's prompt would emit a
88
+ * `visual` target for it, and running that would clobber the footage the user
89
+ * deliberately froze in the editor. Visual targets are gated by `frozen.visual`;
90
+ * voiceover AND captions by `frozen.voiceover` (captions are derived from the VO
91
+ * audio, so a locked VO keeps its captions too). Overlays/music aren't tracked
92
+ * by the frozen-scene model (they're separate clips), so they pass through.
93
+ */
94
+ export declare function isRegenTargetFrozen(target: {
95
+ component: RegenComponent;
96
+ sceneIndex?: number;
97
+ }, frozen: FrozenScenes): boolean;
98
+ export declare function computeFrozenScenes(preserveClips: readonly Clip[]): FrozenScenes;
46
99
  //# sourceMappingURL=planMutations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"planMutations.d.ts","sourceRoot":"","sources":["../../../src/services/agent/planMutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAGlE;;;;;;;;;;;;;;;;GAgBG;AAEH,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAG7D,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5E,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAyDD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACzC,gBAAgB,EAAE,CAgBpB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACzC,OAAO,CAET"}
1
+ {"version":3,"file":"planMutations.d.ts","sourceRoot":"","sources":["../../../src/services/agent/planMutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;;;;;;;;;;;;;;;GAgBG;AAEH,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAG7D,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IAC5E,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,MAAM,EAAE,cAAc,CAAC;IACvB,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAyDD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACzC,gBAAgB,EAAE,CAgBpB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACzC,OAAO,CAET;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAC1C,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,GACnC,IAAI,EAAE,CAMR;AAQD,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACpB,kEAAkE;IAClE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAC1D,MAAM,EAAE,YAAY,GACnB,OAAO,CAOT;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,SAAS,IAAI,EAAE,GAAG,YAAY,CAahF"}
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.USER_PLACED_PROVENANCE_SOURCES = void 0;
4
4
  exports.findClipsNeedingPermission = findClipsNeedingPermission;
5
5
  exports.requiresUserConfirmation = requiresUserConfirmation;
6
+ exports.computePreservedClips = computePreservedClips;
7
+ exports.isRegenTargetFrozen = isRegenTargetFrozen;
8
+ exports.computeFrozenScenes = computeFrozenScenes;
6
9
  const planToProject_1 = require("../editor/planToProject");
7
10
  /**
8
11
  * planMutations — Stage 7-prep helper for the agent permission flow.
@@ -118,3 +121,78 @@ function findClipsNeedingPermission(currentProject) {
118
121
  function requiresUserConfirmation(currentProject) {
119
122
  return findClipsNeedingPermission(currentProject).length > 0;
120
123
  }
124
+ /**
125
+ * Stage 7 (lock enforcement) — the clips from `currentProject` that a
126
+ * regeneration must NOT overwrite: every protected clip (locked or
127
+ * user-placed) whose id the user did NOT explicitly approve to mutate.
128
+ *
129
+ * `allowedMutations` is the set of clip ids the user OK'd in the
130
+ * confirmation modal (echoed back through /execute-confirmed → the run
131
+ * doc → the job payload). A protected clip absent from that set is frozen:
132
+ * planToProject reuses it verbatim instead of rebuilding it from
133
+ * plan+outcome, because the user's edits (trim, volume, text, position)
134
+ * live only on the clip object — they're nowhere in the plan, so a rebuild
135
+ * would silently discard them.
136
+ *
137
+ * Returns `[]` when there's no prior project (first run on an empty canvas)
138
+ * or nothing is protected — the common path, a clean no-op.
139
+ */
140
+ function computePreservedClips(currentProject, allowedMutations) {
141
+ if (!currentProject)
142
+ return [];
143
+ const approved = new Set(allowedMutations ?? []);
144
+ return currentProject.clips.filter((clip) => isProtected(clip) !== null && !approved.has(clip.id));
145
+ }
146
+ // Deterministic clip-id shapes emitted by planToProject. A frozen visual can
147
+ // be a single clip (`scene-3-visual`) or an extend-chain (`scene-3-visual-0`,
148
+ // `-1`, …); both map back to the same scene. VO is always a single clip.
149
+ const VISUAL_CLIP_ID_RE = /^scene-(\d+)-visual(?:-\d+)?$/;
150
+ const VOICEOVER_CLIP_ID_RE = /^scene-(\d+)-vo$/;
151
+ /**
152
+ * Gap #1 follow-up (skip-generation) — derive, from the preserved clips, which
153
+ * scenes don't need their assets regenerated at all. A preserved visual means
154
+ * the user froze that scene's footage, so re-running the (expensive) provider
155
+ * gen just to discard the result is pure waste; same for a preserved VO and
156
+ * the TTS call. The executor consults these sets to short-circuit the tool
157
+ * dispatch, and planToProject uses `visual` to skip building a placeholder twin
158
+ * (the real preserved clip is injected verbatim instead).
159
+ *
160
+ * Keyed off the deterministic clip-id contract so it stays in lockstep with the
161
+ * ids planToProject emits (and the ids the preserve-override matches on).
162
+ */
163
+ /**
164
+ * Gap #5 (diff-based bulk regen, lock-safety) — true if a regen target would
165
+ * overwrite a frozen (locked / user-edited) scene asset, so callers can drop it
166
+ * before charging or executing. The bulk diff (`diffPlans`) is plan-field based
167
+ * and lock-blind: a re-plan that rewrote a locked scene's prompt would emit a
168
+ * `visual` target for it, and running that would clobber the footage the user
169
+ * deliberately froze in the editor. Visual targets are gated by `frozen.visual`;
170
+ * voiceover AND captions by `frozen.voiceover` (captions are derived from the VO
171
+ * audio, so a locked VO keeps its captions too). Overlays/music aren't tracked
172
+ * by the frozen-scene model (they're separate clips), so they pass through.
173
+ */
174
+ function isRegenTargetFrozen(target, frozen) {
175
+ if (typeof target.sceneIndex !== "number")
176
+ return false;
177
+ if (target.component === "visual")
178
+ return frozen.visual.has(target.sceneIndex);
179
+ if (target.component === "voiceover" || target.component === "captions") {
180
+ return frozen.voiceover.has(target.sceneIndex);
181
+ }
182
+ return false;
183
+ }
184
+ function computeFrozenScenes(preserveClips) {
185
+ const visual = new Set();
186
+ const voiceover = new Set();
187
+ for (const clip of preserveClips) {
188
+ const v = VISUAL_CLIP_ID_RE.exec(clip.id);
189
+ if (v) {
190
+ visual.add(Number(v[1]));
191
+ continue;
192
+ }
193
+ const vo = VOICEOVER_CLIP_ID_RE.exec(clip.id);
194
+ if (vo)
195
+ voiceover.add(Number(vo[1]));
196
+ }
197
+ return { visual, voiceover };
198
+ }
@@ -86,22 +86,5 @@ export declare class Planner {
86
86
  /** Free-form caller hint, e.g. "punchier CTA" or "drop the watermark". */
87
87
  instruction?: string;
88
88
  }): Promise<TextOverlay[]>;
89
- private buildMessages;
90
89
  }
91
- /**
92
- * Heuristic — does the brief mention real-world entities that benefit from
93
- * web grounding? A planner without research will happily invent fake app
94
- * names, fabricate statistics, and miss real-world brand details. Triggers
95
- * when the brief contains:
96
- * - explicit "top N / best / popular / list of" framings
97
- * - proper-noun-heavy briefs (≥2 capitalized non-sentence-start words)
98
- * - listicle/comparison/news/review keywords
99
- * - explicit time markers ("2026", "latest", "this year", "recent")
100
- * - statistics signals ("statistics", "data", "percent", "study")
101
- *
102
- * Deliberately conservative — false negatives are fine (we just skip the
103
- * search), false positives waste $0.01 per planner call. Override via
104
- * `useWebResearch: true|false` when the caller knows better.
105
- */
106
- export declare function briefNeedsWebResearch(brief: VideoBrief): boolean;
107
90
  //# sourceMappingURL=Planner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Planner.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/planner/Planner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EAEX,SAAS,EAEV,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAwB7C;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,SAAS,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAEP,IAAI,EAAE,cAAc;IAK3C,IAAI,CACR,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;QACvC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAChC;;;;;;WAMG;QACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC9B,GACL,OAAO,CAAC,SAAS,CAAC;IAmOrB;;;;;;;;;;;OAWG;IACH,UAAU,CACR,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;QACvC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;KAC5B,GACL;QAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;KAAE;IAqDhE;;;;;;;;;;;;;;;;OAgBG;IACG,0BAA0B,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAChC,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,0EAA0E;QAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;KACjB,GACL,OAAO,CAAC,WAAW,EAAE,CAAC;IA0IzB,OAAO,CAAC,aAAa;CAuItB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAiChE"}
1
+ {"version":3,"file":"Planner.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/planner/Planner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAoB,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,SAAS,EAEV,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkB7C;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,SAAS,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,OAAO;IAIN,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAEP,IAAI,EAAE,cAAc;IAK3C,IAAI,CACR,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;QACvC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAChC;;;;;;WAMG;QACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC9B,GACL,OAAO,CAAC,SAAS,CAAC;IAyQrB;;;;;;;;;;;OAWG;IACH,UAAU,CACR,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,WAAW,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;QACvC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;KAC5B,GACL;QAAE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;KAAE;IAqEhE;;;;;;;;;;;;;;;;OAgBG;IACG,0BAA0B,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,UAAU,EACjB,IAAI,GAAE;QACJ,OAAO,CAAC,EAAE,YAAY,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;QACjC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAChC,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,0EAA0E;QAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;KACjB,GACL,OAAO,CAAC,WAAW,EAAE,CAAC;CAQ1B"}
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Planner = void 0;
4
- exports.briefNeedsWebResearch = briefNeedsWebResearch;
5
- const zod_1 = require("zod");
4
+ const brief_schema_1 = require("../../../schemas/brief.schema");
6
5
  const videoPlan_schema_1 = require("../../../schemas/videoPlan.schema");
7
6
  const llmCallerAnthropic_1 = require("../llmCallerAnthropic");
8
7
  const llmCallerRegistry_1 = require("../llmCallerRegistry");
9
8
  const modelRouter_1 = require("../modelRouter");
10
- const personas_1 = require("../personas");
11
- const modelQualityNotes_1 = require("../modelQualityNotes");
12
- const promptSections_1 = require("./promptSections");
13
- const structuralRules_1 = require("./structuralRules");
9
+ const scriptFirstPlanner_1 = require("./scriptFirstPlanner");
14
10
  const repair_1 = require("./repair");
15
11
  const overlaySanity_1 = require("./overlaySanity");
16
12
  const costPreflight_1 = require("../costPreflight");
17
13
  const validators_1 = require("./validators");
14
+ const plannerMessages_1 = require("./plannerMessages");
15
+ const overlayRegen_1 = require("./overlayRegen");
18
16
  class Planner {
19
17
  constructor(opts) {
20
18
  this.opts = opts;
@@ -22,16 +20,27 @@ class Planner {
22
20
  this.maxRetries = opts.maxRetries ?? 2;
23
21
  }
24
22
  async plan(brief, opts = {}) {
23
+ // Stream L (L-3): long-form (L1/L2) uses script-first authoring (full
24
+ // narration → chapters → B-roll scenes) rather than the single-call
25
+ // scene-first planner below, which drifts on multi-minute videos. The
26
+ // assembled plan satisfies the L-2 chapter contract by construction.
27
+ const lengthTier = brief.lengthTier ?? (0, brief_schema_1.deriveLengthTier)(brief.durationSec);
28
+ if (lengthTier === "L1" || lengthTier === "L2") {
29
+ return (0, scriptFirstPlanner_1.planScriptFirst)({ llm: this.opts.llm }, brief, {
30
+ persona: opts.persona,
31
+ bible: opts.bible ?? null,
32
+ });
33
+ }
25
34
  const model = this.router.pickFor("planner", {
26
35
  premium: brief.tierBudget === "T3",
27
36
  });
28
37
  const fallbackModel = this.router.fallbackFor("planner");
29
38
  // Resolve research flag. We only use research when the Anthropic caller
30
39
  // is wired AND the brief implies real-world subjects — otherwise the
31
- // gateway path (provider-portable) is preferred.
40
+ // normal dispatcher path (no server-side web_search) is used.
32
41
  const anthropic = (0, llmCallerRegistry_1.getAnthropicCaller)();
33
42
  const wantsResearch = opts.useWebResearch === true ||
34
- (opts.useWebResearch !== false && briefNeedsWebResearch(brief));
43
+ (opts.useWebResearch !== false && (0, plannerMessages_1.briefNeedsWebResearch)(brief));
35
44
  let useResearchCall = wantsResearch &&
36
45
  anthropic !== null &&
37
46
  typeof anthropic.structuredWithTools === "function" &&
@@ -45,7 +54,7 @@ class Planner {
45
54
  const thinkingBudget = premium ? 4096 : undefined;
46
55
  let lastErrors;
47
56
  for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
48
- const messages = this.buildMessages(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null, lastErrors, useResearchCall);
57
+ const messages = (0, plannerMessages_1.buildPlannerMessages)(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null, lastErrors, useResearchCall);
49
58
  let result;
50
59
  try {
51
60
  if (useResearchCall && anthropic?.structuredWithTools) {
@@ -54,9 +63,10 @@ class Planner {
54
63
  // - `cachePrompt`: 90% discount on cache hits — every retry within
55
64
  // 5 minutes pays ~10% of the system + tools tokens.
56
65
  // - `thinking`: enabled on T3 premium briefs only.
57
- // - Transient Anthropic errors fall through to the gateway path
58
- // below via the catch — better to ship a non-researched plan
59
- // than to 500 the whole /plan endpoint on an outage.
66
+ // - Transient Anthropic errors fall through to the non-research
67
+ // dispatcher path below via the catch — better to ship a
68
+ // non-researched plan than to 500 the whole /plan endpoint on an
69
+ // outage.
60
70
  try {
61
71
  result = await anthropic.structuredWithTools({
62
72
  model,
@@ -77,7 +87,7 @@ class Planner {
77
87
  // subsequent attempts. The plan we produce won't be grounded,
78
88
  // but it'll exist — and the warning flag tells the UI.
79
89
  useResearchCall = false;
80
- const fallbackMessages = this.buildMessages(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null, lastErrors, false);
90
+ const fallbackMessages = (0, plannerMessages_1.buildPlannerMessages)(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null, lastErrors, false);
81
91
  result = await this.opts.llm.structured({
82
92
  model,
83
93
  fallbackModel,
@@ -104,8 +114,8 @@ class Planner {
104
114
  }
105
115
  }
106
116
  catch (e) {
107
- // AG-25: the gateway throws on schema-validation failures. Without this
108
- // catch the planner's correction-retry loop never fires — a single
117
+ // AG-25: the LlmCaller throws on schema-validation failures. Without
118
+ // this catch the planner's correction-retry loop never fires — a single
109
119
  // sub-1ms scene duration from the LLM would crash the whole agent.
110
120
  // Capture the error as correction context and let the loop retry.
111
121
  const msg = e instanceof Error ? e.message : String(e);
@@ -183,6 +193,31 @@ class Planner {
183
193
  lastErrors = narrationGap;
184
194
  continue;
185
195
  }
196
+ // Stream L (L-2): chapter contract for L1/L2 long-form plans — chapters
197
+ // MUST partition the scene list exactly. Downgrade-on-last-attempt
198
+ // (like ttsGap): chapters aren't render-breaking (the schema field is
199
+ // optional and the render path ignores it for now), so ship without
200
+ // them rather than throw away an otherwise-valid long-form plan.
201
+ const chapterGap = (0, validators_1.checkChapterContract)(reparsed.data, brief);
202
+ if (chapterGap && attempt < this.maxRetries) {
203
+ lastErrors = chapterGap;
204
+ continue;
205
+ }
206
+ // Stream L (L-6): hard spend cap. If brief.maxSpendUSD is set and the
207
+ // plan's estimated generation cost is over it, re-prompt for cheaper
208
+ // tiers / stock / fewer scenes. Hard-reject (no downgrade) — shipping
209
+ // an over-budget plan would spend past the user's explicit cap.
210
+ const budgetGap = (0, validators_1.checkBudgetContract)(reparsed.data, brief);
211
+ if (budgetGap) {
212
+ lastErrors = budgetGap;
213
+ continue;
214
+ }
215
+ // Stream L (L-1): stamp the effective length tier so downstream
216
+ // consumers (cost guardrails L-6, editor chapter UI) don't re-derive
217
+ // it. Trust brief.lengthTier when set; otherwise derive from duration.
218
+ // Don't trust the LLM to fill it — overlay deterministically.
219
+ reparsed.data.lengthTier =
220
+ brief.lengthTier ?? (0, brief_schema_1.deriveLengthTier)(brief.durationSec);
186
221
  // Persist the bible on the plan so downstream (executor / AG-13)
187
222
  // has it without a second read. Planner doesn't author the bible.
188
223
  if (opts.bible)
@@ -239,10 +274,25 @@ class Planner {
239
274
  * who already painted partial JSON for the first attempt.
240
275
  */
241
276
  planStream(brief, opts = {}) {
277
+ // Stream L (L-3): long-form is a multi-pass pipeline (script → chapters →
278
+ // scenes) that can't stream a single structured payload cleanly. Run the
279
+ // non-streaming script-first path and emit the finished plan as one chunk,
280
+ // mirroring the no-structuredStream fallback below.
281
+ const lengthTier = brief.lengthTier ?? (0, brief_schema_1.deriveLengthTier)(brief.durationSec);
282
+ if (lengthTier === "L1" || lengthTier === "L2") {
283
+ const result = this.plan(brief, opts);
284
+ const tokens = {
285
+ async *[Symbol.asyncIterator]() {
286
+ const plan = await result;
287
+ yield JSON.stringify(plan);
288
+ },
289
+ };
290
+ return { tokens, result };
291
+ }
242
292
  const model = this.router.pickFor("planner", {
243
293
  premium: brief.tierBudget === "T3",
244
294
  });
245
- const messages = this.buildMessages(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null);
295
+ const messages = (0, plannerMessages_1.buildPlannerMessages)(brief, opts.persona, opts.brandKit ?? null, opts.styleMemory ?? null, opts.bible ?? null);
246
296
  if (!this.opts.llm.structuredStream) {
247
297
  // Fallback path — emit the whole plan as one chunk after non-streaming call.
248
298
  const result = this.plan(brief, opts);
@@ -299,293 +349,7 @@ class Planner {
299
349
  * beyond the LLM call.
300
350
  */
301
351
  async regenerateOverlaysForScene(scene, brief, opts = {}) {
302
- const model = this.router.pickFor("planner", {
303
- premium: brief.tierBudget === "T3",
304
- });
305
- const fallbackModel = this.router.fallbackFor("planner");
306
- const FocusedOverlaySchema = zod_1.z.object({
307
- overlays: zod_1.z.array(videoPlan_schema_1.TextOverlaySchema).max(4),
308
- });
309
- const personaPack = opts.persona ? personas_1.PERSONA_PACKS[opts.persona] : null;
310
- const brandKitSection = (0, promptSections_1.buildBrandKitSection)(opts.brandKit ?? null);
311
- const bibleSection = (0, promptSections_1.buildBibleSection)(opts.bible ?? null);
312
- const closingHint = opts.isClosingScene
313
- ? " - This IS the CLOSING scene — you MUST include role='cta' (max 5 words, brand + verb, e.g. 'Get HydraPure Today')."
314
- : " - This is NOT the closing scene — do NOT emit role='cta' (CTA belongs only on the final scene).";
315
- const watermarkHint = scene.sceneIndex === 0
316
- ? " - This IS scene 0 — you MAY include exactly one role='watermark' overlay with persistAcrossScenes:true (max 2 words, brand name)."
317
- : " - This is NOT scene 0 — do NOT emit role='watermark' (watermark is emitted once on scene 0 and auto-carries forward).";
318
- const overlayContract = [
319
- "Emit ONLY this scene's overlays (array of TextOverlay, max 4 entries).",
320
- "Each overlay = { text, role, position?, persistAcrossScenes?, emphasis?, animation?, startMs?, endMs? }.",
321
- "CRITICAL: `text` is the LITERAL on-screen copy users will read — NOT a description of how it should look. Styling (font, color, position, drop-shadow) is applied automatically from the role.",
322
- " GOOD: text:\"Your eyes lie to you\"",
323
- " BAD: text:\"Bold white sans-serif subtitle in the lower third of a 9:16 frame\" (REJECTED as styling description)",
324
- "Roles + word limits:",
325
- " headline — top, big-bold, max 6 words (the hook).",
326
- " subheadline — lower-third, medium, max 8 words.",
327
- " body — lower-third, small, max 14 words (a supporting line of actual copy).",
328
- " cta — bottom pill, bold, max 5 words, MUST combine brand + verb.",
329
- " watermark — bottom-right tiny, max 2 words, just the brand name.",
330
- " disclaimer — tiny bottom legal copy.",
331
- " label — in-frame object/person label, max 3 words.",
332
- "Max 4 overlays per scene. Don't emit two headlines on the same scene.",
333
- "Emojis are OK — the renderer supports color glyphs natively.",
334
- closingHint,
335
- watermarkHint,
336
- ].join("\n");
337
- const personaLine = personaPack
338
- ? `Persona: ${opts.persona} — ${personaPack.plannerPrompt.split("\n")[0]}`
339
- : "";
340
- const system = [
341
- "You are a video-overlay copywriter.",
342
- "Given ONE scene from a VideoPlan, emit a fresh `overlays[]` for that scene.",
343
- "The rest of the plan (other scenes, VO, visuals, music) is fixed — do not comment on it, do not return it.",
344
- "",
345
- overlayContract,
346
- personaLine,
347
- brandKitSection,
348
- bibleSection,
349
- ]
350
- .filter(Boolean)
351
- .join("\n");
352
- const sceneContext = {
353
- sceneIndex: scene.sceneIndex,
354
- intent: scene.intent,
355
- prompt: scene.prompt,
356
- voiceoverLine: scene.voiceoverLine,
357
- onScreenText: scene.onScreenText,
358
- durationMs: scene.durationMs,
359
- currentOverlays: scene.overlays ?? [],
360
- };
361
- const userParts = [
362
- `Brief context:\n${JSON.stringify({
363
- rawPrompt: brief.rawPrompt,
364
- tone: brief.tone,
365
- niche: brief.niche,
366
- }, null, 2)}`,
367
- `Scene:\n${JSON.stringify(sceneContext, null, 2)}`,
368
- ];
369
- if (opts.instruction?.trim()) {
370
- userParts.push(`Caller instruction: ${opts.instruction.trim()}`);
371
- }
372
- else {
373
- userParts.push("No specific instruction — produce a fresh, on-brand overlay set that fits the scene's intent and voiceoverLine.");
374
- }
375
- const user = userParts.join("\n\n");
376
- let lastErrors;
377
- for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
378
- const messages = [
379
- { role: "system", content: system },
380
- {
381
- role: "user",
382
- content: lastErrors
383
- ? `${user}\n\nPrevious attempt failed validation: ${lastErrors}\nFix and try again.`
384
- : user,
385
- },
386
- ];
387
- try {
388
- const result = await this.opts.llm.structured({
389
- model,
390
- fallbackModel,
391
- messages,
392
- schema: FocusedOverlaySchema,
393
- schemaName: "SceneOverlays",
394
- temperature: attempt === 0 ? 0.6 : 0.3,
395
- });
396
- const overlays = result.data.overlays;
397
- // Re-use the same style-leak validator the full-plan path uses by
398
- // wrapping the overlays in a single-scene VideoPlan-shaped object.
399
- // Cheaper than re-implementing the regex set here.
400
- const probe = {
401
- scenes: [{ ...scene, overlays }],
402
- };
403
- const leak = (0, overlaySanity_1.checkOverlayContentSanity)(probe);
404
- if (leak) {
405
- lastErrors = leak;
406
- continue;
407
- }
408
- return overlays;
409
- }
410
- catch (e) {
411
- const msg = e instanceof Error ? e.message : String(e);
412
- if (/schema validation failed|non-JSON|empty response/i.test(msg)) {
413
- lastErrors = `Previous attempt failed validation: ${msg.slice(0, 400)}.`;
414
- continue;
415
- }
416
- throw e;
417
- }
418
- }
419
- throw new Error(`Planner failed to produce valid overlays for scene ${scene.sceneIndex} after ${this.maxRetries + 1} attempts. Last errors: ${lastErrors}`);
420
- }
421
- buildMessages(brief, persona, brandKit, styleMemory, bible, lastErrors, useResearchCall = false) {
422
- const structuralRulesSection = (0, structuralRules_1.buildStructuralRulesSection)(brief);
423
- const personaSection = persona
424
- ? [
425
- "",
426
- `Selected persona: ${persona}.`,
427
- `Set plan.persona to "${persona}" in the output.`,
428
- "Persona-specific structural rules (apply on top of the global tier rules):",
429
- personas_1.PERSONA_PACKS[persona].plannerPrompt,
430
- ].join("\n")
431
- : "";
432
- const brandKitSection = (0, promptSections_1.buildBrandKitSection)(brandKit);
433
- const styleMemorySection = (0, promptSections_1.buildStyleMemorySection)(styleMemory);
434
- const bibleSection = (0, promptSections_1.buildBibleSection)(bible);
435
- const modelCatalogSection = (0, promptSections_1.buildModelCatalogSection)();
436
- const videoStrategySection = (0, promptSections_1.buildVideoStrategySection)(brief.videoStrategy);
437
- // AG-39: warn the planner away from models with known capability gaps for
438
- // dimensions this brief signals it cares about (brand text on product
439
- // labels is the immediate driver). Empty string when nothing rated.
440
- const modelQualitySection = (0, modelQualityNotes_1.renderModelQualityHintsForSystemPrompt)({
441
- needsBrandText: (0, promptSections_1.briefMentionsBrandText)(brief),
442
- needsCharacterContinuity: persona === "ugc-ad" || persona === "talking-head",
443
- needsFastMotion: brief.tone?.toLowerCase()?.includes("energetic") || brief.tone?.toLowerCase()?.includes("action"),
444
- needsCinematic: brief.tone?.toLowerCase()?.includes("cinematic"),
445
- });
446
- const researchSection = useResearchCall
447
- ? [
448
- "",
449
- "RESEARCH MODE — `web_search` is enabled. The brief mentions real-world",
450
- "subjects (products, companies, people, places, events, or statistics).",
451
- "Before planning, run targeted `web_search` calls (max 5) to ground the",
452
- "plan in real facts: real product names, real feature lists, real logos,",
453
- "real statistics, real quotes. Use the results to populate scene prompts,",
454
- "voiceover lines, and overlay copy — NEVER fabricate company names,",
455
- "product specs, or numbers. Cite findings implicitly via accurate copy;",
456
- "do not embed raw URLs in the plan. When done researching, call the",
457
- "`submit_VideoPlan` tool with the final plan.",
458
- "",
459
- ].join("\n")
460
- : "";
461
- const system = [
462
- "You are a video-production planner.",
463
- "Given a VideoBrief, produce a VideoPlan: an ordered list of scenes",
464
- "with per-scene asset strategy, tier, prompt, duration, and voiceover.",
465
- researchSection,
466
- "",
467
- "Tier rules — respect brief.tierBudget as the maximum tier:",
468
- " T0: stock footage / image with Ken-Burns motion.",
469
- " T1: AI-generated still + camera motion.",
470
- " T2: AI image-to-video on key frames only.",
471
- " T3: full text-to-video (most expensive — use sparingly).",
472
- "",
473
- "Stock strategy bias — when budget is T0 and the scene depicts something",
474
- "with natural motion (skies, light, water, traffic, hands at work,",
475
- "animals, machinery, weather, crowds), prefer strategy='stock-video' over",
476
- "'stock-image-ken-burns'. Static images with synthesized zoom feel like",
477
- "a slideshow when chained for >3 cuts; real stock clips give the same",
478
- "T0 cost with genuine motion. Only fall back to stock-image-ken-burns",
479
- "when the subject is inherently still (diagrams, infographics, single",
480
- "objects on a table, frozen moments) OR when the brief explicitly asks",
481
- "for a poster/title-card feel.",
482
- "",
483
- videoStrategySection,
484
- "",
485
- "talking-head-avatar is wired and runs the kling-avatar pipeline (face",
486
- "still + TTS lipsync). Pick it ONLY when the brand kit exposes a",
487
- "presenterFaceUrl — set scene.avatarFaceUrl to that URL on every avatar",
488
- "scene. If no presenter face is available, fall back to ai-image-to-video",
489
- "or stock-video of a presenter instead.",
490
- "",
491
- "user-asset is wired and reuses the requesting user's existing library",
492
- "(their previously generated images / videos / audio) instead of spending",
493
- "credits to make a new asset. Pick user-asset when the brief mentions a",
494
- "recurring brand subject (their product photo, spokesperson, b-roll) —",
495
- "the executor falls back to stock-video if no library match scores high",
496
- "enough, so picking it is safe.",
497
- "",
498
- "Keep total estimated credits as low as possible while honoring the",
499
- "brief. Mix tiers within a single video where it helps cost without",
500
- "harming quality (e.g. T2 hero shot + T0 b-roll between).",
501
- "",
502
- "Smart model routing — set preferredModel per scene from the catalog:",
503
- " - Hero / opening-hook / product-reveal scenes: pick the highest-",
504
- " quality model in the chosen tier (most expensive in that tier).",
505
- " - B-roll / filler / transition scenes: pick the cheapest model in",
506
- " the chosen tier — the audience won't notice the difference and",
507
- " cost drops 3–5x.",
508
- " - When in doubt for a non-hero scene, pick the median-cost model.",
509
- " - preferredModel must match a key from the catalog below; the",
510
- " executor will swap on rate-limit, so picking is best-effort, not",
511
- " a hard contract.",
512
- modelCatalogSection,
513
- modelQualitySection,
514
- // AG-14 fix: persona section moved above structuralRulesSection and
515
- // bibleSection. The bible block has multiple "MUST" rules that were
516
- // crowding out persona.hookStyle when persona was the last item before
517
- // brandKit; on `seed-ugc-skincare` this regressed hookStrength to 0.4
518
- // (planner picked a generic "Wait…" opener instead of the brief's
519
- // problem-statement hook). Order is now: persona (voice + hookStyle) →
520
- // structural rules → bible (entity verbatim re-statement).
521
- personaSection,
522
- structuralRulesSection,
523
- bibleSection,
524
- brandKitSection,
525
- styleMemorySection,
526
- ]
527
- .filter(Boolean)
528
- .join("\n");
529
- const user = [
530
- `Brief:\n${JSON.stringify(brief, null, 2)}`,
531
- lastErrors
532
- ? `\nYour previous attempt failed validation: ${lastErrors}\nFix the structure and try again.`
533
- : "",
534
- ]
535
- .filter(Boolean)
536
- .join("\n");
537
- return [
538
- { role: "system", content: system },
539
- { role: "user", content: user },
540
- ];
352
+ return (0, overlayRegen_1.regenerateOverlaysForScene)({ llm: this.opts.llm, router: this.router, maxRetries: this.maxRetries }, scene, brief, opts);
541
353
  }
542
354
  }
543
355
  exports.Planner = Planner;
544
- /**
545
- * Heuristic — does the brief mention real-world entities that benefit from
546
- * web grounding? A planner without research will happily invent fake app
547
- * names, fabricate statistics, and miss real-world brand details. Triggers
548
- * when the brief contains:
549
- * - explicit "top N / best / popular / list of" framings
550
- * - proper-noun-heavy briefs (≥2 capitalized non-sentence-start words)
551
- * - listicle/comparison/news/review keywords
552
- * - explicit time markers ("2026", "latest", "this year", "recent")
553
- * - statistics signals ("statistics", "data", "percent", "study")
554
- *
555
- * Deliberately conservative — false negatives are fine (we just skip the
556
- * search), false positives waste $0.01 per planner call. Override via
557
- * `useWebResearch: true|false` when the caller knows better.
558
- */
559
- function briefNeedsWebResearch(brief) {
560
- const text = [
561
- brief.rawPrompt ?? "",
562
- brief.tone ?? "",
563
- brief.niche ?? "",
564
- ]
565
- .filter(Boolean)
566
- .join(" ");
567
- if (!text.trim())
568
- return false;
569
- const lower = text.toLowerCase();
570
- const listicleSignals = /\b(top\s+\d+|best\s+\d*\s*\w+|popular|list\s+of|review|comparison|vs\.?|versus|trending|latest|recent|news|breaking|study|statistics?|data|percent|%|million|billion|industry|market|report)\b/;
571
- if (listicleSignals.test(lower))
572
- return true;
573
- const yearMarker = /\b(20\d{2}|this\s+year|last\s+year)\b/;
574
- if (yearMarker.test(lower))
575
- return true;
576
- // Count proper nouns that aren't sentence-starters — heuristic for
577
- // "specific brands / people / places".
578
- const words = text.split(/\s+/);
579
- let properNouns = 0;
580
- for (let i = 0; i < words.length; i++) {
581
- const w = words[i] ?? "";
582
- const prev = i > 0 ? words[i - 1] ?? "" : "";
583
- const isSentenceStart = i === 0 || /[.!?]$/.test(prev);
584
- if (!isSentenceStart && /^[A-Z][a-zA-Z0-9]{2,}/.test(w)) {
585
- properNouns++;
586
- if (properNouns >= 2)
587
- return true;
588
- }
589
- }
590
- return false;
591
- }