@office-ai/aioncli-core 0.2.3 → 0.18.4
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/dist/index.d.ts +16 -3
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +132 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/codebase-investigator.test.js +35 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/executor.d.ts +114 -0
- package/dist/src/agents/executor.js +779 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.js +1362 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +40 -0
- package/dist/src/agents/registry.js +105 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +160 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +110 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +146 -0
- package/dist/src/agents/types.js +19 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +13 -1
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
- package/dist/src/code_assist/codeAssist.test.js +99 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +5 -1
- package/dist/src/code_assist/converter.js +39 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +112 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +50 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +36 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments.test.js +92 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
- package/dist/src/code_assist/experiments/flagNames.js +13 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +110 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +198 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +3 -3
- package/dist/src/code_assist/oauth2.js +252 -125
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +788 -350
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +8 -6
- package/dist/src/code_assist/server.js +41 -10
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +151 -28
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -2
- package/dist/src/code_assist/setup.js +5 -3
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +18 -3
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +6 -0
- package/dist/src/commands/extensions.test.js +19 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/config/config.d.ts +282 -60
- package/dist/src/config/config.js +677 -129
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +1020 -146
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +185 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +37 -0
- package/dist/src/config/models.js +72 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +116 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +36 -0
- package/dist/src/config/storage.js +115 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +48 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +18 -0
- package/dist/src/confirmation-bus/message-bus.js +87 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +170 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +49 -0
- package/dist/src/confirmation-bus/types.js +16 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +50 -0
- package/dist/src/core/baseLlmClient.js +185 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +311 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +30 -42
- package/dist/src/core/client.js +178 -477
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +739 -617
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +7 -6
- package/dist/src/core/contentGenerator.js +59 -45
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +50 -4
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +28 -11
- package/dist/src/core/coreToolScheduler.js +493 -161
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +995 -163
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +33 -0
- package/dist/src/core/fakeContentGenerator.js +58 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
- package/dist/src/core/fakeContentGenerator.test.js +127 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +61 -55
- package/dist/src/core/geminiChat.js +388 -366
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1600 -355
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +11 -4
- package/dist/src/core/logger.js +39 -30
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +62 -45
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +4 -3
- package/dist/src/core/loggingContentGenerator.js +116 -37
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/loggingContentGenerator.test.js +180 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +4 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -120
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +168 -84
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +4 -3
- package/dist/src/core/openaiContentGenerator.js +49 -19
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +1 -0
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +7 -1
- package/dist/src/core/prompts.js +198 -195
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +172 -104
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +18 -0
- package/dist/src/core/recordingContentGenerator.js +77 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/recordingContentGenerator.test.js +101 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- package/dist/src/core/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +125 -90
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +59 -44
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +26 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +57 -13
- package/dist/src/core/turn.js +79 -35
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +373 -120
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +181 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +245 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +262 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
- package/dist/src/hooks/hookAggregator.test.js +387 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +46 -0
- package/dist/src/hooks/hookPlanner.js +108 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
- package/dist/src/hooks/hookPlanner.test.js +255 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +87 -0
- package/dist/src/hooks/hookRegistry.js +198 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
- package/dist/src/hooks/hookRegistry.test.js +341 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +42 -0
- package/dist/src/hooks/hookRunner.js +272 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +6 -0
- package/dist/src/hooks/hookRunner.test.js +468 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +232 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
- package/dist/src/hooks/hookTranslator.test.js +192 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +384 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +6 -0
- package/dist/src/hooks/types.test.js +313 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- package/dist/src/ide/constants.d.ts +3 -0
- package/dist/src/ide/constants.js +3 -0
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +52 -12
- package/dist/src/ide/detect-ide.js +51 -65
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +95 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +72 -24
- package/dist/src/ide/ide-client.js +380 -84
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +539 -35
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +93 -35
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +157 -26
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +35 -365
- package/dist/src/ide/ideContext.js +60 -106
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +152 -24
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +7 -5
- package/dist/src/ide/process-utils.js +108 -67
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +151 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +41 -2
- package/dist/src/index.js +44 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +5 -3
- package/dist/src/mcp/google-auth-provider.js +21 -3
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +42 -9
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +25 -18
- package/dist/src/mcp/oauth-provider.js +194 -97
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +581 -39
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +14 -32
- package/dist/src/mcp/oauth-token-storage.js +58 -28
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +262 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +16 -1
- package/dist/src/mcp/oauth-utils.js +68 -33
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +86 -3
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
- package/dist/src/mcp/sa-impersonation-provider.js +113 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +151 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +145 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +238 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +305 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +44 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +82 -0
- package/dist/src/output/types.js +22 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +199 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +6 -0
- package/dist/src/policy/config.test.js +538 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +9 -0
- package/dist/src/policy/index.js +10 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +56 -0
- package/dist/src/policy/policies/write.toml +73 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +39 -0
- package/dist/src/policy/policy-engine.js +158 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +899 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +47 -0
- package/dist/src/policy/toml-loader.js +411 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +6 -0
- package/dist/src/policy/toml-loader.test.js +376 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +130 -0
- package/dist/src/policy/types.js +22 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
- package/dist/src/prompts/mcp-prompts.test.js +39 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/prompts/prompt-registry.js +2 -1
- package/dist/src/prompts/prompt-registry.js.map +1 -1
- package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
- package/dist/src/prompts/prompt-registry.test.js +96 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +85 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +160 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +166 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +196 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +68 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +59 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +45 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +6 -0
- package/dist/src/safety/built-in.test.js +199 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +208 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +6 -0
- package/dist/src/safety/checker-runner.test.js +238 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +6 -0
- package/dist/src/safety/context-builder.test.js +49 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +6 -0
- package/dist/src/safety/registry.test.js +31 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +162 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +6 -0
- package/dist/src/services/chatCompressionService.test.js +210 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +10 -15
- package/dist/src/services/chatRecordingService.js +43 -29
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +69 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +8 -10
- package/dist/src/services/fileDiscoveryService.js +31 -53
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +94 -14
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +12 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +30 -24
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +30 -37
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +12 -3
- package/dist/src/services/loopDetectionService.js +148 -55
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +280 -21
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
- package/dist/src/services/modelConfig.golden.test.js +42 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
- package/dist/src/services/modelConfig.integration.test.js +247 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +48 -0
- package/dist/src/services/modelConfigService.js +151 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +6 -0
- package/dist/src/services/modelConfigService.test.js +531 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +37 -2
- package/dist/src/services/shellExecutionService.js +361 -67
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +333 -71
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +251 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +53 -5
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +581 -56
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +2 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +467 -31
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +75 -4
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +182 -6
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +76 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +0 -18
- package/dist/src/telemetry/constants.js +0 -18
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +116 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +16 -2
- package/dist/src/telemetry/index.js +25 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +25 -3
- package/dist/src/telemetry/loggers.js +333 -154
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -4
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +868 -63
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +498 -11
- package/dist/src/telemetry/metrics.js +729 -84
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +964 -101
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +23 -4
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +108 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +269 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +6 -0
- package/dist/src/telemetry/semantic.test.js +387 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +41 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +351 -25
- package/dist/src/telemetry/types.js +1071 -63
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +4 -4
- package/dist/src/telemetry/uiTelemetry.js +14 -15
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +122 -96
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +3 -2
- package/dist/src/test-utils/config.js +1 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +66 -0
- package/dist/src/test-utils/{tools.js → mock-tool.js} +45 -29
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
- package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
- package/dist/src/tools/base-tool-invocation.test.js +85 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +10 -8
- package/dist/src/tools/edit.js +100 -79
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +429 -163
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +11 -5
- package/dist/src/tools/glob.js +58 -42
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +249 -166
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +7 -5
- package/dist/src/tools/grep.js +66 -40
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +41 -15
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +7 -5
- package/dist/src/tools/ls.js +54 -68
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +150 -293
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +52 -12
- package/dist/src/tools/mcp-client-manager.js +196 -27
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +139 -13
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +28 -24
- package/dist/src/tools/mcp-client.js +338 -351
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +380 -193
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +11 -5
- package/dist/src/tools/mcp-tool.js +66 -17
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +278 -211
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +10 -7
- package/dist/src/tools/memoryTool.js +28 -49
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +26 -13
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +196 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +7 -3
- package/dist/src/tools/modifiable-tool.js +41 -19
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +70 -35
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +9 -7
- package/dist/src/tools/read-file.js +39 -60
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +103 -36
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +9 -14
- package/dist/src/tools/read-many-files.js +71 -155
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +98 -44
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +73 -0
- package/dist/src/tools/ripGrep.js +395 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +1305 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +19 -6
- package/dist/src/tools/shell.js +92 -56
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +176 -103
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +78 -0
- package/dist/src/tools/smart-edit.js +717 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +592 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +39 -1
- package/dist/src/tools/tool-error.js +54 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +21 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +38 -20
- package/dist/src/tools/tool-registry.js +134 -77
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +218 -58
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +49 -17
- package/dist/src/tools/tools.js +150 -8
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +14 -5
- package/dist/src/tools/web-fetch.js +90 -44
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +388 -20
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +8 -6
- package/dist/src/tools/web-search.js +40 -15
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +75 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +7 -5
- package/dist/src/tools/write-file.js +54 -54
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +237 -146
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +50 -0
- package/dist/src/tools/write-todos.js +193 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +16 -9
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +6 -0
- package/dist/src/utils/channel.test.js +170 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +69 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +9 -8
- package/dist/src/utils/editCorrector.js +62 -34
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +52 -87
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +4 -2
- package/dist/src/utils/editor.js +56 -55
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +47 -88
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +3 -2
- package/dist/src/utils/environmentContext.js +20 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +6 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +28 -0
- package/dist/src/utils/errors.js +48 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +121 -0
- package/dist/src/utils/events.js +84 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +6 -0
- package/dist/src/utils/events.test.js +212 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +6 -0
- package/dist/src/utils/extensionLoader.test.js +154 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +1 -0
- package/dist/src/utils/fetch.js +5 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +28 -12
- package/dist/src/utils/fileUtils.js +204 -81
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +426 -82
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +103 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +12 -20
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +11 -10
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +7 -8
- package/dist/src/utils/gitIgnoreParser.js +145 -36
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +127 -38
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +152 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +301 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
- package/dist/src/utils/googleQuotaErrors.js +157 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +311 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +246 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +51 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +85 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +155 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +223 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +26 -6
- package/dist/src/utils/memoryDiscovery.js +239 -40
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +365 -44
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +19 -25
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +24 -155
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +3 -3
- package/dist/src/utils/nextSpeakerChecker.js +10 -4
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +85 -66
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +15 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +406 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +133 -57
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +200 -68
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -3
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +5 -10
- package/dist/src/utils/retry.js +114 -197
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +196 -130
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +15 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +21 -3
- package/dist/src/utils/shell-utils.js +427 -159
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +250 -59
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +6 -0
- package/dist/src/utils/stdio.test.js +47 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +6 -4
- package/dist/src/utils/summarizer.js +8 -9
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +32 -12
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +7 -6
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +4 -3
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +14 -0
- package/dist/src/utils/terminal.js +38 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +25 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +5 -0
- package/dist/src/utils/textUtils.js +14 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +67 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +69 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +115 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +41 -36
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +23 -17
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +45 -19
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -10
- package/dist/src/core/modelCheck.d.ts +0 -14
- package/dist/src/core/modelCheck.js +0 -62
- package/dist/src/core/modelCheck.js.map +0 -1
- package/dist/src/test-utils/tools.d.ts +0 -44
- package/dist/src/test-utils/tools.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.js +0 -118
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/flashFallback.integration.test.d.ts → agents/codebase-investigator.test.d.ts} +0 -0
- /package/dist/src/{utils/user_account.test.d.ts → agents/executor.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → agents/invocation.test.d.ts} +0 -0
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
7
|
+
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
7
8
|
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { ListPromptsResultSchema, GetPromptResultSchema, ListRootsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
10
|
+
import { ListRootsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
11
11
|
import { parse } from 'shell-quote';
|
|
12
12
|
import { AuthProviderType } from '../config/config.js';
|
|
13
13
|
import { GoogleCredentialProvider } from '../mcp/google-auth-provider.js';
|
|
14
|
+
import { ServiceAccountImpersonationProvider } from '../mcp/sa-impersonation-provider.js';
|
|
14
15
|
import { DiscoveredMCPTool } from './mcp-tool.js';
|
|
15
|
-
import {
|
|
16
|
+
import { basename } from 'node:path';
|
|
17
|
+
import { pathToFileURL } from 'node:url';
|
|
16
18
|
import { MCPOAuthProvider } from '../mcp/oauth-provider.js';
|
|
17
|
-
import { OAuthUtils } from '../mcp/oauth-utils.js';
|
|
18
19
|
import { MCPOAuthTokenStorage } from '../mcp/oauth-token-storage.js';
|
|
20
|
+
import { OAuthUtils } from '../mcp/oauth-utils.js';
|
|
19
21
|
import { getErrorMessage } from '../utils/errors.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
+
import { debugLogger } from '../utils/debugLogger.js';
|
|
23
|
+
import { coreEvents } from '../utils/events.js';
|
|
22
24
|
export const MCP_DEFAULT_TIMEOUT_MSEC = 10 * 60 * 1000; // default to 10 minutes
|
|
23
25
|
/**
|
|
24
26
|
* Enum representing the connection status of an MCP server
|
|
@@ -27,6 +29,8 @@ export var MCPServerStatus;
|
|
|
27
29
|
(function (MCPServerStatus) {
|
|
28
30
|
/** Server is disconnected or experiencing errors */
|
|
29
31
|
MCPServerStatus["DISCONNECTED"] = "disconnected";
|
|
32
|
+
/** Server is actively disconnecting */
|
|
33
|
+
MCPServerStatus["DISCONNECTING"] = "disconnecting";
|
|
30
34
|
/** Server is in the process of connecting */
|
|
31
35
|
MCPServerStatus["CONNECTING"] = "connecting";
|
|
32
36
|
/** Server is connected and ready to use */
|
|
@@ -60,7 +64,6 @@ export class McpClient {
|
|
|
60
64
|
client;
|
|
61
65
|
transport;
|
|
62
66
|
status = MCPServerStatus.DISCONNECTED;
|
|
63
|
-
isDisconnecting = false;
|
|
64
67
|
constructor(serverName, serverConfig, toolRegistry, promptRegistry, workspaceContext, debugMode) {
|
|
65
68
|
this.serverName = serverName;
|
|
66
69
|
this.serverConfig = serverConfig;
|
|
@@ -68,44 +71,27 @@ export class McpClient {
|
|
|
68
71
|
this.promptRegistry = promptRegistry;
|
|
69
72
|
this.workspaceContext = workspaceContext;
|
|
70
73
|
this.debugMode = debugMode;
|
|
71
|
-
this.client = new Client({
|
|
72
|
-
name: `gemini-cli-mcp-client-${this.serverName}`,
|
|
73
|
-
version: '0.0.1',
|
|
74
|
-
});
|
|
75
74
|
}
|
|
76
75
|
/**
|
|
77
76
|
* Connects to the MCP server.
|
|
78
77
|
*/
|
|
79
78
|
async connect() {
|
|
80
|
-
this.
|
|
79
|
+
if (this.status !== MCPServerStatus.DISCONNECTED) {
|
|
80
|
+
throw new Error(`Can only connect when the client is disconnected, current state is ${this.status}`);
|
|
81
|
+
}
|
|
81
82
|
this.updateStatus(MCPServerStatus.CONNECTING);
|
|
82
83
|
try {
|
|
83
|
-
this.
|
|
84
|
+
this.client = await connectToMcpServer(this.serverName, this.serverConfig, this.debugMode, this.workspaceContext);
|
|
85
|
+
const originalOnError = this.client.onerror;
|
|
84
86
|
this.client.onerror = (error) => {
|
|
85
|
-
if (this.
|
|
87
|
+
if (this.status !== MCPServerStatus.CONNECTED) {
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
88
|
-
|
|
90
|
+
if (originalOnError)
|
|
91
|
+
originalOnError(error);
|
|
92
|
+
coreEvents.emitFeedback('error', `MCP ERROR (${this.serverName})`, error);
|
|
89
93
|
this.updateStatus(MCPServerStatus.DISCONNECTED);
|
|
90
94
|
};
|
|
91
|
-
this.client.registerCapabilities({
|
|
92
|
-
roots: {},
|
|
93
|
-
});
|
|
94
|
-
this.client.setRequestHandler(ListRootsRequestSchema, async () => {
|
|
95
|
-
const roots = [];
|
|
96
|
-
for (const dir of this.workspaceContext.getDirectories()) {
|
|
97
|
-
roots.push({
|
|
98
|
-
uri: pathToFileURL(dir).toString(),
|
|
99
|
-
name: basename(dir),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
roots,
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
await this.client.connect(this.transport, {
|
|
107
|
-
timeout: this.serverConfig.timeout,
|
|
108
|
-
});
|
|
109
95
|
this.updateStatus(MCPServerStatus.CONNECTED);
|
|
110
96
|
}
|
|
111
97
|
catch (error) {
|
|
@@ -116,28 +102,36 @@ export class McpClient {
|
|
|
116
102
|
/**
|
|
117
103
|
* Discovers tools and prompts from the MCP server.
|
|
118
104
|
*/
|
|
119
|
-
async discover() {
|
|
120
|
-
|
|
121
|
-
throw new Error('Client is not connected.');
|
|
122
|
-
}
|
|
105
|
+
async discover(cliConfig) {
|
|
106
|
+
this.assertConnected();
|
|
123
107
|
const prompts = await this.discoverPrompts();
|
|
124
|
-
const tools = await this.discoverTools();
|
|
108
|
+
const tools = await this.discoverTools(cliConfig);
|
|
125
109
|
if (prompts.length === 0 && tools.length === 0) {
|
|
126
110
|
throw new Error('No prompts or tools found on the server.');
|
|
127
111
|
}
|
|
128
112
|
for (const tool of tools) {
|
|
129
113
|
this.toolRegistry.registerTool(tool);
|
|
130
114
|
}
|
|
115
|
+
this.toolRegistry.sortTools();
|
|
131
116
|
}
|
|
132
117
|
/**
|
|
133
118
|
* Disconnects from the MCP server.
|
|
134
119
|
*/
|
|
135
120
|
async disconnect() {
|
|
136
|
-
this.
|
|
121
|
+
if (this.status !== MCPServerStatus.CONNECTED) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.toolRegistry.removeMcpToolsByServer(this.serverName);
|
|
125
|
+
this.promptRegistry.removePromptsByServer(this.serverName);
|
|
126
|
+
this.updateStatus(MCPServerStatus.DISCONNECTING);
|
|
127
|
+
const client = this.client;
|
|
128
|
+
this.client = undefined;
|
|
137
129
|
if (this.transport) {
|
|
138
130
|
await this.transport.close();
|
|
139
131
|
}
|
|
140
|
-
|
|
132
|
+
if (client) {
|
|
133
|
+
await client.close();
|
|
134
|
+
}
|
|
141
135
|
this.updateStatus(MCPServerStatus.DISCONNECTED);
|
|
142
136
|
}
|
|
143
137
|
/**
|
|
@@ -150,15 +144,22 @@ export class McpClient {
|
|
|
150
144
|
this.status = status;
|
|
151
145
|
updateMCPServerStatus(this.serverName, status);
|
|
152
146
|
}
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
assertConnected() {
|
|
148
|
+
if (this.status !== MCPServerStatus.CONNECTED) {
|
|
149
|
+
throw new Error(`Client is not connected, must connect before interacting with the server. Current state is ${this.status}`);
|
|
150
|
+
}
|
|
155
151
|
}
|
|
156
|
-
async discoverTools() {
|
|
157
|
-
|
|
152
|
+
async discoverTools(cliConfig) {
|
|
153
|
+
this.assertConnected();
|
|
154
|
+
return discoverTools(this.serverName, this.serverConfig, this.client, cliConfig, this.toolRegistry.getMessageBus());
|
|
158
155
|
}
|
|
159
156
|
async discoverPrompts() {
|
|
157
|
+
this.assertConnected();
|
|
160
158
|
return discoverPrompts(this.serverName, this.client, this.promptRegistry);
|
|
161
159
|
}
|
|
160
|
+
getServerConfig() {
|
|
161
|
+
return this.serverConfig;
|
|
162
|
+
}
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
164
165
|
* Map to track the status of each MCP server within the core package
|
|
@@ -249,27 +250,21 @@ function extractWWWAuthenticateHeader(errorString) {
|
|
|
249
250
|
*/
|
|
250
251
|
async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate) {
|
|
251
252
|
try {
|
|
252
|
-
|
|
253
|
+
debugLogger.log(`🔐 '${mcpServerName}' requires OAuth authentication`);
|
|
253
254
|
// Always try to parse the resource metadata URI from the www-authenticate header
|
|
254
255
|
let oauthConfig;
|
|
255
256
|
const resourceMetadataUri = OAuthUtils.parseWWWAuthenticateHeader(wwwAuthenticate);
|
|
256
257
|
if (resourceMetadataUri) {
|
|
257
258
|
oauthConfig = await OAuthUtils.discoverOAuthConfig(resourceMetadataUri);
|
|
258
259
|
}
|
|
259
|
-
else if (mcpServerConfig
|
|
260
|
-
// Fallback: try to discover OAuth config from the base URL
|
|
261
|
-
const
|
|
262
|
-
const baseUrl = `${
|
|
263
|
-
oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
264
|
-
}
|
|
265
|
-
else if (mcpServerConfig.httpUrl) {
|
|
266
|
-
// Fallback: try to discover OAuth config from the base URL for HTTP
|
|
267
|
-
const httpUrl = new URL(mcpServerConfig.httpUrl);
|
|
268
|
-
const baseUrl = `${httpUrl.protocol}//${httpUrl.host}`;
|
|
260
|
+
else if (hasNetworkTransport(mcpServerConfig)) {
|
|
261
|
+
// Fallback: try to discover OAuth config from the base URL
|
|
262
|
+
const serverUrl = new URL(mcpServerConfig.httpUrl || mcpServerConfig.url);
|
|
263
|
+
const baseUrl = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
269
264
|
oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
270
265
|
}
|
|
271
266
|
if (!oauthConfig) {
|
|
272
|
-
|
|
267
|
+
coreEvents.emitFeedback('error', `Could not configure OAuth for '${mcpServerName}' - please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
273
268
|
return false;
|
|
274
269
|
}
|
|
275
270
|
// OAuth configuration discovered - proceed with authentication
|
|
@@ -283,16 +278,61 @@ async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthentic
|
|
|
283
278
|
// Perform OAuth authentication
|
|
284
279
|
// Pass the server URL for proper discovery
|
|
285
280
|
const serverUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
281
|
+
debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
282
|
+
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
283
|
+
await authProvider.authenticate(mcpServerName, oauthAuthConfig, serverUrl);
|
|
284
|
+
debugLogger.log(`OAuth authentication successful for server '${mcpServerName}'`);
|
|
289
285
|
return true;
|
|
290
286
|
}
|
|
291
287
|
catch (error) {
|
|
292
|
-
|
|
288
|
+
coreEvents.emitFeedback('error', `Failed to handle automatic OAuth for server '${mcpServerName}': ${getErrorMessage(error)}`, error);
|
|
293
289
|
return false;
|
|
294
290
|
}
|
|
295
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Create RequestInit for TransportOptions.
|
|
294
|
+
*
|
|
295
|
+
* @param mcpServerConfig The MCP server configuration
|
|
296
|
+
* @param headers Additional headers
|
|
297
|
+
*/
|
|
298
|
+
function createTransportRequestInit(mcpServerConfig, headers) {
|
|
299
|
+
return {
|
|
300
|
+
headers: {
|
|
301
|
+
...mcpServerConfig.headers,
|
|
302
|
+
...headers,
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create an AuthProvider for the MCP Transport.
|
|
308
|
+
*
|
|
309
|
+
* @param mcpServerConfig The MCP server configuration
|
|
310
|
+
*/
|
|
311
|
+
function createAuthProvider(mcpServerConfig) {
|
|
312
|
+
if (mcpServerConfig.authProviderType ===
|
|
313
|
+
AuthProviderType.SERVICE_ACCOUNT_IMPERSONATION) {
|
|
314
|
+
return new ServiceAccountImpersonationProvider(mcpServerConfig);
|
|
315
|
+
}
|
|
316
|
+
if (mcpServerConfig.authProviderType === AuthProviderType.GOOGLE_CREDENTIALS) {
|
|
317
|
+
return new GoogleCredentialProvider(mcpServerConfig);
|
|
318
|
+
}
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Create a transport for URL based servers (remote servers).
|
|
323
|
+
*
|
|
324
|
+
* @param mcpServerConfig The MCP server configuration
|
|
325
|
+
* @param transportOptions The transport options
|
|
326
|
+
*/
|
|
327
|
+
function createUrlTransport(mcpServerConfig, transportOptions) {
|
|
328
|
+
if (mcpServerConfig.httpUrl) {
|
|
329
|
+
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), transportOptions);
|
|
330
|
+
}
|
|
331
|
+
if (mcpServerConfig.url) {
|
|
332
|
+
return new SSEClientTransport(new URL(mcpServerConfig.url), transportOptions);
|
|
333
|
+
}
|
|
334
|
+
throw new Error('No URL configured for MCP Server');
|
|
335
|
+
}
|
|
296
336
|
/**
|
|
297
337
|
* Create a transport with OAuth token for the given server configuration.
|
|
298
338
|
*
|
|
@@ -303,33 +343,16 @@ async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthentic
|
|
|
303
343
|
*/
|
|
304
344
|
async function createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken) {
|
|
305
345
|
try {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
};
|
|
316
|
-
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), oauthTransportOptions);
|
|
317
|
-
}
|
|
318
|
-
else if (mcpServerConfig.url) {
|
|
319
|
-
// Create SSE transport with OAuth token in Authorization header
|
|
320
|
-
return new SSEClientTransport(new URL(mcpServerConfig.url), {
|
|
321
|
-
requestInit: {
|
|
322
|
-
headers: {
|
|
323
|
-
...mcpServerConfig.headers,
|
|
324
|
-
Authorization: `Bearer ${accessToken}`,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
return null;
|
|
346
|
+
const headers = {
|
|
347
|
+
Authorization: `Bearer ${accessToken}`,
|
|
348
|
+
};
|
|
349
|
+
const transportOptions = {
|
|
350
|
+
requestInit: createTransportRequestInit(mcpServerConfig, headers),
|
|
351
|
+
};
|
|
352
|
+
return createUrlTransport(mcpServerConfig, transportOptions);
|
|
330
353
|
}
|
|
331
354
|
catch (error) {
|
|
332
|
-
|
|
355
|
+
coreEvents.emitFeedback('error', `Failed to create OAuth transport for server '${mcpServerName}': ${getErrorMessage(error)}`, error);
|
|
333
356
|
return null;
|
|
334
357
|
}
|
|
335
358
|
}
|
|
@@ -343,11 +366,11 @@ async function createTransportWithOAuth(mcpServerName, mcpServerConfig, accessTo
|
|
|
343
366
|
* @param toolRegistry The central registry where discovered tools will be registered.
|
|
344
367
|
* @returns A promise that resolves when the discovery process has been attempted for all servers.
|
|
345
368
|
*/
|
|
346
|
-
export async function discoverMcpTools(mcpServers, mcpServerCommand, toolRegistry, promptRegistry, debugMode, workspaceContext) {
|
|
369
|
+
export async function discoverMcpTools(mcpServers, mcpServerCommand, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig) {
|
|
347
370
|
mcpDiscoveryState = MCPDiscoveryState.IN_PROGRESS;
|
|
348
371
|
try {
|
|
349
372
|
mcpServers = populateMcpServerCommand(mcpServers, mcpServerCommand);
|
|
350
|
-
const discoveryPromises = Object.entries(mcpServers).map(([mcpServerName, mcpServerConfig]) => connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext));
|
|
373
|
+
const discoveryPromises = Object.entries(mcpServers).map(([mcpServerName, mcpServerConfig]) => connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig));
|
|
351
374
|
await Promise.all(discoveryPromises);
|
|
352
375
|
}
|
|
353
376
|
finally {
|
|
@@ -380,18 +403,18 @@ export function populateMcpServerCommand(mcpServers, mcpServerCommand) {
|
|
|
380
403
|
* @param toolRegistry The registry to register discovered tools with
|
|
381
404
|
* @returns Promise that resolves when discovery is complete
|
|
382
405
|
*/
|
|
383
|
-
export async function connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext) {
|
|
406
|
+
export async function connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig) {
|
|
384
407
|
updateMCPServerStatus(mcpServerName, MCPServerStatus.CONNECTING);
|
|
385
408
|
let mcpClient;
|
|
386
409
|
try {
|
|
387
410
|
mcpClient = await connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, workspaceContext);
|
|
388
411
|
mcpClient.onerror = (error) => {
|
|
389
|
-
|
|
412
|
+
coreEvents.emitFeedback('error', `MCP ERROR (${mcpServerName}):`, error);
|
|
390
413
|
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
|
|
391
414
|
};
|
|
392
415
|
// Attempt to discover both prompts and tools
|
|
393
416
|
const prompts = await discoverPrompts(mcpServerName, mcpClient, promptRegistry);
|
|
394
|
-
const tools = await discoverTools(mcpServerName, mcpServerConfig, mcpClient);
|
|
417
|
+
const tools = await discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig, toolRegistry.getMessageBus());
|
|
395
418
|
// If we have neither prompts nor tools, it's a failed discovery
|
|
396
419
|
if (prompts.length === 0 && tools.length === 0) {
|
|
397
420
|
throw new Error('No prompts or tools found on the server.');
|
|
@@ -402,68 +425,16 @@ export async function connectAndDiscover(mcpServerName, mcpServerConfig, toolReg
|
|
|
402
425
|
for (const tool of tools) {
|
|
403
426
|
toolRegistry.registerTool(tool);
|
|
404
427
|
}
|
|
428
|
+
toolRegistry.sortTools();
|
|
405
429
|
}
|
|
406
430
|
catch (error) {
|
|
407
431
|
if (mcpClient) {
|
|
408
432
|
mcpClient.close();
|
|
409
433
|
}
|
|
410
|
-
|
|
434
|
+
coreEvents.emitFeedback('error', `Error connecting to MCP server '${mcpServerName}': ${getErrorMessage(error)}`, error);
|
|
411
435
|
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
|
|
412
436
|
}
|
|
413
437
|
}
|
|
414
|
-
/**
|
|
415
|
-
* Recursively validates that a JSON schema and all its nested properties and
|
|
416
|
-
* items have a `type` defined.
|
|
417
|
-
*
|
|
418
|
-
* @param schema The JSON schema to validate.
|
|
419
|
-
* @returns `true` if the schema is valid, `false` otherwise.
|
|
420
|
-
*
|
|
421
|
-
* @visiblefortesting
|
|
422
|
-
*/
|
|
423
|
-
export function hasValidTypes(schema) {
|
|
424
|
-
if (typeof schema !== 'object' || schema === null) {
|
|
425
|
-
// Not a schema object we can validate, or not a schema at all.
|
|
426
|
-
// Treat as valid as it has no properties to be invalid.
|
|
427
|
-
return true;
|
|
428
|
-
}
|
|
429
|
-
const s = schema;
|
|
430
|
-
if (!s['type']) {
|
|
431
|
-
// These keywords contain an array of schemas that should be validated.
|
|
432
|
-
//
|
|
433
|
-
// If no top level type was given, then they must each have a type.
|
|
434
|
-
let hasSubSchema = false;
|
|
435
|
-
const schemaArrayKeywords = ['anyOf', 'allOf', 'oneOf'];
|
|
436
|
-
for (const keyword of schemaArrayKeywords) {
|
|
437
|
-
const subSchemas = s[keyword];
|
|
438
|
-
if (Array.isArray(subSchemas)) {
|
|
439
|
-
hasSubSchema = true;
|
|
440
|
-
for (const subSchema of subSchemas) {
|
|
441
|
-
if (!hasValidTypes(subSchema)) {
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
// If the node itself is missing a type and had no subschemas, then it isn't valid.
|
|
448
|
-
if (!hasSubSchema)
|
|
449
|
-
return false;
|
|
450
|
-
}
|
|
451
|
-
if (s['type'] === 'object' && s['properties']) {
|
|
452
|
-
if (typeof s['properties'] === 'object' && s['properties'] !== null) {
|
|
453
|
-
for (const prop of Object.values(s['properties'])) {
|
|
454
|
-
if (!hasValidTypes(prop)) {
|
|
455
|
-
return false;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
if (s['type'] === 'array' && s['items']) {
|
|
461
|
-
if (!hasValidTypes(s['items'])) {
|
|
462
|
-
return false;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return true;
|
|
466
|
-
}
|
|
467
438
|
/**
|
|
468
439
|
* Discovers and sanitizes tools from a connected MCP client.
|
|
469
440
|
* It retrieves function declarations from the client, filters out disabled tools,
|
|
@@ -472,33 +443,29 @@ export function hasValidTypes(schema) {
|
|
|
472
443
|
* @param mcpServerName The name of the MCP server.
|
|
473
444
|
* @param mcpServerConfig The configuration for the MCP server.
|
|
474
445
|
* @param mcpClient The active MCP client instance.
|
|
446
|
+
* @param cliConfig The CLI configuration object.
|
|
447
|
+
* @param messageBus Optional message bus for policy engine integration.
|
|
475
448
|
* @returns A promise that resolves to an array of discovered and enabled tools.
|
|
476
449
|
* @throws An error if no enabled tools are found or if the server provides invalid function declarations.
|
|
477
450
|
*/
|
|
478
|
-
export async function discoverTools(mcpServerName, mcpServerConfig, mcpClient) {
|
|
451
|
+
export async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig, messageBus) {
|
|
479
452
|
try {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (!Array.isArray(tool.functionDeclarations)) {
|
|
483
|
-
// This is a valid case for a prompt-only server
|
|
453
|
+
// Only request tools if the server supports them.
|
|
454
|
+
if (mcpClient.getServerCapabilities()?.tools == null)
|
|
484
455
|
return [];
|
|
485
|
-
}
|
|
456
|
+
const response = await mcpClient.listTools({});
|
|
486
457
|
const discoveredTools = [];
|
|
487
|
-
for (const
|
|
458
|
+
for (const toolDef of response.tools) {
|
|
488
459
|
try {
|
|
489
|
-
if (!isEnabled(
|
|
460
|
+
if (!isEnabled(toolDef, mcpServerName, mcpServerConfig)) {
|
|
490
461
|
continue;
|
|
491
462
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
`issue with the owner of the MCP server.`);
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
discoveredTools.push(new DiscoveredMCPTool(mcpCallableTool, mcpServerName, funcDecl.name, funcDecl.description ?? '', funcDecl.parametersJsonSchema ?? { type: 'object', properties: {} }, mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC, mcpServerConfig.trust));
|
|
463
|
+
const mcpCallableTool = new McpCallableTool(mcpClient, toolDef, mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC);
|
|
464
|
+
const tool = new DiscoveredMCPTool(mcpCallableTool, mcpServerName, toolDef.name, toolDef.description ?? '', toolDef.inputSchema ?? { type: 'object', properties: {} }, mcpServerConfig.trust, undefined, cliConfig, mcpServerConfig.extension?.name, mcpServerConfig.extension?.id, messageBus);
|
|
465
|
+
discoveredTools.push(tool);
|
|
499
466
|
}
|
|
500
467
|
catch (error) {
|
|
501
|
-
|
|
468
|
+
coreEvents.emitFeedback('error', `Error discovering tool: '${toolDef.name}' from MCP server '${mcpServerName}': ${error.message}`, error);
|
|
502
469
|
}
|
|
503
470
|
}
|
|
504
471
|
return discoveredTools;
|
|
@@ -506,11 +473,69 @@ export async function discoverTools(mcpServerName, mcpServerConfig, mcpClient) {
|
|
|
506
473
|
catch (error) {
|
|
507
474
|
if (error instanceof Error &&
|
|
508
475
|
!error.message?.includes('Method not found')) {
|
|
509
|
-
|
|
476
|
+
coreEvents.emitFeedback('error', `Error discovering tools from ${mcpServerName}: ${getErrorMessage(error)}`, error);
|
|
510
477
|
}
|
|
511
478
|
return [];
|
|
512
479
|
}
|
|
513
480
|
}
|
|
481
|
+
class McpCallableTool {
|
|
482
|
+
client;
|
|
483
|
+
toolDef;
|
|
484
|
+
timeout;
|
|
485
|
+
constructor(client, toolDef, timeout) {
|
|
486
|
+
this.client = client;
|
|
487
|
+
this.toolDef = toolDef;
|
|
488
|
+
this.timeout = timeout;
|
|
489
|
+
}
|
|
490
|
+
async tool() {
|
|
491
|
+
return {
|
|
492
|
+
functionDeclarations: [
|
|
493
|
+
{
|
|
494
|
+
name: this.toolDef.name,
|
|
495
|
+
description: this.toolDef.description,
|
|
496
|
+
parametersJsonSchema: this.toolDef.inputSchema,
|
|
497
|
+
},
|
|
498
|
+
],
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async callTool(functionCalls) {
|
|
502
|
+
// We only expect one function call at a time for MCP tools in this context
|
|
503
|
+
if (functionCalls.length !== 1) {
|
|
504
|
+
throw new Error('McpCallableTool only supports single function call');
|
|
505
|
+
}
|
|
506
|
+
const call = functionCalls[0];
|
|
507
|
+
try {
|
|
508
|
+
const result = await this.client.callTool({
|
|
509
|
+
name: call.name,
|
|
510
|
+
arguments: call.args,
|
|
511
|
+
}, undefined, { timeout: this.timeout });
|
|
512
|
+
return [
|
|
513
|
+
{
|
|
514
|
+
functionResponse: {
|
|
515
|
+
name: call.name,
|
|
516
|
+
response: result,
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
];
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
// Return error in the format expected by DiscoveredMCPTool
|
|
523
|
+
return [
|
|
524
|
+
{
|
|
525
|
+
functionResponse: {
|
|
526
|
+
name: call.name,
|
|
527
|
+
response: {
|
|
528
|
+
error: {
|
|
529
|
+
message: error instanceof Error ? error.message : String(error),
|
|
530
|
+
isError: true,
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
];
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
514
539
|
/**
|
|
515
540
|
* Discovers and logs prompts from a connected MCP client.
|
|
516
541
|
* It retrieves prompt declarations from the client and logs their names.
|
|
@@ -523,7 +548,7 @@ export async function discoverPrompts(mcpServerName, mcpClient, promptRegistry)
|
|
|
523
548
|
// Only request prompts if the server supports them.
|
|
524
549
|
if (mcpClient.getServerCapabilities()?.prompts == null)
|
|
525
550
|
return [];
|
|
526
|
-
const response = await mcpClient.
|
|
551
|
+
const response = await mcpClient.listPrompts({});
|
|
527
552
|
for (const prompt of response.prompts) {
|
|
528
553
|
promptRegistry.registerPrompt({
|
|
529
554
|
...prompt,
|
|
@@ -538,7 +563,7 @@ export async function discoverPrompts(mcpServerName, mcpClient, promptRegistry)
|
|
|
538
563
|
// Don't log an error if the method is not found, which is a common case.
|
|
539
564
|
if (error instanceof Error &&
|
|
540
565
|
!error.message?.includes('Method not found')) {
|
|
541
|
-
|
|
566
|
+
coreEvents.emitFeedback('error', `Error discovering prompts from ${mcpServerName}: ${getErrorMessage(error)}`, error);
|
|
542
567
|
}
|
|
543
568
|
return [];
|
|
544
569
|
}
|
|
@@ -554,23 +579,35 @@ export async function discoverPrompts(mcpServerName, mcpClient, promptRegistry)
|
|
|
554
579
|
*/
|
|
555
580
|
export async function invokeMcpPrompt(mcpServerName, mcpClient, promptName, promptParams) {
|
|
556
581
|
try {
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
582
|
+
const sanitizedParams = {};
|
|
583
|
+
for (const [key, value] of Object.entries(promptParams)) {
|
|
584
|
+
if (value !== undefined && value !== null) {
|
|
585
|
+
sanitizedParams[key] = String(value);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const response = await mcpClient.getPrompt({
|
|
589
|
+
name: promptName,
|
|
590
|
+
arguments: sanitizedParams,
|
|
591
|
+
});
|
|
564
592
|
return response;
|
|
565
593
|
}
|
|
566
594
|
catch (error) {
|
|
567
595
|
if (error instanceof Error &&
|
|
568
596
|
!error.message?.includes('Method not found')) {
|
|
569
|
-
|
|
597
|
+
coreEvents.emitFeedback('error', `Error invoking prompt '${promptName}' from ${mcpServerName} ${promptParams}: ${getErrorMessage(error)}`, error);
|
|
570
598
|
}
|
|
571
599
|
throw error;
|
|
572
600
|
}
|
|
573
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* @visiblefortesting
|
|
604
|
+
* Checks if the MCP server configuration has a network transport URL (SSE or HTTP).
|
|
605
|
+
* @param config The MCP server configuration.
|
|
606
|
+
* @returns True if a `url` or `httpUrl` is present, false otherwise.
|
|
607
|
+
*/
|
|
608
|
+
export function hasNetworkTransport(config) {
|
|
609
|
+
return !!(config.url || config.httpUrl);
|
|
610
|
+
}
|
|
574
611
|
/**
|
|
575
612
|
* Creates and connects an MCP client to a server based on the provided configuration.
|
|
576
613
|
* It determines the appropriate transport (Stdio, SSE, or Streamable HTTP) and
|
|
@@ -627,17 +664,6 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
627
664
|
unlistenDirectories?.();
|
|
628
665
|
unlistenDirectories = undefined;
|
|
629
666
|
};
|
|
630
|
-
// patch Client.callTool to use request timeout as genai McpCallTool.callTool does not do it
|
|
631
|
-
// TODO: remove this hack once GenAI SDK does callTool with request options
|
|
632
|
-
if ('callTool' in mcpClient) {
|
|
633
|
-
const origCallTool = mcpClient.callTool.bind(mcpClient);
|
|
634
|
-
mcpClient.callTool = function (params, resultSchema, options) {
|
|
635
|
-
return origCallTool(params, resultSchema, {
|
|
636
|
-
...options,
|
|
637
|
-
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
638
|
-
});
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
667
|
try {
|
|
642
668
|
const transport = await createTransport(mcpServerName, mcpServerConfig, debugMode);
|
|
643
669
|
try {
|
|
@@ -654,26 +680,27 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
654
680
|
catch (error) {
|
|
655
681
|
// Check if this is a 401 error that might indicate OAuth is required
|
|
656
682
|
const errorString = String(error);
|
|
657
|
-
if (errorString.includes('401') &&
|
|
658
|
-
(mcpServerConfig.httpUrl || mcpServerConfig.url)) {
|
|
683
|
+
if (errorString.includes('401') && hasNetworkTransport(mcpServerConfig)) {
|
|
659
684
|
mcpServerRequiresOAuth.set(mcpServerName, true);
|
|
660
685
|
// Only trigger automatic OAuth discovery for HTTP servers or when OAuth is explicitly configured
|
|
661
686
|
// For SSE servers, we should not trigger new OAuth flows automatically
|
|
662
687
|
const shouldTriggerOAuth = mcpServerConfig.httpUrl || mcpServerConfig.oauth?.enabled;
|
|
663
688
|
if (!shouldTriggerOAuth) {
|
|
664
689
|
// For SSE servers without explicit OAuth config, if a token was found but rejected, report it accurately.
|
|
665
|
-
const
|
|
690
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
691
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
666
692
|
if (credentials) {
|
|
667
|
-
const
|
|
693
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
694
|
+
const hasStoredTokens = await authProvider.getValidToken(mcpServerName, {
|
|
668
695
|
// Pass client ID if available
|
|
669
696
|
clientId: credentials.clientId,
|
|
670
697
|
});
|
|
671
698
|
if (hasStoredTokens) {
|
|
672
|
-
|
|
699
|
+
coreEvents.emitFeedback('error', `Stored OAuth token for SSE server '${mcpServerName}' was rejected. ` +
|
|
673
700
|
`Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
674
701
|
}
|
|
675
702
|
else {
|
|
676
|
-
|
|
703
|
+
coreEvents.emitFeedback('error', `401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
677
704
|
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
678
705
|
}
|
|
679
706
|
}
|
|
@@ -683,39 +710,44 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
683
710
|
// Try to extract www-authenticate header from the error
|
|
684
711
|
let wwwAuthenticate = extractWWWAuthenticateHeader(errorString);
|
|
685
712
|
// If we didn't get the header from the error string, try to get it from the server
|
|
686
|
-
if (!wwwAuthenticate && mcpServerConfig
|
|
687
|
-
|
|
713
|
+
if (!wwwAuthenticate && hasNetworkTransport(mcpServerConfig)) {
|
|
714
|
+
debugLogger.log(`No www-authenticate header in error, trying to fetch it from server...`);
|
|
688
715
|
try {
|
|
689
|
-
const
|
|
716
|
+
const urlToFetch = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
717
|
+
const response = await fetch(urlToFetch, {
|
|
690
718
|
method: 'HEAD',
|
|
691
719
|
headers: {
|
|
692
|
-
Accept:
|
|
720
|
+
Accept: mcpServerConfig.httpUrl
|
|
721
|
+
? 'application/json'
|
|
722
|
+
: 'text/event-stream',
|
|
693
723
|
},
|
|
694
724
|
signal: AbortSignal.timeout(5000),
|
|
695
725
|
});
|
|
696
726
|
if (response.status === 401) {
|
|
697
727
|
wwwAuthenticate = response.headers.get('www-authenticate');
|
|
698
728
|
if (wwwAuthenticate) {
|
|
699
|
-
|
|
729
|
+
debugLogger.log(`Found www-authenticate header from server: ${wwwAuthenticate}`);
|
|
700
730
|
}
|
|
701
731
|
}
|
|
702
732
|
}
|
|
703
733
|
catch (fetchError) {
|
|
704
|
-
|
|
734
|
+
debugLogger.debug(`Failed to fetch www-authenticate header: ${getErrorMessage(fetchError)}`);
|
|
705
735
|
}
|
|
706
736
|
}
|
|
707
737
|
if (wwwAuthenticate) {
|
|
708
|
-
|
|
738
|
+
debugLogger.log(`Received 401 with www-authenticate header: ${wwwAuthenticate}`);
|
|
709
739
|
// Try automatic OAuth discovery and authentication
|
|
710
740
|
const oauthSuccess = await handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate);
|
|
711
741
|
if (oauthSuccess) {
|
|
712
742
|
// Retry connection with OAuth token
|
|
713
|
-
|
|
743
|
+
debugLogger.log(`Retrying connection to '${mcpServerName}' with OAuth token...`);
|
|
714
744
|
// Get the valid token - we need to create a proper OAuth config
|
|
715
745
|
// The token should already be available from the authentication process
|
|
716
|
-
const
|
|
746
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
747
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
717
748
|
if (credentials) {
|
|
718
|
-
const
|
|
749
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
750
|
+
const accessToken = await authProvider.getValidToken(mcpServerName, {
|
|
719
751
|
// Pass client ID if available
|
|
720
752
|
clientId: credentials.clientId,
|
|
721
753
|
});
|
|
@@ -723,35 +755,25 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
723
755
|
// Create transport with OAuth token
|
|
724
756
|
const oauthTransport = await createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken);
|
|
725
757
|
if (oauthTransport) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
return mcpClient;
|
|
732
|
-
}
|
|
733
|
-
catch (retryError) {
|
|
734
|
-
console.error(`Failed to connect with OAuth token: ${getErrorMessage(retryError)}`);
|
|
735
|
-
throw retryError;
|
|
736
|
-
}
|
|
758
|
+
await mcpClient.connect(oauthTransport, {
|
|
759
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
760
|
+
});
|
|
761
|
+
// Connection successful with OAuth
|
|
762
|
+
return mcpClient;
|
|
737
763
|
}
|
|
738
764
|
else {
|
|
739
|
-
console.error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
740
765
|
throw new Error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
741
766
|
}
|
|
742
767
|
}
|
|
743
768
|
else {
|
|
744
|
-
console.error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
745
769
|
throw new Error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
746
770
|
}
|
|
747
771
|
}
|
|
748
772
|
else {
|
|
749
|
-
console.error(`Failed to get credentials for server '${mcpServerName}' after successful OAuth authentication`);
|
|
750
773
|
throw new Error(`Failed to get credentials for server '${mcpServerName}' after successful OAuth authentication`);
|
|
751
774
|
}
|
|
752
775
|
}
|
|
753
776
|
else {
|
|
754
|
-
console.error(`Failed to handle automatic OAuth for server '${mcpServerName}'`);
|
|
755
777
|
throw new Error(`Failed to handle automatic OAuth for server '${mcpServerName}'`);
|
|
756
778
|
}
|
|
757
779
|
}
|
|
@@ -761,96 +783,84 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
761
783
|
// For SSE servers, we should not trigger new OAuth flows automatically
|
|
762
784
|
const shouldTryDiscovery = mcpServerConfig.httpUrl || mcpServerConfig.oauth?.enabled;
|
|
763
785
|
if (!shouldTryDiscovery) {
|
|
764
|
-
const
|
|
786
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
787
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
765
788
|
if (credentials) {
|
|
766
|
-
const
|
|
789
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
790
|
+
const hasStoredTokens = await authProvider.getValidToken(mcpServerName, {
|
|
767
791
|
// Pass client ID if available
|
|
768
792
|
clientId: credentials.clientId,
|
|
769
793
|
});
|
|
770
794
|
if (hasStoredTokens) {
|
|
771
|
-
|
|
795
|
+
coreEvents.emitFeedback('error', `Stored OAuth token for SSE server '${mcpServerName}' was rejected. ` +
|
|
772
796
|
`Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
773
797
|
}
|
|
774
798
|
else {
|
|
775
|
-
|
|
799
|
+
coreEvents.emitFeedback('error', `401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
776
800
|
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
777
801
|
}
|
|
778
802
|
}
|
|
779
803
|
throw new Error(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
780
804
|
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
781
805
|
}
|
|
782
|
-
// For SSE servers, try to discover OAuth configuration from the base URL
|
|
783
|
-
|
|
784
|
-
if (mcpServerConfig
|
|
785
|
-
const
|
|
786
|
-
const baseUrl = `${
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
catch (retryError) {
|
|
823
|
-
console.error(`Failed to connect with OAuth token: ${getErrorMessage(retryError)}`);
|
|
824
|
-
throw retryError;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
else {
|
|
828
|
-
console.error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
829
|
-
throw new Error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
830
|
-
}
|
|
806
|
+
// For SSE/HTTP servers, try to discover OAuth configuration from the base URL
|
|
807
|
+
debugLogger.log(`🔍 Attempting OAuth discovery for '${mcpServerName}'...`);
|
|
808
|
+
if (hasNetworkTransport(mcpServerConfig)) {
|
|
809
|
+
const serverUrl = new URL(mcpServerConfig.httpUrl || mcpServerConfig.url);
|
|
810
|
+
const baseUrl = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
811
|
+
// Try to discover OAuth configuration from the base URL
|
|
812
|
+
const oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
813
|
+
if (oauthConfig) {
|
|
814
|
+
debugLogger.log(`Discovered OAuth configuration from base URL for server '${mcpServerName}'`);
|
|
815
|
+
// Create OAuth configuration for authentication
|
|
816
|
+
const oauthAuthConfig = {
|
|
817
|
+
enabled: true,
|
|
818
|
+
authorizationUrl: oauthConfig.authorizationUrl,
|
|
819
|
+
tokenUrl: oauthConfig.tokenUrl,
|
|
820
|
+
scopes: oauthConfig.scopes || [],
|
|
821
|
+
};
|
|
822
|
+
// Perform OAuth authentication
|
|
823
|
+
// Pass the server URL for proper discovery
|
|
824
|
+
const authServerUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
825
|
+
debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
826
|
+
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
827
|
+
await authProvider.authenticate(mcpServerName, oauthAuthConfig, authServerUrl);
|
|
828
|
+
// Retry connection with OAuth token
|
|
829
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
830
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
831
|
+
if (credentials) {
|
|
832
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
833
|
+
const accessToken = await authProvider.getValidToken(mcpServerName, {
|
|
834
|
+
// Pass client ID if available
|
|
835
|
+
clientId: credentials.clientId,
|
|
836
|
+
});
|
|
837
|
+
if (accessToken) {
|
|
838
|
+
// Create transport with OAuth token
|
|
839
|
+
const oauthTransport = await createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken);
|
|
840
|
+
if (oauthTransport) {
|
|
841
|
+
await mcpClient.connect(oauthTransport, {
|
|
842
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
843
|
+
});
|
|
844
|
+
// Connection successful with OAuth
|
|
845
|
+
return mcpClient;
|
|
831
846
|
}
|
|
832
847
|
else {
|
|
833
|
-
|
|
834
|
-
throw new Error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
848
|
+
throw new Error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
835
849
|
}
|
|
836
850
|
}
|
|
837
851
|
else {
|
|
838
|
-
|
|
839
|
-
throw new Error(`Failed to get stored credentials for server '${mcpServerName}'`);
|
|
852
|
+
throw new Error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
840
853
|
}
|
|
841
854
|
}
|
|
842
855
|
else {
|
|
843
|
-
|
|
844
|
-
throw new Error(`OAuth configuration failed for '${mcpServerName}'. Please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
856
|
+
throw new Error(`Failed to get stored credentials for server '${mcpServerName}'`);
|
|
845
857
|
}
|
|
846
858
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
throw discoveryError;
|
|
859
|
+
else {
|
|
860
|
+
throw new Error(`OAuth configuration failed for '${mcpServerName}'. Please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
850
861
|
}
|
|
851
862
|
}
|
|
852
863
|
else {
|
|
853
|
-
console.error(`❌ '${mcpServerName}' requires authentication but no OAuth configuration found`);
|
|
854
864
|
throw new Error(`MCP server '${mcpServerName}' requires authentication. Please configure OAuth or check server settings.`);
|
|
855
865
|
}
|
|
856
866
|
}
|
|
@@ -877,80 +887,57 @@ export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMo
|
|
|
877
887
|
}
|
|
878
888
|
/** Visible for Testing */
|
|
879
889
|
export async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
if (mcpServerConfig.
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
890
|
+
const noUrl = !mcpServerConfig.url && !mcpServerConfig.httpUrl;
|
|
891
|
+
if (noUrl) {
|
|
892
|
+
if (mcpServerConfig.authProviderType === AuthProviderType.GOOGLE_CREDENTIALS) {
|
|
893
|
+
throw new Error(`URL must be provided in the config for Google Credentials provider`);
|
|
894
|
+
}
|
|
895
|
+
if (mcpServerConfig.authProviderType ===
|
|
896
|
+
AuthProviderType.SERVICE_ACCOUNT_IMPERSONATION) {
|
|
897
|
+
throw new Error(`No URL configured for ServiceAccountImpersonation MCP Server`);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
if (mcpServerConfig.httpUrl || mcpServerConfig.url) {
|
|
901
|
+
const authProvider = createAuthProvider(mcpServerConfig);
|
|
902
|
+
const headers = {};
|
|
903
|
+
if (authProvider === undefined) {
|
|
904
|
+
// Check if we have OAuth configuration or stored tokens
|
|
905
|
+
let accessToken = null;
|
|
906
|
+
let hasOAuthConfig = mcpServerConfig.oauth?.enabled;
|
|
907
|
+
if (hasOAuthConfig && mcpServerConfig.oauth) {
|
|
908
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
909
|
+
const mcpAuthProvider = new MCPOAuthProvider(tokenStorage);
|
|
910
|
+
accessToken = await mcpAuthProvider.getValidToken(mcpServerName, mcpServerConfig.oauth);
|
|
911
|
+
if (!accessToken) {
|
|
912
|
+
throw new Error(`MCP server '${mcpServerName}' requires OAuth authentication. ` +
|
|
913
|
+
`Please authenticate using the /mcp auth command.`);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
// Check if we have stored OAuth tokens for this server (from previous authentication)
|
|
918
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
919
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
920
|
+
if (credentials) {
|
|
921
|
+
const mcpAuthProvider = new MCPOAuthProvider(tokenStorage);
|
|
922
|
+
accessToken = await mcpAuthProvider.getValidToken(mcpServerName, {
|
|
923
|
+
// Pass client ID if available
|
|
924
|
+
clientId: credentials.clientId,
|
|
925
|
+
});
|
|
926
|
+
if (accessToken) {
|
|
927
|
+
hasOAuthConfig = true;
|
|
928
|
+
debugLogger.log(`Found stored OAuth token for server '${mcpServerName}'`);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (hasOAuthConfig && accessToken) {
|
|
933
|
+
headers['Authorization'] = `Bearer ${accessToken}`;
|
|
916
934
|
}
|
|
917
935
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
transportOptions.requestInit = {
|
|
924
|
-
headers: {
|
|
925
|
-
...mcpServerConfig.headers,
|
|
926
|
-
Authorization: `Bearer ${accessToken}`,
|
|
927
|
-
},
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
else if (mcpServerConfig.headers) {
|
|
931
|
-
transportOptions.requestInit = {
|
|
932
|
-
headers: mcpServerConfig.headers,
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), transportOptions);
|
|
936
|
-
}
|
|
937
|
-
if (mcpServerConfig.url) {
|
|
938
|
-
const transportOptions = {};
|
|
939
|
-
// Set up headers with OAuth token if available
|
|
940
|
-
if (hasOAuthConfig && accessToken) {
|
|
941
|
-
transportOptions.requestInit = {
|
|
942
|
-
headers: {
|
|
943
|
-
...mcpServerConfig.headers,
|
|
944
|
-
Authorization: `Bearer ${accessToken}`,
|
|
945
|
-
},
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
else if (mcpServerConfig.headers) {
|
|
949
|
-
transportOptions.requestInit = {
|
|
950
|
-
headers: mcpServerConfig.headers,
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
return new SSEClientTransport(new URL(mcpServerConfig.url), transportOptions);
|
|
936
|
+
const transportOptions = {
|
|
937
|
+
requestInit: createTransportRequestInit(mcpServerConfig, headers),
|
|
938
|
+
authProvider,
|
|
939
|
+
};
|
|
940
|
+
return createUrlTransport(mcpServerConfig, transportOptions);
|
|
954
941
|
}
|
|
955
942
|
if (mcpServerConfig.command) {
|
|
956
943
|
const transport = new StdioClientTransport({
|
|
@@ -966,7 +953,7 @@ export async function createTransport(mcpServerName, mcpServerConfig, debugMode)
|
|
|
966
953
|
if (debugMode) {
|
|
967
954
|
transport.stderr.on('data', (data) => {
|
|
968
955
|
const stderrStr = data.toString().trim();
|
|
969
|
-
|
|
956
|
+
debugLogger.debug(`[DEBUG] [MCP STDERR (${mcpServerName})]: `, stderrStr);
|
|
970
957
|
});
|
|
971
958
|
}
|
|
972
959
|
return transport;
|
|
@@ -976,7 +963,7 @@ export async function createTransport(mcpServerName, mcpServerConfig, debugMode)
|
|
|
976
963
|
/** Visible for testing */
|
|
977
964
|
export function isEnabled(funcDecl, mcpServerName, mcpServerConfig) {
|
|
978
965
|
if (!funcDecl.name) {
|
|
979
|
-
|
|
966
|
+
debugLogger.warn(`Discovered a function declaration without a name from MCP server '${mcpServerName}'. Skipping.`);
|
|
980
967
|
return false;
|
|
981
968
|
}
|
|
982
969
|
const { includeTools, excludeTools } = mcpServerConfig;
|