@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,1527 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utilities for Gemini 3 native SDK support.
|
|
3
|
-
*
|
|
4
|
-
* Both GoogleAIStudioProvider and GoogleVertexProvider route Gemini 3 models
|
|
5
|
-
* with tools to the native @google/genai SDK (bypassing the Vercel AI SDK)
|
|
6
|
-
* in order to properly handle thought_signature in multi-turn tool calling.
|
|
7
|
-
*
|
|
8
|
-
* This module extracts the functions that are duplicated between the two
|
|
9
|
-
* providers so they can share a single implementation.
|
|
10
|
-
*/
|
|
11
|
-
import { randomUUID } from "node:crypto";
|
|
12
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
13
|
-
import { extname } from "node:path";
|
|
14
|
-
import { DEFAULT_CONTEXT_GUARD_RATIO, DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, DEFAULT_WRAPUP_TIME_LEAD_MS, } from "../../core/constants.js";
|
|
15
|
-
import { needsAudioTranscode, toProviderCompatibleAudio, } from "../../adapters/audioFormatSupport.js";
|
|
16
|
-
import { logger } from "../../utils/logger.js";
|
|
17
|
-
import { resolveSamplingParams } from "../../models/modelRegistry.js";
|
|
18
|
-
import { convertZodToJsonSchema, ensureNestedSchemaTypes, inlineJsonSchema, isZodSchema, normalizeJsonSchemaObject, } from "../../utils/schemaConversion.js";
|
|
19
|
-
import { createNativeThinkingConfig } from "../../utils/thinkingConfig.js";
|
|
20
|
-
import { resolveLiveTool } from "../../tools/toolDiscovery.js";
|
|
21
|
-
import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "../../utils/tool.js";
|
|
22
|
-
// ── Functions ──
|
|
23
|
-
/** Stable, key-order-independent serialization of tool args for the dedup key. */
|
|
24
|
-
function stableStringifyForDedup(value) {
|
|
25
|
-
return JSON.stringify(value, (_key, val) => val && typeof val === "object" && !Array.isArray(val)
|
|
26
|
-
? Object.keys(val)
|
|
27
|
-
.sort()
|
|
28
|
-
.reduce((acc, key) => {
|
|
29
|
-
acc[key] = val[key];
|
|
30
|
-
return acc;
|
|
31
|
-
}, {})
|
|
32
|
-
: val);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A per-turn tool execute map that deduplicates identical tool calls.
|
|
36
|
-
*
|
|
37
|
-
* Gemini occasionally re-emits a tool call with identical arguments across
|
|
38
|
-
* agentic steps even though the prior result is already in the conversation
|
|
39
|
-
* history (BZ-3327). Re-executing produces duplicate side effects and
|
|
40
|
-
* duplicate reports for the user, plus wasted tokens. This map caches the
|
|
41
|
-
* result of each {tool name + args} executed within the turn and returns it
|
|
42
|
-
* for any identical re-request instead of running the tool again.
|
|
43
|
-
*
|
|
44
|
-
* Providers build a fresh executeMap per request, so the cache scope is
|
|
45
|
-
* exactly one turn. Only `.get()` is overridden (the sole access path used by
|
|
46
|
-
* the native agentic loops), so iteration still yields the raw executors.
|
|
47
|
-
*/
|
|
48
|
-
export class DedupExecuteMap extends Map {
|
|
49
|
-
resultCache = new Map();
|
|
50
|
-
get(name) {
|
|
51
|
-
const execute = super.get(name);
|
|
52
|
-
if (!execute) {
|
|
53
|
-
return execute;
|
|
54
|
-
}
|
|
55
|
-
const resultCache = this.resultCache;
|
|
56
|
-
const wrapped = async (args, options) => {
|
|
57
|
-
const key = `${name}::${stableStringifyForDedup(args)}`;
|
|
58
|
-
if (resultCache.has(key)) {
|
|
59
|
-
logger.warn(`[DedupExecuteMap] Tool "${name}" re-requested with identical arguments in the same turn — reusing the previous result instead of re-executing.`);
|
|
60
|
-
return resultCache.get(key);
|
|
61
|
-
}
|
|
62
|
-
const result = await execute(args, options);
|
|
63
|
-
resultCache.set(key, result);
|
|
64
|
-
return result;
|
|
65
|
-
};
|
|
66
|
-
return wrapped;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Google's `function_declarations[].name` validator regex.
|
|
71
|
-
*
|
|
72
|
-
* Empirically (and per the Vertex/AI Studio API error message), the server
|
|
73
|
-
* enforces `[A-Za-z_][A-Za-z0-9_.:-]{0,127}`. Tool names that don't match
|
|
74
|
-
* fail with HTTP 400 "Invalid function name", which surfaces as a misleading
|
|
75
|
-
* tool-calling failure for the whole request.
|
|
76
|
-
*
|
|
77
|
-
* MCP-imported or user-registered tools may legally contain characters
|
|
78
|
-
* outside this set (e.g. `/`, spaces, unicode), so we sanitize defensively
|
|
79
|
-
* before sending to Google. The sanitized name is also used as the
|
|
80
|
-
* `executeMap` key so the round-trip from Google's function-call response
|
|
81
|
-
* back to our executor still works.
|
|
82
|
-
*/
|
|
83
|
-
const GOOGLE_FN_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_.:-]{0,127}$/;
|
|
84
|
-
const GOOGLE_FN_NAME_MAX_LENGTH = 128;
|
|
85
|
-
export function sanitizeForGoogleFunctionName(name) {
|
|
86
|
-
if (GOOGLE_FN_NAME_REGEX.test(name)) {
|
|
87
|
-
return name;
|
|
88
|
-
}
|
|
89
|
-
let sanitized = name.replace(/[^A-Za-z0-9_.:-]/g, "_");
|
|
90
|
-
if (!/^[A-Za-z_]/.test(sanitized)) {
|
|
91
|
-
sanitized = `_${sanitized}`;
|
|
92
|
-
}
|
|
93
|
-
if (sanitized.length > GOOGLE_FN_NAME_MAX_LENGTH) {
|
|
94
|
-
sanitized = sanitized.slice(0, GOOGLE_FN_NAME_MAX_LENGTH);
|
|
95
|
-
}
|
|
96
|
-
return sanitized;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Resolve a sanitized Gemini tool name to one that is both unique within
|
|
100
|
-
* the current request and at most 128 characters. When the candidate
|
|
101
|
-
* collides with an already-used name we append `_2`, `_3`, … — but
|
|
102
|
-
* reserve room for the suffix by truncating the base first so the
|
|
103
|
-
* resolved name never exceeds Google's `function_declarations[].name`
|
|
104
|
-
* limit.
|
|
105
|
-
*
|
|
106
|
-
* @param base The already-sanitized candidate name.
|
|
107
|
-
* @param isTaken Predicate that returns true if `name` is already used.
|
|
108
|
-
*/
|
|
109
|
-
export function resolveUniqueGoogleFunctionName(base, isTaken) {
|
|
110
|
-
if (!isTaken(base)) {
|
|
111
|
-
return base;
|
|
112
|
-
}
|
|
113
|
-
let suffix = 2;
|
|
114
|
-
while (true) {
|
|
115
|
-
const suffixStr = `_${suffix}`;
|
|
116
|
-
const trimmedBase = base.slice(0, GOOGLE_FN_NAME_MAX_LENGTH - suffixStr.length);
|
|
117
|
-
const candidate = `${trimmedBase}${suffixStr}`;
|
|
118
|
-
if (!isTaken(candidate)) {
|
|
119
|
-
return candidate;
|
|
120
|
-
}
|
|
121
|
-
suffix++;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Sanitize a JSON Schema for Gemini's proto-based API.
|
|
126
|
-
*
|
|
127
|
-
* Gemini cannot handle `anyOf`/`oneOf` union types in function declarations
|
|
128
|
-
* because its proto format expects a single `type` field, not a list of types.
|
|
129
|
-
* This function recursively converts unions to `string` type (the most
|
|
130
|
-
* permissive primitive that can represent any value as text).
|
|
131
|
-
*
|
|
132
|
-
* Also removes `$schema`, `additionalProperties`, and `default` keys that
|
|
133
|
-
* Gemini's proto format doesn't support.
|
|
134
|
-
*/
|
|
135
|
-
export function sanitizeSchemaForGemini(schema) {
|
|
136
|
-
// If this node has anyOf/oneOf, collapse to string type
|
|
137
|
-
if (Array.isArray(schema.anyOf) || Array.isArray(schema.oneOf)) {
|
|
138
|
-
const unionKey = schema.anyOf ? "anyOf" : "oneOf";
|
|
139
|
-
const variants = schema[unionKey];
|
|
140
|
-
// Check if it's a nullable union (e.g., anyOf: [{type: "string"}, {type: "null"}])
|
|
141
|
-
const nonNullVariants = variants.filter((v) => v.type !== "null" && v.type !== "undefined");
|
|
142
|
-
if (nonNullVariants.length === 1) {
|
|
143
|
-
// Simple nullable — use the non-null type with nullable flag
|
|
144
|
-
const base = sanitizeSchemaForGemini({ ...nonNullVariants[0] });
|
|
145
|
-
base.nullable = true;
|
|
146
|
-
if (schema.description) {
|
|
147
|
-
base.description = schema.description;
|
|
148
|
-
}
|
|
149
|
-
return base;
|
|
150
|
-
}
|
|
151
|
-
// Multi-type union — collapse to string with description noting the original types
|
|
152
|
-
const types = nonNullVariants.map((v) => v.type || "unknown").join(" | ");
|
|
153
|
-
const result = { type: "string" };
|
|
154
|
-
const desc = schema.description
|
|
155
|
-
? `${schema.description} (accepts: ${types})`
|
|
156
|
-
: `Value as string (accepts: ${types})`;
|
|
157
|
-
result.description = desc;
|
|
158
|
-
if (variants.some((v) => v.type === "null")) {
|
|
159
|
-
result.nullable = true;
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
const result = {};
|
|
164
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
165
|
-
// Skip keys unsupported by Gemini proto format
|
|
166
|
-
if (key === "$schema" ||
|
|
167
|
-
key === "additionalProperties" ||
|
|
168
|
-
key === "default") {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (key === "properties" && value && typeof value === "object") {
|
|
172
|
-
const properties = {};
|
|
173
|
-
for (const [propName, propSchema] of Object.entries(value)) {
|
|
174
|
-
if (propSchema && typeof propSchema === "object") {
|
|
175
|
-
properties[propName] = sanitizeSchemaForGemini(propSchema);
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
properties[propName] = propSchema;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
result[key] = properties;
|
|
182
|
-
}
|
|
183
|
-
else if (key === "items" && value && typeof value === "object") {
|
|
184
|
-
if (Array.isArray(value)) {
|
|
185
|
-
result[key] = value.map((item) => item && typeof item === "object"
|
|
186
|
-
? sanitizeSchemaForGemini(item)
|
|
187
|
-
: item);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
result[key] = sanitizeSchemaForGemini(value);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
result[key] = value;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Recurse through composed schema branches
|
|
198
|
-
if (Array.isArray(result.allOf)) {
|
|
199
|
-
result.allOf = result.allOf.map((s) => sanitizeSchemaForGemini(s));
|
|
200
|
-
}
|
|
201
|
-
if (result.not && typeof result.not === "object") {
|
|
202
|
-
result.not = sanitizeSchemaForGemini(result.not);
|
|
203
|
-
}
|
|
204
|
-
for (const branch of ["if", "then", "else"]) {
|
|
205
|
-
if (result[branch] && typeof result[branch] === "object") {
|
|
206
|
-
result[branch] = sanitizeSchemaForGemini(result[branch]);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
// JSON Schema Draft-4 `exclusiveMinimum: true` / `exclusiveMaximum: true`
|
|
210
|
-
// (boolean form) is rejected by Gemini's OpenAPI 3.0 validator, which
|
|
211
|
-
// expects a numeric bound. zod-to-json-schema's openApi3 target still
|
|
212
|
-
// emits the Draft-4 form for `z.number().positive()` etc. Translate to
|
|
213
|
-
// the numeric form when paired with `minimum`/`maximum`, or drop.
|
|
214
|
-
if (typeof result.exclusiveMinimum === "boolean") {
|
|
215
|
-
if (result.exclusiveMinimum === true &&
|
|
216
|
-
typeof result.minimum === "number") {
|
|
217
|
-
result.exclusiveMinimum = result.minimum;
|
|
218
|
-
delete result.minimum;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
delete result.exclusiveMinimum;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (typeof result.exclusiveMaximum === "boolean") {
|
|
225
|
-
if (result.exclusiveMaximum === true &&
|
|
226
|
-
typeof result.maximum === "number") {
|
|
227
|
-
result.exclusiveMaximum = result.maximum;
|
|
228
|
-
delete result.maximum;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
delete result.exclusiveMaximum;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// Clamp `maximum`/`minimum` past int32 — Gemini's protobuf serializer
|
|
235
|
-
// treats `type: "integer"` as int32 and rejects bounds beyond ~2.1e9.
|
|
236
|
-
const INT32_MAX = 2147483647;
|
|
237
|
-
if (typeof result.maximum === "number" && result.maximum > INT32_MAX) {
|
|
238
|
-
delete result.maximum;
|
|
239
|
-
}
|
|
240
|
-
if (typeof result.minimum === "number" && result.minimum < -INT32_MAX) {
|
|
241
|
-
delete result.minimum;
|
|
242
|
-
}
|
|
243
|
-
return result;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Sanitize Vercel AI SDK tools for Gemini compatibility.
|
|
247
|
-
*
|
|
248
|
-
* For the Vercel AI SDK path (non-native), tool parameters are Zod schemas that
|
|
249
|
-
* get converted to JSON Schema internally by @ai-sdk/google. This conversion
|
|
250
|
-
* doesn't sanitize union types (anyOf/oneOf), causing Gemini proto errors.
|
|
251
|
-
*
|
|
252
|
-
* This function pre-converts each tool's Zod parameters to sanitized JSON Schema
|
|
253
|
-
* and re-wraps with the Vercel AI SDK's jsonSchema() helper.
|
|
254
|
-
*/
|
|
255
|
-
export function sanitizeToolsForGemini(tools) {
|
|
256
|
-
const sanitized = {};
|
|
257
|
-
const dropped = [];
|
|
258
|
-
const renamed = [];
|
|
259
|
-
const originalNameMap = new Map();
|
|
260
|
-
for (const [name, tool] of Object.entries(tools)) {
|
|
261
|
-
try {
|
|
262
|
-
// Sanitize the tool name to fit Google's function_declarations regex.
|
|
263
|
-
// Without this, MCP-imported or user-registered tools whose names contain
|
|
264
|
-
// characters outside [A-Za-z_][A-Za-z0-9_.:-]{0,127} cause the entire
|
|
265
|
-
// request to 400 with "Invalid function name", surfacing as a misleading
|
|
266
|
-
// tool-calling failure. Distinct originals that collapse onto the same
|
|
267
|
-
// sanitized name (e.g. "my/tool" and "my-tool" → "my_tool") are
|
|
268
|
-
// disambiguated with a numeric suffix that preserves Google's 128-char
|
|
269
|
-
// ceiling.
|
|
270
|
-
const candidate = sanitizeForGoogleFunctionName(name);
|
|
271
|
-
const safeName = resolveUniqueGoogleFunctionName(candidate, (n) => n in sanitized);
|
|
272
|
-
// Always record the mapping so downstream code can translate every
|
|
273
|
-
// safeName back to the original — including the no-rename identity
|
|
274
|
-
// mapping, which simplifies the lookup path.
|
|
275
|
-
originalNameMap.set(safeName, name);
|
|
276
|
-
if (safeName !== name) {
|
|
277
|
-
renamed.push({ from: name, to: safeName });
|
|
278
|
-
}
|
|
279
|
-
// Access the legacy `parameters` field that may exist on older AI SDK tools.
|
|
280
|
-
// AI SDK v6 uses `inputSchema`, but v3/v4 tools and third-party wrappers use `parameters`.
|
|
281
|
-
const legacyTool = tool;
|
|
282
|
-
const params = legacyTool.parameters;
|
|
283
|
-
if (params &&
|
|
284
|
-
typeof params === "object" &&
|
|
285
|
-
"_def" in params &&
|
|
286
|
-
typeof params.parse === "function") {
|
|
287
|
-
const rawJsonSchema = convertZodToJsonSchema(params, "openApi3");
|
|
288
|
-
const inlined = inlineJsonSchema(rawJsonSchema);
|
|
289
|
-
// Gemini sanitization strips Zod-only features not supported by the Gemini API:
|
|
290
|
-
// union types (anyOf/oneOf) are collapsed to string, default values and
|
|
291
|
-
// additionalProperties are removed. The resulting schema is Gemini-compatible
|
|
292
|
-
// but loses some type constraints from the original Zod schema.
|
|
293
|
-
const sanitizedSchema = sanitizeSchemaForGemini(inlined);
|
|
294
|
-
sanitized[safeName] = createAISDKTool({
|
|
295
|
-
description: tool.description || `Tool: ${safeName}`,
|
|
296
|
-
inputSchema: aiJsonSchema(sanitizedSchema),
|
|
297
|
-
execute: tool.execute,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
else if (params &&
|
|
301
|
-
typeof params === "object" &&
|
|
302
|
-
"jsonSchema" in params) {
|
|
303
|
-
// Non-Zod JSON schema (e.g., from ai SDK jsonSchema() helper) — still needs sanitization
|
|
304
|
-
const rawSchema = params
|
|
305
|
-
.jsonSchema;
|
|
306
|
-
const sanitizedSchema = sanitizeSchemaForGemini(inlineJsonSchema(rawSchema));
|
|
307
|
-
sanitized[safeName] = createAISDKTool({
|
|
308
|
-
description: tool.description || `Tool: ${safeName}`,
|
|
309
|
-
inputSchema: aiJsonSchema(sanitizedSchema),
|
|
310
|
-
execute: tool.execute,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
sanitized[safeName] = tool;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
catch (error) {
|
|
318
|
-
logger.warn(`[Gemini] Failed to sanitize tool "${name}", skipping: ${error instanceof Error ? error.message : String(error)}`);
|
|
319
|
-
// Don't fall back to the original tool — an incompatible schema would fail the Gemini request
|
|
320
|
-
dropped.push(name);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (renamed.length > 0) {
|
|
324
|
-
logger.warn(`[Gemini] ${renamed.length} tool name(s) sanitized for Google's function-name regex: ${renamed
|
|
325
|
-
.map((r) => `"${r.from}" -> "${r.to}"`)
|
|
326
|
-
.join(", ")}`);
|
|
327
|
-
}
|
|
328
|
-
return { tools: sanitized, dropped, originalNameMap };
|
|
329
|
-
}
|
|
330
|
-
export function normalizeToolsForJsonSchemaProvider(tools) {
|
|
331
|
-
const normalizedTools = {};
|
|
332
|
-
const normalized = [];
|
|
333
|
-
for (const [name, tool] of Object.entries(tools)) {
|
|
334
|
-
const legacyTool = tool;
|
|
335
|
-
const toolParams = legacyTool.parameters || tool.inputSchema;
|
|
336
|
-
let rawSchema;
|
|
337
|
-
if (isZodSchema(toolParams)) {
|
|
338
|
-
rawSchema = convertZodToJsonSchema(toolParams, "openApi3");
|
|
339
|
-
}
|
|
340
|
-
else if (toolParams && typeof toolParams === "object") {
|
|
341
|
-
rawSchema = toolParams;
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
rawSchema = { type: "object", properties: {} };
|
|
345
|
-
}
|
|
346
|
-
if (rawSchema.jsonSchema &&
|
|
347
|
-
typeof rawSchema.jsonSchema === "object" &&
|
|
348
|
-
!rawSchema.type) {
|
|
349
|
-
rawSchema = rawSchema.jsonSchema;
|
|
350
|
-
}
|
|
351
|
-
const schemaBefore = JSON.stringify(rawSchema);
|
|
352
|
-
const normalizedSchema = normalizeJsonSchemaObject(rawSchema);
|
|
353
|
-
if (JSON.stringify(normalizedSchema) !== schemaBefore) {
|
|
354
|
-
normalized.push(name);
|
|
355
|
-
}
|
|
356
|
-
const wrappedSchema = aiJsonSchema(normalizedSchema);
|
|
357
|
-
normalizedTools[name] = {
|
|
358
|
-
...tool,
|
|
359
|
-
inputSchema: wrappedSchema,
|
|
360
|
-
...(legacyTool.parameters ? { parameters: wrappedSchema } : {}),
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
tools: normalizedTools,
|
|
365
|
-
normalized,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Convert Vercel AI SDK tools to @google/genai FunctionDeclarations and an execute map.
|
|
370
|
-
*
|
|
371
|
-
* This handles both Zod schemas and plain JSON Schema objects for tool parameters.
|
|
372
|
-
*/
|
|
373
|
-
export function buildNativeToolDeclarations(tools, reservedNames) {
|
|
374
|
-
const functionDeclarations = [];
|
|
375
|
-
const executeMap = new DedupExecuteMap();
|
|
376
|
-
const skippedTools = [];
|
|
377
|
-
const renamedTools = [];
|
|
378
|
-
// Disambiguate distinct originals that collapse onto the same sanitized
|
|
379
|
-
// name (e.g. "my/tool" and "my-tool" both → "my_tool") via
|
|
380
|
-
// resolveUniqueGoogleFunctionName, which appends `_N` while keeping the
|
|
381
|
-
// final string within Google's 128-char limit. Track all assigned names
|
|
382
|
-
// regardless of whether the tool has an `execute` function (tools without
|
|
383
|
-
// execute are still pushed to functionDeclarations). The originalNameMap
|
|
384
|
-
// lets the calling stream loop translate Google-returned function-call
|
|
385
|
-
// names back to the consumer-facing identifier so the sanitization is
|
|
386
|
-
// transport-only. `reservedNames` seeds the collision set so a mid-turn
|
|
387
|
-
// refresh (see refreshNativeToolDeclarations) never re-issues a safe name
|
|
388
|
-
// already assigned by the pre-loop snapshot.
|
|
389
|
-
const usedNames = new Set(reservedNames ?? []);
|
|
390
|
-
const originalNameMap = new Map();
|
|
391
|
-
for (const [name, tool] of Object.entries(tools)) {
|
|
392
|
-
try {
|
|
393
|
-
const candidate = sanitizeForGoogleFunctionName(name);
|
|
394
|
-
const safeName = resolveUniqueGoogleFunctionName(candidate, (n) => usedNames.has(n));
|
|
395
|
-
originalNameMap.set(safeName, name);
|
|
396
|
-
if (safeName !== name) {
|
|
397
|
-
renamedTools.push({ from: name, to: safeName });
|
|
398
|
-
}
|
|
399
|
-
const decl = {
|
|
400
|
-
name: safeName,
|
|
401
|
-
description: tool.description || `Tool: ${safeName}`,
|
|
402
|
-
};
|
|
403
|
-
// Access legacy `parameters` (AI SDK v3/v4) or current `inputSchema` (v6)
|
|
404
|
-
const legacyTool = tool;
|
|
405
|
-
if (legacyTool.parameters || tool.inputSchema) {
|
|
406
|
-
let rawSchema;
|
|
407
|
-
const toolParams = legacyTool.parameters || tool.inputSchema;
|
|
408
|
-
if (isZodSchema(toolParams)) {
|
|
409
|
-
rawSchema = convertZodToJsonSchema(toolParams, "openApi3");
|
|
410
|
-
}
|
|
411
|
-
else if (typeof toolParams === "object") {
|
|
412
|
-
rawSchema = toolParams;
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
rawSchema = { type: "object", properties: {} };
|
|
416
|
-
}
|
|
417
|
-
// Unwrap Vercel AI SDK's jsonSchema() wrapper: { jsonSchema: { type: "object", ... } }
|
|
418
|
-
if (rawSchema.jsonSchema &&
|
|
419
|
-
typeof rawSchema.jsonSchema === "object" &&
|
|
420
|
-
!rawSchema.type) {
|
|
421
|
-
rawSchema = rawSchema.jsonSchema;
|
|
422
|
-
}
|
|
423
|
-
decl.parametersJsonSchema = sanitizeSchemaForGemini(inlineJsonSchema(rawSchema));
|
|
424
|
-
}
|
|
425
|
-
functionDeclarations.push(decl);
|
|
426
|
-
usedNames.add(safeName);
|
|
427
|
-
if (tool.execute) {
|
|
428
|
-
executeMap.set(decl.name, tool.execute);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
catch (err) {
|
|
432
|
-
skippedTools.push(name);
|
|
433
|
-
logger.error(`[buildNativeToolDeclarations] Failed to convert tool "${name}":`, err);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (skippedTools.length > 0) {
|
|
437
|
-
logger.warn(`[buildNativeToolDeclarations] ${skippedTools.length} tool(s) skipped due to schema errors: ${skippedTools.join(", ")}`);
|
|
438
|
-
}
|
|
439
|
-
if (renamedTools.length > 0) {
|
|
440
|
-
logger.warn(`[buildNativeToolDeclarations] ${renamedTools.length} tool name(s) sanitized for Google's function-name regex: ${renamedTools
|
|
441
|
-
.map((r) => `"${r.from}" -> "${r.to}"`)
|
|
442
|
-
.join(", ")}`);
|
|
443
|
-
}
|
|
444
|
-
return {
|
|
445
|
-
toolsConfig: [{ functionDeclarations }],
|
|
446
|
-
executeMap,
|
|
447
|
-
originalNameMap,
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Mid-turn tool sync for the native Gemini loops that build their snapshot
|
|
452
|
-
* via buildNativeToolDeclarations. `search_tools` (tools.discovery) hydrates
|
|
453
|
-
* discovered tools into the live record between steps; without this refresh
|
|
454
|
-
* they stay invisible to the rest of the turn and every call dies as
|
|
455
|
-
* TOOL_NOT_FOUND. Mutates the snapshot in place — the request config holds
|
|
456
|
-
* `toolsConfig` by reference — and returns true when anything was added.
|
|
457
|
-
*/
|
|
458
|
-
export function refreshNativeToolDeclarations(liveTools, current) {
|
|
459
|
-
if (!liveTools) {
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
const declaredOriginals = new Set(current.originalNameMap.values());
|
|
463
|
-
const missing = Object.entries(liveTools).filter(([name]) => !declaredOriginals.has(name));
|
|
464
|
-
if (missing.length === 0) {
|
|
465
|
-
return false;
|
|
466
|
-
}
|
|
467
|
-
const built = buildNativeToolDeclarations(Object.fromEntries(missing), new Set(current.originalNameMap.keys()));
|
|
468
|
-
current.toolsConfig[0].functionDeclarations.push(...built.toolsConfig[0].functionDeclarations);
|
|
469
|
-
for (const [safeName, originalName] of built.originalNameMap) {
|
|
470
|
-
current.originalNameMap.set(safeName, originalName);
|
|
471
|
-
}
|
|
472
|
-
for (const [safeName, execute] of built.executeMap) {
|
|
473
|
-
current.executeMap.set(safeName, execute);
|
|
474
|
-
}
|
|
475
|
-
logger.info(`[buildNativeToolDeclarations] ${missing.length} tool(s) hydrated mid-turn via discovery: ${missing
|
|
476
|
-
.map(([name]) => name)
|
|
477
|
-
.join(", ")}`);
|
|
478
|
-
return true;
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Build the native @google/genai config object shared by stream and generate.
|
|
482
|
-
*
|
|
483
|
-
* Caller is responsible for the tools-vs-JSON conflict resolution: Gemini's
|
|
484
|
-
* function calling cannot be combined with `responseMimeType:
|
|
485
|
-
* "application/json"`, and `responseSchema` requires that mime type. So
|
|
486
|
-
* when tools are active, callers must NOT pass `wantsJsonOutput`/
|
|
487
|
-
* `responseSchema` here; when JSON/schema output is requested, callers
|
|
488
|
-
* must omit `toolsConfig`. The AI Studio path enforces this by forcing
|
|
489
|
-
* `disableTools: true` whenever JSON/schema output is requested.
|
|
490
|
-
*/
|
|
491
|
-
export function buildNativeConfig(options, toolsConfig) {
|
|
492
|
-
// Registry-driven sampling strip applied for uniformity with every other
|
|
493
|
-
// provider path (inert for current Gemini models).
|
|
494
|
-
const samplingParams = resolveSamplingParams("google-ai", options.model, { temperature: options.temperature ?? 1.0 }, // Gemini 3 requires 1.0 for tool calling
|
|
495
|
-
"googleAiStudio.buildNativeConfig");
|
|
496
|
-
const config = {
|
|
497
|
-
...(samplingParams.temperature !== undefined && {
|
|
498
|
-
temperature: samplingParams.temperature,
|
|
499
|
-
}),
|
|
500
|
-
maxOutputTokens: options.maxTokens,
|
|
501
|
-
};
|
|
502
|
-
if (toolsConfig) {
|
|
503
|
-
config.tools = toolsConfig;
|
|
504
|
-
}
|
|
505
|
-
if (options.systemPrompt) {
|
|
506
|
-
config.systemInstruction = options.systemPrompt;
|
|
507
|
-
}
|
|
508
|
-
// Add thinking config for Gemini 3
|
|
509
|
-
const nativeThinkingConfig = createNativeThinkingConfig(options.thinkingConfig);
|
|
510
|
-
if (nativeThinkingConfig) {
|
|
511
|
-
config.thinkingConfig = nativeThinkingConfig;
|
|
512
|
-
}
|
|
513
|
-
// Native JSON / schema enforcement. Only set when tools are NOT being sent
|
|
514
|
-
// (Gemini rejects the combination). responseSchema implies JSON mime type.
|
|
515
|
-
if (!toolsConfig) {
|
|
516
|
-
if (options.responseSchema || options.wantsJsonOutput) {
|
|
517
|
-
config.responseMimeType = "application/json";
|
|
518
|
-
}
|
|
519
|
-
if (options.responseSchema) {
|
|
520
|
-
config.responseSchema = options.responseSchema;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
return config;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Safety cap for native Gemini 3 SDK agentic tool-calling loops.
|
|
527
|
-
* Lower than DEFAULT_MAX_STEPS (200) to prevent runaway iterations
|
|
528
|
-
* in the native SDK path which bypasses Vercel AI SDK step limits.
|
|
529
|
-
*/
|
|
530
|
-
const GEMINI3_NATIVE_MAX_STEPS = 100;
|
|
531
|
-
/**
|
|
532
|
-
* Compute a safe, clamped maxSteps value.
|
|
533
|
-
*/
|
|
534
|
-
export function computeMaxSteps(rawMaxSteps) {
|
|
535
|
-
const value = rawMaxSteps || DEFAULT_MAX_STEPS;
|
|
536
|
-
return Number.isFinite(value) && value > 0
|
|
537
|
-
? Math.min(Math.floor(value), GEMINI3_NATIVE_MAX_STEPS)
|
|
538
|
-
: Math.min(DEFAULT_MAX_STEPS, GEMINI3_NATIVE_MAX_STEPS);
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Map a `@google/genai` `Candidate.finishReason` enum value onto NeuroLink's
|
|
542
|
-
* unified finish reason, mirroring anthropic.ts `mapAnthropicStopReason`.
|
|
543
|
-
*
|
|
544
|
-
* Enum values per `@google/genai` `FinishReason`: STOP, MAX_TOKENS, SAFETY,
|
|
545
|
-
* RECITATION, LANGUAGE, OTHER, BLOCKLIST, PROHIBITED_CONTENT, SPII,
|
|
546
|
-
* MALFORMED_FUNCTION_CALL, IMAGE_SAFETY, UNEXPECTED_TOOL_CALL,
|
|
547
|
-
* FINISH_REASON_UNSPECIFIED. Unknown / unset / non-terminal values default to
|
|
548
|
-
* "stop" (a clean completion is the safe assumption).
|
|
549
|
-
*
|
|
550
|
-
* Returns a plain string (not a `{ unified, raw }` object): the Vertex result
|
|
551
|
-
* builders and the consuming layer (neurolink.ts `finishReason || "unknown"`
|
|
552
|
-
* and `finishReason === "length"`) compare against plain strings.
|
|
553
|
-
*
|
|
554
|
-
* MALFORMED_FUNCTION_CALL / UNEXPECTED_TOOL_CALL map to "error", NOT
|
|
555
|
-
* "tool-calls": they are provider/model failures, while "tool-calls" is the
|
|
556
|
-
* exclusive contract for "step budget exhausted while the model still wanted
|
|
557
|
-
* tools" — consumers (e.g. curator's step-cap intercept) branch on it and
|
|
558
|
-
* were rendering fake step-limit messages for 2-4-step malformed-call turns.
|
|
559
|
-
*/
|
|
560
|
-
export function mapGeminiFinishReason(raw) {
|
|
561
|
-
switch (raw) {
|
|
562
|
-
case "MAX_TOKENS":
|
|
563
|
-
return "length";
|
|
564
|
-
case "MALFORMED_FUNCTION_CALL":
|
|
565
|
-
case "UNEXPECTED_TOOL_CALL":
|
|
566
|
-
return "error";
|
|
567
|
-
case "SAFETY":
|
|
568
|
-
case "RECITATION":
|
|
569
|
-
case "BLOCKLIST":
|
|
570
|
-
case "PROHIBITED_CONTENT":
|
|
571
|
-
case "SPII":
|
|
572
|
-
case "IMAGE_SAFETY":
|
|
573
|
-
return "content-filter";
|
|
574
|
-
default:
|
|
575
|
-
return "stop";
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Append a step's text to a running cross-step accumulator, ignoring empty
|
|
580
|
-
* steps and inserting a single newline between non-empty contributions.
|
|
581
|
-
*
|
|
582
|
-
* The native Gemini loops overwrite per-step text into `lastStepText`, so when
|
|
583
|
-
* the loop is force-terminated by the step cap the intermediate tool-step prose
|
|
584
|
-
* is lost and a canned placeholder becomes the answer. Accumulating here mirrors
|
|
585
|
-
* the Vertex-Claude loop's `aggregatedTurnText += block.text` so the gathered
|
|
586
|
-
* text can be surfaced at the maxSteps-exhaustion exit instead of the placeholder.
|
|
587
|
-
*/
|
|
588
|
-
export function appendStepText(accumulated, stepText) {
|
|
589
|
-
if (!stepText) {
|
|
590
|
-
return accumulated;
|
|
591
|
-
}
|
|
592
|
-
return accumulated ? `${accumulated}\n${stepText}` : stepText;
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Process stream chunks to extract raw response parts, function calls, and usage metadata.
|
|
596
|
-
*
|
|
597
|
-
* Consumes the full async iterable and returns all collected data.
|
|
598
|
-
*/
|
|
599
|
-
export async function collectStreamChunks(stream) {
|
|
600
|
-
const rawResponseParts = [];
|
|
601
|
-
const stepFunctionCalls = [];
|
|
602
|
-
let inputTokens = 0;
|
|
603
|
-
let outputTokens = 0;
|
|
604
|
-
let cacheReadTokens = 0;
|
|
605
|
-
let reasoningTokens = 0;
|
|
606
|
-
for await (const chunk of stream) {
|
|
607
|
-
// Extract raw parts from candidates FIRST
|
|
608
|
-
// This avoids using chunk.text which triggers SDK warning when
|
|
609
|
-
// non-text parts (thoughtSignature, functionCall) are present
|
|
610
|
-
const chunkRecord = chunk;
|
|
611
|
-
const candidates = chunkRecord.candidates;
|
|
612
|
-
const firstCandidate = candidates?.[0];
|
|
613
|
-
const chunkContent = firstCandidate?.content;
|
|
614
|
-
if (chunkContent && Array.isArray(chunkContent.parts)) {
|
|
615
|
-
rawResponseParts.push(...chunkContent.parts);
|
|
616
|
-
}
|
|
617
|
-
if (chunk.functionCalls) {
|
|
618
|
-
stepFunctionCalls.push(...chunk.functionCalls);
|
|
619
|
-
}
|
|
620
|
-
// Accumulate usage metadata from chunks
|
|
621
|
-
const usage = chunkRecord.usageMetadata;
|
|
622
|
-
if (usage) {
|
|
623
|
-
inputTokens = Math.max(inputTokens, usage.promptTokenCount || 0);
|
|
624
|
-
outputTokens = Math.max(outputTokens, usage.candidatesTokenCount || 0);
|
|
625
|
-
// cachedContentTokenCount is OVERLAPPING (a subset already inside
|
|
626
|
-
// promptTokenCount). Surface it so the call site subtracts once.
|
|
627
|
-
cacheReadTokens = Math.max(cacheReadTokens, usage.cachedContentTokenCount || 0);
|
|
628
|
-
// thoughtsTokenCount (thinking tokens, billed at the output rate) is
|
|
629
|
-
// NOT part of candidatesTokenCount — surface it separately.
|
|
630
|
-
reasoningTokens = Math.max(reasoningTokens, usage.thoughtsTokenCount || 0);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
return {
|
|
634
|
-
rawResponseParts,
|
|
635
|
-
stepFunctionCalls,
|
|
636
|
-
inputTokens,
|
|
637
|
-
outputTokens,
|
|
638
|
-
cacheReadTokens,
|
|
639
|
-
reasoningTokens,
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Iterate a single stream step incrementally, pushing text parts to `channel`
|
|
644
|
-
* as they arrive from the network while simultaneously accumulating the full
|
|
645
|
-
* `CollectedChunkResult` needed for history and token accounting.
|
|
646
|
-
*
|
|
647
|
-
* Used for all steps (both intermediate tool-calling steps and the final
|
|
648
|
-
* text-only step). Text parts are pushed to the channel as they arrive,
|
|
649
|
-
* enabling truly incremental streaming. The complete `rawResponseParts`
|
|
650
|
-
* (including thoughtSignature) are still returned at the end for use by
|
|
651
|
-
* `pushModelResponseToHistory`.
|
|
652
|
-
*/
|
|
653
|
-
export async function collectStreamChunksIncremental(stream, channel) {
|
|
654
|
-
const rawResponseParts = [];
|
|
655
|
-
const stepFunctionCalls = [];
|
|
656
|
-
let inputTokens = 0;
|
|
657
|
-
let outputTokens = 0;
|
|
658
|
-
let cacheReadTokens = 0;
|
|
659
|
-
let reasoningTokens = 0;
|
|
660
|
-
// Surfaced so a caller can map SAFETY / MALFORMED_FUNCTION_CALL rather
|
|
661
|
-
// than inferring the turn ended normally. Additive: existing callers that
|
|
662
|
-
// ignore it are unaffected.
|
|
663
|
-
let finishReason;
|
|
664
|
-
for await (const chunk of stream) {
|
|
665
|
-
const chunkRecord = chunk;
|
|
666
|
-
const candidates = chunkRecord.candidates;
|
|
667
|
-
const firstCandidate = candidates?.[0];
|
|
668
|
-
const candidateFinish = firstCandidate?.finishReason;
|
|
669
|
-
if (typeof candidateFinish === "string") {
|
|
670
|
-
finishReason = candidateFinish;
|
|
671
|
-
}
|
|
672
|
-
const chunkContent = firstCandidate?.content;
|
|
673
|
-
if (chunkContent && Array.isArray(chunkContent.parts)) {
|
|
674
|
-
for (const part of chunkContent.parts) {
|
|
675
|
-
rawResponseParts.push(part);
|
|
676
|
-
// Forward text parts to the consumer immediately
|
|
677
|
-
if (typeof part.text === "string" && part.text.length > 0) {
|
|
678
|
-
channel.push({ content: part.text });
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
if (chunk.functionCalls) {
|
|
683
|
-
stepFunctionCalls.push(...chunk.functionCalls);
|
|
684
|
-
}
|
|
685
|
-
const usage = chunkRecord.usageMetadata;
|
|
686
|
-
if (usage) {
|
|
687
|
-
inputTokens = Math.max(inputTokens, usage.promptTokenCount || 0);
|
|
688
|
-
outputTokens = Math.max(outputTokens, usage.candidatesTokenCount || 0);
|
|
689
|
-
// cachedContentTokenCount is OVERLAPPING (a subset already inside
|
|
690
|
-
// promptTokenCount). Surface it so the call site subtracts once.
|
|
691
|
-
cacheReadTokens = Math.max(cacheReadTokens, usage.cachedContentTokenCount || 0);
|
|
692
|
-
// thoughtsTokenCount (thinking tokens, billed at the output rate) is
|
|
693
|
-
// NOT part of candidatesTokenCount — surface it separately.
|
|
694
|
-
reasoningTokens = Math.max(reasoningTokens, usage.thoughtsTokenCount || 0);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
rawResponseParts,
|
|
699
|
-
stepFunctionCalls,
|
|
700
|
-
finishReason,
|
|
701
|
-
inputTokens,
|
|
702
|
-
outputTokens,
|
|
703
|
-
cacheReadTokens,
|
|
704
|
-
reasoningTokens,
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Extract the thoughtSignature token from raw response parts.
|
|
709
|
-
* Returns the last thoughtSignature found (each step may produce one).
|
|
710
|
-
*/
|
|
711
|
-
export function extractThoughtSignature(rawResponseParts) {
|
|
712
|
-
for (let i = rawResponseParts.length - 1; i >= 0; i--) {
|
|
713
|
-
const part = rawResponseParts[i];
|
|
714
|
-
if (part !== null &&
|
|
715
|
-
part !== undefined &&
|
|
716
|
-
typeof part === "object" &&
|
|
717
|
-
"thoughtSignature" in part &&
|
|
718
|
-
typeof part.thoughtSignature ===
|
|
719
|
-
"string") {
|
|
720
|
-
return part.thoughtSignature;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
return undefined;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Extract text from raw response parts, filtering out non-text parts
|
|
727
|
-
* (thoughtSignature, functionCall) to avoid SDK warnings.
|
|
728
|
-
*/
|
|
729
|
-
export function extractTextFromParts(rawResponseParts) {
|
|
730
|
-
return rawResponseParts
|
|
731
|
-
.filter((part) => typeof part.text === "string")
|
|
732
|
-
.map((part) => part.text)
|
|
733
|
-
.join("");
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Execute a batch of native function calls with retry tracking and permanent failure detection.
|
|
737
|
-
*
|
|
738
|
-
* @param logLabel - Label for log messages (e.g. "[GoogleAIStudio]" or "[GoogleVertex]")
|
|
739
|
-
* @param stepFunctionCalls - The function calls from the model
|
|
740
|
-
* @param executeMap - Map of tool name to execute function
|
|
741
|
-
* @param failedTools - Mutable map tracking per-tool failure counts
|
|
742
|
-
* @param allToolCalls - Mutable array accumulating all tool call records
|
|
743
|
-
* @param options - Optional settings for execution tracking and cancellation,
|
|
744
|
-
* plus an `originalNameMap` (Google-safe → consumer-supplied
|
|
745
|
-
* identifier) so the sanitization stays transport-only and
|
|
746
|
-
* consumers see the names they registered.
|
|
747
|
-
* @returns Array of function responses for conversation history
|
|
748
|
-
*/
|
|
749
|
-
export async function executeNativeToolCalls(logLabel, stepFunctionCalls, executeMap, failedTools, allToolCalls, options) {
|
|
750
|
-
const functionResponses = [];
|
|
751
|
-
// Translate a Google-safe sanitized name back to the consumer-facing
|
|
752
|
-
// original name. Falls back to the safe name if the map is missing or
|
|
753
|
-
// doesn't contain the call (e.g. tool added mid-conversation).
|
|
754
|
-
const externalName = (safeName) => options?.originalNameMap?.get(safeName) ?? safeName;
|
|
755
|
-
// Note: tool:start / tool:end events are emitted by ToolsManager's
|
|
756
|
-
// `execute` wrapper (see src/lib/core/modules/ToolsManager.ts:355 and :790)
|
|
757
|
-
// around every tool's execute function. The native paths invoke that same
|
|
758
|
-
// wrapped execute via the executeMap, so emitting here would duplicate.
|
|
759
|
-
for (const call of stepFunctionCalls) {
|
|
760
|
-
const exposedName = externalName(call.name);
|
|
761
|
-
allToolCalls.push({ toolName: exposedName, args: call.args });
|
|
762
|
-
// Check if this tool has already exceeded retry limit
|
|
763
|
-
const failedInfo = failedTools.get(call.name);
|
|
764
|
-
if (failedInfo && failedInfo.count >= DEFAULT_TOOL_MAX_RETRIES) {
|
|
765
|
-
logger.warn(`${logLabel} Tool "${exposedName}" has exceeded retry limit (${DEFAULT_TOOL_MAX_RETRIES}), skipping execution`);
|
|
766
|
-
const errorOutput = {
|
|
767
|
-
error: `TOOL_PERMANENTLY_FAILED: The tool "${exposedName}" has failed ${failedInfo.count} times and will not be retried. Last error: ${failedInfo.lastError}. Please proceed without using this tool or inform the user that this functionality is unavailable.`,
|
|
768
|
-
status: "permanently_failed",
|
|
769
|
-
do_not_retry: true,
|
|
770
|
-
};
|
|
771
|
-
// Wire transport-side `name: call.name` (Google needs the sanitized
|
|
772
|
-
// form to match the function declaration) while exposing the
|
|
773
|
-
// consumer-facing name in toolExecutions metadata.
|
|
774
|
-
functionResponses.push({
|
|
775
|
-
functionResponse: { name: call.name, response: errorOutput },
|
|
776
|
-
});
|
|
777
|
-
options?.toolExecutions?.push({
|
|
778
|
-
name: exposedName,
|
|
779
|
-
input: call.args,
|
|
780
|
-
output: errorOutput,
|
|
781
|
-
});
|
|
782
|
-
continue;
|
|
783
|
-
}
|
|
784
|
-
let execute = executeMap.get(call.name);
|
|
785
|
-
if (!execute && options?.declarations) {
|
|
786
|
-
// Snapshot miss: the tool may have been hydrated into the live record
|
|
787
|
-
// by search_tools within this very step batch, or the model called a
|
|
788
|
-
// deferred catalog tool directly by its advertised name.
|
|
789
|
-
const liveTool = resolveLiveTool(options.liveTools, exposedName);
|
|
790
|
-
if (liveTool?.execute) {
|
|
791
|
-
refreshNativeToolDeclarations(options.liveTools, options.declarations);
|
|
792
|
-
// NOT_FOUND strikes accrued while the tool was deferred are snapshot
|
|
793
|
-
// artifacts, not real failures — reset so the breaker starts clean.
|
|
794
|
-
failedTools.delete(call.name);
|
|
795
|
-
// The refresh registered the executor under its Google-safe name —
|
|
796
|
-
// resolve it for this dispatch (later calls use the declared name).
|
|
797
|
-
for (const [safeName, originalName] of options.declarations
|
|
798
|
-
.originalNameMap) {
|
|
799
|
-
if (originalName === exposedName) {
|
|
800
|
-
execute = executeMap.get(safeName);
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (execute) {
|
|
805
|
-
logger.info(`${logLabel} Tool "${exposedName}" resolved mid-turn via discovery — executing.`);
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
if (execute) {
|
|
810
|
-
try {
|
|
811
|
-
// AI SDK Tool execute requires (args, options) - provide minimal options
|
|
812
|
-
// Use randomUUID to avoid toolCallId collisions across concurrent calls
|
|
813
|
-
const toolOptions = {
|
|
814
|
-
toolCallId: `${call.name}-${randomUUID()}`,
|
|
815
|
-
messages: [],
|
|
816
|
-
abortSignal: options?.abortSignal,
|
|
817
|
-
};
|
|
818
|
-
const result = await execute(call.args, toolOptions);
|
|
819
|
-
functionResponses.push({
|
|
820
|
-
functionResponse: { name: call.name, response: { result } },
|
|
821
|
-
});
|
|
822
|
-
options?.toolExecutions?.push({
|
|
823
|
-
name: exposedName,
|
|
824
|
-
input: call.args,
|
|
825
|
-
output: result,
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
catch (error) {
|
|
829
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
830
|
-
// Track this failure
|
|
831
|
-
const currentFailInfo = failedTools.get(call.name) || {
|
|
832
|
-
count: 0,
|
|
833
|
-
lastError: "",
|
|
834
|
-
};
|
|
835
|
-
currentFailInfo.count++;
|
|
836
|
-
currentFailInfo.lastError = errorMessage;
|
|
837
|
-
failedTools.set(call.name, currentFailInfo);
|
|
838
|
-
logger.warn(`${logLabel} Tool "${exposedName}" failed (attempt ${currentFailInfo.count}/${DEFAULT_TOOL_MAX_RETRIES}): ${errorMessage}`);
|
|
839
|
-
// Determine if this is a permanent failure
|
|
840
|
-
const isPermanentFailure = currentFailInfo.count >= DEFAULT_TOOL_MAX_RETRIES;
|
|
841
|
-
const errorOutput = {
|
|
842
|
-
error: isPermanentFailure
|
|
843
|
-
? `TOOL_PERMANENTLY_FAILED: The tool "${exposedName}" has failed ${currentFailInfo.count} times with error: ${errorMessage}. This tool will not be retried. Please proceed without using this tool or inform the user that this functionality is unavailable.`
|
|
844
|
-
: `TOOL_EXECUTION_ERROR: ${errorMessage}. Retry attempt ${currentFailInfo.count}/${DEFAULT_TOOL_MAX_RETRIES}.`,
|
|
845
|
-
status: isPermanentFailure ? "permanently_failed" : "failed",
|
|
846
|
-
do_not_retry: isPermanentFailure,
|
|
847
|
-
retry_count: currentFailInfo.count,
|
|
848
|
-
max_retries: DEFAULT_TOOL_MAX_RETRIES,
|
|
849
|
-
};
|
|
850
|
-
functionResponses.push({
|
|
851
|
-
functionResponse: { name: call.name, response: errorOutput },
|
|
852
|
-
});
|
|
853
|
-
options?.toolExecutions?.push({
|
|
854
|
-
name: exposedName,
|
|
855
|
-
input: call.args,
|
|
856
|
-
output: errorOutput,
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
// Tool not found is a permanent error
|
|
862
|
-
const errorOutput = {
|
|
863
|
-
error: `TOOL_NOT_FOUND: The tool "${exposedName}" does not exist. Do not attempt to call this tool again.`,
|
|
864
|
-
status: "permanently_failed",
|
|
865
|
-
do_not_retry: true,
|
|
866
|
-
};
|
|
867
|
-
functionResponses.push({
|
|
868
|
-
functionResponse: { name: call.name, response: errorOutput },
|
|
869
|
-
});
|
|
870
|
-
options?.toolExecutions?.push({
|
|
871
|
-
name: exposedName,
|
|
872
|
-
input: call.args,
|
|
873
|
-
output: errorOutput,
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return functionResponses;
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* Handle maxSteps termination by producing a final answer when the model was
|
|
881
|
-
* still calling tools as the step limit was reached.
|
|
882
|
-
*
|
|
883
|
-
* Resolution order (always returns a non-empty string): the caller's
|
|
884
|
-
* `finalText` if present; else the `lastStepText` gathered from the final step;
|
|
885
|
-
* else a graceful, user-facing cap message from {@link buildToolLoopCapMessage}
|
|
886
|
-
* — which replaced the legacy bracketed step-limit placeholder string.
|
|
887
|
-
*
|
|
888
|
-
* @param logLabel - Label for log messages (e.g. "[GoogleAIStudio]" or "[GoogleVertex]")
|
|
889
|
-
* @returns The resolved final answer text (never the legacy placeholder).
|
|
890
|
-
*/
|
|
891
|
-
export function handleMaxStepsTermination(logLabel, step, maxSteps, finalText, lastStepText) {
|
|
892
|
-
if (step >= maxSteps && !finalText) {
|
|
893
|
-
logger.warn(`${logLabel} Tool call loop terminated after reaching maxSteps (${maxSteps}). ` +
|
|
894
|
-
`Model was still calling tools. Using accumulated text from last step.`);
|
|
895
|
-
return lastStepText || buildToolLoopCapMessage(maxSteps, 0);
|
|
896
|
-
}
|
|
897
|
-
return finalText;
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* Detect whether an error represents an abort/cancellation (from an
|
|
901
|
-
* AbortSignal firing during a fetch/stream drain). Used by the native
|
|
902
|
-
* Gemini-3 agentic loops to break gracefully rather than re-throw.
|
|
903
|
-
*/
|
|
904
|
-
export function isAbortError(error) {
|
|
905
|
-
if (!error) {
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
const e = error;
|
|
909
|
-
return (e.name === "AbortError" ||
|
|
910
|
-
(typeof e.message === "string" && /abort/i.test(e.message)) ||
|
|
911
|
-
(typeof DOMException !== "undefined" &&
|
|
912
|
-
error instanceof DOMException &&
|
|
913
|
-
e.code === 20));
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Build a graceful, user-facing message for when a single agentic turn hits
|
|
917
|
-
* the step cap without producing a final answer. Replaces the legacy
|
|
918
|
-
* bracketed "Tool execution limit reached" placeholder.
|
|
919
|
-
*
|
|
920
|
-
* Emit this ONLY when `step >= maxSteps` genuinely terminated the loop —
|
|
921
|
-
* aborted/timed-out/stalled turns must use {@link buildAbortedTurnMessage},
|
|
922
|
-
* {@link buildTurnTimeoutMessage}, or {@link buildTurnStalledMessage}, never
|
|
923
|
-
* this text (a killed 23-step turn once claimed "reached the 200-step limit").
|
|
924
|
-
*/
|
|
925
|
-
export function buildToolLoopCapMessage(maxSteps, toolCallCount) {
|
|
926
|
-
const calls = toolCallCount > 0
|
|
927
|
-
? `I gathered information across ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} but `
|
|
928
|
-
: "I ";
|
|
929
|
-
return (`${calls}reached the ${maxSteps}-step limit for a single turn before I could finish. ` +
|
|
930
|
-
`Please narrow the request or break it into smaller asks and I'll continue.`);
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Honest message for a turn stopped by the in-loop context guard
|
|
934
|
-
* (stopReason "context-cap") without a synthesized answer. Sibling of
|
|
935
|
-
* {@link buildToolLoopCapMessage} — context exits must never claim a step
|
|
936
|
-
* limit was reached.
|
|
937
|
-
*/
|
|
938
|
-
export function buildContextCapMessage(toolCallCount) {
|
|
939
|
-
const calls = toolCallCount > 0
|
|
940
|
-
? `I gathered information across ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} but `
|
|
941
|
-
: "I ";
|
|
942
|
-
return (`${calls}had to stop because the gathered material filled this turn's ` +
|
|
943
|
-
`context window before I could finish. Please narrow the request or ` +
|
|
944
|
-
`break it into smaller asks and I'll continue.`);
|
|
945
|
-
}
|
|
946
|
-
/** Format an elapsed duration as "Xm Ys" (or "Ys" under a minute). */
|
|
947
|
-
function formatElapsed(elapsedMs) {
|
|
948
|
-
const totalSeconds = Math.max(0, Math.round(elapsedMs / 1000));
|
|
949
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
950
|
-
const seconds = totalSeconds % 60;
|
|
951
|
-
return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Honest message for a turn ended by the `turnTimeoutMs` wall-clock deadline
|
|
955
|
-
* (stopReason "time-limit"). Sibling of {@link buildToolLoopCapMessage} —
|
|
956
|
-
* time exits must never claim a step limit was reached.
|
|
957
|
-
*/
|
|
958
|
-
export function buildTurnTimeoutMessage(elapsedMs, toolCallCount) {
|
|
959
|
-
const calls = toolCallCount > 0
|
|
960
|
-
? ` I completed ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} before stopping;`
|
|
961
|
-
: "";
|
|
962
|
-
return (`I had to stop after ${formatElapsed(elapsedMs)} — this turn hit its ` +
|
|
963
|
-
`processing time limit.${calls} ask me to continue and I'll pick up from there.`);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Honest message for a turn ended by the `stallTimeoutMs` no-progress
|
|
967
|
-
* watchdog (stopReason "stalled") — typically a wedged tool or a hung
|
|
968
|
-
* model call.
|
|
969
|
-
*/
|
|
970
|
-
export function buildTurnStalledMessage(stallTimeoutMs, toolCallCount) {
|
|
971
|
-
const calls = toolCallCount > 0
|
|
972
|
-
? ` I completed ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} before stopping;`
|
|
973
|
-
: "";
|
|
974
|
-
return (`I had to stop because this turn made no progress for ` +
|
|
975
|
-
`${formatElapsed(stallTimeoutMs)} — a tool or model call appears to be stuck.` +
|
|
976
|
-
`${calls} ask me to continue and I'll pick up from there.`);
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* Honest message for a caller-aborted turn (admin kill, coding-task
|
|
980
|
-
* short-circuit — stopReason "aborted").
|
|
981
|
-
*/
|
|
982
|
-
export function buildAbortedTurnMessage(toolCallCount) {
|
|
983
|
-
const calls = toolCallCount > 0
|
|
984
|
-
? ` I completed ${toolCallCount} tool call${toolCallCount === 1 ? "" : "s"} before stopping.`
|
|
985
|
-
: "";
|
|
986
|
-
return `This turn was stopped before I could finish.${calls}`;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Wrap-up nudge injected when the remaining turn time drops inside the
|
|
990
|
-
* `wrapupTimeLeadMs` window — the time-budget twin of the soft step-budget
|
|
991
|
-
* nudge. Rides as a trailing text block on the tool-result user turn.
|
|
992
|
-
*/
|
|
993
|
-
export function buildWrapupNudgeText(useFinalResultTool) {
|
|
994
|
-
return ("NOTE: processing time for this turn is nearly up. Consolidate what you have and " +
|
|
995
|
-
(useFinalResultTool
|
|
996
|
-
? "call final_result with your best answer now."
|
|
997
|
-
: "provide your final answer now."));
|
|
998
|
-
}
|
|
999
|
-
/**
|
|
1000
|
-
* Resolve the turn's `stopReason` discriminator from the loop's exit
|
|
1001
|
-
* bookkeeping. Precedence: time conditions beat the generic abort flag
|
|
1002
|
-
* (the deadline/stall watchdogs abort through the same internal controller),
|
|
1003
|
-
* abort beats step-cap, and a provider-error finishReason (e.g. persistent
|
|
1004
|
-
* MALFORMED_FUNCTION_CALL) beats "completed".
|
|
1005
|
-
*/
|
|
1006
|
-
export function resolveTurnStopReason(params) {
|
|
1007
|
-
if (params.timedOut) {
|
|
1008
|
-
return "time-limit";
|
|
1009
|
-
}
|
|
1010
|
-
if (params.stalled) {
|
|
1011
|
-
return "stalled";
|
|
1012
|
-
}
|
|
1013
|
-
if (params.wasAborted) {
|
|
1014
|
-
return "aborted";
|
|
1015
|
-
}
|
|
1016
|
-
if (params.contextCappedWithoutAnswer) {
|
|
1017
|
-
return "context-cap";
|
|
1018
|
-
}
|
|
1019
|
-
if (params.cappedWithoutAnswer) {
|
|
1020
|
-
return "step-cap";
|
|
1021
|
-
}
|
|
1022
|
-
if (params.finishReason === "error") {
|
|
1023
|
-
return "provider-error";
|
|
1024
|
-
}
|
|
1025
|
-
return "completed";
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* Wall-clock + progress watchdogs for a native agentic turn.
|
|
1029
|
-
*
|
|
1030
|
-
* - Deadline: `turnTimeoutMs` (caller knob) or `defaultTurnTimeoutMs` (the
|
|
1031
|
-
* loop's pre-existing defensive bound) arms a whole-turn timer.
|
|
1032
|
-
* - Stall: when `stallTimeoutMs` is set, a low-frequency interval checks the
|
|
1033
|
-
* time since the last recorded progress (chunk received, tool started or
|
|
1034
|
-
* finished, step started).
|
|
1035
|
-
*
|
|
1036
|
-
* Both fire `onDeadline(kind)` exactly once each and latch a flag the loop's
|
|
1037
|
-
* terminal handling reads to pick the honest exit message and `stopReason`.
|
|
1038
|
-
* Timers are unref'd so they never hold the process open; call `dispose()`
|
|
1039
|
-
* in the loop's finally.
|
|
1040
|
-
*/
|
|
1041
|
-
export function createTurnClock(params) {
|
|
1042
|
-
const startedAt = Date.now();
|
|
1043
|
-
const isValidMs = (value) => value !== undefined && Number.isFinite(value) && value > 0;
|
|
1044
|
-
const effectiveTurnTimeoutMs = isValidMs(params.turnTimeoutMs)
|
|
1045
|
-
? params.turnTimeoutMs
|
|
1046
|
-
: isValidMs(params.defaultTurnTimeoutMs)
|
|
1047
|
-
? params.defaultTurnTimeoutMs
|
|
1048
|
-
: undefined;
|
|
1049
|
-
// Nudging against the loop's defensive default would inject prompt text
|
|
1050
|
-
// into turns whose caller never opted into a time budget — only nudge
|
|
1051
|
-
// against an explicit turnTimeoutMs.
|
|
1052
|
-
const wrapupLeadMs = isValidMs(params.turnTimeoutMs)
|
|
1053
|
-
? (params.wrapupTimeLeadMs ?? DEFAULT_WRAPUP_TIME_LEAD_MS)
|
|
1054
|
-
: undefined;
|
|
1055
|
-
let timedOut = false;
|
|
1056
|
-
let stalled = false;
|
|
1057
|
-
let lastProgressAt = startedAt;
|
|
1058
|
-
let deadlineTimer;
|
|
1059
|
-
let stallTimer;
|
|
1060
|
-
if (effectiveTurnTimeoutMs !== undefined) {
|
|
1061
|
-
deadlineTimer = setTimeout(() => {
|
|
1062
|
-
timedOut = true;
|
|
1063
|
-
params.onDeadline("timeout");
|
|
1064
|
-
}, effectiveTurnTimeoutMs);
|
|
1065
|
-
deadlineTimer.unref?.();
|
|
1066
|
-
}
|
|
1067
|
-
if (isValidMs(params.stallTimeoutMs)) {
|
|
1068
|
-
const stallTimeoutMs = params.stallTimeoutMs;
|
|
1069
|
-
const checkEveryMs = Math.min(Math.max(1000, Math.floor(stallTimeoutMs / 4)), 15_000);
|
|
1070
|
-
stallTimer = setInterval(() => {
|
|
1071
|
-
if (!stalled &&
|
|
1072
|
-
!timedOut &&
|
|
1073
|
-
Date.now() - lastProgressAt >= stallTimeoutMs) {
|
|
1074
|
-
stalled = true;
|
|
1075
|
-
params.onDeadline("stall");
|
|
1076
|
-
}
|
|
1077
|
-
}, checkEveryMs);
|
|
1078
|
-
stallTimer.unref?.();
|
|
1079
|
-
}
|
|
1080
|
-
return {
|
|
1081
|
-
get timedOut() {
|
|
1082
|
-
return timedOut;
|
|
1083
|
-
},
|
|
1084
|
-
get stalled() {
|
|
1085
|
-
return stalled;
|
|
1086
|
-
},
|
|
1087
|
-
/** True when the turn ended on a time condition (deadline or stall). */
|
|
1088
|
-
get expired() {
|
|
1089
|
-
return timedOut || stalled;
|
|
1090
|
-
},
|
|
1091
|
-
/** The effective whole-turn deadline in ms (explicit or defensive default). */
|
|
1092
|
-
get turnTimeoutMs() {
|
|
1093
|
-
return effectiveTurnTimeoutMs;
|
|
1094
|
-
},
|
|
1095
|
-
elapsedMs() {
|
|
1096
|
-
return Date.now() - startedAt;
|
|
1097
|
-
},
|
|
1098
|
-
/** Record progress: chunk received, tool started/finished, step started. */
|
|
1099
|
-
noteProgress() {
|
|
1100
|
-
lastProgressAt = Date.now();
|
|
1101
|
-
},
|
|
1102
|
-
/** True when an explicit deadline exists and remaining time is inside the wrap-up lead. */
|
|
1103
|
-
shouldNudgeWrapup() {
|
|
1104
|
-
if (effectiveTurnTimeoutMs === undefined || wrapupLeadMs === undefined) {
|
|
1105
|
-
return false;
|
|
1106
|
-
}
|
|
1107
|
-
const remaining = effectiveTurnTimeoutMs - (Date.now() - startedAt);
|
|
1108
|
-
return remaining > 0 && remaining <= wrapupLeadMs;
|
|
1109
|
-
},
|
|
1110
|
-
dispose() {
|
|
1111
|
-
if (deadlineTimer) {
|
|
1112
|
-
clearTimeout(deadlineTimer);
|
|
1113
|
-
}
|
|
1114
|
-
if (stallTimer) {
|
|
1115
|
-
clearInterval(stallTimer);
|
|
1116
|
-
}
|
|
1117
|
-
},
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* In-loop context guard for native agentic turns.
|
|
1122
|
-
*
|
|
1123
|
-
* The provider reports the ACTUAL prompt size of every model call
|
|
1124
|
-
* (usage.input_tokens + cache reads/writes on Anthropic;
|
|
1125
|
-
* usageMetadata.promptTokenCount on Gemini). The guard tracks that number
|
|
1126
|
-
* plus an estimate of what the current step appends (assistant output, tool
|
|
1127
|
-
* results), and tells the loop to stop calling tools once the projected next
|
|
1128
|
-
* prompt crosses `thresholdRatio` of the model's context window — the turn
|
|
1129
|
-
* then synthesizes a final answer from what it has instead of stepping into
|
|
1130
|
-
* a provider 400 ("prompt is too long") that destroys all completed work.
|
|
1131
|
-
*
|
|
1132
|
-
* Fail-open: until the first usage report arrives, `shouldStop()` is false.
|
|
1133
|
-
*/
|
|
1134
|
-
export function createContextGuard(contextWindowTokens, thresholdRatio = DEFAULT_CONTEXT_GUARD_RATIO) {
|
|
1135
|
-
const thresholdTokens = Math.floor(contextWindowTokens * thresholdRatio);
|
|
1136
|
-
let observedPromptTokens = 0;
|
|
1137
|
-
let projectedGrowthTokens = 0;
|
|
1138
|
-
return {
|
|
1139
|
-
/** Tokens at which the guard trips (ratio × window). */
|
|
1140
|
-
get thresholdTokens() {
|
|
1141
|
-
return thresholdTokens;
|
|
1142
|
-
},
|
|
1143
|
-
/** Last observed prompt size plus estimated growth since. */
|
|
1144
|
-
get projectedNextPromptTokens() {
|
|
1145
|
-
return observedPromptTokens + projectedGrowthTokens;
|
|
1146
|
-
},
|
|
1147
|
-
/**
|
|
1148
|
-
* Record a model call's reported usage. `promptTokens` must be the FULL
|
|
1149
|
-
* prompt size (uncached input + cache read + cache creation for
|
|
1150
|
-
* Anthropic). The response's own output is counted as growth — it is
|
|
1151
|
-
* appended to the conversation for the next call.
|
|
1152
|
-
*/
|
|
1153
|
-
noteUsage(promptTokens, outputTokens) {
|
|
1154
|
-
if (promptTokens > 0) {
|
|
1155
|
-
observedPromptTokens = promptTokens;
|
|
1156
|
-
projectedGrowthTokens = Math.max(0, outputTokens);
|
|
1157
|
-
}
|
|
1158
|
-
},
|
|
1159
|
-
/**
|
|
1160
|
-
* Add growth for content appended since the last model call (tool
|
|
1161
|
-
* results, nudge text) using the ~4 chars/token heuristic.
|
|
1162
|
-
*/
|
|
1163
|
-
noteAppendedChars(chars) {
|
|
1164
|
-
if (chars > 0) {
|
|
1165
|
-
projectedGrowthTokens += Math.ceil(chars / 4);
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
/**
|
|
1169
|
-
* Clear the projection after the caller has reclaimed context.
|
|
1170
|
-
*
|
|
1171
|
-
* The observed prompt size reflects the pre-reclaim conversation, so
|
|
1172
|
-
* leaving it in place would keep `shouldStop()` true forever and defeat
|
|
1173
|
-
* the reclaim. Resetting to the fail-open state means the guard stays
|
|
1174
|
-
* quiet until the next real usage report re-establishes the truth.
|
|
1175
|
-
*/
|
|
1176
|
-
resetAfterReclaim() {
|
|
1177
|
-
observedPromptTokens = 0;
|
|
1178
|
-
projectedGrowthTokens = 0;
|
|
1179
|
-
},
|
|
1180
|
-
/** True when issuing another model call risks crossing the threshold. */
|
|
1181
|
-
shouldStop() {
|
|
1182
|
-
return (observedPromptTokens > 0 &&
|
|
1183
|
-
observedPromptTokens + projectedGrowthTokens >= thresholdTokens);
|
|
1184
|
-
},
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
/**
|
|
1188
|
-
* Push model response parts to conversation history, preserving thoughtSignature
|
|
1189
|
-
* for Gemini 3 multi-turn tool calling.
|
|
1190
|
-
*/
|
|
1191
|
-
export function pushModelResponseToHistory(currentContents, rawResponseParts, stepFunctionCalls) {
|
|
1192
|
-
currentContents.push({
|
|
1193
|
-
role: "model",
|
|
1194
|
-
parts: rawResponseParts.length > 0
|
|
1195
|
-
? rawResponseParts
|
|
1196
|
-
: stepFunctionCalls.map((fc) => ({ functionCall: fc })),
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* Convert a Zod schema (or AI SDK `jsonSchema()` wrapper) into the shape
|
|
1201
|
-
* `@google/genai` accepts as `responseSchema`. Mirrors the inline pipeline
|
|
1202
|
-
* the Vertex Gemini paths already use:
|
|
1203
|
-
*
|
|
1204
|
-
* convertZodToJsonSchema → inlineJsonSchema → strip `$schema` → ensure
|
|
1205
|
-
* every nested schema has a `type` (Vertex/Gemini reject schemas missing
|
|
1206
|
-
* that field, even on nested objects).
|
|
1207
|
-
*
|
|
1208
|
-
* Lives here so the AI Studio and Vertex paths can share the same
|
|
1209
|
-
* sanitization without duplicating the schema-conversion churn.
|
|
1210
|
-
*/
|
|
1211
|
-
export function buildGeminiResponseSchema(schema) {
|
|
1212
|
-
const raw = convertZodToJsonSchema(schema, "openApi3");
|
|
1213
|
-
const inlined = inlineJsonSchema(raw);
|
|
1214
|
-
if (inlined.$schema) {
|
|
1215
|
-
delete inlined.$schema;
|
|
1216
|
-
}
|
|
1217
|
-
return ensureNestedSchemaTypes(inlined);
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Map NeuroLink ChatMessage[] history into the @google/genai content format
|
|
1221
|
-
* and push the entries onto a contents array.
|
|
1222
|
-
*
|
|
1223
|
-
* Used by the native Vertex Gemini and Google AI Studio paths to honor
|
|
1224
|
-
* `options.conversationMessages` so multi-turn conversations (memory, loop
|
|
1225
|
-
* REPL, agent flows) actually carry prior turns into the request.
|
|
1226
|
-
*
|
|
1227
|
-
* Behavior notes:
|
|
1228
|
-
* - Only `user` and `assistant` roles are forwarded; system messages are
|
|
1229
|
-
* expected to be wired via `systemInstruction`, and tool-call /
|
|
1230
|
-
* tool-result roles only appear inside intra-call tool loops which build
|
|
1231
|
-
* their own model/function entries.
|
|
1232
|
-
* - String content is wrapped as a single `{ text }` part. Empty strings
|
|
1233
|
-
* are skipped to avoid sending empty parts that some Gemini regions
|
|
1234
|
-
* reject.
|
|
1235
|
-
* - The current user input should be appended AFTER calling this helper
|
|
1236
|
-
* so the prior turns appear first in chronological order.
|
|
1237
|
-
*/
|
|
1238
|
-
export function prependConversationMessages(contents,
|
|
1239
|
-
// Accept either the full ChatMessage shape (when callers pass real Redis-
|
|
1240
|
-
// backed history) or the reduced MinimalChatMessage shape (tests / synthetic
|
|
1241
|
-
// callers). Only role, content, tool, args, and metadata.* are read here.
|
|
1242
|
-
conversationMessages) {
|
|
1243
|
-
if (!conversationMessages || conversationMessages.length === 0) {
|
|
1244
|
-
return;
|
|
1245
|
-
}
|
|
1246
|
-
// Walk prior turns building ordered segments. Tool_call / tool_result rows
|
|
1247
|
-
// get grouped by (turnCounter, stepIndex) so parallel calls within a step
|
|
1248
|
-
// stay together and don't bleed across turn boundaries. Regular user/
|
|
1249
|
-
// assistant messages act as those boundaries.
|
|
1250
|
-
//
|
|
1251
|
-
// Without this reconstruction, a text-only mapper would strip tool rows
|
|
1252
|
-
// from history — leaving the model unaware of any tools it called in
|
|
1253
|
-
// prior turns. The grouped emit (model with functionCall parts → user
|
|
1254
|
-
// with functionResponse parts) is what @google/genai's own
|
|
1255
|
-
// automaticFunctionCalling produces, so the SDK validates it as a
|
|
1256
|
-
// well-formed multi-turn conversation.
|
|
1257
|
-
const stepMap = new Map();
|
|
1258
|
-
const segments = [];
|
|
1259
|
-
let turnCounter = 0;
|
|
1260
|
-
const makeKey = (stepIndex) => `${turnCounter}:${stepIndex ?? "undefined"}`;
|
|
1261
|
-
const getOrCreateStep = (stepIndex) => {
|
|
1262
|
-
const key = makeKey(stepIndex);
|
|
1263
|
-
const existing = stepMap.get(key);
|
|
1264
|
-
if (existing) {
|
|
1265
|
-
return existing;
|
|
1266
|
-
}
|
|
1267
|
-
const step = {
|
|
1268
|
-
type: "tool_step",
|
|
1269
|
-
callParts: [],
|
|
1270
|
-
resultParts: [],
|
|
1271
|
-
};
|
|
1272
|
-
stepMap.set(key, step);
|
|
1273
|
-
segments.push(step);
|
|
1274
|
-
return step;
|
|
1275
|
-
};
|
|
1276
|
-
for (const msg of conversationMessages) {
|
|
1277
|
-
if (msg.role === "tool_call") {
|
|
1278
|
-
const step = getOrCreateStep(msg.metadata?.stepIndex);
|
|
1279
|
-
const fcPart = {
|
|
1280
|
-
functionCall: {
|
|
1281
|
-
name: msg.tool || "unknown",
|
|
1282
|
-
args: msg.args || {},
|
|
1283
|
-
},
|
|
1284
|
-
};
|
|
1285
|
-
if (msg.metadata?.thoughtSignature) {
|
|
1286
|
-
fcPart.thoughtSignature = msg.metadata.thoughtSignature;
|
|
1287
|
-
}
|
|
1288
|
-
step.callParts.push(fcPart);
|
|
1289
|
-
continue;
|
|
1290
|
-
}
|
|
1291
|
-
if (msg.role === "tool_result") {
|
|
1292
|
-
const step = getOrCreateStep(msg.metadata?.stepIndex);
|
|
1293
|
-
let responsePayload;
|
|
1294
|
-
try {
|
|
1295
|
-
responsePayload =
|
|
1296
|
-
msg.content !== undefined && msg.content !== null
|
|
1297
|
-
? { result: JSON.parse(msg.content) }
|
|
1298
|
-
: { result: "success" };
|
|
1299
|
-
}
|
|
1300
|
-
catch {
|
|
1301
|
-
responsePayload = { result: msg.content ?? "success" };
|
|
1302
|
-
}
|
|
1303
|
-
step.resultParts.push({
|
|
1304
|
-
functionResponse: {
|
|
1305
|
-
name: msg.tool || "unknown",
|
|
1306
|
-
response: responsePayload,
|
|
1307
|
-
},
|
|
1308
|
-
});
|
|
1309
|
-
continue;
|
|
1310
|
-
}
|
|
1311
|
-
// Regular (user / assistant) message — acts as a turn boundary.
|
|
1312
|
-
const role = msg.role === "assistant" ? "model" : msg.role;
|
|
1313
|
-
if (role !== "user" && role !== "model") {
|
|
1314
|
-
continue;
|
|
1315
|
-
}
|
|
1316
|
-
if (!msg.content || msg.content.trim().length === 0) {
|
|
1317
|
-
continue;
|
|
1318
|
-
}
|
|
1319
|
-
// Increment turn counter BEFORE pushing the segment so any tool_calls
|
|
1320
|
-
// that follow this message get a fresh (turnCounter, stepIndex) namespace.
|
|
1321
|
-
turnCounter++;
|
|
1322
|
-
const textPart = { text: msg.content };
|
|
1323
|
-
if (msg.metadata?.thoughtSignature) {
|
|
1324
|
-
textPart.thoughtSignature = msg.metadata.thoughtSignature;
|
|
1325
|
-
}
|
|
1326
|
-
segments.push({ type: "regular", role, parts: [textPart] });
|
|
1327
|
-
}
|
|
1328
|
-
// Emit in order: each ToolStep → model turn (calls) + user turn (results)
|
|
1329
|
-
// — same ordering @google/genai's automaticFunctionCalling produces.
|
|
1330
|
-
for (const seg of segments) {
|
|
1331
|
-
if (seg.type === "regular") {
|
|
1332
|
-
contents.push({ role: seg.role, parts: seg.parts });
|
|
1333
|
-
continue;
|
|
1334
|
-
}
|
|
1335
|
-
if (seg.callParts.length === 0) {
|
|
1336
|
-
if (seg.resultParts.length > 0) {
|
|
1337
|
-
logger.debug("[GoogleNativeGemini3] Dropping orphan tool_result segment with no matching tool_call rows", { resultCount: seg.resultParts.length });
|
|
1338
|
-
}
|
|
1339
|
-
continue;
|
|
1340
|
-
}
|
|
1341
|
-
contents.push({ role: "model", parts: seg.callParts });
|
|
1342
|
-
if (seg.resultParts.length > 0) {
|
|
1343
|
-
contents.push({ role: "user", parts: seg.resultParts });
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
/**
|
|
1348
|
-
* Build the `parts` array for the current user turn of a Gemini native
|
|
1349
|
-
* `generateContent` request, including inline image + PDF blobs.
|
|
1350
|
-
*
|
|
1351
|
-
* Both providers that hit the native `@google/genai` SDK — `GoogleVertex`
|
|
1352
|
-
* and `GoogleAIStudio` — need this. The previous AI Studio code only
|
|
1353
|
-
* pushed a single `{ text }` part, which silently dropped `input.images`
|
|
1354
|
-
* and `input.pdfFiles` on the floor: the model received text only and
|
|
1355
|
-
* legitimately reported "no image attached". Extracting this from the
|
|
1356
|
-
* Vertex copy keeps both providers on one definition.
|
|
1357
|
-
*
|
|
1358
|
-
* Accepted shapes per element (mirroring the runtime behaviour the Vertex
|
|
1359
|
-
* code already supported):
|
|
1360
|
-
* - `Buffer` → used as-is
|
|
1361
|
-
* - local file path → read via `readFileSync`, MIME guessed from extension
|
|
1362
|
-
* - `data:<mime>;base64,...` URL → mime parsed, data base64-decoded
|
|
1363
|
-
* - `http(s)://...` URL → fetched, mime from `content-type`
|
|
1364
|
-
* - any other string → assumed to be a base64-encoded payload
|
|
1365
|
-
*
|
|
1366
|
-
* Image MIME guessing is conservative — only known extensions override the
|
|
1367
|
-
* default `image/jpeg`. Fetch failures are logged and the offending entry
|
|
1368
|
-
* is skipped rather than aborting the entire request, matching prior
|
|
1369
|
-
* Vertex behaviour.
|
|
1370
|
-
*/
|
|
1371
|
-
/**
|
|
1372
|
-
* Append audio to a Gemini request as `inlineData` parts.
|
|
1373
|
-
*
|
|
1374
|
-
* Shared by both Gemini front ends. Vertex assembles its request here and AI
|
|
1375
|
-
* Studio assembles it in `buildUserPartsWithMultimodal`; when this lived only in
|
|
1376
|
-
* the Vertex client, AI Studio advertised audio support through
|
|
1377
|
-
* `NATIVE_AUDIO_PROVIDERS` and then silently dropped the bytes.
|
|
1378
|
-
*
|
|
1379
|
-
* Gemini's native request shape is assembled directly rather than taken from the
|
|
1380
|
-
* AI SDK's `file` parts, so audio has to be added explicitly the same way PDFs
|
|
1381
|
-
* and images are — a `{ type: "file" }` part built upstream simply never
|
|
1382
|
-
* reaches this request body. That asymmetry is why attaching a recording
|
|
1383
|
-
* produced only the metadata summary even after the message builder learned to
|
|
1384
|
-
* carry the bytes.
|
|
1385
|
-
*
|
|
1386
|
-
* A container Gemini does not accept is converted first; one that cannot be
|
|
1387
|
-
* converted is skipped rather than sent, because an unsupported inlineData
|
|
1388
|
-
* mimeType fails the whole request, and the caller still has the metadata
|
|
1389
|
-
* summary in the text part.
|
|
1390
|
-
*/
|
|
1391
|
-
export async function appendNativeAudioParts(userParts, audioFiles, logPrefix = "[GeminiNative]") {
|
|
1392
|
-
if (!audioFiles || audioFiles.length === 0) {
|
|
1393
|
-
return;
|
|
1394
|
-
}
|
|
1395
|
-
for (const audio of audioFiles) {
|
|
1396
|
-
// Split on both separators: a Windows-style name reaching a POSIX host
|
|
1397
|
-
// would otherwise keep its whole path, and the extension lookup below
|
|
1398
|
-
// needs the bare filename.
|
|
1399
|
-
const base = audio.filename.split(/[\\/]/).pop() ?? audio.filename;
|
|
1400
|
-
const dot = base.lastIndexOf(".");
|
|
1401
|
-
const extension = dot > 0 ? base.slice(dot) : ".bin";
|
|
1402
|
-
const compatible = await toProviderCompatibleAudio(audio.buffer, audio.mimeType, extension);
|
|
1403
|
-
if (needsAudioTranscode(compatible.mimeType)) {
|
|
1404
|
-
logger.warn(`${logPrefix} Skipping native audio for ${base}: ${compatible.mimeType} ` +
|
|
1405
|
-
`is not accepted and could not be converted. The metadata summary was ` +
|
|
1406
|
-
`still included.`);
|
|
1407
|
-
continue;
|
|
1408
|
-
}
|
|
1409
|
-
userParts.push({
|
|
1410
|
-
inlineData: {
|
|
1411
|
-
mimeType: compatible.mimeType,
|
|
1412
|
-
data: compatible.buffer.toString("base64"),
|
|
1413
|
-
},
|
|
1414
|
-
});
|
|
1415
|
-
logger.debug(`${logPrefix} Added native audio part for ${base} (${compatible.mimeType})`);
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
export async function buildUserPartsWithMultimodal(input, textOverride, logPrefix = "[GeminiNative]") {
|
|
1419
|
-
const text = typeof textOverride === "string" ? textOverride : (input?.text ?? "");
|
|
1420
|
-
const parts = [{ text }];
|
|
1421
|
-
if (input?.pdfFiles && input.pdfFiles.length > 0) {
|
|
1422
|
-
logger.debug(`${logPrefix} Processing ${input.pdfFiles.length} PDF(s)`);
|
|
1423
|
-
for (const pdfFile of input.pdfFiles) {
|
|
1424
|
-
let pdfBuffer;
|
|
1425
|
-
if (typeof pdfFile === "string") {
|
|
1426
|
-
if (existsSync(pdfFile)) {
|
|
1427
|
-
pdfBuffer = readFileSync(pdfFile);
|
|
1428
|
-
}
|
|
1429
|
-
else {
|
|
1430
|
-
// Treat as already-base64-encoded payload
|
|
1431
|
-
pdfBuffer = Buffer.from(pdfFile, "base64");
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
else {
|
|
1435
|
-
pdfBuffer = pdfFile;
|
|
1436
|
-
}
|
|
1437
|
-
parts.push({
|
|
1438
|
-
inlineData: {
|
|
1439
|
-
mimeType: "application/pdf",
|
|
1440
|
-
data: pdfBuffer.toString("base64"),
|
|
1441
|
-
},
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
if (input?.images && input.images.length > 0) {
|
|
1446
|
-
logger.debug(`${logPrefix} Processing ${input.images.length} image(s)`);
|
|
1447
|
-
for (const rawImage of input.images) {
|
|
1448
|
-
// `images` may carry plain Buffer/string values or `{ data, altText? }`
|
|
1449
|
-
// objects. Normalise to the inner payload before format detection.
|
|
1450
|
-
const image = rawImage && typeof rawImage === "object" && !Buffer.isBuffer(rawImage)
|
|
1451
|
-
? rawImage.data
|
|
1452
|
-
: rawImage;
|
|
1453
|
-
let imageBuffer;
|
|
1454
|
-
let mimeType = "image/jpeg";
|
|
1455
|
-
if (typeof image === "string") {
|
|
1456
|
-
if (existsSync(image)) {
|
|
1457
|
-
imageBuffer = readFileSync(image);
|
|
1458
|
-
const ext = extname(image).toLowerCase();
|
|
1459
|
-
if (ext === ".png") {
|
|
1460
|
-
mimeType = "image/png";
|
|
1461
|
-
}
|
|
1462
|
-
else if (ext === ".gif") {
|
|
1463
|
-
mimeType = "image/gif";
|
|
1464
|
-
}
|
|
1465
|
-
else if (ext === ".webp") {
|
|
1466
|
-
mimeType = "image/webp";
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
else if (image.startsWith("data:")) {
|
|
1470
|
-
const matches = image.match(/^data:([^;]+);base64,(.+)$/);
|
|
1471
|
-
if (matches) {
|
|
1472
|
-
mimeType = matches[1];
|
|
1473
|
-
imageBuffer = Buffer.from(matches[2], "base64");
|
|
1474
|
-
}
|
|
1475
|
-
else {
|
|
1476
|
-
continue;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
else if (image.startsWith("http://") ||
|
|
1480
|
-
image.startsWith("https://")) {
|
|
1481
|
-
try {
|
|
1482
|
-
const response = await fetch(image);
|
|
1483
|
-
if (!response.ok) {
|
|
1484
|
-
logger.warn(`${logPrefix} Image fetch failed: ${response.status} ${response.statusText}, skipping`, { url: image });
|
|
1485
|
-
continue;
|
|
1486
|
-
}
|
|
1487
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
1488
|
-
imageBuffer = Buffer.from(arrayBuffer);
|
|
1489
|
-
const headerMime = response.headers.get("content-type");
|
|
1490
|
-
if (headerMime && headerMime.startsWith("image/")) {
|
|
1491
|
-
mimeType = headerMime.split(";")[0];
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
catch (fetchError) {
|
|
1495
|
-
logger.warn(`${logPrefix} Image URL fetch threw, skipping: ${fetchError instanceof Error
|
|
1496
|
-
? fetchError.message
|
|
1497
|
-
: String(fetchError)}`, { url: image });
|
|
1498
|
-
continue;
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
else {
|
|
1502
|
-
imageBuffer = Buffer.from(image, "base64");
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
else {
|
|
1506
|
-
imageBuffer = image;
|
|
1507
|
-
}
|
|
1508
|
-
if (!imageBuffer) {
|
|
1509
|
-
continue;
|
|
1510
|
-
}
|
|
1511
|
-
parts.push({
|
|
1512
|
-
inlineData: {
|
|
1513
|
-
mimeType,
|
|
1514
|
-
data: imageBuffer.toString("base64"),
|
|
1515
|
-
},
|
|
1516
|
-
});
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
// Audio last, and through the same helper the Vertex client uses. AI Studio
|
|
1520
|
-
// never touches `buildMultimodalMessagesArray` — it overrides generate() and
|
|
1521
|
-
// stream() and assembles its request here — so wiring audio only into the
|
|
1522
|
-
// Vertex client left this front end advertising native audio via
|
|
1523
|
-
// NATIVE_AUDIO_PROVIDERS and then dropping the bytes on the floor.
|
|
1524
|
-
await appendNativeAudioParts(parts, input?.nativeAudioFiles, logPrefix);
|
|
1525
|
-
return parts;
|
|
1526
|
-
}
|
|
1527
|
-
//# sourceMappingURL=utils.js.map
|