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
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ChatRequest, ChatResponse, LlmCaller, StructuredRequest, StructuredResponse, StructuredWithToolsRequest } from "./llmCaller";
|
|
3
|
+
import { TransientLlmError, isTransientLlmError } from "./llmRetry";
|
|
4
|
+
export { TransientLlmError, isTransientLlmError };
|
|
3
5
|
/**
|
|
4
|
-
* Direct Anthropic SDK LlmCaller
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Direct Anthropic SDK LlmCaller — the `anthropic` slice of the native
|
|
7
|
+
* ProviderRoutingLlmCaller (LLM_NATIVE_MIGRATION_PLAN). Serves all anthropic
|
|
8
|
+
* models the router picks (router / planner / executor) and is the only caller
|
|
9
|
+
* that implements `structuredWithTools`, because Anthropic's server-side tools
|
|
10
|
+
* (`web_search_20260209`, `web_fetch`, etc.) are Anthropic-only constructs the
|
|
11
|
+
* API executes server-side — no other provider exposes them.
|
|
8
12
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* citations) without a translation layer.
|
|
13
|
-
*
|
|
14
|
-
* Use the gateway caller when:
|
|
15
|
-
* - You want provider portability (GPT-5 / Gemini fallback chains).
|
|
16
|
-
* - You don't need built-in tools.
|
|
17
|
-
*
|
|
18
|
-
* The Planner reads from `getAnthropicCaller()` only when `useWebResearch`
|
|
19
|
-
* is set; otherwise it stays on the gateway path.
|
|
13
|
+
* The Planner also reads this directly via `getAnthropicCaller()` when
|
|
14
|
+
* `useWebResearch` is set (server-side `web_search` grounding); otherwise it
|
|
15
|
+
* goes through the normal dispatcher, which already routes anthropic natively.
|
|
20
16
|
*
|
|
21
17
|
* Implemented features:
|
|
22
18
|
* - Prompt caching (`cachePrompt: true`): `cache_control: ephemeral` on
|
|
@@ -25,8 +21,10 @@ import { ChatRequest, ChatResponse, LlmCaller, StructuredRequest, StructuredResp
|
|
|
25
21
|
* - Extended thinking (`thinking.budgetTokens`): enables Claude's
|
|
26
22
|
* interleaved reasoning blocks for T3 / complex briefs. Forces
|
|
27
23
|
* temperature=1 and threads `thinking` blocks through the tool-use loop.
|
|
28
|
-
* -
|
|
29
|
-
*
|
|
24
|
+
* - Native incremental streaming (`structuredStream`): forces the
|
|
25
|
+
* `submit_<schema>` tool and streams its `input_json_delta` partials.
|
|
26
|
+
* - Transient errors propagate as `TransientLlmError` so the dispatcher can
|
|
27
|
+
* run the cross-provider `fallbackModel` on Anthropic outages.
|
|
30
28
|
*
|
|
31
29
|
* Deferred work (v2):
|
|
32
30
|
* - Custom client-side tools (Tavily / image search): extend the loop
|
|
@@ -46,15 +44,6 @@ export interface AnthropicCallerConfig {
|
|
|
46
44
|
/** Max retries on transient errors per call. Default 3. */
|
|
47
45
|
maxRetries?: number;
|
|
48
46
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Marks an error worth retrying on the gateway path. The Planner catches
|
|
51
|
-
* this specifically to degrade gracefully — drops research, keeps planning.
|
|
52
|
-
*/
|
|
53
|
-
export declare class TransientLlmError extends Error {
|
|
54
|
-
readonly cause?: unknown | undefined;
|
|
55
|
-
constructor(message: string, cause?: unknown | undefined);
|
|
56
|
-
}
|
|
57
|
-
export declare function isTransientLlmError(err: unknown): err is TransientLlmError;
|
|
58
47
|
export declare class AnthropicLlmCaller implements LlmCaller {
|
|
59
48
|
private readonly client;
|
|
60
49
|
private readonly timeoutMs;
|
|
@@ -63,6 +52,26 @@ export declare class AnthropicLlmCaller implements LlmCaller {
|
|
|
63
52
|
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
64
53
|
structured<T extends z.ZodTypeAny>(req: StructuredRequest<T>): Promise<StructuredResponse<T>>;
|
|
65
54
|
structuredWithTools<T extends z.ZodTypeAny>(req: StructuredWithToolsRequest<T>): Promise<StructuredResponse<T>>;
|
|
55
|
+
/**
|
|
56
|
+
* Native incremental streaming structured output. Forces the
|
|
57
|
+
* `submit_<schemaName>` tool and streams its argument JSON as
|
|
58
|
+
* `input_json_delta` chunks — yielding each partial for token-by-token UI —
|
|
59
|
+
* then takes the authoritative payload from `stream.finalMessage()` (more
|
|
60
|
+
* robust than re-concatenating partials) and Zod-validates it.
|
|
61
|
+
*
|
|
62
|
+
* Scope: the base StructuredRequest carries no server tools / thinking /
|
|
63
|
+
* caching (those live on StructuredWithToolsRequest and run the blocking
|
|
64
|
+
* tool-loop), so this is a single forced-tool turn. Failure handling mirrors
|
|
65
|
+
* the other streaming callers: a post-stream parse/validation miss rejects
|
|
66
|
+
* `result` and returns cleanly (so the caller's token loop completes and its
|
|
67
|
+
* `await result` retry path fires); a mid-stream/connect drop rejects AND
|
|
68
|
+
* throws out so the iteration aborts.
|
|
69
|
+
*/
|
|
70
|
+
structuredStream<T extends z.ZodTypeAny>(req: StructuredRequest<T>): {
|
|
71
|
+
tokens: AsyncIterable<string>;
|
|
72
|
+
result: Promise<StructuredResponse<T>>;
|
|
73
|
+
};
|
|
74
|
+
private streamIterator;
|
|
66
75
|
/**
|
|
67
76
|
* Anthropic's API takes a top-level `system` (string or TextBlockParam[])
|
|
68
77
|
* and messages of user/assistant only. Our LlmCaller carries system as
|
|
@@ -78,13 +87,17 @@ export declare class AnthropicLlmCaller implements LlmCaller {
|
|
|
78
87
|
private splitSystem;
|
|
79
88
|
private buildServerTools;
|
|
80
89
|
/**
|
|
81
|
-
* Map our ModelChoice → Anthropic API model id
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
90
|
+
* Map our ModelChoice → Anthropic API model id via the shared registry
|
|
91
|
+
* (pass-through today). Throws on a non-Anthropic provider rather than
|
|
92
|
+
* silently sending GPT/Gemini names to the Anthropic API — the dispatcher
|
|
93
|
+
* routes by provider, so this guards against a mis-wire.
|
|
85
94
|
*/
|
|
86
95
|
private resolveModelId;
|
|
96
|
+
/**
|
|
97
|
+
* Delegates to the shared transient-retry helper so all native callers share
|
|
98
|
+
* one backoff/classification policy (Phase 1 extraction). The SDK's own
|
|
99
|
+
* `status`/connection-error shapes are recognised by `isTransientError`.
|
|
100
|
+
*/
|
|
87
101
|
private withRetry;
|
|
88
|
-
private isTransient;
|
|
89
102
|
}
|
|
90
103
|
//# sourceMappingURL=llmCallerAnthropic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llmCallerAnthropic.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerAnthropic.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"llmCallerAnthropic.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerAnthropic.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAmB,YAAW,SAAS;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,GAAG,EAAE,qBAAqB;IAShC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA4B7C,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAI3B,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAC9C,GAAG,EAAE,0BAA0B,CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAoHjC;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB;QACD,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;YAgBc,cAAc;IAsF7B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,WAAW;IAkDnB,OAAO,CAAC,gBAAgB;IAkBxB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAStB;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAGlB"}
|
|
@@ -3,26 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AnthropicLlmCaller = exports.TransientLlmError = void 0;
|
|
7
|
-
exports.isTransientLlmError = isTransientLlmError;
|
|
6
|
+
exports.AnthropicLlmCaller = exports.isTransientLlmError = exports.TransientLlmError = void 0;
|
|
8
7
|
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
9
8
|
const zod_1 = require("zod");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
super(message);
|
|
18
|
-
this.cause = cause;
|
|
19
|
-
this.name = "TransientLlmError";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.TransientLlmError = TransientLlmError;
|
|
23
|
-
function isTransientLlmError(err) {
|
|
24
|
-
return err instanceof Error && err.name === "TransientLlmError";
|
|
25
|
-
}
|
|
9
|
+
const llmModelRegistry_1 = require("./llmModelRegistry");
|
|
10
|
+
// Transient-retry primitives are shared across all native callers (Phase 1 of
|
|
11
|
+
// LLM_NATIVE_MIGRATION_PLAN). Re-exported here for backward compat with existing
|
|
12
|
+
// importers that pulled `TransientLlmError` / `isTransientLlmError` from this file.
|
|
13
|
+
const llmRetry_1 = require("./llmRetry");
|
|
14
|
+
Object.defineProperty(exports, "TransientLlmError", { enumerable: true, get: function () { return llmRetry_1.TransientLlmError; } });
|
|
15
|
+
Object.defineProperty(exports, "isTransientLlmError", { enumerable: true, get: function () { return llmRetry_1.isTransientLlmError; } });
|
|
26
16
|
class AnthropicLlmCaller {
|
|
27
17
|
constructor(cfg) {
|
|
28
18
|
this.client = new sdk_1.default({
|
|
@@ -149,6 +139,101 @@ class AnthropicLlmCaller {
|
|
|
149
139
|
}
|
|
150
140
|
throw new Error(`AnthropicLlmCaller.structuredWithTools: exceeded ${maxRounds} tool rounds without ${submitToolName}`);
|
|
151
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Native incremental streaming structured output. Forces the
|
|
144
|
+
* `submit_<schemaName>` tool and streams its argument JSON as
|
|
145
|
+
* `input_json_delta` chunks — yielding each partial for token-by-token UI —
|
|
146
|
+
* then takes the authoritative payload from `stream.finalMessage()` (more
|
|
147
|
+
* robust than re-concatenating partials) and Zod-validates it.
|
|
148
|
+
*
|
|
149
|
+
* Scope: the base StructuredRequest carries no server tools / thinking /
|
|
150
|
+
* caching (those live on StructuredWithToolsRequest and run the blocking
|
|
151
|
+
* tool-loop), so this is a single forced-tool turn. Failure handling mirrors
|
|
152
|
+
* the other streaming callers: a post-stream parse/validation miss rejects
|
|
153
|
+
* `result` and returns cleanly (so the caller's token loop completes and its
|
|
154
|
+
* `await result` retry path fires); a mid-stream/connect drop rejects AND
|
|
155
|
+
* throws out so the iteration aborts.
|
|
156
|
+
*/
|
|
157
|
+
structuredStream(req) {
|
|
158
|
+
let resolveResult;
|
|
159
|
+
let rejectResult;
|
|
160
|
+
const result = new Promise((resolve, reject) => {
|
|
161
|
+
resolveResult = resolve;
|
|
162
|
+
rejectResult = reject;
|
|
163
|
+
});
|
|
164
|
+
const self = this;
|
|
165
|
+
const tokens = {
|
|
166
|
+
[Symbol.asyncIterator]() {
|
|
167
|
+
return self.streamIterator(req, resolveResult, rejectResult);
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
return { tokens, result };
|
|
171
|
+
}
|
|
172
|
+
async *streamIterator(req, resolveResult, rejectResult) {
|
|
173
|
+
const submitToolName = `submit_${req.schemaName}`;
|
|
174
|
+
const jsonSchema = zod_1.z.toJSONSchema(req.schema, { target: "draft-7" });
|
|
175
|
+
const tools = [
|
|
176
|
+
{
|
|
177
|
+
name: submitToolName,
|
|
178
|
+
description: `Submit the final ${req.schemaName} payload. Call this exactly once when ready.`,
|
|
179
|
+
input_schema: jsonSchema,
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
const { system, messages } = this.splitSystem(req.messages, false);
|
|
183
|
+
let requestId;
|
|
184
|
+
let inputTokens;
|
|
185
|
+
let outputTokens;
|
|
186
|
+
try {
|
|
187
|
+
const stream = this.client.messages.stream({
|
|
188
|
+
model: this.resolveModelId(req.model),
|
|
189
|
+
max_tokens: req.maxTokens ?? 8192,
|
|
190
|
+
temperature: req.temperature,
|
|
191
|
+
system,
|
|
192
|
+
tools,
|
|
193
|
+
tool_choice: { type: "tool", name: submitToolName },
|
|
194
|
+
messages,
|
|
195
|
+
});
|
|
196
|
+
for await (const event of stream) {
|
|
197
|
+
if (event.type === "message_start") {
|
|
198
|
+
requestId = event.message.id;
|
|
199
|
+
inputTokens = event.message.usage?.input_tokens;
|
|
200
|
+
}
|
|
201
|
+
else if (event.type === "content_block_delta" &&
|
|
202
|
+
event.delta.type === "input_json_delta") {
|
|
203
|
+
const partial = event.delta.partial_json;
|
|
204
|
+
if (partial)
|
|
205
|
+
yield partial;
|
|
206
|
+
}
|
|
207
|
+
else if (event.type === "message_delta") {
|
|
208
|
+
outputTokens = event.usage?.output_tokens ?? outputTokens;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Authoritative payload from the assembled final message (the forced
|
|
212
|
+
// tool_use block's input), not the concatenated partials.
|
|
213
|
+
const final = await stream.finalMessage();
|
|
214
|
+
const submit = final.content.find((b) => b.type === "tool_use" && b.name === submitToolName);
|
|
215
|
+
if (!submit) {
|
|
216
|
+
rejectResult(new Error(`AnthropicLlmCaller.structuredStream: no ${submitToolName} tool_use in final message`));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const parsed = req.schema.safeParse(submit.input);
|
|
220
|
+
if (!parsed.success) {
|
|
221
|
+
rejectResult(new Error(`AnthropicLlmCaller.structuredStream: schema validation failed for ${req.schemaName}: ${parsed.error.message}`));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
resolveResult({
|
|
225
|
+
data: parsed.data,
|
|
226
|
+
usage: { promptTokens: inputTokens, completionTokens: outputTokens },
|
|
227
|
+
requestId,
|
|
228
|
+
attemptedModels: [req.model],
|
|
229
|
+
usedFallback: false,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
rejectResult(e);
|
|
234
|
+
throw e;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
152
237
|
// ---------- helpers ----------
|
|
153
238
|
/**
|
|
154
239
|
* Anthropic's API takes a top-level `system` (string or TextBlockParam[])
|
|
@@ -170,9 +255,24 @@ class AnthropicLlmCaller {
|
|
|
170
255
|
systemText = systemText ? `${systemText}\n\n${m.content}` : m.content;
|
|
171
256
|
continue;
|
|
172
257
|
}
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
258
|
+
// Vision: when a message carries imageUrls, emit a content-block array
|
|
259
|
+
// (text + image blocks) instead of a bare string. Uses Anthropic's native
|
|
260
|
+
// URL image source (`source.type: "url"`) — no base64 round-trip — which
|
|
261
|
+
// the direct API supports (unlike the gateway's Anthropic translator,
|
|
262
|
+
// which rejected raw https URLs). Needed for the critic fallback
|
|
263
|
+
// (claude-sonnet-4-6, vision) now that it routes here instead of the
|
|
264
|
+
// gateway.
|
|
265
|
+
if (m.imageUrls?.length) {
|
|
266
|
+
const blocks = [
|
|
267
|
+
{ type: "text", text: m.content },
|
|
268
|
+
...m.imageUrls.map((url) => ({
|
|
269
|
+
type: "image",
|
|
270
|
+
source: { type: "url", url },
|
|
271
|
+
})),
|
|
272
|
+
];
|
|
273
|
+
out.push({ role: m.role, content: blocks });
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
176
276
|
out.push({ role: m.role, content: m.content });
|
|
177
277
|
}
|
|
178
278
|
if (!systemText)
|
|
@@ -207,49 +307,24 @@ class AnthropicLlmCaller {
|
|
|
207
307
|
});
|
|
208
308
|
}
|
|
209
309
|
/**
|
|
210
|
-
* Map our ModelChoice → Anthropic API model id
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
310
|
+
* Map our ModelChoice → Anthropic API model id via the shared registry
|
|
311
|
+
* (pass-through today). Throws on a non-Anthropic provider rather than
|
|
312
|
+
* silently sending GPT/Gemini names to the Anthropic API — the dispatcher
|
|
313
|
+
* routes by provider, so this guards against a mis-wire.
|
|
214
314
|
*/
|
|
215
315
|
resolveModelId(m) {
|
|
216
|
-
if (m.provider !== "anthropic") {
|
|
217
|
-
throw new Error(`AnthropicLlmCaller cannot serve provider=${m.provider}; route
|
|
218
|
-
}
|
|
219
|
-
return m.modelId;
|
|
220
|
-
}
|
|
221
|
-
async withRetry(fn) {
|
|
222
|
-
let lastErr;
|
|
223
|
-
for (let attempt = 0; attempt < this.maxRetries; attempt++) {
|
|
224
|
-
try {
|
|
225
|
-
return await fn();
|
|
226
|
-
}
|
|
227
|
-
catch (err) {
|
|
228
|
-
lastErr = err;
|
|
229
|
-
const transient = this.isTransient(err);
|
|
230
|
-
if (!transient || attempt === this.maxRetries - 1) {
|
|
231
|
-
if (transient) {
|
|
232
|
-
throw new TransientLlmError(`Anthropic transient error after ${attempt + 1} attempts: ${String(err?.message ?? err)}`, err);
|
|
233
|
-
}
|
|
234
|
-
throw err;
|
|
235
|
-
}
|
|
236
|
-
await new Promise((r) => setTimeout(r, 250 * Math.pow(4, attempt)));
|
|
237
|
-
}
|
|
316
|
+
if ((0, llmModelRegistry_1.normalizeProvider)(m.provider) !== "anthropic") {
|
|
317
|
+
throw new Error(`AnthropicLlmCaller cannot serve provider=${m.provider}; route via the dispatcher.`);
|
|
238
318
|
}
|
|
239
|
-
|
|
319
|
+
return (0, llmModelRegistry_1.nativeModelId)(m);
|
|
240
320
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
if (e.name === "APIConnectionError" || e.name === "APIConnectionTimeoutError") {
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
|
-
const msg = String(e.message ?? "");
|
|
252
|
-
return /timeout|ECONNRESET|ETIMEDOUT|network|socket hang up/i.test(msg);
|
|
321
|
+
/**
|
|
322
|
+
* Delegates to the shared transient-retry helper so all native callers share
|
|
323
|
+
* one backoff/classification policy (Phase 1 extraction). The SDK's own
|
|
324
|
+
* `status`/connection-error shapes are recognised by `isTransientError`.
|
|
325
|
+
*/
|
|
326
|
+
withRetry(fn) {
|
|
327
|
+
return (0, llmRetry_1.withRetry)(fn, { maxRetries: this.maxRetries });
|
|
253
328
|
}
|
|
254
329
|
}
|
|
255
330
|
exports.AnthropicLlmCaller = AnthropicLlmCaller;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LlmCaller } from "./llmCaller";
|
|
2
|
+
import { ProviderRoutingLlmCaller } from "./llmCallerRouting";
|
|
3
|
+
/**
|
|
4
|
+
* Build the native provider-dispatching LlmCaller from per-provider API keys
|
|
5
|
+
* (LLM_NATIVE_MIGRATION_PLAN). This is the single place the "construct three
|
|
6
|
+
* native callers + wrap in a dispatcher" wiring lives — both app bootstraps
|
|
7
|
+
* (firebase-functions, node-express-server) and the dev/eval scripts call it
|
|
8
|
+
* instead of copy-pasting the construction. Replaced the old per-call-site
|
|
9
|
+
* `new GatewayLlmCaller(...)`.
|
|
10
|
+
*
|
|
11
|
+
* Hosts own env reading (keys are passed in, not read here) so this stays a
|
|
12
|
+
* pure function. A provider with no key is left unwired — calls routed to it
|
|
13
|
+
* throw at dispatch, and its name is returned in `missing` so the caller can
|
|
14
|
+
* log/alert at boot rather than at first use.
|
|
15
|
+
*/
|
|
16
|
+
export interface NativeLlmCallerResult {
|
|
17
|
+
/** The dispatcher to hand to setLlmCaller(). */
|
|
18
|
+
caller: ProviderRoutingLlmCaller;
|
|
19
|
+
/**
|
|
20
|
+
* The Anthropic caller instance (or undefined if no key). Exposed so the
|
|
21
|
+
* functions host can also setAnthropicCaller() for the planner's web-search
|
|
22
|
+
* grounding, sharing the one client the dispatcher uses.
|
|
23
|
+
*/
|
|
24
|
+
anthropic?: LlmCaller;
|
|
25
|
+
/** Provider env-var names with no key supplied, for boot-time logging. */
|
|
26
|
+
missing: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare function createNativeLlmCaller(opts: {
|
|
29
|
+
openaiKey?: string;
|
|
30
|
+
anthropicKey?: string;
|
|
31
|
+
geminiKey?: string;
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
}): NativeLlmCallerResult;
|
|
34
|
+
//# sourceMappingURL=llmCallerFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmCallerFactory.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,MAAM,EAAE,wBAAwB,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,qBAAqB,CAuBxB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNativeLlmCaller = createNativeLlmCaller;
|
|
4
|
+
const llmCallerAnthropic_1 = require("./llmCallerAnthropic");
|
|
5
|
+
const llmCallerOpenai_1 = require("./llmCallerOpenai");
|
|
6
|
+
const llmCallerGemini_1 = require("./llmCallerGemini");
|
|
7
|
+
const llmCallerRouting_1 = require("./llmCallerRouting");
|
|
8
|
+
function createNativeLlmCaller(opts) {
|
|
9
|
+
const { openaiKey, anthropicKey, geminiKey, timeoutMs } = opts;
|
|
10
|
+
const anthropic = anthropicKey
|
|
11
|
+
? new llmCallerAnthropic_1.AnthropicLlmCaller({ apiKey: anthropicKey, timeoutMs })
|
|
12
|
+
: undefined;
|
|
13
|
+
const openai = openaiKey
|
|
14
|
+
? new llmCallerOpenai_1.OpenAiLlmCaller({ apiKey: openaiKey, timeoutMs })
|
|
15
|
+
: undefined;
|
|
16
|
+
const google = geminiKey
|
|
17
|
+
? new llmCallerGemini_1.GeminiLlmCaller({ apiKey: geminiKey, timeoutMs })
|
|
18
|
+
: undefined;
|
|
19
|
+
const missing = [];
|
|
20
|
+
if (!openaiKey)
|
|
21
|
+
missing.push("OPENAI_API_KEY");
|
|
22
|
+
if (!anthropicKey)
|
|
23
|
+
missing.push("ANTHROPIC_API_KEY");
|
|
24
|
+
if (!geminiKey)
|
|
25
|
+
missing.push("GOOGLE_API_KEY");
|
|
26
|
+
return {
|
|
27
|
+
caller: new llmCallerRouting_1.ProviderRoutingLlmCaller({ anthropic, openai, google }),
|
|
28
|
+
anthropic,
|
|
29
|
+
missing,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ChatRequest, ChatResponse, LlmCaller, StructuredRequest, StructuredResponse } from "./llmCaller";
|
|
3
|
+
/**
|
|
4
|
+
* Direct Google Gemini SDK LlmCaller (`@google/genai`) — native replacement for
|
|
5
|
+
* the Google slice of the Vercel AI Gateway (LLM_NATIVE_MIGRATION_PLAN Phase 4).
|
|
6
|
+
*
|
|
7
|
+
* Required to not regress the critic (gemini-2.5-flash, vision) and reference
|
|
8
|
+
* (gemini-2.5-pro, vision) roles, which route to `google` today. Single-provider:
|
|
9
|
+
* only serves `provider === "google"` ModelChoices; transport retry only (the
|
|
10
|
+
* dispatcher owns cross-provider fallback).
|
|
11
|
+
*
|
|
12
|
+
* Structured output uses Gemini's native `responseSchema` + JSON mime type; the
|
|
13
|
+
* client-side `JSON.parse` + Zod `safeParse` stay the source of truth (same
|
|
14
|
+
* contract as the OpenAI/gateway callers).
|
|
15
|
+
*
|
|
16
|
+
* Mapping notes:
|
|
17
|
+
* - system messages → `config.systemInstruction` (Gemini has no system role).
|
|
18
|
+
* - assistant role → Gemini's "model" role.
|
|
19
|
+
* - maxTokens → `config.maxOutputTokens`.
|
|
20
|
+
* - vision: imageUrls are fetched + base64-inlined (`inlineData`); Gemini does
|
|
21
|
+
* not accept arbitrary https URLs in `generateContent`.
|
|
22
|
+
*/
|
|
23
|
+
export interface GeminiCallerConfig {
|
|
24
|
+
apiKey: string;
|
|
25
|
+
/** Default request timeout in ms. Default 180s. */
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
/** Max retries on transient errors per call. Default 3. */
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
/** Optional fetch override (tests). */
|
|
30
|
+
fetchImpl?: typeof fetch;
|
|
31
|
+
}
|
|
32
|
+
export declare class GeminiLlmCaller implements LlmCaller {
|
|
33
|
+
private readonly ai;
|
|
34
|
+
private readonly maxRetries;
|
|
35
|
+
private readonly fetchImpl;
|
|
36
|
+
constructor(cfg: GeminiCallerConfig);
|
|
37
|
+
chat(req: ChatRequest): Promise<ChatResponse>;
|
|
38
|
+
structured<T extends z.ZodTypeAny>(req: StructuredRequest<T>): Promise<StructuredResponse<T>>;
|
|
39
|
+
structuredStream<T extends z.ZodTypeAny>(req: StructuredRequest<T>): {
|
|
40
|
+
tokens: AsyncIterable<string>;
|
|
41
|
+
result: Promise<StructuredResponse<T>>;
|
|
42
|
+
};
|
|
43
|
+
private streamIterator;
|
|
44
|
+
private buildConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Split system messages into a merged `systemInstruction` and map the rest to
|
|
47
|
+
* Gemini `Content` (user/model roles). Vision images are fetched + inlined.
|
|
48
|
+
*/
|
|
49
|
+
private encode;
|
|
50
|
+
/** Fetch an image URL and inline it as base64 (Gemini rejects raw https URLs). */
|
|
51
|
+
private toInlinePart;
|
|
52
|
+
private parseStructured;
|
|
53
|
+
private resolveModelId;
|
|
54
|
+
private usage;
|
|
55
|
+
/**
|
|
56
|
+
* Transport retry mapping the genai SDK's error shape (carries a numeric
|
|
57
|
+
* `status`) into the shared transient policy. Non-transient statuses
|
|
58
|
+
* (400/401/403/404) propagate immediately.
|
|
59
|
+
*/
|
|
60
|
+
private withRetry;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=llmCallerGemini.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmCallerGemini.d.ts","sourceRoot":"","sources":["../../../src/services/agent/llmCallerGemini.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAKrB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAID,qBAAa,eAAgB,YAAW,SAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAc;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAE7B,GAAG,EAAE,kBAAkB;IAM7B,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAuB7C,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAwBjC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,GACxB;QACD,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;YAgBc,cAAc;IAyD7B,OAAO,CAAC,WAAW;IAmBnB;;;OAGG;YACW,MAAM;IAyBpB,kFAAkF;YACpE,YAAY;IAkB1B,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,KAAK;IAcb;;;;OAIG;IACH,OAAO,CAAC,SAAS;CAmBlB"}
|