@juspay/neurolink 11.13.0 → 11.13.2
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/CHANGELOG.md +2 -6
- package/dist/browser/neurolink.min.js +681 -842
- package/dist/cli/commands/agent.js +2 -2
- package/dist/cli/commands/auth.d.ts +1 -1
- package/dist/cli/commands/auth.js +11 -11
- package/dist/cli/commands/authProviders.d.ts +1 -1
- package/dist/cli/commands/authProviders.js +2 -2
- package/dist/cli/commands/autoresearch.js +5 -5
- package/dist/cli/commands/config.d.ts +1 -1
- package/dist/cli/commands/config.js +4 -4
- package/dist/cli/commands/docs.d.ts +1 -1
- package/dist/cli/commands/evaluate.d.ts +1 -1
- package/dist/cli/commands/evaluate.js +4 -4
- package/dist/cli/commands/mcp.js +14 -14
- package/dist/cli/commands/models.js +3 -3
- package/dist/cli/commands/observability.d.ts +1 -1
- package/dist/cli/commands/observability.js +3 -3
- package/dist/cli/commands/ollama.js +1 -1
- package/dist/cli/commands/proxy.d.ts +2 -2
- package/dist/cli/commands/proxy.js +45 -45
- package/dist/cli/commands/proxyAnalyze.d.ts +1 -1
- package/dist/cli/commands/proxyAnalyze.js +2 -2
- package/dist/cli/commands/proxyReplay.d.ts +1 -1
- package/dist/cli/commands/proxyReplay.js +2 -2
- package/dist/cli/commands/rag.js +10 -10
- package/dist/cli/commands/serve.js +7 -7
- package/dist/cli/commands/server.js +6 -6
- package/dist/cli/commands/setup-anthropic.d.ts +1 -1
- package/dist/cli/commands/setup-anthropic.js +3 -3
- package/dist/cli/commands/setup-azure.d.ts +1 -1
- package/dist/cli/commands/setup-azure.js +3 -3
- package/dist/cli/commands/setup-bedrock.d.ts +1 -1
- package/dist/cli/commands/setup-bedrock.js +3 -3
- package/dist/cli/commands/setup-gcp.d.ts +1 -1
- package/dist/cli/commands/setup-gcp.js +1 -1
- package/dist/cli/commands/setup-google-ai.d.ts +1 -1
- package/dist/cli/commands/setup-google-ai.js +4 -4
- package/dist/cli/commands/setup-huggingface.d.ts +1 -1
- package/dist/cli/commands/setup-huggingface.js +1 -1
- package/dist/cli/commands/setup-mistral.d.ts +1 -1
- package/dist/cli/commands/setup-mistral.js +3 -3
- package/dist/cli/commands/setup-openai.d.ts +1 -1
- package/dist/cli/commands/setup-openai.js +3 -3
- package/dist/cli/commands/setup.d.ts +1 -1
- package/dist/cli/commands/setup.js +4 -4
- package/dist/cli/commands/task.js +4 -4
- package/dist/cli/commands/telemetry.d.ts +1 -1
- package/dist/cli/commands/telemetry.js +4 -4
- package/dist/cli/commands/voiceServer.d.ts +1 -1
- package/dist/cli/commands/voiceServer.js +6 -2
- package/dist/cli/commands/workflow.js +5 -5
- package/dist/cli/errorHandler.js +3 -3
- package/dist/cli/factories/commandFactory.js +13 -13
- package/dist/cli/factories/ollamaCommandFactory.js +3 -3
- package/dist/cli/factories/sagemakerCommandFactory.js +5 -5
- package/dist/cli/index.js +1 -1
- package/dist/cli/loop/conversationSelector.d.ts +1 -1
- package/dist/cli/loop/conversationSelector.js +3 -3
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/loop/optionsSchema.js +1 -1
- package/dist/cli/loop/session.d.ts +1 -1
- package/dist/cli/loop/session.js +6 -6
- package/dist/cli/parser.js +10 -2
- package/dist/cli/proxy-clients/claudeCode.d.ts +1 -1
- package/dist/cli/proxy-clients/claudeCode.js +1 -1
- package/dist/cli/proxy-clients/codex.d.ts +1 -1
- package/dist/cli/proxy-clients/codex.js +1 -1
- package/dist/cli/proxy-clients/copilot.d.ts +1 -1
- package/dist/cli/proxy-clients/copilot.js +1 -1
- package/dist/cli/proxy-clients/openCode.d.ts +1 -1
- package/dist/cli/proxy-clients/openCode.js +1 -1
- package/dist/cli/proxy-clients/qwenCode.d.ts +1 -1
- package/dist/cli/proxy-clients/qwenCode.js +1 -1
- package/dist/cli/proxy-clients/registry.d.ts +1 -1
- package/dist/cli/proxy-clients/registry.js +1 -1
- package/dist/cli/utils/audioFileUtils.d.ts +1 -1
- package/dist/cli/utils/audioPlayer.d.ts +1 -1
- package/dist/cli/utils/classifierRouterFlags.d.ts +1 -1
- package/dist/cli/utils/classifierRouterFlags.js +1 -1
- package/dist/cli/utils/completeSetup.d.ts +1 -1
- package/dist/cli/utils/completeSetup.js +1 -1
- package/dist/cli/utils/envManager.d.ts +1 -1
- package/dist/cli/utils/envManager.js +1 -1
- package/dist/cli/utils/inputValidation.js +2 -2
- package/dist/cli/utils/interactiveSetup.d.ts +2 -2
- package/dist/cli/utils/interactiveSetup.js +3 -3
- package/dist/cli/utils/ollamaUtils.d.ts +1 -1
- package/dist/cli/utils/ollamaUtils.js +1 -1
- package/dist/cli/utils/skillsFlags.d.ts +1 -1
- package/dist/cli/utils/toolRoutingFlags.d.ts +1 -1
- package/dist/cli/utils/toolRoutingFlags.js +1 -1
- package/dist/cli/utils/videoFileUtils.d.ts +1 -1
- package/dist/processors/data/XmlProcessor.d.ts +14 -0
- package/dist/processors/data/XmlProcessor.js +14 -0
- package/dist/processors/document/PptxProcessor.d.ts +9 -0
- package/dist/processors/document/PptxProcessor.js +9 -0
- package/dist/processors/media/VideoProcessor.js +30 -2
- package/dist/providers/amazonBedrock/client.js +1 -2
- package/dist/providers/googleVertex/index.d.ts +0 -1
- package/dist/providers/googleVertex/index.js +0 -1
- package/dist/rag/document/loaders.js +49 -21
- package/dist/server/abstract/baseServerAdapter.d.ts +13 -0
- package/dist/server/abstract/baseServerAdapter.js +39 -1
- package/dist/server/adapters/expressAdapter.js +15 -5
- package/dist/server/adapters/fastifyAdapter.js +15 -5
- package/dist/server/adapters/koaAdapter.js +16 -6
- package/dist/types/generate.d.ts +7 -0
- package/dist/types/stream.d.ts +1 -1
- package/docs-site/mcp-server/search.js +20 -12
- package/docs-site/mcp-server/types.d.ts +12 -5
- package/docs-site/static/search-index.json +1 -0
- package/package.json +16 -16
- package/dist/lib/action/actionExecutor.d.ts +0 -29
- package/dist/lib/action/actionExecutor.js +0 -291
- package/dist/lib/action/actionInputs.d.ts +0 -25
- package/dist/lib/action/actionInputs.js +0 -294
- package/dist/lib/action/githubIntegration.d.ts +0 -21
- package/dist/lib/action/githubIntegration.js +0 -188
- package/dist/lib/action/index.d.ts +0 -7
- package/dist/lib/action/index.js +0 -13
- package/dist/lib/adapters/audioFormatSupport.d.ts +0 -53
- package/dist/lib/adapters/audioFormatSupport.js +0 -201
- package/dist/lib/adapters/imageFormatSupport.d.ts +0 -75
- package/dist/lib/adapters/imageFormatSupport.js +0 -284
- package/dist/lib/adapters/providerImageAdapter.d.ts +0 -51
- package/dist/lib/adapters/providerImageAdapter.js +0 -704
- package/dist/lib/adapters/replicate/auth.d.ts +0 -19
- package/dist/lib/adapters/replicate/auth.js +0 -33
- package/dist/lib/adapters/replicate/predictionLifecycle.d.ts +0 -46
- package/dist/lib/adapters/replicate/predictionLifecycle.js +0 -289
- package/dist/lib/adapters/tts/cartesiaHandler.d.ts +0 -12
- package/dist/lib/adapters/tts/cartesiaHandler.js +0 -131
- package/dist/lib/adapters/tts/googleTTSHandler.d.ts +0 -97
- package/dist/lib/adapters/tts/googleTTSHandler.js +0 -353
- package/dist/lib/adapters/video/directorPipeline.d.ts +0 -31
- package/dist/lib/adapters/video/directorPipeline.js +0 -523
- package/dist/lib/adapters/video/ffmpegAdapter.d.ts +0 -84
- package/dist/lib/adapters/video/ffmpegAdapter.js +0 -207
- package/dist/lib/adapters/video/frameExtractor.d.ts +0 -28
- package/dist/lib/adapters/video/frameExtractor.js +0 -144
- package/dist/lib/adapters/video/klingVideoHandler.d.ts +0 -37
- package/dist/lib/adapters/video/klingVideoHandler.js +0 -306
- package/dist/lib/adapters/video/replicateVideoHandler.d.ts +0 -29
- package/dist/lib/adapters/video/replicateVideoHandler.js +0 -168
- package/dist/lib/adapters/video/runwayVideoHandler.d.ts +0 -32
- package/dist/lib/adapters/video/runwayVideoHandler.js +0 -317
- package/dist/lib/adapters/video/vertexVideoHandler.d.ts +0 -119
- package/dist/lib/adapters/video/vertexVideoHandler.js +0 -804
- package/dist/lib/adapters/video/videoAnalyzer.d.ts +0 -26
- package/dist/lib/adapters/video/videoAnalyzer.js +0 -239
- package/dist/lib/adapters/video/videoMerger.d.ts +0 -22
- package/dist/lib/adapters/video/videoMerger.js +0 -172
- package/dist/lib/agent/agent.d.ts +0 -104
- package/dist/lib/agent/agent.js +0 -433
- package/dist/lib/agent/agentNetwork.d.ts +0 -87
- package/dist/lib/agent/agentNetwork.js +0 -501
- package/dist/lib/agent/agentToolRegistrar.d.ts +0 -48
- package/dist/lib/agent/agentToolRegistrar.js +0 -337
- package/dist/lib/agent/communication/index.d.ts +0 -9
- package/dist/lib/agent/communication/index.js +0 -10
- package/dist/lib/agent/communication/message-bus.d.ts +0 -113
- package/dist/lib/agent/communication/message-bus.js +0 -407
- package/dist/lib/agent/coordination/coordinator.d.ts +0 -83
- package/dist/lib/agent/coordination/coordinator.js +0 -599
- package/dist/lib/agent/coordination/index.d.ts +0 -10
- package/dist/lib/agent/coordination/index.js +0 -11
- package/dist/lib/agent/coordination/task-distributor.d.ts +0 -113
- package/dist/lib/agent/coordination/task-distributor.js +0 -586
- package/dist/lib/agent/directTools.d.ts +0 -306
- package/dist/lib/agent/directTools.js +0 -907
- package/dist/lib/agent/index.d.ts +0 -41
- package/dist/lib/agent/index.js +0 -49
- package/dist/lib/agent/isolatedAgentRunner.d.ts +0 -73
- package/dist/lib/agent/isolatedAgentRunner.js +0 -947
- package/dist/lib/agent/orchestration/index.d.ts +0 -10
- package/dist/lib/agent/orchestration/index.js +0 -11
- package/dist/lib/agent/orchestration/orchestrator.d.ts +0 -114
- package/dist/lib/agent/orchestration/orchestrator.js +0 -479
- package/dist/lib/agent/orchestration/topology.d.ts +0 -164
- package/dist/lib/agent/orchestration/topology.js +0 -521
- package/dist/lib/agent/prompts/routingPrompts.d.ts +0 -63
- package/dist/lib/agent/prompts/routingPrompts.js +0 -202
- package/dist/lib/agent/structuredRecovery.d.ts +0 -30
- package/dist/lib/agent/structuredRecovery.js +0 -105
- package/dist/lib/analytics/index.d.ts +0 -7
- package/dist/lib/analytics/index.js +0 -8
- package/dist/lib/analytics/parseQualityScore.d.ts +0 -9
- package/dist/lib/analytics/parseQualityScore.js +0 -30
- package/dist/lib/analytics/pricing.d.ts +0 -27
- package/dist/lib/analytics/pricing.js +0 -42
- package/dist/lib/analytics/service.d.ts +0 -36
- package/dist/lib/analytics/service.js +0 -394
- package/dist/lib/analytics/storage.d.ts +0 -19
- package/dist/lib/analytics/storage.js +0 -33
- package/dist/lib/artifacts/artifactStore.d.ts +0 -55
- package/dist/lib/artifacts/artifactStore.js +0 -145
- package/dist/lib/auth/AuthProviderFactory.d.ts +0 -69
- package/dist/lib/auth/AuthProviderFactory.js +0 -112
- package/dist/lib/auth/AuthProviderRegistry.d.ts +0 -33
- package/dist/lib/auth/AuthProviderRegistry.js +0 -191
- package/dist/lib/auth/RequestContext.d.ts +0 -23
- package/dist/lib/auth/RequestContext.js +0 -79
- package/dist/lib/auth/accountPool.d.ts +0 -68
- package/dist/lib/auth/accountPool.js +0 -179
- package/dist/lib/auth/anthropicOAuth.d.ts +0 -400
- package/dist/lib/auth/anthropicOAuth.js +0 -1143
- package/dist/lib/auth/authContext.d.ts +0 -198
- package/dist/lib/auth/authContext.js +0 -315
- package/dist/lib/auth/codexOAuth.d.ts +0 -67
- package/dist/lib/auth/codexOAuth.js +0 -203
- package/dist/lib/auth/errors.d.ts +0 -63
- package/dist/lib/auth/errors.js +0 -40
- package/dist/lib/auth/index.d.ts +0 -41
- package/dist/lib/auth/index.js +0 -86
- package/dist/lib/auth/middleware/AuthMiddleware.d.ts +0 -127
- package/dist/lib/auth/middleware/AuthMiddleware.js +0 -523
- package/dist/lib/auth/middleware/rateLimitByUser.d.ts +0 -193
- package/dist/lib/auth/middleware/rateLimitByUser.js +0 -559
- package/dist/lib/auth/providers/BaseAuthProvider.d.ts +0 -259
- package/dist/lib/auth/providers/BaseAuthProvider.js +0 -724
- package/dist/lib/auth/providers/CognitoProvider.d.ts +0 -61
- package/dist/lib/auth/providers/CognitoProvider.js +0 -308
- package/dist/lib/auth/providers/KeycloakProvider.d.ts +0 -61
- package/dist/lib/auth/providers/KeycloakProvider.js +0 -396
- package/dist/lib/auth/providers/auth0.d.ts +0 -59
- package/dist/lib/auth/providers/auth0.js +0 -275
- package/dist/lib/auth/providers/betterAuth.d.ts +0 -51
- package/dist/lib/auth/providers/betterAuth.js +0 -183
- package/dist/lib/auth/providers/clerk.d.ts +0 -65
- package/dist/lib/auth/providers/clerk.js +0 -318
- package/dist/lib/auth/providers/custom.d.ts +0 -64
- package/dist/lib/auth/providers/custom.js +0 -113
- package/dist/lib/auth/providers/firebase.d.ts +0 -63
- package/dist/lib/auth/providers/firebase.js +0 -231
- package/dist/lib/auth/providers/jwt.d.ts +0 -68
- package/dist/lib/auth/providers/jwt.js +0 -217
- package/dist/lib/auth/providers/oauth2.d.ts +0 -73
- package/dist/lib/auth/providers/oauth2.js +0 -304
- package/dist/lib/auth/providers/supabase.d.ts +0 -63
- package/dist/lib/auth/providers/supabase.js +0 -260
- package/dist/lib/auth/providers/workos.d.ts +0 -61
- package/dist/lib/auth/providers/workos.js +0 -289
- package/dist/lib/auth/serverBridge.d.ts +0 -14
- package/dist/lib/auth/serverBridge.js +0 -26
- package/dist/lib/auth/sessionManager.d.ts +0 -118
- package/dist/lib/auth/sessionManager.js +0 -511
- package/dist/lib/auth/tokenStore.d.ts +0 -283
- package/dist/lib/auth/tokenStore.js +0 -929
- package/dist/lib/autoresearch/config.d.ts +0 -11
- package/dist/lib/autoresearch/config.js +0 -109
- package/dist/lib/autoresearch/errors.d.ts +0 -40
- package/dist/lib/autoresearch/errors.js +0 -21
- package/dist/lib/autoresearch/index.d.ts +0 -23
- package/dist/lib/autoresearch/index.js +0 -35
- package/dist/lib/autoresearch/phasePolicy.d.ts +0 -9
- package/dist/lib/autoresearch/phasePolicy.js +0 -70
- package/dist/lib/autoresearch/promptCompiler.d.ts +0 -15
- package/dist/lib/autoresearch/promptCompiler.js +0 -121
- package/dist/lib/autoresearch/repoPolicy.d.ts +0 -32
- package/dist/lib/autoresearch/repoPolicy.js +0 -129
- package/dist/lib/autoresearch/resultRecorder.d.ts +0 -20
- package/dist/lib/autoresearch/resultRecorder.js +0 -131
- package/dist/lib/autoresearch/runner.d.ts +0 -10
- package/dist/lib/autoresearch/runner.js +0 -109
- package/dist/lib/autoresearch/stateStore.d.ts +0 -12
- package/dist/lib/autoresearch/stateStore.js +0 -164
- package/dist/lib/autoresearch/summaryParser.d.ts +0 -16
- package/dist/lib/autoresearch/summaryParser.js +0 -95
- package/dist/lib/autoresearch/tools.d.ts +0 -27
- package/dist/lib/autoresearch/tools.js +0 -618
- package/dist/lib/autoresearch/worker.d.ts +0 -71
- package/dist/lib/autoresearch/worker.js +0 -418
- package/dist/lib/avatar/index.d.ts +0 -26
- package/dist/lib/avatar/index.js +0 -86
- package/dist/lib/avatar/providers/DIDAvatar.d.ts +0 -49
- package/dist/lib/avatar/providers/DIDAvatar.js +0 -502
- package/dist/lib/avatar/providers/HeyGenAvatar.d.ts +0 -30
- package/dist/lib/avatar/providers/HeyGenAvatar.js +0 -338
- package/dist/lib/avatar/providers/ReplicateAvatar.d.ts +0 -36
- package/dist/lib/avatar/providers/ReplicateAvatar.js +0 -268
- package/dist/lib/client/aiSdkAdapter.d.ts +0 -196
- package/dist/lib/client/aiSdkAdapter.js +0 -498
- package/dist/lib/client/auth.d.ts +0 -248
- package/dist/lib/client/auth.js +0 -469
- package/dist/lib/client/errors.d.ts +0 -298
- package/dist/lib/client/errors.js +0 -553
- package/dist/lib/client/httpClient.d.ts +0 -296
- package/dist/lib/client/httpClient.js +0 -851
- package/dist/lib/client/index.d.ts +0 -103
- package/dist/lib/client/index.js +0 -174
- package/dist/lib/client/interceptors.d.ts +0 -207
- package/dist/lib/client/interceptors.js +0 -620
- package/dist/lib/client/reactHooks.d.ts +0 -238
- package/dist/lib/client/reactHooks.js +0 -1168
- package/dist/lib/client/sseClient.d.ts +0 -115
- package/dist/lib/client/sseClient.js +0 -575
- package/dist/lib/client/streamingClient.d.ts +0 -255
- package/dist/lib/client/streamingClient.js +0 -963
- package/dist/lib/client/wsClient.d.ts +0 -127
- package/dist/lib/client/wsClient.js +0 -450
- package/dist/lib/config/configManager.d.ts +0 -60
- package/dist/lib/config/configManager.js +0 -304
- package/dist/lib/config/conversationMemory.d.ts +0 -51
- package/dist/lib/config/conversationMemory.js +0 -87
- package/dist/lib/config/modelSpecificPrompts.d.ts +0 -9
- package/dist/lib/config/modelSpecificPrompts.js +0 -39
- package/dist/lib/config/taskClassificationConfig.d.ts +0 -51
- package/dist/lib/config/taskClassificationConfig.js +0 -149
- package/dist/lib/constants/contextWindows.d.ts +0 -89
- package/dist/lib/constants/contextWindows.js +0 -568
- package/dist/lib/constants/enums.d.ts +0 -979
- package/dist/lib/constants/enums.js +0 -1247
- package/dist/lib/constants/index.d.ts +0 -184
- package/dist/lib/constants/index.js +0 -209
- package/dist/lib/constants/networkErrorCodes.d.ts +0 -14
- package/dist/lib/constants/networkErrorCodes.js +0 -22
- package/dist/lib/constants/performance.d.ts +0 -366
- package/dist/lib/constants/performance.js +0 -390
- package/dist/lib/constants/retry.d.ts +0 -224
- package/dist/lib/constants/retry.js +0 -267
- package/dist/lib/constants/timeouts.d.ts +0 -225
- package/dist/lib/constants/timeouts.js +0 -183
- package/dist/lib/constants/tokens.d.ts +0 -294
- package/dist/lib/constants/tokens.js +0 -381
- package/dist/lib/constants/videoErrors.d.ts +0 -49
- package/dist/lib/constants/videoErrors.js +0 -51
- package/dist/lib/context/anthropicLoopGuard.d.ts +0 -47
- package/dist/lib/context/anthropicLoopGuard.js +0 -186
- package/dist/lib/context/budgetChecker.d.ts +0 -33
- package/dist/lib/context/budgetChecker.js +0 -132
- package/dist/lib/context/contextCompactor.d.ts +0 -19
- package/dist/lib/context/contextCompactor.js +0 -258
- package/dist/lib/context/effectiveHistory.d.ts +0 -52
- package/dist/lib/context/effectiveHistory.js +0 -106
- package/dist/lib/context/emergencyTruncation.d.ts +0 -21
- package/dist/lib/context/emergencyTruncation.js +0 -89
- package/dist/lib/context/errorDetection.d.ts +0 -36
- package/dist/lib/context/errorDetection.js +0 -190
- package/dist/lib/context/errors.d.ts +0 -19
- package/dist/lib/context/errors.js +0 -22
- package/dist/lib/context/fileSummarizationService.d.ts +0 -45
- package/dist/lib/context/fileSummarizationService.js +0 -256
- package/dist/lib/context/fileSummarizer.d.ts +0 -55
- package/dist/lib/context/fileSummarizer.js +0 -146
- package/dist/lib/context/fileTokenBudget.d.ts +0 -52
- package/dist/lib/context/fileTokenBudget.js +0 -128
- package/dist/lib/context/geminiLoopGuard.d.ts +0 -54
- package/dist/lib/context/geminiLoopGuard.js +0 -141
- package/dist/lib/context/loopGuardCore.d.ts +0 -43
- package/dist/lib/context/loopGuardCore.js +0 -146
- package/dist/lib/context/openaiCompatLoopGuard.d.ts +0 -42
- package/dist/lib/context/openaiCompatLoopGuard.js +0 -173
- package/dist/lib/context/prompts/summarizationPrompt.d.ts +0 -16
- package/dist/lib/context/prompts/summarizationPrompt.js +0 -118
- package/dist/lib/context/stages/fileReadDeduplicator.d.ts +0 -8
- package/dist/lib/context/stages/fileReadDeduplicator.js +0 -67
- package/dist/lib/context/stages/slidingWindowTruncator.d.ts +0 -15
- package/dist/lib/context/stages/slidingWindowTruncator.js +0 -237
- package/dist/lib/context/stages/structuredSummarizer.d.ts +0 -8
- package/dist/lib/context/stages/structuredSummarizer.js +0 -123
- package/dist/lib/context/stages/toolOutputPruner.d.ts +0 -8
- package/dist/lib/context/stages/toolOutputPruner.js +0 -53
- package/dist/lib/context/stepBudgetGuard.d.ts +0 -61
- package/dist/lib/context/stepBudgetGuard.js +0 -358
- package/dist/lib/context/summarizationEngine.d.ts +0 -45
- package/dist/lib/context/summarizationEngine.js +0 -162
- package/dist/lib/context/toolOutputLimits.d.ts +0 -36
- package/dist/lib/context/toolOutputLimits.js +0 -95
- package/dist/lib/context/toolPairRepair.d.ts +0 -43
- package/dist/lib/context/toolPairRepair.js +0 -242
- package/dist/lib/core/analytics.d.ts +0 -11
- package/dist/lib/core/analytics.js +0 -117
- package/dist/lib/core/baseProvider.d.ts +0 -500
- package/dist/lib/core/baseProvider.js +0 -2081
- package/dist/lib/core/constants.d.ts +0 -146
- package/dist/lib/core/constants.js +0 -278
- package/dist/lib/core/conversationMemoryFactory.d.ts +0 -19
- package/dist/lib/core/conversationMemoryFactory.js +0 -147
- package/dist/lib/core/conversationMemoryInitializer.d.ts +0 -14
- package/dist/lib/core/conversationMemoryInitializer.js +0 -129
- package/dist/lib/core/conversationMemoryManager.d.ts +0 -110
- package/dist/lib/core/conversationMemoryManager.js +0 -471
- package/dist/lib/core/dynamicModels.d.ts +0 -89
- package/dist/lib/core/dynamicModels.js +0 -337
- package/dist/lib/core/evaluation.d.ts +0 -18
- package/dist/lib/core/evaluation.js +0 -310
- package/dist/lib/core/evaluationProviders.d.ts +0 -60
- package/dist/lib/core/evaluationProviders.js +0 -249
- package/dist/lib/core/factory.d.ts +0 -54
- package/dist/lib/core/factory.js +0 -364
- package/dist/lib/core/geminiLoopAdapter.d.ts +0 -20
- package/dist/lib/core/geminiLoopAdapter.js +0 -171
- package/dist/lib/core/handlerRegistry.d.ts +0 -29
- package/dist/lib/core/handlerRegistry.js +0 -62
- package/dist/lib/core/infrastructure/baseError.d.ts +0 -21
- package/dist/lib/core/infrastructure/baseError.js +0 -23
- package/dist/lib/core/infrastructure/baseFactory.d.ts +0 -16
- package/dist/lib/core/infrastructure/baseFactory.js +0 -55
- package/dist/lib/core/infrastructure/baseRegistry.d.ts +0 -19
- package/dist/lib/core/infrastructure/baseRegistry.js +0 -54
- package/dist/lib/core/infrastructure/index.d.ts +0 -5
- package/dist/lib/core/infrastructure/index.js +0 -6
- package/dist/lib/core/infrastructure/retry.d.ts +0 -2
- package/dist/lib/core/infrastructure/retry.js +0 -21
- package/dist/lib/core/infrastructure/typedEventEmitter.d.ts +0 -8
- package/dist/lib/core/infrastructure/typedEventEmitter.js +0 -24
- package/dist/lib/core/loopEngine.d.ts +0 -21
- package/dist/lib/core/loopEngine.js +0 -272
- package/dist/lib/core/modelConfiguration.d.ts +0 -179
- package/dist/lib/core/modelConfiguration.js +0 -549
- package/dist/lib/core/modules/GenerationHandler.d.ts +0 -135
- package/dist/lib/core/modules/GenerationHandler.js +0 -1028
- package/dist/lib/core/modules/MessageBuilder.d.ts +0 -24
- package/dist/lib/core/modules/MessageBuilder.js +0 -311
- package/dist/lib/core/modules/StreamHandler.d.ts +0 -70
- package/dist/lib/core/modules/StreamHandler.js +0 -229
- package/dist/lib/core/modules/TelemetryHandler.d.ts +0 -70
- package/dist/lib/core/modules/TelemetryHandler.js +0 -229
- package/dist/lib/core/modules/ToolsManager.d.ts +0 -105
- package/dist/lib/core/modules/ToolsManager.js +0 -737
- package/dist/lib/core/modules/Utilities.d.ts +0 -90
- package/dist/lib/core/modules/Utilities.js +0 -347
- package/dist/lib/core/modules/structuredOutputPolicy.d.ts +0 -91
- package/dist/lib/core/modules/structuredOutputPolicy.js +0 -136
- package/dist/lib/core/nativeToolFormat.d.ts +0 -33
- package/dist/lib/core/nativeToolFormat.js +0 -31
- package/dist/lib/core/redisConversationMemoryManager.d.ts +0 -235
- package/dist/lib/core/redisConversationMemoryManager.js +0 -1724
- package/dist/lib/core/serviceRegistry.d.ts +0 -40
- package/dist/lib/core/serviceRegistry.js +0 -113
- package/dist/lib/core/streamAnalytics.d.ts +0 -27
- package/dist/lib/core/streamAnalytics.js +0 -132
- package/dist/lib/core/streamChannel.d.ts +0 -10
- package/dist/lib/core/streamChannel.js +0 -77
- package/dist/lib/core/toolDedup.d.ts +0 -51
- package/dist/lib/core/toolDedup.js +0 -197
- package/dist/lib/core/toolEvents.d.ts +0 -2
- package/dist/lib/core/toolEvents.js +0 -8
- package/dist/lib/core/toolExecutionRecorder.d.ts +0 -76
- package/dist/lib/core/toolExecutionRecorder.js +0 -261
- package/dist/lib/core/toolRouting.d.ts +0 -68
- package/dist/lib/core/toolRouting.js +0 -496
- package/dist/lib/core/toolRoutingCache.d.ts +0 -64
- package/dist/lib/core/toolRoutingCache.js +0 -155
- package/dist/lib/core/toolRoutingEmbedding.d.ts +0 -112
- package/dist/lib/core/toolRoutingEmbedding.js +0 -323
- package/dist/lib/dynamic/dynamicResolver.d.ts +0 -282
- package/dist/lib/dynamic/dynamicResolver.js +0 -634
- package/dist/lib/dynamic/index.d.ts +0 -10
- package/dist/lib/dynamic/index.js +0 -13
- package/dist/lib/dynamic/resolution.d.ts +0 -17
- package/dist/lib/dynamic/resolution.js +0 -22
- package/dist/lib/evaluation/BatchEvaluator.d.ts +0 -65
- package/dist/lib/evaluation/BatchEvaluator.js +0 -271
- package/dist/lib/evaluation/EvaluationAggregator.d.ts +0 -156
- package/dist/lib/evaluation/EvaluationAggregator.js +0 -378
- package/dist/lib/evaluation/EvaluatorFactory.d.ts +0 -102
- package/dist/lib/evaluation/EvaluatorFactory.js +0 -281
- package/dist/lib/evaluation/EvaluatorRegistry.d.ts +0 -111
- package/dist/lib/evaluation/EvaluatorRegistry.js +0 -185
- package/dist/lib/evaluation/contextBuilder.d.ts +0 -44
- package/dist/lib/evaluation/contextBuilder.js +0 -132
- package/dist/lib/evaluation/errors/EvaluationError.d.ts +0 -161
- package/dist/lib/evaluation/errors/EvaluationError.js +0 -207
- package/dist/lib/evaluation/errors/index.d.ts +0 -4
- package/dist/lib/evaluation/errors/index.js +0 -5
- package/dist/lib/evaluation/hooks/index.d.ts +0 -6
- package/dist/lib/evaluation/hooks/index.js +0 -7
- package/dist/lib/evaluation/hooks/langfuseAdapter.d.ts +0 -62
- package/dist/lib/evaluation/hooks/langfuseAdapter.js +0 -173
- package/dist/lib/evaluation/hooks/observabilityHooks.d.ts +0 -77
- package/dist/lib/evaluation/hooks/observabilityHooks.js +0 -187
- package/dist/lib/evaluation/index.d.ts +0 -41
- package/dist/lib/evaluation/index.js +0 -78
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +0 -83
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +0 -397
- package/dist/lib/evaluation/pipeline/index.d.ts +0 -8
- package/dist/lib/evaluation/pipeline/index.js +0 -9
- package/dist/lib/evaluation/pipeline/pipelineBuilder.d.ts +0 -126
- package/dist/lib/evaluation/pipeline/pipelineBuilder.js +0 -261
- package/dist/lib/evaluation/pipeline/presets.d.ts +0 -66
- package/dist/lib/evaluation/pipeline/presets.js +0 -225
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.d.ts +0 -46
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +0 -242
- package/dist/lib/evaluation/pipeline/strategies/index.d.ts +0 -6
- package/dist/lib/evaluation/pipeline/strategies/index.js +0 -7
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.d.ts +0 -76
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +0 -247
- package/dist/lib/evaluation/prompts.d.ts +0 -22
- package/dist/lib/evaluation/prompts.js +0 -74
- package/dist/lib/evaluation/ragasEvaluator.d.ts +0 -28
- package/dist/lib/evaluation/ragasEvaluator.js +0 -127
- package/dist/lib/evaluation/reporting/index.d.ts +0 -6
- package/dist/lib/evaluation/reporting/index.js +0 -7
- package/dist/lib/evaluation/reporting/metricsCollector.d.ts +0 -88
- package/dist/lib/evaluation/reporting/metricsCollector.js +0 -286
- package/dist/lib/evaluation/reporting/reportGenerator.d.ts +0 -57
- package/dist/lib/evaluation/reporting/reportGenerator.js +0 -375
- package/dist/lib/evaluation/retryManager.d.ts +0 -39
- package/dist/lib/evaluation/retryManager.js +0 -79
- package/dist/lib/evaluation/scorers/baseScorer.d.ts +0 -82
- package/dist/lib/evaluation/scorers/baseScorer.js +0 -233
- package/dist/lib/evaluation/scorers/customScorerUtils.d.ts +0 -86
- package/dist/lib/evaluation/scorers/customScorerUtils.js +0 -382
- package/dist/lib/evaluation/scorers/index.d.ts +0 -10
- package/dist/lib/evaluation/scorers/index.js +0 -17
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/answerRelevancyScorer.js +0 -100
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.d.ts +0 -69
- package/dist/lib/evaluation/scorers/llm/baseLLMScorer.js +0 -282
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/biasDetectionScorer.js +0 -128
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/contextPrecisionScorer.js +0 -93
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/contextRelevancyScorer.js +0 -108
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/faithfulnessScorer.js +0 -122
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/hallucinationScorer.js +0 -141
- package/dist/lib/evaluation/scorers/llm/index.d.ts +0 -15
- package/dist/lib/evaluation/scorers/llm/index.js +0 -17
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/promptAlignmentScorer.js +0 -107
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/summarizationScorer.js +0 -115
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/toneConsistencyScorer.js +0 -107
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.d.ts +0 -12
- package/dist/lib/evaluation/scorers/llm/toxicityScorer.js +0 -122
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.d.ts +0 -77
- package/dist/lib/evaluation/scorers/rule/baseRuleScorer.js +0 -234
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.d.ts +0 -81
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.js +0 -353
- package/dist/lib/evaluation/scorers/rule/formatScorer.d.ts +0 -107
- package/dist/lib/evaluation/scorers/rule/formatScorer.js +0 -471
- package/dist/lib/evaluation/scorers/rule/index.d.ts +0 -9
- package/dist/lib/evaluation/scorers/rule/index.js +0 -11
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.d.ts +0 -66
- package/dist/lib/evaluation/scorers/rule/keywordCoverageScorer.js +0 -348
- package/dist/lib/evaluation/scorers/rule/lengthScorer.d.ts +0 -74
- package/dist/lib/evaluation/scorers/rule/lengthScorer.js +0 -352
- package/dist/lib/evaluation/scorers/scorerBuilder.d.ts +0 -160
- package/dist/lib/evaluation/scorers/scorerBuilder.js +0 -421
- package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +0 -65
- package/dist/lib/evaluation/scorers/scorerRegistry.js +0 -540
- package/dist/lib/evaluation/scoring.d.ts +0 -15
- package/dist/lib/evaluation/scoring.js +0 -61
- package/dist/lib/factories/providerDescriptors.d.ts +0 -18
- package/dist/lib/factories/providerDescriptors.js +0 -547
- package/dist/lib/factories/providerFactory.d.ts +0 -87
- package/dist/lib/factories/providerFactory.js +0 -199
- package/dist/lib/factories/providerRegistry.d.ts +0 -58
- package/dist/lib/factories/providerRegistry.js +0 -549
- package/dist/lib/features/ppt/constants.d.ts +0 -121
- package/dist/lib/features/ppt/constants.js +0 -897
- package/dist/lib/features/ppt/contentPlanner.d.ts +0 -47
- package/dist/lib/features/ppt/contentPlanner.js +0 -558
- package/dist/lib/features/ppt/index.d.ts +0 -11
- package/dist/lib/features/ppt/index.js +0 -33
- package/dist/lib/features/ppt/pptError.d.ts +0 -38
- package/dist/lib/features/ppt/pptError.js +0 -54
- package/dist/lib/features/ppt/presentationOrchestrator.d.ts +0 -37
- package/dist/lib/features/ppt/presentationOrchestrator.js +0 -231
- package/dist/lib/features/ppt/slideGenerator.d.ts +0 -56
- package/dist/lib/features/ppt/slideGenerator.js +0 -542
- package/dist/lib/features/ppt/slideRenderers.d.ts +0 -347
- package/dist/lib/features/ppt/slideRenderers.js +0 -2384
- package/dist/lib/features/ppt/slideTypeInference.d.ts +0 -91
- package/dist/lib/features/ppt/slideTypeInference.js +0 -406
- package/dist/lib/features/ppt/utils.d.ts +0 -103
- package/dist/lib/features/ppt/utils.js +0 -446
- package/dist/lib/files/fileReferenceRegistry.d.ts +0 -275
- package/dist/lib/files/fileReferenceRegistry.js +0 -1559
- package/dist/lib/files/fileTools.d.ts +0 -176
- package/dist/lib/files/fileTools.js +0 -435
- package/dist/lib/files/index.d.ts +0 -13
- package/dist/lib/files/index.js +0 -14
- package/dist/lib/files/streamingReader.d.ts +0 -93
- package/dist/lib/files/streamingReader.js +0 -322
- package/dist/lib/hitl/hitlErrors.d.ts +0 -38
- package/dist/lib/hitl/hitlErrors.js +0 -55
- package/dist/lib/hitl/hitlManager.d.ts +0 -100
- package/dist/lib/hitl/hitlManager.js +0 -461
- package/dist/lib/hitl/index.d.ts +0 -7
- package/dist/lib/hitl/index.js +0 -10
- package/dist/lib/image-gen/ImageGenService.d.ts +0 -146
- package/dist/lib/image-gen/ImageGenService.js +0 -349
- package/dist/lib/image-gen/imageGenTools.d.ts +0 -109
- package/dist/lib/image-gen/imageGenTools.js +0 -305
- package/dist/lib/image-gen/index.d.ts +0 -45
- package/dist/lib/image-gen/index.js +0 -49
- package/dist/lib/index.d.ts +0 -447
- package/dist/lib/index.js +0 -748
- package/dist/lib/knowledge/context.d.ts +0 -18
- package/dist/lib/knowledge/context.js +0 -92
- package/dist/lib/knowledge/defaults.d.ts +0 -24
- package/dist/lib/knowledge/defaults.js +0 -30
- package/dist/lib/knowledge/engine.d.ts +0 -35
- package/dist/lib/knowledge/engine.js +0 -180
- package/dist/lib/knowledge/index.d.ts +0 -15
- package/dist/lib/knowledge/index.js +0 -16
- package/dist/lib/knowledge/indexCache.d.ts +0 -19
- package/dist/lib/knowledge/indexCache.js +0 -110
- package/dist/lib/knowledge/knowledgeIndex.d.ts +0 -41
- package/dist/lib/knowledge/knowledgeIndex.js +0 -205
- package/dist/lib/knowledge/normalize.d.ts +0 -32
- package/dist/lib/knowledge/normalize.js +0 -75
- package/dist/lib/knowledge/resolve.d.ts +0 -18
- package/dist/lib/knowledge/resolve.js +0 -157
- package/dist/lib/knowledge/retrieval.d.ts +0 -16
- package/dist/lib/knowledge/retrieval.js +0 -222
- package/dist/lib/mcp/agentExposure.d.ts +0 -83
- package/dist/lib/mcp/agentExposure.js +0 -357
- package/dist/lib/mcp/auth/index.d.ts +0 -6
- package/dist/lib/mcp/auth/index.js +0 -12
- package/dist/lib/mcp/auth/oauthClientProvider.d.ts +0 -93
- package/dist/lib/mcp/auth/oauthClientProvider.js +0 -331
- package/dist/lib/mcp/auth/tokenStorage.d.ts +0 -56
- package/dist/lib/mcp/auth/tokenStorage.js +0 -135
- package/dist/lib/mcp/batching/index.d.ts +0 -1
- package/dist/lib/mcp/batching/index.js +0 -2
- package/dist/lib/mcp/batching/requestBatcher.d.ts +0 -130
- package/dist/lib/mcp/batching/requestBatcher.js +0 -468
- package/dist/lib/mcp/caching/index.d.ts +0 -1
- package/dist/lib/mcp/caching/index.js +0 -2
- package/dist/lib/mcp/caching/toolCache.d.ts +0 -154
- package/dist/lib/mcp/caching/toolCache.js +0 -434
- package/dist/lib/mcp/elicitation/elicitationManager.d.ts +0 -169
- package/dist/lib/mcp/elicitation/elicitationManager.js +0 -377
- package/dist/lib/mcp/elicitation/index.d.ts +0 -1
- package/dist/lib/mcp/elicitation/index.js +0 -3
- package/dist/lib/mcp/elicitationProtocol.d.ts +0 -139
- package/dist/lib/mcp/elicitationProtocol.js +0 -376
- package/dist/lib/mcp/enhancedToolDiscovery.d.ts +0 -125
- package/dist/lib/mcp/enhancedToolDiscovery.js +0 -482
- package/dist/lib/mcp/externalServerManager.d.ts +0 -189
- package/dist/lib/mcp/externalServerManager.js +0 -1525
- package/dist/lib/mcp/factory.d.ts +0 -60
- package/dist/lib/mcp/factory.js +0 -162
- package/dist/lib/mcp/flexibleToolValidator.d.ts +0 -46
- package/dist/lib/mcp/flexibleToolValidator.js +0 -162
- package/dist/lib/mcp/httpRateLimiter.d.ts +0 -152
- package/dist/lib/mcp/httpRateLimiter.js +0 -386
- package/dist/lib/mcp/httpRetryHandler.d.ts +0 -62
- package/dist/lib/mcp/httpRetryHandler.js +0 -180
- package/dist/lib/mcp/index.d.ts +0 -60
- package/dist/lib/mcp/index.js +0 -82
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +0 -123
- package/dist/lib/mcp/mcpCircuitBreaker.js +0 -428
- package/dist/lib/mcp/mcpClientFactory.d.ts +0 -109
- package/dist/lib/mcp/mcpClientFactory.js +0 -714
- package/dist/lib/mcp/mcpOutputNormalizer.d.ts +0 -47
- package/dist/lib/mcp/mcpOutputNormalizer.js +0 -183
- package/dist/lib/mcp/mcpRegistryClient.d.ts +0 -129
- package/dist/lib/mcp/mcpRegistryClient.js +0 -489
- package/dist/lib/mcp/mcpServerBase.d.ts +0 -162
- package/dist/lib/mcp/mcpServerBase.js +0 -377
- package/dist/lib/mcp/multiServerManager.d.ts +0 -182
- package/dist/lib/mcp/multiServerManager.js +0 -580
- package/dist/lib/mcp/registry.d.ts +0 -94
- package/dist/lib/mcp/registry.js +0 -159
- package/dist/lib/mcp/routing/index.d.ts +0 -1
- package/dist/lib/mcp/routing/index.js +0 -2
- package/dist/lib/mcp/routing/toolRouter.d.ts +0 -110
- package/dist/lib/mcp/routing/toolRouter.js +0 -417
- package/dist/lib/mcp/serverCapabilities.d.ts +0 -175
- package/dist/lib/mcp/serverCapabilities.js +0 -503
- package/dist/lib/mcp/servers/agent/directToolsServer.d.ts +0 -8
- package/dist/lib/mcp/servers/agent/directToolsServer.js +0 -152
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.d.ts +0 -6
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +0 -364
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.d.ts +0 -10
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.js +0 -232
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.d.ts +0 -5
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +0 -584
- package/dist/lib/mcp/servers/utilities/utilityServer.d.ts +0 -8
- package/dist/lib/mcp/servers/utilities/utilityServer.js +0 -327
- package/dist/lib/mcp/toolAnnotations.d.ts +0 -57
- package/dist/lib/mcp/toolAnnotations.js +0 -240
- package/dist/lib/mcp/toolConverter.d.ts +0 -87
- package/dist/lib/mcp/toolConverter.js +0 -259
- package/dist/lib/mcp/toolDiscoveryService.d.ts +0 -144
- package/dist/lib/mcp/toolDiscoveryService.js +0 -978
- package/dist/lib/mcp/toolIntegration.d.ts +0 -92
- package/dist/lib/mcp/toolIntegration.js +0 -335
- package/dist/lib/mcp/toolRegistry.d.ts +0 -151
- package/dist/lib/mcp/toolRegistry.js +0 -755
- package/dist/lib/memory/hippocampusInitializer.d.ts +0 -2
- package/dist/lib/memory/hippocampusInitializer.js +0 -50
- package/dist/lib/memory/memoryRetrievalTools.d.ts +0 -13
- package/dist/lib/memory/memoryRetrievalTools.js +0 -267
- package/dist/lib/middleware/builtin/analytics.d.ts +0 -16
- package/dist/lib/middleware/builtin/analytics.js +0 -133
- package/dist/lib/middleware/builtin/autoEvaluation.d.ts +0 -11
- package/dist/lib/middleware/builtin/autoEvaluation.js +0 -201
- package/dist/lib/middleware/builtin/guardrails.d.ts +0 -7
- package/dist/lib/middleware/builtin/guardrails.js +0 -110
- package/dist/lib/middleware/builtin/lifecycle.d.ts +0 -2
- package/dist/lib/middleware/builtin/lifecycle.js +0 -161
- package/dist/lib/middleware/factory.d.ts +0 -69
- package/dist/lib/middleware/factory.js +0 -328
- package/dist/lib/middleware/index.d.ts +0 -11
- package/dist/lib/middleware/index.js +0 -17
- package/dist/lib/middleware/registry.d.ts +0 -76
- package/dist/lib/middleware/registry.js +0 -296
- package/dist/lib/middleware/utils/guardrailsUtils.d.ts +0 -50
- package/dist/lib/middleware/utils/guardrailsUtils.js +0 -397
- package/dist/lib/models/anthropicModels.d.ts +0 -261
- package/dist/lib/models/anthropicModels.js +0 -556
- package/dist/lib/models/manifestRegistry.d.ts +0 -33
- package/dist/lib/models/manifestRegistry.js +0 -174
- package/dist/lib/models/manifests/anthropic.d.ts +0 -9
- package/dist/lib/models/manifests/anthropic.js +0 -346
- package/dist/lib/models/manifests/azure.d.ts +0 -2
- package/dist/lib/models/manifests/azure.js +0 -87
- package/dist/lib/models/manifests/bedrock.d.ts +0 -2
- package/dist/lib/models/manifests/bedrock.js +0 -75
- package/dist/lib/models/manifests/cloudflare.d.ts +0 -8
- package/dist/lib/models/manifests/cloudflare.js +0 -19
- package/dist/lib/models/manifests/cohere.d.ts +0 -8
- package/dist/lib/models/manifests/cohere.js +0 -19
- package/dist/lib/models/manifests/deepseek.d.ts +0 -8
- package/dist/lib/models/manifests/deepseek.js +0 -19
- package/dist/lib/models/manifests/fireworks.d.ts +0 -8
- package/dist/lib/models/manifests/fireworks.js +0 -19
- package/dist/lib/models/manifests/google-ai.d.ts +0 -2
- package/dist/lib/models/manifests/google-ai.js +0 -28
- package/dist/lib/models/manifests/groq.d.ts +0 -8
- package/dist/lib/models/manifests/groq.js +0 -19
- package/dist/lib/models/manifests/huggingface.d.ts +0 -8
- package/dist/lib/models/manifests/huggingface.js +0 -19
- package/dist/lib/models/manifests/ideogram.d.ts +0 -8
- package/dist/lib/models/manifests/ideogram.js +0 -19
- package/dist/lib/models/manifests/jina.d.ts +0 -8
- package/dist/lib/models/manifests/jina.js +0 -19
- package/dist/lib/models/manifests/litellm.d.ts +0 -8
- package/dist/lib/models/manifests/litellm.js +0 -19
- package/dist/lib/models/manifests/llamacpp.d.ts +0 -8
- package/dist/lib/models/manifests/llamacpp.js +0 -19
- package/dist/lib/models/manifests/lm-studio.d.ts +0 -8
- package/dist/lib/models/manifests/lm-studio.js +0 -19
- package/dist/lib/models/manifests/mistral.d.ts +0 -2
- package/dist/lib/models/manifests/mistral.js +0 -50
- package/dist/lib/models/manifests/nvidia-nim.d.ts +0 -8
- package/dist/lib/models/manifests/nvidia-nim.js +0 -19
- package/dist/lib/models/manifests/ollama.d.ts +0 -2
- package/dist/lib/models/manifests/ollama.js +0 -72
- package/dist/lib/models/manifests/openai-compatible.d.ts +0 -8
- package/dist/lib/models/manifests/openai-compatible.js +0 -19
- package/dist/lib/models/manifests/openai.d.ts +0 -11
- package/dist/lib/models/manifests/openai.js +0 -560
- package/dist/lib/models/manifests/openrouter.d.ts +0 -8
- package/dist/lib/models/manifests/openrouter.js +0 -19
- package/dist/lib/models/manifests/perplexity.d.ts +0 -8
- package/dist/lib/models/manifests/perplexity.js +0 -19
- package/dist/lib/models/manifests/recraft.d.ts +0 -8
- package/dist/lib/models/manifests/recraft.js +0 -19
- package/dist/lib/models/manifests/replicate.d.ts +0 -8
- package/dist/lib/models/manifests/replicate.js +0 -19
- package/dist/lib/models/manifests/sagemaker.d.ts +0 -8
- package/dist/lib/models/manifests/sagemaker.js +0 -19
- package/dist/lib/models/manifests/stability.d.ts +0 -8
- package/dist/lib/models/manifests/stability.js +0 -19
- package/dist/lib/models/manifests/together-ai.d.ts +0 -8
- package/dist/lib/models/manifests/together-ai.js +0 -19
- package/dist/lib/models/manifests/vertex.d.ts +0 -8
- package/dist/lib/models/manifests/vertex.js +0 -19
- package/dist/lib/models/manifests/voyage.d.ts +0 -8
- package/dist/lib/models/manifests/voyage.js +0 -19
- package/dist/lib/models/manifests/xai.d.ts +0 -8
- package/dist/lib/models/manifests/xai.js +0 -19
- package/dist/lib/models/modelRegistry.d.ts +0 -74
- package/dist/lib/models/modelRegistry.js +0 -2695
- package/dist/lib/models/modelResolver.d.ts +0 -74
- package/dist/lib/models/modelResolver.js +0 -470
- package/dist/lib/music/index.d.ts +0 -27
- package/dist/lib/music/index.js +0 -94
- package/dist/lib/music/providers/BeatovenMusic.d.ts +0 -31
- package/dist/lib/music/providers/BeatovenMusic.js +0 -334
- package/dist/lib/music/providers/ElevenLabsMusic.d.ts +0 -30
- package/dist/lib/music/providers/ElevenLabsMusic.js +0 -169
- package/dist/lib/music/providers/LyriaMusic.d.ts +0 -29
- package/dist/lib/music/providers/LyriaMusic.js +0 -173
- package/dist/lib/music/providers/ReplicateMusic.d.ts +0 -31
- package/dist/lib/music/providers/ReplicateMusic.js +0 -262
- package/dist/lib/neurolink.d.ts +0 -2662
- package/dist/lib/neurolink.js +0 -12946
- package/dist/lib/observability/exporterRegistry.d.ts +0 -133
- package/dist/lib/observability/exporterRegistry.js +0 -414
- package/dist/lib/observability/exporters/arizeExporter.d.ts +0 -32
- package/dist/lib/observability/exporters/arizeExporter.js +0 -139
- package/dist/lib/observability/exporters/baseExporter.d.ts +0 -117
- package/dist/lib/observability/exporters/baseExporter.js +0 -191
- package/dist/lib/observability/exporters/braintrustExporter.d.ts +0 -30
- package/dist/lib/observability/exporters/braintrustExporter.js +0 -155
- package/dist/lib/observability/exporters/datadogExporter.d.ts +0 -37
- package/dist/lib/observability/exporters/datadogExporter.js +0 -197
- package/dist/lib/observability/exporters/index.d.ts +0 -13
- package/dist/lib/observability/exporters/index.js +0 -14
- package/dist/lib/observability/exporters/laminarExporter.d.ts +0 -48
- package/dist/lib/observability/exporters/laminarExporter.js +0 -304
- package/dist/lib/observability/exporters/langfuseExporter.d.ts +0 -48
- package/dist/lib/observability/exporters/langfuseExporter.js +0 -210
- package/dist/lib/observability/exporters/langsmithExporter.d.ts +0 -26
- package/dist/lib/observability/exporters/langsmithExporter.js +0 -144
- package/dist/lib/observability/exporters/otelExporter.d.ts +0 -39
- package/dist/lib/observability/exporters/otelExporter.js +0 -165
- package/dist/lib/observability/exporters/posthogExporter.d.ts +0 -48
- package/dist/lib/observability/exporters/posthogExporter.js +0 -289
- package/dist/lib/observability/exporters/sentryExporter.d.ts +0 -32
- package/dist/lib/observability/exporters/sentryExporter.js +0 -167
- package/dist/lib/observability/index.d.ts +0 -23
- package/dist/lib/observability/index.js +0 -32
- package/dist/lib/observability/metricsAggregator.d.ts +0 -126
- package/dist/lib/observability/metricsAggregator.js +0 -553
- package/dist/lib/observability/otelBridge.d.ts +0 -49
- package/dist/lib/observability/otelBridge.js +0 -141
- package/dist/lib/observability/retryPolicy.d.ts +0 -154
- package/dist/lib/observability/retryPolicy.js +0 -384
- package/dist/lib/observability/sampling/index.d.ts +0 -4
- package/dist/lib/observability/sampling/index.js +0 -5
- package/dist/lib/observability/sampling/samplers.d.ts +0 -104
- package/dist/lib/observability/sampling/samplers.js +0 -217
- package/dist/lib/observability/spanProcessor.d.ts +0 -115
- package/dist/lib/observability/spanProcessor.js +0 -304
- package/dist/lib/observability/tokenTracker.d.ts +0 -109
- package/dist/lib/observability/tokenTracker.js +0 -416
- package/dist/lib/observability/utils/index.d.ts +0 -4
- package/dist/lib/observability/utils/index.js +0 -5
- package/dist/lib/observability/utils/safeMetadata.d.ts +0 -10
- package/dist/lib/observability/utils/safeMetadata.js +0 -26
- package/dist/lib/observability/utils/spanSerializer.d.ts +0 -119
- package/dist/lib/observability/utils/spanSerializer.js +0 -314
- package/dist/lib/processors/archive/ArchiveProcessor.d.ts +0 -323
- package/dist/lib/processors/archive/ArchiveProcessor.js +0 -1662
- package/dist/lib/processors/archive/index.d.ts +0 -33
- package/dist/lib/processors/archive/index.js +0 -44
- package/dist/lib/processors/archive/zipEntryReader.d.ts +0 -51
- package/dist/lib/processors/archive/zipEntryReader.js +0 -81
- package/dist/lib/processors/base/BaseFileProcessor.d.ts +0 -309
- package/dist/lib/processors/base/BaseFileProcessor.js +0 -769
- package/dist/lib/processors/base/index.d.ts +0 -13
- package/dist/lib/processors/base/index.js +0 -23
- package/dist/lib/processors/cli/fileProcessorCli.d.ts +0 -124
- package/dist/lib/processors/cli/fileProcessorCli.js +0 -392
- package/dist/lib/processors/cli/index.d.ts +0 -36
- package/dist/lib/processors/cli/index.js +0 -53
- package/dist/lib/processors/code/ConfigProcessor.d.ts +0 -169
- package/dist/lib/processors/code/ConfigProcessor.js +0 -405
- package/dist/lib/processors/code/SourceCodeProcessor.d.ts +0 -172
- package/dist/lib/processors/code/SourceCodeProcessor.js +0 -309
- package/dist/lib/processors/code/index.d.ts +0 -44
- package/dist/lib/processors/code/index.js +0 -65
- package/dist/lib/processors/config/fileExtensions.d.ts +0 -280
- package/dist/lib/processors/config/fileExtensions.js +0 -485
- package/dist/lib/processors/config/fileTypeRegistry.d.ts +0 -106
- package/dist/lib/processors/config/fileTypeRegistry.js +0 -702
- package/dist/lib/processors/config/index.d.ts +0 -33
- package/dist/lib/processors/config/index.js +0 -104
- package/dist/lib/processors/config/languageMap.d.ts +0 -62
- package/dist/lib/processors/config/languageMap.js +0 -414
- package/dist/lib/processors/config/mimeConstants.d.ts +0 -373
- package/dist/lib/processors/config/mimeConstants.js +0 -348
- package/dist/lib/processors/config/sizeLimits.d.ts +0 -198
- package/dist/lib/processors/config/sizeLimits.js +0 -262
- package/dist/lib/processors/data/JsonProcessor.d.ts +0 -120
- package/dist/lib/processors/data/JsonProcessor.js +0 -206
- package/dist/lib/processors/data/XmlProcessor.d.ts +0 -158
- package/dist/lib/processors/data/XmlProcessor.js +0 -288
- package/dist/lib/processors/data/YamlProcessor.d.ts +0 -161
- package/dist/lib/processors/data/YamlProcessor.js +0 -297
- package/dist/lib/processors/data/index.d.ts +0 -49
- package/dist/lib/processors/data/index.js +0 -83
- package/dist/lib/processors/document/ExcelProcessor.d.ts +0 -250
- package/dist/lib/processors/document/ExcelProcessor.js +0 -615
- package/dist/lib/processors/document/OpenDocumentProcessor.d.ts +0 -67
- package/dist/lib/processors/document/OpenDocumentProcessor.js +0 -236
- package/dist/lib/processors/document/PptxProcessor.d.ts +0 -77
- package/dist/lib/processors/document/PptxProcessor.js +0 -262
- package/dist/lib/processors/document/RtfProcessor.d.ts +0 -150
- package/dist/lib/processors/document/RtfProcessor.js +0 -364
- package/dist/lib/processors/document/WordProcessor.d.ts +0 -166
- package/dist/lib/processors/document/WordProcessor.js +0 -365
- package/dist/lib/processors/document/index.d.ts +0 -55
- package/dist/lib/processors/document/index.js +0 -100
- package/dist/lib/processors/errors/FileErrorCode.d.ts +0 -86
- package/dist/lib/processors/errors/FileErrorCode.js +0 -256
- package/dist/lib/processors/errors/errorHelpers.d.ts +0 -121
- package/dist/lib/processors/errors/errorHelpers.js +0 -387
- package/dist/lib/processors/errors/errorSerializer.d.ts +0 -96
- package/dist/lib/processors/errors/errorSerializer.js +0 -508
- package/dist/lib/processors/errors/index.d.ts +0 -46
- package/dist/lib/processors/errors/index.js +0 -50
- package/dist/lib/processors/index.d.ts +0 -79
- package/dist/lib/processors/index.js +0 -133
- package/dist/lib/processors/integration/FileProcessorIntegration.d.ts +0 -176
- package/dist/lib/processors/integration/FileProcessorIntegration.js +0 -279
- package/dist/lib/processors/integration/index.d.ts +0 -41
- package/dist/lib/processors/integration/index.js +0 -48
- package/dist/lib/processors/markup/HtmlProcessor.d.ts +0 -167
- package/dist/lib/processors/markup/HtmlProcessor.js +0 -252
- package/dist/lib/processors/markup/MarkdownProcessor.d.ts +0 -163
- package/dist/lib/processors/markup/MarkdownProcessor.js +0 -249
- package/dist/lib/processors/markup/SvgProcessor.d.ts +0 -154
- package/dist/lib/processors/markup/SvgProcessor.js +0 -245
- package/dist/lib/processors/markup/TextProcessor.d.ts +0 -133
- package/dist/lib/processors/markup/TextProcessor.js +0 -191
- package/dist/lib/processors/markup/index.d.ts +0 -66
- package/dist/lib/processors/markup/index.js +0 -111
- package/dist/lib/processors/media/AudioProcessor.d.ts +0 -266
- package/dist/lib/processors/media/AudioProcessor.js +0 -712
- package/dist/lib/processors/media/VideoProcessor.d.ts +0 -337
- package/dist/lib/processors/media/VideoProcessor.js +0 -1154
- package/dist/lib/processors/media/index.d.ts +0 -26
- package/dist/lib/processors/media/index.js +0 -30
- package/dist/lib/processors/registry/ProcessorRegistry.d.ts +0 -347
- package/dist/lib/processors/registry/ProcessorRegistry.js +0 -715
- package/dist/lib/processors/registry/index.d.ts +0 -2
- package/dist/lib/processors/registry/index.js +0 -10
- package/dist/lib/providers/amazonBedrock/client.d.ts +0 -93
- package/dist/lib/providers/amazonBedrock/client.js +0 -1178
- package/dist/lib/providers/amazonBedrock/constants.d.ts +0 -1
- package/dist/lib/providers/amazonBedrock/constants.js +0 -3
- package/dist/lib/providers/amazonBedrock/index.d.ts +0 -3
- package/dist/lib/providers/amazonBedrock/index.js +0 -4
- package/dist/lib/providers/amazonBedrock/inferenceProfile.d.ts +0 -72
- package/dist/lib/providers/amazonBedrock/inferenceProfile.js +0 -186
- package/dist/lib/providers/amazonBedrock/loopAdapter.d.ts +0 -36
- package/dist/lib/providers/amazonBedrock/loopAdapter.js +0 -278
- package/dist/lib/providers/amazonBedrock/utils.d.ts +0 -1
- package/dist/lib/providers/amazonBedrock/utils.js +0 -4
- package/dist/lib/providers/amazonSagemaker.d.ts +0 -108
- package/dist/lib/providers/amazonSagemaker.js +0 -292
- package/dist/lib/providers/anthropic/cacheControl.d.ts +0 -12
- package/dist/lib/providers/anthropic/cacheControl.js +0 -15
- package/dist/lib/providers/anthropic/client.d.ts +0 -149
- package/dist/lib/providers/anthropic/client.js +0 -1862
- package/dist/lib/providers/anthropic/constants.d.ts +0 -3
- package/dist/lib/providers/anthropic/constants.js +0 -7
- package/dist/lib/providers/anthropic/index.d.ts +0 -2
- package/dist/lib/providers/anthropic/index.js +0 -3
- package/dist/lib/providers/anthropic/loopAdapter.d.ts +0 -26
- package/dist/lib/providers/anthropic/loopAdapter.js +0 -326
- package/dist/lib/providers/anthropic/rateLimitCapture.d.ts +0 -82
- package/dist/lib/providers/anthropic/rateLimitCapture.js +0 -375
- package/dist/lib/providers/anthropic/structuredOutput.d.ts +0 -58
- package/dist/lib/providers/anthropic/structuredOutput.js +0 -98
- package/dist/lib/providers/anthropic/toolOutput.d.ts +0 -9
- package/dist/lib/providers/anthropic/toolOutput.js +0 -39
- package/dist/lib/providers/anthropicImageBlocks.d.ts +0 -47
- package/dist/lib/providers/anthropicImageBlocks.js +0 -223
- package/dist/lib/providers/azureOpenai.d.ts +0 -67
- package/dist/lib/providers/azureOpenai.js +0 -230
- package/dist/lib/providers/cohere.d.ts +0 -54
- package/dist/lib/providers/cohere.js +0 -183
- package/dist/lib/providers/configuredOpenAICompat.d.ts +0 -24
- package/dist/lib/providers/configuredOpenAICompat.js +0 -67
- package/dist/lib/providers/deepseek.d.ts +0 -47
- package/dist/lib/providers/deepseek.js +0 -121
- package/dist/lib/providers/googleAiStudio/client.d.ts +0 -92
- package/dist/lib/providers/googleAiStudio/client.js +0 -1661
- package/dist/lib/providers/googleAiStudio/index.d.ts +0 -1
- package/dist/lib/providers/googleAiStudio/index.js +0 -2
- package/dist/lib/providers/googleNativeGemini3/index.d.ts +0 -1
- package/dist/lib/providers/googleNativeGemini3/index.js +0 -2
- package/dist/lib/providers/googleNativeGemini3/utils.d.ts +0 -482
- package/dist/lib/providers/googleNativeGemini3/utils.js +0 -1527
- package/dist/lib/providers/googleVertex/client.d.ts +0 -415
- package/dist/lib/providers/googleVertex/client.js +0 -7018
- package/dist/lib/providers/googleVertex/constants.d.ts +0 -5
- package/dist/lib/providers/googleVertex/constants.js +0 -27
- package/dist/lib/providers/googleVertex/index.d.ts +0 -3
- package/dist/lib/providers/googleVertex/index.js +0 -4
- package/dist/lib/providers/googleVertex/utils.d.ts +0 -12
- package/dist/lib/providers/googleVertex/utils.js +0 -287
- package/dist/lib/providers/huggingFace/client.d.ts +0 -31
- package/dist/lib/providers/huggingFace/client.js +0 -103
- package/dist/lib/providers/huggingFace/index.d.ts +0 -1
- package/dist/lib/providers/huggingFace/index.js +0 -2
- package/dist/lib/providers/ideogram.d.ts +0 -34
- package/dist/lib/providers/ideogram.js +0 -184
- package/dist/lib/providers/jina.d.ts +0 -58
- package/dist/lib/providers/jina.js +0 -217
- package/dist/lib/providers/litellm/client.d.ts +0 -84
- package/dist/lib/providers/litellm/client.js +0 -504
- package/dist/lib/providers/litellm/index.d.ts +0 -1
- package/dist/lib/providers/litellm/index.js +0 -2
- package/dist/lib/providers/llamaCpp.d.ts +0 -24
- package/dist/lib/providers/llamaCpp.js +0 -80
- package/dist/lib/providers/lmStudio.d.ts +0 -29
- package/dist/lib/providers/lmStudio.js +0 -88
- package/dist/lib/providers/nvidiaNim/client.d.ts +0 -60
- package/dist/lib/providers/nvidiaNim/client.js +0 -291
- package/dist/lib/providers/nvidiaNim/constants.d.ts +0 -1
- package/dist/lib/providers/nvidiaNim/constants.js +0 -2
- package/dist/lib/providers/nvidiaNim/index.d.ts +0 -2
- package/dist/lib/providers/nvidiaNim/index.js +0 -3
- package/dist/lib/providers/ollama/client.d.ts +0 -71
- package/dist/lib/providers/ollama/client.js +0 -283
- package/dist/lib/providers/ollama/constants.d.ts +0 -4
- package/dist/lib/providers/ollama/constants.js +0 -6
- package/dist/lib/providers/ollama/index.d.ts +0 -2
- package/dist/lib/providers/ollama/index.js +0 -3
- package/dist/lib/providers/openAI/client.d.ts +0 -76
- package/dist/lib/providers/openAI/client.js +0 -503
- package/dist/lib/providers/openAI/index.d.ts +0 -1
- package/dist/lib/providers/openAI/index.js +0 -2
- package/dist/lib/providers/openRouter/client.d.ts +0 -75
- package/dist/lib/providers/openRouter/client.js +0 -402
- package/dist/lib/providers/openRouter/constants.d.ts +0 -1
- package/dist/lib/providers/openRouter/constants.js +0 -2
- package/dist/lib/providers/openRouter/index.d.ts +0 -3
- package/dist/lib/providers/openRouter/index.js +0 -4
- package/dist/lib/providers/openRouter/utils.d.ts +0 -1
- package/dist/lib/providers/openRouter/utils.js +0 -6
- package/dist/lib/providers/openaiChatCompletionsBase.d.ts +0 -212
- package/dist/lib/providers/openaiChatCompletionsBase.js +0 -1154
- package/dist/lib/providers/openaiChatCompletionsClient.d.ts +0 -70
- package/dist/lib/providers/openaiChatCompletionsClient.js +0 -684
- package/dist/lib/providers/openaiCompatCatalog.d.ts +0 -24
- package/dist/lib/providers/openaiCompatCatalog.js +0 -270
- package/dist/lib/providers/openaiCompatible/client.d.ts +0 -21
- package/dist/lib/providers/openaiCompatible/client.js +0 -91
- package/dist/lib/providers/openaiCompatible/constants.d.ts +0 -1
- package/dist/lib/providers/openaiCompatible/constants.js +0 -2
- package/dist/lib/providers/openaiCompatible/index.d.ts +0 -3
- package/dist/lib/providers/openaiCompatible/index.js +0 -4
- package/dist/lib/providers/openaiCompatible/utils.d.ts +0 -5
- package/dist/lib/providers/openaiCompatible/utils.js +0 -17
- package/dist/lib/providers/providerTypeUtils.d.ts +0 -23
- package/dist/lib/providers/providerTypeUtils.js +0 -41
- package/dist/lib/providers/recraft.d.ts +0 -34
- package/dist/lib/providers/recraft.js +0 -197
- package/dist/lib/providers/replicate.d.ts +0 -74
- package/dist/lib/providers/replicate.js +0 -416
- package/dist/lib/providers/sagemaker/adaptive-semaphore.d.ts +0 -74
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +0 -216
- package/dist/lib/providers/sagemaker/client.d.ts +0 -161
- package/dist/lib/providers/sagemaker/client.js +0 -509
- package/dist/lib/providers/sagemaker/config.d.ts +0 -87
- package/dist/lib/providers/sagemaker/config.js +0 -355
- package/dist/lib/providers/sagemaker/detection.d.ts +0 -121
- package/dist/lib/providers/sagemaker/detection.js +0 -607
- package/dist/lib/providers/sagemaker/diagnostics.d.ts +0 -14
- package/dist/lib/providers/sagemaker/diagnostics.js +0 -138
- package/dist/lib/providers/sagemaker/error-constants.d.ts +0 -78
- package/dist/lib/providers/sagemaker/error-constants.js +0 -228
- package/dist/lib/providers/sagemaker/errors.d.ts +0 -90
- package/dist/lib/providers/sagemaker/errors.js +0 -301
- package/dist/lib/providers/sagemaker/index.d.ts +0 -34
- package/dist/lib/providers/sagemaker/index.js +0 -69
- package/dist/lib/providers/sagemaker/language-model.d.ts +0 -207
- package/dist/lib/providers/sagemaker/language-model.js +0 -805
- package/dist/lib/providers/sagemaker/parsers.d.ts +0 -111
- package/dist/lib/providers/sagemaker/parsers.js +0 -644
- package/dist/lib/providers/sagemaker/streaming.d.ts +0 -48
- package/dist/lib/providers/sagemaker/streaming.js +0 -390
- package/dist/lib/providers/sagemaker/structured-parser.d.ts +0 -117
- package/dist/lib/providers/sagemaker/structured-parser.js +0 -626
- package/dist/lib/providers/stability.d.ts +0 -37
- package/dist/lib/providers/stability.js +0 -191
- package/dist/lib/providers/voyage.d.ts +0 -46
- package/dist/lib/providers/voyage.js +0 -176
- package/dist/lib/proxy/accountCooldown.d.ts +0 -5
- package/dist/lib/proxy/accountCooldown.js +0 -121
- package/dist/lib/proxy/accountQuota.d.ts +0 -84
- package/dist/lib/proxy/accountQuota.js +0 -459
- package/dist/lib/proxy/accountQuotaRefreshCoordinator.d.ts +0 -19
- package/dist/lib/proxy/accountQuotaRefreshCoordinator.js +0 -105
- package/dist/lib/proxy/accountSelection.d.ts +0 -8
- package/dist/lib/proxy/accountSelection.js +0 -26
- package/dist/lib/proxy/accountUsage.d.ts +0 -45
- package/dist/lib/proxy/accountUsage.js +0 -302
- package/dist/lib/proxy/awsProxyIntegration.d.ts +0 -23
- package/dist/lib/proxy/awsProxyIntegration.js +0 -286
- package/dist/lib/proxy/claudeFormat.d.ts +0 -129
- package/dist/lib/proxy/claudeFormat.js +0 -600
- package/dist/lib/proxy/cloaking/index.d.ts +0 -43
- package/dist/lib/proxy/cloaking/index.js +0 -88
- package/dist/lib/proxy/cloaking/plugins/headerScrubber.d.ts +0 -9
- package/dist/lib/proxy/cloaking/plugins/headerScrubber.js +0 -87
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.d.ts +0 -11
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.js +0 -42
- package/dist/lib/proxy/cloaking/plugins/systemPromptInjector.d.ts +0 -11
- package/dist/lib/proxy/cloaking/plugins/systemPromptInjector.js +0 -84
- package/dist/lib/proxy/cloaking/plugins/tlsFingerprint.d.ts +0 -14
- package/dist/lib/proxy/cloaking/plugins/tlsFingerprint.js +0 -39
- package/dist/lib/proxy/cloaking/plugins/wordObfuscator.d.ts +0 -9
- package/dist/lib/proxy/cloaking/plugins/wordObfuscator.js +0 -122
- package/dist/lib/proxy/codexAccountUsage.d.ts +0 -26
- package/dist/lib/proxy/codexAccountUsage.js +0 -174
- package/dist/lib/proxy/codexUsage.d.ts +0 -68
- package/dist/lib/proxy/codexUsage.js +0 -247
- package/dist/lib/proxy/globalInstaller.d.ts +0 -19
- package/dist/lib/proxy/globalInstaller.js +0 -242
- package/dist/lib/proxy/logCleanupScheduler.d.ts +0 -12
- package/dist/lib/proxy/logCleanupScheduler.js +0 -74
- package/dist/lib/proxy/logCleanupWorkerEntry.d.ts +0 -1
- package/dist/lib/proxy/logCleanupWorkerEntry.js +0 -15
- package/dist/lib/proxy/modelRouter.d.ts +0 -34
- package/dist/lib/proxy/modelRouter.js +0 -74
- package/dist/lib/proxy/oauthFetch.d.ts +0 -36
- package/dist/lib/proxy/oauthFetch.js +0 -353
- package/dist/lib/proxy/openaiFormat.d.ts +0 -139
- package/dist/lib/proxy/openaiFormat.js +0 -817
- package/dist/lib/proxy/providerTransportCoordinator.d.ts +0 -17
- package/dist/lib/proxy/providerTransportCoordinator.js +0 -156
- package/dist/lib/proxy/proxyActivity.d.ts +0 -8
- package/dist/lib/proxy/proxyActivity.js +0 -117
- package/dist/lib/proxy/proxyAnalysis.d.ts +0 -3
- package/dist/lib/proxy/proxyAnalysis.js +0 -985
- package/dist/lib/proxy/proxyConfig.d.ts +0 -42
- package/dist/lib/proxy/proxyConfig.js +0 -700
- package/dist/lib/proxy/proxyDispatcher.d.ts +0 -5
- package/dist/lib/proxy/proxyDispatcher.js +0 -61
- package/dist/lib/proxy/proxyEnv.d.ts +0 -3
- package/dist/lib/proxy/proxyEnv.js +0 -73
- package/dist/lib/proxy/proxyFetch.d.ts +0 -50
- package/dist/lib/proxy/proxyFetch.js +0 -729
- package/dist/lib/proxy/proxyHealth.d.ts +0 -20
- package/dist/lib/proxy/proxyHealth.js +0 -76
- package/dist/lib/proxy/proxyLifecycle.d.ts +0 -13
- package/dist/lib/proxy/proxyLifecycle.js +0 -383
- package/dist/lib/proxy/proxyPaths.d.ts +0 -17
- package/dist/lib/proxy/proxyPaths.js +0 -42
- package/dist/lib/proxy/proxyReplay.d.ts +0 -10
- package/dist/lib/proxy/proxyReplay.js +0 -765
- package/dist/lib/proxy/proxyTracer.d.ts +0 -128
- package/dist/lib/proxy/proxyTracer.js +0 -748
- package/dist/lib/proxy/proxyTranslationEngine.d.ts +0 -125
- package/dist/lib/proxy/proxyTranslationEngine.js +0 -740
- package/dist/lib/proxy/quietDetector.d.ts +0 -17
- package/dist/lib/proxy/quietDetector.js +0 -125
- package/dist/lib/proxy/quotaHeaders.d.ts +0 -73
- package/dist/lib/proxy/quotaHeaders.js +0 -189
- package/dist/lib/proxy/rawStreamCapture.d.ts +0 -2
- package/dist/lib/proxy/rawStreamCapture.js +0 -129
- package/dist/lib/proxy/requestLogger.d.ts +0 -78
- package/dist/lib/proxy/requestLogger.js +0 -770
- package/dist/lib/proxy/rollingProxyServer.d.ts +0 -3
- package/dist/lib/proxy/rollingProxyServer.js +0 -220
- package/dist/lib/proxy/rollingWorkerProcess.d.ts +0 -2
- package/dist/lib/proxy/rollingWorkerProcess.js +0 -199
- package/dist/lib/proxy/rollingWorkerProtocol.d.ts +0 -5
- package/dist/lib/proxy/rollingWorkerProtocol.js +0 -46
- package/dist/lib/proxy/rollingWorkerSupervisor.d.ts +0 -44
- package/dist/lib/proxy/rollingWorkerSupervisor.js +0 -530
- package/dist/lib/proxy/routingEvidence.d.ts +0 -17
- package/dist/lib/proxy/routingEvidence.js +0 -59
- package/dist/lib/proxy/routingPolicy.d.ts +0 -19
- package/dist/lib/proxy/routingPolicy.js +0 -75
- package/dist/lib/proxy/runtimeConfig.d.ts +0 -27
- package/dist/lib/proxy/runtimeConfig.js +0 -448
- package/dist/lib/proxy/snapshotPersistence.d.ts +0 -2
- package/dist/lib/proxy/snapshotPersistence.js +0 -41
- package/dist/lib/proxy/socketWorkerRuntime.d.ts +0 -14
- package/dist/lib/proxy/socketWorkerRuntime.js +0 -322
- package/dist/lib/proxy/sseInterceptor.d.ts +0 -41
- package/dist/lib/proxy/sseInterceptor.js +0 -496
- package/dist/lib/proxy/streamOutcome.d.ts +0 -5
- package/dist/lib/proxy/streamOutcome.js +0 -104
- package/dist/lib/proxy/systemRelocation.d.ts +0 -21
- package/dist/lib/proxy/systemRelocation.js +0 -51
- package/dist/lib/proxy/tokenRefresh.d.ts +0 -18
- package/dist/lib/proxy/tokenRefresh.js +0 -257
- package/dist/lib/proxy/updateChecker.d.ts +0 -17
- package/dist/lib/proxy/updateChecker.js +0 -98
- package/dist/lib/proxy/updateCoordinator.d.ts +0 -7
- package/dist/lib/proxy/updateCoordinator.js +0 -60
- package/dist/lib/proxy/updateState.d.ts +0 -69
- package/dist/lib/proxy/updateState.js +0 -309
- package/dist/lib/proxy/updaterSupervisor.d.ts +0 -3
- package/dist/lib/proxy/updaterSupervisor.js +0 -58
- package/dist/lib/proxy/usageStats.d.ts +0 -91
- package/dist/lib/proxy/usageStats.js +0 -1154
- package/dist/lib/proxy/utils/noProxyUtils.d.ts +0 -39
- package/dist/lib/proxy/utils/noProxyUtils.js +0 -150
- package/dist/lib/proxy/workerLog.d.ts +0 -6
- package/dist/lib/proxy/workerLog.js +0 -42
- package/dist/lib/rag/ChunkerFactory.d.ts +0 -91
- package/dist/lib/rag/ChunkerFactory.js +0 -321
- package/dist/lib/rag/ChunkerRegistry.d.ts +0 -91
- package/dist/lib/rag/ChunkerRegistry.js +0 -422
- package/dist/lib/rag/chunkers/BaseChunker.d.ts +0 -53
- package/dist/lib/rag/chunkers/BaseChunker.js +0 -158
- package/dist/lib/rag/chunkers/CharacterChunker.d.ts +0 -18
- package/dist/lib/rag/chunkers/CharacterChunker.js +0 -29
- package/dist/lib/rag/chunkers/HTMLChunker.d.ts +0 -19
- package/dist/lib/rag/chunkers/HTMLChunker.js +0 -39
- package/dist/lib/rag/chunkers/JSONChunker.d.ts +0 -19
- package/dist/lib/rag/chunkers/JSONChunker.js +0 -69
- package/dist/lib/rag/chunkers/LaTeXChunker.d.ts +0 -15
- package/dist/lib/rag/chunkers/LaTeXChunker.js +0 -64
- package/dist/lib/rag/chunkers/MarkdownChunker.d.ts +0 -37
- package/dist/lib/rag/chunkers/MarkdownChunker.js +0 -315
- package/dist/lib/rag/chunkers/RecursiveChunker.d.ts +0 -27
- package/dist/lib/rag/chunkers/RecursiveChunker.js +0 -140
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.d.ts +0 -22
- package/dist/lib/rag/chunkers/SemanticMarkdownChunker.js +0 -139
- package/dist/lib/rag/chunkers/SentenceChunker.d.ts +0 -19
- package/dist/lib/rag/chunkers/SentenceChunker.js +0 -67
- package/dist/lib/rag/chunkers/TokenChunker.d.ts +0 -19
- package/dist/lib/rag/chunkers/TokenChunker.js +0 -62
- package/dist/lib/rag/chunkers/index.d.ts +0 -15
- package/dist/lib/rag/chunkers/index.js +0 -16
- package/dist/lib/rag/chunking/characterChunker.d.ts +0 -16
- package/dist/lib/rag/chunking/characterChunker.js +0 -143
- package/dist/lib/rag/chunking/chunkerRegistry.d.ts +0 -67
- package/dist/lib/rag/chunking/chunkerRegistry.js +0 -195
- package/dist/lib/rag/chunking/htmlChunker.d.ts +0 -34
- package/dist/lib/rag/chunking/htmlChunker.js +0 -248
- package/dist/lib/rag/chunking/index.d.ts +0 -15
- package/dist/lib/rag/chunking/index.js +0 -18
- package/dist/lib/rag/chunking/jsonChunker.d.ts +0 -20
- package/dist/lib/rag/chunking/jsonChunker.js +0 -282
- package/dist/lib/rag/chunking/latexChunker.d.ts +0 -26
- package/dist/lib/rag/chunking/latexChunker.js +0 -252
- package/dist/lib/rag/chunking/markdownChunker.d.ts +0 -35
- package/dist/lib/rag/chunking/markdownChunker.js +0 -383
- package/dist/lib/rag/chunking/recursiveChunker.d.ts +0 -19
- package/dist/lib/rag/chunking/recursiveChunker.js +0 -149
- package/dist/lib/rag/chunking/semanticChunker.d.ts +0 -41
- package/dist/lib/rag/chunking/semanticChunker.js +0 -306
- package/dist/lib/rag/chunking/sentenceChunker.d.ts +0 -25
- package/dist/lib/rag/chunking/sentenceChunker.js +0 -231
- package/dist/lib/rag/chunking/tokenChunker.d.ts +0 -36
- package/dist/lib/rag/chunking/tokenChunker.js +0 -184
- package/dist/lib/rag/document/MDocument.d.ts +0 -198
- package/dist/lib/rag/document/MDocument.js +0 -392
- package/dist/lib/rag/document/index.d.ts +0 -5
- package/dist/lib/rag/document/index.js +0 -6
- package/dist/lib/rag/document/loaders.d.ts +0 -142
- package/dist/lib/rag/document/loaders.js +0 -544
- package/dist/lib/rag/errors/RAGError.d.ts +0 -244
- package/dist/lib/rag/errors/RAGError.js +0 -275
- package/dist/lib/rag/errors/index.d.ts +0 -6
- package/dist/lib/rag/errors/index.js +0 -7
- package/dist/lib/rag/graphRag/graphRAG.d.ts +0 -115
- package/dist/lib/rag/graphRag/graphRAG.js +0 -402
- package/dist/lib/rag/graphRag/index.d.ts +0 -4
- package/dist/lib/rag/graphRag/index.js +0 -5
- package/dist/lib/rag/index.d.ts +0 -104
- package/dist/lib/rag/index.js +0 -144
- package/dist/lib/rag/metadata/MetadataExtractorFactory.d.ts +0 -103
- package/dist/lib/rag/metadata/MetadataExtractorFactory.js +0 -419
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.d.ts +0 -99
- package/dist/lib/rag/metadata/MetadataExtractorRegistry.js +0 -363
- package/dist/lib/rag/metadata/index.d.ts +0 -6
- package/dist/lib/rag/metadata/index.js +0 -10
- package/dist/lib/rag/metadata/metadataExtractor.d.ts +0 -69
- package/dist/lib/rag/metadata/metadataExtractor.js +0 -281
- package/dist/lib/rag/pipeline/RAGPipeline.d.ts +0 -105
- package/dist/lib/rag/pipeline/RAGPipeline.js +0 -436
- package/dist/lib/rag/pipeline/contextAssembly.d.ts +0 -80
- package/dist/lib/rag/pipeline/contextAssembly.js +0 -342
- package/dist/lib/rag/pipeline/index.d.ts +0 -5
- package/dist/lib/rag/pipeline/index.js +0 -6
- package/dist/lib/rag/ragIntegration.d.ts +0 -30
- package/dist/lib/rag/ragIntegration.js +0 -327
- package/dist/lib/rag/reranker/RerankerFactory.d.ts +0 -124
- package/dist/lib/rag/reranker/RerankerFactory.js +0 -431
- package/dist/lib/rag/reranker/RerankerRegistry.d.ts +0 -119
- package/dist/lib/rag/reranker/RerankerRegistry.js +0 -403
- package/dist/lib/rag/reranker/index.d.ts +0 -6
- package/dist/lib/rag/reranker/index.js +0 -10
- package/dist/lib/rag/reranker/reranker.d.ts +0 -70
- package/dist/lib/rag/reranker/reranker.js +0 -307
- package/dist/lib/rag/resilience/CircuitBreaker.d.ts +0 -142
- package/dist/lib/rag/resilience/CircuitBreaker.js +0 -432
- package/dist/lib/rag/resilience/RetryHandler.d.ts +0 -95
- package/dist/lib/rag/resilience/RetryHandler.js +0 -305
- package/dist/lib/rag/resilience/index.d.ts +0 -7
- package/dist/lib/rag/resilience/index.js +0 -8
- package/dist/lib/rag/retrieval/hybridSearch.d.ts +0 -53
- package/dist/lib/rag/retrieval/hybridSearch.js +0 -339
- package/dist/lib/rag/retrieval/index.d.ts +0 -5
- package/dist/lib/rag/retrieval/index.js +0 -6
- package/dist/lib/rag/retrieval/vectorQueryTool.d.ts +0 -72
- package/dist/lib/rag/retrieval/vectorQueryTool.js +0 -325
- package/dist/lib/rag/stores/chroma.d.ts +0 -90
- package/dist/lib/rag/stores/chroma.js +0 -281
- package/dist/lib/rag/stores/index.d.ts +0 -21
- package/dist/lib/rag/stores/index.js +0 -22
- package/dist/lib/rag/stores/pgvector.d.ts +0 -95
- package/dist/lib/rag/stores/pgvector.js +0 -400
- package/dist/lib/rag/stores/pinecone.d.ts +0 -85
- package/dist/lib/rag/stores/pinecone.js +0 -159
- package/dist/lib/routing/classifierRouter.d.ts +0 -52
- package/dist/lib/routing/classifierRouter.js +0 -269
- package/dist/lib/routing/classifierStrategies.d.ts +0 -23
- package/dist/lib/routing/classifierStrategies.js +0 -156
- package/dist/lib/routing/index.d.ts +0 -9
- package/dist/lib/routing/index.js +0 -10
- package/dist/lib/routing/modelPool.d.ts +0 -83
- package/dist/lib/routing/modelPool.js +0 -243
- package/dist/lib/routing/requestRouter.d.ts +0 -30
- package/dist/lib/routing/requestRouter.js +0 -81
- package/dist/lib/sdk/toolRegistration.d.ts +0 -74
- package/dist/lib/sdk/toolRegistration.js +0 -383
- package/dist/lib/server/abstract/baseServerAdapter.d.ts +0 -171
- package/dist/lib/server/abstract/baseServerAdapter.js +0 -575
- package/dist/lib/server/adapters/expressAdapter.d.ts +0 -70
- package/dist/lib/server/adapters/expressAdapter.js +0 -487
- package/dist/lib/server/adapters/fastifyAdapter.d.ts +0 -70
- package/dist/lib/server/adapters/fastifyAdapter.js +0 -473
- package/dist/lib/server/adapters/honoAdapter.d.ts +0 -77
- package/dist/lib/server/adapters/honoAdapter.js +0 -633
- package/dist/lib/server/adapters/index.d.ts +0 -7
- package/dist/lib/server/adapters/index.js +0 -8
- package/dist/lib/server/adapters/koaAdapter.d.ts +0 -79
- package/dist/lib/server/adapters/koaAdapter.js +0 -511
- package/dist/lib/server/errors.d.ts +0 -193
- package/dist/lib/server/errors.js +0 -487
- package/dist/lib/server/factory/serverAdapterFactory.d.ts +0 -73
- package/dist/lib/server/factory/serverAdapterFactory.js +0 -161
- package/dist/lib/server/index.d.ts +0 -46
- package/dist/lib/server/index.js +0 -122
- package/dist/lib/server/middleware/abortSignal.d.ts +0 -52
- package/dist/lib/server/middleware/abortSignal.js +0 -112
- package/dist/lib/server/middleware/auth.d.ts +0 -166
- package/dist/lib/server/middleware/auth.js +0 -404
- package/dist/lib/server/middleware/cache.d.ts +0 -161
- package/dist/lib/server/middleware/cache.js +0 -370
- package/dist/lib/server/middleware/common.d.ts +0 -108
- package/dist/lib/server/middleware/common.js +0 -297
- package/dist/lib/server/middleware/deprecation.d.ts +0 -40
- package/dist/lib/server/middleware/deprecation.js +0 -191
- package/dist/lib/server/middleware/index.d.ts +0 -12
- package/dist/lib/server/middleware/index.js +0 -13
- package/dist/lib/server/middleware/mcpBodyAttachment.d.ts +0 -42
- package/dist/lib/server/middleware/mcpBodyAttachment.js +0 -64
- package/dist/lib/server/middleware/rateLimit.d.ts +0 -70
- package/dist/lib/server/middleware/rateLimit.js +0 -224
- package/dist/lib/server/middleware/validation.d.ts +0 -69
- package/dist/lib/server/middleware/validation.js +0 -393
- package/dist/lib/server/openapi/generator.d.ts +0 -61
- package/dist/lib/server/openapi/generator.js +0 -399
- package/dist/lib/server/openapi/index.d.ts +0 -7
- package/dist/lib/server/openapi/index.js +0 -37
- package/dist/lib/server/openapi/schemas.d.ts +0 -94
- package/dist/lib/server/openapi/schemas.js +0 -696
- package/dist/lib/server/openapi/templates.d.ts +0 -108
- package/dist/lib/server/openapi/templates.js +0 -375
- package/dist/lib/server/routes/agentRoutes.d.ts +0 -9
- package/dist/lib/server/routes/agentRoutes.js +0 -423
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +0 -491
- package/dist/lib/server/routes/claudeProxyRoutes.js +0 -6455
- package/dist/lib/server/routes/codexProxyRoutes.d.ts +0 -64
- package/dist/lib/server/routes/codexProxyRoutes.js +0 -482
- package/dist/lib/server/routes/healthRoutes.d.ts +0 -9
- package/dist/lib/server/routes/healthRoutes.js +0 -234
- package/dist/lib/server/routes/index.d.ts +0 -25
- package/dist/lib/server/routes/index.js +0 -66
- package/dist/lib/server/routes/mcpRoutes.d.ts +0 -9
- package/dist/lib/server/routes/mcpRoutes.js +0 -376
- package/dist/lib/server/routes/memoryRoutes.d.ts +0 -11
- package/dist/lib/server/routes/memoryRoutes.js +0 -366
- package/dist/lib/server/routes/openApiRoutes.d.ts +0 -34
- package/dist/lib/server/routes/openApiRoutes.js +0 -151
- package/dist/lib/server/routes/openaiProxyRoutes.d.ts +0 -38
- package/dist/lib/server/routes/openaiProxyRoutes.js +0 -404
- package/dist/lib/server/routes/toolRoutes.d.ts +0 -9
- package/dist/lib/server/routes/toolRoutes.js +0 -272
- package/dist/lib/server/streaming/dataStream.d.ts +0 -212
- package/dist/lib/server/streaming/dataStream.js +0 -502
- package/dist/lib/server/streaming/index.d.ts +0 -5
- package/dist/lib/server/streaming/index.js +0 -17
- package/dist/lib/server/utils/redaction.d.ts +0 -68
- package/dist/lib/server/utils/redaction.js +0 -321
- package/dist/lib/server/utils/validation.d.ts +0 -153
- package/dist/lib/server/utils/validation.js +0 -265
- package/dist/lib/server/voice/frameBus.d.ts +0 -8
- package/dist/lib/server/voice/frameBus.js +0 -25
- package/dist/lib/server/voice/tokenCompare.d.ts +0 -14
- package/dist/lib/server/voice/tokenCompare.js +0 -23
- package/dist/lib/server/voice/turnManager.d.ts +0 -15
- package/dist/lib/server/voice/turnManager.js +0 -36
- package/dist/lib/server/voice/voiceServerApp.d.ts +0 -1
- package/dist/lib/server/voice/voiceServerApp.js +0 -177
- package/dist/lib/server/voice/voiceWebSocketHandler.d.ts +0 -24
- package/dist/lib/server/voice/voiceWebSocketHandler.js +0 -669
- package/dist/lib/server/websocket/WebSocketHandler.d.ts +0 -107
- package/dist/lib/server/websocket/WebSocketHandler.js +0 -384
- package/dist/lib/server/websocket/index.d.ts +0 -4
- package/dist/lib/server/websocket/index.js +0 -5
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +0 -229
- package/dist/lib/services/server/ai/observability/instrumentation.js +0 -1244
- package/dist/lib/session/globalSessionState.d.ts +0 -71
- package/dist/lib/session/globalSessionState.js +0 -235
- package/dist/lib/skills/skillMatcher.d.ts +0 -55
- package/dist/lib/skills/skillMatcher.js +0 -170
- package/dist/lib/skills/skillSessionTracker.d.ts +0 -52
- package/dist/lib/skills/skillSessionTracker.js +0 -150
- package/dist/lib/skills/skillStoreRedis.d.ts +0 -30
- package/dist/lib/skills/skillStoreRedis.js +0 -114
- package/dist/lib/skills/skillStoreS3.d.ts +0 -56
- package/dist/lib/skills/skillStoreS3.js +0 -305
- package/dist/lib/skills/skillStores.d.ts +0 -58
- package/dist/lib/skills/skillStores.js +0 -341
- package/dist/lib/skills/skillTools.d.ts +0 -35
- package/dist/lib/skills/skillTools.js +0 -451
- package/dist/lib/skills/skillsManager.d.ts +0 -78
- package/dist/lib/skills/skillsManager.js +0 -281
- package/dist/lib/tasks/autoresearchTaskExecutor.d.ts +0 -31
- package/dist/lib/tasks/autoresearchTaskExecutor.js +0 -304
- package/dist/lib/tasks/backends/bullmqBackend.d.ts +0 -33
- package/dist/lib/tasks/backends/bullmqBackend.js +0 -206
- package/dist/lib/tasks/backends/nodeTimeoutBackend.d.ts +0 -27
- package/dist/lib/tasks/backends/nodeTimeoutBackend.js +0 -141
- package/dist/lib/tasks/backends/taskBackendRegistry.d.ts +0 -31
- package/dist/lib/tasks/backends/taskBackendRegistry.js +0 -66
- package/dist/lib/tasks/errors.d.ts +0 -33
- package/dist/lib/tasks/errors.js +0 -19
- package/dist/lib/tasks/store/fileTaskStore.d.ts +0 -43
- package/dist/lib/tasks/store/fileTaskStore.js +0 -179
- package/dist/lib/tasks/store/redisTaskStore.d.ts +0 -43
- package/dist/lib/tasks/store/redisTaskStore.js +0 -222
- package/dist/lib/tasks/taskExecutor.d.ts +0 -22
- package/dist/lib/tasks/taskExecutor.js +0 -170
- package/dist/lib/tasks/taskManager.d.ts +0 -65
- package/dist/lib/tasks/taskManager.js +0 -545
- package/dist/lib/tasks/tools/taskTools.d.ts +0 -20
- package/dist/lib/tasks/tools/taskTools.js +0 -265
- package/dist/lib/telemetry/attributes.d.ts +0 -136
- package/dist/lib/telemetry/attributes.js +0 -165
- package/dist/lib/telemetry/index.d.ts +0 -20
- package/dist/lib/telemetry/index.js +0 -28
- package/dist/lib/telemetry/telemetryService.d.ts +0 -58
- package/dist/lib/telemetry/telemetryService.js +0 -387
- package/dist/lib/telemetry/traceContext.d.ts +0 -9
- package/dist/lib/telemetry/traceContext.js +0 -19
- package/dist/lib/telemetry/tracers.d.ts +0 -38
- package/dist/lib/telemetry/tracers.js +0 -40
- package/dist/lib/telemetry/withSpan.d.ts +0 -39
- package/dist/lib/telemetry/withSpan.js +0 -138
- package/dist/lib/tools/toolDiscovery.d.ts +0 -70
- package/dist/lib/tools/toolDiscovery.js +0 -303
- package/dist/lib/tools/toolGate.d.ts +0 -16
- package/dist/lib/tools/toolGate.js +0 -51
- package/dist/lib/tools/toolPolicy.d.ts +0 -40
- package/dist/lib/tools/toolPolicy.js +0 -194
- package/dist/lib/types/action.d.ts +0 -207
- package/dist/lib/types/action.js +0 -7
- package/dist/lib/types/agentNetwork.d.ts +0 -1199
- package/dist/lib/types/agentNetwork.js +0 -8
- package/dist/lib/types/aliases.d.ts +0 -368
- package/dist/lib/types/aliases.js +0 -50
- package/dist/lib/types/analytics.d.ts +0 -215
- package/dist/lib/types/analytics.js +0 -6
- package/dist/lib/types/artifact.d.ts +0 -70
- package/dist/lib/types/artifact.js +0 -11
- package/dist/lib/types/auth.d.ts +0 -1140
- package/dist/lib/types/auth.js +0 -10
- package/dist/lib/types/autoresearch.d.ts +0 -206
- package/dist/lib/types/autoresearch.js +0 -18
- package/dist/lib/types/avatar.d.ts +0 -150
- package/dist/lib/types/avatar.js +0 -20
- package/dist/lib/types/circuitBreakerErrors.d.ts +0 -30
- package/dist/lib/types/circuitBreakerErrors.js +0 -35
- package/dist/lib/types/classifierRouter.d.ts +0 -194
- package/dist/lib/types/classifierRouter.js +0 -17
- package/dist/lib/types/cli.d.ts +0 -1734
- package/dist/lib/types/cli.js +0 -22
- package/dist/lib/types/client.d.ts +0 -1287
- package/dist/lib/types/client.js +0 -11
- package/dist/lib/types/codex.d.ts +0 -95
- package/dist/lib/types/codex.js +0 -15
- package/dist/lib/types/common.d.ts +0 -434
- package/dist/lib/types/common.js +0 -52
- package/dist/lib/types/config.d.ts +0 -506
- package/dist/lib/types/config.js +0 -54
- package/dist/lib/types/content.d.ts +0 -18
- package/dist/lib/types/content.js +0 -20
- package/dist/lib/types/context.d.ts +0 -587
- package/dist/lib/types/context.js +0 -401
- package/dist/lib/types/conversation.d.ts +0 -637
- package/dist/lib/types/conversation.js +0 -48
- package/dist/lib/types/conversationMemoryInterface.d.ts +0 -59
- package/dist/lib/types/conversationMemoryInterface.js +0 -7
- package/dist/lib/types/domain.d.ts +0 -62
- package/dist/lib/types/domain.js +0 -6
- package/dist/lib/types/dynamic.d.ts +0 -110
- package/dist/lib/types/dynamic.js +0 -10
- package/dist/lib/types/elicitation.d.ts +0 -278
- package/dist/lib/types/elicitation.js +0 -11
- package/dist/lib/types/enums.d.ts +0 -9
- package/dist/lib/types/enums.js +0 -10
- package/dist/lib/types/errors.d.ts +0 -188
- package/dist/lib/types/errors.js +0 -262
- package/dist/lib/types/evaluation.d.ts +0 -647
- package/dist/lib/types/evaluation.js +0 -2
- package/dist/lib/types/evaluationProviders.d.ts +0 -104
- package/dist/lib/types/evaluationProviders.js +0 -6
- package/dist/lib/types/exporter.d.ts +0 -257
- package/dist/lib/types/exporter.js +0 -6
- package/dist/lib/types/externalMcp.d.ts +0 -349
- package/dist/lib/types/externalMcp.js +0 -7
- package/dist/lib/types/file.d.ts +0 -616
- package/dist/lib/types/file.js +0 -5
- package/dist/lib/types/fileReference.d.ts +0 -243
- package/dist/lib/types/fileReference.js +0 -22
- package/dist/lib/types/generate.d.ts +0 -1520
- package/dist/lib/types/generate.js +0 -2
- package/dist/lib/types/grounding.d.ts +0 -231
- package/dist/lib/types/grounding.js +0 -12
- package/dist/lib/types/guardrails.d.ts +0 -116
- package/dist/lib/types/guardrails.js +0 -2
- package/dist/lib/types/hitl.d.ts +0 -237
- package/dist/lib/types/hitl.js +0 -9
- package/dist/lib/types/imageGen.d.ts +0 -255
- package/dist/lib/types/imageGen.js +0 -25
- package/dist/lib/types/index.d.ts +0 -86
- package/dist/lib/types/index.js +0 -98
- package/dist/lib/types/ioProcessor.d.ts +0 -119
- package/dist/lib/types/ioProcessor.js +0 -10
- package/dist/lib/types/isolatedAgent.d.ts +0 -365
- package/dist/lib/types/isolatedAgent.js +0 -12
- package/dist/lib/types/knowledge.d.ts +0 -342
- package/dist/lib/types/knowledge.js +0 -30
- package/dist/lib/types/livekit.d.ts +0 -512
- package/dist/lib/types/livekit.js +0 -13
- package/dist/lib/types/loopEngine.d.ts +0 -306
- package/dist/lib/types/loopEngine.js +0 -2
- package/dist/lib/types/mcp.d.ts +0 -2135
- package/dist/lib/types/mcp.js +0 -6
- package/dist/lib/types/mcpOutput.d.ts +0 -40
- package/dist/lib/types/mcpOutput.js +0 -9
- package/dist/lib/types/memory.d.ts +0 -96
- package/dist/lib/types/memory.js +0 -23
- package/dist/lib/types/middleware.d.ts +0 -435
- package/dist/lib/types/middleware.js +0 -2
- package/dist/lib/types/model.d.ts +0 -342
- package/dist/lib/types/model.js +0 -32
- package/dist/lib/types/modelPool.d.ts +0 -47
- package/dist/lib/types/modelPool.js +0 -11
- package/dist/lib/types/multimodal.d.ts +0 -614
- package/dist/lib/types/multimodal.js +0 -144
- package/dist/lib/types/music.d.ts +0 -172
- package/dist/lib/types/music.js +0 -21
- package/dist/lib/types/nativeTools.d.ts +0 -16
- package/dist/lib/types/nativeTools.js +0 -2
- package/dist/lib/types/noOutputSentinel.d.ts +0 -26
- package/dist/lib/types/noOutputSentinel.js +0 -2
- package/dist/lib/types/observability.d.ts +0 -502
- package/dist/lib/types/observability.js +0 -7
- package/dist/lib/types/openaiCompatible.d.ts +0 -287
- package/dist/lib/types/openaiCompatible.js +0 -2
- package/dist/lib/types/ppt.d.ts +0 -1093
- package/dist/lib/types/ppt.js +0 -37
- package/dist/lib/types/processor.d.ts +0 -993
- package/dist/lib/types/processor.js +0 -91
- package/dist/lib/types/providers.d.ts +0 -2155
- package/dist/lib/types/providers.js +0 -112
- package/dist/lib/types/proxy.d.ts +0 -2789
- package/dist/lib/types/proxy.js +0 -17
- package/dist/lib/types/proxyClient.d.ts +0 -54
- package/dist/lib/types/proxyClient.js +0 -2
- package/dist/lib/types/rag.d.ts +0 -1332
- package/dist/lib/types/rag.js +0 -2
- package/dist/lib/types/realtime.d.ts +0 -243
- package/dist/lib/types/realtime.js +0 -70
- package/dist/lib/types/replicate.d.ts +0 -67
- package/dist/lib/types/replicate.js +0 -10
- package/dist/lib/types/requestRouter.d.ts +0 -75
- package/dist/lib/types/requestRouter.js +0 -16
- package/dist/lib/types/safeFetch.d.ts +0 -24
- package/dist/lib/types/safeFetch.js +0 -7
- package/dist/lib/types/scorer.d.ts +0 -564
- package/dist/lib/types/scorer.js +0 -6
- package/dist/lib/types/sdk.d.ts +0 -23
- package/dist/lib/types/sdk.js +0 -9
- package/dist/lib/types/server.d.ts +0 -1192
- package/dist/lib/types/server.js +0 -68
- package/dist/lib/types/service.d.ts +0 -79
- package/dist/lib/types/service.js +0 -6
- package/dist/lib/types/skills.d.ts +0 -427
- package/dist/lib/types/skills.js +0 -17
- package/dist/lib/types/span.d.ts +0 -247
- package/dist/lib/types/span.js +0 -96
- package/dist/lib/types/stream.d.ts +0 -771
- package/dist/lib/types/stream.js +0 -2
- package/dist/lib/types/streamDedup.d.ts +0 -14
- package/dist/lib/types/streamDedup.js +0 -2
- package/dist/lib/types/streaming.d.ts +0 -15
- package/dist/lib/types/streaming.js +0 -2
- package/dist/lib/types/stt.d.ts +0 -585
- package/dist/lib/types/stt.js +0 -90
- package/dist/lib/types/subscription.d.ts +0 -1064
- package/dist/lib/types/subscription.js +0 -10
- package/dist/lib/types/task.d.ts +0 -313
- package/dist/lib/types/task.js +0 -37
- package/dist/lib/types/taskClassification.d.ts +0 -52
- package/dist/lib/types/taskClassification.js +0 -6
- package/dist/lib/types/toolDedup.d.ts +0 -45
- package/dist/lib/types/toolDedup.js +0 -14
- package/dist/lib/types/toolResolution.d.ts +0 -83
- package/dist/lib/types/toolResolution.js +0 -11
- package/dist/lib/types/toolRouting.d.ts +0 -350
- package/dist/lib/types/toolRouting.js +0 -19
- package/dist/lib/types/tools.d.ts +0 -531
- package/dist/lib/types/tools.js +0 -26
- package/dist/lib/types/tts.d.ts +0 -195
- package/dist/lib/types/tts.js +0 -65
- package/dist/lib/types/utilities.d.ts +0 -310
- package/dist/lib/types/utilities.js +0 -5
- package/dist/lib/types/vectorStoreChroma.d.ts +0 -67
- package/dist/lib/types/vectorStoreChroma.js +0 -12
- package/dist/lib/types/vectorStorePinecone.d.ts +0 -48
- package/dist/lib/types/vectorStorePinecone.js +0 -12
- package/dist/lib/types/video.d.ts +0 -89
- package/dist/lib/types/video.js +0 -15
- package/dist/lib/types/voice.d.ts +0 -272
- package/dist/lib/types/voice.js +0 -137
- package/dist/lib/types/workflow.d.ts +0 -598
- package/dist/lib/types/workflow.js +0 -24
- package/dist/lib/utils/analyticsUtils.d.ts +0 -37
- package/dist/lib/utils/analyticsUtils.js +0 -110
- package/dist/lib/utils/anthropicCacheBreakpoints.d.ts +0 -43
- package/dist/lib/utils/anthropicCacheBreakpoints.js +0 -151
- package/dist/lib/utils/anthropicTraceSanitizer.d.ts +0 -7
- package/dist/lib/utils/anthropicTraceSanitizer.js +0 -26
- package/dist/lib/utils/async/delay.d.ts +0 -40
- package/dist/lib/utils/async/delay.js +0 -43
- package/dist/lib/utils/async/index.d.ts +0 -23
- package/dist/lib/utils/async/index.js +0 -24
- package/dist/lib/utils/async/retry.d.ts +0 -107
- package/dist/lib/utils/async/retry.js +0 -172
- package/dist/lib/utils/async/withTimeout.d.ts +0 -85
- package/dist/lib/utils/async/withTimeout.js +0 -144
- package/dist/lib/utils/asyncMutex.d.ts +0 -14
- package/dist/lib/utils/asyncMutex.js +0 -61
- package/dist/lib/utils/audioFormatDetector.d.ts +0 -15
- package/dist/lib/utils/audioFormatDetector.js +0 -34
- package/dist/lib/utils/avatarProcessor.d.ts +0 -78
- package/dist/lib/utils/avatarProcessor.js +0 -173
- package/dist/lib/utils/cloneOptions.d.ts +0 -36
- package/dist/lib/utils/cloneOptions.js +0 -62
- package/dist/lib/utils/conversationMemory.d.ts +0 -80
- package/dist/lib/utils/conversationMemory.js +0 -670
- package/dist/lib/utils/csvProcessor.d.ts +0 -221
- package/dist/lib/utils/csvProcessor.js +0 -1527
- package/dist/lib/utils/csvUtils.d.ts +0 -26
- package/dist/lib/utils/csvUtils.js +0 -85
- package/dist/lib/utils/errorClassifier.d.ts +0 -30
- package/dist/lib/utils/errorClassifier.js +0 -183
- package/dist/lib/utils/errorHandling.d.ts +0 -398
- package/dist/lib/utils/errorHandling.js +0 -1282
- package/dist/lib/utils/evaluationUtils.d.ts +0 -27
- package/dist/lib/utils/evaluationUtils.js +0 -132
- package/dist/lib/utils/factoryProcessing.d.ts +0 -71
- package/dist/lib/utils/factoryProcessing.js +0 -590
- package/dist/lib/utils/fileDetector.d.ts +0 -198
- package/dist/lib/utils/fileDetector.js +0 -2806
- package/dist/lib/utils/generation.d.ts +0 -8
- package/dist/lib/utils/generation.js +0 -9
- package/dist/lib/utils/generationErrors.d.ts +0 -10
- package/dist/lib/utils/generationErrors.js +0 -11
- package/dist/lib/utils/imageCache.d.ts +0 -124
- package/dist/lib/utils/imageCache.js +0 -437
- package/dist/lib/utils/imageDetection.d.ts +0 -15
- package/dist/lib/utils/imageDetection.js +0 -53
- package/dist/lib/utils/imageProcessor.d.ts +0 -296
- package/dist/lib/utils/imageProcessor.js +0 -1158
- package/dist/lib/utils/isoBmff.d.ts +0 -24
- package/dist/lib/utils/isoBmff.js +0 -83
- package/dist/lib/utils/json/coerce.d.ts +0 -30
- package/dist/lib/utils/json/coerce.js +0 -412
- package/dist/lib/utils/json/extract.d.ts +0 -112
- package/dist/lib/utils/json/extract.js +0 -299
- package/dist/lib/utils/json/index.d.ts +0 -36
- package/dist/lib/utils/json/index.js +0 -37
- package/dist/lib/utils/json/safeParse.d.ts +0 -130
- package/dist/lib/utils/json/safeParse.js +0 -191
- package/dist/lib/utils/lifecycleCallbacks.d.ts +0 -56
- package/dist/lib/utils/lifecycleCallbacks.js +0 -100
- package/dist/lib/utils/lifecycleTimeout.d.ts +0 -25
- package/dist/lib/utils/lifecycleTimeout.js +0 -39
- package/dist/lib/utils/logSanitize.d.ts +0 -285
- package/dist/lib/utils/logSanitize.js +0 -555
- package/dist/lib/utils/logger.d.ts +0 -273
- package/dist/lib/utils/logger.js +0 -516
- package/dist/lib/utils/loggingFetch.d.ts +0 -29
- package/dist/lib/utils/loggingFetch.js +0 -60
- package/dist/lib/utils/loopUtils.d.ts +0 -70
- package/dist/lib/utils/loopUtils.js +0 -263
- package/dist/lib/utils/markupSniff.d.ts +0 -37
- package/dist/lib/utils/markupSniff.js +0 -125
- package/dist/lib/utils/mcpDefaults.d.ts +0 -54
- package/dist/lib/utils/mcpDefaults.js +0 -135
- package/dist/lib/utils/mcpErrorText.d.ts +0 -37
- package/dist/lib/utils/mcpErrorText.js +0 -95
- package/dist/lib/utils/mediaDuration.d.ts +0 -23
- package/dist/lib/utils/mediaDuration.js +0 -45
- package/dist/lib/utils/messageBuilder.d.ts +0 -59
- package/dist/lib/utils/messageBuilder.js +0 -2716
- package/dist/lib/utils/mimeTypeHints.d.ts +0 -40
- package/dist/lib/utils/mimeTypeHints.js +0 -122
- package/dist/lib/utils/modelAliasResolver.d.ts +0 -17
- package/dist/lib/utils/modelAliasResolver.js +0 -55
- package/dist/lib/utils/modelChoices.d.ts +0 -75
- package/dist/lib/utils/modelChoices.js +0 -698
- package/dist/lib/utils/modelDetection.d.ts +0 -37
- package/dist/lib/utils/modelDetection.js +0 -131
- package/dist/lib/utils/modelRouter.d.ts +0 -91
- package/dist/lib/utils/modelRouter.js +0 -293
- package/dist/lib/utils/multimodalOptionsBuilder.d.ts +0 -74
- package/dist/lib/utils/multimodalOptionsBuilder.js +0 -74
- package/dist/lib/utils/musicProcessor.d.ts +0 -77
- package/dist/lib/utils/musicProcessor.js +0 -190
- package/dist/lib/utils/noOutputSentinel.d.ts +0 -67
- package/dist/lib/utils/noOutputSentinel.js +0 -180
- package/dist/lib/utils/observabilityHelpers.d.ts +0 -27
- package/dist/lib/utils/observabilityHelpers.js +0 -48
- package/dist/lib/utils/optionsConversion.d.ts +0 -47
- package/dist/lib/utils/optionsConversion.js +0 -128
- package/dist/lib/utils/optionsUtils.d.ts +0 -175
- package/dist/lib/utils/optionsUtils.js +0 -970
- package/dist/lib/utils/parameterValidation.d.ts +0 -200
- package/dist/lib/utils/parameterValidation.js +0 -981
- package/dist/lib/utils/pdfProcessor.d.ts +0 -137
- package/dist/lib/utils/pdfProcessor.js +0 -689
- package/dist/lib/utils/performance.d.ts +0 -93
- package/dist/lib/utils/performance.js +0 -223
- package/dist/lib/utils/piiDetector.d.ts +0 -24
- package/dist/lib/utils/piiDetector.js +0 -221
- package/dist/lib/utils/pricing.d.ts +0 -26
- package/dist/lib/utils/pricing.js +0 -890
- package/dist/lib/utils/promptRedaction.d.ts +0 -22
- package/dist/lib/utils/promptRedaction.js +0 -63
- package/dist/lib/utils/providerConfig.d.ts +0 -393
- package/dist/lib/utils/providerConfig.js +0 -1363
- package/dist/lib/utils/providerErrorClassification.d.ts +0 -58
- package/dist/lib/utils/providerErrorClassification.js +0 -149
- package/dist/lib/utils/providerHealth.d.ts +0 -253
- package/dist/lib/utils/providerHealth.js +0 -1479
- package/dist/lib/utils/providerRetry.d.ts +0 -68
- package/dist/lib/utils/providerRetry.js +0 -230
- package/dist/lib/utils/providerSetupMessages.d.ts +0 -8
- package/dist/lib/utils/providerSetupMessages.js +0 -122
- package/dist/lib/utils/providerUtils.d.ts +0 -38
- package/dist/lib/utils/providerUtils.js +0 -366
- package/dist/lib/utils/rateLimiter.d.ts +0 -75
- package/dist/lib/utils/rateLimiter.js +0 -201
- package/dist/lib/utils/redis.d.ts +0 -119
- package/dist/lib/utils/redis.js +0 -530
- package/dist/lib/utils/responseValidator.d.ts +0 -21
- package/dist/lib/utils/responseValidator.js +0 -354
- package/dist/lib/utils/retryAfter.d.ts +0 -7
- package/dist/lib/utils/retryAfter.js +0 -44
- package/dist/lib/utils/retryHandler.d.ts +0 -82
- package/dist/lib/utils/retryHandler.js +0 -270
- package/dist/lib/utils/retryability.d.ts +0 -27
- package/dist/lib/utils/retryability.js +0 -45
- package/dist/lib/utils/safeFetch.d.ts +0 -26
- package/dist/lib/utils/safeFetch.js +0 -121
- package/dist/lib/utils/sanitizers/filename.d.ts +0 -116
- package/dist/lib/utils/sanitizers/filename.js +0 -366
- package/dist/lib/utils/sanitizers/html.d.ts +0 -170
- package/dist/lib/utils/sanitizers/html.js +0 -326
- package/dist/lib/utils/sanitizers/index.d.ts +0 -26
- package/dist/lib/utils/sanitizers/index.js +0 -30
- package/dist/lib/utils/sanitizers/svg.d.ts +0 -71
- package/dist/lib/utils/sanitizers/svg.js +0 -482
- package/dist/lib/utils/schemaConversion.d.ts +0 -56
- package/dist/lib/utils/schemaConversion.js +0 -656
- package/dist/lib/utils/sizeGuard.d.ts +0 -34
- package/dist/lib/utils/sizeGuard.js +0 -45
- package/dist/lib/utils/ssrfGuard.d.ts +0 -60
- package/dist/lib/utils/ssrfGuard.js +0 -446
- package/dist/lib/utils/sttProcessor.d.ts +0 -125
- package/dist/lib/utils/sttProcessor.js +0 -301
- package/dist/lib/utils/systemMessages.d.ts +0 -29
- package/dist/lib/utils/systemMessages.js +0 -45
- package/dist/lib/utils/taskClassificationUtils.d.ts +0 -55
- package/dist/lib/utils/taskClassificationUtils.js +0 -150
- package/dist/lib/utils/taskClassifier.d.ts +0 -23
- package/dist/lib/utils/taskClassifier.js +0 -95
- package/dist/lib/utils/textEncoding.d.ts +0 -25
- package/dist/lib/utils/textEncoding.js +0 -141
- package/dist/lib/utils/thinkingConfig.d.ts +0 -76
- package/dist/lib/utils/thinkingConfig.js +0 -105
- package/dist/lib/utils/timeout.d.ts +0 -158
- package/dist/lib/utils/timeout.js +0 -427
- package/dist/lib/utils/tokenEstimation.d.ts +0 -90
- package/dist/lib/utils/tokenEstimation.js +0 -187
- package/dist/lib/utils/tokenLimits.d.ts +0 -53
- package/dist/lib/utils/tokenLimits.js +0 -236
- package/dist/lib/utils/tokenUtils.d.ts +0 -101
- package/dist/lib/utils/tokenUtils.js +0 -323
- package/dist/lib/utils/tool.d.ts +0 -8
- package/dist/lib/utils/tool.js +0 -9
- package/dist/lib/utils/toolCallRepair.d.ts +0 -14
- package/dist/lib/utils/toolCallRepair.js +0 -286
- package/dist/lib/utils/toolChoice.d.ts +0 -4
- package/dist/lib/utils/toolChoice.js +0 -7
- package/dist/lib/utils/toolEndEmitter.d.ts +0 -25
- package/dist/lib/utils/toolEndEmitter.js +0 -65
- package/dist/lib/utils/toolUtils.d.ts +0 -40
- package/dist/lib/utils/toolUtils.js +0 -76
- package/dist/lib/utils/transformationUtils.d.ts +0 -218
- package/dist/lib/utils/transformationUtils.js +0 -578
- package/dist/lib/utils/tripwireEvaluator.d.ts +0 -73
- package/dist/lib/utils/tripwireEvaluator.js +0 -285
- package/dist/lib/utils/tryImport.d.ts +0 -35
- package/dist/lib/utils/tryImport.js +0 -95
- package/dist/lib/utils/ttsProcessor.d.ts +0 -159
- package/dist/lib/utils/ttsProcessor.js +0 -293
- package/dist/lib/utils/typeUtils.d.ts +0 -77
- package/dist/lib/utils/typeUtils.js +0 -98
- package/dist/lib/utils/videoAnalysisProcessor.d.ts +0 -24
- package/dist/lib/utils/videoAnalysisProcessor.js +0 -61
- package/dist/lib/utils/videoProcessor.d.ts +0 -64
- package/dist/lib/utils/videoProcessor.js +0 -196
- package/dist/lib/voice/RealtimeVoiceAPI.d.ts +0 -186
- package/dist/lib/voice/RealtimeVoiceAPI.js +0 -431
- package/dist/lib/voice/audio-utils.d.ts +0 -135
- package/dist/lib/voice/audio-utils.js +0 -435
- package/dist/lib/voice/errors.d.ts +0 -123
- package/dist/lib/voice/errors.js +0 -386
- package/dist/lib/voice/index.d.ts +0 -49
- package/dist/lib/voice/index.js +0 -177
- package/dist/lib/voice/livekit/brain.d.ts +0 -21
- package/dist/lib/voice/livekit/brain.js +0 -75
- package/dist/lib/voice/livekit/config.d.ts +0 -52
- package/dist/lib/voice/livekit/config.js +0 -134
- package/dist/lib/voice/livekit/eventBridge.d.ts +0 -27
- package/dist/lib/voice/livekit/eventBridge.js +0 -360
- package/dist/lib/voice/livekit/index.d.ts +0 -22
- package/dist/lib/voice/livekit/index.js +0 -23
- package/dist/lib/voice/livekit/realtimeEventBridge.d.ts +0 -14
- package/dist/lib/voice/livekit/realtimeEventBridge.js +0 -161
- package/dist/lib/voice/livekit/realtimeMcpTools.d.ts +0 -31
- package/dist/lib/voice/livekit/realtimeMcpTools.js +0 -206
- package/dist/lib/voice/livekit/realtimeVoiceAgent.d.ts +0 -26
- package/dist/lib/voice/livekit/realtimeVoiceAgent.js +0 -365
- package/dist/lib/voice/livekit/roomContext.d.ts +0 -23
- package/dist/lib/voice/livekit/roomContext.js +0 -57
- package/dist/lib/voice/livekit/roomDispatch.d.ts +0 -24
- package/dist/lib/voice/livekit/roomDispatch.js +0 -31
- package/dist/lib/voice/livekit/schemaSanitizer.d.ts +0 -26
- package/dist/lib/voice/livekit/schemaSanitizer.js +0 -144
- package/dist/lib/voice/livekit/tokens.d.ts +0 -19
- package/dist/lib/voice/livekit/tokens.js +0 -51
- package/dist/lib/voice/livekit/vertexAuth.d.ts +0 -30
- package/dist/lib/voice/livekit/vertexAuth.js +0 -73
- package/dist/lib/voice/livekit/voiceAgent.d.ts +0 -32
- package/dist/lib/voice/livekit/voiceAgent.js +0 -425
- package/dist/lib/voice/livekit/voiceAgentWorker.d.ts +0 -29
- package/dist/lib/voice/livekit/voiceAgentWorker.js +0 -122
- package/dist/lib/voice/providers/AzureSTT.d.ts +0 -47
- package/dist/lib/voice/providers/AzureSTT.js +0 -345
- package/dist/lib/voice/providers/AzureTTS.d.ts +0 -59
- package/dist/lib/voice/providers/AzureTTS.js +0 -349
- package/dist/lib/voice/providers/CartesiaTTS.d.ts +0 -31
- package/dist/lib/voice/providers/CartesiaTTS.js +0 -189
- package/dist/lib/voice/providers/DeepgramSTT.d.ts +0 -40
- package/dist/lib/voice/providers/DeepgramSTT.js +0 -550
- package/dist/lib/voice/providers/ElevenLabsTTS.d.ts +0 -53
- package/dist/lib/voice/providers/ElevenLabsTTS.js +0 -311
- package/dist/lib/voice/providers/FishAudioTTS.d.ts +0 -27
- package/dist/lib/voice/providers/FishAudioTTS.js +0 -183
- package/dist/lib/voice/providers/GeminiLive.d.ts +0 -52
- package/dist/lib/voice/providers/GeminiLive.js +0 -372
- package/dist/lib/voice/providers/GoogleSTT.d.ts +0 -60
- package/dist/lib/voice/providers/GoogleSTT.js +0 -454
- package/dist/lib/voice/providers/OpenAIRealtime.d.ts +0 -47
- package/dist/lib/voice/providers/OpenAIRealtime.js +0 -412
- package/dist/lib/voice/providers/OpenAISTT.d.ts +0 -41
- package/dist/lib/voice/providers/OpenAISTT.js +0 -286
- package/dist/lib/voice/providers/OpenAITTS.d.ts +0 -55
- package/dist/lib/voice/providers/OpenAITTS.js +0 -285
- package/dist/lib/voice/stream-handler.d.ts +0 -166
- package/dist/lib/voice/stream-handler.js +0 -514
- package/dist/lib/workflow/LAYER-EXAMPLES.d.ts +0 -13
- package/dist/lib/workflow/LAYER-EXAMPLES.js +0 -312
- package/dist/lib/workflow/PROMPT-EXAMPLES.d.ts +0 -117
- package/dist/lib/workflow/PROMPT-EXAMPLES.js +0 -246
- package/dist/lib/workflow/config.d.ts +0 -376
- package/dist/lib/workflow/config.js +0 -399
- package/dist/lib/workflow/core/ensembleExecutor.d.ts +0 -55
- package/dist/lib/workflow/core/ensembleExecutor.js +0 -451
- package/dist/lib/workflow/core/judgeScorer.d.ts +0 -25
- package/dist/lib/workflow/core/judgeScorer.js +0 -568
- package/dist/lib/workflow/core/responseConditioner.d.ts +0 -21
- package/dist/lib/workflow/core/responseConditioner.js +0 -243
- package/dist/lib/workflow/core/workflowRegistry.d.ts +0 -72
- package/dist/lib/workflow/core/workflowRegistry.js +0 -305
- package/dist/lib/workflow/core/workflowRunner.d.ts +0 -61
- package/dist/lib/workflow/core/workflowRunner.js +0 -642
- package/dist/lib/workflow/index.d.ts +0 -21
- package/dist/lib/workflow/index.js +0 -46
- package/dist/lib/workflow/utils/workflowMetrics.d.ts +0 -74
- package/dist/lib/workflow/utils/workflowMetrics.js +0 -312
- package/dist/lib/workflow/utils/workflowValidation.d.ts +0 -29
- package/dist/lib/workflow/utils/workflowValidation.js +0 -421
- package/dist/lib/workflow/workflows/adaptiveWorkflow.d.ts +0 -72
- package/dist/lib/workflow/workflows/adaptiveWorkflow.js +0 -367
- package/dist/lib/workflow/workflows/consensusWorkflow.d.ts +0 -69
- package/dist/lib/workflow/workflows/consensusWorkflow.js +0 -193
- package/dist/lib/workflow/workflows/fallbackWorkflow.d.ts +0 -49
- package/dist/lib/workflow/workflows/fallbackWorkflow.js +0 -226
- package/dist/lib/workflow/workflows/multiJudgeWorkflow.d.ts +0 -70
- package/dist/lib/workflow/workflows/multiJudgeWorkflow.js +0 -352
- package/dist/providers/googleVertex/utils.d.ts +0 -12
- package/dist/providers/googleVertex/utils.js +0 -286
|
@@ -1,2081 +0,0 @@
|
|
|
1
|
-
import { context, SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
2
|
-
import { directAgentTools } from "../agent/directTools.js";
|
|
3
|
-
import { isImageGenerationModel } from "../core/constants.js";
|
|
4
|
-
import { MiddlewareFactory } from "../middleware/factory.js";
|
|
5
|
-
import { modelSupports } from "../models/modelRegistry.js";
|
|
6
|
-
import { ATTR, tracers } from "../telemetry/index.js";
|
|
7
|
-
import { ERROR_CODES, isAbortError, NeuroLinkError, } from "../utils/errorHandling.js";
|
|
8
|
-
import { createAnalytics as buildAnalytics } from "./analytics.js";
|
|
9
|
-
import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
|
|
10
|
-
import { duckTypedStatusCode, extractRetryAfterMsFromError, } from "../utils/providerRetry.js";
|
|
11
|
-
import { hasLifecycleErrorFired, markLifecycleErrorFired, } from "../utils/lifecycleCallbacks.js";
|
|
12
|
-
import { resolveLifecycleTimeoutMs } from "../utils/lifecycleTimeout.js";
|
|
13
|
-
import { logger } from "../utils/logger.js";
|
|
14
|
-
import { TimeoutError as AsyncTimeoutError, withTimeoutFn, } from "../utils/async/withTimeout.js";
|
|
15
|
-
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
16
|
-
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
17
|
-
import { getKeyCount, getKeysAsString } from "../utils/transformationUtils.js";
|
|
18
|
-
import { ToolExecutionRecorder, resolveToolExecutionRecords, } from "./toolExecutionRecorder.js";
|
|
19
|
-
import { TTS_ERROR_CODES, TTSProcessor } from "../utils/ttsProcessor.js";
|
|
20
|
-
import { executeVideoAnalysis, hasVideoFrames, } from "../utils/videoAnalysisProcessor.js";
|
|
21
|
-
import { dedupeTools } from "./toolDedup.js";
|
|
22
|
-
import { resolveToolPolicy, toolNameMatcher } from "../tools/toolPolicy.js";
|
|
23
|
-
import { applyToolGate } from "../tools/toolGate.js";
|
|
24
|
-
import { partitionToolsForDiscovery, isDiscoveryMetaTool, LARGE_CATALOG_WARN_THRESHOLD, } from "../tools/toolDiscovery.js";
|
|
25
|
-
import { GenerationHandler } from "./modules/GenerationHandler.js";
|
|
26
|
-
// Import modules for composition
|
|
27
|
-
import { MessageBuilder } from "./modules/MessageBuilder.js";
|
|
28
|
-
import { StreamHandler } from "./modules/StreamHandler.js";
|
|
29
|
-
import { TelemetryHandler } from "./modules/TelemetryHandler.js";
|
|
30
|
-
import { ToolsManager } from "./modules/ToolsManager.js";
|
|
31
|
-
import { Utilities } from "./modules/Utilities.js";
|
|
32
|
-
import { generateText } from "../utils/generation.js";
|
|
33
|
-
import { extractTokenUsage } from "../utils/tokenUtils.js";
|
|
34
|
-
/**
|
|
35
|
-
* Read the consumer-facing lifecycle callbacks buried inside a request's
|
|
36
|
-
* middleware blob. The parameter is `unknown` on purpose: request options
|
|
37
|
-
* arrive as several structurally-unrelated shapes (StreamOptions,
|
|
38
|
-
* TextGenerationOptions), and the lifecycle branch is an optional add-on
|
|
39
|
-
* none of them declare — a single structural view keeps the read cast-free
|
|
40
|
-
* at every call site.
|
|
41
|
-
*/
|
|
42
|
-
function getLifecycleMiddlewareConfig(options) {
|
|
43
|
-
return options?.middleware
|
|
44
|
-
?.middlewareConfig?.lifecycle?.config;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Abstract base class for all AI providers
|
|
48
|
-
* Tools are integrated as first-class citizens - always available by default
|
|
49
|
-
*/
|
|
50
|
-
export class BaseProvider {
|
|
51
|
-
// Not `readonly` because providers that auto-discover the model from a
|
|
52
|
-
// /v1/models endpoint (lm-studio, llamacpp) need to update modelName after
|
|
53
|
-
// construction so handlers (TelemetryHandler, MessageBuilder) cache the
|
|
54
|
-
// resolved name. All other providers treat this as effectively readonly.
|
|
55
|
-
modelName;
|
|
56
|
-
providerName;
|
|
57
|
-
defaultTimeout = 30000; // 30 seconds
|
|
58
|
-
middlewareOptions; // TODO(#1179): Implement global level middlewares that can be used
|
|
59
|
-
// Tools are conditionally included based on centralized configuration
|
|
60
|
-
directTools = shouldDisableBuiltinTools()
|
|
61
|
-
? {}
|
|
62
|
-
: directAgentTools;
|
|
63
|
-
mcpTools; // MCP tools loaded dynamically when available
|
|
64
|
-
customTools; // Custom tools from registerTool()
|
|
65
|
-
toolExecutor; // Tool executor from setupToolExecutor
|
|
66
|
-
sessionId;
|
|
67
|
-
userId;
|
|
68
|
-
neurolink; // Reference to actual NeuroLink instance for MCP tools
|
|
69
|
-
/** @internal Trace context propagated from NeuroLink SDK for span hierarchy */
|
|
70
|
-
_traceContext = null;
|
|
71
|
-
setTraceContext(ctx) {
|
|
72
|
-
this._traceContext = ctx;
|
|
73
|
-
}
|
|
74
|
-
// Composition modules - Single Responsibility Principle
|
|
75
|
-
// Handlers below are not `readonly` so that providers which auto-discover
|
|
76
|
-
// their model after construction (lm-studio, llamacpp) can rebuild them
|
|
77
|
-
// via `refreshHandlersForModel(...)` and propagate the resolved name into
|
|
78
|
-
// pricing / telemetry / span attributes. All other providers leave these
|
|
79
|
-
// alone.
|
|
80
|
-
messageBuilder;
|
|
81
|
-
streamHandler;
|
|
82
|
-
generationHandler;
|
|
83
|
-
telemetryHandler;
|
|
84
|
-
utilities;
|
|
85
|
-
toolsManager;
|
|
86
|
-
constructor(modelName, providerName, neurolink, middleware) {
|
|
87
|
-
this.modelName = modelName || this.getDefaultModel();
|
|
88
|
-
this.providerName = providerName || this.getProviderName();
|
|
89
|
-
this.neurolink = neurolink;
|
|
90
|
-
this.middlewareOptions = middleware;
|
|
91
|
-
// Initialize composition modules
|
|
92
|
-
this.messageBuilder = new MessageBuilder(this.providerName, this.modelName);
|
|
93
|
-
this.streamHandler = new StreamHandler(this.providerName, this.modelName);
|
|
94
|
-
this.telemetryHandler = new TelemetryHandler(this.providerName, this.modelName, this.neurolink);
|
|
95
|
-
this.generationHandler = new GenerationHandler(this.providerName, this.modelName, () => this.supportsTools(), (options, type) => this.telemetryHandler.getTelemetryConfig(options, type), (toolCalls, toolResults, options, timestamp) => this.handleToolExecutionStorage(toolCalls, toolResults, options, timestamp), { getEmitterFn: () => this.neurolink?.getEventEmitter() });
|
|
96
|
-
this.utilities = new Utilities(this.providerName, this.modelName, this.defaultTimeout, this.middlewareOptions);
|
|
97
|
-
this.toolsManager = new ToolsManager(this.providerName, this.directTools, this.neurolink, {
|
|
98
|
-
isZodSchema: (schema) => this.isZodSchema(schema),
|
|
99
|
-
convertToolResult: (result) => this.convertToolResult(result),
|
|
100
|
-
createPermissiveZodSchema: () => this.createPermissiveZodSchema(),
|
|
101
|
-
fixSchemaForOpenAIStrictMode: (schema) => this.fixSchemaForOpenAIStrictMode(schema),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Update modelName and rebuild composition handlers with the new value.
|
|
106
|
-
*
|
|
107
|
-
* Auto-discovery providers (lm-studio, llamacpp) call this once they have
|
|
108
|
-
* resolved the loaded model from `/v1/models`. Without this, handlers
|
|
109
|
-
* (TelemetryHandler, MessageBuilder, ...) keep the pre-discovery name and
|
|
110
|
-
* pricing / span / log metadata reports the stale value.
|
|
111
|
-
*/
|
|
112
|
-
refreshHandlersForModel(model) {
|
|
113
|
-
this.modelName = model;
|
|
114
|
-
trace
|
|
115
|
-
.getSpan(context.active())
|
|
116
|
-
?.setAttribute(ATTR.GEN_AI_MODEL, this.modelName);
|
|
117
|
-
this.messageBuilder = new MessageBuilder(this.providerName, this.modelName);
|
|
118
|
-
this.streamHandler = new StreamHandler(this.providerName, this.modelName);
|
|
119
|
-
this.telemetryHandler = new TelemetryHandler(this.providerName, this.modelName, this.neurolink);
|
|
120
|
-
this.generationHandler = new GenerationHandler(this.providerName, this.modelName, () => this.supportsTools(), (options, type) => this.telemetryHandler.getTelemetryConfig(options, type), (toolCalls, toolResults, options, timestamp) => this.handleToolExecutionStorage(toolCalls, toolResults, options, timestamp), { getEmitterFn: () => this.neurolink?.getEventEmitter() });
|
|
121
|
-
this.utilities = new Utilities(this.providerName, this.modelName, this.defaultTimeout, this.middlewareOptions);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Check if this provider supports tool/function calling
|
|
125
|
-
* Override in subclasses to disable tools for specific providers or models
|
|
126
|
-
* @returns the current model's registered capability, or true when unknown
|
|
127
|
-
*/
|
|
128
|
-
supportsTools() {
|
|
129
|
-
return modelSupports("functionCalling", this.providerName, this.modelName);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Apply the shared tool gate and optionally report registry-backed
|
|
133
|
-
* suppression at the request entry point.
|
|
134
|
-
*/
|
|
135
|
-
shouldUseTools(options, warnWhenUnsupported = false) {
|
|
136
|
-
if (options.disableTools) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
const supportsTools = this.supportsTools();
|
|
140
|
-
if (!supportsTools && warnWhenUnsupported) {
|
|
141
|
-
logger.warn(`Tools disabled for ${this.providerName}/${this.modelName} because the model does not support function calling`, {
|
|
142
|
-
provider: this.providerName,
|
|
143
|
-
model: this.modelName,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return supportsTools;
|
|
147
|
-
}
|
|
148
|
-
// ===================
|
|
149
|
-
// PUBLIC API METHODS
|
|
150
|
-
// ===================
|
|
151
|
-
/**
|
|
152
|
-
* Primary streaming method - implements AIProvider interface
|
|
153
|
-
* When tools are involved, falls back to generate() with synthetic streaming
|
|
154
|
-
*/
|
|
155
|
-
async stream(optionsOrPrompt, analysisSchema) {
|
|
156
|
-
// Runtime model limits must land before normalizeStreamOptions resolves
|
|
157
|
-
// maxTokens (getSafeMaxTokens consults the discovered output ceiling).
|
|
158
|
-
await this.ensureModelLimits();
|
|
159
|
-
let options = this.normalizeStreamOptions(optionsOrPrompt);
|
|
160
|
-
logger.info(`Starting stream`, {
|
|
161
|
-
provider: this.providerName,
|
|
162
|
-
hasTools: !options.disableTools && this.supportsTools(),
|
|
163
|
-
disableTools: !!options.disableTools,
|
|
164
|
-
supportsTools: this.supportsTools(),
|
|
165
|
-
inputLength: options.input?.text?.length || 0,
|
|
166
|
-
maxTokens: options.maxTokens,
|
|
167
|
-
temperature: options.temperature,
|
|
168
|
-
timestamp: Date.now(),
|
|
169
|
-
});
|
|
170
|
-
// ===== EARLY MULTIMODAL DETECTION =====
|
|
171
|
-
// #1259: audioFiles was missing here while videoFiles was present, so an
|
|
172
|
-
// audio-only stream skipped this branch entirely.
|
|
173
|
-
const hasFileInput = !!options.input?.files?.length ||
|
|
174
|
-
!!options.input?.videoFiles?.length ||
|
|
175
|
-
!!options.input?.audioFiles?.length;
|
|
176
|
-
if (hasFileInput) {
|
|
177
|
-
// ===== VIDEO ANALYSIS DETECTION =====
|
|
178
|
-
// Check if video frames are present and handle with fake streaming
|
|
179
|
-
const messages = await this.buildMessagesForStream(options);
|
|
180
|
-
if (hasVideoFrames(messages)) {
|
|
181
|
-
logger.info(`Video frames detected in stream, using fake streaming for video analysis`, {
|
|
182
|
-
provider: this.providerName,
|
|
183
|
-
model: this.modelName,
|
|
184
|
-
});
|
|
185
|
-
// Note: executeFakeStreaming() owns its own catch that fires the
|
|
186
|
-
// consumer-supplied onError before re-throwing through
|
|
187
|
-
// handleProviderError(), so we do not need to wrap again here —
|
|
188
|
-
// doing so would route the error through handleProviderError()
|
|
189
|
-
// twice (and risk a double-fire onError without the shared
|
|
190
|
-
// lifecycle-fired WeakSet mark).
|
|
191
|
-
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
192
|
-
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
// CRITICAL: Image generation models don't support real streaming
|
|
196
|
-
// Force fake streaming for image models to ensure image output is yielded.
|
|
197
|
-
// Skip this path when the caller explicitly requests non-image output (e.g.
|
|
198
|
-
// JSON analysis) so dual-mode models like gemini-3.1-flash-image-preview
|
|
199
|
-
// can still perform text/structured generation.
|
|
200
|
-
const isImageModel = isImageGenerationModel(this.modelName);
|
|
201
|
-
const requestsNonImageOutput = options.output?.format === "json" ||
|
|
202
|
-
options.output?.format === "structured" ||
|
|
203
|
-
options.output?.format === "text";
|
|
204
|
-
if (isImageModel && !requestsNonImageOutput) {
|
|
205
|
-
logger.info(`Image model detected, forcing fake streaming`, {
|
|
206
|
-
provider: this.providerName,
|
|
207
|
-
model: this.modelName,
|
|
208
|
-
reason: "Image generation requires fake streaming to yield image output",
|
|
209
|
-
});
|
|
210
|
-
// Skip real streaming, go directly to fake streaming.
|
|
211
|
-
// executeFakeStreaming() owns its own catch + lifecycle fire, so
|
|
212
|
-
// wrapping again here would double-route through handleProviderError().
|
|
213
|
-
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
214
|
-
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
215
|
-
}
|
|
216
|
-
// Central tool merge: Pre-merge base tools (MCP/built-in) with user-provided
|
|
217
|
-
// tools (e.g. RAG tools) into options.tools. This way, every provider's
|
|
218
|
-
// executeStream() can simply use options.tools (or getAllTools() + options.tools)
|
|
219
|
-
// and get the complete tool set without needing per-provider merge logic.
|
|
220
|
-
if (this.shouldUseTools(options, true)) {
|
|
221
|
-
const mergedTools = await this.getToolsForStream(options);
|
|
222
|
-
options = { ...options, tools: mergedTools };
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
options = { ...options, tools: {} };
|
|
226
|
-
}
|
|
227
|
-
// CRITICAL FIX: Always prefer real streaming over fake streaming
|
|
228
|
-
// Try real streaming first, use fake streaming only as fallback
|
|
229
|
-
try {
|
|
230
|
-
logger.debug(`Attempting real streaming`, {
|
|
231
|
-
provider: this.providerName,
|
|
232
|
-
timestamp: Date.now(),
|
|
233
|
-
});
|
|
234
|
-
const realStreamResult = await this.executeStream(options, analysisSchema);
|
|
235
|
-
logger.info(`Real streaming succeeded`, {
|
|
236
|
-
provider: this.providerName,
|
|
237
|
-
timestamp: Date.now(),
|
|
238
|
-
});
|
|
239
|
-
// Wire lifecycle callbacks (onChunk/onFinish/onError) on the user-
|
|
240
|
-
// facing StreamResult.stream. The AI-SDK lifecycle middleware only
|
|
241
|
-
// sees AI-SDK-internal chunks via streamText/wrapLanguageModel, so
|
|
242
|
-
// providers with custom HTTP streaming (Ollama, llama.cpp's /api,
|
|
243
|
-
// anything that doesn't go through streamText) bypass it. Wrapping
|
|
244
|
-
// here makes the callbacks fire for every provider, regardless of
|
|
245
|
-
// streaming implementation.
|
|
246
|
-
return this.wrapStreamWithLifecycleCallbacks(realStreamResult, options);
|
|
247
|
-
}
|
|
248
|
-
catch (realStreamError) {
|
|
249
|
-
// Don't retry on terminal/abort errors — only fall back for
|
|
250
|
-
// "real streaming with tools is unsupported" style failures.
|
|
251
|
-
const errMsg = realStreamError instanceof Error
|
|
252
|
-
? realStreamError.message
|
|
253
|
-
: String(realStreamError);
|
|
254
|
-
const errName = realStreamError instanceof Error ? realStreamError.name : "";
|
|
255
|
-
if (errName === "AbortError" ||
|
|
256
|
-
errMsg.includes("abort") ||
|
|
257
|
-
errMsg.includes("timeout") ||
|
|
258
|
-
errMsg.includes("401") ||
|
|
259
|
-
errMsg.includes("403") ||
|
|
260
|
-
errMsg.includes("quota") ||
|
|
261
|
-
errMsg.includes("rate limit") ||
|
|
262
|
-
errMsg.includes("authentication")) {
|
|
263
|
-
await this.fireLifecycleErrorCallback(options, realStreamError);
|
|
264
|
-
throw this.handleProviderError(realStreamError);
|
|
265
|
-
}
|
|
266
|
-
logger.warn(`Real streaming failed for ${this.providerName}, falling back to fake streaming:`, {
|
|
267
|
-
error: errMsg,
|
|
268
|
-
timestamp: Date.now(),
|
|
269
|
-
});
|
|
270
|
-
// Fallback to fake streaming only if real streaming fails AND tools
|
|
271
|
-
// are enabled. executeFakeStreaming() owns its own catch + lifecycle
|
|
272
|
-
// fire, so a fake-streaming failure here surfaces through that path
|
|
273
|
-
// without needing an outer wrap (which would double-route through
|
|
274
|
-
// handleProviderError()).
|
|
275
|
-
if (!options.disableTools && this.supportsTools()) {
|
|
276
|
-
const fakeResult = await this.executeFakeStreaming(options, analysisSchema);
|
|
277
|
-
return this.wrapStreamWithLifecycleCallbacks(fakeResult, options);
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
// If real streaming failed and no tools are enabled, fire onError
|
|
281
|
-
// before re-throwing so consumer-supplied callbacks see the failure.
|
|
282
|
-
await this.fireLifecycleErrorCallback(options, realStreamError);
|
|
283
|
-
// If real streaming failed and no tools are enabled, re-throw the original error
|
|
284
|
-
logger.error(`Real streaming failed for ${this.providerName}:`, realStreamError);
|
|
285
|
-
throw this.handleProviderError(realStreamError);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Wrap a StreamResult with consumer-facing lifecycle callbacks.
|
|
291
|
-
*
|
|
292
|
-
* `options.onChunk`, `options.onFinish`, `options.onError` are translated
|
|
293
|
-
* by NeuroLink.applyStreamLifecycleMiddleware() into
|
|
294
|
-
* `options.middleware.middlewareConfig.lifecycle.config`. The AI SDK's
|
|
295
|
-
* lifecycle middleware only sees these via the wrapped LanguageModel —
|
|
296
|
-
* which is bypassed by providers that stream via raw HTTP fetch (Ollama
|
|
297
|
-
* over /api/chat, custom OpenAI-compatible servers, etc). Wrapping the
|
|
298
|
-
* user-facing stream here ensures the callbacks fire regardless of the
|
|
299
|
-
* underlying transport.
|
|
300
|
-
*/
|
|
301
|
-
wrapStreamWithLifecycleCallbacks(result, options) {
|
|
302
|
-
const lifecycle = getLifecycleMiddlewareConfig(options);
|
|
303
|
-
if (!lifecycle?.onChunk && !lifecycle?.onFinish && !lifecycle?.onError) {
|
|
304
|
-
return result;
|
|
305
|
-
}
|
|
306
|
-
const { onChunk, onFinish, onError } = lifecycle;
|
|
307
|
-
const startTime = Date.now();
|
|
308
|
-
const originalStream = result.stream;
|
|
309
|
-
// Lifecycle callbacks are awaited with a bounded deadline so callers
|
|
310
|
-
// observe ordering guarantees (onChunk/onFinish/onError have all
|
|
311
|
-
// settled by the time `for await` returns / throws). The previous
|
|
312
|
-
// fire-and-forget pattern left async work running past stream close,
|
|
313
|
-
// creating races during cleanup. The deadline is configurable via
|
|
314
|
-
// `lifecycle.timeoutMs` (per-call) or `NEUROLINK_LIFECYCLE_TIMEOUT_MS`
|
|
315
|
-
// (env / CLI surface) — see `resolveLifecycleTimeoutMs`.
|
|
316
|
-
const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
|
|
317
|
-
const safeFire = async (fn, label) => {
|
|
318
|
-
try {
|
|
319
|
-
await withTimeoutFn(async () => {
|
|
320
|
-
const ret = fn();
|
|
321
|
-
if (ret && typeof ret.then === "function") {
|
|
322
|
-
await ret;
|
|
323
|
-
}
|
|
324
|
-
}, timeoutMs, `[lifecycle] ${label} callback exceeded ${timeoutMs}ms`);
|
|
325
|
-
}
|
|
326
|
-
catch (e) {
|
|
327
|
-
logger.warn(`[lifecycle] ${label} callback error:`, e);
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const wrappedStream = (async function* () {
|
|
331
|
-
let accumulated = "";
|
|
332
|
-
let seq = 0;
|
|
333
|
-
try {
|
|
334
|
-
for await (const chunk of originalStream) {
|
|
335
|
-
const textPart = chunk &&
|
|
336
|
-
typeof chunk === "object" &&
|
|
337
|
-
"content" in chunk &&
|
|
338
|
-
typeof chunk.content === "string"
|
|
339
|
-
? chunk.content
|
|
340
|
-
: "";
|
|
341
|
-
// Only fire onChunk for actual text deltas. Non-text chunks
|
|
342
|
-
// (image, tts_audio) would otherwise produce empty text-delta
|
|
343
|
-
// events that consumers must filter out themselves.
|
|
344
|
-
if (onChunk && textPart) {
|
|
345
|
-
const currentSeq = seq++;
|
|
346
|
-
await safeFire(() => onChunk({
|
|
347
|
-
type: "text-delta",
|
|
348
|
-
textDelta: textPart,
|
|
349
|
-
sequenceNumber: currentSeq,
|
|
350
|
-
}), "onChunk");
|
|
351
|
-
}
|
|
352
|
-
if (textPart) {
|
|
353
|
-
accumulated += textPart;
|
|
354
|
-
}
|
|
355
|
-
yield chunk;
|
|
356
|
-
}
|
|
357
|
-
if (onFinish) {
|
|
358
|
-
await safeFire(() => onFinish({
|
|
359
|
-
text: accumulated,
|
|
360
|
-
duration: Date.now() - startTime,
|
|
361
|
-
}), "onFinish");
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
catch (error) {
|
|
365
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
366
|
-
if (onError && !hasLifecycleErrorFired(err)) {
|
|
367
|
-
// Mark before firing so a higher layer that also routes through
|
|
368
|
-
// fireLifecycleErrorCallback (or its own lifecycle wrapper) with
|
|
369
|
-
// the same error instance won't double-fire onError. Mirrors the
|
|
370
|
-
// pattern in fireLifecycleErrorCallback below.
|
|
371
|
-
markLifecycleErrorFired(err);
|
|
372
|
-
await safeFire(() => onError({
|
|
373
|
-
error: err,
|
|
374
|
-
duration: Date.now() - startTime,
|
|
375
|
-
recoverable: false,
|
|
376
|
-
}), "onError");
|
|
377
|
-
}
|
|
378
|
-
throw err;
|
|
379
|
-
}
|
|
380
|
-
})();
|
|
381
|
-
return { ...result, stream: wrappedStream };
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Fire the consumer-supplied onError callback before throwing. Used in
|
|
385
|
-
* error branches inside stream() that re-throw without emitting any
|
|
386
|
-
* stream chunks (which would otherwise hide the failure from a caller
|
|
387
|
-
* that supplied `onError`).
|
|
388
|
-
*/
|
|
389
|
-
async fireLifecycleErrorCallback(options, error) {
|
|
390
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
391
|
-
// The AI-SDK lifecycle middleware stamps errors it has already
|
|
392
|
-
// surfaced (Symbol.for("neurolink.onErrorFired"); see
|
|
393
|
-
// utils/lifecycleCallbacks.ts). Skip here so consumers don't receive
|
|
394
|
-
// duplicate onError events for the same failure.
|
|
395
|
-
if (hasLifecycleErrorFired(err)) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
const lifecycle = getLifecycleMiddlewareConfig(options);
|
|
399
|
-
const onError = lifecycle?.onError;
|
|
400
|
-
if (!onError) {
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
// Set the marker before invoking so a sync re-entry (or a concurrent
|
|
404
|
-
// dispatch path) can't double-fire onError for the same error object.
|
|
405
|
-
markLifecycleErrorFired(err);
|
|
406
|
-
// Fire the consumer's onError with a bounded deadline AND await its
|
|
407
|
-
// completion — callers can now `await fireLifecycleErrorCallback(...)`
|
|
408
|
-
// to guarantee the consumer's async onError settles before the
|
|
409
|
-
// surrounding stream() / executeFakeStreaming() rethrows. Deadline is
|
|
410
|
-
// configurable via `lifecycle.timeoutMs` or the
|
|
411
|
-
// `NEUROLINK_LIFECYCLE_TIMEOUT_MS` env var.
|
|
412
|
-
const timeoutMs = resolveLifecycleTimeoutMs(lifecycle);
|
|
413
|
-
try {
|
|
414
|
-
await withTimeoutFn(async () => {
|
|
415
|
-
// Capturing `onError` into a const above means TypeScript sees the
|
|
416
|
-
// narrowing past the early-return, so no non-null assertion needed
|
|
417
|
-
// here — and the callback identity is stable across the timeout
|
|
418
|
-
// boundary even if the caller mutates `lifecycle.onError` mid-call.
|
|
419
|
-
const ret = onError({
|
|
420
|
-
error: err,
|
|
421
|
-
duration: 0,
|
|
422
|
-
recoverable: false,
|
|
423
|
-
});
|
|
424
|
-
if (ret && typeof ret.then === "function") {
|
|
425
|
-
await ret;
|
|
426
|
-
}
|
|
427
|
-
}, timeoutMs, `[lifecycle] onError callback exceeded ${timeoutMs}ms`);
|
|
428
|
-
}
|
|
429
|
-
catch (e) {
|
|
430
|
-
logger.warn("[lifecycle] onError callback error:", e);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Execute fake streaming - extracted method for reusability
|
|
435
|
-
*/
|
|
436
|
-
async executeFakeStreaming(options, analysisSchema) {
|
|
437
|
-
try {
|
|
438
|
-
logger.info(`Starting fake streaming with tools`, {
|
|
439
|
-
provider: this.providerName,
|
|
440
|
-
supportsTools: this.supportsTools(),
|
|
441
|
-
timestamp: Date.now(),
|
|
442
|
-
});
|
|
443
|
-
// Convert stream options to text generation options
|
|
444
|
-
const textOptions = {
|
|
445
|
-
prompt: options.input?.text || "",
|
|
446
|
-
input: options.input,
|
|
447
|
-
systemPrompt: options.systemPrompt,
|
|
448
|
-
temperature: options.temperature,
|
|
449
|
-
maxTokens: options.maxTokens,
|
|
450
|
-
tools: options.tools, // 🔧 FIX: Pass user-provided tools (including RAG tools) to generation pipeline
|
|
451
|
-
disableTools: !!options.disableTools,
|
|
452
|
-
maxSteps: options.maxSteps || 5,
|
|
453
|
-
provider: options.provider,
|
|
454
|
-
model: options.model,
|
|
455
|
-
region: options.region, // Pass region for Vertex AI
|
|
456
|
-
// 🔧 FIX: Include analytics and evaluation options from stream options
|
|
457
|
-
enableAnalytics: options.enableAnalytics,
|
|
458
|
-
enableEvaluation: options.enableEvaluation,
|
|
459
|
-
evaluationDomain: options.evaluationDomain,
|
|
460
|
-
toolUsageContext: options.toolUsageContext,
|
|
461
|
-
context: options.context,
|
|
462
|
-
csvOptions: options.csvOptions,
|
|
463
|
-
pdfOptions: options.pdfOptions,
|
|
464
|
-
// Forward abort, tool filtering, and timeout options to prevent
|
|
465
|
-
// silent bypass when falling back from real streaming to fake streaming
|
|
466
|
-
abortSignal: options.abortSignal,
|
|
467
|
-
toolFilter: options.toolFilter,
|
|
468
|
-
excludeTools: options.excludeTools,
|
|
469
|
-
skipToolPromptInjection: options.skipToolPromptInjection,
|
|
470
|
-
timeout: options.timeout,
|
|
471
|
-
stt: options.stt,
|
|
472
|
-
// Forward TTS options too — without this, the fake-streaming fallback
|
|
473
|
-
// path silently drops `tts` and the resulting StreamResult never
|
|
474
|
-
// produces a `tts_audio` chunk even when synthesis was requested.
|
|
475
|
-
tts: options.tts,
|
|
476
|
-
};
|
|
477
|
-
logger.debug(`Calling generate for fake streaming`, {
|
|
478
|
-
provider: this.providerName,
|
|
479
|
-
maxSteps: textOptions.maxSteps,
|
|
480
|
-
disableTools: textOptions.disableTools,
|
|
481
|
-
timestamp: Date.now(),
|
|
482
|
-
});
|
|
483
|
-
const result = await this.generate(textOptions, analysisSchema);
|
|
484
|
-
logger.info(`Generate completed for fake streaming`, {
|
|
485
|
-
provider: this.providerName,
|
|
486
|
-
hasContent: !!result?.content,
|
|
487
|
-
contentLength: result?.content?.length || 0,
|
|
488
|
-
toolsUsed: result?.toolsUsed?.length || 0,
|
|
489
|
-
hasImageOutput: !!result?.imageOutput,
|
|
490
|
-
timestamp: Date.now(),
|
|
491
|
-
});
|
|
492
|
-
// Create a synthetic stream from the generate result that simulates progressive delivery
|
|
493
|
-
return {
|
|
494
|
-
stream: (async function* () {
|
|
495
|
-
if (result?.content) {
|
|
496
|
-
// Split content into words for more natural streaming
|
|
497
|
-
const words = result.content.split(/(\s+)/); // Keep whitespace
|
|
498
|
-
let buffer = "";
|
|
499
|
-
for (let i = 0; i < words.length; i++) {
|
|
500
|
-
buffer += words[i];
|
|
501
|
-
// Yield chunks of roughly 5-10 words or at punctuation
|
|
502
|
-
const shouldYield = i === words.length - 1 || // Last word
|
|
503
|
-
buffer.length > 50 || // Buffer getting long
|
|
504
|
-
/[.!?;,]\s*$/.test(buffer); // End of sentence/clause
|
|
505
|
-
if (shouldYield && buffer.trim()) {
|
|
506
|
-
yield { content: buffer };
|
|
507
|
-
buffer = "";
|
|
508
|
-
// Small delay to simulate streaming (1-10ms)
|
|
509
|
-
await new Promise((resolve) => {
|
|
510
|
-
setTimeout(resolve, Math.random() * 9 + 1);
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
// Yield all remaining content
|
|
515
|
-
if (buffer.trim()) {
|
|
516
|
-
yield { content: buffer };
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
// 🔧 CRITICAL FIX: Yield image output if present
|
|
520
|
-
if (result?.imageOutput) {
|
|
521
|
-
yield {
|
|
522
|
-
type: "image",
|
|
523
|
-
imageOutput: result.imageOutput,
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
// Yield synthesized audio so callers using stream() with tts.enabled
|
|
527
|
-
// still receive a tts_audio chunk on the fake-streaming fallback
|
|
528
|
-
// path (matches the discriminator used by the real streaming path).
|
|
529
|
-
if (result?.audio) {
|
|
530
|
-
yield {
|
|
531
|
-
type: "tts_audio",
|
|
532
|
-
audio: {
|
|
533
|
-
data: result.audio.buffer,
|
|
534
|
-
format: result.audio.format,
|
|
535
|
-
index: 0,
|
|
536
|
-
isFinal: true,
|
|
537
|
-
cumulativeSize: result.audio.size,
|
|
538
|
-
voice: result.audio.voice,
|
|
539
|
-
sampleRate: result.audio.sampleRate,
|
|
540
|
-
},
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
})(),
|
|
544
|
-
usage: result?.usage,
|
|
545
|
-
provider: result?.provider,
|
|
546
|
-
model: result?.model,
|
|
547
|
-
toolCalls: result?.toolCalls?.map((call) => ({
|
|
548
|
-
toolName: call.toolName,
|
|
549
|
-
parameters: call.args,
|
|
550
|
-
id: call.toolCallId,
|
|
551
|
-
})),
|
|
552
|
-
toolResults: result?.toolResults
|
|
553
|
-
? result.toolResults.map((tr) => ({
|
|
554
|
-
toolName: tr.toolName || "unknown",
|
|
555
|
-
status: (tr.status === "error"
|
|
556
|
-
? "failure"
|
|
557
|
-
: "success"),
|
|
558
|
-
result: tr.output ?? tr.result,
|
|
559
|
-
error: tr.error,
|
|
560
|
-
}))
|
|
561
|
-
: undefined,
|
|
562
|
-
// 🔧 FIX: Include analytics and evaluation from generate result
|
|
563
|
-
analytics: result?.analytics,
|
|
564
|
-
evaluation: result?.evaluation,
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
catch (error) {
|
|
568
|
-
logger.error(`Fake streaming fallback failed for ${this.providerName}:`, error);
|
|
569
|
-
// Fire the consumer-supplied onError BEFORE re-throwing through
|
|
570
|
-
// handleProviderError() so callers using onChunk/onFinish/onError
|
|
571
|
-
// get notified even when fake-streaming setup (message build, image
|
|
572
|
-
// adapter, etc.) fails synchronously. Awaited so the consumer's
|
|
573
|
-
// async onError fully settles before we rethrow. The shared
|
|
574
|
-
// lifecycle-fired WeakSet mark prevents double-fire if a wrapper
|
|
575
|
-
// layer also handles this.
|
|
576
|
-
await this.fireLifecycleErrorCallback(options, error);
|
|
577
|
-
throw this.handleProviderError(error);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Apply per-call tool filtering (whitelist/blacklist) to a tools record.
|
|
582
|
-
*
|
|
583
|
-
* All filtering surfaces are merged into one ResolvedToolPolicy by
|
|
584
|
-
* `resolveToolPolicy()` — per-call `toolFilter` (whitelist),
|
|
585
|
-
* `enabledToolNames` (merged into the whitelist, as its docs always
|
|
586
|
-
* promised), `excludeTools` (denylist, applied after the whitelist), and
|
|
587
|
-
* the instance-level `tools` config (enabled/include/exclude, `*` globs) —
|
|
588
|
-
* then applied by `applyToolGate()`. This is the single filter semantics
|
|
589
|
-
* for every generate/stream path.
|
|
590
|
-
*/
|
|
591
|
-
getToolPolicy(options) {
|
|
592
|
-
return resolveToolPolicy({
|
|
593
|
-
options: {
|
|
594
|
-
// Defense-in-depth: both current call sites already zero the tool
|
|
595
|
-
// record via shouldUseTools before the gate runs, but forwarding
|
|
596
|
-
// disableTools makes the gate self-sufficient for any future call
|
|
597
|
-
// site that forgets the upstream check.
|
|
598
|
-
disableTools: options.disableTools,
|
|
599
|
-
toolFilter: options.toolFilter,
|
|
600
|
-
excludeTools: options.excludeTools,
|
|
601
|
-
enabledToolNames: options.enabledToolNames,
|
|
602
|
-
},
|
|
603
|
-
instanceConfig: this.neurolink?.getToolsConfig(),
|
|
604
|
-
builtinToolNames: Object.keys(this.directTools ?? {}),
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
applyToolFiltering(tools, options) {
|
|
608
|
-
const policy = this.getToolPolicy(options);
|
|
609
|
-
// Check whether the dedup pass is requested — even when no whitelist/
|
|
610
|
-
// denylist is set we still need to run the dedup pass if enabled.
|
|
611
|
-
const dedupConfig = this.neurolink?.getToolDedupConfig();
|
|
612
|
-
const hasDedupEnabled = dedupConfig !== undefined && dedupConfig.enabled === true;
|
|
613
|
-
const beforeCount = Object.keys(tools).length;
|
|
614
|
-
const filtered = applyToolGate(tools, policy);
|
|
615
|
-
const afterCount = Object.keys(filtered).length;
|
|
616
|
-
if (beforeCount !== afterCount) {
|
|
617
|
-
logger.debug(`Tool filtering applied`, {
|
|
618
|
-
provider: this.providerName,
|
|
619
|
-
beforeCount,
|
|
620
|
-
afterCount,
|
|
621
|
-
policySources: policy.sources,
|
|
622
|
-
toolFilter: options.toolFilter,
|
|
623
|
-
excludeTools: options.excludeTools,
|
|
624
|
-
enabledToolNames: options.enabledToolNames,
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
if (!hasDedupEnabled || dedupConfig === undefined) {
|
|
628
|
-
return this.sortToolRecord(filtered);
|
|
629
|
-
}
|
|
630
|
-
const deduped = this.applyDedupPass(filtered, dedupConfig);
|
|
631
|
-
// A forced toolChoice must survive dedup: keep-first can collapse the
|
|
632
|
-
// forced tool into an earlier near-identical signature, and the provider
|
|
633
|
-
// would then reject the request for naming an unknown tool. Restore it
|
|
634
|
-
// from the pre-dedup record (whitelisted names are already safe — the
|
|
635
|
-
// gate runs before dedup, so a whitelist leaves no duplicate to lose to).
|
|
636
|
-
const forcedName = options.toolChoice?.toolName;
|
|
637
|
-
if (typeof forcedName === "string" &&
|
|
638
|
-
!Object.hasOwn(deduped, forcedName) &&
|
|
639
|
-
Object.hasOwn(filtered, forcedName)) {
|
|
640
|
-
deduped[forcedName] = filtered[forcedName];
|
|
641
|
-
logger.debug(`Restored toolChoice-forced tool removed by signature dedup`, { provider: this.providerName, toolName: forcedName });
|
|
642
|
-
}
|
|
643
|
-
return this.sortToolRecord(deduped);
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Deterministic name-sorted key order. External MCP servers connect and
|
|
647
|
-
* discover in parallel, so insertion order varies across process restarts;
|
|
648
|
-
* providers serialize this record in key order (and Anthropic pins its
|
|
649
|
-
* cache_control breakpoint to the LAST tool), so an unstable order silently
|
|
650
|
-
* busts provider prompt caches. Runs AFTER the dedup pass — dedup's
|
|
651
|
-
* keep-first policy must see phase order (built-ins first) so duplicate
|
|
652
|
-
* winners don't flip when an MCP tool name sorts earlier.
|
|
653
|
-
*/
|
|
654
|
-
sortToolRecord(tools) {
|
|
655
|
-
// Null prototype: a tool named "__proto__" must become an own entry, not
|
|
656
|
-
// a prototype mutation that silently drops the tool.
|
|
657
|
-
const sorted = Object.create(null);
|
|
658
|
-
for (const name of Object.keys(tools).sort()) {
|
|
659
|
-
sorted[name] = tools[name];
|
|
660
|
-
}
|
|
661
|
-
return sorted;
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* On-demand discovery (`tools.discovery: true`): defer external MCP tool
|
|
665
|
-
* schemas behind one `search_tools` meta-tool. Built-in tools, per-call
|
|
666
|
-
* tools, explicitly whitelisted tools, and session-pinned (previously
|
|
667
|
-
* discovered) tools always stay hot. No-op when discovery is off — with a
|
|
668
|
-
* one-time WARN when the catalog is large enough that selection accuracy
|
|
669
|
-
* measurably degrades.
|
|
670
|
-
*/
|
|
671
|
-
async applyToolDiscovery(toolsInput, options) {
|
|
672
|
-
// Strip a stale meta-tool left by a previous resolution pass (the
|
|
673
|
-
// stream → generate fallback re-enters resolution with options.tools
|
|
674
|
-
// already partitioned). Discovery re-partitions against the fresh merged
|
|
675
|
-
// record below; without this, the collision guard would see our own
|
|
676
|
-
// meta-tool and skip partitioning, shipping the full catalog AND a stale
|
|
677
|
-
// search_tools closure. Real user tools named "search_tools" are not
|
|
678
|
-
// marked and are left untouched.
|
|
679
|
-
let tools = toolsInput;
|
|
680
|
-
if (isDiscoveryMetaTool(tools["search_tools"])) {
|
|
681
|
-
const { search_tools: _stale, ...rest } = tools;
|
|
682
|
-
tools = rest;
|
|
683
|
-
}
|
|
684
|
-
const toolCount = Object.keys(tools).length;
|
|
685
|
-
const policy = this.getToolPolicy(options);
|
|
686
|
-
if (!policy.discovery) {
|
|
687
|
-
if (toolCount > LARGE_CATALOG_WARN_THRESHOLD) {
|
|
688
|
-
this.warnLargeCatalogOnce(toolCount);
|
|
689
|
-
}
|
|
690
|
-
return tools;
|
|
691
|
-
}
|
|
692
|
-
const externalTools = this.neurolink?.getExternalMCPTools() ?? [];
|
|
693
|
-
if (externalTools.length === 0) {
|
|
694
|
-
return tools;
|
|
695
|
-
}
|
|
696
|
-
// Session pinning requires a caller-provided sessionId. Without one there
|
|
697
|
-
// is no session identity — pinning to a shared fallback key would leak
|
|
698
|
-
// one caller's discoveries into every other caller of a shared instance
|
|
699
|
-
// and monotonically defeat deferral, so pins are simply not persisted.
|
|
700
|
-
const rawSessionId = options.context?.sessionId;
|
|
701
|
-
const sessionKey = typeof rawSessionId === "string" && rawSessionId.length > 0
|
|
702
|
-
? rawSessionId
|
|
703
|
-
: typeof rawSessionId === "number"
|
|
704
|
-
? String(rawSessionId)
|
|
705
|
-
: undefined;
|
|
706
|
-
const pinnedNames = (sessionKey ? this.neurolink?.getDiscoveryPins(sessionKey) : undefined) ??
|
|
707
|
-
new Set();
|
|
708
|
-
const perCallNames = new Set(Object.keys(options.tools ?? {}));
|
|
709
|
-
// Explicitly requested tools stay hot. Allowlist entries may be globs
|
|
710
|
-
// (e.g. toolFilter: ["github*"]), so match with the same pattern matcher
|
|
711
|
-
// the gate uses — a Set of pattern STRINGS would defer glob-whitelisted
|
|
712
|
-
// tools the gate deliberately kept.
|
|
713
|
-
const explicitPatterns = [
|
|
714
|
-
...(options.toolFilter ?? []),
|
|
715
|
-
...(options.enabledToolNames ?? []),
|
|
716
|
-
];
|
|
717
|
-
// A toolChoice that forces a named tool must never see that tool
|
|
718
|
-
// deferred — the provider would reject the request (unknown tool name).
|
|
719
|
-
const toolChoice = options.toolChoice;
|
|
720
|
-
if (toolChoice && typeof toolChoice.toolName === "string") {
|
|
721
|
-
explicitPatterns.push(toolChoice.toolName);
|
|
722
|
-
}
|
|
723
|
-
const explicitMatcher = explicitPatterns.length > 0 ? toolNameMatcher(explicitPatterns) : null;
|
|
724
|
-
const deferrableNames = externalTools
|
|
725
|
-
.map((t) => t.name)
|
|
726
|
-
.filter((name) => name in tools &&
|
|
727
|
-
!perCallNames.has(name) &&
|
|
728
|
-
!(explicitMatcher ? explicitMatcher(name) : false));
|
|
729
|
-
return partitionToolsForDiscovery(tools, {
|
|
730
|
-
deferrableNames,
|
|
731
|
-
pinnedNames,
|
|
732
|
-
onHydrate: (names) => {
|
|
733
|
-
if (sessionKey) {
|
|
734
|
-
this.neurolink?.pinDiscoveredTools(sessionKey, names);
|
|
735
|
-
}
|
|
736
|
-
},
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
static warnedLargeCatalog = false;
|
|
740
|
-
warnLargeCatalogOnce(toolCount) {
|
|
741
|
-
if (BaseProvider.warnedLargeCatalog) {
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
BaseProvider.warnedLargeCatalog = true;
|
|
745
|
-
logger.warn(`[ToolDiscovery] ${toolCount} tools are being sent in full on every request (~${Math.round((toolCount * 175) / 100) / 10}K tokens). Tool-selection accuracy degrades past 30-50 tools — consider enabling on-demand discovery: new NeuroLink({ tools: { discovery: true } })`, { toolCount, provider: this.providerName });
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* Opt-in signature dedup — runs AFTER whitelist/blacklist filtering and
|
|
749
|
-
* BEFORE the tool set reaches the provider call. Fails open: any error
|
|
750
|
-
* inside dedupeTools returns the original filtered set unchanged.
|
|
751
|
-
*/
|
|
752
|
-
applyDedupPass(filtered, dedupConfig) {
|
|
753
|
-
const { tools: dedupedTools, removed } = dedupeTools(filtered, dedupConfig);
|
|
754
|
-
if (removed.length > 0 && logger.shouldLog("debug")) {
|
|
755
|
-
logger.debug(`Tool signature dedup removed duplicates`, {
|
|
756
|
-
provider: this.providerName,
|
|
757
|
-
removedCount: removed.length,
|
|
758
|
-
removed: removed.map((r) => ({
|
|
759
|
-
name: r.name,
|
|
760
|
-
duplicateOf: r.duplicateOf,
|
|
761
|
-
similarity: r.similarity,
|
|
762
|
-
})),
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
return dedupedTools;
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Prepare generation context including tools and model
|
|
769
|
-
*/
|
|
770
|
-
async prepareGenerationContext(options) {
|
|
771
|
-
const shouldUseTools = this.shouldUseTools(options, true);
|
|
772
|
-
const baseTools = shouldUseTools ? await this.getAllTools() : {};
|
|
773
|
-
let tools = shouldUseTools
|
|
774
|
-
? {
|
|
775
|
-
...baseTools,
|
|
776
|
-
...(options.tools || {}),
|
|
777
|
-
}
|
|
778
|
-
: {};
|
|
779
|
-
// Apply per-call tool filtering (whitelist/blacklist)
|
|
780
|
-
tools = this.applyToolFiltering(tools, options);
|
|
781
|
-
// Per-call execution capture: wrap every executable tool so real
|
|
782
|
-
// params/results/timing surface on result.toolExecutions. Must run
|
|
783
|
-
// BEFORE discovery — search_tools hydration mutates the discovery
|
|
784
|
-
// record in place, so tools hydrated mid-turn stay wrapped.
|
|
785
|
-
tools = this.wrapToolsForExecutionCapture(tools, options);
|
|
786
|
-
// On-demand discovery: defer external MCP schemas behind search_tools
|
|
787
|
-
tools = await this.applyToolDiscovery(tools, options);
|
|
788
|
-
logger.debug(`Final tools prepared for AI`, {
|
|
789
|
-
provider: this.providerName,
|
|
790
|
-
directTools: getKeyCount(baseTools),
|
|
791
|
-
directToolNames: getKeysAsString(baseTools),
|
|
792
|
-
externalTools: getKeyCount(options.tools || {}),
|
|
793
|
-
externalToolNames: getKeysAsString(options.tools || {}),
|
|
794
|
-
totalTools: getKeyCount(tools),
|
|
795
|
-
totalToolNames: getKeysAsString(tools),
|
|
796
|
-
shouldUseTools,
|
|
797
|
-
timestamp: Date.now(),
|
|
798
|
-
});
|
|
799
|
-
const model = await this.getAISDKModelWithMiddleware(options);
|
|
800
|
-
return { tools, model };
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Get merged tools for streaming: combines base tools (MCP/built-in) with
|
|
804
|
-
* user-provided tools (e.g., RAG tools passed via options.tools).
|
|
805
|
-
*
|
|
806
|
-
* This is the canonical tool-merge pattern for executeStream() implementations.
|
|
807
|
-
* All providers should call this instead of getAllTools() directly.
|
|
808
|
-
*/
|
|
809
|
-
async getToolsForStream(options) {
|
|
810
|
-
const shouldUseTools = this.shouldUseTools(options);
|
|
811
|
-
if (!shouldUseTools) {
|
|
812
|
-
return {};
|
|
813
|
-
}
|
|
814
|
-
const baseTools = await this.getAllTools();
|
|
815
|
-
const externalTools = (options.tools || {});
|
|
816
|
-
let merged = { ...baseTools, ...externalTools };
|
|
817
|
-
// Apply per-call tool filtering (whitelist/blacklist)
|
|
818
|
-
merged = this.applyToolFiltering(merged, options);
|
|
819
|
-
// Per-call execution capture (native loops obtain their tools here, so
|
|
820
|
-
// this single wrap covers the Gemini/Anthropic native paths too). Must
|
|
821
|
-
// run BEFORE discovery so tools hydrated mid-turn stay wrapped.
|
|
822
|
-
merged = this.wrapToolsForExecutionCapture(merged, options);
|
|
823
|
-
// On-demand discovery: defer external MCP schemas behind search_tools
|
|
824
|
-
merged = await this.applyToolDiscovery(merged, options);
|
|
825
|
-
logger.debug(`Tools prepared for streaming`, {
|
|
826
|
-
provider: this.providerName,
|
|
827
|
-
baseToolCount: Object.keys(baseTools).length,
|
|
828
|
-
externalToolCount: Object.keys(externalTools).length,
|
|
829
|
-
totalToolCount: Object.keys(merged).length,
|
|
830
|
-
});
|
|
831
|
-
return merged;
|
|
832
|
-
}
|
|
833
|
-
/**
|
|
834
|
-
* Create (or reuse) the per-call ToolExecutionRecorder and wrap the final
|
|
835
|
-
* tool record with it. The recorder rides on the options object so provider
|
|
836
|
-
* loops and result assembly observe the same capture state; wrapping is
|
|
837
|
-
* idempotent, so paths that re-enter (stream→generate fallback) never
|
|
838
|
-
* double-record.
|
|
839
|
-
*/
|
|
840
|
-
wrapToolsForExecutionCapture(tools, options) {
|
|
841
|
-
if (Object.keys(tools).length === 0) {
|
|
842
|
-
return tools;
|
|
843
|
-
}
|
|
844
|
-
let recorder = ToolExecutionRecorder.from(options);
|
|
845
|
-
if (!recorder) {
|
|
846
|
-
recorder = new ToolExecutionRecorder(options.toolExecutionCapture);
|
|
847
|
-
recorder.attachTo(options);
|
|
848
|
-
}
|
|
849
|
-
return recorder.wrapTools(tools);
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Build messages array for generation - delegated to MessageBuilder
|
|
853
|
-
*/
|
|
854
|
-
async buildMessages(options) {
|
|
855
|
-
return this.messageBuilder.buildMessages(options);
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Build messages array for streaming operations - delegated to MessageBuilder
|
|
859
|
-
* This is a protected helper method that providers can use to build messages
|
|
860
|
-
* with automatic multimodal detection, eliminating code duplication
|
|
861
|
-
*
|
|
862
|
-
* @param options - Stream options or text generation options
|
|
863
|
-
* @returns Promise resolving to ModelMessage array ready for AI SDK
|
|
864
|
-
*/
|
|
865
|
-
async buildMessagesForStream(options) {
|
|
866
|
-
return this.messageBuilder.buildMessagesForStream(options);
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* Execute the generation with AI SDK - delegated to GenerationHandler
|
|
870
|
-
*/
|
|
871
|
-
async executeGeneration(model, messages, tools, options) {
|
|
872
|
-
return this.generationHandler.executeGeneration(model, messages, tools, options);
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* Log generation completion information - delegated to GenerationHandler
|
|
876
|
-
*/
|
|
877
|
-
logGenerationComplete(generateResult) {
|
|
878
|
-
this.generationHandler.logGenerationComplete(generateResult);
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Record performance metrics - delegated to TelemetryHandler
|
|
882
|
-
*/
|
|
883
|
-
async recordPerformanceMetrics(usage, responseTime) {
|
|
884
|
-
await this.telemetryHandler.recordPerformanceMetrics(usage, responseTime);
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Extract tool information from generation result - delegated to GenerationHandler
|
|
888
|
-
*/
|
|
889
|
-
extractToolInformation(generateResult) {
|
|
890
|
-
return this.generationHandler.extractToolInformation(generateResult);
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Format the enhanced result - delegated to GenerationHandler
|
|
894
|
-
*/
|
|
895
|
-
formatEnhancedResult(generateResult, tools, toolsUsed, toolExecutions, options) {
|
|
896
|
-
return this.generationHandler.formatEnhancedResult(generateResult, tools, toolsUsed, toolExecutions, options);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Analyze AI response structure and log detailed debugging information - delegated to GenerationHandler
|
|
900
|
-
*/
|
|
901
|
-
analyzeAIResponse(result) {
|
|
902
|
-
this.generationHandler.analyzeAIResponse(result);
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Text generation method - implements AIProvider interface
|
|
906
|
-
* Tools are always available unless explicitly disabled
|
|
907
|
-
*
|
|
908
|
-
* Supports Text-to-Speech (TTS) audio generation in two modes:
|
|
909
|
-
* 1. Direct synthesis (default): TTS synthesizes the input text without AI generation
|
|
910
|
-
* 2. AI response synthesis: TTS synthesizes the AI-generated response after generation
|
|
911
|
-
*
|
|
912
|
-
* When TTS is enabled with useAiResponse=false (default), the method returns early with
|
|
913
|
-
* only the audio result, skipping AI generation entirely for optimal performance.
|
|
914
|
-
*
|
|
915
|
-
* When TTS is enabled with useAiResponse=true, the method performs full AI generation
|
|
916
|
-
* and then synthesizes the AI response to audio.
|
|
917
|
-
*
|
|
918
|
-
* @param optionsOrPrompt - Generation options or prompt string
|
|
919
|
-
* @param _analysisSchema - Optional analysis schema (not used)
|
|
920
|
-
* @returns Enhanced result with optional audio field containing TTSResult
|
|
921
|
-
*
|
|
922
|
-
* IMPLEMENTATION NOTE: Uses streamText() under the hood and accumulates results
|
|
923
|
-
* for consistency and better performance
|
|
924
|
-
*/
|
|
925
|
-
/**
|
|
926
|
-
* Ensure runtime-discovered model limits (context window, output-token
|
|
927
|
-
* ceiling) are registered before any budget math runs. Generation
|
|
928
|
-
* pipelines await this BEFORE `checkContextBudget`, and generate()/stream()
|
|
929
|
-
* await it before options normalization so `getSafeMaxTokens` sees the
|
|
930
|
-
* discovered output ceiling.
|
|
931
|
-
*
|
|
932
|
-
* Default no-op. Providers with a runtime discovery source override it
|
|
933
|
-
* (e.g. LiteLLM's `/model/info`). Implementations must NEVER reject —
|
|
934
|
-
* discovery failure degrades to the static defaults.
|
|
935
|
-
*/
|
|
936
|
-
async ensureModelLimits() { }
|
|
937
|
-
async generate(optionsOrPrompt, _analysisSchema) {
|
|
938
|
-
// Runtime model limits must land before normalizeTextOptions resolves
|
|
939
|
-
// maxTokens (getSafeMaxTokens consults the discovered output ceiling).
|
|
940
|
-
await this.ensureModelLimits();
|
|
941
|
-
const options = this.normalizeTextOptions(optionsOrPrompt);
|
|
942
|
-
this.validateOptions(options);
|
|
943
|
-
const startTime = Date.now();
|
|
944
|
-
// OTEL span for provider-level generate tracing
|
|
945
|
-
// Use startActiveSpan pattern via context.with() so child spans become descendants
|
|
946
|
-
const otelSpan = tracers.provider.startSpan("neurolink.provider.generate", {
|
|
947
|
-
kind: SpanKind.CLIENT,
|
|
948
|
-
attributes: {
|
|
949
|
-
[ATTR.GEN_AI_SYSTEM]: this.providerName || "unknown",
|
|
950
|
-
[ATTR.GEN_AI_MODEL]: this.modelName || options.model || "unknown",
|
|
951
|
-
[ATTR.GEN_AI_OPERATION]: "generate",
|
|
952
|
-
[ATTR.NL_PROVIDER]: this.providerName || "unknown",
|
|
953
|
-
},
|
|
954
|
-
});
|
|
955
|
-
// Set this span as the active context so child spans (GenerationHandler, etc.) become descendants
|
|
956
|
-
const activeCtx = trace.setSpan(context.active(), otelSpan);
|
|
957
|
-
const otelSpanState = { ended: false };
|
|
958
|
-
return await context.with(activeCtx, async () => this.runGenerateInActiveContext(options, startTime, otelSpan, otelSpanState));
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Alias for generate method - implements AIProvider interface
|
|
962
|
-
*/
|
|
963
|
-
async gen(optionsOrPrompt, analysisSchema) {
|
|
964
|
-
return this.generate(optionsOrPrompt, analysisSchema);
|
|
965
|
-
}
|
|
966
|
-
async runGenerateInActiveContext(options, startTime, otelSpan, otelSpanState) {
|
|
967
|
-
try {
|
|
968
|
-
if (options.output?.mode === "video") {
|
|
969
|
-
return await this.handleVideoGeneration(options, startTime);
|
|
970
|
-
}
|
|
971
|
-
const isImageModel = isImageGenerationModel(this.modelName);
|
|
972
|
-
const requestsNonImageOutput = options.output?.format === "json" ||
|
|
973
|
-
options.output?.format === "structured" ||
|
|
974
|
-
options.output?.format === "text";
|
|
975
|
-
if (isImageModel && !requestsNonImageOutput) {
|
|
976
|
-
logger.info(`Image generation model detected, routing to executeImageGeneration`, {
|
|
977
|
-
provider: this.providerName,
|
|
978
|
-
model: this.modelName,
|
|
979
|
-
});
|
|
980
|
-
const imageResult = await this.executeImageGeneration(options);
|
|
981
|
-
return await this.enhanceResult(imageResult, options, startTime);
|
|
982
|
-
}
|
|
983
|
-
if (options.tts?.enabled && !options.tts?.useAiResponse) {
|
|
984
|
-
return this.handleDirectTTSSynthesis(options, startTime);
|
|
985
|
-
}
|
|
986
|
-
const { tools, model } = await this.prepareGenerationContext(options);
|
|
987
|
-
const messages = await this.buildMessages(options);
|
|
988
|
-
const videoFrameResult = await this.handleVideoFrameGeneration(options, messages, model, startTime);
|
|
989
|
-
if (videoFrameResult) {
|
|
990
|
-
return videoFrameResult;
|
|
991
|
-
}
|
|
992
|
-
return await this.executeStandardGenerateFlow(options, startTime, model, messages, tools);
|
|
993
|
-
}
|
|
994
|
-
catch (error) {
|
|
995
|
-
otelSpan.setStatus({
|
|
996
|
-
code: SpanStatusCode.ERROR,
|
|
997
|
-
message: error instanceof Error ? error.message : String(error),
|
|
998
|
-
});
|
|
999
|
-
otelSpan.end();
|
|
1000
|
-
otelSpanState.ended = true;
|
|
1001
|
-
if (isAbortError(error)) {
|
|
1002
|
-
logger.info(`Generate aborted for ${this.providerName}`, {
|
|
1003
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
else {
|
|
1007
|
-
logger.error(`Generate failed for ${this.providerName}:`, error);
|
|
1008
|
-
}
|
|
1009
|
-
throw this.handleProviderError(error);
|
|
1010
|
-
}
|
|
1011
|
-
finally {
|
|
1012
|
-
if (!otelSpanState.ended) {
|
|
1013
|
-
otelSpan.setStatus({ code: SpanStatusCode.OK });
|
|
1014
|
-
otelSpan.end();
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
async handleDirectTTSSynthesis(options, startTime) {
|
|
1019
|
-
const textToSynthesize = options.prompt ?? options.input?.text ?? "";
|
|
1020
|
-
const baseResult = {
|
|
1021
|
-
content: textToSynthesize,
|
|
1022
|
-
provider: options.provider ?? this.providerName,
|
|
1023
|
-
model: this.modelName,
|
|
1024
|
-
usage: { input: 0, output: 0, total: 0 },
|
|
1025
|
-
};
|
|
1026
|
-
const ttsOptions = options.tts;
|
|
1027
|
-
if (!ttsOptions) {
|
|
1028
|
-
return this.enhanceResult(baseResult, options, startTime);
|
|
1029
|
-
}
|
|
1030
|
-
const ttsStartTime = Date.now();
|
|
1031
|
-
const ttsProvider = ttsOptions.provider ?? options.provider ?? this.providerName;
|
|
1032
|
-
const ttsTimeout = this.getTimeout(options);
|
|
1033
|
-
try {
|
|
1034
|
-
baseResult.audio = await withTimeoutFn(() => TTSProcessor.synthesize(textToSynthesize, ttsProvider, ttsOptions), ttsTimeout, `TTS synthesis timed out after ${ttsTimeout}ms for provider "${ttsProvider}"`);
|
|
1035
|
-
baseResult.ttsMetadata = {
|
|
1036
|
-
attempted: true,
|
|
1037
|
-
success: true,
|
|
1038
|
-
latency: Date.now() - ttsStartTime,
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
catch (ttsError) {
|
|
1042
|
-
const latency = Date.now() - ttsStartTime;
|
|
1043
|
-
const error = this.getTTSErrorDetails(ttsError);
|
|
1044
|
-
baseResult.ttsMetadata = {
|
|
1045
|
-
attempted: true,
|
|
1046
|
-
success: false,
|
|
1047
|
-
error,
|
|
1048
|
-
latency,
|
|
1049
|
-
};
|
|
1050
|
-
this.telemetryHandler.recordTTSFailure(ttsProvider, error, latency);
|
|
1051
|
-
logger.error(`TTS synthesis failed in Mode 1 (direct input synthesis):`, ttsError);
|
|
1052
|
-
}
|
|
1053
|
-
return this.enhanceResult(baseResult, options, startTime);
|
|
1054
|
-
}
|
|
1055
|
-
async handleVideoFrameGeneration(options, messages, model, startTime) {
|
|
1056
|
-
if (!hasVideoFrames(messages)) {
|
|
1057
|
-
return null;
|
|
1058
|
-
}
|
|
1059
|
-
// Bug 2 fix: callers requesting structured output (schema or explicit
|
|
1060
|
-
// output.format) must NOT be hijacked into the prose-returning video
|
|
1061
|
-
// analysis path. Without this gate, schema/format are silently dropped
|
|
1062
|
-
// whenever messages contain >=3 image parts.
|
|
1063
|
-
if (options.schema !== undefined || options.output?.format !== undefined) {
|
|
1064
|
-
logger.info("[VideoFrameGen] Skipping video-frame analysis route; caller requested structured output", {
|
|
1065
|
-
provider: this.providerName,
|
|
1066
|
-
model: this.modelName,
|
|
1067
|
-
hasSchema: options.schema !== undefined,
|
|
1068
|
-
outputFormat: options.output?.format,
|
|
1069
|
-
});
|
|
1070
|
-
return null;
|
|
1071
|
-
}
|
|
1072
|
-
const videoAnalysisResult = await executeVideoAnalysis(messages, {
|
|
1073
|
-
provider: options.provider,
|
|
1074
|
-
providerName: this.providerName,
|
|
1075
|
-
region: options.region,
|
|
1076
|
-
});
|
|
1077
|
-
const userText = messages
|
|
1078
|
-
.filter((m) => m.role === "user")
|
|
1079
|
-
.flatMap((m) => Array.isArray(m.content)
|
|
1080
|
-
? m.content
|
|
1081
|
-
.filter((p) => p.type === "text")
|
|
1082
|
-
.map((p) => p.text)
|
|
1083
|
-
: [typeof m.content === "string" ? m.content : ""])
|
|
1084
|
-
.filter(Boolean)
|
|
1085
|
-
.join("\n")
|
|
1086
|
-
.trim();
|
|
1087
|
-
let formattedContent = videoAnalysisResult;
|
|
1088
|
-
let usage = { input: 0, output: 0, total: 0 };
|
|
1089
|
-
if (options.systemPrompt) {
|
|
1090
|
-
try {
|
|
1091
|
-
const formattingPrompt = userText
|
|
1092
|
-
? `The user asked: "${userText}"\n\nHere is the video/image analysis result from the visual analysis system:\n\n${videoAnalysisResult}\n\nBased on this analysis, provide your response.`
|
|
1093
|
-
: `Here is a video/image analysis result from the visual analysis system:\n\n${videoAnalysisResult}\n\nBased on this analysis, provide your response.`;
|
|
1094
|
-
logger.debug("[VideoAnalysis] Formatting via Claude", {
|
|
1095
|
-
userTextLength: userText.length,
|
|
1096
|
-
analysisLength: videoAnalysisResult.length,
|
|
1097
|
-
});
|
|
1098
|
-
const formattedResult = await generateText({
|
|
1099
|
-
model,
|
|
1100
|
-
system: options.systemPrompt,
|
|
1101
|
-
messages: [{ role: "user", content: formattingPrompt }],
|
|
1102
|
-
maxOutputTokens: options.maxTokens || 8192,
|
|
1103
|
-
temperature: 0.3,
|
|
1104
|
-
abortSignal: options.abortSignal,
|
|
1105
|
-
experimental_telemetry: this.telemetryHandler?.getTelemetryConfig(options, "generate"),
|
|
1106
|
-
});
|
|
1107
|
-
formattedContent = formattedResult.text;
|
|
1108
|
-
usage = extractTokenUsage(formattedResult.totalUsage ?? formattedResult.usage);
|
|
1109
|
-
logger.debug("[VideoAnalysis] Claude formatting complete", {
|
|
1110
|
-
formattedLength: formattedContent.length,
|
|
1111
|
-
usage,
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
catch (error) {
|
|
1115
|
-
logger.warn("[VideoAnalysis] Claude formatting failed, using raw Gemini output", {
|
|
1116
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
return this.enhanceResult({
|
|
1121
|
-
content: formattedContent,
|
|
1122
|
-
provider: options.provider ?? this.providerName,
|
|
1123
|
-
model: this.modelName,
|
|
1124
|
-
usage,
|
|
1125
|
-
}, options, startTime);
|
|
1126
|
-
}
|
|
1127
|
-
async executeStandardGenerateFlow(options, startTime, model, messages, tools) {
|
|
1128
|
-
// Apply a defensive default timeout (3 min) when the caller didn't pass
|
|
1129
|
-
// one. Without this guard, AI SDK's generateText() will wait forever on
|
|
1130
|
-
// an upstream that accepts the connection but never produces a response
|
|
1131
|
-
// (observed against the litellm gateway when a request triggers the
|
|
1132
|
-
// team-access denial path — connection stays open, no response is sent,
|
|
1133
|
-
// and the matrix test hangs the entire suite). Callers can still pass
|
|
1134
|
-
// a larger value (e.g. video generation passes 10 min).
|
|
1135
|
-
const effectiveTimeout = options.timeout ?? 180_000;
|
|
1136
|
-
const timeoutController = createTimeoutController(effectiveTimeout, this.providerName, "generate");
|
|
1137
|
-
const composedSignal = composeAbortSignals(options.abortSignal, timeoutController?.controller.signal);
|
|
1138
|
-
const composedOptions = composedSignal
|
|
1139
|
-
? { ...options, abortSignal: composedSignal }
|
|
1140
|
-
: options;
|
|
1141
|
-
let generateResult;
|
|
1142
|
-
try {
|
|
1143
|
-
generateResult = await this.executeGeneration(model, messages, tools, composedOptions);
|
|
1144
|
-
}
|
|
1145
|
-
finally {
|
|
1146
|
-
timeoutController?.cleanup();
|
|
1147
|
-
}
|
|
1148
|
-
this.analyzeAIResponse(generateResult);
|
|
1149
|
-
this.logGenerationComplete(generateResult);
|
|
1150
|
-
const responseTime = Date.now() - startTime;
|
|
1151
|
-
const { toolsUsed, toolExecutions } = this.extractToolInformation(generateResult);
|
|
1152
|
-
// Prefer the per-call recorder's real records (params/result/timing per
|
|
1153
|
-
// execution); fall back to a conversion of the step-extraction entries
|
|
1154
|
-
// for tools the recorder could not wrap (provider-executed tools).
|
|
1155
|
-
const toolExecutionRecords = resolveToolExecutionRecords(options, toolExecutions);
|
|
1156
|
-
let enhancedResult = this.formatEnhancedResult(generateResult, tools, toolsUsed, toolExecutionRecords, options);
|
|
1157
|
-
// Recorded AFTER formatEnhancedResult so telemetry sees the same usage
|
|
1158
|
-
// the caller gets: the cross-step aggregate (totalUsage, not last-step
|
|
1159
|
-
// usage) WITH the providerMetadata cache merge applied — otherwise
|
|
1160
|
-
// providers whose cache data lives only in providerMetadata would have
|
|
1161
|
-
// their cache tokens billed at the full input rate in OTEL metrics,
|
|
1162
|
-
// diverging from analytics.cost.
|
|
1163
|
-
await this.recordPerformanceMetrics(enhancedResult.usage, responseTime);
|
|
1164
|
-
enhancedResult = await this.synthesizeAIResponseIfNeeded(enhancedResult, options);
|
|
1165
|
-
const finalResult = await this.enhanceResult(enhancedResult, options, startTime);
|
|
1166
|
-
return finalResult;
|
|
1167
|
-
}
|
|
1168
|
-
async synthesizeAIResponseIfNeeded(enhancedResult, options) {
|
|
1169
|
-
if (!options.tts?.enabled || !options.tts?.useAiResponse) {
|
|
1170
|
-
return enhancedResult;
|
|
1171
|
-
}
|
|
1172
|
-
const ttsOptions = options.tts;
|
|
1173
|
-
const aiResponse = enhancedResult.content;
|
|
1174
|
-
const ttsProvider = ttsOptions.provider ?? options.provider ?? this.providerName;
|
|
1175
|
-
if (!aiResponse || !ttsProvider) {
|
|
1176
|
-
logger.warn(`TTS synthesis skipped despite being enabled`, {
|
|
1177
|
-
provider: this.providerName,
|
|
1178
|
-
hasAiResponse: !!aiResponse,
|
|
1179
|
-
aiResponseLength: aiResponse?.length ?? 0,
|
|
1180
|
-
hasProvider: !!ttsProvider,
|
|
1181
|
-
ttsConfig: {
|
|
1182
|
-
enabled: options.tts?.enabled,
|
|
1183
|
-
useAiResponse: options.tts?.useAiResponse,
|
|
1184
|
-
},
|
|
1185
|
-
reason: !aiResponse
|
|
1186
|
-
? "AI response is empty or undefined"
|
|
1187
|
-
: "Provider is missing",
|
|
1188
|
-
});
|
|
1189
|
-
return {
|
|
1190
|
-
...enhancedResult,
|
|
1191
|
-
ttsMetadata: {
|
|
1192
|
-
attempted: false,
|
|
1193
|
-
success: false,
|
|
1194
|
-
},
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
const ttsStartTime = Date.now();
|
|
1198
|
-
const ttsTimeout = this.getTimeout(options);
|
|
1199
|
-
try {
|
|
1200
|
-
const ttsResult = await withTimeoutFn(() => TTSProcessor.synthesize(aiResponse, ttsProvider, ttsOptions), ttsTimeout, `TTS synthesis timed out after ${ttsTimeout}ms for provider "${ttsProvider}"`);
|
|
1201
|
-
return {
|
|
1202
|
-
...enhancedResult,
|
|
1203
|
-
audio: ttsResult,
|
|
1204
|
-
ttsMetadata: {
|
|
1205
|
-
attempted: true,
|
|
1206
|
-
success: true,
|
|
1207
|
-
latency: Date.now() - ttsStartTime,
|
|
1208
|
-
},
|
|
1209
|
-
};
|
|
1210
|
-
}
|
|
1211
|
-
catch (ttsError) {
|
|
1212
|
-
const latency = Date.now() - ttsStartTime;
|
|
1213
|
-
const error = this.getTTSErrorDetails(ttsError);
|
|
1214
|
-
this.telemetryHandler.recordTTSFailure(ttsProvider, error, latency);
|
|
1215
|
-
logger.error(`TTS synthesis failed in Mode 2 (AI response synthesis):`, ttsError);
|
|
1216
|
-
return {
|
|
1217
|
-
...enhancedResult,
|
|
1218
|
-
ttsMetadata: {
|
|
1219
|
-
attempted: true,
|
|
1220
|
-
success: false,
|
|
1221
|
-
error,
|
|
1222
|
-
latency,
|
|
1223
|
-
},
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
getTTSErrorDetails(error) {
|
|
1228
|
-
if (error instanceof AsyncTimeoutError) {
|
|
1229
|
-
return {
|
|
1230
|
-
code: TTS_ERROR_CODES.SYNTHESIS_FAILED,
|
|
1231
|
-
message: error.message,
|
|
1232
|
-
retriable: true,
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
if (error instanceof NeuroLinkError) {
|
|
1236
|
-
return {
|
|
1237
|
-
code: error.code,
|
|
1238
|
-
message: error.message,
|
|
1239
|
-
retriable: error.retriable,
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
|
-
return {
|
|
1243
|
-
code: TTS_ERROR_CODES.SYNTHESIS_FAILED,
|
|
1244
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1245
|
-
};
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* BACKWARD COMPATIBILITY: Legacy generateText method
|
|
1249
|
-
* Converts EnhancedGenerateResult to TextGenerationResult format
|
|
1250
|
-
* Ensures existing scripts using createAIProvider().generateText() continue to work
|
|
1251
|
-
*/
|
|
1252
|
-
async generateText(options) {
|
|
1253
|
-
// Validate required parameters for backward compatibility - support both prompt and input.text
|
|
1254
|
-
const promptText = options.prompt || options.input?.text;
|
|
1255
|
-
if (!promptText ||
|
|
1256
|
-
typeof promptText !== "string" ||
|
|
1257
|
-
promptText.trim() === "") {
|
|
1258
|
-
throw new Error("GenerateText options must include prompt or input.text as a non-empty string");
|
|
1259
|
-
}
|
|
1260
|
-
// Call the main generate method
|
|
1261
|
-
const result = await this.generate(options);
|
|
1262
|
-
if (!result) {
|
|
1263
|
-
throw new Error("Generation failed: No result returned");
|
|
1264
|
-
}
|
|
1265
|
-
// Convert EnhancedGenerateResult to TextGenerationResult format
|
|
1266
|
-
return {
|
|
1267
|
-
content: result.content || "",
|
|
1268
|
-
provider: result.provider || this.providerName,
|
|
1269
|
-
model: result.model || this.modelName,
|
|
1270
|
-
usage: result.usage || {
|
|
1271
|
-
input: 0,
|
|
1272
|
-
output: 0,
|
|
1273
|
-
total: 0,
|
|
1274
|
-
},
|
|
1275
|
-
responseTime: 0, // BaseProvider doesn't track response time directly
|
|
1276
|
-
toolsUsed: result.toolsUsed || [],
|
|
1277
|
-
// Map ToolExecutionRecord entries to the legacy TextGenerationResult
|
|
1278
|
-
// shape: real timing and error status now come from the records.
|
|
1279
|
-
toolExecutions: result.toolExecutions?.map((te) => ({
|
|
1280
|
-
toolName: te.toolName,
|
|
1281
|
-
executionTime: te.durationMs,
|
|
1282
|
-
success: !te.isError,
|
|
1283
|
-
})),
|
|
1284
|
-
enhancedWithTools: !!(result.toolsUsed && result.toolsUsed.length > 0),
|
|
1285
|
-
analytics: result.analytics,
|
|
1286
|
-
evaluation: result.evaluation,
|
|
1287
|
-
audio: result.audio,
|
|
1288
|
-
// Forward reasoning fields populated by GenerationHandler from AI-SDK
|
|
1289
|
-
// reasoning parts (DeepSeek `reasoning_content`, Anthropic thinking,
|
|
1290
|
-
// Gemini thought parts, OpenAI o1).
|
|
1291
|
-
reasoning: result.reasoning,
|
|
1292
|
-
reasoningTokens: result.reasoningTokens,
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* Generate embeddings for text
|
|
1297
|
-
*
|
|
1298
|
-
* This is a default implementation that throws an error.
|
|
1299
|
-
* Providers that support embeddings (OpenAI, Google Vertex, Amazon Bedrock)
|
|
1300
|
-
* should override this method with their specific implementation.
|
|
1301
|
-
*
|
|
1302
|
-
* @param text - The text to embed
|
|
1303
|
-
* @param _modelName - Optional embedding model name (provider-specific)
|
|
1304
|
-
* @returns Promise resolving to the embedding vector (array of numbers)
|
|
1305
|
-
* @throws Error if the provider does not support embeddings
|
|
1306
|
-
*
|
|
1307
|
-
* @example
|
|
1308
|
-
* ```typescript
|
|
1309
|
-
* const provider = await ProviderFactory.createProvider('openai', 'text-embedding-3-small');
|
|
1310
|
-
* const embedding = await provider.embed('Hello world');
|
|
1311
|
-
* console.log(embedding); // [0.123, -0.456, ...]
|
|
1312
|
-
* ```
|
|
1313
|
-
*/
|
|
1314
|
-
async embed(text, _modelName) {
|
|
1315
|
-
logger.warn(`embed() called on ${this.providerName} which does not have a native implementation`, {
|
|
1316
|
-
textLength: text.length,
|
|
1317
|
-
});
|
|
1318
|
-
throw new Error(`Embedding generation is not supported by the ${this.providerName} provider. ` +
|
|
1319
|
-
`Supported providers: openai, vertex/google, bedrock, cohere, voyage, jina. ` +
|
|
1320
|
-
`Use an embedding model like text-embedding-3-small (OpenAI), text-embedding-004 (Vertex), ` +
|
|
1321
|
-
`embed-english-v3.0 (Cohere), voyage-3 (Voyage), jina-embeddings-v3 (Jina), ` +
|
|
1322
|
-
`or amazon.titan-embed-text-v2:0 (Bedrock).`);
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
1325
|
-
* Generate embeddings for multiple texts in a single batch
|
|
1326
|
-
*
|
|
1327
|
-
* This is a default implementation that throws an error.
|
|
1328
|
-
* Providers that support embeddings should override this method.
|
|
1329
|
-
* The AI SDK's embedMany automatically handles chunking for models with batch limits.
|
|
1330
|
-
*
|
|
1331
|
-
* @param texts - The texts to embed
|
|
1332
|
-
* @param _modelName - Optional embedding model name (provider-specific)
|
|
1333
|
-
* @returns Promise resolving to an array of embedding vectors
|
|
1334
|
-
* @throws Error if the provider does not support embeddings
|
|
1335
|
-
*/
|
|
1336
|
-
async embedMany(texts, _modelName) {
|
|
1337
|
-
logger.warn(`embedMany() called on ${this.providerName} which does not have a native implementation`, {
|
|
1338
|
-
count: texts.length,
|
|
1339
|
-
});
|
|
1340
|
-
throw new Error(`Batch embedding generation is not supported by the ${this.providerName} provider. ` +
|
|
1341
|
-
`Supported providers: openai, googleAiStudio, vertex/google, bedrock, cohere, voyage, jina. ` +
|
|
1342
|
-
`Use an embedding model like text-embedding-3-small (OpenAI), gemini-embedding-001 (Google AI), ` +
|
|
1343
|
-
`text-embedding-004 (Vertex), embed-english-v3.0 (Cohere), voyage-3 (Voyage), ` +
|
|
1344
|
-
`jina-embeddings-v3 (Jina), or amazon.titan-embed-text-v2:0 (Bedrock).`);
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Get the default embedding model for this provider
|
|
1348
|
-
*
|
|
1349
|
-
* Override in subclasses to provide provider-specific defaults.
|
|
1350
|
-
* Returns undefined for providers that don't support embeddings.
|
|
1351
|
-
*
|
|
1352
|
-
* @returns The default embedding model name, or undefined if not supported
|
|
1353
|
-
*/
|
|
1354
|
-
getDefaultEmbeddingModel() {
|
|
1355
|
-
// Default implementation returns undefined - providers override this
|
|
1356
|
-
return undefined;
|
|
1357
|
-
}
|
|
1358
|
-
// ===================
|
|
1359
|
-
// ===================
|
|
1360
|
-
// BZ-665: Schema-driven tool call repair
|
|
1361
|
-
// ===================
|
|
1362
|
-
/**
|
|
1363
|
-
* Create an `experimental_repairToolCall` handler for streamText/generateText.
|
|
1364
|
-
* Dynamically reads the tool's JSON schema to repair wrong names and params.
|
|
1365
|
-
* Returns undefined when repair is disabled via options.
|
|
1366
|
-
*/
|
|
1367
|
-
getToolCallRepairFn(options) {
|
|
1368
|
-
if (options?.disableToolCallRepair) {
|
|
1369
|
-
return undefined;
|
|
1370
|
-
}
|
|
1371
|
-
// Lazy import to avoid circular dependency at module load time
|
|
1372
|
-
return (async (...args) => {
|
|
1373
|
-
const { createToolCallRepair } = await import("../utils/toolCallRepair.js");
|
|
1374
|
-
return createToolCallRepair()(...args);
|
|
1375
|
-
});
|
|
1376
|
-
}
|
|
1377
|
-
/**
|
|
1378
|
-
* Provider-specific streaming implementation (only used when tools are
|
|
1379
|
-
* disabled).
|
|
1380
|
-
*
|
|
1381
|
-
* This used to be `protected abstract`, which meant a provider had exactly
|
|
1382
|
-
* two options: write the whole adapter by hand, or not stream at all. The
|
|
1383
|
-
* failure mode that produced was SageMaker's — a complete, working
|
|
1384
|
-
* `doStream` sitting one property access away from an `executeStream` that
|
|
1385
|
-
* unconditionally threw "not yet fully implemented". Providers that
|
|
1386
|
-
* implement `doStream` now inherit a correct implementation, and providers
|
|
1387
|
-
* that override this method are unaffected.
|
|
1388
|
-
*/
|
|
1389
|
-
async executeStream(options, _analysisSchema) {
|
|
1390
|
-
if (!this.doStream) {
|
|
1391
|
-
throw new NeuroLinkError({
|
|
1392
|
-
code: ERROR_CODES.INVALID_CONFIGURATION,
|
|
1393
|
-
message: `${this.providerName} cannot stream: it neither implements doStream() nor overrides executeStream()`,
|
|
1394
|
-
category: ErrorCategory.CONFIGURATION,
|
|
1395
|
-
severity: ErrorSeverity.CRITICAL,
|
|
1396
|
-
retriable: false,
|
|
1397
|
-
context: { provider: this.providerName, model: this.modelName },
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
const startTime = Date.now();
|
|
1401
|
-
const { stream, finishReason, usage, warnings } = await this.doStream(options);
|
|
1402
|
-
if (warnings?.length) {
|
|
1403
|
-
logger.warn(`[${this.providerName}] doStream reported warnings`, {
|
|
1404
|
-
provider: this.providerName,
|
|
1405
|
-
count: warnings.length,
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
// `metadata` is handed back by reference and filled in when the turn
|
|
1409
|
-
// ends — the documented contract for background-loop streams, since a
|
|
1410
|
-
// result-object spread would snapshot a top-level getter before the
|
|
1411
|
-
// stream has produced anything.
|
|
1412
|
-
const metadata = {
|
|
1413
|
-
startTime,
|
|
1414
|
-
streamId: `${this.providerName}-${startTime}`,
|
|
1415
|
-
};
|
|
1416
|
-
// Chained off the provider's own promises rather than off the consumer
|
|
1417
|
-
// draining the stream. Binding analytics to a stream iterator's finally
|
|
1418
|
-
// block means a caller that awaits analytics without iterating waits
|
|
1419
|
-
// forever, because a generator body does not run until it is iterated.
|
|
1420
|
-
const analytics = (async () => {
|
|
1421
|
-
const [resolvedFinishReason, resolvedUsage] = await Promise.all([
|
|
1422
|
-
finishReason,
|
|
1423
|
-
usage,
|
|
1424
|
-
]);
|
|
1425
|
-
metadata.finishReason = resolvedFinishReason;
|
|
1426
|
-
metadata.rawFinishReason = resolvedFinishReason;
|
|
1427
|
-
return buildAnalytics(this.providerName, this.modelName || this.getDefaultModel(), {
|
|
1428
|
-
usage: {
|
|
1429
|
-
input: resolvedUsage.inputTokens,
|
|
1430
|
-
output: resolvedUsage.outputTokens,
|
|
1431
|
-
total: resolvedUsage.inputTokens + resolvedUsage.outputTokens,
|
|
1432
|
-
},
|
|
1433
|
-
stopReason: resolvedFinishReason,
|
|
1434
|
-
}, Date.now() - startTime, { streamingMode: true });
|
|
1435
|
-
})();
|
|
1436
|
-
return {
|
|
1437
|
-
stream,
|
|
1438
|
-
model: this.modelName || this.getDefaultModel(),
|
|
1439
|
-
provider: this.getProviderName(),
|
|
1440
|
-
analytics,
|
|
1441
|
-
metadata,
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
/**
|
|
1445
|
-
* Get AI SDK model with middleware applied
|
|
1446
|
-
* This method wraps the base model with any configured middleware
|
|
1447
|
-
* TODO(#1179): Implement global level middlewares that can be used
|
|
1448
|
-
*/
|
|
1449
|
-
async getAISDKModelWithMiddleware(options = {}) {
|
|
1450
|
-
// Get the base model
|
|
1451
|
-
const baseModel = await this.getAISDKModel();
|
|
1452
|
-
logger.debug(`Retrieved base model for ${this.providerName}`, {
|
|
1453
|
-
provider: this.providerName,
|
|
1454
|
-
model: this.modelName,
|
|
1455
|
-
hasMiddlewareConfig: !!this.middlewareOptions,
|
|
1456
|
-
timestamp: Date.now(),
|
|
1457
|
-
});
|
|
1458
|
-
// Check if middleware should be applied
|
|
1459
|
-
const middlewareOptions = this.extractMiddlewareOptions(options);
|
|
1460
|
-
logger.debug(`Middleware extraction result`, {
|
|
1461
|
-
provider: this.providerName,
|
|
1462
|
-
model: this.modelName,
|
|
1463
|
-
middlewareOptions,
|
|
1464
|
-
});
|
|
1465
|
-
if (!middlewareOptions) {
|
|
1466
|
-
return baseModel;
|
|
1467
|
-
}
|
|
1468
|
-
try {
|
|
1469
|
-
logger.debug(`Applying middleware to ${this.providerName} model`, {
|
|
1470
|
-
provider: this.providerName,
|
|
1471
|
-
model: this.modelName,
|
|
1472
|
-
middlewareOptions,
|
|
1473
|
-
});
|
|
1474
|
-
// Create a new factory instance with the specified options
|
|
1475
|
-
const factory = new MiddlewareFactory(middlewareOptions);
|
|
1476
|
-
// Create middleware context
|
|
1477
|
-
const context = factory.createContext(this.providerName, this.modelName, options, {
|
|
1478
|
-
sessionId: this.sessionId,
|
|
1479
|
-
userId: this.userId,
|
|
1480
|
-
});
|
|
1481
|
-
// Apply middleware to the model
|
|
1482
|
-
const wrappedModel = factory.applyMiddleware(baseModel, context, middlewareOptions);
|
|
1483
|
-
logger.debug(`Applied middleware to ${this.providerName} model`, {
|
|
1484
|
-
provider: this.providerName,
|
|
1485
|
-
model: this.modelName,
|
|
1486
|
-
hasMiddleware: true,
|
|
1487
|
-
});
|
|
1488
|
-
return wrappedModel;
|
|
1489
|
-
}
|
|
1490
|
-
catch (error) {
|
|
1491
|
-
logger.warn(`Failed to apply middleware to ${this.providerName}, using base model`, {
|
|
1492
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1493
|
-
});
|
|
1494
|
-
// Return base model on middleware failure to maintain functionality
|
|
1495
|
-
return baseModel;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Extract middleware options - delegated to Utilities
|
|
1500
|
-
*/
|
|
1501
|
-
extractMiddlewareOptions(options) {
|
|
1502
|
-
return this.utilities.extractMiddlewareOptions(options);
|
|
1503
|
-
}
|
|
1504
|
-
// ===================
|
|
1505
|
-
// TOOL MANAGEMENT
|
|
1506
|
-
// ===================
|
|
1507
|
-
/**
|
|
1508
|
-
* Check if a schema is a Zod schema - delegated to Utilities
|
|
1509
|
-
*/
|
|
1510
|
-
isZodSchema(schema) {
|
|
1511
|
-
return this.utilities.isZodSchema(schema);
|
|
1512
|
-
}
|
|
1513
|
-
/**
|
|
1514
|
-
* Convert tool execution result - delegated to Utilities
|
|
1515
|
-
*/
|
|
1516
|
-
async convertToolResult(result) {
|
|
1517
|
-
return this.utilities.convertToolResult(result);
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* Fix JSON Schema for OpenAI strict mode - delegated to Utilities
|
|
1521
|
-
*/
|
|
1522
|
-
fixSchemaForOpenAIStrictMode(schema) {
|
|
1523
|
-
return this.utilities.fixSchemaForOpenAIStrictMode(schema);
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Get all available tools - delegated to ToolsManager
|
|
1527
|
-
*/
|
|
1528
|
-
async getAllTools() {
|
|
1529
|
-
return this.toolsManager.getAllTools();
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Calculate actual cost - delegated to TelemetryHandler
|
|
1533
|
-
*/
|
|
1534
|
-
async calculateActualCost(usage) {
|
|
1535
|
-
return this.telemetryHandler.calculateActualCost(usage);
|
|
1536
|
-
}
|
|
1537
|
-
/**
|
|
1538
|
-
* Create a permissive Zod schema - delegated to Utilities
|
|
1539
|
-
*/
|
|
1540
|
-
createPermissiveZodSchema() {
|
|
1541
|
-
return this.utilities.createPermissiveZodSchema();
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Set session context for MCP tools - delegated to ToolsManager
|
|
1545
|
-
*/
|
|
1546
|
-
setSessionContext(sessionId, userId) {
|
|
1547
|
-
this.sessionId = sessionId;
|
|
1548
|
-
this.userId = userId;
|
|
1549
|
-
this.toolsManager.setSessionContext(sessionId, userId);
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
* Handle provider errors with abort passthrough.
|
|
1553
|
-
* AbortErrors are never wrapped — they must propagate with their
|
|
1554
|
-
* original identity so that isAbortError() can detect them in
|
|
1555
|
-
* retry/fallback loops (directProviderGeneration, performMCPGenerationRetries).
|
|
1556
|
-
*/
|
|
1557
|
-
handleProviderError(error) {
|
|
1558
|
-
if (isAbortError(error)) {
|
|
1559
|
-
// Preserve AbortError identity — never wrap in provider-specific formatting
|
|
1560
|
-
return error instanceof Error
|
|
1561
|
-
? error
|
|
1562
|
-
: new DOMException("The operation was aborted", "AbortError");
|
|
1563
|
-
}
|
|
1564
|
-
const formatted = this.formatProviderError(error);
|
|
1565
|
-
// Preserve transport retry metadata across formatting. Provider
|
|
1566
|
-
// formatters return fresh Error instances (RateLimitError, NetworkError,
|
|
1567
|
-
// …) that would otherwise destroy the classification upper layers need:
|
|
1568
|
-
// performMCPGenerationRetries' isRetryable/status checks and
|
|
1569
|
-
// providerRetry's Retry-After extraction. Copied generically so every
|
|
1570
|
-
// provider's 429/5xx keeps its status and server-requested delay.
|
|
1571
|
-
if (error && typeof error === "object" && formatted !== error) {
|
|
1572
|
-
const src = error;
|
|
1573
|
-
const dst = formatted;
|
|
1574
|
-
const statusCode = duckTypedStatusCode(error);
|
|
1575
|
-
if (statusCode !== undefined && dst.statusCode === undefined) {
|
|
1576
|
-
dst.statusCode = statusCode;
|
|
1577
|
-
}
|
|
1578
|
-
if (typeof src.isRetryable === "boolean" &&
|
|
1579
|
-
dst.isRetryable === undefined) {
|
|
1580
|
-
dst.isRetryable = src.isRetryable;
|
|
1581
|
-
}
|
|
1582
|
-
if (dst.retryAfterMs === undefined) {
|
|
1583
|
-
const retryAfterMs = extractRetryAfterMsFromError(error);
|
|
1584
|
-
if (retryAfterMs !== undefined) {
|
|
1585
|
-
dst.retryAfterMs = retryAfterMs;
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
// Preserve the lifecycle-fired mark across formatting:
|
|
1590
|
-
// fireLifecycleErrorCallback() marks the ORIGINAL error in the shared
|
|
1591
|
-
// WeakSet, but formatProviderError() typically returns a new Error
|
|
1592
|
-
// instance. Re-mark the formatted error so a higher layer (e.g.
|
|
1593
|
-
// NeuroLink.stream()'s top-level catch + applyStreamLifecycleMiddleware)
|
|
1594
|
-
// doesn't fire onError a second time for the same failure.
|
|
1595
|
-
if (hasLifecycleErrorFired(error)) {
|
|
1596
|
-
markLifecycleErrorFired(formatted);
|
|
1597
|
-
}
|
|
1598
|
-
// P3 fix: Classify error and set error.type on the active OTel span
|
|
1599
|
-
try {
|
|
1600
|
-
const activeSpan = trace.getSpan(context.active());
|
|
1601
|
-
if (activeSpan) {
|
|
1602
|
-
let errorType = "provider_error";
|
|
1603
|
-
const errName = formatted?.constructor?.name ?? "";
|
|
1604
|
-
if (errName === "RateLimitError") {
|
|
1605
|
-
errorType = "rate_limit";
|
|
1606
|
-
}
|
|
1607
|
-
else if (errName === "AuthenticationError") {
|
|
1608
|
-
errorType = "auth_failure";
|
|
1609
|
-
}
|
|
1610
|
-
else if (errName === "NetworkError") {
|
|
1611
|
-
errorType = "network";
|
|
1612
|
-
}
|
|
1613
|
-
else if (errName === "InvalidModelError") {
|
|
1614
|
-
errorType = "invalid_model";
|
|
1615
|
-
}
|
|
1616
|
-
else if (errName === "TimeoutError") {
|
|
1617
|
-
errorType = "timeout";
|
|
1618
|
-
}
|
|
1619
|
-
activeSpan.setAttribute("error.type", errorType);
|
|
1620
|
-
if (formatted instanceof Error) {
|
|
1621
|
-
activeSpan.setAttribute("error.message", formatted.message.substring(0, 500));
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
catch {
|
|
1626
|
-
// Non-blocking — telemetry failures shouldn't mask the original error
|
|
1627
|
-
}
|
|
1628
|
-
return formatted;
|
|
1629
|
-
}
|
|
1630
|
-
/**
|
|
1631
|
-
* Image generation method. Providers that support it should override this.
|
|
1632
|
-
* By default, it throws an error indicating that the functionality is not supported.
|
|
1633
|
-
* @param _options The generation options.
|
|
1634
|
-
* @returns A promise that resolves to the generation result.
|
|
1635
|
-
*/
|
|
1636
|
-
async executeImageGeneration(_options) {
|
|
1637
|
-
throw new Error(`Image generation is not supported by the ${this.providerName} provider or the selected model.`);
|
|
1638
|
-
}
|
|
1639
|
-
// ===================
|
|
1640
|
-
// CONSOLIDATED PROVIDER METHODS - MOVED FROM INDIVIDUAL PROVIDERS
|
|
1641
|
-
// ===================
|
|
1642
|
-
/**
|
|
1643
|
-
* Execute operation with timeout and proper cleanup
|
|
1644
|
-
* Consolidates identical timeout handling from 8/10 providers
|
|
1645
|
-
*/
|
|
1646
|
-
async executeWithTimeout(operation, options) {
|
|
1647
|
-
const timeout = this.getTimeout(options);
|
|
1648
|
-
const timeoutController = createTimeoutController(timeout, this.providerName, options.operationType || "generate");
|
|
1649
|
-
try {
|
|
1650
|
-
if (timeoutController) {
|
|
1651
|
-
return await Promise.race([
|
|
1652
|
-
operation(),
|
|
1653
|
-
new Promise((_, reject) => {
|
|
1654
|
-
timeoutController.controller.signal.addEventListener("abort", () => {
|
|
1655
|
-
reject(new TimeoutError(`${this.providerName} operation timed out`, timeoutController.timeoutMs, this.providerName, options.operationType ||
|
|
1656
|
-
"generate"));
|
|
1657
|
-
});
|
|
1658
|
-
}),
|
|
1659
|
-
]);
|
|
1660
|
-
}
|
|
1661
|
-
else {
|
|
1662
|
-
return await operation();
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
finally {
|
|
1666
|
-
timeoutController?.cleanup();
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
/**
|
|
1670
|
-
* Validate stream options - delegated to StreamHandler
|
|
1671
|
-
*/
|
|
1672
|
-
validateStreamOptions(options) {
|
|
1673
|
-
this.streamHandler.validateStreamOptions(options);
|
|
1674
|
-
}
|
|
1675
|
-
/**
|
|
1676
|
-
* Create text stream transformation - delegated to StreamHandler.
|
|
1677
|
-
* Reviewer follow-up: forwards the optional `getUnderlyingError`
|
|
1678
|
-
* callback so providers can capture upstream errors via
|
|
1679
|
-
* `streamText`'s `onError` and have them flow into the
|
|
1680
|
-
* NoOutputGeneratedError sentinel's `providerError` /
|
|
1681
|
-
* `modelResponseRaw`.
|
|
1682
|
-
*/
|
|
1683
|
-
createTextStream(result, getUnderlyingError) {
|
|
1684
|
-
return this.streamHandler.createTextStream(result, getUnderlyingError);
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* Create standardized stream result - delegated to StreamHandler
|
|
1688
|
-
*/
|
|
1689
|
-
createStreamResult(stream, additionalProps = {}) {
|
|
1690
|
-
return this.streamHandler.createStreamResult(stream, additionalProps);
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* Create stream analytics - delegated to StreamHandler
|
|
1694
|
-
*/
|
|
1695
|
-
async createStreamAnalytics(result, startTime, options) {
|
|
1696
|
-
return this.streamHandler.createStreamAnalytics(result, startTime, options);
|
|
1697
|
-
}
|
|
1698
|
-
/**
|
|
1699
|
-
* Handle common error patterns - delegated to Utilities
|
|
1700
|
-
*/
|
|
1701
|
-
handleCommonErrors(error) {
|
|
1702
|
-
return this.utilities.handleCommonErrors(error);
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* Set up tool executor - delegated to ToolsManager
|
|
1706
|
-
* @param sdk - The NeuroLinkSDK instance for tool execution
|
|
1707
|
-
* @param functionTag - Function name for logging
|
|
1708
|
-
*/
|
|
1709
|
-
setupToolExecutor(sdk, functionTag) {
|
|
1710
|
-
this.toolsManager.setupToolExecutor(sdk, functionTag);
|
|
1711
|
-
}
|
|
1712
|
-
// ===================
|
|
1713
|
-
// TEMPLATE METHODS - COMMON FUNCTIONALITY
|
|
1714
|
-
// ===================
|
|
1715
|
-
/**
|
|
1716
|
-
* Normalize text generation options - delegated to Utilities
|
|
1717
|
-
*/
|
|
1718
|
-
normalizeTextOptions(optionsOrPrompt) {
|
|
1719
|
-
return this.utilities.normalizeTextOptions(optionsOrPrompt);
|
|
1720
|
-
}
|
|
1721
|
-
/**
|
|
1722
|
-
* Normalize stream options - delegated to Utilities
|
|
1723
|
-
*/
|
|
1724
|
-
normalizeStreamOptions(optionsOrPrompt) {
|
|
1725
|
-
return this.utilities.normalizeStreamOptions(optionsOrPrompt);
|
|
1726
|
-
}
|
|
1727
|
-
async enhanceResult(result, options, startTime) {
|
|
1728
|
-
const responseTime = Date.now() - startTime;
|
|
1729
|
-
// CRITICAL FIX: Store imageOutput separately to ensure it's preserved
|
|
1730
|
-
const imageOutput = result.imageOutput;
|
|
1731
|
-
let enhancedResult = { ...result };
|
|
1732
|
-
if (options.enableAnalytics) {
|
|
1733
|
-
try {
|
|
1734
|
-
const analytics = await this.createAnalytics(result, responseTime, options);
|
|
1735
|
-
// Preserve ALL fields including imageOutput when adding analytics
|
|
1736
|
-
enhancedResult = { ...enhancedResult, analytics, imageOutput };
|
|
1737
|
-
}
|
|
1738
|
-
catch (error) {
|
|
1739
|
-
logger.warn(`Analytics creation failed for ${this.providerName}:`, error);
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1742
|
-
if (options.enableEvaluation) {
|
|
1743
|
-
try {
|
|
1744
|
-
const evaluation = await this.createEvaluation(result, options);
|
|
1745
|
-
// Preserve ALL fields including imageOutput when adding evaluation
|
|
1746
|
-
enhancedResult = { ...enhancedResult, evaluation, imageOutput };
|
|
1747
|
-
}
|
|
1748
|
-
catch (error) {
|
|
1749
|
-
logger.warn(`Evaluation creation failed for ${this.providerName}:`, error);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
// CRITICAL FIX: Always restore imageOutput if it existed in the original result
|
|
1753
|
-
if (imageOutput) {
|
|
1754
|
-
enhancedResult.imageOutput = imageOutput;
|
|
1755
|
-
}
|
|
1756
|
-
return enhancedResult;
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* Handle video generation mode
|
|
1760
|
-
*
|
|
1761
|
-
* Generates video from input image + text prompt using Vertex AI Veo 3.1.
|
|
1762
|
-
*
|
|
1763
|
-
* @param options - Text generation options with video configuration
|
|
1764
|
-
* @param startTime - Generation start timestamp for metrics
|
|
1765
|
-
* @returns Enhanced result with video data
|
|
1766
|
-
*
|
|
1767
|
-
* @example
|
|
1768
|
-
* ```typescript
|
|
1769
|
-
* const result = await provider.generate({
|
|
1770
|
-
* input: { text: "Product showcase", images: [imageBuffer] },
|
|
1771
|
-
* output: { mode: "video", video: { resolution: "1080p" } }
|
|
1772
|
-
* });
|
|
1773
|
-
* // result.video contains the generated video
|
|
1774
|
-
* ```
|
|
1775
|
-
*/
|
|
1776
|
-
// eslint-disable-next-line max-lines-per-function
|
|
1777
|
-
async handleVideoGeneration(options, startTime) {
|
|
1778
|
-
// Dynamic imports to avoid loading video dependencies unless needed.
|
|
1779
|
-
// Pull VideoError + VIDEO_ERROR_CODES from VideoProcessor (which already
|
|
1780
|
-
// re-exports both) so non-vertex routes don't carry a direct dependency
|
|
1781
|
-
// on the Vertex adapter's module.
|
|
1782
|
-
const { VideoProcessor, VideoError, VIDEO_ERROR_CODES } = await import("../utils/videoProcessor.js");
|
|
1783
|
-
const { validateVideoGenerationInput, validateImageForVideo, validateDirectorModeInput, } = await import("../utils/parameterValidation.js");
|
|
1784
|
-
const { ErrorFactory } = await import("../utils/errorHandling.js");
|
|
1785
|
-
// Build GenerateOptions for validation
|
|
1786
|
-
const generateOptions = {
|
|
1787
|
-
input: options.input || { text: options.prompt || "" },
|
|
1788
|
-
output: options.output,
|
|
1789
|
-
provider: options.provider,
|
|
1790
|
-
model: options.model,
|
|
1791
|
-
};
|
|
1792
|
-
// ===== DIRECTOR MODE =====
|
|
1793
|
-
// Route to Director pipeline when segments are provided
|
|
1794
|
-
if (generateOptions.input?.segments &&
|
|
1795
|
-
Array.isArray(generateOptions.input.segments) &&
|
|
1796
|
-
generateOptions.input.segments.length > 0) {
|
|
1797
|
-
// Type narrowing: segments is guaranteed to exist here
|
|
1798
|
-
const segments = generateOptions.input.segments;
|
|
1799
|
-
const directorValidation = validateDirectorModeInput(generateOptions);
|
|
1800
|
-
if (!directorValidation.isValid) {
|
|
1801
|
-
throw ErrorFactory.invalidParameters("director-mode", new Error(directorValidation.errors
|
|
1802
|
-
.map((e) => e.message)
|
|
1803
|
-
.join("; ")), { errors: directorValidation.errors });
|
|
1804
|
-
}
|
|
1805
|
-
if (directorValidation.warnings.length > 0) {
|
|
1806
|
-
for (const warning of directorValidation.warnings) {
|
|
1807
|
-
logger.warn(`Director Mode warning: ${warning}`);
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
const { executeDirectorPipeline, DIRECTOR_PIPELINE_TIMEOUT_MS } = await import("../adapters/video/directorPipeline.js");
|
|
1811
|
-
// Use caller's timeout if provided, otherwise use default Director timeout
|
|
1812
|
-
const directorTimeout = options.timeout ?? DIRECTOR_PIPELINE_TIMEOUT_MS;
|
|
1813
|
-
const videoResult = await this.executeWithTimeout(() => executeDirectorPipeline(segments, generateOptions.output?.video ?? {}, generateOptions.output?.director ?? {}, options.region), { timeout: directorTimeout, operationType: "generate" });
|
|
1814
|
-
// Build content summary with metadata
|
|
1815
|
-
const joinedPrompts = generateOptions.input.segments
|
|
1816
|
-
.map((s) => s.prompt)
|
|
1817
|
-
.join(" → ");
|
|
1818
|
-
const segmentCount = videoResult.metadata?.segmentCount ??
|
|
1819
|
-
generateOptions.input.segments.length;
|
|
1820
|
-
const transitionCount = videoResult.metadata?.transitionCount ?? Math.max(0, segmentCount - 1);
|
|
1821
|
-
const totalDuration = videoResult.metadata?.duration ?? 0;
|
|
1822
|
-
const contentSummary = `${joinedPrompts} — duration: ${totalDuration}s, segments: ${segmentCount}, transitions: ${transitionCount}`;
|
|
1823
|
-
const baseResult = {
|
|
1824
|
-
content: contentSummary,
|
|
1825
|
-
provider: "vertex",
|
|
1826
|
-
model: options.model || "veo-3.1-generate-001",
|
|
1827
|
-
usage: { input: 0, output: 0, total: 0 },
|
|
1828
|
-
video: videoResult,
|
|
1829
|
-
};
|
|
1830
|
-
return await this.enhanceResult(baseResult, options, startTime);
|
|
1831
|
-
}
|
|
1832
|
-
// ===== STANDARD SINGLE-CLIP VIDEO GENERATION =====
|
|
1833
|
-
// Validate video generation input
|
|
1834
|
-
const validation = validateVideoGenerationInput(generateOptions);
|
|
1835
|
-
if (!validation.isValid) {
|
|
1836
|
-
throw ErrorFactory.invalidParameters("video-generation", new Error(validation.errors.map((e) => e.message).join("; ")), { errors: validation.errors });
|
|
1837
|
-
}
|
|
1838
|
-
// Log warnings if any
|
|
1839
|
-
if (validation.warnings.length > 0) {
|
|
1840
|
-
for (const warning of validation.warnings) {
|
|
1841
|
-
logger.warn(`Video generation warning: ${warning}`);
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
// Extract image from input
|
|
1845
|
-
const imageInput = options.input?.images?.[0];
|
|
1846
|
-
if (!imageInput) {
|
|
1847
|
-
throw new VideoError({
|
|
1848
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1849
|
-
message: "Video generation requires an input image. Provide via input.images array.",
|
|
1850
|
-
retriable: false,
|
|
1851
|
-
context: { field: "input.images" },
|
|
1852
|
-
});
|
|
1853
|
-
}
|
|
1854
|
-
// Timeout for image IO operations (15 seconds)
|
|
1855
|
-
const IMAGE_IO_TIMEOUT_MS = 15000;
|
|
1856
|
-
// Load image buffer if path/URL
|
|
1857
|
-
let imageBuffer;
|
|
1858
|
-
if (typeof imageInput === "string") {
|
|
1859
|
-
if (imageInput.startsWith("http://") ||
|
|
1860
|
-
imageInput.startsWith("https://")) {
|
|
1861
|
-
// URL - fetch the image with timeout
|
|
1862
|
-
logger.debug("Fetching image from URL for video generation", {
|
|
1863
|
-
url: imageInput.substring(0, 100),
|
|
1864
|
-
});
|
|
1865
|
-
let response;
|
|
1866
|
-
try {
|
|
1867
|
-
response = await this.executeWithTimeout(() => fetch(imageInput), {
|
|
1868
|
-
timeout: IMAGE_IO_TIMEOUT_MS,
|
|
1869
|
-
operationType: "generate", // Part of video generation flow
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
catch (error) {
|
|
1873
|
-
throw new VideoError({
|
|
1874
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1875
|
-
message: `Failed to fetch image from URL: ${error instanceof Error ? error.message : "Request timed out"}`,
|
|
1876
|
-
retriable: true,
|
|
1877
|
-
context: { url: imageInput, timeout: IMAGE_IO_TIMEOUT_MS },
|
|
1878
|
-
originalError: error instanceof Error ? error : undefined,
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1881
|
-
if (!response.ok) {
|
|
1882
|
-
throw new VideoError({
|
|
1883
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1884
|
-
message: `Failed to fetch image from URL: ${response.status} ${response.statusText}`,
|
|
1885
|
-
retriable: response.status >= 500,
|
|
1886
|
-
context: { url: imageInput, status: response.status },
|
|
1887
|
-
});
|
|
1888
|
-
}
|
|
1889
|
-
imageBuffer = Buffer.from(await response.arrayBuffer());
|
|
1890
|
-
}
|
|
1891
|
-
else {
|
|
1892
|
-
// File path - read from disk with timeout
|
|
1893
|
-
logger.debug("Reading image from path for video generation", {
|
|
1894
|
-
path: imageInput,
|
|
1895
|
-
});
|
|
1896
|
-
const fs = await import("node:fs/promises");
|
|
1897
|
-
try {
|
|
1898
|
-
imageBuffer = await this.executeWithTimeout(() => fs.readFile(imageInput), { timeout: IMAGE_IO_TIMEOUT_MS, operationType: "generate" });
|
|
1899
|
-
}
|
|
1900
|
-
catch (error) {
|
|
1901
|
-
throw new VideoError({
|
|
1902
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1903
|
-
message: `Failed to read image file: ${error instanceof Error ? error.message : String(error)}`,
|
|
1904
|
-
retriable: false,
|
|
1905
|
-
context: { path: imageInput, timeout: IMAGE_IO_TIMEOUT_MS },
|
|
1906
|
-
originalError: error instanceof Error ? error : undefined,
|
|
1907
|
-
});
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
else if (Buffer.isBuffer(imageInput)) {
|
|
1912
|
-
imageBuffer = imageInput;
|
|
1913
|
-
}
|
|
1914
|
-
else if (typeof imageInput === "object" && "data" in imageInput) {
|
|
1915
|
-
// ImageWithAltText type
|
|
1916
|
-
const imgData = imageInput.data;
|
|
1917
|
-
if (typeof imgData === "string") {
|
|
1918
|
-
imageBuffer = Buffer.from(imgData, "base64");
|
|
1919
|
-
}
|
|
1920
|
-
else if (Buffer.isBuffer(imgData)) {
|
|
1921
|
-
imageBuffer = imgData;
|
|
1922
|
-
}
|
|
1923
|
-
else {
|
|
1924
|
-
throw new VideoError({
|
|
1925
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1926
|
-
message: "ImageWithAltText.data must be a base64 string or Buffer.",
|
|
1927
|
-
retriable: false,
|
|
1928
|
-
context: { field: "input.images[0].data", type: typeof imgData },
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
else {
|
|
1933
|
-
throw new VideoError({
|
|
1934
|
-
code: VIDEO_ERROR_CODES.INVALID_INPUT,
|
|
1935
|
-
message: "Invalid image input type. Provide Buffer, path string, URL, or ImageWithAltText.",
|
|
1936
|
-
retriable: false,
|
|
1937
|
-
context: { field: "input.images[0]", type: typeof imageInput },
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
// Validate image format and size (for Buffer inputs)
|
|
1941
|
-
const imageValidation = validateImageForVideo(imageBuffer);
|
|
1942
|
-
if (imageValidation) {
|
|
1943
|
-
throw ErrorFactory.invalidParameters("video-generation", new Error(imageValidation.message), {
|
|
1944
|
-
field: "input.images[0]",
|
|
1945
|
-
validation: imageValidation,
|
|
1946
|
-
});
|
|
1947
|
-
}
|
|
1948
|
-
// Get prompt text
|
|
1949
|
-
const prompt = options.prompt || options.input?.text || "";
|
|
1950
|
-
// Honor output.video.provider — when omitted, fall back to "vertex"
|
|
1951
|
-
// for backward compatibility with the original implementation.
|
|
1952
|
-
const requestedProvider = options.output?.video?.provider ?? "vertex";
|
|
1953
|
-
if (!VideoProcessor.supports(requestedProvider)) {
|
|
1954
|
-
throw new VideoError({
|
|
1955
|
-
code: VIDEO_ERROR_CODES.PROVIDER_NOT_SUPPORTED,
|
|
1956
|
-
message: `Video provider "${requestedProvider}" is not registered. Available: ${VideoProcessor.listProviders().join(", ")}`,
|
|
1957
|
-
retriable: false,
|
|
1958
|
-
context: {
|
|
1959
|
-
provider: requestedProvider,
|
|
1960
|
-
available: VideoProcessor.listProviders(),
|
|
1961
|
-
},
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
// Resolve the model name without hardcoding a Vertex default for
|
|
1965
|
-
// non-Vertex routes. Precedence: caller-supplied output.video.model,
|
|
1966
|
-
// then options.model (LLM-level field that the caller may have repurposed
|
|
1967
|
-
// for video), then the Vertex Veo default but only when we're actually
|
|
1968
|
-
// calling Vertex. Otherwise leave it null at this stage and let the
|
|
1969
|
-
// handler's metadata fill it in below.
|
|
1970
|
-
const requestedVideoModel = options.output?.video?.model;
|
|
1971
|
-
const resolvedRequestModel = requestedVideoModel ??
|
|
1972
|
-
options.model ??
|
|
1973
|
-
(requestedProvider === "vertex" ? "veo-3.1-generate-001" : undefined);
|
|
1974
|
-
logger.info("Starting video generation", {
|
|
1975
|
-
provider: requestedProvider,
|
|
1976
|
-
...(resolvedRequestModel ? { model: resolvedRequestModel } : {}),
|
|
1977
|
-
promptLength: prompt.length,
|
|
1978
|
-
imageSize: imageBuffer.length,
|
|
1979
|
-
resolution: options.output?.video?.resolution || "720p",
|
|
1980
|
-
duration: options.output?.video?.length || 6,
|
|
1981
|
-
});
|
|
1982
|
-
// Dispatch through the central VideoProcessor — picks up vertex,
|
|
1983
|
-
// kling, runway, replicate (or any custom handler) registered via
|
|
1984
|
-
// ProviderRegistry / VideoProcessor.registerHandler(). Wrap in the
|
|
1985
|
-
// shared timeout helper so standard video gen honors the caller's
|
|
1986
|
-
// timeout the same way director mode does (see above ~Line 2062).
|
|
1987
|
-
const videoTimeout = options.timeout ?? 600_000; // 10 min default
|
|
1988
|
-
const videoResult = await this.executeWithTimeout(() => VideoProcessor.generate(requestedProvider, imageBuffer, prompt, options.output?.video ?? {}, options.region), { timeout: videoTimeout, operationType: "generate" });
|
|
1989
|
-
// Prefer the handler's own model id (more accurate — it knows the exact
|
|
1990
|
-
// checkpoint that ran). Fall back to the request-time value, and finally
|
|
1991
|
-
// to the Vertex default only when we're on the Vertex route.
|
|
1992
|
-
const responseModel = videoResult.metadata?.model ??
|
|
1993
|
-
resolvedRequestModel ??
|
|
1994
|
-
(requestedProvider === "vertex" ? "veo-3.1-generate-001" : "unknown");
|
|
1995
|
-
logger.info("Video generation complete", {
|
|
1996
|
-
provider: requestedProvider,
|
|
1997
|
-
model: responseModel,
|
|
1998
|
-
videoSize: videoResult.data.length,
|
|
1999
|
-
duration: videoResult.metadata?.duration,
|
|
2000
|
-
processingTime: videoResult.metadata?.processingTime,
|
|
2001
|
-
});
|
|
2002
|
-
// Build result
|
|
2003
|
-
const baseResult = {
|
|
2004
|
-
content: prompt, // Echo the prompt as content
|
|
2005
|
-
provider: requestedProvider,
|
|
2006
|
-
model: responseModel,
|
|
2007
|
-
usage: { input: 0, output: 0, total: 0 },
|
|
2008
|
-
video: videoResult,
|
|
2009
|
-
};
|
|
2010
|
-
return await this.enhanceResult(baseResult, options, startTime);
|
|
2011
|
-
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Create analytics - delegated to TelemetryHandler
|
|
2014
|
-
*/
|
|
2015
|
-
async createAnalytics(result, responseTime, options) {
|
|
2016
|
-
return this.telemetryHandler.createAnalytics(result, responseTime, options.context);
|
|
2017
|
-
}
|
|
2018
|
-
/**
|
|
2019
|
-
* Create evaluation - delegated to TelemetryHandler
|
|
2020
|
-
*/
|
|
2021
|
-
async createEvaluation(result, options) {
|
|
2022
|
-
return this.telemetryHandler.createEvaluation(result, options);
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* Validate text generation options - delegated to Utilities
|
|
2026
|
-
*/
|
|
2027
|
-
validateOptions(options) {
|
|
2028
|
-
this.utilities.validateOptions(options);
|
|
2029
|
-
}
|
|
2030
|
-
/**
|
|
2031
|
-
* Get provider information - delegated to Utilities
|
|
2032
|
-
*/
|
|
2033
|
-
getProviderInfo() {
|
|
2034
|
-
return this.utilities.getProviderInfo();
|
|
2035
|
-
}
|
|
2036
|
-
/**
|
|
2037
|
-
* Get timeout value in milliseconds - delegated to Utilities
|
|
2038
|
-
*/
|
|
2039
|
-
getTimeout(options) {
|
|
2040
|
-
return this.utilities.getTimeout(options);
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* Check if tool executions should be stored and handle storage
|
|
2044
|
-
*/
|
|
2045
|
-
async handleToolExecutionStorage(toolCalls, toolResults, options, currentTime) {
|
|
2046
|
-
return this.telemetryHandler.handleToolExecutionStorage(toolCalls, toolResults, options, currentTime);
|
|
2047
|
-
}
|
|
2048
|
-
/**
|
|
2049
|
-
* Utility method to chunk large prompts into smaller pieces
|
|
2050
|
-
* @param prompt The prompt to chunk
|
|
2051
|
-
* @param maxChunkSize Maximum size per chunk (default: 900,000 characters)
|
|
2052
|
-
* @param overlap Overlap between chunks to maintain context (default: 100 characters)
|
|
2053
|
-
* @returns Array of prompt chunks
|
|
2054
|
-
*/
|
|
2055
|
-
static chunkPrompt(prompt, maxChunkSize = 900000, overlap = 100) {
|
|
2056
|
-
if (prompt.length <= maxChunkSize) {
|
|
2057
|
-
return [prompt];
|
|
2058
|
-
}
|
|
2059
|
-
const chunks = [];
|
|
2060
|
-
let start = 0;
|
|
2061
|
-
while (start < prompt.length) {
|
|
2062
|
-
const end = Math.min(start + maxChunkSize, prompt.length);
|
|
2063
|
-
chunks.push(prompt.slice(start, end));
|
|
2064
|
-
// Break if we've reached the end
|
|
2065
|
-
if (end >= prompt.length) {
|
|
2066
|
-
break;
|
|
2067
|
-
}
|
|
2068
|
-
// Move start forward, accounting for overlap
|
|
2069
|
-
const nextStart = end - overlap;
|
|
2070
|
-
// Ensure we make progress (avoid infinite loops)
|
|
2071
|
-
if (nextStart <= start) {
|
|
2072
|
-
start = end;
|
|
2073
|
-
}
|
|
2074
|
-
else {
|
|
2075
|
-
start = Math.max(nextStart, 0);
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
return chunks;
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
//# sourceMappingURL=baseProvider.js.map
|