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.
- package/lib/globals/aiModels/enums.d.ts +11 -1
- package/lib/globals/aiModels/enums.d.ts.map +1 -1
- package/lib/globals/aiModels/enums.js +24 -1
- package/lib/globals/aiModels/index.d.ts.map +1 -1
- package/lib/globals/aiModels/index.js +2 -0
- package/lib/globals/aiModels/providers/anthropic.d.ts +12 -0
- package/lib/globals/aiModels/providers/anthropic.d.ts.map +1 -0
- package/lib/globals/aiModels/providers/anthropic.js +88 -0
- package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/google.js +115 -10
- package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/openai.js +63 -4
- package/lib/globals/aiModels/tierHelpers.d.ts +12 -0
- package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -1
- package/lib/globals/aiModels/tierHelpers.js +83 -0
- package/lib/globals/aiModels/types.d.ts +19 -0
- package/lib/globals/aiModels/types.d.ts.map +1 -1
- package/lib/globals/types.d.ts +120 -1
- package/lib/globals/types.d.ts.map +1 -1
- package/lib/globals/types.js +135 -1
- package/lib/models/agent.model.d.ts +41 -1
- package/lib/models/agent.model.d.ts.map +1 -1
- package/lib/models/index.d.ts +1 -0
- package/lib/models/index.d.ts.map +1 -1
- package/lib/models/index.js +1 -0
- package/lib/models/social.model.d.ts +180 -0
- package/lib/models/social.model.d.ts.map +1 -0
- package/lib/models/social.model.js +2 -0
- package/lib/models/user.model.d.ts +10 -0
- package/lib/models/user.model.d.ts.map +1 -1
- package/lib/models/video.model.d.ts +6 -0
- package/lib/models/video.model.d.ts.map +1 -1
- package/lib/schemas/brief.schema.d.ts +46 -0
- package/lib/schemas/brief.schema.d.ts.map +1 -1
- package/lib/schemas/brief.schema.js +72 -1
- package/lib/schemas/index.d.ts +1 -0
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +1 -0
- package/lib/schemas/project.schema.d.ts +70 -3
- package/lib/schemas/project.schema.d.ts.map +1 -1
- package/lib/schemas/project.schema.js +12 -0
- package/lib/schemas/social.schema.d.ts +91 -0
- package/lib/schemas/social.schema.d.ts.map +1 -0
- package/lib/schemas/social.schema.js +114 -0
- package/lib/schemas/videoPlan.schema.d.ts +117 -3
- package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
- package/lib/schemas/videoPlan.schema.js +141 -1
- package/lib/services/agent/chatAgent.d.ts +25 -1
- package/lib/services/agent/chatAgent.d.ts.map +1 -1
- package/lib/services/agent/chatAgent.js +145 -9
- package/lib/services/agent/costPreflight.d.ts +11 -1
- package/lib/services/agent/costPreflight.d.ts.map +1 -1
- package/lib/services/agent/costPreflight.js +18 -1
- package/lib/services/agent/covers/coverPlanner.d.ts +41 -0
- package/lib/services/agent/covers/coverPlanner.d.ts.map +1 -0
- package/lib/services/agent/covers/coverPlanner.js +278 -0
- package/lib/services/agent/covers/covers.schema.d.ts +158 -0
- package/lib/services/agent/covers/covers.schema.d.ts.map +1 -0
- package/lib/services/agent/covers/covers.schema.js +166 -0
- package/lib/services/agent/covers/index.d.ts +3 -0
- package/lib/services/agent/covers/index.d.ts.map +1 -0
- package/lib/services/agent/covers/index.js +18 -0
- package/lib/services/agent/critic.d.ts +10 -0
- package/lib/services/agent/critic.d.ts.map +1 -1
- package/lib/services/agent/critic.js +37 -1
- package/lib/services/agent/editClassifier.d.ts +4 -4
- package/lib/services/agent/editClassifier.js +2 -2
- package/lib/services/agent/editExisting/editAssembler.d.ts +78 -0
- package/lib/services/agent/editExisting/editAssembler.d.ts.map +1 -0
- package/lib/services/agent/editExisting/editAssembler.js +172 -0
- package/lib/services/agent/editExisting/editExisting.schema.d.ts +119 -0
- package/lib/services/agent/editExisting/editExisting.schema.d.ts.map +1 -0
- package/lib/services/agent/editExisting/editExisting.schema.js +157 -0
- package/lib/services/agent/editExisting/highlightPicker.d.ts +48 -0
- package/lib/services/agent/editExisting/highlightPicker.d.ts.map +1 -0
- package/lib/services/agent/editExisting/highlightPicker.js +199 -0
- package/lib/services/agent/editExisting/index.d.ts +4 -0
- package/lib/services/agent/editExisting/index.d.ts.map +1 -0
- package/lib/services/agent/editExisting/index.js +19 -0
- package/lib/services/agent/eval/recorder.d.ts +13 -1
- package/lib/services/agent/eval/recorder.d.ts.map +1 -1
- package/lib/services/agent/eval/recorder.js +59 -0
- package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
- package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
- package/lib/services/agent/eval/seedBriefs.js +283 -3
- package/lib/services/agent/eval/types.d.ts +10 -0
- package/lib/services/agent/eval/types.d.ts.map +1 -1
- package/lib/services/agent/executor/core.d.ts +70 -0
- package/lib/services/agent/executor/core.d.ts.map +1 -0
- package/lib/services/agent/executor/core.js +250 -0
- package/lib/services/agent/executor/duration.d.ts +20 -0
- package/lib/services/agent/executor/duration.d.ts.map +1 -0
- package/lib/services/agent/executor/duration.js +46 -0
- package/lib/services/agent/executor/index.d.ts +15 -0
- package/lib/services/agent/executor/index.d.ts.map +1 -0
- package/lib/services/agent/executor/index.js +32 -0
- package/lib/services/agent/executor/types.d.ts +183 -0
- package/lib/services/agent/executor/types.d.ts.map +1 -0
- package/lib/services/agent/executor/types.js +29 -0
- package/lib/services/agent/executor/visual.d.ts +32 -0
- package/lib/services/agent/executor/visual.d.ts.map +1 -0
- package/lib/services/agent/executor/visual.js +400 -0
- package/lib/services/agent/executor/voice.d.ts +17 -0
- package/lib/services/agent/executor/voice.d.ts.map +1 -0
- package/lib/services/agent/executor/voice.js +119 -0
- package/lib/services/agent/extendChain.d.ts +101 -0
- package/lib/services/agent/extendChain.d.ts.map +1 -0
- package/lib/services/agent/extendChain.js +177 -0
- package/lib/services/agent/index.d.ts +11 -1
- package/lib/services/agent/index.d.ts.map +1 -1
- package/lib/services/agent/index.js +11 -1
- package/lib/services/agent/llmCaller.d.ts +7 -8
- package/lib/services/agent/llmCaller.d.ts.map +1 -1
- package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
- package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
- package/lib/services/agent/llmCallerAnthropic.js +135 -60
- package/lib/services/agent/llmCallerFactory.d.ts +34 -0
- package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
- package/lib/services/agent/llmCallerFactory.js +31 -0
- package/lib/services/agent/llmCallerGemini.d.ts +62 -0
- package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
- package/lib/services/agent/llmCallerGemini.js +235 -0
- package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
- package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
- package/lib/services/agent/llmCallerOpenai.js +230 -0
- package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
- package/lib/services/agent/llmCallerRegistry.js +7 -7
- package/lib/services/agent/llmCallerRouting.d.ts +63 -0
- package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
- package/lib/services/agent/llmCallerRouting.js +124 -0
- package/lib/services/agent/llmModelRegistry.d.ts +59 -0
- package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
- package/lib/services/agent/llmModelRegistry.js +168 -0
- package/lib/services/agent/llmRetry.d.ts +57 -0
- package/lib/services/agent/llmRetry.d.ts.map +1 -0
- package/lib/services/agent/llmRetry.js +102 -0
- package/lib/services/agent/modelRouter.d.ts +3 -3
- package/lib/services/agent/modelRouter.d.ts.map +1 -1
- package/lib/services/agent/modelRouter.js +27 -13
- package/lib/services/agent/planMutations.d.ts +54 -1
- package/lib/services/agent/planMutations.d.ts.map +1 -1
- package/lib/services/agent/planMutations.js +78 -0
- package/lib/services/agent/planner/Planner.d.ts +0 -17
- package/lib/services/agent/planner/Planner.d.ts.map +1 -1
- package/lib/services/agent/planner/Planner.js +67 -303
- package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
- package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
- package/lib/services/agent/planner/overlayRegen.js +145 -0
- package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
- package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
- package/lib/services/agent/planner/plannerMessages.js +185 -0
- package/lib/services/agent/planner/promptSections.d.ts +12 -0
- package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
- package/lib/services/agent/planner/promptSections.js +57 -0
- package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
- package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
- package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
- package/lib/services/agent/planner/structuralRules.d.ts +10 -0
- package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
- package/lib/services/agent/planner/structuralRules.js +92 -9
- package/lib/services/agent/planner/validators.d.ts +18 -0
- package/lib/services/agent/planner/validators.d.ts.map +1 -1
- package/lib/services/agent/planner/validators.js +97 -0
- package/lib/services/agent/planner.d.ts +2 -1
- package/lib/services/agent/planner.d.ts.map +1 -1
- package/lib/services/agent/planner.js +5 -1
- package/lib/services/agent/priorProject.d.ts +26 -0
- package/lib/services/agent/priorProject.d.ts.map +1 -0
- package/lib/services/agent/priorProject.js +51 -0
- package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
- package/lib/services/agent/providerFallback/chains.js +27 -15
- package/lib/services/agent/repurpose/index.d.ts +3 -0
- package/lib/services/agent/repurpose/index.d.ts.map +1 -0
- package/lib/services/agent/repurpose/index.js +18 -0
- package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
- package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
- package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
- package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
- package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
- package/lib/services/agent/repurpose/shortsPicker.js +218 -0
- package/lib/services/agent/runHelpers.d.ts +21 -2
- package/lib/services/agent/runHelpers.d.ts.map +1 -1
- package/lib/services/agent/runHelpers.js +71 -2
- package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
- package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/animateImage.tool.js +12 -0
- package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
- package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
- package/lib/services/agent/tools/composeScene.tool.d.ts +65 -2
- package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/estimateCost.tool.d.ts +28 -1
- package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/estimateCost.tool.js +55 -7
- package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
- package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/extendVideo.tool.js +149 -0
- package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
- package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/generateScript.tool.js +123 -0
- package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
- package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/generateVideo.tool.js +20 -1
- package/lib/services/agent/tools/index.d.ts +4 -0
- package/lib/services/agent/tools/index.d.ts.map +1 -1
- package/lib/services/agent/tools/index.js +4 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
- package/lib/services/agent/tools/planVideo.tool.d.ts +57 -1
- package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/planVideo.tool.js +3 -3
- package/lib/services/agent/tools/render.tool.d.ts +22 -1
- package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.js +18 -3
- package/lib/services/aiGen/helpers.d.ts +8 -0
- package/lib/services/aiGen/helpers.d.ts.map +1 -1
- package/lib/services/aiGen/helpers.js +12 -0
- package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
- package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts +25 -1
- package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/google/google.service.js +136 -237
- package/lib/services/aiGen/providers/google/googleApiKeys.d.ts +71 -0
- package/lib/services/aiGen/providers/google/googleApiKeys.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleApiKeys.js +137 -0
- package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
- package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
- package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
- package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
- package/lib/services/aiGen/providers/google/googleKeyPool.d.ts +52 -0
- package/lib/services/aiGen/providers/google/googleKeyPool.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleKeyPool.js +129 -0
- package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
- package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
- package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
- package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
- package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
- package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
- package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/pixverse/pixverse.service.js +7 -1
- package/lib/services/bullmq.service.d.ts +61 -0
- package/lib/services/bullmq.service.d.ts.map +1 -1
- package/lib/services/bullmq.service.js +124 -2
- package/lib/services/crypto/index.d.ts +2 -0
- package/lib/services/crypto/index.d.ts.map +1 -0
- package/lib/services/crypto/index.js +17 -0
- package/lib/services/crypto/tokenVault.d.ts +47 -0
- package/lib/services/crypto/tokenVault.d.ts.map +1 -0
- package/lib/services/crypto/tokenVault.js +179 -0
- package/lib/services/editor/captionStyleHint.d.ts +3 -0
- package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
- package/lib/services/editor/captionStyleHint.js +112 -0
- package/lib/services/editor/planToProject.d.ts +7 -66
- package/lib/services/editor/planToProject.d.ts.map +1 -1
- package/lib/services/editor/planToProject.helpers.d.ts +40 -0
- package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
- package/lib/services/editor/planToProject.helpers.js +177 -0
- package/lib/services/editor/planToProject.js +197 -180
- package/lib/services/editor/planToProject.types.d.ts +94 -0
- package/lib/services/editor/planToProject.types.d.ts.map +1 -0
- package/lib/services/editor/planToProject.types.js +2 -0
- package/lib/services/firestore.service.d.ts +5 -0
- package/lib/services/firestore.service.d.ts.map +1 -1
- package/lib/services/firestore.service.js +13 -0
- package/lib/services/index.d.ts +13 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +13 -0
- package/lib/services/promptEnhancer/index.d.ts +18 -0
- package/lib/services/promptEnhancer/index.d.ts.map +1 -0
- package/lib/services/promptEnhancer/index.js +33 -0
- package/lib/services/promptEnhancer/models.d.ts +54 -0
- package/lib/services/promptEnhancer/models.d.ts.map +1 -0
- package/lib/services/promptEnhancer/models.js +37 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
- package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
- package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/base.js +35 -0
- package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
- package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
- package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
- package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/index.js +33 -0
- package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
- package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
- package/lib/services/promptEnhancer/schema.d.ts +19 -0
- package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
- package/lib/services/promptEnhancer/schema.js +43 -0
- package/lib/services/promptEnhancer/types.d.ts +112 -0
- package/lib/services/promptEnhancer/types.d.ts.map +1 -0
- package/lib/services/promptEnhancer/types.js +2 -0
- package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts +60 -5
- package/lib/services/rateLimiter/distributedRateLimiter.service.d.ts.map +1 -1
- package/lib/services/rateLimiter/distributedRateLimiter.service.js +184 -16
- package/lib/services/socialAI/captionGen.d.ts +81 -0
- package/lib/services/socialAI/captionGen.d.ts.map +1 -0
- package/lib/services/socialAI/captionGen.js +206 -0
- package/lib/services/socialAI/hookScore.d.ts +85 -0
- package/lib/services/socialAI/hookScore.d.ts.map +1 -0
- package/lib/services/socialAI/hookScore.js +170 -0
- package/lib/services/socialAI/index.d.ts +3 -0
- package/lib/services/socialAI/index.d.ts.map +1 -0
- package/lib/services/socialAI/index.js +18 -0
- package/lib/services/socialAccounts/index.d.ts +2 -0
- package/lib/services/socialAccounts/index.d.ts.map +1 -0
- package/lib/services/socialAccounts/index.js +17 -0
- package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
- package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
- package/lib/services/socialAccounts/socialAccountService.js +105 -0
- package/lib/services/socialEngage/factory.d.ts +7 -0
- package/lib/services/socialEngage/factory.d.ts.map +1 -0
- package/lib/services/socialEngage/factory.js +25 -0
- package/lib/services/socialEngage/index.d.ts +6 -0
- package/lib/services/socialEngage/index.d.ts.map +1 -0
- package/lib/services/socialEngage/index.js +21 -0
- package/lib/services/socialEngage/meta.engage.d.ts +17 -0
- package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
- package/lib/services/socialEngage/meta.engage.js +128 -0
- package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
- package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
- package/lib/services/socialEngage/metaWebhook.js +93 -0
- package/lib/services/socialEngage/types.d.ts +72 -0
- package/lib/services/socialEngage/types.d.ts.map +1 -0
- package/lib/services/socialEngage/types.js +10 -0
- package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
- package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
- package/lib/services/socialEngage/youtube.engage.js +87 -0
- package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
- package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
- package/lib/services/socialFormat/aspectGeometry.js +135 -0
- package/lib/services/socialFormat/index.d.ts +2 -0
- package/lib/services/socialFormat/index.d.ts.map +1 -0
- package/lib/services/socialFormat/index.js +19 -0
- package/lib/services/socialInsights/index.d.ts +3 -0
- package/lib/services/socialInsights/index.d.ts.map +1 -0
- package/lib/services/socialInsights/index.js +18 -0
- package/lib/services/socialInsights/recommendations.d.ts +131 -0
- package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
- package/lib/services/socialInsights/recommendations.js +277 -0
- package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
- package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
- package/lib/services/socialInsights/timeBuckets.js +78 -0
- package/lib/services/socialMetrics/factory.d.ts +5 -0
- package/lib/services/socialMetrics/factory.d.ts.map +1 -0
- package/lib/services/socialMetrics/factory.js +24 -0
- package/lib/services/socialMetrics/index.d.ts +6 -0
- package/lib/services/socialMetrics/index.d.ts.map +1 -0
- package/lib/services/socialMetrics/index.js +21 -0
- package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
- package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/meta.metrics.js +137 -0
- package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
- package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
- package/lib/services/socialMetrics/types.d.ts +54 -0
- package/lib/services/socialMetrics/types.d.ts.map +1 -0
- package/lib/services/socialMetrics/types.js +2 -0
- package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
- package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/youtube.metrics.js +43 -0
- package/lib/services/socialOAuth/factory.d.ts +7 -0
- package/lib/services/socialOAuth/factory.d.ts.map +1 -0
- package/lib/services/socialOAuth/factory.js +42 -0
- package/lib/services/socialOAuth/index.d.ts +11 -0
- package/lib/services/socialOAuth/index.d.ts.map +1 -0
- package/lib/services/socialOAuth/index.js +26 -0
- package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
- package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
- package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
- package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/meta.oauth.js +214 -0
- package/lib/services/socialOAuth/oauthState.d.ts +14 -0
- package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
- package/lib/services/socialOAuth/oauthState.js +66 -0
- package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
- package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
- package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/threads.oauth.js +129 -0
- package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
- package/lib/services/socialOAuth/types.d.ts +67 -0
- package/lib/services/socialOAuth/types.d.ts.map +1 -0
- package/lib/services/socialOAuth/types.js +2 -0
- package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
- package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/x.oauth.js +134 -0
- package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/youtube.oauth.js +156 -0
- package/lib/services/socialPublish/factory.d.ts +5 -0
- package/lib/services/socialPublish/factory.d.ts.map +1 -0
- package/lib/services/socialPublish/factory.js +32 -0
- package/lib/services/socialPublish/index.d.ts +10 -0
- package/lib/services/socialPublish/index.d.ts.map +1 -0
- package/lib/services/socialPublish/index.js +25 -0
- package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
- package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/linkedin.publish.js +143 -0
- package/lib/services/socialPublish/meta.publish.d.ts +28 -0
- package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/meta.publish.js +149 -0
- package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
- package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/pinterest.publish.js +130 -0
- package/lib/services/socialPublish/threads.publish.d.ts +12 -0
- package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/threads.publish.js +96 -0
- package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
- package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/tiktok.publish.js +118 -0
- package/lib/services/socialPublish/types.d.ts +47 -0
- package/lib/services/socialPublish/types.d.ts.map +1 -0
- package/lib/services/socialPublish/types.js +2 -0
- package/lib/services/socialPublish/x.publish.d.ts +12 -0
- package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/x.publish.js +147 -0
- package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
- package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/youtube.publish.js +107 -0
- package/lib/services/stock/index.d.ts +2 -0
- package/lib/services/stock/index.d.ts.map +1 -0
- package/lib/services/stock/index.js +17 -0
- package/lib/services/stock/realPersonSafety.d.ts +99 -0
- package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
- package/lib/services/stock/realPersonSafety.js +248 -0
- package/lib/services/translation/index.d.ts +2 -0
- package/lib/services/translation/index.d.ts.map +1 -0
- package/lib/services/translation/index.js +9 -0
- package/lib/services/translation/translation.service.d.ts +50 -0
- package/lib/services/translation/translation.service.d.ts.map +1 -0
- package/lib/services/translation/translation.service.js +211 -0
- package/lib/utils/helpers.d.ts +2 -4
- package/lib/utils/helpers.d.ts.map +1 -1
- package/lib/utils/helpers.js +9 -63
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/renderTier.d.ts +26 -0
- package/lib/utils/renderTier.d.ts.map +1 -0
- package/lib/utils/renderTier.js +34 -0
- package/package.json +1 -1
|
@@ -15,182 +15,93 @@ const logger_1 = require("../../../../utils/logger");
|
|
|
15
15
|
const errors_1 = require("../../../../utils/errors");
|
|
16
16
|
const helpers_2 = require("../../helpers");
|
|
17
17
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
18
|
-
const google_auth_library_1 = require("google-auth-library");
|
|
19
18
|
const fs_1 = require("fs");
|
|
20
19
|
const promises_2 = require("stream/promises");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
"ECONNREFUSED",
|
|
27
|
-
"ETIMEDOUT",
|
|
28
|
-
"ENOTFOUND",
|
|
29
|
-
"EAI_AGAIN",
|
|
30
|
-
"EPIPE",
|
|
31
|
-
"UND_ERR_SOCKET",
|
|
32
|
-
"UND_ERR_CONNECT_TIMEOUT",
|
|
33
|
-
"UND_ERR_HEADERS_TIMEOUT",
|
|
34
|
-
"UND_ERR_BODY_TIMEOUT",
|
|
35
|
-
]);
|
|
36
|
-
// Pick a Veo-compatible image MIME type. Veo accepts image/jpeg, image/png,
|
|
37
|
-
// image/webp. We prefer the upstream Content-Type header (Firebase Storage
|
|
38
|
-
// returns the type set at upload), then fall back to URL extension, then to
|
|
39
|
-
// image/jpeg as a reasonable last resort for phone-camera uploads.
|
|
40
|
-
const VEO_SUPPORTED_IMAGE_MIMES = new Set([
|
|
41
|
-
"image/jpeg",
|
|
42
|
-
"image/png",
|
|
43
|
-
"image/webp",
|
|
44
|
-
]);
|
|
45
|
-
function pickImageMimeType(contentType, url) {
|
|
46
|
-
const normalized = contentType.split(";")[0]?.trim().toLowerCase();
|
|
47
|
-
if (normalized && VEO_SUPPORTED_IMAGE_MIMES.has(normalized)) {
|
|
48
|
-
return normalized;
|
|
49
|
-
}
|
|
50
|
-
// Map common but non-canonical types
|
|
51
|
-
if (normalized === "image/jpg")
|
|
52
|
-
return "image/jpeg";
|
|
53
|
-
// Extension fallback. Strip query string first (Firebase URLs have ?alt=media).
|
|
54
|
-
const pathOnly = url.split("?")[0]?.toLowerCase() ?? "";
|
|
55
|
-
if (pathOnly.endsWith(".png"))
|
|
56
|
-
return "image/png";
|
|
57
|
-
if (pathOnly.endsWith(".webp"))
|
|
58
|
-
return "image/webp";
|
|
59
|
-
if (pathOnly.endsWith(".jpg") || pathOnly.endsWith(".jpeg"))
|
|
60
|
-
return "image/jpeg";
|
|
61
|
-
// Phone uploads default to JPEG far more often than PNG, so it's a safer
|
|
62
|
-
// last-resort than the previous hardcoded "image/png".
|
|
63
|
-
return "image/jpeg";
|
|
64
|
-
}
|
|
65
|
-
function isTransientFetchError(err) {
|
|
66
|
-
if (!err)
|
|
67
|
-
return false;
|
|
68
|
-
// undici wraps low-level errors as `TypeError: fetch failed` with the real
|
|
69
|
-
// reason on `err.cause`. Treat that exact shape as transient.
|
|
70
|
-
if (err.message === "fetch failed")
|
|
71
|
-
return true;
|
|
72
|
-
const code = err.code ?? err.cause?.code;
|
|
73
|
-
return !!code && TRANSIENT_NETWORK_CODES.has(code);
|
|
74
|
-
}
|
|
20
|
+
const googleErrors_1 = require("./googleErrors");
|
|
21
|
+
const googleFetch_1 = require("./googleFetch");
|
|
22
|
+
const googleMusic_1 = require("./googleMusic");
|
|
23
|
+
const googleApiKeys_1 = require("./googleApiKeys");
|
|
24
|
+
const googleKeyPool_1 = require("./googleKeyPool");
|
|
75
25
|
const VEO_3_1_MODELS = new Set([
|
|
76
26
|
aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1,
|
|
77
27
|
aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_FAST,
|
|
78
28
|
aiModels_1.EVideoGenModels.GOOGLE_VEO_3_1_LITE,
|
|
79
29
|
]);
|
|
80
|
-
function inferImageMime(url) {
|
|
81
|
-
const lower = (url.split("?")[0] ?? url).toLowerCase();
|
|
82
|
-
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg"))
|
|
83
|
-
return "image/jpeg";
|
|
84
|
-
if (lower.endsWith(".webp"))
|
|
85
|
-
return "image/webp";
|
|
86
|
-
return "image/png";
|
|
87
|
-
}
|
|
88
|
-
async function fetchAsImage(url) {
|
|
89
|
-
const resp = await fetch(url);
|
|
90
|
-
// fetch() does NOT throw on 4xx/5xx — surface the HTTP error so we don't
|
|
91
|
-
// encode an HTML error page as image bytes (Veo silently rejects them).
|
|
92
|
-
if (!resp.ok) {
|
|
93
|
-
throw new errors_1.UserFacingError(`Input image could not be downloaded (HTTP ${resp.status}). The image URL may have expired or been deleted.`);
|
|
94
|
-
}
|
|
95
|
-
const buf = Buffer.from(await resp.arrayBuffer());
|
|
96
|
-
// 0-byte body slips through resp.ok if the upstream wrote an empty file.
|
|
97
|
-
// Veo treats empty bytes as content-filtered (no error, no video).
|
|
98
|
-
if (buf.length === 0) {
|
|
99
|
-
throw new errors_1.UserFacingError("Input image is empty (0 bytes). Please re-upload the image.");
|
|
100
|
-
}
|
|
101
|
-
// Prefer Content-Type from the response (authoritative — set by Firebase
|
|
102
|
-
// Storage upload metadata) over URL-extension inference. Hardcoded
|
|
103
|
-
// image/png caused Veo to reject JPEG bytes labelled PNG with no detail.
|
|
104
|
-
const respContentType = resp.headers.get("content-type") ?? "";
|
|
105
|
-
return {
|
|
106
|
-
mimeType: pickImageMimeType(respContentType, url),
|
|
107
|
-
imageBytes: buf.toString("base64"),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Maps `@google/genai` `ApiError` failures (whose message is a JSON string)
|
|
112
|
-
* to a `UserFacingError` with a stable code the frontend can translate.
|
|
113
|
-
* Returns null when the error is not a known user-facing case (re-throw as-is).
|
|
114
|
-
*/
|
|
115
|
-
function classifyGoogleApiError(err) {
|
|
116
|
-
const raw = err?.message ?? "";
|
|
117
|
-
try {
|
|
118
|
-
const parsed = JSON.parse(raw);
|
|
119
|
-
const inner = parsed.error ?? parsed;
|
|
120
|
-
const httpCode = inner.code;
|
|
121
|
-
const status = inner.status;
|
|
122
|
-
const msg = inner.message ?? raw;
|
|
123
|
-
if (status === "RESOURCE_EXHAUSTED" || httpCode === 429) {
|
|
124
|
-
return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_RATE_LIMITED);
|
|
125
|
-
}
|
|
126
|
-
// gRPC code 14 = UNAVAILABLE; Veo surfaces "high demand" failures with this.
|
|
127
|
-
if (httpCode === 14 || /high demand/i.test(msg)) {
|
|
128
|
-
return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_HIGH_DEMAND);
|
|
129
|
-
}
|
|
130
|
-
// INVALID_ARGUMENT 400 — narrow match: only the specific "use case is
|
|
131
|
-
// currently not supported" string, which Veo returns when our request
|
|
132
|
-
// structure doesn't match the chosen model variant's capabilities.
|
|
133
|
-
// The pre-call guards above (duration=8 for lastFrame/refs) should
|
|
134
|
-
// prevent the known cases; if we still hit this it's a NEW combo we
|
|
135
|
-
// haven't profiled — surface as CAPABILITY_MISMATCH so the user gets a
|
|
136
|
-
// useful message, AND keep the raw provider text in the error so the
|
|
137
|
-
// next entry in PROD_FIX_LOG can identify which combo broke. Generic
|
|
138
|
-
// 400s (other INVALID_ARGUMENT variants) still surface as `error` so
|
|
139
|
-
// a real platform bug isn't muted.
|
|
140
|
-
if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
|
|
141
|
-
/use case is currently not supported/i.test(msg)) {
|
|
142
|
-
return new errors_1.UserFacingError(msg, errors_1.USER_FACING_ERROR_CODES.CAPABILITY_MISMATCH);
|
|
143
|
-
}
|
|
144
|
-
// Imagen + Nano-Banana surface Responsible-AI filter rejections as
|
|
145
|
-
// INVALID_ARGUMENT 400 with the literal text "filtered out because they
|
|
146
|
-
// violated Google's Responsible AI practices" (and a recommendation to
|
|
147
|
-
// rephrase). This is user content moderation, not a system bug — show the
|
|
148
|
-
// user the rephrase hint and skip the Slack page. Also matches the Veo
|
|
149
|
-
// RAI message ("violated Google's content policies") for the same reason.
|
|
150
|
-
if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
|
|
151
|
-
/(filtered out because they violated|violated Google's (?:Responsible AI|content) (?:practices|policies))/i.test(msg)) {
|
|
152
|
-
return new errors_1.UserFacingError("Your prompt was flagged by Google's safety filters. Please rephrase and try again.", errors_1.USER_FACING_ERROR_CODES.CONTENT_POLICY_VIOLATION);
|
|
153
|
-
}
|
|
154
|
-
// Generic INVALID_ARGUMENT 400 on a provided string field. Veo echoes the
|
|
155
|
-
// offending value back ("The string value `<prompt>` ...") and the only
|
|
156
|
-
// large free-text field we send is the prompt, so attribute this to the
|
|
157
|
-
// prompt: it's either over the model's length limit or otherwise rejected
|
|
158
|
-
// by the validator. Either way it's user input, not a platform bug —
|
|
159
|
-
// surface a typed, actionable, non-retryable error (logged warn, no Slack
|
|
160
|
-
// page) instead of leaking the echoed prompt into the error channel.
|
|
161
|
-
if ((status === "INVALID_ARGUMENT" || httpCode === 400) &&
|
|
162
|
-
/string value/i.test(msg)) {
|
|
163
|
-
const tooLong = /(exceed|too long|maximum length|length limit|\blimit\b)/i.test(msg);
|
|
164
|
-
return tooLong
|
|
165
|
-
? new errors_1.UserFacingError("Your prompt is too long for this model. Please shorten it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_TOO_LONG)
|
|
166
|
-
: new errors_1.UserFacingError("Your prompt was rejected by the model. Please simplify or rephrase it and try again.", errors_1.USER_FACING_ERROR_CODES.PROMPT_INVALID);
|
|
167
|
-
}
|
|
168
|
-
// gRPC code 13 = INTERNAL. Veo returns this for transient backend failures
|
|
169
|
-
// ("Video generation failed due to an internal server issue. Please try
|
|
170
|
-
// again in a few minutes."). It is NOT our bug and NOT moderation — a
|
|
171
|
-
// Google-side flake. Surface as a transient PROVIDER_UNAVAILABLE so the
|
|
172
|
-
// user gets a "try again" message and it logs warn (Loki) instead of
|
|
173
|
-
// paging Slack as a platform error. (Egregiously-blocked content that Veo
|
|
174
|
-
// masks as code 13 also lands here; we can't distinguish it from a real
|
|
175
|
-
// internal flake, and "try again" is an acceptable fallback message.)
|
|
176
|
-
if (httpCode === 13 ||
|
|
177
|
-
status === "INTERNAL" ||
|
|
178
|
-
/internal (server|error)/i.test(msg)) {
|
|
179
|
-
return new errors_1.UserFacingError("Google's video service had a temporary problem. Please try again in a few minutes.", errors_1.USER_FACING_ERROR_CODES.PROVIDER_UNAVAILABLE);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
// Not JSON — fall through to non-JSON checks.
|
|
184
|
-
}
|
|
185
|
-
if (/timeout/i.test(raw) || err?.code === "ECONNABORTED") {
|
|
186
|
-
return new errors_1.UserFacingError(raw, errors_1.USER_FACING_ERROR_CODES.VIDEO_PROVIDER_TIMEOUT);
|
|
187
|
-
}
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
30
|
class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
191
31
|
constructor() {
|
|
192
32
|
super();
|
|
193
33
|
this.ai = new genai_1.GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY });
|
|
34
|
+
this.keyPool = (0, googleKeyPool_1.getGoogleKeyPool)();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Plain text generation via Gemini (`@google/genai` generateContent) for the
|
|
38
|
+
* aiGen text factory (LLM_NATIVE_MIGRATION_PLAN Phase 6). Accepts the same
|
|
39
|
+
* `input` shape as OpenaiService.generateText — a bare prompt string or an
|
|
40
|
+
* OpenAI-style message array (role + string content). System messages fold
|
|
41
|
+
* into Gemini's `systemInstruction`; assistant turns map to the "model" role.
|
|
42
|
+
* `options.responseFormat` of type json_object/json_schema flips on Gemini's
|
|
43
|
+
* native JSON mode (responseMimeType) so callers asking OpenAI for JSON get
|
|
44
|
+
* the same contract here.
|
|
45
|
+
*/
|
|
46
|
+
async generateText(params) {
|
|
47
|
+
const { input, modelKey, options } = params;
|
|
48
|
+
const model = aiModels_1.aiModelConfigs[modelKey];
|
|
49
|
+
const modelId = model?.modelId || "gemini-2.5-flash";
|
|
50
|
+
const { systemInstruction, contents } = this.encodeTextInput(input);
|
|
51
|
+
const wantsJson = options?.responseFormat?.type === "json_object" ||
|
|
52
|
+
options?.responseFormat?.type === "json_schema";
|
|
53
|
+
const temperature = model?.fields?.temperature?.default
|
|
54
|
+
? options?.temperature ?? model.fields.temperature.default
|
|
55
|
+
: undefined;
|
|
56
|
+
const maxOutputTokens = model?.fields?.maxOutputTokens?.default
|
|
57
|
+
? options?.maxOutputTokens ?? model.fields.maxOutputTokens.default
|
|
58
|
+
: undefined;
|
|
59
|
+
const resp = await this.withTransientRetry("generateText", () => this.ai.models.generateContent({
|
|
60
|
+
model: modelId,
|
|
61
|
+
contents,
|
|
62
|
+
config: {
|
|
63
|
+
...(systemInstruction ? { systemInstruction } : {}),
|
|
64
|
+
...(typeof temperature === "number" ? { temperature } : {}),
|
|
65
|
+
...(typeof maxOutputTokens === "number" ? { maxOutputTokens } : {}),
|
|
66
|
+
...(wantsJson ? { responseMimeType: "application/json" } : {}),
|
|
67
|
+
},
|
|
68
|
+
}));
|
|
69
|
+
const text = resp.text?.trim() || "No response";
|
|
70
|
+
return { text };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Map an OpenAI-style `input` (string | {role, content}[]) onto Gemini's
|
|
74
|
+
* shape: merged systemInstruction + Content[] (assistant→"model"). Array
|
|
75
|
+
* `content` (vision parts) is flattened to its text segments — the text
|
|
76
|
+
* factory is text-only; image inputs go through the agent GeminiLlmCaller.
|
|
77
|
+
*/
|
|
78
|
+
encodeTextInput(input) {
|
|
79
|
+
if (typeof input === "string") {
|
|
80
|
+
return { contents: [{ role: "user", parts: [{ text: input }] }] };
|
|
81
|
+
}
|
|
82
|
+
const messages = Array.isArray(input)
|
|
83
|
+
? input
|
|
84
|
+
: [];
|
|
85
|
+
let systemInstruction;
|
|
86
|
+
const contents = [];
|
|
87
|
+
for (const m of messages) {
|
|
88
|
+
const text = typeof m.content === "string"
|
|
89
|
+
? m.content
|
|
90
|
+
: Array.isArray(m.content)
|
|
91
|
+
? m.content
|
|
92
|
+
.map((p) => p?.text ?? "")
|
|
93
|
+
.join("")
|
|
94
|
+
: String(m.content ?? "");
|
|
95
|
+
if (m.role === "system") {
|
|
96
|
+
systemInstruction = systemInstruction
|
|
97
|
+
? `${systemInstruction}\n\n${text}`
|
|
98
|
+
: text;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const role = m.role === "assistant" ? "model" : "user";
|
|
102
|
+
contents.push({ role, parts: [{ text }] });
|
|
103
|
+
}
|
|
104
|
+
return { systemInstruction, contents };
|
|
194
105
|
}
|
|
195
106
|
/**
|
|
196
107
|
* Retries `fn` on transient network errors (undici "fetch failed", ECONNRESET, ETIMEDOUT,
|
|
@@ -205,12 +116,12 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
205
116
|
}
|
|
206
117
|
catch (err) {
|
|
207
118
|
lastErr = err;
|
|
208
|
-
const transient = isTransientFetchError(err);
|
|
119
|
+
const transient = (0, googleFetch_1.isTransientFetchError)(err);
|
|
209
120
|
if (!transient || attempt === GoogleService.MAX_RETRY_ATTEMPTS) {
|
|
210
121
|
// Convert known provider errors (quota, high-demand, timeout) into a
|
|
211
122
|
// typed UserFacingError so the scene processor stores a translatable
|
|
212
123
|
// code instead of the raw provider JSON.
|
|
213
|
-
const userFacing = classifyGoogleApiError(err);
|
|
124
|
+
const userFacing = (0, googleErrors_1.classifyGoogleApiError)(err);
|
|
214
125
|
if (userFacing)
|
|
215
126
|
throw userFacing;
|
|
216
127
|
throw err;
|
|
@@ -256,9 +167,35 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
256
167
|
aspectRatio: params.aspectRatio,
|
|
257
168
|
resolution: params.resolution,
|
|
258
169
|
durationSeconds: params.duration,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
170
|
+
// REMOVED for the Gemini Developer API backend — kept for reference.
|
|
171
|
+
// `seed` is NOT supported by Veo on the Gemini API (Mldev): this client
|
|
172
|
+
// is `new GoogleGenAI({ apiKey })`, whose SDK transformer
|
|
173
|
+
// (generateVideosConfigToMldev) throws *client-side*
|
|
174
|
+
// "seed parameter is not supported in Gemini API" before any request is
|
|
175
|
+
// sent — so it can never reach Google and was failing every job that
|
|
176
|
+
// carried a seed. Like `generateAudio`, it is a Vertex-AI-only field.
|
|
177
|
+
// Restore this line if/when this client switches to Vertex (vertexai:true).
|
|
178
|
+
// ...(params.seed !== undefined ? { seed: params.seed } : {}),
|
|
179
|
+
// personGeneration on the Gemini API Veo backend: "allow_all" is the
|
|
180
|
+
// ONLY supported value for Veo 3.x (and it is also the default).
|
|
181
|
+
// "allow_adult" and "dont_allow" are Veo-2-only legacy values — sending
|
|
182
|
+
// either returns 400 "<value> for personGeneration is currently not
|
|
183
|
+
// supported", which is NOT matched by classifyGoogleApiError and so
|
|
184
|
+
// leaks to logger.error → Slack while failing the job. Since allow_all
|
|
185
|
+
// is the default, forward the param only when it's explicitly allow_all
|
|
186
|
+
// (a no-op that documents intent); drop any other requested value
|
|
187
|
+
// rather than hard-fail. Restoring allow_adult/dont_allow would require
|
|
188
|
+
// a Veo-2 model or an allowlisted Vertex project.
|
|
189
|
+
...(params.personGeneration === "allow_all"
|
|
190
|
+
? { personGeneration: "allow_all" }
|
|
191
|
+
: {}),
|
|
192
|
+
// negativePrompt support is MODEL-SPECIFIC on the Gemini API: veo-3.1 and
|
|
193
|
+
// veo-3.1-fast accept it, veo-3.1-lite returns 400 "negativePrompt isn't
|
|
194
|
+
// supported by this model". Gate on the model config declaring the field
|
|
195
|
+
// (negative_prompt) so we never forward it to a model that rejects it.
|
|
196
|
+
...(params.negativePrompt && (0, helpers_2.modelDeclaresField)(params.modelKey, "negative_prompt")
|
|
197
|
+
? { negativePrompt: params.negativePrompt }
|
|
198
|
+
: {}),
|
|
262
199
|
// REMOVED for the Gemini Developer API backend — kept for reference.
|
|
263
200
|
// `generateAudio` is a Vertex-AI-only config field. This client is
|
|
264
201
|
// constructed with `new GoogleGenAI({ apiKey })` (the Mldev / Gemini
|
|
@@ -278,11 +215,11 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
278
215
|
request.video = { uri: params.inputVideoUrl };
|
|
279
216
|
}
|
|
280
217
|
else if (params.inputImageUrl) {
|
|
281
|
-
request.image = await this.withTransientRetry("input-image fetch", () => fetchAsImage(params.inputImageUrl));
|
|
218
|
+
request.image = await this.withTransientRetry("input-image fetch", () => (0, googleFetch_1.fetchAsImage)(params.inputImageUrl));
|
|
282
219
|
}
|
|
283
220
|
// Last-frame image for first-last-frame interpolation. Mutually exclusive with referenceImages.
|
|
284
221
|
if (params.lastFrameImageUrl) {
|
|
285
|
-
request.config.lastFrame = await this.withTransientRetry("last-frame fetch", () => fetchAsImage(params.lastFrameImageUrl));
|
|
222
|
+
request.config.lastFrame = await this.withTransientRetry("last-frame fetch", () => (0, googleFetch_1.fetchAsImage)(params.lastFrameImageUrl));
|
|
286
223
|
}
|
|
287
224
|
// Reference images (Veo 3.1 only — up to 3 asset images for character/scene consistency).
|
|
288
225
|
// When references are provided the API requires durationSeconds=8 and forbids image/video/lastFrame.
|
|
@@ -292,23 +229,36 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
292
229
|
}
|
|
293
230
|
else {
|
|
294
231
|
const refs = params.referenceImageUrls.slice(0, 3);
|
|
295
|
-
const fetched = await Promise.all(refs.map((url) => this.withTransientRetry("reference-image fetch", () => fetchAsImage(url))));
|
|
232
|
+
const fetched = await Promise.all(refs.map((url) => this.withTransientRetry("reference-image fetch", () => (0, googleFetch_1.fetchAsImage)(url))));
|
|
296
233
|
request.config.referenceImages = fetched.map((image) => ({
|
|
297
234
|
image,
|
|
298
235
|
referenceType: genai_1.VideoGenerationReferenceType.ASSET,
|
|
299
236
|
}));
|
|
300
237
|
}
|
|
301
238
|
}
|
|
302
|
-
|
|
239
|
+
// Route this submit to a key with budget (priority order). The per-key
|
|
240
|
+
// caps are the single-key Tier-2 numbers in the model config; the
|
|
241
|
+
// model-level limiter already gated the aggregate (per-key × key count).
|
|
242
|
+
const keyEntry = await this.keyPool.pickForSubmit(modelId, modelConfig.requestPerMin ?? 0, modelConfig.requestPerDay ?? 0);
|
|
243
|
+
const operation = await this.withTransientRetry("generateVideos", () => keyEntry.client.models.generateVideos(request));
|
|
303
244
|
if (!operation || !operation.name) {
|
|
304
245
|
throw new Error("Failed to initiate video generation task");
|
|
305
246
|
}
|
|
306
|
-
|
|
247
|
+
// Tag the task with the issuing key so poll + download re-select the same
|
|
248
|
+
// (project-scoped) client. Single-key pool → bare name (legacy format).
|
|
249
|
+
return {
|
|
250
|
+
task: (0, googleApiKeys_1.encodeVeoTask)(keyEntry.id, operation.name, this.keyPool.size),
|
|
251
|
+
status: types_1.EVideoSceneStatus.TRIGGERED,
|
|
252
|
+
};
|
|
307
253
|
}
|
|
308
254
|
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
255
|
+
// Re-select the key that submitted this task (Veo operations are
|
|
256
|
+
// project-scoped). Un-tagged / unknown ids fall back to the legacy client.
|
|
257
|
+
const { keyId, operationName } = (0, googleApiKeys_1.decodeVeoTask)(task);
|
|
258
|
+
const client = this.keyPool.clientById(keyId) ?? this.ai;
|
|
309
259
|
const operation = new genai_1.GenerateVideosOperation();
|
|
310
|
-
operation.name =
|
|
311
|
-
const result = await this.withTransientRetry("getVideosOperation", () =>
|
|
260
|
+
operation.name = operationName;
|
|
261
|
+
const result = await this.withTransientRetry("getVideosOperation", () => client.operations.getVideosOperation({ operation }));
|
|
312
262
|
if (result.done) {
|
|
313
263
|
if (result.error) {
|
|
314
264
|
// A long-running operation can finish with an error (e.g. gRPC 13
|
|
@@ -316,7 +266,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
316
266
|
// as thrown API errors so transient INTERNAL and invalid-prompt
|
|
317
267
|
// failures get a typed `{code, message}` (which sceneMonitor demotes to
|
|
318
268
|
// warn) instead of leaking raw gRPC JSON that pages Slack as a bug.
|
|
319
|
-
const classified = classifyGoogleApiError({
|
|
269
|
+
const classified = (0, googleErrors_1.classifyGoogleApiError)({
|
|
320
270
|
message: JSON.stringify(result.error),
|
|
321
271
|
});
|
|
322
272
|
return {
|
|
@@ -396,7 +346,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
396
346
|
// Responsible AI practices") become UserFacingError(CONTENT_POLICY_VIOLATION)
|
|
397
347
|
// instead of leaking as raw provider JSON into the worker's Slack
|
|
398
348
|
// error channel.
|
|
399
|
-
const userFacing = classifyGoogleApiError(err);
|
|
349
|
+
const userFacing = (0, googleErrors_1.classifyGoogleApiError)(err);
|
|
400
350
|
if (userFacing)
|
|
401
351
|
throw userFacing;
|
|
402
352
|
throw err;
|
|
@@ -455,7 +405,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
455
405
|
...(params.inputImageUrls ?? []),
|
|
456
406
|
];
|
|
457
407
|
for (const url of refs) {
|
|
458
|
-
const ref = await fetchAsImage(url);
|
|
408
|
+
const ref = await (0, googleFetch_1.fetchAsImage)(url);
|
|
459
409
|
parts.push({ inlineData: { mimeType: ref.mimeType, data: ref.imageBytes } });
|
|
460
410
|
}
|
|
461
411
|
const resp = await this.ai.models.generateContent({
|
|
@@ -506,64 +456,13 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
506
456
|
*
|
|
507
457
|
* Required env: GCP_PROJECT_ID. Optional: GCP_LOCATION (default us-central1).
|
|
508
458
|
*/
|
|
459
|
+
/**
|
|
460
|
+
* Lyria 2 (Vertex AI) — delegates to the standalone generateGoogleMusic
|
|
461
|
+
* (Vertex predict endpoint via ADC, not the GoogleGenAI client). See
|
|
462
|
+
* ./googleMusic.
|
|
463
|
+
*/
|
|
509
464
|
async generateMusic(params) {
|
|
510
|
-
|
|
511
|
-
const modelId = modelConfig?.modelId ?? "lyria-002";
|
|
512
|
-
const projectId = process.env.GCP_PROJECT_ID;
|
|
513
|
-
if (!projectId) {
|
|
514
|
-
throw new Error("Missing GCP_PROJECT_ID env var (required for Vertex Lyria)");
|
|
515
|
-
}
|
|
516
|
-
const location = process.env.GCP_LOCATION ?? "us-central1";
|
|
517
|
-
const auth = new google_auth_library_1.GoogleAuth({
|
|
518
|
-
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
|
|
519
|
-
});
|
|
520
|
-
const client = await auth.getClient();
|
|
521
|
-
const tokenRes = await client.getAccessToken();
|
|
522
|
-
const token = tokenRes?.token;
|
|
523
|
-
if (!token)
|
|
524
|
-
throw new Error("Failed to obtain GCP access token for Vertex Lyria");
|
|
525
|
-
const url = `https://${location}-aiplatform.googleapis.com/v1/projects/${projectId}` +
|
|
526
|
-
`/locations/${location}/publishers/google/models/${modelId}:predict`;
|
|
527
|
-
const instance = { prompt: params.prompt };
|
|
528
|
-
const parameters = {
|
|
529
|
-
sample_count: 1,
|
|
530
|
-
};
|
|
531
|
-
if (params.negativePrompt) {
|
|
532
|
-
instance.negative_prompt = params.negativePrompt;
|
|
533
|
-
}
|
|
534
|
-
if (params.seed !== undefined) {
|
|
535
|
-
parameters.seed = params.seed;
|
|
536
|
-
}
|
|
537
|
-
const resp = await fetch(url, {
|
|
538
|
-
method: "POST",
|
|
539
|
-
headers: {
|
|
540
|
-
Authorization: `Bearer ${token}`,
|
|
541
|
-
"Content-Type": "application/json",
|
|
542
|
-
},
|
|
543
|
-
body: JSON.stringify({ instances: [instance], parameters }),
|
|
544
|
-
});
|
|
545
|
-
if (!resp.ok) {
|
|
546
|
-
const errText = await resp.text();
|
|
547
|
-
throw new Error(`Vertex Lyria failed (${resp.status}): ${errText}`);
|
|
548
|
-
}
|
|
549
|
-
const data = await resp.json();
|
|
550
|
-
const audioB64 = data?.predictions?.[0]?.bytesBase64Encoded;
|
|
551
|
-
if (!audioB64) {
|
|
552
|
-
throw new Error("Vertex Lyria returned no audio data");
|
|
553
|
-
}
|
|
554
|
-
const buffer = Buffer.from(audioB64, "base64");
|
|
555
|
-
const path = `music/lyria/${params.outputFilename}.wav`;
|
|
556
|
-
const file = (0, firebase_1.getBucket)().file(path);
|
|
557
|
-
await file.save(buffer, { contentType: "audio/wav" });
|
|
558
|
-
const [signed] = await file.getSignedUrl({
|
|
559
|
-
action: "read",
|
|
560
|
-
expires: "03-09-2491",
|
|
561
|
-
});
|
|
562
|
-
return {
|
|
563
|
-
audioUrl: signed,
|
|
564
|
-
mimeType: "audio/wav",
|
|
565
|
-
extension: "wav",
|
|
566
|
-
};
|
|
465
|
+
return (0, googleMusic_1.generateGoogleMusic)(params);
|
|
567
466
|
}
|
|
568
467
|
getCreditUsed({ modelKey, duration = 8, resolution = "720p", multiClip = false, numImages = 1, imageSize }) {
|
|
569
468
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure (SDK-free, Redis-free) helpers for the Google AI Studio API key pool.
|
|
3
|
+
*
|
|
4
|
+
* ── DECISION RECORD (2026-06-15) ────────────────────────────────────────────
|
|
5
|
+
* Problem: Veo on a single Gemini Developer API key is quota-starved — Tier 2
|
|
6
|
+
* is ~4 req/min and ~50/day per Veo model — which serialized bursts of jobs
|
|
7
|
+
* into a multi-hour queue (~370 min observed avg latency).
|
|
8
|
+
*
|
|
9
|
+
* Chosen fix (today): a multi-key pool over TWO Google AI Studio keys that live
|
|
10
|
+
* in SEPARATE GCP projects / billing accounts, so their quotas are independent
|
|
11
|
+
* and ADD UP. Keys are used in PRIORITY order:
|
|
12
|
+
* - key[0] = the NEW key (vidspotai project), currently **Tier 1** (2/min,
|
|
13
|
+
* 10/day per Veo model). Used FIRST, deliberately, to drive usage and
|
|
14
|
+
* promote its billing account up the tier ladder.
|
|
15
|
+
* - key[1] = the CURRENT key, **Tier 2** (4/min, 50/day). Used once key[0]
|
|
16
|
+
* is out of per-minute / per-day budget.
|
|
17
|
+
* Aggregate Veo budget = T1 + T2 = 6/min, 60/day. When BOTH are exhausted, the
|
|
18
|
+
* job-start capacity selector (videoJobProcessor) spills to another provider.
|
|
19
|
+
*
|
|
20
|
+
* When key[1]'s account is billed it moves to Tier 3; bump its tier in
|
|
21
|
+
* GOOGLE_API_KEY_TIERS then (no code change — the ladder below handles it).
|
|
22
|
+
*
|
|
23
|
+
* Vertex AI (DEFERRED, on record for the future): Veo is also available via
|
|
24
|
+
* Vertex, where quota is **per-project** and the current billing account is
|
|
25
|
+
* Tier-2-per-project — so we could create multiple projects under one account
|
|
26
|
+
* to scale further. We are NOT doing Vertex now: the two AI-Studio keys across
|
|
27
|
+
* two billing accounts already cover our needed headroom, and the Vertex path
|
|
28
|
+
* needs a different output flow (GCS `gs://` URIs rather than the Files API)
|
|
29
|
+
* that we'd rather build + test deliberately when the extra capacity is needed.
|
|
30
|
+
*
|
|
31
|
+
* ── CONFIG ──────────────────────────────────────────────────────────────────
|
|
32
|
+
* GOOGLE_API_KEYS — comma-separated keys in PRIORITY order. Falls back
|
|
33
|
+
* to the single legacy GOOGLE_API_KEY when unset.
|
|
34
|
+
* GOOGLE_API_KEY_TIERS — comma-separated tier numbers (1/2/3) aligned to
|
|
35
|
+
* GOOGLE_API_KEYS. Missing/extra entries default to 2.
|
|
36
|
+
* GOOGLE_API_KEY — legacy single key; also the client used to poll
|
|
37
|
+
* tasks submitted before the pool existed (un-tagged).
|
|
38
|
+
*
|
|
39
|
+
* Per-key budget is derived from the model config's Tier-2 baseline
|
|
40
|
+
* (requestPerMin / requestPerDay) scaled by each key's tier (see TIER_FACTORS);
|
|
41
|
+
* the pool gives us the SUM across keys.
|
|
42
|
+
*/
|
|
43
|
+
/** Parse the configured keys in priority order, de-duped, empties removed. */
|
|
44
|
+
export declare function parseGoogleApiKeys(): string[];
|
|
45
|
+
/** Tier per key (aligned to parseGoogleApiKeys order); defaults to 2. */
|
|
46
|
+
export declare function parseGoogleApiKeyTiers(): number[];
|
|
47
|
+
/** Number of configured Google keys (>= 1 so callers can multiply safely). */
|
|
48
|
+
export declare function googleApiKeyCount(): number;
|
|
49
|
+
/** Per-key rate cap for a given Tier-2 baseline and tier. */
|
|
50
|
+
export declare function scaleLimitForTier(baseline: number | undefined, tier: number, kind: "rpm" | "rpd"): number;
|
|
51
|
+
/**
|
|
52
|
+
* Aggregate multiplier across all configured keys, for scaling a Google
|
|
53
|
+
* model's Tier-2 baseline into the pool-wide budget. Returns 1 for a single
|
|
54
|
+
* default key (legacy behavior unchanged).
|
|
55
|
+
*/
|
|
56
|
+
export declare function googleAggregateFactor(kind: "rpm" | "rpd"): number;
|
|
57
|
+
/** Stable id for the key at a given priority index. */
|
|
58
|
+
export declare function googleKeyId(index: number): string;
|
|
59
|
+
/**
|
|
60
|
+
* Tag a Veo operation name with the id of the key that created it, so polling
|
|
61
|
+
* + download can re-select the same project-scoped client. With a single key
|
|
62
|
+
* we return the bare operation name (no tag) — byte-for-byte the legacy format,
|
|
63
|
+
* so nothing changes until a real pool is configured.
|
|
64
|
+
*/
|
|
65
|
+
export declare function encodeVeoTask(keyId: string, operationName: string, poolSize: number): string;
|
|
66
|
+
/** Reverse of encodeVeoTask. `keyId` is undefined for legacy/un-tagged tasks. */
|
|
67
|
+
export declare function decodeVeoTask(task: string): {
|
|
68
|
+
keyId?: string;
|
|
69
|
+
operationName: string;
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=googleApiKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"googleApiKeys.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/google/googleApiKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAoBH,8EAA8E;AAC9E,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAa7C;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CAUjD;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,GAAG,KAAK,GAClB,MAAM,CAGR;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAIjE;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAID;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5F;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAIrF"}
|