@hibanacloud/core 0.3.15
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/.last_build +0 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__mocks__/fs/promises.d.ts +11 -0
- package/dist/src/__mocks__/fs/promises.js +17 -0
- package/dist/src/__mocks__/fs/promises.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +12 -0
- package/dist/src/code_assist/codeAssist.js +31 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +74 -0
- package/dist/src/code_assist/converter.js +160 -0
- package/dist/src/code_assist/converter.js.map +1 -0
- package/dist/src/code_assist/converter.test.d.ts +6 -0
- package/dist/src/code_assist/converter.test.js +372 -0
- package/dist/src/code_assist/converter.test.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 +109 -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 +136 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +22 -0
- package/dist/src/code_assist/oauth2.js +431 -0
- package/dist/src/code_assist/oauth2.js.map +1 -0
- package/dist/src/code_assist/oauth2.test.d.ts +6 -0
- package/dist/src/code_assist/oauth2.test.js +818 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +37 -0
- package/dist/src/code_assist/server.js +148 -0
- package/dist/src/code_assist/server.js.map +1 -0
- package/dist/src/code_assist/server.test.d.ts +6 -0
- package/dist/src/code_assist/server.test.js +159 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +20 -0
- package/dist/src/code_assist/setup.js +101 -0
- package/dist/src/code_assist/setup.js.map +1 -0
- package/dist/src/code_assist/setup.test.d.ts +6 -0
- package/dist/src/code_assist/setup.test.js +171 -0
- package/dist/src/code_assist/setup.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +163 -0
- package/dist/src/code_assist/types.js +46 -0
- package/dist/src/code_assist/types.js.map +1 -0
- package/dist/src/config/config.d.ts +431 -0
- package/dist/src/config/config.js +869 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/config.test.d.ts +6 -0
- package/dist/src/config/config.test.js +896 -0
- package/dist/src/config/config.test.js.map +1 -0
- 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/flashFallback.test.d.ts +6 -0
- package/dist/src/config/flashFallback.test.js +87 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +28 -0
- package/dist/src/config/models.js +42 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +55 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +34 -0
- package/dist/src/config/storage.js +95 -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 +43 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/core/__tests__/openaiTimeoutHandling.test.d.ts +6 -0
- package/dist/src/core/__tests__/openaiTimeoutHandling.test.js +295 -0
- package/dist/src/core/__tests__/openaiTimeoutHandling.test.js.map +1 -0
- package/dist/src/core/__tests__/orphanedToolCallsTest.d.ts +64 -0
- package/dist/src/core/__tests__/orphanedToolCallsTest.js +122 -0
- package/dist/src/core/__tests__/orphanedToolCallsTest.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +49 -0
- package/dist/src/core/baseLlmClient.js +104 -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 +323 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +56 -0
- package/dist/src/core/client.js +522 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/client.test.d.ts +6 -0
- package/dist/src/core/client.test.js +1829 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +52 -0
- package/dist/src/core/contentGenerator.js +106 -0
- package/dist/src/core/contentGenerator.js.map +1 -0
- package/dist/src/core/contentGenerator.test.d.ts +6 -0
- package/dist/src/core/contentGenerator.test.js +77 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +134 -0
- package/dist/src/core/coreToolScheduler.js +774 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/coreToolScheduler.test.d.ts +6 -0
- package/dist/src/core/coreToolScheduler.test.js +1802 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +124 -0
- package/dist/src/core/geminiChat.js +518 -0
- package/dist/src/core/geminiChat.js.map +1 -0
- package/dist/src/core/geminiChat.test.d.ts +6 -0
- package/dist/src/core/geminiChat.test.js +1149 -0
- package/dist/src/core/geminiChat.test.js.map +1 -0
- package/dist/src/core/geminiRequest.d.ts +13 -0
- package/dist/src/core/geminiRequest.js +11 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/geminiRequest.test.d.ts +6 -0
- package/dist/src/core/geminiRequest.test.js +73 -0
- package/dist/src/core/geminiRequest.test.js.map +1 -0
- package/dist/src/core/logger.d.ts +67 -0
- package/dist/src/core/logger.js +361 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/logger.test.d.ts +6 -0
- package/dist/src/core/logger.test.js +534 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +25 -0
- package/dist/src/core/loggingContentGenerator.js +94 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +16 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +29 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js +294 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/constants.d.ts +7 -0
- package/dist/src/core/openaiContentGenerator/constants.js +8 -0
- package/dist/src/core/openaiContentGenerator/constants.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/converter.d.ts +108 -0
- package/dist/src/core/openaiContentGenerator/converter.js +851 -0
- package/dist/src/core/openaiContentGenerator/converter.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/converter.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/converter.test.js +108 -0
- package/dist/src/core/openaiContentGenerator/converter.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.d.ts +20 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.js +82 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.test.js +287 -0
- package/dist/src/core/openaiContentGenerator/errorHandler.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/index.d.ts +22 -0
- package/dist/src/core/openaiContentGenerator/index.js +49 -0
- package/dist/src/core/openaiContentGenerator/index.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.d.ts +21 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.js +105 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.test.js +230 -0
- package/dist/src/core/openaiContentGenerator/openaiContentGenerator.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/pipeline.d.ts +66 -0
- package/dist/src/core/openaiContentGenerator/pipeline.js +265 -0
- package/dist/src/core/openaiContentGenerator/pipeline.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/pipeline.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/pipeline.test.js +1028 -0
- package/dist/src/core/openaiContentGenerator/pipeline.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/README.md +61 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.d.ts +14 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.js +28 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.test.d.ts +1 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.test.js +138 -0
- package/dist/src/core/openaiContentGenerator/provider/anthropic.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.d.ts +63 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.js +241 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.test.js +707 -0
- package/dist/src/core/openaiContentGenerator/provider/dashscope.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.d.ts +14 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.js +70 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.test.js +151 -0
- package/dist/src/core/openaiContentGenerator/provider/deepseek.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/default.d.ts +15 -0
- package/dist/src/core/openaiContentGenerator/provider/default.js +48 -0
- package/dist/src/core/openaiContentGenerator/provider/default.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/default.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/provider/default.test.js +176 -0
- package/dist/src/core/openaiContentGenerator/provider/default.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/index.d.ts +7 -0
- package/dist/src/core/openaiContentGenerator/provider/index.js +7 -0
- package/dist/src/core/openaiContentGenerator/provider/index.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.d.ts +17 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.js +25 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.test.js +66 -0
- package/dist/src/core/openaiContentGenerator/provider/modelscope.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.d.ts +10 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.js +33 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.test.js +175 -0
- package/dist/src/core/openaiContentGenerator/provider/openrouter.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/provider/types.d.ts +23 -0
- package/dist/src/core/openaiContentGenerator/provider/types.js +2 -0
- package/dist/src/core/openaiContentGenerator/provider/types.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.d.ts +145 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.js +381 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.test.js +537 -0
- package/dist/src/core/openaiContentGenerator/streamingToolCallParser.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.d.ts +36 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.js +150 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.js.map +1 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.test.d.ts +6 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.test.js +978 -0
- package/dist/src/core/openaiContentGenerator/telemetryService.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +73 -0
- package/dist/src/core/prompts.js +813 -0
- package/dist/src/core/prompts.js.map +1 -0
- package/dist/src/core/prompts.test.d.ts +6 -0
- package/dist/src/core/prompts.test.js +488 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +25 -0
- package/dist/src/core/tokenLimits.js +194 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +1 -0
- package/dist/src/core/tokenLimits.test.js +304 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +152 -0
- package/dist/src/core/turn.js +187 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turn.test.d.ts +6 -0
- package/dist/src/core/turn.test.js +628 -0
- package/dist/src/core/turn.test.js.map +1 -0
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +97 -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 +130 -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 +7 -0
- package/dist/src/generated/git-commit.js +10 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/ide/constants.d.ts +9 -0
- package/dist/src/ide/constants.js +10 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +56 -0
- package/dist/src/ide/detect-ide.js +68 -0
- package/dist/src/ide/detect-ide.js.map +1 -0
- package/dist/src/ide/detect-ide.test.d.ts +6 -0
- package/dist/src/ide/detect-ide.test.js +113 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +110 -0
- package/dist/src/ide/ide-client.js +651 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ide-client.test.d.ts +6 -0
- package/dist/src/ide/ide-client.test.js +390 -0
- package/dist/src/ide/ide-client.test.js.map +1 -0
- package/dist/src/ide/ide-installer.d.ts +14 -0
- package/dist/src/ide/ide-installer.js +112 -0
- package/dist/src/ide/ide-installer.js.map +1 -0
- package/dist/src/ide/ide-installer.test.d.ts +6 -0
- package/dist/src/ide/ide-installer.test.js +134 -0
- package/dist/src/ide/ide-installer.test.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +44 -0
- package/dist/src/ide/ideContext.js +101 -0
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/ide/ideContext.test.d.ts +6 -0
- package/dist/src/ide/ideContext.test.js +393 -0
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +21 -0
- package/dist/src/ide/process-utils.js +171 -0
- package/dist/src/ide/process-utils.js.map +1 -0
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +158 -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 +99 -0
- package/dist/src/index.js +112 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +6 -0
- package/dist/src/index.test.js +12 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +23 -0
- package/dist/src/mcp/google-auth-provider.js +72 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.test.d.ts +6 -0
- package/dist/src/mcp/google-auth-provider.test.js +89 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +150 -0
- package/dist/src/mcp/oauth-provider.js +613 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-provider.test.d.ts +6 -0
- package/dist/src/mcp/oauth-provider.test.js +847 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +65 -0
- package/dist/src/mcp/oauth-token-storage.js +180 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/oauth-token-storage.test.js +299 -0
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
- package/dist/src/mcp/oauth-utils.d.ts +119 -0
- package/dist/src/mcp/oauth-utils.js +236 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -0
- package/dist/src/mcp/oauth-utils.test.d.ts +6 -0
- package/dist/src/mcp/oauth-utils.test.js +199 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -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 +160 -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 +144 -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 +235 -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 +31 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +190 -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 +254 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +38 -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/mocks/msw.d.ts +6 -0
- package/dist/src/mocks/msw.js +8 -0
- package/dist/src/mocks/msw.js.map +1 -0
- package/dist/src/oauth/callbackServer.d.ts +15 -0
- package/dist/src/oauth/callbackServer.js +89 -0
- package/dist/src/oauth/callbackServer.js.map +1 -0
- package/dist/src/oauth/oauthClient.d.ts +57 -0
- package/dist/src/oauth/oauthClient.js +233 -0
- package/dist/src/oauth/oauthClient.js.map +1 -0
- package/dist/src/oauth/pkce.d.ts +25 -0
- package/dist/src/oauth/pkce.js +45 -0
- package/dist/src/oauth/pkce.js.map +1 -0
- package/dist/src/oauth/tokenManager.d.ts +37 -0
- package/dist/src/oauth/tokenManager.js +110 -0
- package/dist/src/oauth/tokenManager.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/types.d.ts +25 -0
- package/dist/src/output/types.js +17 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +8 -0
- package/dist/src/prompts/mcp-prompts.js +13 -0
- package/dist/src/prompts/mcp-prompts.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +34 -0
- package/dist/src/prompts/prompt-registry.js +63 -0
- package/dist/src/prompts/prompt-registry.js.map +1 -0
- package/dist/src/qwen/qwenContentGenerator.d.ts +70 -0
- package/dist/src/qwen/qwenContentGenerator.js +180 -0
- package/dist/src/qwen/qwenContentGenerator.js.map +1 -0
- package/dist/src/qwen/qwenContentGenerator.test.d.ts +6 -0
- package/dist/src/qwen/qwenContentGenerator.test.js +1178 -0
- package/dist/src/qwen/qwenContentGenerator.test.js.map +1 -0
- package/dist/src/qwen/qwenOAuth2.d.ts +194 -0
- package/dist/src/qwen/qwenOAuth2.js +594 -0
- package/dist/src/qwen/qwenOAuth2.js.map +1 -0
- package/dist/src/qwen/qwenOAuth2.test.d.ts +6 -0
- package/dist/src/qwen/qwenOAuth2.test.js +1724 -0
- package/dist/src/qwen/qwenOAuth2.test.js.map +1 -0
- package/dist/src/qwen/sharedTokenManager.d.ts +196 -0
- package/dist/src/qwen/sharedTokenManager.js +647 -0
- package/dist/src/qwen/sharedTokenManager.js.map +1 -0
- package/dist/src/qwen/sharedTokenManager.test.d.ts +7 -0
- package/dist/src/qwen/sharedTokenManager.test.js +662 -0
- package/dist/src/qwen/sharedTokenManager.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +180 -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 +292 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +144 -0
- package/dist/src/services/chatRecordingService.js +330 -0
- package/dist/src/services/chatRecordingService.js.map +1 -0
- package/dist/src/services/chatRecordingService.test.d.ts +6 -0
- package/dist/src/services/chatRecordingService.test.js +332 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +45 -0
- package/dist/src/services/fileDiscoveryService.js +104 -0
- package/dist/src/services/fileDiscoveryService.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.test.d.ts +6 -0
- package/dist/src/services/fileDiscoveryService.test.js +143 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +40 -0
- package/dist/src/services/fileSystemService.js +29 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/fileSystemService.test.d.ts +6 -0
- package/dist/src/services/fileSystemService.test.js +41 -0
- package/dist/src/services/fileSystemService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +22 -0
- package/dist/src/services/gitService.js +98 -0
- package/dist/src/services/gitService.js.map +1 -0
- package/dist/src/services/gitService.test.d.ts +6 -0
- package/dist/src/services/gitService.test.js +187 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +103 -0
- package/dist/src/services/loopDetectionService.js +379 -0
- package/dist/src/services/loopDetectionService.js.map +1 -0
- package/dist/src/services/loopDetectionService.test.d.ts +6 -0
- package/dist/src/services/loopDetectionService.test.js +588 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +102 -0
- package/dist/src/services/shellExecutionService.js +522 -0
- package/dist/src/services/shellExecutionService.js.map +1 -0
- package/dist/src/services/shellExecutionService.test.d.ts +6 -0
- package/dist/src/services/shellExecutionService.test.js +655 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -0
- package/dist/src/subagents/builtin-agents.d.ts +35 -0
- package/dist/src/subagents/builtin-agents.js +85 -0
- package/dist/src/subagents/builtin-agents.js.map +1 -0
- package/dist/src/subagents/builtin-agents.test.d.ts +6 -0
- package/dist/src/subagents/builtin-agents.test.js +78 -0
- package/dist/src/subagents/builtin-agents.test.js.map +1 -0
- package/dist/src/subagents/index.d.ts +29 -0
- package/dist/src/subagents/index.js +15 -0
- package/dist/src/subagents/index.js.map +1 -0
- package/dist/src/subagents/subagent-events.d.ts +95 -0
- package/dist/src/subagents/subagent-events.js +31 -0
- package/dist/src/subagents/subagent-events.js.map +1 -0
- package/dist/src/subagents/subagent-hooks.d.ts +29 -0
- package/dist/src/subagents/subagent-hooks.js +7 -0
- package/dist/src/subagents/subagent-hooks.js.map +1 -0
- package/dist/src/subagents/subagent-manager.d.ts +170 -0
- package/dist/src/subagents/subagent-manager.js +596 -0
- package/dist/src/subagents/subagent-manager.js.map +1 -0
- package/dist/src/subagents/subagent-manager.test.d.ts +6 -0
- package/dist/src/subagents/subagent-manager.test.js +822 -0
- package/dist/src/subagents/subagent-manager.test.js.map +1 -0
- package/dist/src/subagents/subagent-statistics.d.ts +46 -0
- package/dist/src/subagents/subagent-statistics.js +193 -0
- package/dist/src/subagents/subagent-statistics.js.map +1 -0
- package/dist/src/subagents/subagent-statistics.test.d.ts +6 -0
- package/dist/src/subagents/subagent-statistics.test.js +231 -0
- package/dist/src/subagents/subagent-statistics.test.js.map +1 -0
- package/dist/src/subagents/subagent.d.ts +162 -0
- package/dist/src/subagents/subagent.js +677 -0
- package/dist/src/subagents/subagent.js.map +1 -0
- package/dist/src/subagents/subagent.test.d.ts +6 -0
- package/dist/src/subagents/subagent.test.js +477 -0
- package/dist/src/subagents/subagent.test.js.map +1 -0
- package/dist/src/subagents/types.d.ts +218 -0
- package/dist/src/subagents/types.js +58 -0
- package/dist/src/subagents/types.js.map +1 -0
- package/dist/src/subagents/types.test.d.ts +6 -0
- package/dist/src/subagents/types.test.js +31 -0
- package/dist/src/subagents/types.test.js.map +1 -0
- package/dist/src/subagents/validation.d.ts +63 -0
- package/dist/src/subagents/validation.js +293 -0
- package/dist/src/subagents/validation.js.map +1 -0
- package/dist/src/subagents/validation.test.d.ts +6 -0
- package/dist/src/subagents/validation.test.js +330 -0
- package/dist/src/subagents/validation.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +137 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +915 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +18 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +594 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +115 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +291 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- 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 +36 -0
- package/dist/src/telemetry/constants.js +38 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/file-exporters.d.ts +29 -0
- package/dist/src/telemetry/file-exporters.js +62 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +25 -0
- package/dist/src/telemetry/index.js +31 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
- package/dist/src/telemetry/integration.test.circular.js +95 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +37 -0
- package/dist/src/telemetry/loggers.js +651 -0
- package/dist/src/telemetry/loggers.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.circular.js +107 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.test.d.ts +6 -0
- package/dist/src/telemetry/loggers.test.js +978 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +320 -0
- package/dist/src/telemetry/metrics.js +532 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/telemetry/metrics.test.d.ts +6 -0
- package/dist/src/telemetry/metrics.test.js +744 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- package/dist/src/telemetry/qwen-logger/event-types.d.ts +88 -0
- package/dist/src/telemetry/qwen-logger/event-types.js +2 -0
- package/dist/src/telemetry/qwen-logger/event-types.js.map +1 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.d.ts +91 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.js +685 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.js.map +1 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.test.d.ts +6 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.test.js +317 -0
- package/dist/src/telemetry/qwen-logger/qwen-logger.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -0
- package/dist/src/telemetry/sdk.js +164 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/sdk.test.d.ts +6 -0
- package/dist/src/telemetry/sdk.test.js +116 -0
- package/dist/src/telemetry/sdk.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 +40 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry.test.js +50 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +327 -0
- package/dist/src/telemetry/types.js +558 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +75 -0
- package/dist/src/telemetry/uiTelemetry.js +152 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
- package/dist/src/telemetry/uiTelemetry.test.js +625 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +17 -0
- package/dist/src/test-utils/config.js +32 -0
- package/dist/src/test-utils/config.js.map +1 -0
- 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/mock-tool.js +121 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +13 -0
- package/dist/src/test-utils/mockWorkspaceContext.js +24 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +9 -0
- package/dist/src/tools/diffOptions.js +46 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/diffOptions.test.d.ts +6 -0
- package/dist/src/tools/diffOptions.test.js +155 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +55 -0
- package/dist/src/tools/edit.js +421 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/edit.test.d.ts +6 -0
- package/dist/src/tools/edit.test.js +684 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/exitPlanMode.d.ts +28 -0
- package/dist/src/tools/exitPlanMode.js +132 -0
- package/dist/src/tools/exitPlanMode.js.map +1 -0
- package/dist/src/tools/exitPlanMode.test.d.ts +6 -0
- package/dist/src/tools/exitPlanMode.test.js +178 -0
- package/dist/src/tools/exitPlanMode.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +44 -0
- package/dist/src/tools/glob.js +190 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/glob.test.d.ts +6 -0
- package/dist/src/tools/glob.test.js +442 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +44 -0
- package/dist/src/tools/grep.js +425 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/grep.test.d.ts +6 -0
- package/dist/src/tools/grep.test.js +360 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +68 -0
- package/dist/src/tools/ls.js +215 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/ls.test.d.ts +6 -0
- package/dist/src/tools/ls.test.js +249 -0
- package/dist/src/tools/ls.test.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +40 -0
- package/dist/src/tools/mcp-client-manager.js +83 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.test.d.ts +6 -0
- package/dist/src/tools/mcp-client-manager.test.js +58 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +189 -0
- package/dist/src/tools/mcp-client.js +957 -0
- package/dist/src/tools/mcp-client.js.map +1 -0
- package/dist/src/tools/mcp-client.test.d.ts +6 -0
- package/dist/src/tools/mcp-client.test.js +309 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +24 -0
- package/dist/src/tools/mcp-tool.js +268 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/mcp-tool.test.d.ts +6 -0
- package/dist/src/tools/mcp-tool.test.js +714 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +41 -0
- package/dist/src/tools/memoryTool.js +396 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/memoryTool.test.d.ts +6 -0
- package/dist/src/tools/memoryTool.test.js +419 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +32 -0
- package/dist/src/tools/modifiable-tool.js +88 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.test.d.ts +6 -0
- package/dist/src/tools/modifiable-tool.test.js +193 -0
- package/dist/src/tools/modifiable-tool.test.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +35 -0
- package/dist/src/tools/read-file.js +124 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-file.test.d.ts +6 -0
- package/dist/src/tools/read-file.test.js +339 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +60 -0
- package/dist/src/tools/read-many-files.js +391 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/read-many-files.test.d.ts +6 -0
- package/dist/src/tools/read-many-files.test.js +566 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +44 -0
- package/dist/src/tools/ripGrep.js +233 -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 +529 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +33 -0
- package/dist/src/tools/shell.js +388 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/shell.test.d.ts +6 -0
- package/dist/src/tools/shell.test.js +566 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- package/dist/src/tools/smart-edit.d.ts +91 -0
- package/dist/src/tools/smart-edit.js +703 -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 +542 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/task.d.ts +59 -0
- package/dist/src/tools/task.js +412 -0
- package/dist/src/tools/task.js.map +1 -0
- package/dist/src/tools/task.test.d.ts +6 -0
- package/dist/src/tools/task.test.js +369 -0
- package/dist/src/tools/task.test.js.map +1 -0
- package/dist/src/tools/todoWrite.d.ts +42 -0
- package/dist/src/tools/todoWrite.js +407 -0
- package/dist/src/tools/todoWrite.js.map +1 -0
- package/dist/src/tools/todoWrite.test.d.ts +6 -0
- package/dist/src/tools/todoWrite.test.js +234 -0
- package/dist/src/tools/todoWrite.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +45 -0
- package/dist/src/tools/tool-error.js +61 -0
- package/dist/src/tools/tool-error.js.map +1 -0
- package/dist/src/tools/tool-names.d.ts +56 -0
- package/dist/src/tools/tool-names.js +62 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +87 -0
- package/dist/src/tools/tool-registry.js +370 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tool-registry.test.d.ts +6 -0
- package/dist/src/tools/tool-registry.test.js +332 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +327 -0
- package/dist/src/tools/tools.js +258 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/tools.test.d.ts +6 -0
- package/dist/src/tools/tools.test.js +205 -0
- package/dist/src/tools/tools.test.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +31 -0
- package/dist/src/tools/web-fetch.js +163 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/tools/web-fetch.test.d.ts +6 -0
- package/dist/src/tools/web-fetch.test.js +133 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -0
- package/dist/src/tools/web-search/base-provider.d.ts +31 -0
- package/dist/src/tools/web-search/base-provider.js +34 -0
- package/dist/src/tools/web-search/base-provider.js.map +1 -0
- package/dist/src/tools/web-search/index.d.ts +24 -0
- package/dist/src/tools/web-search/index.js +245 -0
- package/dist/src/tools/web-search/index.js.map +1 -0
- package/dist/src/tools/web-search/index.test.d.ts +6 -0
- package/dist/src/tools/web-search/index.test.js +237 -0
- package/dist/src/tools/web-search/index.test.js.map +1 -0
- package/dist/src/tools/web-search/providers/dashscope-provider.d.ts +23 -0
- package/dist/src/tools/web-search/providers/dashscope-provider.js +120 -0
- package/dist/src/tools/web-search/providers/dashscope-provider.js.map +1 -0
- package/dist/src/tools/web-search/providers/google-provider.d.ts +17 -0
- package/dist/src/tools/web-search/providers/google-provider.js +55 -0
- package/dist/src/tools/web-search/providers/google-provider.js.map +1 -0
- package/dist/src/tools/web-search/providers/tavily-provider.d.ts +17 -0
- package/dist/src/tools/web-search/providers/tavily-provider.js +54 -0
- package/dist/src/tools/web-search/providers/tavily-provider.js.map +1 -0
- package/dist/src/tools/web-search/types.d.ts +138 -0
- package/dist/src/tools/web-search/types.js +7 -0
- package/dist/src/tools/web-search/types.js.map +1 -0
- package/dist/src/tools/web-search/utils.d.ts +28 -0
- package/dist/src/tools/web-search/utils.js +35 -0
- package/dist/src/tools/web-search/utils.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +52 -0
- package/dist/src/tools/write-file.js +293 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/tools/write-file.test.d.ts +6 -0
- package/dist/src/tools/write-file.test.js +516 -0
- package/dist/src/tools/write-file.test.js.map +1 -0
- package/dist/src/utils/LruCache.d.ts +13 -0
- package/dist/src/utils/LruCache.js +38 -0
- package/dist/src/utils/LruCache.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +24 -0
- package/dist/src/utils/bfsFileSearch.js +95 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.test.d.ts +6 -0
- package/dist/src/utils/bfsFileSearch.test.js +163 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/browser.d.ts +13 -0
- package/dist/src/utils/browser.js +50 -0
- package/dist/src/utils/browser.js.map +1 -0
- package/dist/src/utils/editHelper.d.ts +53 -0
- package/dist/src/utils/editHelper.js +359 -0
- package/dist/src/utils/editHelper.js.map +1 -0
- package/dist/src/utils/editHelper.test.d.ts +6 -0
- package/dist/src/utils/editHelper.test.js +93 -0
- package/dist/src/utils/editHelper.test.js.map +1 -0
- package/dist/src/utils/editor.d.ts +28 -0
- package/dist/src/utils/editor.js +177 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/editor.test.d.ts +6 -0
- package/dist/src/utils/editor.test.js +437 -0
- package/dist/src/utils/editor.test.js.map +1 -0
- package/dist/src/utils/environmentContext.d.ts +22 -0
- package/dist/src/utils/environmentContext.js +108 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/environmentContext.test.d.ts +6 -0
- package/dist/src/utils/environmentContext.test.js +219 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -0
- package/dist/src/utils/errorParsing.d.ts +8 -0
- package/dist/src/utils/errorParsing.js +93 -0
- package/dist/src/utils/errorParsing.js.map +1 -0
- package/dist/src/utils/errorParsing.test.d.ts +6 -0
- package/dist/src/utils/errorParsing.test.js +172 -0
- package/dist/src/utils/errorParsing.test.js.map +1 -0
- package/dist/src/utils/errorReporting.d.ts +14 -0
- package/dist/src/utils/errorReporting.js +88 -0
- package/dist/src/utils/errorReporting.js.map +1 -0
- package/dist/src/utils/errorReporting.test.d.ts +6 -0
- package/dist/src/utils/errorReporting.test.js +130 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +39 -0
- package/dist/src/utils/errors.js +96 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +11 -0
- package/dist/src/utils/fetch.js +51 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +69 -0
- package/dist/src/utils/fileUtils.js +426 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/fileUtils.test.d.ts +6 -0
- package/dist/src/utils/fileUtils.test.js +685 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.d.ts +25 -0
- package/dist/src/utils/filesearch/crawlCache.js +57 -0
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawlCache.test.js +103 -0
- package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.d.ts +15 -0
- package/dist/src/utils/filesearch/crawler.js +50 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.test.d.ts +6 -0
- package/dist/src/utils/filesearch/crawler.test.js +468 -0
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +38 -0
- package/dist/src/utils/filesearch/fileSearch.js +191 -0
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +6 -0
- package/dist/src/utils/filesearch/fileSearch.test.js +642 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.d.ts +42 -0
- package/dist/src/utils/filesearch/ignore.js +106 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.test.d.ts +6 -0
- package/dist/src/utils/filesearch/ignore.test.js +144 -0
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.d.ts +33 -0
- package/dist/src/utils/filesearch/result-cache.js +59 -0
- package/dist/src/utils/filesearch/result-cache.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.test.d.ts +6 -0
- package/dist/src/utils/filesearch/result-cache.test.js +46 -0
- package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +122 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +6 -0
- package/dist/src/utils/formatters.js +16 -0
- package/dist/src/utils/formatters.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +13 -0
- package/dist/src/utils/generateContentResponseUtilities.js +80 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js +235 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +31 -0
- package/dist/src/utils/getFolderStructure.js +246 -0
- package/dist/src/utils/getFolderStructure.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.d.ts +6 -0
- package/dist/src/utils/getFolderStructure.test.js +282 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +16 -0
- package/dist/src/utils/gitIgnoreParser.js +152 -0
- package/dist/src/utils/gitIgnoreParser.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/gitIgnoreParser.test.js +185 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +17 -0
- package/dist/src/utils/gitUtils.js +61 -0
- package/dist/src/utils/gitUtils.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 +250 -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 +50 -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 +83 -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 +131 -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 +186 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +16 -0
- package/dist/src/utils/memoryDiscovery.js +272 -0
- package/dist/src/utils/memoryDiscovery.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.test.d.ts +6 -0
- package/dist/src/utils/memoryDiscovery.test.js +244 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +42 -0
- package/dist/src/utils/memoryImportProcessor.js +284 -0
- package/dist/src/utils/memoryImportProcessor.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
- package/dist/src/utils/memoryImportProcessor.test.js +587 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
- package/dist/src/utils/messageInspectors.d.ts +8 -0
- package/dist/src/utils/messageInspectors.js +16 -0
- package/dist/src/utils/messageInspectors.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
- package/dist/src/utils/nextSpeakerChecker.js +97 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
- package/dist/src/utils/nextSpeakerChecker.test.js +181 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
- package/dist/src/utils/openaiLogger.d.ts +42 -0
- package/dist/src/utils/openaiLogger.js +138 -0
- package/dist/src/utils/openaiLogger.js.map +1 -0
- package/dist/src/utils/openaiLogger.test.d.ts +6 -0
- package/dist/src/utils/openaiLogger.test.js +304 -0
- package/dist/src/utils/openaiLogger.test.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +35 -0
- package/dist/src/utils/partUtils.js +133 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/partUtils.test.d.ts +6 -0
- package/dist/src/utils/partUtils.test.js +241 -0
- package/dist/src/utils/partUtils.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 +365 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +93 -0
- package/dist/src/utils/paths.js +229 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/paths.test.d.ts +6 -0
- package/dist/src/utils/paths.test.js +438 -0
- package/dist/src/utils/paths.test.js.map +1 -0
- package/dist/src/utils/projectSummary.d.ts +22 -0
- package/dist/src/utils/projectSummary.js +86 -0
- package/dist/src/utils/projectSummary.js.map +1 -0
- 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 +20 -0
- package/dist/src/utils/quotaErrorDetection.js +114 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.test.d.ts +6 -0
- package/dist/src/utils/quotaErrorDetection.test.js +153 -0
- package/dist/src/utils/quotaErrorDetection.test.js.map +1 -0
- package/dist/src/utils/qwenIgnoreParser.d.ts +18 -0
- package/dist/src/utils/qwenIgnoreParser.js +69 -0
- package/dist/src/utils/qwenIgnoreParser.js.map +1 -0
- package/dist/src/utils/qwenIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/qwenIgnoreParser.test.js +50 -0
- package/dist/src/utils/qwenIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.d.ts +112 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.js +401 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.js.map +1 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.test.d.ts +6 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.test.js +114 -0
- package/dist/src/utils/request-tokenizer/imageTokenizer.test.js.map +1 -0
- package/dist/src/utils/request-tokenizer/index.d.ts +18 -0
- package/dist/src/utils/request-tokenizer/index.js +30 -0
- package/dist/src/utils/request-tokenizer/index.js.map +1 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.d.ts +56 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.js +263 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.js.map +1 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.test.d.ts +6 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.test.js +245 -0
- package/dist/src/utils/request-tokenizer/requestTokenizer.test.js.map +1 -0
- package/dist/src/utils/request-tokenizer/supportedImageFormats.d.ts +30 -0
- package/dist/src/utils/request-tokenizer/supportedImageFormats.js +41 -0
- package/dist/src/utils/request-tokenizer/supportedImageFormats.js.map +1 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.d.ts +29 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.js +88 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.js.map +1 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.test.d.ts +6 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.test.js +253 -0
- package/dist/src/utils/request-tokenizer/textTokenizer.test.js.map +1 -0
- package/dist/src/utils/request-tokenizer/types.d.ts +55 -0
- package/dist/src/utils/request-tokenizer/types.js +7 -0
- package/dist/src/utils/request-tokenizer/types.js.map +1 -0
- package/dist/src/utils/retry.d.ts +32 -0
- package/dist/src/utils/retry.js +303 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/retry.test.d.ts +6 -0
- package/dist/src/utils/retry.test.js +474 -0
- package/dist/src/utils/retry.test.js.map +1 -0
- package/dist/src/utils/ripgrepUtils.d.ts +61 -0
- package/dist/src/utils/ripgrepUtils.js +230 -0
- package/dist/src/utils/ripgrepUtils.js.map +1 -0
- package/dist/src/utils/ripgrepUtils.test.d.ts +6 -0
- package/dist/src/utils/ripgrepUtils.test.js +101 -0
- package/dist/src/utils/ripgrepUtils.test.js.map +1 -0
- package/dist/src/utils/safeJsonParse.d.ts +15 -0
- package/dist/src/utils/safeJsonParse.js +41 -0
- package/dist/src/utils/safeJsonParse.js.map +1 -0
- package/dist/src/utils/safeJsonParse.test.d.ts +6 -0
- package/dist/src/utils/safeJsonParse.test.js +112 -0
- package/dist/src/utils/safeJsonParse.test.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +13 -0
- package/dist/src/utils/safeJsonStringify.js +25 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.test.d.ts +6 -0
- package/dist/src/utils/safeJsonStringify.test.js +61 -0
- package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +15 -0
- package/dist/src/utils/schemaValidator.js +67 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- 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/secure-browser-launcher.d.ts +23 -0
- package/dist/src/utils/secure-browser-launcher.js +165 -0
- package/dist/src/utils/secure-browser-launcher.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.test.d.ts +6 -0
- package/dist/src/utils/secure-browser-launcher.test.js +149 -0
- package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
- package/dist/src/utils/session.d.ts +6 -0
- package/dist/src/utils/session.js +8 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +152 -0
- package/dist/src/utils/shell-utils.js +467 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/shell-utils.test.d.ts +6 -0
- package/dist/src/utils/shell-utils.test.js +351 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -0
- package/dist/src/utils/shellReadOnlyChecker.d.ts +6 -0
- package/dist/src/utils/shellReadOnlyChecker.js +247 -0
- package/dist/src/utils/shellReadOnlyChecker.js.map +1 -0
- package/dist/src/utils/shellReadOnlyChecker.test.d.ts +6 -0
- package/dist/src/utils/shellReadOnlyChecker.test.js +47 -0
- package/dist/src/utils/shellReadOnlyChecker.test.js.map +1 -0
- package/dist/src/utils/subagentGenerator.d.ts +20 -0
- package/dist/src/utils/subagentGenerator.js +120 -0
- package/dist/src/utils/subagentGenerator.js.map +1 -0
- package/dist/src/utils/subagentGenerator.test.d.ts +6 -0
- package/dist/src/utils/subagentGenerator.test.js +135 -0
- package/dist/src/utils/subagentGenerator.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +25 -0
- package/dist/src/utils/summarizer.js +51 -0
- package/dist/src/utils/summarizer.js.map +1 -0
- package/dist/src/utils/summarizer.test.d.ts +6 -0
- package/dist/src/utils/summarizer.test.js +131 -0
- package/dist/src/utils/summarizer.test.js.map +1 -0
- package/dist/src/utils/systemEncoding.d.ts +40 -0
- package/dist/src/utils/systemEncoding.js +149 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/systemEncoding.test.d.ts +6 -0
- package/dist/src/utils/systemEncoding.test.js +368 -0
- package/dist/src/utils/systemEncoding.test.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/testUtils.d.ts +29 -0
- package/dist/src/utils/testUtils.js +70 -0
- package/dist/src/utils/testUtils.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +18 -0
- package/dist/src/utils/textUtils.js +42 -0
- package/dist/src/utils/textUtils.js.map +1 -0
- 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 +22 -0
- package/dist/src/utils/tool-utils.js +121 -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 +100 -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 +114 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/userAccountManager.test.js +223 -0
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +66 -0
- package/dist/src/utils/workspaceContext.js +171 -0
- package/dist/src/utils/workspaceContext.js.map +1 -0
- package/dist/src/utils/workspaceContext.test.d.ts +6 -0
- package/dist/src/utils/workspaceContext.test.js +318 -0
- package/dist/src/utils/workspaceContext.test.js.map +1 -0
- package/dist/src/utils/yaml-parser.d.ts +29 -0
- package/dist/src/utils/yaml-parser.js +172 -0
- package/dist/src/utils/yaml-parser.js.map +1 -0
- package/dist/src/utils/yaml-parser.test.d.ts +6 -0
- package/dist/src/utils/yaml-parser.test.js +170 -0
- package/dist/src/utils/yaml-parser.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +106 -0
- package/scripts/postinstall.js +100 -0
- package/vendor/ripgrep/COPYING +3 -0
- package/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/ripgrep/x64-win32/rg.exe +0 -0
|
@@ -0,0 +1,957 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
7
|
+
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
8
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
9
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
10
|
+
import { GetPromptResultSchema, ListPromptsResultSchema, ListRootsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
import { parse } from 'shell-quote';
|
|
12
|
+
import { AuthProviderType } from '../config/config.js';
|
|
13
|
+
import { GoogleCredentialProvider } from '../mcp/google-auth-provider.js';
|
|
14
|
+
import { ServiceAccountImpersonationProvider } from '../mcp/sa-impersonation-provider.js';
|
|
15
|
+
import { DiscoveredMCPTool } from './mcp-tool.js';
|
|
16
|
+
import { mcpToTool } from '@google/genai';
|
|
17
|
+
import { basename } from 'node:path';
|
|
18
|
+
import { pathToFileURL } from 'node:url';
|
|
19
|
+
import { MCPOAuthProvider } from '../mcp/oauth-provider.js';
|
|
20
|
+
import { MCPOAuthTokenStorage } from '../mcp/oauth-token-storage.js';
|
|
21
|
+
import { OAuthUtils } from '../mcp/oauth-utils.js';
|
|
22
|
+
import { getErrorMessage } from '../utils/errors.js';
|
|
23
|
+
export const MCP_DEFAULT_TIMEOUT_MSEC = 10 * 60 * 1000; // default to 10 minutes
|
|
24
|
+
/**
|
|
25
|
+
* Enum representing the connection status of an MCP server
|
|
26
|
+
*/
|
|
27
|
+
export var MCPServerStatus;
|
|
28
|
+
(function (MCPServerStatus) {
|
|
29
|
+
/** Server is disconnected or experiencing errors */
|
|
30
|
+
MCPServerStatus["DISCONNECTED"] = "disconnected";
|
|
31
|
+
/** Server is in the process of connecting */
|
|
32
|
+
MCPServerStatus["CONNECTING"] = "connecting";
|
|
33
|
+
/** Server is connected and ready to use */
|
|
34
|
+
MCPServerStatus["CONNECTED"] = "connected";
|
|
35
|
+
})(MCPServerStatus || (MCPServerStatus = {}));
|
|
36
|
+
/**
|
|
37
|
+
* Enum representing the overall MCP discovery state
|
|
38
|
+
*/
|
|
39
|
+
export var MCPDiscoveryState;
|
|
40
|
+
(function (MCPDiscoveryState) {
|
|
41
|
+
/** Discovery has not started yet */
|
|
42
|
+
MCPDiscoveryState["NOT_STARTED"] = "not_started";
|
|
43
|
+
/** Discovery is currently in progress */
|
|
44
|
+
MCPDiscoveryState["IN_PROGRESS"] = "in_progress";
|
|
45
|
+
/** Discovery has completed (with or without errors) */
|
|
46
|
+
MCPDiscoveryState["COMPLETED"] = "completed";
|
|
47
|
+
})(MCPDiscoveryState || (MCPDiscoveryState = {}));
|
|
48
|
+
/**
|
|
49
|
+
* A client for a single MCP server.
|
|
50
|
+
*
|
|
51
|
+
* This class is responsible for connecting to, discovering tools from, and
|
|
52
|
+
* managing the state of a single MCP server.
|
|
53
|
+
*/
|
|
54
|
+
export class McpClient {
|
|
55
|
+
serverName;
|
|
56
|
+
serverConfig;
|
|
57
|
+
toolRegistry;
|
|
58
|
+
promptRegistry;
|
|
59
|
+
workspaceContext;
|
|
60
|
+
debugMode;
|
|
61
|
+
client;
|
|
62
|
+
transport;
|
|
63
|
+
status = MCPServerStatus.DISCONNECTED;
|
|
64
|
+
isDisconnecting = false;
|
|
65
|
+
constructor(serverName, serverConfig, toolRegistry, promptRegistry, workspaceContext, debugMode) {
|
|
66
|
+
this.serverName = serverName;
|
|
67
|
+
this.serverConfig = serverConfig;
|
|
68
|
+
this.toolRegistry = toolRegistry;
|
|
69
|
+
this.promptRegistry = promptRegistry;
|
|
70
|
+
this.workspaceContext = workspaceContext;
|
|
71
|
+
this.debugMode = debugMode;
|
|
72
|
+
this.client = new Client({
|
|
73
|
+
name: `qwen-cli-mcp-client-${this.serverName}`,
|
|
74
|
+
version: '0.0.1',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Connects to the MCP server.
|
|
79
|
+
*/
|
|
80
|
+
async connect() {
|
|
81
|
+
this.isDisconnecting = false;
|
|
82
|
+
this.updateStatus(MCPServerStatus.CONNECTING);
|
|
83
|
+
try {
|
|
84
|
+
this.transport = await this.createTransport();
|
|
85
|
+
this.client.onerror = (error) => {
|
|
86
|
+
if (this.isDisconnecting) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
console.error(`MCP ERROR (${this.serverName}):`, error.toString());
|
|
90
|
+
this.updateStatus(MCPServerStatus.DISCONNECTED);
|
|
91
|
+
};
|
|
92
|
+
this.client.registerCapabilities({
|
|
93
|
+
roots: {},
|
|
94
|
+
});
|
|
95
|
+
this.client.setRequestHandler(ListRootsRequestSchema, async () => {
|
|
96
|
+
const roots = [];
|
|
97
|
+
for (const dir of this.workspaceContext.getDirectories()) {
|
|
98
|
+
roots.push({
|
|
99
|
+
uri: pathToFileURL(dir).toString(),
|
|
100
|
+
name: basename(dir),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
roots,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
await this.client.connect(this.transport, {
|
|
108
|
+
timeout: this.serverConfig.timeout,
|
|
109
|
+
});
|
|
110
|
+
this.updateStatus(MCPServerStatus.CONNECTED);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
this.updateStatus(MCPServerStatus.DISCONNECTED);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Discovers tools and prompts from the MCP server.
|
|
119
|
+
*/
|
|
120
|
+
async discover(cliConfig) {
|
|
121
|
+
if (this.status !== MCPServerStatus.CONNECTED) {
|
|
122
|
+
throw new Error('Client is not connected.');
|
|
123
|
+
}
|
|
124
|
+
const prompts = await this.discoverPrompts();
|
|
125
|
+
const tools = await this.discoverTools(cliConfig);
|
|
126
|
+
if (prompts.length === 0 && tools.length === 0) {
|
|
127
|
+
throw new Error('No prompts or tools found on the server.');
|
|
128
|
+
}
|
|
129
|
+
for (const tool of tools) {
|
|
130
|
+
this.toolRegistry.registerTool(tool);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Disconnects from the MCP server.
|
|
135
|
+
*/
|
|
136
|
+
async disconnect() {
|
|
137
|
+
this.isDisconnecting = true;
|
|
138
|
+
if (this.transport) {
|
|
139
|
+
await this.transport.close();
|
|
140
|
+
}
|
|
141
|
+
this.client.close();
|
|
142
|
+
this.updateStatus(MCPServerStatus.DISCONNECTED);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Returns the current status of the client.
|
|
146
|
+
*/
|
|
147
|
+
getStatus() {
|
|
148
|
+
return this.status;
|
|
149
|
+
}
|
|
150
|
+
updateStatus(status) {
|
|
151
|
+
this.status = status;
|
|
152
|
+
updateMCPServerStatus(this.serverName, status);
|
|
153
|
+
}
|
|
154
|
+
async createTransport() {
|
|
155
|
+
return createTransport(this.serverName, this.serverConfig, this.debugMode);
|
|
156
|
+
}
|
|
157
|
+
async discoverTools(cliConfig) {
|
|
158
|
+
return discoverTools(this.serverName, this.serverConfig, this.client, cliConfig);
|
|
159
|
+
}
|
|
160
|
+
async discoverPrompts() {
|
|
161
|
+
return discoverPrompts(this.serverName, this.client, this.promptRegistry);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Map to track the status of each MCP server within the core package
|
|
166
|
+
*/
|
|
167
|
+
const serverStatuses = new Map();
|
|
168
|
+
/**
|
|
169
|
+
* Track the overall MCP discovery state
|
|
170
|
+
*/
|
|
171
|
+
let mcpDiscoveryState = MCPDiscoveryState.NOT_STARTED;
|
|
172
|
+
/**
|
|
173
|
+
* Map to track which MCP servers have been discovered to require OAuth
|
|
174
|
+
*/
|
|
175
|
+
export const mcpServerRequiresOAuth = new Map();
|
|
176
|
+
const statusChangeListeners = [];
|
|
177
|
+
/**
|
|
178
|
+
* Add a listener for MCP server status changes
|
|
179
|
+
*/
|
|
180
|
+
export function addMCPStatusChangeListener(listener) {
|
|
181
|
+
statusChangeListeners.push(listener);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Remove a listener for MCP server status changes
|
|
185
|
+
*/
|
|
186
|
+
export function removeMCPStatusChangeListener(listener) {
|
|
187
|
+
const index = statusChangeListeners.indexOf(listener);
|
|
188
|
+
if (index !== -1) {
|
|
189
|
+
statusChangeListeners.splice(index, 1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Update the status of an MCP server
|
|
194
|
+
*/
|
|
195
|
+
export function updateMCPServerStatus(serverName, status) {
|
|
196
|
+
serverStatuses.set(serverName, status);
|
|
197
|
+
// Notify all listeners
|
|
198
|
+
for (const listener of statusChangeListeners) {
|
|
199
|
+
listener(serverName, status);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get the current status of an MCP server
|
|
204
|
+
*/
|
|
205
|
+
export function getMCPServerStatus(serverName) {
|
|
206
|
+
return serverStatuses.get(serverName) || MCPServerStatus.DISCONNECTED;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get all MCP server statuses
|
|
210
|
+
*/
|
|
211
|
+
export function getAllMCPServerStatuses() {
|
|
212
|
+
return new Map(serverStatuses);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get the current MCP discovery state
|
|
216
|
+
*/
|
|
217
|
+
export function getMCPDiscoveryState() {
|
|
218
|
+
return mcpDiscoveryState;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Extract WWW-Authenticate header from error message string.
|
|
222
|
+
* This is a more robust approach than regex matching.
|
|
223
|
+
*
|
|
224
|
+
* @param errorString The error message string
|
|
225
|
+
* @returns The www-authenticate header value if found, null otherwise
|
|
226
|
+
*/
|
|
227
|
+
function extractWWWAuthenticateHeader(errorString) {
|
|
228
|
+
// Try multiple patterns to extract the header
|
|
229
|
+
const patterns = [
|
|
230
|
+
/www-authenticate:\s*([^\n\r]+)/i,
|
|
231
|
+
/WWW-Authenticate:\s*([^\n\r]+)/i,
|
|
232
|
+
/"www-authenticate":\s*"([^"]+)"/i,
|
|
233
|
+
/'www-authenticate':\s*'([^']+)'/i,
|
|
234
|
+
];
|
|
235
|
+
for (const pattern of patterns) {
|
|
236
|
+
const match = errorString.match(pattern);
|
|
237
|
+
if (match) {
|
|
238
|
+
return match[1].trim();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Handle automatic OAuth discovery and authentication for a server.
|
|
245
|
+
*
|
|
246
|
+
* @param mcpServerName The name of the MCP server
|
|
247
|
+
* @param mcpServerConfig The MCP server configuration
|
|
248
|
+
* @param wwwAuthenticate The www-authenticate header value
|
|
249
|
+
* @returns True if OAuth was successfully configured and authenticated, false otherwise
|
|
250
|
+
*/
|
|
251
|
+
async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate) {
|
|
252
|
+
try {
|
|
253
|
+
console.log(`🔐 '${mcpServerName}' requires OAuth authentication`);
|
|
254
|
+
// Always try to parse the resource metadata URI from the www-authenticate header
|
|
255
|
+
let oauthConfig;
|
|
256
|
+
const resourceMetadataUri = OAuthUtils.parseWWWAuthenticateHeader(wwwAuthenticate);
|
|
257
|
+
if (resourceMetadataUri) {
|
|
258
|
+
oauthConfig = await OAuthUtils.discoverOAuthConfig(resourceMetadataUri);
|
|
259
|
+
}
|
|
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}`;
|
|
264
|
+
oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
265
|
+
}
|
|
266
|
+
if (!oauthConfig) {
|
|
267
|
+
console.error(`❌ Could not configure OAuth for '${mcpServerName}' - please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
// OAuth configuration discovered - proceed with authentication
|
|
271
|
+
// Create OAuth configuration for authentication
|
|
272
|
+
const oauthAuthConfig = {
|
|
273
|
+
enabled: true,
|
|
274
|
+
authorizationUrl: oauthConfig.authorizationUrl,
|
|
275
|
+
tokenUrl: oauthConfig.tokenUrl,
|
|
276
|
+
scopes: oauthConfig.scopes || [],
|
|
277
|
+
};
|
|
278
|
+
// Perform OAuth authentication
|
|
279
|
+
// Pass the server URL for proper discovery
|
|
280
|
+
const serverUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
281
|
+
console.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
282
|
+
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
283
|
+
await authProvider.authenticate(mcpServerName, oauthAuthConfig, serverUrl);
|
|
284
|
+
console.log(`OAuth authentication successful for server '${mcpServerName}'`);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
console.error(`Failed to handle automatic OAuth for server '${mcpServerName}': ${getErrorMessage(error)}`);
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Create a transport with OAuth token for the given server configuration.
|
|
294
|
+
*
|
|
295
|
+
* @param mcpServerName The name of the MCP server
|
|
296
|
+
* @param mcpServerConfig The MCP server configuration
|
|
297
|
+
* @param accessToken The OAuth access token
|
|
298
|
+
* @returns The transport with OAuth token, or null if creation fails
|
|
299
|
+
*/
|
|
300
|
+
async function createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken) {
|
|
301
|
+
try {
|
|
302
|
+
if (mcpServerConfig.httpUrl) {
|
|
303
|
+
// Create HTTP transport with OAuth token
|
|
304
|
+
const oauthTransportOptions = {
|
|
305
|
+
requestInit: {
|
|
306
|
+
headers: {
|
|
307
|
+
...mcpServerConfig.headers,
|
|
308
|
+
Authorization: `Bearer ${accessToken}`,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), oauthTransportOptions);
|
|
313
|
+
}
|
|
314
|
+
else if (mcpServerConfig.url) {
|
|
315
|
+
// Create SSE transport with OAuth token in Authorization header
|
|
316
|
+
return new SSEClientTransport(new URL(mcpServerConfig.url), {
|
|
317
|
+
requestInit: {
|
|
318
|
+
headers: {
|
|
319
|
+
...mcpServerConfig.headers,
|
|
320
|
+
Authorization: `Bearer ${accessToken}`,
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
console.error(`Failed to create OAuth transport for server '${mcpServerName}': ${getErrorMessage(error)}`);
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Discovers tools from all configured MCP servers and registers them with the tool registry.
|
|
334
|
+
* It orchestrates the connection and discovery process for each server defined in the
|
|
335
|
+
* configuration, as well as any server specified via a command-line argument.
|
|
336
|
+
*
|
|
337
|
+
* @param mcpServers A record of named MCP server configurations.
|
|
338
|
+
* @param mcpServerCommand An optional command string for a dynamically specified MCP server.
|
|
339
|
+
* @param toolRegistry The central registry where discovered tools will be registered.
|
|
340
|
+
* @returns A promise that resolves when the discovery process has been attempted for all servers.
|
|
341
|
+
*/
|
|
342
|
+
export async function discoverMcpTools(mcpServers, mcpServerCommand, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig) {
|
|
343
|
+
mcpDiscoveryState = MCPDiscoveryState.IN_PROGRESS;
|
|
344
|
+
try {
|
|
345
|
+
mcpServers = populateMcpServerCommand(mcpServers, mcpServerCommand);
|
|
346
|
+
const discoveryPromises = Object.entries(mcpServers).map(([mcpServerName, mcpServerConfig]) => connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig));
|
|
347
|
+
await Promise.all(discoveryPromises);
|
|
348
|
+
}
|
|
349
|
+
finally {
|
|
350
|
+
mcpDiscoveryState = MCPDiscoveryState.COMPLETED;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/** Visible for Testing */
|
|
354
|
+
export function populateMcpServerCommand(mcpServers, mcpServerCommand) {
|
|
355
|
+
if (mcpServerCommand) {
|
|
356
|
+
const cmd = mcpServerCommand;
|
|
357
|
+
const args = parse(cmd, process.env);
|
|
358
|
+
if (args.some((arg) => typeof arg !== 'string')) {
|
|
359
|
+
throw new Error('failed to parse mcpServerCommand: ' + cmd);
|
|
360
|
+
}
|
|
361
|
+
// use generic server name 'mcp'
|
|
362
|
+
mcpServers['mcp'] = {
|
|
363
|
+
command: args[0],
|
|
364
|
+
args: args.slice(1),
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return mcpServers;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Connects to an MCP server and discovers available tools, registering them with the tool registry.
|
|
371
|
+
* This function handles the complete lifecycle of connecting to a server, discovering tools,
|
|
372
|
+
* and cleaning up resources if no tools are found.
|
|
373
|
+
*
|
|
374
|
+
* @param mcpServerName The name identifier for this MCP server
|
|
375
|
+
* @param mcpServerConfig Configuration object containing connection details
|
|
376
|
+
* @param toolRegistry The registry to register discovered tools with
|
|
377
|
+
* @returns Promise that resolves when discovery is complete
|
|
378
|
+
*/
|
|
379
|
+
export async function connectAndDiscover(mcpServerName, mcpServerConfig, toolRegistry, promptRegistry, debugMode, workspaceContext, cliConfig) {
|
|
380
|
+
updateMCPServerStatus(mcpServerName, MCPServerStatus.CONNECTING);
|
|
381
|
+
let mcpClient;
|
|
382
|
+
try {
|
|
383
|
+
mcpClient = await connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, workspaceContext);
|
|
384
|
+
mcpClient.onerror = (error) => {
|
|
385
|
+
console.error(`MCP ERROR (${mcpServerName}):`, error.toString());
|
|
386
|
+
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
|
|
387
|
+
};
|
|
388
|
+
// Attempt to discover both prompts and tools
|
|
389
|
+
const prompts = await discoverPrompts(mcpServerName, mcpClient, promptRegistry);
|
|
390
|
+
const tools = await discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig);
|
|
391
|
+
// If we have neither prompts nor tools, it's a failed discovery
|
|
392
|
+
if (prompts.length === 0 && tools.length === 0) {
|
|
393
|
+
throw new Error('No prompts or tools found on the server.');
|
|
394
|
+
}
|
|
395
|
+
// If we found anything, the server is connected
|
|
396
|
+
updateMCPServerStatus(mcpServerName, MCPServerStatus.CONNECTED);
|
|
397
|
+
// Register any discovered tools
|
|
398
|
+
for (const tool of tools) {
|
|
399
|
+
toolRegistry.registerTool(tool);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
if (mcpClient) {
|
|
404
|
+
mcpClient.close();
|
|
405
|
+
}
|
|
406
|
+
console.error(`Error connecting to MCP server '${mcpServerName}': ${getErrorMessage(error)}`);
|
|
407
|
+
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Discovers and sanitizes tools from a connected MCP client.
|
|
412
|
+
* It retrieves function declarations from the client, filters out disabled tools,
|
|
413
|
+
* generates valid names for them, and wraps them in `DiscoveredMCPTool` instances.
|
|
414
|
+
*
|
|
415
|
+
* @param mcpServerName The name of the MCP server.
|
|
416
|
+
* @param mcpServerConfig The configuration for the MCP server.
|
|
417
|
+
* @param mcpClient The active MCP client instance.
|
|
418
|
+
* @returns A promise that resolves to an array of discovered and enabled tools.
|
|
419
|
+
* @throws An error if no enabled tools are found or if the server provides invalid function declarations.
|
|
420
|
+
*/
|
|
421
|
+
export async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig) {
|
|
422
|
+
try {
|
|
423
|
+
const mcpCallableTool = mcpToTool(mcpClient, {
|
|
424
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
425
|
+
});
|
|
426
|
+
const tool = await mcpCallableTool.tool();
|
|
427
|
+
if (!Array.isArray(tool.functionDeclarations)) {
|
|
428
|
+
// This is a valid case for a prompt-only server
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
const discoveredTools = [];
|
|
432
|
+
for (const funcDecl of tool.functionDeclarations) {
|
|
433
|
+
try {
|
|
434
|
+
if (!isEnabled(funcDecl, mcpServerName, mcpServerConfig)) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
discoveredTools.push(new DiscoveredMCPTool(mcpCallableTool, mcpServerName, funcDecl.name, funcDecl.description ?? '', funcDecl.parametersJsonSchema ?? { type: 'object', properties: {} }, mcpServerConfig.trust, undefined, cliConfig));
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
console.error(`Error discovering tool: '${funcDecl.name}' from MCP server '${mcpServerName}': ${error.message}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return discoveredTools;
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (error instanceof Error &&
|
|
447
|
+
!error.message?.includes('Method not found')) {
|
|
448
|
+
console.error(`Error discovering tools from ${mcpServerName}: ${getErrorMessage(error)}`);
|
|
449
|
+
}
|
|
450
|
+
return [];
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Discovers and logs prompts from a connected MCP client.
|
|
455
|
+
* It retrieves prompt declarations from the client and logs their names.
|
|
456
|
+
*
|
|
457
|
+
* @param mcpServerName The name of the MCP server.
|
|
458
|
+
* @param mcpClient The active MCP client instance.
|
|
459
|
+
*/
|
|
460
|
+
export async function discoverPrompts(mcpServerName, mcpClient, promptRegistry) {
|
|
461
|
+
try {
|
|
462
|
+
// Only request prompts if the server supports them.
|
|
463
|
+
if (mcpClient.getServerCapabilities()?.prompts == null)
|
|
464
|
+
return [];
|
|
465
|
+
const response = await mcpClient.request({ method: 'prompts/list', params: {} }, ListPromptsResultSchema);
|
|
466
|
+
for (const prompt of response.prompts) {
|
|
467
|
+
promptRegistry.registerPrompt({
|
|
468
|
+
...prompt,
|
|
469
|
+
serverName: mcpServerName,
|
|
470
|
+
invoke: (params) => invokeMcpPrompt(mcpServerName, mcpClient, prompt.name, params),
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
return response.prompts;
|
|
474
|
+
}
|
|
475
|
+
catch (error) {
|
|
476
|
+
// It's okay if this fails, not all servers will have prompts.
|
|
477
|
+
// Don't log an error if the method is not found, which is a common case.
|
|
478
|
+
if (error instanceof Error &&
|
|
479
|
+
!error.message?.includes('Method not found')) {
|
|
480
|
+
console.error(`Error discovering prompts from ${mcpServerName}: ${getErrorMessage(error)}`);
|
|
481
|
+
}
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Invokes a prompt on a connected MCP client.
|
|
487
|
+
*
|
|
488
|
+
* @param mcpServerName The name of the MCP server.
|
|
489
|
+
* @param mcpClient The active MCP client instance.
|
|
490
|
+
* @param promptName The name of the prompt to invoke.
|
|
491
|
+
* @param promptParams The parameters to pass to the prompt.
|
|
492
|
+
* @returns A promise that resolves to the result of the prompt invocation.
|
|
493
|
+
*/
|
|
494
|
+
export async function invokeMcpPrompt(mcpServerName, mcpClient, promptName, promptParams) {
|
|
495
|
+
try {
|
|
496
|
+
const response = await mcpClient.request({
|
|
497
|
+
method: 'prompts/get',
|
|
498
|
+
params: {
|
|
499
|
+
name: promptName,
|
|
500
|
+
arguments: promptParams,
|
|
501
|
+
},
|
|
502
|
+
}, GetPromptResultSchema);
|
|
503
|
+
return response;
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
if (error instanceof Error &&
|
|
507
|
+
!error.message?.includes('Method not found')) {
|
|
508
|
+
console.error(`Error invoking prompt '${promptName}' from ${mcpServerName} ${promptParams}: ${getErrorMessage(error)}`);
|
|
509
|
+
}
|
|
510
|
+
throw error;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* @visiblefortesting
|
|
515
|
+
* Checks if the MCP server configuration has a network transport URL (SSE or HTTP).
|
|
516
|
+
* @param config The MCP server configuration.
|
|
517
|
+
* @returns True if a `url` or `httpUrl` is present, false otherwise.
|
|
518
|
+
*/
|
|
519
|
+
export function hasNetworkTransport(config) {
|
|
520
|
+
return !!(config.url || config.httpUrl);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Creates and connects an MCP client to a server based on the provided configuration.
|
|
524
|
+
* It determines the appropriate transport (Stdio, SSE, or Streamable HTTP) and
|
|
525
|
+
* establishes a connection. It also applies a patch to handle request timeouts.
|
|
526
|
+
*
|
|
527
|
+
* @param mcpServerName The name of the MCP server, used for logging and identification.
|
|
528
|
+
* @param mcpServerConfig The configuration specifying how to connect to the server.
|
|
529
|
+
* @returns A promise that resolves to a connected MCP `Client` instance.
|
|
530
|
+
* @throws An error if the connection fails or the configuration is invalid.
|
|
531
|
+
*/
|
|
532
|
+
export async function connectToMcpServer(mcpServerName, mcpServerConfig, debugMode, workspaceContext) {
|
|
533
|
+
const mcpClient = new Client({
|
|
534
|
+
name: 'qwen-code-mcp-client',
|
|
535
|
+
version: '0.0.1',
|
|
536
|
+
});
|
|
537
|
+
mcpClient.registerCapabilities({
|
|
538
|
+
roots: {
|
|
539
|
+
listChanged: true,
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
mcpClient.setRequestHandler(ListRootsRequestSchema, async () => {
|
|
543
|
+
const roots = [];
|
|
544
|
+
for (const dir of workspaceContext.getDirectories()) {
|
|
545
|
+
roots.push({
|
|
546
|
+
uri: pathToFileURL(dir).toString(),
|
|
547
|
+
name: basename(dir),
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
roots,
|
|
552
|
+
};
|
|
553
|
+
});
|
|
554
|
+
let unlistenDirectories = workspaceContext.onDirectoriesChanged(async () => {
|
|
555
|
+
try {
|
|
556
|
+
await mcpClient.notification({
|
|
557
|
+
method: 'notifications/roots/list_changed',
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
catch (_) {
|
|
561
|
+
// If this fails, its almost certainly because the connection was closed
|
|
562
|
+
// and we should just stop listening for future directory changes.
|
|
563
|
+
unlistenDirectories?.();
|
|
564
|
+
unlistenDirectories = undefined;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
// Attempt to pro-actively unsubscribe if the mcp client closes. This API is
|
|
568
|
+
// very brittle though so we don't have any guarantees, hence the try/catch
|
|
569
|
+
// above as well.
|
|
570
|
+
//
|
|
571
|
+
// Be a good steward and don't just bash over onclose.
|
|
572
|
+
const oldOnClose = mcpClient.onclose;
|
|
573
|
+
mcpClient.onclose = () => {
|
|
574
|
+
oldOnClose?.();
|
|
575
|
+
unlistenDirectories?.();
|
|
576
|
+
unlistenDirectories = undefined;
|
|
577
|
+
};
|
|
578
|
+
try {
|
|
579
|
+
const transport = await createTransport(mcpServerName, mcpServerConfig, debugMode);
|
|
580
|
+
try {
|
|
581
|
+
await mcpClient.connect(transport, {
|
|
582
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
583
|
+
});
|
|
584
|
+
return mcpClient;
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
await transport.close();
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
// Check if this is a 401 error that might indicate OAuth is required
|
|
593
|
+
const errorString = String(error);
|
|
594
|
+
if (errorString.includes('401') && hasNetworkTransport(mcpServerConfig)) {
|
|
595
|
+
mcpServerRequiresOAuth.set(mcpServerName, true);
|
|
596
|
+
// Only trigger automatic OAuth discovery for HTTP servers or when OAuth is explicitly configured
|
|
597
|
+
// For SSE servers, we should not trigger new OAuth flows automatically
|
|
598
|
+
const shouldTriggerOAuth = mcpServerConfig.httpUrl || mcpServerConfig.oauth?.enabled;
|
|
599
|
+
if (!shouldTriggerOAuth) {
|
|
600
|
+
// For SSE servers without explicit OAuth config, if a token was found but rejected, report it accurately.
|
|
601
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
602
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
603
|
+
if (credentials) {
|
|
604
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
605
|
+
const hasStoredTokens = await authProvider.getValidToken(mcpServerName, {
|
|
606
|
+
// Pass client ID if available
|
|
607
|
+
clientId: credentials.clientId,
|
|
608
|
+
});
|
|
609
|
+
if (hasStoredTokens) {
|
|
610
|
+
console.log(`Stored OAuth token for SSE server '${mcpServerName}' was rejected. ` +
|
|
611
|
+
`Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
console.log(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
615
|
+
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
throw new Error(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
619
|
+
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
620
|
+
}
|
|
621
|
+
// Try to extract www-authenticate header from the error
|
|
622
|
+
let wwwAuthenticate = extractWWWAuthenticateHeader(errorString);
|
|
623
|
+
// If we didn't get the header from the error string, try to get it from the server
|
|
624
|
+
if (!wwwAuthenticate && hasNetworkTransport(mcpServerConfig)) {
|
|
625
|
+
console.log(`No www-authenticate header in error, trying to fetch it from server...`);
|
|
626
|
+
try {
|
|
627
|
+
const urlToFetch = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
628
|
+
const response = await fetch(urlToFetch, {
|
|
629
|
+
method: 'HEAD',
|
|
630
|
+
headers: {
|
|
631
|
+
Accept: mcpServerConfig.httpUrl
|
|
632
|
+
? 'application/json'
|
|
633
|
+
: 'text/event-stream',
|
|
634
|
+
},
|
|
635
|
+
signal: AbortSignal.timeout(5000),
|
|
636
|
+
});
|
|
637
|
+
if (response.status === 401) {
|
|
638
|
+
wwwAuthenticate = response.headers.get('www-authenticate');
|
|
639
|
+
if (wwwAuthenticate) {
|
|
640
|
+
console.log(`Found www-authenticate header from server: ${wwwAuthenticate}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
catch (fetchError) {
|
|
645
|
+
console.debug(`Failed to fetch www-authenticate header: ${getErrorMessage(fetchError)}`);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (wwwAuthenticate) {
|
|
649
|
+
console.log(`Received 401 with www-authenticate header: ${wwwAuthenticate}`);
|
|
650
|
+
// Try automatic OAuth discovery and authentication
|
|
651
|
+
const oauthSuccess = await handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthenticate);
|
|
652
|
+
if (oauthSuccess) {
|
|
653
|
+
// Retry connection with OAuth token
|
|
654
|
+
console.log(`Retrying connection to '${mcpServerName}' with OAuth token...`);
|
|
655
|
+
// Get the valid token - we need to create a proper OAuth config
|
|
656
|
+
// The token should already be available from the authentication process
|
|
657
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
658
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
659
|
+
if (credentials) {
|
|
660
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
661
|
+
const accessToken = await authProvider.getValidToken(mcpServerName, {
|
|
662
|
+
// Pass client ID if available
|
|
663
|
+
clientId: credentials.clientId,
|
|
664
|
+
});
|
|
665
|
+
if (accessToken) {
|
|
666
|
+
// Create transport with OAuth token
|
|
667
|
+
const oauthTransport = await createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken);
|
|
668
|
+
if (oauthTransport) {
|
|
669
|
+
try {
|
|
670
|
+
await mcpClient.connect(oauthTransport, {
|
|
671
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
672
|
+
});
|
|
673
|
+
// Connection successful with OAuth
|
|
674
|
+
return mcpClient;
|
|
675
|
+
}
|
|
676
|
+
catch (retryError) {
|
|
677
|
+
console.error(`Failed to connect with OAuth token: ${getErrorMessage(retryError)}`);
|
|
678
|
+
throw retryError;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
console.error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
683
|
+
throw new Error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
console.error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
688
|
+
throw new Error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
console.error(`Failed to get credentials for server '${mcpServerName}' after successful OAuth authentication`);
|
|
693
|
+
throw new Error(`Failed to get credentials for server '${mcpServerName}' after successful OAuth authentication`);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
console.error(`Failed to handle automatic OAuth for server '${mcpServerName}'`);
|
|
698
|
+
throw new Error(`Failed to handle automatic OAuth for server '${mcpServerName}'`);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
// No www-authenticate header found, but we got a 401
|
|
703
|
+
// Only try OAuth discovery for HTTP servers or when OAuth is explicitly configured
|
|
704
|
+
// For SSE servers, we should not trigger new OAuth flows automatically
|
|
705
|
+
const shouldTryDiscovery = mcpServerConfig.httpUrl || mcpServerConfig.oauth?.enabled;
|
|
706
|
+
if (!shouldTryDiscovery) {
|
|
707
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
708
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
709
|
+
if (credentials) {
|
|
710
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
711
|
+
const hasStoredTokens = await authProvider.getValidToken(mcpServerName, {
|
|
712
|
+
// Pass client ID if available
|
|
713
|
+
clientId: credentials.clientId,
|
|
714
|
+
});
|
|
715
|
+
if (hasStoredTokens) {
|
|
716
|
+
console.log(`Stored OAuth token for SSE server '${mcpServerName}' was rejected. ` +
|
|
717
|
+
`Please re-authenticate using: /mcp auth ${mcpServerName}`);
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
console.log(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
721
|
+
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
throw new Error(`401 error received for SSE server '${mcpServerName}' without OAuth configuration. ` +
|
|
725
|
+
`Please authenticate using: /mcp auth ${mcpServerName}`);
|
|
726
|
+
}
|
|
727
|
+
// For SSE/HTTP servers, try to discover OAuth configuration from the base URL
|
|
728
|
+
console.log(`🔍 Attempting OAuth discovery for '${mcpServerName}'...`);
|
|
729
|
+
if (hasNetworkTransport(mcpServerConfig)) {
|
|
730
|
+
const serverUrl = new URL(mcpServerConfig.httpUrl || mcpServerConfig.url);
|
|
731
|
+
const baseUrl = `${serverUrl.protocol}//${serverUrl.host}`;
|
|
732
|
+
try {
|
|
733
|
+
// Try to discover OAuth configuration from the base URL
|
|
734
|
+
const oauthConfig = await OAuthUtils.discoverOAuthConfig(baseUrl);
|
|
735
|
+
if (oauthConfig) {
|
|
736
|
+
console.log(`Discovered OAuth configuration from base URL for server '${mcpServerName}'`);
|
|
737
|
+
// Create OAuth configuration for authentication
|
|
738
|
+
const oauthAuthConfig = {
|
|
739
|
+
enabled: true,
|
|
740
|
+
authorizationUrl: oauthConfig.authorizationUrl,
|
|
741
|
+
tokenUrl: oauthConfig.tokenUrl,
|
|
742
|
+
scopes: oauthConfig.scopes || [],
|
|
743
|
+
};
|
|
744
|
+
// Perform OAuth authentication
|
|
745
|
+
// Pass the server URL for proper discovery
|
|
746
|
+
const authServerUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
|
|
747
|
+
console.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
|
|
748
|
+
const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
|
|
749
|
+
await authProvider.authenticate(mcpServerName, oauthAuthConfig, authServerUrl);
|
|
750
|
+
// Retry connection with OAuth token
|
|
751
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
752
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
753
|
+
if (credentials) {
|
|
754
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
755
|
+
const accessToken = await authProvider.getValidToken(mcpServerName, {
|
|
756
|
+
// Pass client ID if available
|
|
757
|
+
clientId: credentials.clientId,
|
|
758
|
+
});
|
|
759
|
+
if (accessToken) {
|
|
760
|
+
// Create transport with OAuth token
|
|
761
|
+
const oauthTransport = await createTransportWithOAuth(mcpServerName, mcpServerConfig, accessToken);
|
|
762
|
+
if (oauthTransport) {
|
|
763
|
+
try {
|
|
764
|
+
await mcpClient.connect(oauthTransport, {
|
|
765
|
+
timeout: mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
|
766
|
+
});
|
|
767
|
+
// Connection successful with OAuth
|
|
768
|
+
return mcpClient;
|
|
769
|
+
}
|
|
770
|
+
catch (retryError) {
|
|
771
|
+
console.error(`Failed to connect with OAuth token: ${getErrorMessage(retryError)}`);
|
|
772
|
+
throw retryError;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
console.error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
777
|
+
throw new Error(`Failed to create OAuth transport for server '${mcpServerName}'`);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
console.error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
782
|
+
throw new Error(`Failed to get OAuth token for server '${mcpServerName}'`);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
console.error(`Failed to get stored credentials for server '${mcpServerName}'`);
|
|
787
|
+
throw new Error(`Failed to get stored credentials for server '${mcpServerName}'`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
console.error(`❌ Could not configure OAuth for '${mcpServerName}' - please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
792
|
+
throw new Error(`OAuth configuration failed for '${mcpServerName}'. Please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
catch (discoveryError) {
|
|
796
|
+
console.error(`❌ OAuth discovery failed for '${mcpServerName}' - please authenticate manually with /mcp auth ${mcpServerName}`);
|
|
797
|
+
throw discoveryError;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
console.error(`❌ '${mcpServerName}' requires authentication but no OAuth configuration found`);
|
|
802
|
+
throw new Error(`MCP server '${mcpServerName}' requires authentication. Please configure OAuth or check server settings.`);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
// Handle other connection errors
|
|
808
|
+
// Create a concise error message
|
|
809
|
+
const errorMessage = error.message || String(error);
|
|
810
|
+
const isNetworkError = errorMessage.includes('ENOTFOUND') ||
|
|
811
|
+
errorMessage.includes('ECONNREFUSED');
|
|
812
|
+
let conciseError;
|
|
813
|
+
if (isNetworkError) {
|
|
814
|
+
conciseError = `Cannot connect to '${mcpServerName}' - server may be down or URL incorrect`;
|
|
815
|
+
}
|
|
816
|
+
else {
|
|
817
|
+
conciseError = `Connection failed for '${mcpServerName}': ${errorMessage}`;
|
|
818
|
+
}
|
|
819
|
+
if (process.env['SANDBOX']) {
|
|
820
|
+
conciseError += ` (check sandbox availability)`;
|
|
821
|
+
}
|
|
822
|
+
throw new Error(conciseError);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
/** Visible for Testing */
|
|
827
|
+
export async function createTransport(mcpServerName, mcpServerConfig, debugMode) {
|
|
828
|
+
if (mcpServerConfig.authProviderType ===
|
|
829
|
+
AuthProviderType.SERVICE_ACCOUNT_IMPERSONATION) {
|
|
830
|
+
const provider = new ServiceAccountImpersonationProvider(mcpServerConfig);
|
|
831
|
+
const transportOptions = {
|
|
832
|
+
authProvider: provider,
|
|
833
|
+
};
|
|
834
|
+
if (mcpServerConfig.httpUrl) {
|
|
835
|
+
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), transportOptions);
|
|
836
|
+
}
|
|
837
|
+
else if (mcpServerConfig.url) {
|
|
838
|
+
// Default to SSE if only url is provided
|
|
839
|
+
return new SSEClientTransport(new URL(mcpServerConfig.url), transportOptions);
|
|
840
|
+
}
|
|
841
|
+
throw new Error('No URL configured for ServiceAccountImpersonation MCP Server');
|
|
842
|
+
}
|
|
843
|
+
if (mcpServerConfig.authProviderType === AuthProviderType.GOOGLE_CREDENTIALS) {
|
|
844
|
+
const provider = new GoogleCredentialProvider(mcpServerConfig);
|
|
845
|
+
const transportOptions = {
|
|
846
|
+
authProvider: provider,
|
|
847
|
+
};
|
|
848
|
+
if (mcpServerConfig.httpUrl) {
|
|
849
|
+
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), transportOptions);
|
|
850
|
+
}
|
|
851
|
+
else if (mcpServerConfig.url) {
|
|
852
|
+
return new SSEClientTransport(new URL(mcpServerConfig.url), transportOptions);
|
|
853
|
+
}
|
|
854
|
+
throw new Error('No URL configured for Google Credentials MCP server');
|
|
855
|
+
}
|
|
856
|
+
// Check if we have OAuth configuration or stored tokens
|
|
857
|
+
let accessToken = null;
|
|
858
|
+
let hasOAuthConfig = mcpServerConfig.oauth?.enabled;
|
|
859
|
+
if (hasOAuthConfig && mcpServerConfig.oauth) {
|
|
860
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
861
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
862
|
+
accessToken = await authProvider.getValidToken(mcpServerName, mcpServerConfig.oauth);
|
|
863
|
+
if (!accessToken) {
|
|
864
|
+
console.error(`MCP server '${mcpServerName}' requires OAuth authentication. ` +
|
|
865
|
+
`Please authenticate using the /mcp auth command.`);
|
|
866
|
+
throw new Error(`MCP server '${mcpServerName}' requires OAuth authentication. ` +
|
|
867
|
+
`Please authenticate using the /mcp auth command.`);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
// Check if we have stored OAuth tokens for this server (from previous authentication)
|
|
872
|
+
const tokenStorage = new MCPOAuthTokenStorage();
|
|
873
|
+
const credentials = await tokenStorage.getCredentials(mcpServerName);
|
|
874
|
+
if (credentials) {
|
|
875
|
+
const authProvider = new MCPOAuthProvider(tokenStorage);
|
|
876
|
+
accessToken = await authProvider.getValidToken(mcpServerName, {
|
|
877
|
+
// Pass client ID if available
|
|
878
|
+
clientId: credentials.clientId,
|
|
879
|
+
});
|
|
880
|
+
if (accessToken) {
|
|
881
|
+
hasOAuthConfig = true;
|
|
882
|
+
console.log(`Found stored OAuth token for server '${mcpServerName}'`);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (mcpServerConfig.httpUrl) {
|
|
887
|
+
const transportOptions = {};
|
|
888
|
+
// Set up headers with OAuth token if available
|
|
889
|
+
if (hasOAuthConfig && accessToken) {
|
|
890
|
+
transportOptions.requestInit = {
|
|
891
|
+
headers: {
|
|
892
|
+
...mcpServerConfig.headers,
|
|
893
|
+
Authorization: `Bearer ${accessToken}`,
|
|
894
|
+
},
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
else if (mcpServerConfig.headers) {
|
|
898
|
+
transportOptions.requestInit = {
|
|
899
|
+
headers: mcpServerConfig.headers,
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
return new StreamableHTTPClientTransport(new URL(mcpServerConfig.httpUrl), transportOptions);
|
|
903
|
+
}
|
|
904
|
+
if (mcpServerConfig.url) {
|
|
905
|
+
const transportOptions = {};
|
|
906
|
+
// Set up headers with OAuth token if available
|
|
907
|
+
if (hasOAuthConfig && accessToken) {
|
|
908
|
+
transportOptions.requestInit = {
|
|
909
|
+
headers: {
|
|
910
|
+
...mcpServerConfig.headers,
|
|
911
|
+
Authorization: `Bearer ${accessToken}`,
|
|
912
|
+
},
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
else if (mcpServerConfig.headers) {
|
|
916
|
+
transportOptions.requestInit = {
|
|
917
|
+
headers: mcpServerConfig.headers,
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
return new SSEClientTransport(new URL(mcpServerConfig.url), transportOptions);
|
|
921
|
+
}
|
|
922
|
+
if (mcpServerConfig.command) {
|
|
923
|
+
const transport = new StdioClientTransport({
|
|
924
|
+
command: mcpServerConfig.command,
|
|
925
|
+
args: mcpServerConfig.args || [],
|
|
926
|
+
env: {
|
|
927
|
+
...process.env,
|
|
928
|
+
...(mcpServerConfig.env || {}),
|
|
929
|
+
},
|
|
930
|
+
cwd: mcpServerConfig.cwd,
|
|
931
|
+
stderr: 'pipe',
|
|
932
|
+
});
|
|
933
|
+
if (debugMode) {
|
|
934
|
+
transport.stderr.on('data', (data) => {
|
|
935
|
+
const stderrStr = data.toString().trim();
|
|
936
|
+
console.debug(`[DEBUG] [MCP STDERR (${mcpServerName})]: `, stderrStr);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
return transport;
|
|
940
|
+
}
|
|
941
|
+
throw new Error(`Invalid configuration: missing httpUrl (for Streamable HTTP), url (for SSE), and command (for stdio).`);
|
|
942
|
+
}
|
|
943
|
+
/** Visible for testing */
|
|
944
|
+
export function isEnabled(funcDecl, mcpServerName, mcpServerConfig) {
|
|
945
|
+
if (!funcDecl.name) {
|
|
946
|
+
console.warn(`Discovered a function declaration without a name from MCP server '${mcpServerName}'. Skipping.`);
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
const { includeTools, excludeTools } = mcpServerConfig;
|
|
950
|
+
// excludeTools takes precedence over includeTools
|
|
951
|
+
if (excludeTools && excludeTools.includes(funcDecl.name)) {
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
return (!includeTools ||
|
|
955
|
+
includeTools.some((tool) => tool === funcDecl.name || tool.startsWith(`${funcDecl.name}(`)));
|
|
956
|
+
}
|
|
957
|
+
//# sourceMappingURL=mcp-client.js.map
|