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