@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,1862 +0,0 @@
|
|
|
1
|
-
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
-
import { SpanKind, trace } from "@opentelemetry/api";
|
|
3
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "fs";
|
|
4
|
-
import { homedir } from "os";
|
|
5
|
-
import { join } from "path";
|
|
6
|
-
import { ANTHROPIC_TOKEN_URL, CLAUDE_CLI_USER_AGENT, CLAUDE_CODE_CLIENT_ID, CLAUDE_CODE_OAUTH_BETAS, } from "../../auth/anthropicOAuth.js";
|
|
7
|
-
import { AnthropicModels, TOKEN_EXPIRY_BUFFER_MS, } from "../../constants/enums.js";
|
|
8
|
-
import { BaseProvider } from "../../core/baseProvider.js";
|
|
9
|
-
import { DEFAULT_MAX_STEPS } from "../../core/constants.js";
|
|
10
|
-
import { streamAnalyticsCollector } from "../../core/streamAnalytics.js";
|
|
11
|
-
import { getModelCapabilities, getRecommendedModelForTier, isModelAvailableForTier, } from "../../models/anthropicModels.js";
|
|
12
|
-
import { createOAuthFetch } from "../../proxy/oauthFetch.js";
|
|
13
|
-
import { createProxyFetch } from "../../proxy/proxyFetch.js";
|
|
14
|
-
import { getCapturedLimitSnapshot, getCapturedResponseHeaders, logClaudeLimitSnapshot, runInLimitCaptureScope, setLimitSpanAttributes, withLimitCapture, wrapFetchWithLimitCapture, } from "./rateLimitCapture.js";
|
|
15
|
-
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../../types/index.js";
|
|
16
|
-
import { classifyProviderError } from "../../utils/errorClassifier.js";
|
|
17
|
-
import { logger } from "../../utils/logger.js";
|
|
18
|
-
import { ANTHROPIC_ELISION_NOTE, planAnthropicLoopReclaim, previewAnthropicToolResultText, } from "../../context/anthropicLoopGuard.js";
|
|
19
|
-
import { getAvailableInputTokens } from "../../constants/contextWindows.js";
|
|
20
|
-
import { estimateTokens } from "../../utils/tokenEstimation.js";
|
|
21
|
-
import { redactUrlCredentials } from "../../utils/logSanitize.js";
|
|
22
|
-
import { ANTHROPIC_MAX_CACHE_BREAKPOINTS, applyAnthropicHistoryCacheBreakpoints, countAnthropicCacheMarkers, } from "../../utils/anthropicCacheBreakpoints.js";
|
|
23
|
-
import { calculateCost } from "../../utils/pricing.js";
|
|
24
|
-
import { stringifyAnthropicToolOutput } from "./toolOutput.js";
|
|
25
|
-
import { createAnthropicLoopAdapter } from "./loopAdapter.js";
|
|
26
|
-
import { runAgenticLoop } from "../../core/loopEngine.js";
|
|
27
|
-
import { createAnthropicConfig, getProviderModel, validateApiKey, } from "../../utils/providerConfig.js";
|
|
28
|
-
import { composeAbortSignals, createTimeoutController, mergeAbortSignals, } from "../../utils/timeout.js";
|
|
29
|
-
import { resolveToolChoice } from "../../utils/toolChoice.js";
|
|
30
|
-
import { emitToolEndFromStepFinish } from "../../utils/toolEndEmitter.js";
|
|
31
|
-
import { NoOutputGeneratedError } from "../../utils/generationErrors.js";
|
|
32
|
-
import { buildNoOutputSentinel, stampNoOutputSpan, } from "../../utils/noOutputSentinel.js";
|
|
33
|
-
import { convertZodToJsonSchema } from "../../utils/schemaConversion.js";
|
|
34
|
-
import { resolveClaudeMaxTokens } from "../../utils/tokenLimits.js";
|
|
35
|
-
import { toAnthropicImageBlock, fileToAnthropicBlock, } from "../anthropicImageBlocks.js";
|
|
36
|
-
import { resolveSamplingParams } from "../../models/modelRegistry.js";
|
|
37
|
-
import { createDeferredAnalytics, stringifyToolInput, } from "../openaiChatCompletionsClient.js";
|
|
38
|
-
import { createStreamChannel } from "../../core/streamChannel.js";
|
|
39
|
-
import { toNativeToolDeclarations } from "../../core/nativeToolFormat.js";
|
|
40
|
-
import { ANTHROPIC_BETA_HEADERS } from "./constants.js";
|
|
41
|
-
import { cacheControlOf } from "./cacheControl.js";
|
|
42
|
-
import { appendFinalResultInstruction, appendFinalResultTool, FINAL_RESULT_TOOL_NAME, } from "./structuredOutput.js";
|
|
43
|
-
// AnthropicProviderConfig is imported from types/providers.ts
|
|
44
|
-
// Re-export for backward compatibility
|
|
45
|
-
// Configuration helpers - now using consolidated utility
|
|
46
|
-
const getAnthropicApiKey = () => {
|
|
47
|
-
return validateApiKey(createAnthropicConfig());
|
|
48
|
-
};
|
|
49
|
-
const getDefaultAnthropicModel = () => {
|
|
50
|
-
return getProviderModel("ANTHROPIC_MODEL", AnthropicModels.CLAUDE_SONNET_4_6);
|
|
51
|
-
};
|
|
52
|
-
const streamTracer = trace.getTracer("neurolink.provider.anthropic");
|
|
53
|
-
/**
|
|
54
|
-
* Get OAuth token from stored credentials file or environment.
|
|
55
|
-
* Priority:
|
|
56
|
-
* 1. Stored credentials file (~/.neurolink/anthropic-credentials.json)
|
|
57
|
-
* 2. Environment variables (ANTHROPIC_OAUTH_TOKEN or CLAUDE_OAUTH_TOKEN)
|
|
58
|
-
*/
|
|
59
|
-
const getOAuthToken = () => {
|
|
60
|
-
// First, check stored credentials file (highest priority)
|
|
61
|
-
try {
|
|
62
|
-
const credentialsPath = join(homedir(), ".neurolink", "anthropic-credentials.json");
|
|
63
|
-
if (existsSync(credentialsPath)) {
|
|
64
|
-
const credentialsContent = readFileSync(credentialsPath, "utf-8");
|
|
65
|
-
const credentials = JSON.parse(credentialsContent);
|
|
66
|
-
if (credentials.type === "oauth" && credentials.oauth?.accessToken) {
|
|
67
|
-
logger.debug("[AnthropicProvider] Using OAuth token from stored credentials file");
|
|
68
|
-
return credentials.oauth;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
logger.debug("[AnthropicProvider] Failed to read stored credentials:", error);
|
|
74
|
-
}
|
|
75
|
-
// Fallback to environment variables
|
|
76
|
-
const tokenString = process.env.ANTHROPIC_OAUTH_TOKEN || process.env.CLAUDE_OAUTH_TOKEN;
|
|
77
|
-
if (!tokenString) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
// Try to parse as JSON (for full token object with refresh token and expiry)
|
|
81
|
-
try {
|
|
82
|
-
const parsed = JSON.parse(tokenString);
|
|
83
|
-
if (typeof parsed === "object" && parsed.accessToken) {
|
|
84
|
-
return parsed;
|
|
85
|
-
}
|
|
86
|
-
// If it's a simple string in JSON, use it as access token
|
|
87
|
-
if (typeof parsed === "string") {
|
|
88
|
-
return { accessToken: parsed };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
// Not JSON, treat as plain access token string
|
|
93
|
-
}
|
|
94
|
-
// Treat as plain access token string
|
|
95
|
-
return { accessToken: tokenString };
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Detect subscription tier from environment or token.
|
|
99
|
-
* Environment variable ANTHROPIC_SUBSCRIPTION_TIER takes precedence.
|
|
100
|
-
*/
|
|
101
|
-
const detectSubscriptionTier = (oauthToken) => {
|
|
102
|
-
// Check explicit environment variable first
|
|
103
|
-
const envTier = process.env.ANTHROPIC_SUBSCRIPTION_TIER?.toLowerCase();
|
|
104
|
-
if (envTier) {
|
|
105
|
-
const validTiers = [
|
|
106
|
-
"free",
|
|
107
|
-
"pro",
|
|
108
|
-
"max",
|
|
109
|
-
"max_5",
|
|
110
|
-
"max_20",
|
|
111
|
-
"api",
|
|
112
|
-
];
|
|
113
|
-
if (validTiers.includes(envTier)) {
|
|
114
|
-
logger.debug("[detectSubscriptionTier] Using environment override", {
|
|
115
|
-
tier: envTier,
|
|
116
|
-
});
|
|
117
|
-
return envTier;
|
|
118
|
-
}
|
|
119
|
-
logger.warn("[detectSubscriptionTier] Invalid ANTHROPIC_SUBSCRIPTION_TIER", {
|
|
120
|
-
value: envTier,
|
|
121
|
-
validTiers,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
// If using OAuth, default to 'pro' (most common subscription tier)
|
|
125
|
-
if (oauthToken) {
|
|
126
|
-
// Check if token scopes indicate tier (future-proofing)
|
|
127
|
-
const scopes = oauthToken.scopes ?? [];
|
|
128
|
-
let detectedTier = "pro";
|
|
129
|
-
if (scopes.includes("max_20")) {
|
|
130
|
-
detectedTier = "max_20";
|
|
131
|
-
}
|
|
132
|
-
else if (scopes.includes("max_5")) {
|
|
133
|
-
detectedTier = "max_5";
|
|
134
|
-
}
|
|
135
|
-
else if (scopes.includes("max")) {
|
|
136
|
-
detectedTier = "max";
|
|
137
|
-
}
|
|
138
|
-
logger.debug("[detectSubscriptionTier] Detected from OAuth token", {
|
|
139
|
-
tier: detectedTier,
|
|
140
|
-
scopes,
|
|
141
|
-
});
|
|
142
|
-
return detectedTier;
|
|
143
|
-
}
|
|
144
|
-
// Default to 'api' for API key authentication
|
|
145
|
-
logger.debug("[detectSubscriptionTier] No OAuth token, defaulting to API tier");
|
|
146
|
-
return "api";
|
|
147
|
-
};
|
|
148
|
-
/**
|
|
149
|
-
* Determine authentication method based on available credentials.
|
|
150
|
-
* OAuth takes precedence over API key if both are available.
|
|
151
|
-
*/
|
|
152
|
-
const detectAuthMethod = (oauthToken) => {
|
|
153
|
-
// Explicit env var takes highest precedence — allows forcing api_key mode
|
|
154
|
-
// even when OAuth credentials exist (e.g., when using a proxy that handles auth)
|
|
155
|
-
const explicit = process.env.ANTHROPIC_AUTH_METHOD?.toLowerCase();
|
|
156
|
-
if (explicit === "api_key" || explicit === "apikey") {
|
|
157
|
-
logger.debug("[detectAuthMethod] Forced to api_key by ANTHROPIC_AUTH_METHOD env var");
|
|
158
|
-
return "api_key";
|
|
159
|
-
}
|
|
160
|
-
if (explicit === "oauth") {
|
|
161
|
-
if (oauthToken) {
|
|
162
|
-
logger.debug("[detectAuthMethod] Forced to oauth by ANTHROPIC_AUTH_METHOD env var");
|
|
163
|
-
return "oauth";
|
|
164
|
-
}
|
|
165
|
-
logger.warn("[detectAuthMethod] ANTHROPIC_AUTH_METHOD=oauth but no OAuth token found; falling through to auto-detection");
|
|
166
|
-
}
|
|
167
|
-
else if (explicit) {
|
|
168
|
-
logger.warn("[detectAuthMethod] Unrecognized ANTHROPIC_AUTH_METHOD value; falling through to auto-detection", {
|
|
169
|
-
value: explicit,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
// Auto-detect: OAuth takes precedence if available
|
|
173
|
-
const method = oauthToken ? "oauth" : "api_key";
|
|
174
|
-
logger.debug("[detectAuthMethod] Auth method resolved", {
|
|
175
|
-
method,
|
|
176
|
-
hasOAuthToken: !!oauthToken,
|
|
177
|
-
});
|
|
178
|
-
return method;
|
|
179
|
-
};
|
|
180
|
-
// Rate-limit header parsing lives in `rateLimitCapture.ts`, which sees the raw
|
|
181
|
-
// fetch Response and understands both header families (unified subscription
|
|
182
|
-
// windows and the legacy per-tier counters). The module-private copy that used
|
|
183
|
-
// to sit here parsed only the legacy family and had no callers.
|
|
184
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
185
|
-
// Native Messages-API conversion helpers (NeuroLink/V3 shapes → Anthropic)
|
|
186
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
187
|
-
/**
|
|
188
|
-
* Convert NeuroLink/V3-shaped messages (the shape produced by
|
|
189
|
-
* buildMessagesForStream and by the AI-SDK prompt on the V3 doGenerate path)
|
|
190
|
-
* into the Anthropic Messages payload: a top-level `system` string plus
|
|
191
|
-
* alternating user/assistant messages with typed content blocks.
|
|
192
|
-
*/
|
|
193
|
-
const messagesToAnthropic = (msgs) => {
|
|
194
|
-
const systemBlocks = [];
|
|
195
|
-
const messages = [];
|
|
196
|
-
const partsOf = (content) => Array.isArray(content) ? content : [content];
|
|
197
|
-
// Message-level cache breakpoints apply to the message's LAST content
|
|
198
|
-
// block (the AI-SDK convention MessageBuilder relies on).
|
|
199
|
-
const applyMessageCacheControl = (blocks, msg) => {
|
|
200
|
-
const cc = cacheControlOf(msg);
|
|
201
|
-
if (cc && blocks.length > 0) {
|
|
202
|
-
const last = blocks[blocks.length - 1];
|
|
203
|
-
last.cache_control = cc;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
for (const msg of msgs) {
|
|
207
|
-
switch (msg.role) {
|
|
208
|
-
case "system": {
|
|
209
|
-
const text = typeof msg.content === "string"
|
|
210
|
-
? msg.content
|
|
211
|
-
: partsOf(msg.content)
|
|
212
|
-
.map((p) => typeof p === "string"
|
|
213
|
-
? p
|
|
214
|
-
: String(p?.text ?? ""))
|
|
215
|
-
.join("\n");
|
|
216
|
-
const cc = cacheControlOf(msg);
|
|
217
|
-
systemBlocks.push({
|
|
218
|
-
type: "text",
|
|
219
|
-
text,
|
|
220
|
-
...(cc ? { cache_control: cc } : {}),
|
|
221
|
-
});
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
case "user": {
|
|
225
|
-
const blocks = [];
|
|
226
|
-
for (const part of partsOf(msg.content)) {
|
|
227
|
-
if (typeof part === "string") {
|
|
228
|
-
if (part.length > 0) {
|
|
229
|
-
blocks.push({ type: "text", text: part });
|
|
230
|
-
}
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
const p = part;
|
|
234
|
-
if (p?.type === "text" && typeof p.text === "string") {
|
|
235
|
-
const cc = cacheControlOf(p);
|
|
236
|
-
blocks.push({
|
|
237
|
-
type: "text",
|
|
238
|
-
text: p.text,
|
|
239
|
-
...(cc ? { cache_control: cc } : {}),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
else if (p?.type === "image" || p?.type === "image_url") {
|
|
243
|
-
const img = toAnthropicImageBlock(p.image ?? p.data ?? p.url);
|
|
244
|
-
if (img) {
|
|
245
|
-
const cc = cacheControlOf(p);
|
|
246
|
-
blocks.push(cc ? { ...img, cache_control: cc } : img);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else if (p?.type === "file") {
|
|
250
|
-
// AI-SDK v6 encodes images AND PDFs as `type:"file"` parts in the
|
|
251
|
-
// LanguageModel prompt that `doGenerate` receives. Without this
|
|
252
|
-
// branch the image is dropped on the tool-using generate path and
|
|
253
|
-
// the model never sees it ("no image detected").
|
|
254
|
-
//
|
|
255
|
-
// Runtime guard: p comes from message parsing and may not match the
|
|
256
|
-
// expected shape. Verify p is an object and that mediaType, if
|
|
257
|
-
// present, is a string (not an object/array from a malformed part).
|
|
258
|
-
// Skip gracefully rather than passing a bad shape to fileToAnthropicBlock.
|
|
259
|
-
const isValidFilePart = typeof p === "object" &&
|
|
260
|
-
p !== null &&
|
|
261
|
-
("mediaType" in p
|
|
262
|
-
? typeof p.mediaType === "string"
|
|
263
|
-
: true);
|
|
264
|
-
const block = isValidFilePart
|
|
265
|
-
? fileToAnthropicBlock(p)
|
|
266
|
-
: undefined;
|
|
267
|
-
if (block) {
|
|
268
|
-
const cc = cacheControlOf(p);
|
|
269
|
-
if (cc) {
|
|
270
|
-
// block is a fresh object from fileToAnthropicBlock; mutate in
|
|
271
|
-
// place to keep the discriminated-union type (a spread widens it
|
|
272
|
-
// past ContentBlockParam).
|
|
273
|
-
block.cache_control = cc;
|
|
274
|
-
}
|
|
275
|
-
blocks.push(block);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (blocks.length > 0) {
|
|
280
|
-
applyMessageCacheControl(blocks, msg);
|
|
281
|
-
messages.push({ role: "user", content: blocks });
|
|
282
|
-
}
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
case "assistant": {
|
|
286
|
-
const blocks = [];
|
|
287
|
-
for (const part of partsOf(msg.content)) {
|
|
288
|
-
if (typeof part === "string") {
|
|
289
|
-
if (part.length > 0) {
|
|
290
|
-
blocks.push({ type: "text", text: part });
|
|
291
|
-
}
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
const p = part;
|
|
295
|
-
if (p?.type === "text" && typeof p.text === "string") {
|
|
296
|
-
if (p.text.length > 0) {
|
|
297
|
-
const cc = cacheControlOf(p);
|
|
298
|
-
blocks.push({
|
|
299
|
-
type: "text",
|
|
300
|
-
text: p.text,
|
|
301
|
-
...(cc ? { cache_control: cc } : {}),
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
else if (p?.type === "tool-call") {
|
|
306
|
-
let input = p.input;
|
|
307
|
-
if (typeof input === "string") {
|
|
308
|
-
try {
|
|
309
|
-
input = JSON.parse(input);
|
|
310
|
-
}
|
|
311
|
-
catch {
|
|
312
|
-
input = {};
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
blocks.push({
|
|
316
|
-
type: "tool_use",
|
|
317
|
-
id: p.toolCallId ?? "",
|
|
318
|
-
name: p.toolName ?? "",
|
|
319
|
-
input: input ?? {},
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (blocks.length > 0) {
|
|
324
|
-
applyMessageCacheControl(blocks, msg);
|
|
325
|
-
messages.push({ role: "assistant", content: blocks });
|
|
326
|
-
}
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
case "tool": {
|
|
330
|
-
// Tool results are user-role messages with tool_result blocks.
|
|
331
|
-
const blocks = [];
|
|
332
|
-
if (Array.isArray(msg.content)) {
|
|
333
|
-
for (const part of msg.content) {
|
|
334
|
-
const p = part;
|
|
335
|
-
if (p?.type === "tool-result") {
|
|
336
|
-
blocks.push({
|
|
337
|
-
type: "tool_result",
|
|
338
|
-
tool_use_id: p.toolCallId ?? "",
|
|
339
|
-
content: stringifyAnthropicToolOutput(p.output),
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else if (typeof msg.content === "string") {
|
|
345
|
-
blocks.push({
|
|
346
|
-
type: "tool_result",
|
|
347
|
-
tool_use_id: msg.toolCallId ?? "",
|
|
348
|
-
content: msg.content,
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
if (blocks.length > 0) {
|
|
352
|
-
messages.push({ role: "user", content: blocks });
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
// Plain-string system when no cache breakpoints are present (matches the
|
|
359
|
-
// previous wire shape); block form only when cache_control must ride along.
|
|
360
|
-
const system = systemBlocks.length === 0
|
|
361
|
-
? undefined
|
|
362
|
-
: systemBlocks.some((b) => b.cache_control)
|
|
363
|
-
? systemBlocks
|
|
364
|
-
: systemBlocks.map((b) => b.text).join("\n\n");
|
|
365
|
-
return {
|
|
366
|
-
...(system !== undefined ? { system } : {}),
|
|
367
|
-
messages,
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
|
-
/** Map a NeuroLink tool choice onto Anthropic's tool_choice shape. */
|
|
371
|
-
const toolChoiceToAnthropic = (choice) => {
|
|
372
|
-
if (!choice || choice === "auto") {
|
|
373
|
-
return undefined; // Anthropic defaults to auto when tools are present
|
|
374
|
-
}
|
|
375
|
-
if (choice === "none") {
|
|
376
|
-
return { type: "none" };
|
|
377
|
-
}
|
|
378
|
-
if (choice === "required") {
|
|
379
|
-
return { type: "any" };
|
|
380
|
-
}
|
|
381
|
-
if (typeof choice === "object") {
|
|
382
|
-
const c = choice;
|
|
383
|
-
if (c.type === "tool" && c.toolName) {
|
|
384
|
-
return { type: "tool", name: c.toolName };
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return undefined;
|
|
388
|
-
};
|
|
389
|
-
/** Map Anthropic stop_reason onto the V3 unified finish reason. */
|
|
390
|
-
const mapAnthropicStopReason = (raw) => {
|
|
391
|
-
switch (raw) {
|
|
392
|
-
case "max_tokens":
|
|
393
|
-
return "length";
|
|
394
|
-
case "tool_use":
|
|
395
|
-
return "tool-calls";
|
|
396
|
-
case "refusal":
|
|
397
|
-
return "content-filter";
|
|
398
|
-
default:
|
|
399
|
-
return "stop";
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
// Anthropic's Messages API requires max_tokens on every request. When the
|
|
403
|
-
// caller omits it, default to the model's real output ceiling via
|
|
404
|
-
// resolveClaudeMaxTokens (e.g. 64K for Sonnet 4.x) instead of the legacy 4096,
|
|
405
|
-
// which silently truncated large structured responses mid-JSON.
|
|
406
|
-
//
|
|
407
|
-
// Client-level request timeout. The Anthropic SDK throws "Streaming is required
|
|
408
|
-
// for long requests" from a NON-streaming `messages.create` when `max_tokens`
|
|
409
|
-
// is large AND no client-level timeout is configured (it can't estimate a safe
|
|
410
|
-
// timeout). Setting an explicit client timeout — equal to the SDK's own default
|
|
411
|
-
// for the non-throwing path — suppresses that pre-flight throw so large
|
|
412
|
-
// max_tokens (our model-ceiling default) works. Per-request duration is still
|
|
413
|
-
// bounded by the abort signal NeuroLink composes for each call.
|
|
414
|
-
const ANTHROPIC_CLIENT_TIMEOUT_MS = 600_000;
|
|
415
|
-
/**
|
|
416
|
-
* Anthropic Provider v2 - BaseProvider Implementation
|
|
417
|
-
* Enhanced with OAuth support, subscription tiers, and beta headers for Claude Code integration.
|
|
418
|
-
*/
|
|
419
|
-
export class AnthropicProvider extends BaseProvider {
|
|
420
|
-
client;
|
|
421
|
-
authMethod;
|
|
422
|
-
subscriptionTier;
|
|
423
|
-
enableBetaFeatures;
|
|
424
|
-
oauthToken;
|
|
425
|
-
lastResponseMetadata = null;
|
|
426
|
-
usageInfo = null;
|
|
427
|
-
refreshPromise;
|
|
428
|
-
/**
|
|
429
|
-
* Create a new Anthropic provider instance.
|
|
430
|
-
*
|
|
431
|
-
* @param modelName - Optional model name to use (defaults to CLAUDE_3_5_SONNET)
|
|
432
|
-
* @param sdk - Optional NeuroLink SDK instance
|
|
433
|
-
* @param config - Optional configuration options for auth, subscription tier, and beta features
|
|
434
|
-
*/
|
|
435
|
-
constructor(modelName, sdk, config, credentials) {
|
|
436
|
-
// Pre-compute effective model with tier validation before calling super.
|
|
437
|
-
//
|
|
438
|
-
// When per-request credentials supply an apiKey (without oauthToken),
|
|
439
|
-
// force api_key auth — skip OAuth detection entirely so the caller's
|
|
440
|
-
// key is used rather than a stale OAuth token from ~/.neurolink/.
|
|
441
|
-
const forceApiKey = !!(credentials?.apiKey && !credentials?.oauthToken);
|
|
442
|
-
const oauthToken = forceApiKey
|
|
443
|
-
? null
|
|
444
|
-
: ((credentials?.oauthToken
|
|
445
|
-
? { accessToken: credentials.oauthToken }
|
|
446
|
-
: null) ??
|
|
447
|
-
config?.oauthToken ??
|
|
448
|
-
getOAuthToken());
|
|
449
|
-
// Resolve auth method FIRST so that tier detection uses the chosen method.
|
|
450
|
-
// If ANTHROPIC_AUTH_METHOD=api_key wins over an existing OAuth token, the
|
|
451
|
-
// tier must reflect api_key mode (full model access) rather than the OAuth
|
|
452
|
-
// token's subscription level.
|
|
453
|
-
const authMethod = forceApiKey
|
|
454
|
-
? "api_key"
|
|
455
|
-
: (config?.authMethod ?? detectAuthMethod(oauthToken));
|
|
456
|
-
const subscriptionTier = config?.subscriptionTier ??
|
|
457
|
-
(authMethod === "oauth" ? detectSubscriptionTier(oauthToken) : "api");
|
|
458
|
-
const targetModel = modelName || getDefaultAnthropicModel();
|
|
459
|
-
// Determine effective model based on tier access.
|
|
460
|
-
// Skip tier validation when a proxy is in use (ANTHROPIC_BASE_URL is set)
|
|
461
|
-
// — the proxy handles model access and auth, so the SDK should pass
|
|
462
|
-
// the requested model through without downgrading.
|
|
463
|
-
let effectiveModel = targetModel;
|
|
464
|
-
const usingProxy = !!process.env.ANTHROPIC_BASE_URL;
|
|
465
|
-
if (!usingProxy &&
|
|
466
|
-
subscriptionTier !== "api" &&
|
|
467
|
-
!isModelAvailableForTier(targetModel, subscriptionTier)) {
|
|
468
|
-
effectiveModel = getRecommendedModelForTier(subscriptionTier);
|
|
469
|
-
logger.warn("Model not available for subscription tier, using recommended model", {
|
|
470
|
-
requestedModel: targetModel,
|
|
471
|
-
subscriptionTier,
|
|
472
|
-
recommendedModel: effectiveModel,
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
super(effectiveModel, "anthropic", sdk);
|
|
476
|
-
// Apply configuration with defaults
|
|
477
|
-
this.enableBetaFeatures = config?.enableBetaFeatures ?? true;
|
|
478
|
-
// Store computed values
|
|
479
|
-
this.oauthToken = oauthToken;
|
|
480
|
-
this.subscriptionTier = subscriptionTier;
|
|
481
|
-
// Use the auth method already resolved above (before tier computation)
|
|
482
|
-
this.authMethod = authMethod;
|
|
483
|
-
// Build headers based on auth method and subscription tier
|
|
484
|
-
const headers = this.getAuthHeaders();
|
|
485
|
-
// Create the official Anthropic SDK client based on auth method
|
|
486
|
-
let client;
|
|
487
|
-
logger.debug("[AnthropicProvider] Constructor - checking OAuth:", {
|
|
488
|
-
authMethod: this.authMethod,
|
|
489
|
-
hasOAuthToken: !!this.oauthToken,
|
|
490
|
-
hasAccessToken: !!this.oauthToken?.accessToken,
|
|
491
|
-
});
|
|
492
|
-
if (this.authMethod === "oauth" && this.oauthToken) {
|
|
493
|
-
// OAuth authentication - use custom fetch wrapper that handles:
|
|
494
|
-
// - Bearer token authorization
|
|
495
|
-
// - OAuth beta headers (oauth-2025-04-20, NOT claude-code-20250219)
|
|
496
|
-
// - User-Agent spoofing
|
|
497
|
-
// - ?beta=true query param
|
|
498
|
-
// - Tool name prefixing/stripping
|
|
499
|
-
logger.debug("[AnthropicProvider] Creating OAuth fetch wrapper...");
|
|
500
|
-
// Pass a getter so the fetch wrapper always uses the current token,
|
|
501
|
-
// even after an automatic token refresh.
|
|
502
|
-
// oauthToken is guaranteed non-null here (checked by the enclosing if-guard).
|
|
503
|
-
const tokenRef = this.oauthToken;
|
|
504
|
-
// skipBodyTransform=true: For the SDK client path, body transforms ARE
|
|
505
|
-
// intentionally skipped because the official Anthropic SDK builds its
|
|
506
|
-
// own request format (system prompts, metadata, tool definitions). The
|
|
507
|
-
// billing header, agent block, user_id injection, and mcp_ tool-name
|
|
508
|
-
// prefixing are only needed for proxy passthrough of raw Claude API
|
|
509
|
-
// requests where we must make the request look like it came from
|
|
510
|
-
// Claude Code / CLIProxyAPI.
|
|
511
|
-
const oauthFetch = createOAuthFetch(() => tokenRef.accessToken, this.enableBetaFeatures, false, // No mcp_ prefix — tool names pass through as-is (matches CLIProxyAPI)
|
|
512
|
-
true);
|
|
513
|
-
// For OAuth, we use a dummy API key since our fetch wrapper handles auth
|
|
514
|
-
// IMPORTANT: Do NOT pass beta headers here - our fetch wrapper handles them
|
|
515
|
-
// The claude-code-20250219 beta header triggers "credential only for Claude Code" error
|
|
516
|
-
client = new Anthropic({
|
|
517
|
-
apiKey: "oauth-authenticated", // Placeholder, actual auth is in fetch wrapper
|
|
518
|
-
// Note: No headers passed - fetch wrapper sets oauth-2025-04-20 beta header
|
|
519
|
-
// Limit capture wraps the OAuth fetch so subscription quota headers
|
|
520
|
-
// (anthropic-ratelimit-unified-*) are recorded on every request —
|
|
521
|
-
// streaming and non-streaming alike.
|
|
522
|
-
fetch: wrapFetchWithLimitCapture(oauthFetch),
|
|
523
|
-
timeout: ANTHROPIC_CLIENT_TIMEOUT_MS,
|
|
524
|
-
// The SDK's built-in retry honors Retry-After hints without any
|
|
525
|
-
// upper bound (a 429 with retry-after: 8549 sleeps 2.4h per retry,
|
|
526
|
-
// invisible to fallback orchestration). Retries are the
|
|
527
|
-
// orchestrator's job; transient network blips are still retried by
|
|
528
|
-
// the fetch wrapper.
|
|
529
|
-
maxRetries: 0,
|
|
530
|
-
});
|
|
531
|
-
logger.debug("[AnthropicProvider] Anthropic SDK client created with OAuth fetch wrapper");
|
|
532
|
-
logger.debug("Anthropic Provider initialized with OAuth", {
|
|
533
|
-
modelName: this.modelName,
|
|
534
|
-
provider: this.providerName,
|
|
535
|
-
authMethod: this.authMethod,
|
|
536
|
-
subscriptionTier: this.subscriptionTier,
|
|
537
|
-
enableBetaFeatures: this.enableBetaFeatures,
|
|
538
|
-
hasRefreshToken: !!this.oauthToken.refreshToken,
|
|
539
|
-
tokenExpiry: this.oauthToken.expiresAt
|
|
540
|
-
? new Date(this.oauthToken.expiresAt).toISOString()
|
|
541
|
-
: "none",
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
else {
|
|
545
|
-
// Traditional API key authentication
|
|
546
|
-
const apiKeyToUse = credentials?.apiKey ?? config?.apiKey ?? getAnthropicApiKey();
|
|
547
|
-
// The official Anthropic SDK builds `${baseURL}/v1/messages` itself, so
|
|
548
|
-
// a version-suffixed base URL — the form the previous @ai-sdk/anthropic
|
|
549
|
-
// implementation REQUIRED (`https://api.anthropic.com/v1`) — would
|
|
550
|
-
// double up as `/v1/v1/messages`. Normalize the inverse way now: strip
|
|
551
|
-
// a trailing `/vN` segment when present so both historical forms of
|
|
552
|
-
// ANTHROPIC_BASE_URL keep working.
|
|
553
|
-
const normalizedBaseURL = (() => {
|
|
554
|
-
const raw = process.env.ANTHROPIC_BASE_URL;
|
|
555
|
-
if (!raw) {
|
|
556
|
-
return undefined;
|
|
557
|
-
}
|
|
558
|
-
const trimmed = raw.replace(/\/+$/, "");
|
|
559
|
-
const stripped = trimmed.replace(/\/v\d+$/, "");
|
|
560
|
-
if (stripped !== trimmed) {
|
|
561
|
-
logger.debug("[AnthropicProvider] Stripping the version suffix from " +
|
|
562
|
-
"ANTHROPIC_BASE_URL — the official Anthropic SDK appends /v1 " +
|
|
563
|
-
"to the base URL itself.", {
|
|
564
|
-
baseURL: redactUrlCredentials(raw),
|
|
565
|
-
rewrittenTo: redactUrlCredentials(stripped),
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
return stripped;
|
|
569
|
-
})();
|
|
570
|
-
client = new Anthropic({
|
|
571
|
-
apiKey: apiKeyToUse,
|
|
572
|
-
defaultHeaders: headers,
|
|
573
|
-
...(normalizedBaseURL && { baseURL: normalizedBaseURL }),
|
|
574
|
-
// Same capture as the OAuth branch: works for direct API-key traffic
|
|
575
|
-
// (legacy requests/tokens counters) and for the NeuroLink Claude proxy
|
|
576
|
-
// (verbatim unified quota plus x-neurolink-* account/pool state).
|
|
577
|
-
fetch: wrapFetchWithLimitCapture(createProxyFetch()),
|
|
578
|
-
timeout: ANTHROPIC_CLIENT_TIMEOUT_MS,
|
|
579
|
-
// See the OAuth-path client above: unbounded Retry-After sleeps in
|
|
580
|
-
// the SDK's retry loop must never stall fallback orchestration.
|
|
581
|
-
maxRetries: 0,
|
|
582
|
-
});
|
|
583
|
-
logger.debug("Anthropic Provider initialized with API key", {
|
|
584
|
-
modelName: this.modelName,
|
|
585
|
-
provider: this.providerName,
|
|
586
|
-
authMethod: this.authMethod,
|
|
587
|
-
subscriptionTier: this.subscriptionTier,
|
|
588
|
-
enableBetaFeatures: this.enableBetaFeatures,
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
this.client = client;
|
|
592
|
-
// Initialize usage tracking
|
|
593
|
-
this.usageInfo = {
|
|
594
|
-
messagesUsed: 0,
|
|
595
|
-
messagesRemaining: -1, // Unknown until we get rate limit headers
|
|
596
|
-
tokensUsed: 0,
|
|
597
|
-
tokensRemaining: -1,
|
|
598
|
-
inputTokensUsed: 0,
|
|
599
|
-
outputTokensUsed: 0,
|
|
600
|
-
lastRequestTimestamp: 0,
|
|
601
|
-
isRateLimited: false,
|
|
602
|
-
requestCount: 0,
|
|
603
|
-
messageQuotaPercent: 0,
|
|
604
|
-
tokenQuotaPercent: 0,
|
|
605
|
-
};
|
|
606
|
-
logger.debug("Anthropic Provider v2 initialized", {
|
|
607
|
-
modelName: this.modelName,
|
|
608
|
-
provider: this.providerName,
|
|
609
|
-
authMethod: this.authMethod,
|
|
610
|
-
subscriptionTier: this.subscriptionTier,
|
|
611
|
-
enableBetaFeatures: this.enableBetaFeatures,
|
|
612
|
-
betaFeatures: this.enableBetaFeatures
|
|
613
|
-
? ANTHROPIC_BETA_HEADERS["anthropic-beta"]
|
|
614
|
-
: "disabled",
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Get authentication headers based on current auth method and configuration.
|
|
619
|
-
*
|
|
620
|
-
* @returns Headers object containing auth and beta feature headers
|
|
621
|
-
*/
|
|
622
|
-
getAuthHeaders() {
|
|
623
|
-
const headers = {};
|
|
624
|
-
// When routing through proxy (ANTHROPIC_BASE_URL set), use the full
|
|
625
|
-
// OAuth beta set so the proxy forwards them upstream. Without these,
|
|
626
|
-
// Anthropic treats the request with tighter non-subscription rate limits.
|
|
627
|
-
const usingProxy = !!process.env.ANTHROPIC_BASE_URL;
|
|
628
|
-
if (this.enableBetaFeatures) {
|
|
629
|
-
if (usingProxy) {
|
|
630
|
-
// The 1M-context beta requires a plan upgrade on most accounts;
|
|
631
|
-
// surfacing it by default forces a "The long context beta is not
|
|
632
|
-
// yet available for this subscription." failure for everyone else.
|
|
633
|
-
// Gate behind ANTHROPIC_ENABLE_LONG_CONTEXT_BETA=1 so default-tier
|
|
634
|
-
// accounts (and CI) can use the proxy without the gated feature.
|
|
635
|
-
const longContextOptIn = process.env.ANTHROPIC_ENABLE_LONG_CONTEXT_BETA === "1" ||
|
|
636
|
-
process.env.ANTHROPIC_ENABLE_LONG_CONTEXT_BETA === "true";
|
|
637
|
-
const betas = [
|
|
638
|
-
...CLAUDE_CODE_OAUTH_BETAS,
|
|
639
|
-
"fine-grained-tool-streaming-2025-05-14",
|
|
640
|
-
"interleaved-thinking-2025-05-14",
|
|
641
|
-
"redact-thinking-2026-02-12",
|
|
642
|
-
];
|
|
643
|
-
if (longContextOptIn) {
|
|
644
|
-
betas.push("context-1m-2025-08-07");
|
|
645
|
-
}
|
|
646
|
-
headers["anthropic-beta"] = betas.join(",");
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
headers["anthropic-beta"] = ANTHROPIC_BETA_HEADERS["anthropic-beta"];
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
if (usingProxy) {
|
|
653
|
-
// WAFs in front of ANTHROPIC_BASE_URL proxies commonly block the bare
|
|
654
|
-
// SDK UA ("Anthropic/JS x.y.z"); send the claude-cli UA the OAuth path
|
|
655
|
-
// already uses. Direct-to-Anthropic traffic keeps the honest SDK UA.
|
|
656
|
-
headers["User-Agent"] = CLAUDE_CLI_USER_AGENT;
|
|
657
|
-
}
|
|
658
|
-
// Add subscription-specific headers if applicable
|
|
659
|
-
if (this.subscriptionTier !== "api") {
|
|
660
|
-
headers["x-subscription-tier"] = this.subscriptionTier;
|
|
661
|
-
}
|
|
662
|
-
return headers;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* Validate if a model is accessible with the current subscription tier.
|
|
666
|
-
*
|
|
667
|
-
* @param model - The model ID to validate
|
|
668
|
-
* @returns true if the model is accessible, false otherwise
|
|
669
|
-
*
|
|
670
|
-
* @example
|
|
671
|
-
* ```typescript
|
|
672
|
-
* const provider = new AnthropicProvider();
|
|
673
|
-
* if (provider.validateModelAccess("claude-opus-4-5-20251101")) {
|
|
674
|
-
* // Use the model
|
|
675
|
-
* } else {
|
|
676
|
-
* // Fall back to a different model or show upgrade prompt
|
|
677
|
-
* }
|
|
678
|
-
* ```
|
|
679
|
-
*/
|
|
680
|
-
validateModelAccess(model) {
|
|
681
|
-
// Proxy mode: bypass tier validation entirely — the proxy handles model
|
|
682
|
-
// access. Log at debug level so users can tell why an unknown model name
|
|
683
|
-
// "validated" when their proxy may not actually expose it.
|
|
684
|
-
if (process.env.ANTHROPIC_BASE_URL) {
|
|
685
|
-
logger.debug("[validateModelAccess] Bypassing tier check (ANTHROPIC_BASE_URL set — proxy enforces access)", { model });
|
|
686
|
-
return true;
|
|
687
|
-
}
|
|
688
|
-
// API tier has access to all models
|
|
689
|
-
if (this.subscriptionTier === "api") {
|
|
690
|
-
return true;
|
|
691
|
-
}
|
|
692
|
-
const hasAccess = isModelAvailableForTier(model, this.subscriptionTier);
|
|
693
|
-
if (!hasAccess) {
|
|
694
|
-
logger.debug("[validateModelAccess] Model not available for tier", {
|
|
695
|
-
model,
|
|
696
|
-
tier: this.subscriptionTier,
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
return hasAccess;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Get current usage information.
|
|
703
|
-
*
|
|
704
|
-
* Returns usage tracking data including messages sent, tokens consumed,
|
|
705
|
-
* and remaining quotas. This information is updated after each API request.
|
|
706
|
-
*
|
|
707
|
-
* @returns Current usage info or null if no requests have been made
|
|
708
|
-
*
|
|
709
|
-
* @example
|
|
710
|
-
* ```typescript
|
|
711
|
-
* const usage = provider.getUsageInfo();
|
|
712
|
-
* if (usage && usage.tokenQuotaPercent > 80) {
|
|
713
|
-
* console.warn("Approaching token quota limit");
|
|
714
|
-
* }
|
|
715
|
-
* ```
|
|
716
|
-
*/
|
|
717
|
-
getUsageInfo() {
|
|
718
|
-
return this.usageInfo;
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* Check if beta features are enabled for this provider instance.
|
|
722
|
-
*
|
|
723
|
-
* @returns true if beta features are enabled
|
|
724
|
-
*/
|
|
725
|
-
areBetaFeaturesEnabled() {
|
|
726
|
-
return this.enableBetaFeatures;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Get model capabilities for the current model.
|
|
730
|
-
*
|
|
731
|
-
* @returns The model capabilities or undefined if not found
|
|
732
|
-
*/
|
|
733
|
-
getModelCapabilities() {
|
|
734
|
-
return getModelCapabilities(this.modelName || this.getDefaultModel());
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Get the current subscription tier.
|
|
738
|
-
* @returns The detected or configured subscription tier
|
|
739
|
-
*/
|
|
740
|
-
getSubscriptionTier() {
|
|
741
|
-
return this.subscriptionTier;
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* Get the authentication method being used.
|
|
745
|
-
* @returns The current authentication method
|
|
746
|
-
*/
|
|
747
|
-
getAuthMethod() {
|
|
748
|
-
return this.authMethod;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Refresh OAuth token if needed and possible.
|
|
752
|
-
* This method checks if the token is expired or about to expire,
|
|
753
|
-
* and attempts to refresh it using the refresh token if available.
|
|
754
|
-
*
|
|
755
|
-
* @returns Promise that resolves when refresh is complete (or not needed)
|
|
756
|
-
* @throws Error if refresh is needed but fails
|
|
757
|
-
*/
|
|
758
|
-
async refreshAuthIfNeeded() {
|
|
759
|
-
// Only applicable for OAuth authentication
|
|
760
|
-
if (this.authMethod !== "oauth" || !this.oauthToken) {
|
|
761
|
-
logger.debug("Token refresh not applicable for API key authentication");
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
// Check if token has expiry information
|
|
765
|
-
if (!this.oauthToken.expiresAt) {
|
|
766
|
-
logger.debug("Token has no expiry information, assuming valid");
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
// expiresAt is stored as Unix milliseconds (matching how auth status/refresh stores it).
|
|
770
|
-
// Compare against Date.now() so both sides are in milliseconds.
|
|
771
|
-
const now = Date.now();
|
|
772
|
-
const isExpired = this.oauthToken.expiresAt <= now;
|
|
773
|
-
const isExpiringSoon = this.oauthToken.expiresAt <= now + TOKEN_EXPIRY_BUFFER_MS;
|
|
774
|
-
if (!isExpired && !isExpiringSoon) {
|
|
775
|
-
logger.debug("OAuth token is still valid", {
|
|
776
|
-
expiresInMs: this.oauthToken.expiresAt - now,
|
|
777
|
-
});
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
// Check if we have a refresh token
|
|
781
|
-
if (!this.oauthToken.refreshToken) {
|
|
782
|
-
if (isExpired) {
|
|
783
|
-
throw new AuthenticationError("OAuth token expired and no refresh token available. Please re-authenticate.", this.providerName);
|
|
784
|
-
}
|
|
785
|
-
logger.warn("OAuth token expiring soon but no refresh token available", {
|
|
786
|
-
expiresInMs: this.oauthToken.expiresAt - now,
|
|
787
|
-
});
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
// Serialize concurrent refresh attempts — if a refresh is already in flight,
|
|
791
|
-
// wait for it rather than issuing a duplicate request.
|
|
792
|
-
if (this.refreshPromise) {
|
|
793
|
-
await this.refreshPromise;
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
// Attempt to refresh the token using the correct Anthropic token endpoint.
|
|
797
|
-
logger.info("Refreshing OAuth token", {
|
|
798
|
-
isExpired,
|
|
799
|
-
expiresInMs: this.oauthToken.expiresAt - now,
|
|
800
|
-
});
|
|
801
|
-
// Capture the token reference before entering the async IIFE;
|
|
802
|
-
// the enclosing guards already verified both fields are non-null.
|
|
803
|
-
const tokenRef = this.oauthToken;
|
|
804
|
-
const refreshToken = tokenRef.refreshToken;
|
|
805
|
-
this.refreshPromise = (async () => {
|
|
806
|
-
const REFRESH_TIMEOUT_MS = 30_000;
|
|
807
|
-
const controller = new AbortController();
|
|
808
|
-
const timeoutId = setTimeout(() => controller.abort(), REFRESH_TIMEOUT_MS);
|
|
809
|
-
// User-Agent is set to CLAUDE_CLI_USER_AGENT so the refresh request
|
|
810
|
-
// matches what the official Claude CLI / CLIProxyAPI sends. Anthropic
|
|
811
|
-
// gates parts of the OAuth flow on this UA (the same `client_id` is
|
|
812
|
-
// rejected by `ANTHROPIC_TOKEN_URL` if the UA looks like a generic
|
|
813
|
-
// SDK), so this is required for OAuth refresh to succeed — not a
|
|
814
|
-
// cosmetic choice. If Anthropic ever publishes a separate UA for
|
|
815
|
-
// third-party OAuth clients, switch to that. See `auth/anthropicOAuth.ts`
|
|
816
|
-
// for the source of `CLAUDE_CLI_USER_AGENT` / `CLAUDE_CODE_CLIENT_ID`.
|
|
817
|
-
const response = await fetch(ANTHROPIC_TOKEN_URL, {
|
|
818
|
-
method: "POST",
|
|
819
|
-
headers: {
|
|
820
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
821
|
-
"User-Agent": CLAUDE_CLI_USER_AGENT,
|
|
822
|
-
},
|
|
823
|
-
body: new URLSearchParams({
|
|
824
|
-
grant_type: "refresh_token",
|
|
825
|
-
refresh_token: refreshToken,
|
|
826
|
-
client_id: CLAUDE_CODE_CLIENT_ID,
|
|
827
|
-
}),
|
|
828
|
-
signal: controller.signal,
|
|
829
|
-
});
|
|
830
|
-
clearTimeout(timeoutId);
|
|
831
|
-
if (!response.ok) {
|
|
832
|
-
const errorText = await response.text();
|
|
833
|
-
throw new AuthenticationError(`Failed to refresh OAuth token: ${response.status} ${errorText}`, this.providerName);
|
|
834
|
-
}
|
|
835
|
-
const newToken = (await response.json());
|
|
836
|
-
// Mutate the existing oauthToken object in-place so that the fetch wrapper
|
|
837
|
-
// closure (which captured the object reference, not a copy) picks up the
|
|
838
|
-
// new accessToken automatically on the next request.
|
|
839
|
-
// Store expiresAt as milliseconds to match the format used by auth status/refresh.
|
|
840
|
-
tokenRef.accessToken = newToken.access_token;
|
|
841
|
-
tokenRef.refreshToken = newToken.refresh_token || tokenRef.refreshToken;
|
|
842
|
-
tokenRef.expiresAt = newToken.expires_in
|
|
843
|
-
? Date.now() + newToken.expires_in * 1000
|
|
844
|
-
: undefined;
|
|
845
|
-
tokenRef.tokenType = newToken.token_type || "Bearer";
|
|
846
|
-
const updatedToken = tokenRef;
|
|
847
|
-
// Persist the refreshed token to disk atomically (tmp + rename) so
|
|
848
|
-
// subsequent provider instances and the CLI pick up the new credentials.
|
|
849
|
-
try {
|
|
850
|
-
const credentialsDir = join(homedir(), ".neurolink");
|
|
851
|
-
if (!existsSync(credentialsDir)) {
|
|
852
|
-
mkdirSync(credentialsDir, { recursive: true });
|
|
853
|
-
}
|
|
854
|
-
const credentialsPath = join(credentialsDir, "anthropic-credentials.json");
|
|
855
|
-
const tmpPath = `${credentialsPath}.tmp`;
|
|
856
|
-
const existingRaw = existsSync(credentialsPath)
|
|
857
|
-
? JSON.parse(readFileSync(credentialsPath, "utf-8"))
|
|
858
|
-
: {};
|
|
859
|
-
const updated = {
|
|
860
|
-
...existingRaw,
|
|
861
|
-
type: "oauth",
|
|
862
|
-
oauth: updatedToken,
|
|
863
|
-
updatedAt: Date.now(),
|
|
864
|
-
};
|
|
865
|
-
writeFileSync(tmpPath, JSON.stringify(updated, null, 2), {
|
|
866
|
-
mode: 0o600,
|
|
867
|
-
});
|
|
868
|
-
renameSync(tmpPath, credentialsPath);
|
|
869
|
-
logger.debug("Refreshed OAuth credentials persisted to disk");
|
|
870
|
-
}
|
|
871
|
-
catch (persistError) {
|
|
872
|
-
// Non-fatal: in-memory token is already updated; next CLI start will
|
|
873
|
-
// need a manual refresh but the current session will work.
|
|
874
|
-
logger.warn("Failed to persist refreshed OAuth token to disk", {
|
|
875
|
-
error: persistError instanceof Error
|
|
876
|
-
? persistError.message
|
|
877
|
-
: String(persistError),
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
logger.info("OAuth token refreshed successfully", {
|
|
881
|
-
hasNewRefreshToken: !!newToken.refresh_token,
|
|
882
|
-
expiresIn: newToken.expires_in,
|
|
883
|
-
});
|
|
884
|
-
})();
|
|
885
|
-
try {
|
|
886
|
-
await this.refreshPromise;
|
|
887
|
-
}
|
|
888
|
-
catch (error) {
|
|
889
|
-
if (error instanceof AuthenticationError) {
|
|
890
|
-
throw error;
|
|
891
|
-
}
|
|
892
|
-
throw new AuthenticationError(`Failed to refresh OAuth token: ${error instanceof Error ? error.message : String(error)}`, this.providerName);
|
|
893
|
-
}
|
|
894
|
-
finally {
|
|
895
|
-
this.refreshPromise = undefined;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Get the last response metadata including rate limit information.
|
|
900
|
-
* @returns The last response metadata or null if no request has been made
|
|
901
|
-
*/
|
|
902
|
-
getLastResponseMetadata() {
|
|
903
|
-
return this.lastResponseMetadata;
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Update response metadata from a captured limit snapshot.
|
|
907
|
-
*
|
|
908
|
-
* Takes already-parsed rate-limit info rather than raw headers: parsing now
|
|
909
|
-
* lives in `rateLimitCapture`, which is the only layer that sees the raw
|
|
910
|
-
* response and understands both header families (unified subscription
|
|
911
|
-
* windows and legacy per-tier counters).
|
|
912
|
-
*
|
|
913
|
-
* @param rateLimit - Parsed rate-limit figures
|
|
914
|
-
* @param requestId - Optional Anthropic request ID
|
|
915
|
-
* @param usageUpdate - Optional token counts to fold into usage tracking
|
|
916
|
-
*/
|
|
917
|
-
updateResponseMetadata(rateLimit, requestId, usageUpdate) {
|
|
918
|
-
this.lastResponseMetadata = {
|
|
919
|
-
rateLimit,
|
|
920
|
-
...(requestId ? { requestId } : {}),
|
|
921
|
-
};
|
|
922
|
-
if (this.usageInfo) {
|
|
923
|
-
this.usageInfo.requestCount++;
|
|
924
|
-
this.usageInfo.messagesUsed++;
|
|
925
|
-
this.usageInfo.lastRequestTimestamp = Date.now();
|
|
926
|
-
// Update token usage if provided
|
|
927
|
-
if (usageUpdate) {
|
|
928
|
-
if (usageUpdate.inputTokens !== undefined) {
|
|
929
|
-
this.usageInfo.inputTokensUsed += usageUpdate.inputTokens;
|
|
930
|
-
this.usageInfo.tokensUsed += usageUpdate.inputTokens;
|
|
931
|
-
}
|
|
932
|
-
if (usageUpdate.outputTokens !== undefined) {
|
|
933
|
-
this.usageInfo.outputTokensUsed += usageUpdate.outputTokens;
|
|
934
|
-
this.usageInfo.tokensUsed += usageUpdate.outputTokens;
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
// Update remaining quotas from rate limit headers
|
|
938
|
-
if (rateLimit?.requestsRemaining !== undefined) {
|
|
939
|
-
this.usageInfo.messagesRemaining = rateLimit.requestsRemaining;
|
|
940
|
-
}
|
|
941
|
-
if (rateLimit?.tokensRemaining !== undefined) {
|
|
942
|
-
this.usageInfo.tokensRemaining = rateLimit.tokensRemaining;
|
|
943
|
-
}
|
|
944
|
-
// Calculate quota percentages
|
|
945
|
-
if (rateLimit?.requestsLimit && rateLimit.requestsLimit > 0) {
|
|
946
|
-
this.usageInfo.messageQuotaPercent = Math.round(((rateLimit.requestsLimit - (rateLimit.requestsRemaining ?? 0)) /
|
|
947
|
-
rateLimit.requestsLimit) *
|
|
948
|
-
100);
|
|
949
|
-
}
|
|
950
|
-
if (rateLimit?.tokensLimit && rateLimit.tokensLimit > 0) {
|
|
951
|
-
this.usageInfo.tokenQuotaPercent = Math.round(((rateLimit.tokensLimit - (rateLimit.tokensRemaining ?? 0)) /
|
|
952
|
-
rateLimit.tokensLimit) *
|
|
953
|
-
100);
|
|
954
|
-
}
|
|
955
|
-
// Check for rate limiting
|
|
956
|
-
if (rateLimit?.retryAfter !== undefined) {
|
|
957
|
-
this.usageInfo.isRateLimited = true;
|
|
958
|
-
this.usageInfo.rateLimitExpiresAt =
|
|
959
|
-
Date.now() + rateLimit.retryAfter * 1000;
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
this.usageInfo.isRateLimited = false;
|
|
963
|
-
this.usageInfo.rateLimitExpiresAt = undefined;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
// Log rate limit warnings if approaching limits
|
|
967
|
-
if (rateLimit?.requestsRemaining !== undefined) {
|
|
968
|
-
if (rateLimit.requestsRemaining <= 5) {
|
|
969
|
-
logger.warn("Approaching Anthropic request rate limit", {
|
|
970
|
-
remaining: rateLimit.requestsRemaining,
|
|
971
|
-
limit: rateLimit.requestsLimit,
|
|
972
|
-
reset: rateLimit.requestsReset,
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
if (rateLimit?.tokensRemaining !== undefined) {
|
|
977
|
-
if (rateLimit.tokensLimit &&
|
|
978
|
-
rateLimit.tokensRemaining < rateLimit.tokensLimit * 0.1) {
|
|
979
|
-
logger.warn("Approaching Anthropic token rate limit", {
|
|
980
|
-
remaining: rateLimit.tokensRemaining,
|
|
981
|
-
limit: rateLimit.tokensLimit,
|
|
982
|
-
reset: rateLimit.tokensReset,
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
getProviderName() {
|
|
988
|
-
return "anthropic";
|
|
989
|
-
}
|
|
990
|
-
getDefaultModel() {
|
|
991
|
-
return getDefaultAnthropicModel();
|
|
992
|
-
}
|
|
993
|
-
/**
|
|
994
|
-
* Returns a V3-shaped delegating model whose `doGenerate` drives the
|
|
995
|
-
* official Anthropic Messages API directly. BaseProvider's `generate()`
|
|
996
|
-
* path (and its middleware wrapping) keeps working unchanged; the
|
|
997
|
-
* streaming path bypasses this entirely via `executeStream`.
|
|
998
|
-
*/
|
|
999
|
-
getAISDKModel() {
|
|
1000
|
-
const client = this.client;
|
|
1001
|
-
const providerName = this.providerName;
|
|
1002
|
-
const modelId = this.modelName || getDefaultAnthropicModel();
|
|
1003
|
-
const getTimeoutForOptions = (opts) => this.getTimeout((opts ?? {}));
|
|
1004
|
-
const refreshAuth = () => this.refreshAuthIfNeeded();
|
|
1005
|
-
// Structural AI-SDK model shape (`SageMakerAsLanguageModel`, the
|
|
1006
|
-
// sanctioned intermediate from src/lib/types/providers.ts): assigning the
|
|
1007
|
-
// literal to it keeps the compiler's member checks, and the intermediate
|
|
1008
|
-
// is single-assertable to the ai-package `LanguageModel` handle.
|
|
1009
|
-
const delegatingModel = {
|
|
1010
|
-
specificationVersion: "v3",
|
|
1011
|
-
provider: providerName,
|
|
1012
|
-
modelId,
|
|
1013
|
-
supportedUrls: {},
|
|
1014
|
-
doGenerate: async (options) => {
|
|
1015
|
-
await refreshAuth();
|
|
1016
|
-
const built = messagesToAnthropic(options.prompt);
|
|
1017
|
-
const messages = built.messages;
|
|
1018
|
-
// `let`: the additive structured-output path below appends the
|
|
1019
|
-
// final_result instruction to the system prompt.
|
|
1020
|
-
let system = built.system;
|
|
1021
|
-
let tools = (options.tools ?? [])
|
|
1022
|
-
.filter((t) => t.type === "function")
|
|
1023
|
-
.map((t) => {
|
|
1024
|
-
// GenerationHandler marks the last tool definition with a cache
|
|
1025
|
-
// breakpoint when prompt caching is active — keep honoring it.
|
|
1026
|
-
const cc = cacheControlOf(t);
|
|
1027
|
-
return {
|
|
1028
|
-
name: t.name,
|
|
1029
|
-
...(t.description ? { description: t.description } : {}),
|
|
1030
|
-
input_schema: (t.inputSchema ?? {
|
|
1031
|
-
type: "object",
|
|
1032
|
-
properties: {},
|
|
1033
|
-
}),
|
|
1034
|
-
...(cc ? { cache_control: cc } : {}),
|
|
1035
|
-
};
|
|
1036
|
-
});
|
|
1037
|
-
if (tools && tools.length === 0) {
|
|
1038
|
-
tools = undefined;
|
|
1039
|
-
}
|
|
1040
|
-
let toolChoice = options.toolChoice
|
|
1041
|
-
? toolChoiceToAnthropic(options.toolChoice.type === "tool"
|
|
1042
|
-
? { type: "tool", toolName: options.toolChoice.toolName }
|
|
1043
|
-
: options.toolChoice.type)
|
|
1044
|
-
: undefined;
|
|
1045
|
-
// JSON/structured output: Anthropic has no response_format — emulate
|
|
1046
|
-
// with a forced synthetic tool whose input IS the JSON payload (the
|
|
1047
|
-
// same object-tool strategy @ai-sdk/anthropic used).
|
|
1048
|
-
let jsonTool;
|
|
1049
|
-
if (options.responseFormat?.type === "json") {
|
|
1050
|
-
jsonTool = options.responseFormat.name ?? "json";
|
|
1051
|
-
const schema = (options.responseFormat.schema ?? {
|
|
1052
|
-
type: "object",
|
|
1053
|
-
});
|
|
1054
|
-
tools = [
|
|
1055
|
-
{
|
|
1056
|
-
name: jsonTool,
|
|
1057
|
-
description: options.responseFormat.description ??
|
|
1058
|
-
"Respond by calling this tool with the answer as its input.",
|
|
1059
|
-
input_schema: schema,
|
|
1060
|
-
},
|
|
1061
|
-
];
|
|
1062
|
-
toolChoice = { type: "tool", name: jsonTool };
|
|
1063
|
-
}
|
|
1064
|
-
// Additive structured output: when the caller wants a schema AND real
|
|
1065
|
-
// tools, the forced-json path above cannot be used (it replaces the
|
|
1066
|
-
// tools array), and the AI-SDK experimental_output path is excluded
|
|
1067
|
-
// for this surface by structuredOutputPolicy. GenerationHandler hands
|
|
1068
|
-
// the JSON Schema down here instead, and we APPEND a `final_result`
|
|
1069
|
-
// tool — tool_choice stays auto, so every real tool keeps working and
|
|
1070
|
-
// the model self-selects final_result when it is ready to answer.
|
|
1071
|
-
const finalResultSchema = options.providerOptions?.anthropic
|
|
1072
|
-
?.finalResultSchema;
|
|
1073
|
-
let finalResultActive = false;
|
|
1074
|
-
if (!jsonTool && finalResultSchema) {
|
|
1075
|
-
const appended = appendFinalResultTool(tools, finalResultSchema);
|
|
1076
|
-
tools = appended.tools;
|
|
1077
|
-
finalResultActive = appended.applied;
|
|
1078
|
-
if (appended.applied) {
|
|
1079
|
-
system = appendFinalResultInstruction(system);
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
// Extended thinking passthrough (providerOptions.anthropic.thinking).
|
|
1083
|
-
const thinking = options.providerOptions?.anthropic?.thinking;
|
|
1084
|
-
// Prompt-cache parity with the native Vertex+Claude path: upstream
|
|
1085
|
-
// layers mark only the stable prefix (system via MessageBuilder,
|
|
1086
|
-
// last tool via GenerationHandler) — the growing conversation
|
|
1087
|
-
// history has no breakpoint, so on every turn it falls after the
|
|
1088
|
-
// last marker and is re-billed as fresh input. Add rolling history
|
|
1089
|
-
// breakpoints in whatever budget remains under Anthropic's
|
|
1090
|
-
// four-marker ceiling; pre-existing markers are counted so the
|
|
1091
|
-
// request can never exceed the cap.
|
|
1092
|
-
const cacheMarkersUsed = countAnthropicCacheMarkers({
|
|
1093
|
-
system,
|
|
1094
|
-
tools,
|
|
1095
|
-
messages: messages,
|
|
1096
|
-
});
|
|
1097
|
-
const cachedMessages = applyAnthropicHistoryCacheBreakpoints(messages, ANTHROPIC_MAX_CACHE_BREAKPOINTS - cacheMarkersUsed);
|
|
1098
|
-
// Registry-driven strip: Sonnet 5 / Opus 4.7+ / Fable 5 families
|
|
1099
|
-
// reject sampling params (also covers the retry paths — this params
|
|
1100
|
-
// object is what any rebuild spreads).
|
|
1101
|
-
const samplingParams = resolveSamplingParams("anthropic", modelId, {
|
|
1102
|
-
...(options.temperature !== undefined &&
|
|
1103
|
-
options.temperature !== null
|
|
1104
|
-
? { temperature: options.temperature }
|
|
1105
|
-
: {}),
|
|
1106
|
-
...(options.topP !== undefined && options.topP !== null
|
|
1107
|
-
? { topP: options.topP }
|
|
1108
|
-
: {}),
|
|
1109
|
-
}, "anthropic.doGenerate");
|
|
1110
|
-
const params = {
|
|
1111
|
-
model: modelId,
|
|
1112
|
-
messages: cachedMessages,
|
|
1113
|
-
max_tokens: resolveClaudeMaxTokens(modelId, options.maxOutputTokens),
|
|
1114
|
-
...(system ? { system } : {}),
|
|
1115
|
-
...(samplingParams.temperature !== undefined
|
|
1116
|
-
? { temperature: samplingParams.temperature }
|
|
1117
|
-
: {}),
|
|
1118
|
-
...(samplingParams.topP !== undefined
|
|
1119
|
-
? { top_p: samplingParams.topP }
|
|
1120
|
-
: {}),
|
|
1121
|
-
...(options.stopSequences && options.stopSequences.length > 0
|
|
1122
|
-
? { stop_sequences: options.stopSequences }
|
|
1123
|
-
: {}),
|
|
1124
|
-
...(tools ? { tools } : {}),
|
|
1125
|
-
...(toolChoice ? { tool_choice: toolChoice } : {}),
|
|
1126
|
-
...(thinking ? { thinking } : {}),
|
|
1127
|
-
};
|
|
1128
|
-
// The 60s anthropic generate default was tuned for the old ~4096
|
|
1129
|
-
// max_tokens. Now that the default ceiling is the model's real max,
|
|
1130
|
-
// a large structured response needs more wall-clock to be produced —
|
|
1131
|
-
// otherwise the inner controller aborts mid-generation (the AI-SDK
|
|
1132
|
-
// doGenerate layer doesn't see the caller's `timeout`). Raise the
|
|
1133
|
-
// floor to 5 min when a large output budget is in play — but only
|
|
1134
|
-
// when the caller did NOT set an explicit timeout: an explicit value
|
|
1135
|
-
// is a contract and must never be silently extended. The abort
|
|
1136
|
-
// signal stays the real bound.
|
|
1137
|
-
const callerTimeout = options
|
|
1138
|
-
.timeout;
|
|
1139
|
-
const callerSpecifiedTimeout = callerTimeout !== undefined && callerTimeout !== null;
|
|
1140
|
-
const generateTimeoutMs = params.max_tokens > 8192 && !callerSpecifiedTimeout
|
|
1141
|
-
? Math.max(getTimeoutForOptions(options), 300_000)
|
|
1142
|
-
: getTimeoutForOptions(options);
|
|
1143
|
-
const timeoutController = createTimeoutController(generateTimeoutMs, providerName, "generate");
|
|
1144
|
-
let response;
|
|
1145
|
-
try {
|
|
1146
|
-
response = await client.messages.create(params, {
|
|
1147
|
-
signal: composeAbortSignals(options.abortSignal, timeoutController?.controller.signal),
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
finally {
|
|
1151
|
-
timeoutController?.cleanup();
|
|
1152
|
-
}
|
|
1153
|
-
const content = [];
|
|
1154
|
-
let finalResultText;
|
|
1155
|
-
// Text emitted in forced-json mode, kept only as a fallback (see below).
|
|
1156
|
-
const jsonModeText = [];
|
|
1157
|
-
let jsonToolAnswered = false;
|
|
1158
|
-
for (const block of response.content) {
|
|
1159
|
-
if (block.type === "thinking") {
|
|
1160
|
-
content.push({ type: "reasoning", text: block.thinking });
|
|
1161
|
-
}
|
|
1162
|
-
else if (block.type === "text") {
|
|
1163
|
-
// In forced-json mode the payload arrives via the tool input, not
|
|
1164
|
-
// text — pass text through only in normal mode.
|
|
1165
|
-
if (jsonTool) {
|
|
1166
|
-
jsonModeText.push(block.text);
|
|
1167
|
-
}
|
|
1168
|
-
else {
|
|
1169
|
-
content.push({ type: "text", text: block.text });
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
else if (block.type === "tool_use") {
|
|
1173
|
-
if (jsonTool && block.name === jsonTool) {
|
|
1174
|
-
// Unwrap the synthetic tool call back into text JSON.
|
|
1175
|
-
jsonToolAnswered = true;
|
|
1176
|
-
content.push({
|
|
1177
|
-
type: "text",
|
|
1178
|
-
text: stringifyToolInput(block.input),
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
else if (finalResultActive &&
|
|
1182
|
-
block.name === FINAL_RESULT_TOOL_NAME) {
|
|
1183
|
-
// Internal pattern: never surfaced as a tool call. Its arguments
|
|
1184
|
-
// ARE the structured answer.
|
|
1185
|
-
finalResultText = stringifyToolInput(block.input);
|
|
1186
|
-
}
|
|
1187
|
-
else {
|
|
1188
|
-
content.push({
|
|
1189
|
-
type: "tool-call",
|
|
1190
|
-
toolCallId: block.id,
|
|
1191
|
-
toolName: block.name,
|
|
1192
|
-
input: stringifyToolInput(block.input),
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
// Forced-json mode normally drops text blocks because the payload rides
|
|
1198
|
-
// in the synthetic tool's input. But when the response is cut short
|
|
1199
|
-
// (stop_reason "max_tokens") the tool call can be missing entirely, and
|
|
1200
|
-
// dropping the text would leave an EMPTY completion with nothing for
|
|
1201
|
-
// coerceJsonToSchema to recover. Fall back to the text so a partial
|
|
1202
|
-
// object can still be salvaged and flagged truncated.
|
|
1203
|
-
if (jsonTool && !jsonToolAnswered && jsonModeText.length > 0) {
|
|
1204
|
-
content.push({ type: "text", text: jsonModeText.join("") });
|
|
1205
|
-
}
|
|
1206
|
-
// final_result is terminal — parity with the native Claude-on-Vertex
|
|
1207
|
-
// and Gemini loops, which break out of the tool loop the moment it
|
|
1208
|
-
// arrives. Reasoning blocks are kept; any prose preamble and any tool
|
|
1209
|
-
// calls issued alongside it are dropped so `text` is exactly the
|
|
1210
|
-
// structured payload and the AI-SDK loop stops here.
|
|
1211
|
-
if (finalResultText !== undefined) {
|
|
1212
|
-
const reasoning = content.filter((part) => part.type === "reasoning");
|
|
1213
|
-
content.length = 0;
|
|
1214
|
-
content.push(...reasoning, { type: "text", text: finalResultText });
|
|
1215
|
-
logger.debug("[Anthropic] Extracted structured output from final_result tool (generate)", { chars: finalResultText.length });
|
|
1216
|
-
}
|
|
1217
|
-
const cacheRead = response.usage.cache_read_input_tokens ?? 0;
|
|
1218
|
-
const cacheWrite = response.usage.cache_creation_input_tokens ?? 0;
|
|
1219
|
-
return {
|
|
1220
|
-
content,
|
|
1221
|
-
finishReason: {
|
|
1222
|
-
// A final_result call ends the turn: the provider reports
|
|
1223
|
-
// stop_reason "tool_use", but no tool call is surfaced, so
|
|
1224
|
-
// reporting "tool-calls" would misread as a step-capped turn.
|
|
1225
|
-
// `raw` still carries the provider's verbatim stop_reason.
|
|
1226
|
-
unified: finalResultText !== undefined
|
|
1227
|
-
? "stop"
|
|
1228
|
-
: mapAnthropicStopReason(response.stop_reason),
|
|
1229
|
-
raw: response.stop_reason ?? "stop",
|
|
1230
|
-
},
|
|
1231
|
-
usage: {
|
|
1232
|
-
inputTokens: {
|
|
1233
|
-
total: response.usage.input_tokens + cacheRead + cacheWrite,
|
|
1234
|
-
noCache: response.usage.input_tokens,
|
|
1235
|
-
cacheRead,
|
|
1236
|
-
cacheWrite,
|
|
1237
|
-
},
|
|
1238
|
-
outputTokens: {
|
|
1239
|
-
total: response.usage.output_tokens,
|
|
1240
|
-
text: response.usage.output_tokens,
|
|
1241
|
-
reasoning: undefined,
|
|
1242
|
-
},
|
|
1243
|
-
},
|
|
1244
|
-
warnings: [],
|
|
1245
|
-
request: { body: params },
|
|
1246
|
-
response: {
|
|
1247
|
-
id: response.id,
|
|
1248
|
-
modelId: response.model,
|
|
1249
|
-
// Real response headers, captured by the fetch wrapper. This used
|
|
1250
|
-
// to be a hardcoded `{}`, which silently discarded every
|
|
1251
|
-
// rate-limit and quota header Anthropic returns.
|
|
1252
|
-
headers: getCapturedResponseHeaders() ?? {},
|
|
1253
|
-
body: response,
|
|
1254
|
-
},
|
|
1255
|
-
};
|
|
1256
|
-
},
|
|
1257
|
-
doStream: () => {
|
|
1258
|
-
throw new Error(`${providerName}: doStream is not implemented on the delegating model — the streaming path uses executeStream directly.`);
|
|
1259
|
-
},
|
|
1260
|
-
};
|
|
1261
|
-
return delegatingModel;
|
|
1262
|
-
}
|
|
1263
|
-
formatProviderError(error) {
|
|
1264
|
-
const rules = [
|
|
1265
|
-
{
|
|
1266
|
-
// Plan 02's mocked-contract work documented a pre-existing gap: the
|
|
1267
|
-
// Anthropic SDK formats auth failures as a bare "401 <msg>" string,
|
|
1268
|
-
// which the message-text regex alone does not catch — mirrors
|
|
1269
|
-
// Vertex's statusCode === 401 fallback in this same task.
|
|
1270
|
-
match: (ctx) => ctx.statusCode === 401 ||
|
|
1271
|
-
/API_KEY_INVALID|Invalid API key/i.test(ctx.message),
|
|
1272
|
-
errorClass: AuthenticationError,
|
|
1273
|
-
message: "Invalid Anthropic API key. Please check your ANTHROPIC_API_KEY environment variable.",
|
|
1274
|
-
},
|
|
1275
|
-
{
|
|
1276
|
-
match: (ctx) => ctx.statusCode === 429 ||
|
|
1277
|
-
/rate limit|too_many_requests|429/i.test(ctx.message),
|
|
1278
|
-
errorClass: RateLimitError,
|
|
1279
|
-
message: "Anthropic rate limit exceeded. Please try again later.",
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
match: (ctx) => /ECONNRESET|ENOTFOUND|ECONNREFUSED|network|connection/i.test(ctx.message),
|
|
1283
|
-
errorClass: NetworkError,
|
|
1284
|
-
message: (ctx) => `Connection error: ${ctx.message}`,
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
match: (ctx) => /500|502|503|504|server error/i.test(ctx.message),
|
|
1288
|
-
errorClass: ProviderError,
|
|
1289
|
-
message: (ctx) => `Server error: ${ctx.message}`,
|
|
1290
|
-
},
|
|
1291
|
-
{
|
|
1292
|
-
match: () => true,
|
|
1293
|
-
errorClass: ProviderError,
|
|
1294
|
-
message: (ctx) => `Anthropic error: ${ctx.message}`,
|
|
1295
|
-
},
|
|
1296
|
-
];
|
|
1297
|
-
return classifyProviderError(error, rules, this.providerName, this.modelName);
|
|
1298
|
-
}
|
|
1299
|
-
// executeGenerate removed - BaseProvider handles all generation with tools
|
|
1300
|
-
/**
|
|
1301
|
-
* Override generate to refresh the OAuth token before delegating to
|
|
1302
|
-
* BaseProvider so that expired tokens are renewed automatically.
|
|
1303
|
-
*/
|
|
1304
|
-
async generate(optionsOrPrompt, analysisSchema) {
|
|
1305
|
-
await this.refreshAuthIfNeeded();
|
|
1306
|
-
// Open a per-request capture scope around the whole turn. Scoping here
|
|
1307
|
-
// rather than on the instance is what makes it concurrency-safe: several
|
|
1308
|
-
// generate() calls can be in flight on one provider instance, and an
|
|
1309
|
-
// instance field would attribute one call's limits to another.
|
|
1310
|
-
const { result, snapshot } = await withLimitCapture(() => super.generate(optionsOrPrompt, analysisSchema));
|
|
1311
|
-
if (result && snapshot) {
|
|
1312
|
-
this.recordLimitSnapshot(snapshot);
|
|
1313
|
-
result.limits = snapshot;
|
|
1314
|
-
if (result.analytics) {
|
|
1315
|
-
result.analytics.limits = snapshot;
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
return result;
|
|
1319
|
-
}
|
|
1320
|
-
/**
|
|
1321
|
-
* Fold a captured snapshot into the provider's usage bookkeeping and log it.
|
|
1322
|
-
*
|
|
1323
|
-
* `updateResponseMetadata` had no callers before this — the metadata it
|
|
1324
|
-
* maintains, and the public `getLastResponseMetadata()` / `getUsageInfo()`
|
|
1325
|
-
* that read it, were never populated by anything.
|
|
1326
|
-
*/
|
|
1327
|
-
recordLimitSnapshot(snapshot) {
|
|
1328
|
-
this.updateResponseMetadata(snapshot.rateLimit, snapshot.requestId);
|
|
1329
|
-
setLimitSpanAttributes(snapshot);
|
|
1330
|
-
logClaudeLimitSnapshot(snapshot, this.modelName);
|
|
1331
|
-
}
|
|
1332
|
-
async executeStream(options, analysisSchema) {
|
|
1333
|
-
// The capture scope must outlive this call: the SSE loop keeps running in
|
|
1334
|
-
// the background after executeStream returns, and its per-step HTTP
|
|
1335
|
-
// requests are what carry the limit headers. AsyncLocalStorage.run
|
|
1336
|
-
// propagates into every continuation started inside, so the whole stream
|
|
1337
|
-
// lifetime shares one slot.
|
|
1338
|
-
return runInLimitCaptureScope(() => this.executeStreamInCaptureScope(options, analysisSchema));
|
|
1339
|
-
}
|
|
1340
|
-
async executeStreamInCaptureScope(options, _analysisSchema) {
|
|
1341
|
-
// Refresh OAuth token if needed before making any API request.
|
|
1342
|
-
await this.refreshAuthIfNeeded();
|
|
1343
|
-
this.validateStreamOptions(options);
|
|
1344
|
-
const timeout = this.getTimeout(options);
|
|
1345
|
-
const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
|
|
1346
|
-
// Consumer-driven abort: fires when the async iterator is closed early
|
|
1347
|
-
// (caller breaks out of `for await`) so the background loop stops
|
|
1348
|
-
// reading SSE and running tools.
|
|
1349
|
-
const consumerAbortController = new AbortController();
|
|
1350
|
-
const abortSignal = mergeAbortSignals([
|
|
1351
|
-
options.abortSignal,
|
|
1352
|
-
timeoutController?.controller.signal,
|
|
1353
|
-
consumerAbortController.signal,
|
|
1354
|
-
]).signal;
|
|
1355
|
-
let toolsRecord;
|
|
1356
|
-
let anthropicTools;
|
|
1357
|
-
let payload;
|
|
1358
|
-
let shouldUseTools;
|
|
1359
|
-
// True once the additive `final_result` tool is in the request — the
|
|
1360
|
-
// streaming twin of the doGenerate path above.
|
|
1361
|
-
let finalResultActive = false;
|
|
1362
|
-
try {
|
|
1363
|
-
// options.tools is pre-merged by BaseProvider.stream() with base tools
|
|
1364
|
-
// (MCP/built-in) + user-provided tools (RAG, etc.)
|
|
1365
|
-
shouldUseTools = !options.disableTools && this.supportsTools();
|
|
1366
|
-
toolsRecord = shouldUseTools
|
|
1367
|
-
? options.tools || (await this.getAllTools())
|
|
1368
|
-
: {};
|
|
1369
|
-
anthropicTools = shouldUseTools
|
|
1370
|
-
? toNativeToolDeclarations(toolsRecord, "input_schema")
|
|
1371
|
-
: undefined;
|
|
1372
|
-
// Build message array from options with multimodal support, then
|
|
1373
|
-
// convert to the Anthropic Messages payload (system + content blocks).
|
|
1374
|
-
const built = await this.buildMessagesForStream(options);
|
|
1375
|
-
payload = messagesToAnthropic(built);
|
|
1376
|
-
// Schema + tools: append final_result rather than pinning tool_choice to
|
|
1377
|
-
// a json tool, so the real tools stay callable for the whole turn.
|
|
1378
|
-
// Unlike generate, no plumbing is needed — this is a native loop, so the
|
|
1379
|
-
// caller's Zod/JSON schema is right here on the options.
|
|
1380
|
-
if (options.schema && anthropicTools && anthropicTools.length > 0) {
|
|
1381
|
-
const appended = appendFinalResultTool(anthropicTools, convertZodToJsonSchema(options.schema));
|
|
1382
|
-
anthropicTools = appended.tools;
|
|
1383
|
-
finalResultActive = appended.applied;
|
|
1384
|
-
if (appended.applied) {
|
|
1385
|
-
payload.system = appendFinalResultInstruction(payload.system);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
catch (setupErr) {
|
|
1390
|
-
timeoutController?.cleanup();
|
|
1391
|
-
throw this.handleProviderError(setupErr);
|
|
1392
|
-
}
|
|
1393
|
-
const modelId = this.modelName || getDefaultAnthropicModel();
|
|
1394
|
-
const anthropicToolChoice = shouldUseTools && anthropicTools && anthropicTools.length > 0
|
|
1395
|
-
? toolChoiceToAnthropic(resolveToolChoice(options, toolsRecord, shouldUseTools))
|
|
1396
|
-
: undefined;
|
|
1397
|
-
// Extended thinking: enabled when the caller supplies an explicit token
|
|
1398
|
-
// budget (mirrors the previous experimental_thinking gating). Thinking
|
|
1399
|
-
// deltas stream out on the `reasoning` chunk channel.
|
|
1400
|
-
const thinking = options.thinkingConfig?.enabled && options.thinkingConfig.budgetTokens
|
|
1401
|
-
? {
|
|
1402
|
-
type: "enabled",
|
|
1403
|
-
budget_tokens: options.thinkingConfig.budgetTokens,
|
|
1404
|
-
}
|
|
1405
|
-
: undefined;
|
|
1406
|
-
// Wrap the native stream in an OTel span to capture provider-level
|
|
1407
|
-
// latency and token usage (same span name as the pre-migration path so
|
|
1408
|
-
// dashboards stay continuous).
|
|
1409
|
-
const streamSpan = streamTracer.startSpan("neurolink.provider.streamText", {
|
|
1410
|
-
kind: SpanKind.CLIENT,
|
|
1411
|
-
attributes: {
|
|
1412
|
-
"gen_ai.system": "anthropic",
|
|
1413
|
-
"gen_ai.request.model": modelId,
|
|
1414
|
-
},
|
|
1415
|
-
});
|
|
1416
|
-
const maxSteps = options.maxSteps || DEFAULT_MAX_STEPS;
|
|
1417
|
-
const emitter = this.neurolink?.getEventEmitter();
|
|
1418
|
-
const channel = createStreamChannel();
|
|
1419
|
-
const { push: pushChunk } = channel;
|
|
1420
|
-
const { usagePromise, finishPromise, resolveUsage, resolveFinish } = createDeferredAnalytics();
|
|
1421
|
-
usagePromise
|
|
1422
|
-
.then((usage) => {
|
|
1423
|
-
streamSpan.setAttribute("gen_ai.usage.input_tokens", usage.promptTokens || 0);
|
|
1424
|
-
streamSpan.setAttribute("gen_ai.usage.output_tokens", usage.completionTokens || 0);
|
|
1425
|
-
if (usage.cacheReadTokens) {
|
|
1426
|
-
streamSpan.setAttribute("gen_ai.usage.cached_input_tokens", usage.cacheReadTokens);
|
|
1427
|
-
}
|
|
1428
|
-
const cost = calculateCost(this.providerName, this.modelName, {
|
|
1429
|
-
input: usage.promptTokens || 0,
|
|
1430
|
-
output: usage.completionTokens || 0,
|
|
1431
|
-
total: usage.totalTokens || 0,
|
|
1432
|
-
...(usage.cacheReadTokens
|
|
1433
|
-
? { cacheReadTokens: usage.cacheReadTokens }
|
|
1434
|
-
: {}),
|
|
1435
|
-
...(usage.cacheCreationTokens
|
|
1436
|
-
? { cacheCreationTokens: usage.cacheCreationTokens }
|
|
1437
|
-
: {}),
|
|
1438
|
-
});
|
|
1439
|
-
if (cost && cost > 0) {
|
|
1440
|
-
streamSpan.setAttribute("neurolink.cost", cost);
|
|
1441
|
-
}
|
|
1442
|
-
})
|
|
1443
|
-
.catch(() => {
|
|
1444
|
-
// usage may never resolve if the stream is aborted before completion
|
|
1445
|
-
});
|
|
1446
|
-
finishPromise
|
|
1447
|
-
.then((reason) => {
|
|
1448
|
-
streamSpan.setAttribute("gen_ai.response.finish_reason", reason || "unknown");
|
|
1449
|
-
streamSpan.end();
|
|
1450
|
-
})
|
|
1451
|
-
.catch(() => {
|
|
1452
|
-
streamSpan.end();
|
|
1453
|
-
});
|
|
1454
|
-
let capturedProviderError;
|
|
1455
|
-
const client = this.client;
|
|
1456
|
-
const toolsUsed = [];
|
|
1457
|
-
const streamStartTime = Date.now();
|
|
1458
|
-
// Hoisted out of runLoop so the error path can resolve the usage
|
|
1459
|
-
// accumulated by steps that completed BEFORE the failure — those steps
|
|
1460
|
-
// were billed and must not be reported as zero.
|
|
1461
|
-
let totalInput = 0;
|
|
1462
|
-
let totalOutput = 0;
|
|
1463
|
-
let totalCacheRead = 0;
|
|
1464
|
-
let totalCacheWrite = 0;
|
|
1465
|
-
let lastStop = null;
|
|
1466
|
-
const buildDeferredUsage = () => ({
|
|
1467
|
-
promptTokens: totalInput,
|
|
1468
|
-
completionTokens: totalOutput,
|
|
1469
|
-
totalTokens: totalInput + totalCacheRead + totalCacheWrite + totalOutput,
|
|
1470
|
-
...(totalCacheRead > 0 ? { cacheReadTokens: totalCacheRead } : {}),
|
|
1471
|
-
...(totalCacheWrite > 0 ? { cacheCreationTokens: totalCacheWrite } : {}),
|
|
1472
|
-
});
|
|
1473
|
-
// Structured-output turns are delivered as ONE chunk, not incrementally:
|
|
1474
|
-
// a caller that passed a schema needs parseable JSON, and text deltas
|
|
1475
|
-
// emitted before the model calls final_result would prefix the payload
|
|
1476
|
-
// with prose and break every JSON.parse on the consumer side. Same
|
|
1477
|
-
// contract as the native Vertex loops. Non-schema streams are untouched
|
|
1478
|
-
// and stay fully incremental.
|
|
1479
|
-
let bufferedText = "";
|
|
1480
|
-
let finalResultText;
|
|
1481
|
-
/** System prompt + tool definitions: they ride outside `messages`. */
|
|
1482
|
-
const estimateAnthropicFixedOverhead = (system, tools) => {
|
|
1483
|
-
const text = (value) => {
|
|
1484
|
-
if (typeof value === "string") {
|
|
1485
|
-
return value;
|
|
1486
|
-
}
|
|
1487
|
-
try {
|
|
1488
|
-
return JSON.stringify(value) ?? "";
|
|
1489
|
-
}
|
|
1490
|
-
catch {
|
|
1491
|
-
return "";
|
|
1492
|
-
}
|
|
1493
|
-
};
|
|
1494
|
-
return (estimateTokens(text(system), "anthropic") +
|
|
1495
|
-
estimateTokens(text(tools), "anthropic"));
|
|
1496
|
-
};
|
|
1497
|
-
const runLoop = async () => {
|
|
1498
|
-
// The provider's REAL prompt-token count for the previous step,
|
|
1499
|
-
// calibrating the guard's char-based estimate for free, paired with the
|
|
1500
|
-
// guard's own estimate for that same request — a ratio between counts of
|
|
1501
|
-
// two different payloads would be meaningless.
|
|
1502
|
-
let lastObservedPromptTokens;
|
|
1503
|
-
let lastSentEstimate;
|
|
1504
|
-
/**
|
|
1505
|
-
* Reclaim, as a PURE function of the conversation.
|
|
1506
|
-
*
|
|
1507
|
-
* The hand-rolled loop this replaces rebuilt in place
|
|
1508
|
-
* (`conversation.length = 0; conversation.push(...rebuilt)`) because it
|
|
1509
|
-
* owned the array. The engine owns it now and assigns what this
|
|
1510
|
-
* returns, so mutating here would corrupt a retried or reclaimed step.
|
|
1511
|
-
*/
|
|
1512
|
-
const planReclaim = (conversation) => {
|
|
1513
|
-
const reclaim = planAnthropicLoopReclaim({
|
|
1514
|
-
conversation,
|
|
1515
|
-
availableInputTokens: getAvailableInputTokens("anthropic", modelId, options.maxTokens ?? undefined),
|
|
1516
|
-
fixedOverheadTokens: estimateAnthropicFixedOverhead(payload.system, anthropicTools),
|
|
1517
|
-
provider: "anthropic",
|
|
1518
|
-
observedPromptTokens: lastObservedPromptTokens,
|
|
1519
|
-
// Both halves of the calibration ratio must describe the same
|
|
1520
|
-
// request: the tokens the provider reported, and this guard's own
|
|
1521
|
-
// estimate for what was sent to earn them.
|
|
1522
|
-
previousSentEstimate: lastSentEstimate,
|
|
1523
|
-
onSentEstimate: (tokens) => {
|
|
1524
|
-
lastSentEstimate = tokens;
|
|
1525
|
-
},
|
|
1526
|
-
});
|
|
1527
|
-
if (!reclaim) {
|
|
1528
|
-
return undefined;
|
|
1529
|
-
}
|
|
1530
|
-
// Dropping an assistant tool_use message together with its user
|
|
1531
|
-
// tool_result message is what keeps blocks paired.
|
|
1532
|
-
const dropSet = new Set(reclaim.drop);
|
|
1533
|
-
const truncateSet = new Set(reclaim.truncate);
|
|
1534
|
-
const rebuilt = [];
|
|
1535
|
-
for (let i = 0; i < conversation.length; i++) {
|
|
1536
|
-
if (dropSet.has(i)) {
|
|
1537
|
-
continue;
|
|
1538
|
-
}
|
|
1539
|
-
const message = conversation[i];
|
|
1540
|
-
if (truncateSet.has(i) && Array.isArray(message.content)) {
|
|
1541
|
-
rebuilt.push({
|
|
1542
|
-
...message,
|
|
1543
|
-
content: message.content.map((block) => block.type === "tool_result"
|
|
1544
|
-
? {
|
|
1545
|
-
...block,
|
|
1546
|
-
content: previewAnthropicToolResultText(typeof block.content === "string"
|
|
1547
|
-
? block.content
|
|
1548
|
-
: (JSON.stringify(block.content) ?? "")),
|
|
1549
|
-
}
|
|
1550
|
-
: block),
|
|
1551
|
-
});
|
|
1552
|
-
continue;
|
|
1553
|
-
}
|
|
1554
|
-
rebuilt.push(message);
|
|
1555
|
-
}
|
|
1556
|
-
if (dropSet.size > 0) {
|
|
1557
|
-
// Anthropic requires user/assistant alternation around tool blocks;
|
|
1558
|
-
// the note is a user turn placed immediately before the first
|
|
1559
|
-
// surviving assistant tool_use turn, which preserves it.
|
|
1560
|
-
let noteIndex = rebuilt.findIndex((m) => Array.isArray(m.content) &&
|
|
1561
|
-
m.content.some((b) => b.type === "tool_use" || b.type === "tool_result"));
|
|
1562
|
-
if (noteIndex < 0) {
|
|
1563
|
-
noteIndex = Math.min(1, rebuilt.length);
|
|
1564
|
-
}
|
|
1565
|
-
rebuilt.splice(noteIndex, 0, {
|
|
1566
|
-
role: "user",
|
|
1567
|
-
content: [{ type: "text", text: ANTHROPIC_ELISION_NOTE }],
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
return rebuilt;
|
|
1571
|
-
};
|
|
1572
|
-
const buildParams = (conversation) => {
|
|
1573
|
-
// Mid-turn discovery sync: search_tools (tools.discovery) hydrates
|
|
1574
|
-
// new tools into toolsRecord between steps; Claude only calls tools
|
|
1575
|
-
// declared in the request, so advertise them now.
|
|
1576
|
-
if (anthropicTools) {
|
|
1577
|
-
const declared = new Set(anthropicTools.map((t) => t.name));
|
|
1578
|
-
const hydrated = Object.fromEntries(Object.entries(toolsRecord).filter(([name]) => !declared.has(name)));
|
|
1579
|
-
if (Object.keys(hydrated).length > 0) {
|
|
1580
|
-
const extra = toNativeToolDeclarations(hydrated, "input_schema");
|
|
1581
|
-
if (extra && extra.length > 0) {
|
|
1582
|
-
anthropicTools = [...anthropicTools, ...extra];
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
// Prompt-cache parity with the native Vertex+Claude path — rolling
|
|
1587
|
-
// history breakpoints, re-applied per step so the stable prefix stays
|
|
1588
|
-
// byte-identical while the breakpoint follows the growing tail.
|
|
1589
|
-
const cacheMarkersUsed = countAnthropicCacheMarkers({
|
|
1590
|
-
system: payload.system,
|
|
1591
|
-
tools: anthropicTools,
|
|
1592
|
-
messages: conversation,
|
|
1593
|
-
});
|
|
1594
|
-
const cachedConversation = applyAnthropicHistoryCacheBreakpoints(conversation, ANTHROPIC_MAX_CACHE_BREAKPOINTS - cacheMarkersUsed);
|
|
1595
|
-
const streamSamplingParams = resolveSamplingParams("anthropic", modelId, options.temperature !== undefined && options.temperature !== null
|
|
1596
|
-
? { temperature: options.temperature }
|
|
1597
|
-
: {}, "anthropic.executeStream");
|
|
1598
|
-
return {
|
|
1599
|
-
model: modelId,
|
|
1600
|
-
messages: cachedConversation,
|
|
1601
|
-
max_tokens: resolveClaudeMaxTokens(modelId, options.maxTokens),
|
|
1602
|
-
stream: true,
|
|
1603
|
-
...(payload.system ? { system: payload.system } : {}),
|
|
1604
|
-
...(streamSamplingParams.temperature !== undefined
|
|
1605
|
-
? { temperature: streamSamplingParams.temperature }
|
|
1606
|
-
: {}),
|
|
1607
|
-
...(anthropicTools && anthropicTools.length > 0
|
|
1608
|
-
? { tools: anthropicTools }
|
|
1609
|
-
: {}),
|
|
1610
|
-
...(anthropicToolChoice ? { tool_choice: anthropicToolChoice } : {}),
|
|
1611
|
-
...(thinking ? { thinking } : {}),
|
|
1612
|
-
};
|
|
1613
|
-
};
|
|
1614
|
-
const baseAdapter = createAnthropicLoopAdapter({
|
|
1615
|
-
client,
|
|
1616
|
-
maxSteps,
|
|
1617
|
-
toolsRecord,
|
|
1618
|
-
buildParams,
|
|
1619
|
-
planReclaim,
|
|
1620
|
-
noteObservedPromptTokens: (tokens) => {
|
|
1621
|
-
lastObservedPromptTokens = tokens;
|
|
1622
|
-
},
|
|
1623
|
-
...(finalResultActive
|
|
1624
|
-
? {
|
|
1625
|
-
finalResultToolName: FINAL_RESULT_TOOL_NAME,
|
|
1626
|
-
onTerminalResult: (text) => {
|
|
1627
|
-
finalResultText = text;
|
|
1628
|
-
logger.debug("[Anthropic] Extracted structured output from final_result tool (stream)", { chars: text.length });
|
|
1629
|
-
},
|
|
1630
|
-
}
|
|
1631
|
-
: {}),
|
|
1632
|
-
});
|
|
1633
|
-
// Wrapped rather than folded into the adapter: analytics emission and
|
|
1634
|
-
// tool-execution storage fire ONCE PER STEP in the loop this replaces,
|
|
1635
|
-
// and buildToolResultMessages is the only per-step hook — it receives
|
|
1636
|
-
// exactly that step's results. Doing this from the turn's final result
|
|
1637
|
-
// instead would batch every step's tools into one late write.
|
|
1638
|
-
const adapter = {
|
|
1639
|
-
...baseAdapter,
|
|
1640
|
-
buildToolResultMessages: (conversation, stepResult, toolResults) => {
|
|
1641
|
-
for (const result of toolResults) {
|
|
1642
|
-
toolsUsed.push(result.name);
|
|
1643
|
-
}
|
|
1644
|
-
const toolCallsForStorage = toolResults.map((result) => ({
|
|
1645
|
-
type: "tool-call",
|
|
1646
|
-
toolCallId: result.id,
|
|
1647
|
-
toolName: result.name,
|
|
1648
|
-
args: result.args,
|
|
1649
|
-
}));
|
|
1650
|
-
const toolResultsForStorage = toolResults.map((result) => result.error
|
|
1651
|
-
? {
|
|
1652
|
-
type: "tool-result",
|
|
1653
|
-
toolCallId: result.id,
|
|
1654
|
-
toolName: result.name,
|
|
1655
|
-
error: result.error,
|
|
1656
|
-
}
|
|
1657
|
-
: {
|
|
1658
|
-
type: "tool-result",
|
|
1659
|
-
toolCallId: result.id,
|
|
1660
|
-
toolName: result.name,
|
|
1661
|
-
result: result.output,
|
|
1662
|
-
});
|
|
1663
|
-
emitToolEndFromStepFinish(emitter, toolResultsForStorage.map((tr) => ({
|
|
1664
|
-
toolName: tr.toolName,
|
|
1665
|
-
result: "result" in tr ? tr.result : undefined,
|
|
1666
|
-
error: "error" in tr ? tr.error : undefined,
|
|
1667
|
-
})));
|
|
1668
|
-
this.handleToolExecutionStorage(toolCallsForStorage, toolResultsForStorage, options, new Date()).catch((storageErr) => {
|
|
1669
|
-
logger.warn("[AnthropicProvider] Failed to store tool executions", {
|
|
1670
|
-
provider: this.providerName,
|
|
1671
|
-
error: storageErr instanceof Error
|
|
1672
|
-
? storageErr.message
|
|
1673
|
-
: String(storageErr),
|
|
1674
|
-
});
|
|
1675
|
-
});
|
|
1676
|
-
return baseAdapter.buildToolResultMessages(conversation, stepResult, toolResults);
|
|
1677
|
-
},
|
|
1678
|
-
};
|
|
1679
|
-
// Presented in the shape the engine dispatches through. The engine
|
|
1680
|
-
// supplies `{ toolCallId, abortSignal }`; the loop this replaces also
|
|
1681
|
-
// supplied `messages: []`, so it is kept — a tool that reads it would
|
|
1682
|
-
// otherwise see undefined where it used to see an empty array.
|
|
1683
|
-
const engineTools = {};
|
|
1684
|
-
for (const [name, tool] of Object.entries(toolsRecord)) {
|
|
1685
|
-
const execute = tool.execute;
|
|
1686
|
-
if (!execute) {
|
|
1687
|
-
continue;
|
|
1688
|
-
}
|
|
1689
|
-
engineTools[name] = {
|
|
1690
|
-
execute: async (args, opts) => {
|
|
1691
|
-
const ctx = opts;
|
|
1692
|
-
return execute(args, {
|
|
1693
|
-
toolCallId: ctx.toolCallId ?? "",
|
|
1694
|
-
...(ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}),
|
|
1695
|
-
messages: [],
|
|
1696
|
-
});
|
|
1697
|
-
},
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
const { stream, resultPromise } = runAgenticLoop(adapter, payload.messages.slice(), {
|
|
1701
|
-
tools: engineTools,
|
|
1702
|
-
...(abortSignal ? { abortSignal } : {}),
|
|
1703
|
-
});
|
|
1704
|
-
// Structured turns buffer their text rather than streaming it: a caller
|
|
1705
|
-
// that passed a schema needs parseable JSON, and deltas emitted before
|
|
1706
|
-
// the model calls final_result would prefix the payload with prose.
|
|
1707
|
-
// Reasoning is forwarded either way — it is not part of the payload.
|
|
1708
|
-
const pump = (async () => {
|
|
1709
|
-
for await (const chunk of stream) {
|
|
1710
|
-
if (chunk.reasoning) {
|
|
1711
|
-
pushChunk({ content: "", reasoning: chunk.reasoning });
|
|
1712
|
-
}
|
|
1713
|
-
if (chunk.content) {
|
|
1714
|
-
if (finalResultActive) {
|
|
1715
|
-
bufferedText += chunk.content;
|
|
1716
|
-
}
|
|
1717
|
-
else {
|
|
1718
|
-
pushChunk({ content: chunk.content });
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
}
|
|
1722
|
-
})();
|
|
1723
|
-
const result = await resultPromise;
|
|
1724
|
-
await pump;
|
|
1725
|
-
totalInput += result.usage.inputTokens;
|
|
1726
|
-
totalOutput += result.usage.outputTokens;
|
|
1727
|
-
totalCacheRead += result.usage.cacheReadTokens ?? 0;
|
|
1728
|
-
totalCacheWrite += result.usage.cacheWriteTokens ?? 0;
|
|
1729
|
-
lastStop = result.rawStopReason ?? lastStop;
|
|
1730
|
-
resolveUsage(buildDeferredUsage());
|
|
1731
|
-
resolveFinish(lastStop ?? "stop");
|
|
1732
|
-
};
|
|
1733
|
-
const loopPromise = runLoop()
|
|
1734
|
-
// Parameter named `error` so the compiled `capturedProviderError = error`
|
|
1735
|
-
// assignment matches the regression-grep in test:context 6.14.
|
|
1736
|
-
.catch((error) => {
|
|
1737
|
-
capturedProviderError = error;
|
|
1738
|
-
logger.error("Anthropic: Stream error", {
|
|
1739
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1740
|
-
});
|
|
1741
|
-
// Report whatever the completed steps accumulated — they were billed
|
|
1742
|
-
// — and unblock any consumer awaiting the usage promise.
|
|
1743
|
-
resolveUsage(buildDeferredUsage());
|
|
1744
|
-
resolveFinish("error");
|
|
1745
|
-
throw this.formatProviderError(error);
|
|
1746
|
-
})
|
|
1747
|
-
.finally(() => {
|
|
1748
|
-
// Deliver the buffered structured-output turn: `finalResultText` when
|
|
1749
|
-
// the model called final_result, otherwise the prose it produced
|
|
1750
|
-
// instead — never nothing, so a model that ignores the instruction
|
|
1751
|
-
// degrades to today's plain-text behaviour rather than an empty
|
|
1752
|
-
// stream. In `finally` so a turn that dies mid-loop still surfaces
|
|
1753
|
-
// the text it had already buffered, exactly as the unbuffered path
|
|
1754
|
-
// surfaces its partial deltas.
|
|
1755
|
-
if (finalResultActive) {
|
|
1756
|
-
const output = finalResultText ?? bufferedText;
|
|
1757
|
-
if (output.length > 0) {
|
|
1758
|
-
pushChunk({ content: output });
|
|
1759
|
-
}
|
|
1760
|
-
}
|
|
1761
|
-
timeoutController?.cleanup();
|
|
1762
|
-
channel.close();
|
|
1763
|
-
});
|
|
1764
|
-
loopPromise.catch(() => {
|
|
1765
|
-
// Swallowed by design: the generator below surfaces loop errors after
|
|
1766
|
-
// draining the channel; this guard only prevents an unhandled-rejection
|
|
1767
|
-
// crash when the consumer abandons the stream early.
|
|
1768
|
-
});
|
|
1769
|
-
const providerName = this.providerName;
|
|
1770
|
-
const transformedStream = async function* () {
|
|
1771
|
-
let contentYielded = 0;
|
|
1772
|
-
try {
|
|
1773
|
-
for await (const chunk of channel.iterable) {
|
|
1774
|
-
if ("content" in chunk &&
|
|
1775
|
-
typeof chunk.content === "string" &&
|
|
1776
|
-
chunk.content.length > 0) {
|
|
1777
|
-
contentYielded++;
|
|
1778
|
-
}
|
|
1779
|
-
yield chunk;
|
|
1780
|
-
}
|
|
1781
|
-
// Surface any error the loop threw after draining the channel.
|
|
1782
|
-
await loopPromise;
|
|
1783
|
-
// No-output path: stream completed normally but yielded zero text.
|
|
1784
|
-
if (contentYielded === 0 && toolsUsed.length === 0) {
|
|
1785
|
-
logger.warn(`${providerName}: Stream produced no output — emitting enriched sentinel`);
|
|
1786
|
-
const fauxNoOutput = new NoOutputGeneratedError({
|
|
1787
|
-
message: "Stream produced no output",
|
|
1788
|
-
});
|
|
1789
|
-
const sentinel = await buildNoOutputSentinel(fauxNoOutput, undefined, capturedProviderError);
|
|
1790
|
-
stampNoOutputSpan(sentinel);
|
|
1791
|
-
yield sentinel;
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
catch (streamError) {
|
|
1795
|
-
const sentinel = await buildNoOutputSentinel(streamError, undefined, capturedProviderError);
|
|
1796
|
-
stampNoOutputSpan(sentinel);
|
|
1797
|
-
yield sentinel;
|
|
1798
|
-
if (!NoOutputGeneratedError.isInstance(streamError)) {
|
|
1799
|
-
throw streamError;
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
finally {
|
|
1803
|
-
if (!consumerAbortController.signal.aborted) {
|
|
1804
|
-
consumerAbortController.abort();
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
};
|
|
1808
|
-
return {
|
|
1809
|
-
stream: transformedStream(),
|
|
1810
|
-
provider: this.providerName,
|
|
1811
|
-
model: this.modelName,
|
|
1812
|
-
toolCalls: [],
|
|
1813
|
-
toolResults: [],
|
|
1814
|
-
// Wire the deferred usage/finish promises into the analytics collector
|
|
1815
|
-
// (mirrors openaiChatCompletionsBase). Without this the loop computed a
|
|
1816
|
-
// fully correct aggregate that was consumed only by the OTel span —
|
|
1817
|
-
// stream consumers and session cost tracking saw no usage at all.
|
|
1818
|
-
// Chained off finishPromise so requestDuration reflects the DRAINED
|
|
1819
|
-
// stream, not the milliseconds it took to construct this result object.
|
|
1820
|
-
analytics: finishPromise.then(async () => {
|
|
1821
|
-
const analytics = await streamAnalyticsCollector.createAnalytics(this.providerName, modelId, {
|
|
1822
|
-
textStream: (async function* () { })(),
|
|
1823
|
-
usage: usagePromise,
|
|
1824
|
-
finishReason: finishPromise,
|
|
1825
|
-
}, Date.now() - streamStartTime, {
|
|
1826
|
-
requestId: options.requestId ??
|
|
1827
|
-
`${this.providerName}-stream-${Date.now()}`,
|
|
1828
|
-
streamingMode: true,
|
|
1829
|
-
});
|
|
1830
|
-
// Still inside the capture scope opened by executeStream, so this sees
|
|
1831
|
-
// the limits reported by the last upstream step of the stream.
|
|
1832
|
-
const snapshot = getCapturedLimitSnapshot();
|
|
1833
|
-
if (snapshot && analytics) {
|
|
1834
|
-
this.recordLimitSnapshot(snapshot);
|
|
1835
|
-
analytics.limits = snapshot;
|
|
1836
|
-
}
|
|
1837
|
-
return analytics;
|
|
1838
|
-
}),
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
async isAvailable() {
|
|
1842
|
-
try {
|
|
1843
|
-
// Check OAuth token first
|
|
1844
|
-
const oauthToken = getOAuthToken();
|
|
1845
|
-
if (oauthToken) {
|
|
1846
|
-
return true;
|
|
1847
|
-
}
|
|
1848
|
-
// Fall back to API key check
|
|
1849
|
-
getAnthropicApiKey();
|
|
1850
|
-
return true;
|
|
1851
|
-
}
|
|
1852
|
-
catch {
|
|
1853
|
-
return false;
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
getModel() {
|
|
1857
|
-
return this.getAISDKModel();
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
// Re-export types and utilities for convenience
|
|
1861
|
-
export { getModelCapabilities, getRecommendedModelForTier, isModelAvailableForTier, ModelAccessError, } from "../../models/anthropicModels.js";
|
|
1862
|
-
//# sourceMappingURL=client.js.map
|