@opensumi/ide-ai-native 3.8.1-next-1741250387.0 → 3.8.1-next-1741251026.0
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/lib/browser/ai-core.contextkeys.d.ts +1 -1
- package/lib/browser/ai-core.contextkeys.d.ts.map +1 -1
- package/lib/browser/ai-core.contextkeys.js +1 -1
- package/lib/browser/ai-core.contextkeys.js.map +1 -1
- package/lib/browser/ai-core.contribution.d.ts +5 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +71 -9
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts +11 -3
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +43 -5
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +1 -0
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +6 -8
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +4 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +57 -2
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +13 -6
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.api.service.d.ts +1 -2
- package/lib/browser/chat/chat.api.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.api.service.js +0 -4
- package/lib/browser/chat/chat.api.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +2 -0
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +3 -0
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +1 -2
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +46 -29
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +29 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +6 -1
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +0 -2
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +2 -10
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +2 -3
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/WelcomeMsg.js +1 -1
- package/lib/browser/components/WelcomeMsg.js.map +1 -1
- package/lib/browser/components/chat-history.module.less +2 -1
- package/lib/browser/components/components.module.less +22 -0
- package/lib/browser/context/llm-context.service.d.ts +18 -5
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +80 -47
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.controller.js +1 -1
- package/lib/browser/contrib/inline-completions/inline-completions.controller.js.map +1 -1
- package/lib/browser/contrib/inline-completions/prompt/matcher.js +2 -2
- package/lib/browser/contrib/inline-completions/prompt/similarSnippets.d.ts +1 -1
- package/lib/browser/contrib/inline-completions/prompt/similarSnippets.js +2 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts +2 -1
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +4 -1
- package/lib/browser/contrib/intelligent-completions/index.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js +2 -2
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.contribution.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js +6 -5
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.js +4 -2
- package/lib/browser/contrib/intelligent-completions/view/code-edits-previewer.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/default.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/view/default.js +23 -11
- package/lib/browser/contrib/intelligent-completions/view/default.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +4 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/layout.module.less +4 -4
- package/lib/browser/mcp/base-apply.service.d.ts +26 -11
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +255 -103
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.module.less +178 -0
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts +3 -0
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +1 -0
- package/lib/browser/mcp/config/components/mcp-config.view.js +150 -0
- package/lib/browser/mcp/config/components/mcp-config.view.js.map +1 -0
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts +16 -0
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts.map +1 -0
- package/lib/browser/mcp/config/components/mcp-server-form.js +84 -0
- package/lib/browser/mcp/config/components/mcp-server-form.js.map +1 -0
- package/lib/browser/mcp/config/components/mcp-server-form.module.less +78 -0
- package/lib/browser/mcp/config/mcp-config.commands.d.ts +10 -0
- package/lib/browser/mcp/config/mcp-config.commands.d.ts.map +1 -0
- package/lib/browser/mcp/config/mcp-config.commands.js +35 -0
- package/lib/browser/mcp/config/mcp-config.commands.js.map +1 -0
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts +16 -0
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts.map +1 -0
- package/lib/browser/mcp/config/mcp-config.contribution.js +62 -0
- package/lib/browser/mcp/config/mcp-config.contribution.js.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +6 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +10 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +8 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +28 -3
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.js +15 -9
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts +13 -0
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/{SearchResult.js → ExpandableFileList.js} +29 -19
- package/lib/browser/mcp/tools/components/ExpandableFileList.js.map +1 -0
- package/lib/browser/mcp/tools/components/Terminal.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/Terminal.js +10 -2
- package/lib/browser/mcp/tools/components/Terminal.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +4 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +19 -11
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts +1 -0
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.js +14 -5
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.js +6 -3
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js +3 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +2 -0
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/listDir.d.ts +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +35 -4
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +2 -2
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +4 -10
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +22 -2
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +4 -0
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-controller.js +6 -1
- package/lib/browser/widget/inline-chat/inline-chat-controller.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.js +68 -8
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +10 -4
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +14 -3
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +25 -4
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts +3 -3
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.js +10 -5
- package/lib/browser/widget/inline-diff/inline-diff.controller.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +46 -17
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +110 -53
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts +4 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +26 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +13 -4
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +5 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +13 -9
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/mcp-server-manager.d.ts +17 -1
- package/lib/common/mcp-server-manager.d.ts.map +1 -1
- package/lib/common/mcp-server-manager.js.map +1 -1
- package/lib/common/model.d.ts +12 -0
- package/lib/common/model.d.ts.map +1 -0
- package/lib/common/model.js +83 -0
- package/lib/common/model.js.map +1 -0
- package/lib/common/prompts/context-prompt-provider.d.ts +4 -3
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +33 -22
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/tool-invocation-registry.d.ts +2 -2
- package/lib/common/tool-invocation-registry.d.ts.map +1 -1
- package/lib/common/tool-invocation-registry.js +1 -1
- package/lib/common/tool-invocation-registry.js.map +1 -1
- package/lib/common/types.d.ts +8 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -1
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +3 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.js +6 -2
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -1
- package/lib/node/base-language-model.d.ts +6 -3
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +14 -31
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +3 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.js +6 -2
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +17 -3
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +59 -6
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +4 -3
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +26 -6
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.d.ts +5 -16
- package/lib/node/mcp-server.d.ts.map +1 -1
- package/lib/node/mcp-server.js +12 -6
- package/lib/node/mcp-server.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +4 -2
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +6 -4
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts +10 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts.map +1 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.js +32 -0
- package/lib/node/openai-compatible/openai-compatible-language-model.js.map +1 -0
- package/package.json +27 -26
- package/src/browser/ai-core.contextkeys.ts +3 -3
- package/src/browser/ai-core.contribution.ts +89 -12
- package/src/browser/chat/chat-agent.service.ts +53 -9
- package/src/browser/chat/chat-manager.service.ts +10 -8
- package/src/browser/chat/chat-model.ts +63 -5
- package/src/browser/chat/chat-proxy.service.ts +16 -8
- package/src/browser/chat/chat.api.service.ts +1 -5
- package/src/browser/chat/chat.internal.service.ts +4 -0
- package/src/browser/chat/chat.module.less +1 -2
- package/src/browser/chat/chat.view.tsx +63 -69
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatInput.tsx +81 -6
- package/src/browser/components/ChatReply.tsx +6 -6
- package/src/browser/components/ChatThinking.tsx +3 -9
- package/src/browser/components/ChatToolRender.tsx +1 -2
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/components/chat-history.module.less +2 -1
- package/src/browser/components/components.module.less +22 -0
- package/src/browser/context/llm-context.service.ts +93 -54
- package/src/browser/contrib/inline-completions/inline-completions.controller.ts +1 -1
- package/src/browser/contrib/inline-completions/prompt/matcher.ts +2 -2
- package/src/browser/contrib/inline-completions/prompt/similarSnippets.ts +2 -2
- package/src/browser/contrib/intelligent-completions/index.ts +5 -1
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +3 -3
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +7 -6
- package/src/browser/contrib/intelligent-completions/view/code-edits-previewer.ts +4 -2
- package/src/browser/contrib/intelligent-completions/view/default.ts +34 -19
- package/src/browser/index.ts +4 -0
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +306 -109
- package/src/browser/mcp/config/components/mcp-config.module.less +178 -0
- package/src/browser/mcp/config/components/mcp-config.view.tsx +215 -0
- package/src/browser/mcp/config/components/mcp-server-form.module.less +78 -0
- package/src/browser/mcp/config/components/mcp-server-form.tsx +144 -0
- package/src/browser/mcp/config/mcp-config.commands.ts +29 -0
- package/src/browser/mcp/config/mcp-config.contribution.ts +65 -0
- package/src/browser/mcp/mcp-server-proxy.service.ts +14 -2
- package/src/browser/mcp/mcp-server.feature.registry.ts +35 -4
- package/src/browser/mcp/tools/components/EditFile.tsx +16 -9
- package/src/browser/mcp/tools/components/ExpandableFileList.tsx +133 -0
- package/src/browser/mcp/tools/components/Terminal.tsx +13 -2
- package/src/browser/mcp/tools/components/index.module.less +4 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +21 -12
- package/src/browser/mcp/tools/fileSearch.ts +14 -4
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -0
- package/src/browser/mcp/tools/grepSearch.ts +6 -3
- package/src/browser/mcp/tools/handlers/EditFile.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +4 -0
- package/src/browser/mcp/tools/handlers/RunCommand.ts +2 -0
- package/src/browser/mcp/tools/listDir.ts +36 -5
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -0
- package/src/browser/model/msg-history-manager.ts +5 -11
- package/src/browser/preferences/schema.ts +22 -2
- package/src/browser/types.ts +1 -0
- package/src/browser/widget/inline-chat/inline-chat-controller.ts +5 -1
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +143 -21
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +25 -7
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +25 -4
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +16 -8
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +139 -68
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +30 -1
- package/src/common/index.ts +15 -4
- package/src/common/llm-context.ts +10 -4
- package/src/common/mcp-server-manager.ts +17 -1
- package/src/common/model.ts +90 -0
- package/src/common/prompts/context-prompt-provider.ts +38 -29
- package/src/common/tool-invocation-registry.ts +2 -2
- package/src/common/types.ts +8 -0
- package/src/common/utils.ts +3 -1
- package/src/node/anthropic/anthropic-language-model.ts +7 -2
- package/src/node/base-language-model.ts +25 -38
- package/src/node/deepseek/deepseek-language-model.ts +7 -2
- package/src/node/mcp/sumi-mcp-server.ts +67 -9
- package/src/node/mcp-server-manager-impl.ts +30 -9
- package/src/node/mcp-server.ts +11 -14
- package/src/node/openai/openai-language-model.ts +8 -4
- package/src/node/openai-compatible/openai-compatible-language-model.ts +30 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +0 -11
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/SearchResult.js.map +0 -1
- package/src/browser/mcp/tools/components/SearchResult.tsx +0 -92
|
@@ -4,7 +4,7 @@ import { Autowired, Injectable } from '@opensumi/di';
|
|
|
4
4
|
import { ILogger } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { Emitter, Event } from '@opensumi/ide-core-common';
|
|
6
6
|
|
|
7
|
-
import { ISumiMCPServerBackend, SumiMCPServerProxyServicePath } from '../../common';
|
|
7
|
+
import { BUILTIN_MCP_SERVER_NAME, ISumiMCPServerBackend, SumiMCPServerProxyServicePath } from '../../common';
|
|
8
8
|
import { IMCPServerProxyService } from '../../common/types';
|
|
9
9
|
import { IMCPServerRegistry, TokenMCPServerRegistry } from '../types';
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export class MCPServerProxyService implements IMCPServerProxyService {
|
|
|
35
35
|
name: tool.name,
|
|
36
36
|
description: tool.description,
|
|
37
37
|
inputSchema: zodToJsonSchema(tool.inputSchema),
|
|
38
|
-
providerName:
|
|
38
|
+
providerName: BUILTIN_MCP_SERVER_NAME,
|
|
39
39
|
}),
|
|
40
40
|
);
|
|
41
41
|
|
|
@@ -52,4 +52,16 @@ export class MCPServerProxyService implements IMCPServerProxyService {
|
|
|
52
52
|
async getAllMCPTools() {
|
|
53
53
|
return this.sumiMCPServerProxyService.getAllMCPTools();
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
async $getServers() {
|
|
57
|
+
return this.sumiMCPServerProxyService.getServers();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async $startServer(serverName: string) {
|
|
61
|
+
await this.sumiMCPServerProxyService.startServer(serverName);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async $stopServer(serverName: string) {
|
|
65
|
+
await this.sumiMCPServerProxyService.stopServer(serverName);
|
|
66
|
+
}
|
|
55
67
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// OpenSumi as MCP Server 前端的代理服务
|
|
2
2
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
3
|
-
import { ILogger } from '@opensumi/ide-core-common';
|
|
3
|
+
import { AIServiceType, IAIReporter, ILogger } from '@opensumi/ide-core-common';
|
|
4
4
|
|
|
5
|
+
import { BUILTIN_MCP_SERVER_NAME } from '../../common';
|
|
5
6
|
import { getToolName } from '../../common/utils';
|
|
6
7
|
import { IMCPServerRegistry, IMCPServerToolComponentProps, MCPLogger, MCPToolDefinition } from '../types';
|
|
7
8
|
|
|
@@ -18,14 +19,27 @@ export class MCPServerRegistry implements IMCPServerRegistry {
|
|
|
18
19
|
private tools: MCPToolDefinition[] = [];
|
|
19
20
|
private toolComponents: Record<string, React.FC<IMCPServerToolComponentProps>> = {};
|
|
20
21
|
|
|
22
|
+
private _activeMessageInfo: {
|
|
23
|
+
messageId: string;
|
|
24
|
+
sessionId: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
21
27
|
@Autowired(ILogger)
|
|
22
28
|
private readonly baseLogger: ILogger;
|
|
23
29
|
|
|
30
|
+
@Autowired(IAIReporter)
|
|
31
|
+
private readonly aiReporter: IAIReporter;
|
|
32
|
+
|
|
24
33
|
private get logger(): MCPLogger {
|
|
25
34
|
return new LoggerAdapter(this.baseLogger);
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
/** 设置当前活跃的消息信息,便于toolCall打点 */
|
|
38
|
+
set activeMessageInfo(params: { messageId: string; sessionId: string }) {
|
|
39
|
+
this._activeMessageInfo = params;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getMCPTool(name: string, serverName = BUILTIN_MCP_SERVER_NAME): MCPToolDefinition | undefined {
|
|
29
43
|
return this.tools.find((tool) => getToolName(tool.name, serverName) === name);
|
|
30
44
|
}
|
|
31
45
|
|
|
@@ -36,7 +50,7 @@ export class MCPServerRegistry implements IMCPServerRegistry {
|
|
|
36
50
|
registerToolComponent(
|
|
37
51
|
name: string,
|
|
38
52
|
component: React.FC<IMCPServerToolComponentProps>,
|
|
39
|
-
serverName =
|
|
53
|
+
serverName = BUILTIN_MCP_SERVER_NAME,
|
|
40
54
|
): void {
|
|
41
55
|
this.toolComponents[getToolName(name, serverName)] = component;
|
|
42
56
|
}
|
|
@@ -64,14 +78,31 @@ export class MCPServerRegistry implements IMCPServerRegistry {
|
|
|
64
78
|
// 统一校验并转换
|
|
65
79
|
const toolCallId = args.toolCallId;
|
|
66
80
|
args = tool.inputSchema.parse(args);
|
|
67
|
-
|
|
81
|
+
const result = await tool.handler({ ...args, toolCallId }, this.logger);
|
|
82
|
+
this.reportToolCall(name, args, result, toolCallId);
|
|
83
|
+
return result;
|
|
68
84
|
} catch (error) {
|
|
69
85
|
// eslint-disable-next-line no-console
|
|
70
86
|
console.error('callMCPTool error:', error);
|
|
87
|
+
this.reportToolCall(name, args, error, args.toolCallId);
|
|
71
88
|
return {
|
|
72
89
|
content: [{ type: 'text', text: `The tool ${name} failed to execute. Error: ${error}` }],
|
|
73
90
|
isError: true,
|
|
74
91
|
};
|
|
75
92
|
}
|
|
76
93
|
}
|
|
94
|
+
|
|
95
|
+
private reportToolCall(name: string, args: any, result: any, toolCallId: string) {
|
|
96
|
+
const tool = this.tools.find((tool) => tool.name === name);
|
|
97
|
+
if (!tool) {
|
|
98
|
+
throw new Error(`MCP tool ${name} not found`);
|
|
99
|
+
}
|
|
100
|
+
this.aiReporter.send({
|
|
101
|
+
msgType: AIServiceType.ToolCall,
|
|
102
|
+
message: JSON.stringify({ args, name, result }),
|
|
103
|
+
messageId: this._activeMessageInfo.messageId,
|
|
104
|
+
sessionId: this._activeMessageInfo.sessionId,
|
|
105
|
+
relationId: toolCallId,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
77
108
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useInjectable,
|
|
14
14
|
} from '@opensumi/ide-core-browser';
|
|
15
15
|
import { Loading } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
16
|
+
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
16
17
|
import { ILanguageService } from '@opensumi/monaco-editor-core/esm/vs/editor/common/languages/language';
|
|
17
18
|
import { IModelService } from '@opensumi/monaco-editor-core/esm/vs/editor/common/services/model';
|
|
18
19
|
import { StandaloneServices } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
@@ -30,6 +31,7 @@ export const EditFileToolComponent = (props: IMCPServerToolComponentProps) => {
|
|
|
30
31
|
const labelService = useInjectable(LabelService);
|
|
31
32
|
const appConfig = useInjectable<AppConfig>(AppConfig);
|
|
32
33
|
const applyService = useInjectable<BaseApplyService>(BaseApplyService);
|
|
34
|
+
const editorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
|
|
33
35
|
const { target_file = '', code_edit, instructions } = args || {};
|
|
34
36
|
const absolutePath = path.join(appConfig.workspaceDir, target_file);
|
|
35
37
|
const [codeBlockData, setCodeBlockData] = useState<CodeBlockData | undefined>(
|
|
@@ -55,15 +57,20 @@ export const EditFileToolComponent = (props: IMCPServerToolComponentProps) => {
|
|
|
55
57
|
|
|
56
58
|
useEffect(() => {
|
|
57
59
|
const disposable = applyService.onCodeBlockUpdate((codeBlockData) => {
|
|
58
|
-
|
|
60
|
+
if (codeBlockData.toolCallId === toolCallId) {
|
|
61
|
+
setCodeBlockData({ ...codeBlockData });
|
|
62
|
+
}
|
|
59
63
|
});
|
|
60
64
|
return () => {
|
|
61
65
|
disposable.dispose();
|
|
62
66
|
};
|
|
63
67
|
}, []);
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
const handleToggleMode = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
setMode(mode === 'code' ? 'diff' : 'code');
|
|
72
|
+
};
|
|
73
|
+
|
|
67
74
|
if (!args || !codeBlockData) {
|
|
68
75
|
return null;
|
|
69
76
|
}
|
|
@@ -77,7 +84,7 @@ export const EditFileToolComponent = (props: IMCPServerToolComponentProps) => {
|
|
|
77
84
|
})}
|
|
78
85
|
onClick={() => {
|
|
79
86
|
if (codeBlockData.status === 'pending') {
|
|
80
|
-
|
|
87
|
+
editorService.open(URI.file(absolutePath));
|
|
81
88
|
} else if (codeBlockData.status === 'success') {
|
|
82
89
|
applyService.revealApplyPosition(codeBlockData);
|
|
83
90
|
}
|
|
@@ -89,15 +96,15 @@ export const EditFileToolComponent = (props: IMCPServerToolComponentProps) => {
|
|
|
89
96
|
{codeBlockData.iterationCount > 1 && (
|
|
90
97
|
<span className={styles['edit-file-tool-iteration-count']}>{codeBlockData.iterationCount}/3</span>
|
|
91
98
|
)}
|
|
92
|
-
{renderStatus(codeBlockData)}
|
|
99
|
+
{renderStatus(codeBlockData, props.result)}
|
|
93
100
|
</div>
|
|
94
101
|
<div className={styles.right}>
|
|
95
102
|
<Popover title={'Show Code'} id={'edit-file-tool-show-code'}>
|
|
96
|
-
<Icon iconClass='codicon codicon-file-code' onClick={
|
|
103
|
+
<Icon iconClass='codicon codicon-file-code' onClick={handleToggleMode} />
|
|
97
104
|
</Popover>
|
|
98
105
|
{codeBlockData.applyResult?.diff && (
|
|
99
106
|
<Popover title={'Show Diff'} id={'edit-file-tool-show-diff'}>
|
|
100
|
-
<Icon iconClass='codicon codicon-diff-multiple' onClick={
|
|
107
|
+
<Icon iconClass='codicon codicon-diff-multiple' onClick={handleToggleMode} />
|
|
101
108
|
</Popover>
|
|
102
109
|
)}
|
|
103
110
|
</div>
|
|
@@ -131,7 +138,7 @@ export const EditFileToolComponent = (props: IMCPServerToolComponentProps) => {
|
|
|
131
138
|
];
|
|
132
139
|
};
|
|
133
140
|
|
|
134
|
-
const renderStatus = (codeBlockData: CodeBlockData) => {
|
|
141
|
+
const renderStatus = (codeBlockData: CodeBlockData, error?: string) => {
|
|
135
142
|
const status = codeBlockData.status;
|
|
136
143
|
switch (status) {
|
|
137
144
|
case 'generating':
|
|
@@ -150,7 +157,7 @@ const renderStatus = (codeBlockData: CodeBlockData) => {
|
|
|
150
157
|
);
|
|
151
158
|
case 'failed':
|
|
152
159
|
return (
|
|
153
|
-
<Popover title=
|
|
160
|
+
<Popover title={`Failed (${error})`} id={'edit-file-tool-status-failed'}>
|
|
154
161
|
<Icon iconClass='codicon codicon-error' style={{ color: 'var(--debugConsole-errorForeground)' }} />
|
|
155
162
|
</Popover>
|
|
156
163
|
);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CommandService, LabelService, URI, path, useInjectable } from '@opensumi/ide-core-browser';
|
|
4
|
+
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
5
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
6
|
+
|
|
7
|
+
import { IChatInternalService } from '../../../../common';
|
|
8
|
+
import { ChatInternalService } from '../../../chat/chat.internal.service';
|
|
9
|
+
|
|
10
|
+
import styles from './index.module.less';
|
|
11
|
+
|
|
12
|
+
interface FileInfo {
|
|
13
|
+
uri: string;
|
|
14
|
+
isDirectory: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface ExpandableFileListProps {
|
|
18
|
+
args: any;
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
messageId: string;
|
|
21
|
+
toolName: string;
|
|
22
|
+
headerText?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const FileSearchToolComponent: React.FC<ExpandableFileListProps> = ({ args, toolCallId, messageId }) => (
|
|
26
|
+
<ExpandableFileList
|
|
27
|
+
args={args}
|
|
28
|
+
toolCallId={toolCallId}
|
|
29
|
+
messageId={messageId}
|
|
30
|
+
toolName='fileSearch'
|
|
31
|
+
headerText={`Searched files "${args.query}"`}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const GrepSearchToolComponent: React.FC<ExpandableFileListProps> = ({ args, toolCallId, messageId }) => (
|
|
36
|
+
<ExpandableFileList
|
|
37
|
+
args={args}
|
|
38
|
+
toolCallId={toolCallId}
|
|
39
|
+
messageId={messageId}
|
|
40
|
+
toolName='grepSearch'
|
|
41
|
+
headerText={`Grepped codebase "${args.query}"`}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const ListDirToolComponent: React.FC<ExpandableFileListProps> = ({ args, toolCallId, messageId }) => (
|
|
46
|
+
<ExpandableFileList
|
|
47
|
+
args={args}
|
|
48
|
+
toolCallId={toolCallId}
|
|
49
|
+
messageId={messageId}
|
|
50
|
+
toolName='listDir'
|
|
51
|
+
headerText={`Listed directory "${args.relative_workspace_path}"`}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const ExpandableFileList: React.FC<ExpandableFileListProps> = ({
|
|
56
|
+
args,
|
|
57
|
+
toolCallId,
|
|
58
|
+
toolName,
|
|
59
|
+
messageId,
|
|
60
|
+
headerText,
|
|
61
|
+
}) => {
|
|
62
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
63
|
+
const labelService = useInjectable<LabelService>(LabelService);
|
|
64
|
+
const editorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
|
|
65
|
+
const workspaceService = useInjectable<IWorkspaceService>(IWorkspaceService);
|
|
66
|
+
const commandService = useInjectable<CommandService>(CommandService);
|
|
67
|
+
const workspaceRoot = useMemo(() => URI.parse(workspaceService.tryGetRoots()?.[0]?.uri), []);
|
|
68
|
+
|
|
69
|
+
const chatService = useInjectable<ChatInternalService>(IChatInternalService);
|
|
70
|
+
const [fileList, setFileList] = useState<FileInfo[]>([]);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const toDispose = chatService.sessionModel.history.onMessageAdditionalChange((additional) => {
|
|
74
|
+
setFileList(additional[toolCallId]?.files || []);
|
|
75
|
+
});
|
|
76
|
+
return () => {
|
|
77
|
+
toDispose.dispose();
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
const handleFileClick = async (fileInfo: FileInfo) => {
|
|
82
|
+
// 处理文件点击跳转
|
|
83
|
+
if (!fileInfo.isDirectory) {
|
|
84
|
+
editorService.open(URI.parse(fileInfo.uri));
|
|
85
|
+
} else {
|
|
86
|
+
// 如果是目录,聚焦到文件树并展开该目录
|
|
87
|
+
const uri = URI.parse(fileInfo.uri);
|
|
88
|
+
commandService.executeCommand('filetree.location', uri);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const parsedFiles = useMemo(
|
|
93
|
+
() =>
|
|
94
|
+
fileList.map((file) => {
|
|
95
|
+
const uri = URI.parse(file.uri);
|
|
96
|
+
const iconClass = labelService.getIcon(uri, { isDirectory: file.isDirectory });
|
|
97
|
+
return {
|
|
98
|
+
iconClass,
|
|
99
|
+
name: uri.path.base,
|
|
100
|
+
path: path.relative(workspaceRoot.codeUri.fsPath, uri.path.dir.toString()),
|
|
101
|
+
uri: file.uri,
|
|
102
|
+
isDirectory: file.isDirectory,
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
105
|
+
[fileList],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div className={styles.container}>
|
|
110
|
+
<div className={styles.header} onClick={() => setIsExpanded(!isExpanded)}>
|
|
111
|
+
<span style={{ transform: `rotate(${isExpanded ? '90deg' : '0deg'})` }}>▶</span>
|
|
112
|
+
<span>
|
|
113
|
+
{headerText} · {fileList.length} files
|
|
114
|
+
</span>
|
|
115
|
+
</div>
|
|
116
|
+
{isExpanded && (
|
|
117
|
+
<ul className={styles.fileList}>
|
|
118
|
+
{parsedFiles.map((file, index) => (
|
|
119
|
+
<li
|
|
120
|
+
key={index}
|
|
121
|
+
className={styles.fileItem}
|
|
122
|
+
onClick={() => handleFileClick({ uri: file.uri, isDirectory: file.isDirectory })}
|
|
123
|
+
>
|
|
124
|
+
<span className={file.iconClass}></span>
|
|
125
|
+
<span style={{ flex: 1 }}>{file.name}</span>
|
|
126
|
+
<span className={styles.filePath}>{file.path}</span>
|
|
127
|
+
</li>
|
|
128
|
+
))}
|
|
129
|
+
</ul>
|
|
130
|
+
)}
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
@@ -3,6 +3,7 @@ import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useInjectable } from '@opensumi/ide-core-browser';
|
|
4
4
|
import { Button, Icon } from '@opensumi/ide-core-browser/lib/components';
|
|
5
5
|
import { localize } from '@opensumi/ide-core-common';
|
|
6
|
+
import { stripAnsi } from '@opensumi/ide-utils/lib/ansi';
|
|
6
7
|
|
|
7
8
|
import { IMCPServerToolComponentProps } from '../../../types';
|
|
8
9
|
import { RunCommandHandler } from '../handlers/RunCommand';
|
|
@@ -58,13 +59,23 @@ export const TerminalToolComponent = memo((props: IMCPServerToolComponentProps)
|
|
|
58
59
|
<div className={styles.run_cmd_tool}>
|
|
59
60
|
{props.state === 'result' && (
|
|
60
61
|
<div>
|
|
62
|
+
{args && (
|
|
63
|
+
<>
|
|
64
|
+
<div className={styles.command_title}>
|
|
65
|
+
<Icon icon='terminal' />
|
|
66
|
+
<span>{localize('ai.native.mcp.terminal.command')}</span>
|
|
67
|
+
</div>
|
|
68
|
+
<p className={styles.command_content}>
|
|
69
|
+
<code>$ {args.command}</code>
|
|
70
|
+
</p>
|
|
71
|
+
</>
|
|
72
|
+
)}
|
|
61
73
|
<div className={styles.command_title}>
|
|
62
|
-
<Icon icon='terminal' />
|
|
63
74
|
<span>{localize('ai.native.mcp.terminal.output')}</span>
|
|
64
75
|
</div>
|
|
65
76
|
{output ? (
|
|
66
77
|
<div className={styles.command_content}>
|
|
67
|
-
<code>{output.text}</code>
|
|
78
|
+
<code>{stripAnsi(output.text)}</code>
|
|
68
79
|
</div>
|
|
69
80
|
) : (
|
|
70
81
|
''
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
align-items: center;
|
|
18
18
|
justify-content: center;
|
|
19
19
|
}
|
|
20
|
+
.left {
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
20
23
|
.left,
|
|
21
24
|
.right {
|
|
22
25
|
display: flex;
|
|
@@ -154,6 +157,7 @@
|
|
|
154
157
|
background-color: var(--design-chatInput-background);
|
|
155
158
|
padding: 10px;
|
|
156
159
|
border-radius: 4px;
|
|
160
|
+
margin: 10px 0px;
|
|
157
161
|
|
|
158
162
|
.command_title {
|
|
159
163
|
display: flex;
|
|
@@ -6,10 +6,13 @@ import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
|
6
6
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
7
7
|
|
|
8
8
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
9
|
+
import { BaseApplyService } from '../base-apply.service';
|
|
10
|
+
|
|
11
|
+
import { EditFileToolComponent } from './components/EditFile';
|
|
9
12
|
|
|
10
13
|
const inputSchema = z.object({
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
target_file: z.string().describe('The relative path where the file should be created'),
|
|
15
|
+
code_edit: z.string().describe('The content to write into the new file'),
|
|
13
16
|
});
|
|
14
17
|
|
|
15
18
|
@Domain(MCPServerContribution)
|
|
@@ -20,29 +23,31 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
20
23
|
@Autowired(IFileServiceClient)
|
|
21
24
|
private readonly fileService: IFileServiceClient;
|
|
22
25
|
|
|
26
|
+
@Autowired(BaseApplyService)
|
|
27
|
+
private applyService: BaseApplyService;
|
|
28
|
+
|
|
23
29
|
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
24
30
|
registry.registerMCPTool(this.getToolDefinition());
|
|
31
|
+
registry.registerToolComponent('create_new_file_with_text', EditFileToolComponent);
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
getToolDefinition(): MCPToolDefinition {
|
|
28
35
|
return {
|
|
29
36
|
name: 'create_new_file_with_text',
|
|
37
|
+
label: 'Create File',
|
|
30
38
|
description:
|
|
31
39
|
'Creates a new file at the specified path within the project directory and populates it with the provided text. ' +
|
|
32
40
|
'Use this tool to generate new files in your project structure. ' +
|
|
33
|
-
'Requires two parameters: ' +
|
|
34
|
-
'- pathInProject: The relative path where the file should be created ' +
|
|
35
|
-
'- text: The content to write into the new file ' +
|
|
36
41
|
'Returns one of two possible responses: ' +
|
|
37
42
|
'"ok" if the file was successfully created and populated, ' +
|
|
38
43
|
'"can\'t find project dir" if the project directory cannot be determined. ' +
|
|
39
|
-
'Note:
|
|
44
|
+
'Note: This tool creates any necessary parent directories automatically.',
|
|
40
45
|
inputSchema,
|
|
41
46
|
handler: this.handler.bind(this),
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
private async handler(args: z.infer<typeof inputSchema
|
|
50
|
+
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
46
51
|
try {
|
|
47
52
|
// 获取工作区根目录
|
|
48
53
|
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
@@ -56,7 +61,7 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
56
61
|
|
|
57
62
|
// 构建完整的文件路径
|
|
58
63
|
const rootUri = URI.parse(workspaceRoots[0].uri);
|
|
59
|
-
const fullPath = path.join(rootUri.codeUri.fsPath, args.
|
|
64
|
+
const fullPath = path.join(rootUri.codeUri.fsPath, args.target_file);
|
|
60
65
|
const fileUri = URI.file(fullPath);
|
|
61
66
|
|
|
62
67
|
// 创建父目录
|
|
@@ -64,17 +69,21 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
64
69
|
const parentUri = URI.file(parentDir);
|
|
65
70
|
await this.fileService.createFolder(parentUri.toString());
|
|
66
71
|
|
|
67
|
-
//
|
|
68
|
-
await this.fileService.createFile(fileUri.toString()
|
|
72
|
+
// 创建文件
|
|
73
|
+
await this.fileService.createFile(fileUri.toString());
|
|
74
|
+
|
|
75
|
+
// 使用 applyService 写入文件内容
|
|
76
|
+
const codeBlock = await this.applyService.registerCodeBlock(args.target_file, args.code_edit, args.toolCallId);
|
|
77
|
+
await this.applyService.apply(codeBlock);
|
|
69
78
|
|
|
70
|
-
logger.appendLine(`Successfully created file at: ${args.
|
|
79
|
+
logger.appendLine(`Successfully created file at: ${args.target_file}`);
|
|
71
80
|
return {
|
|
72
81
|
content: [{ type: 'text', text: 'ok' }],
|
|
73
82
|
};
|
|
74
83
|
} catch (error) {
|
|
75
84
|
logger.appendLine(`Error during file creation: ${error}`);
|
|
76
85
|
return {
|
|
77
|
-
content: [{ type: 'text', text:
|
|
86
|
+
content: [{ type: 'text', text: error.message }],
|
|
78
87
|
isError: true,
|
|
79
88
|
};
|
|
80
89
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
|
+
import { getValidateInput } from '@opensumi/ide-addons/lib/browser/file-search.contribution';
|
|
4
5
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
5
6
|
import { FileSearchServicePath, IFileSearchService } from '@opensumi/ide-file-search/lib/common';
|
|
6
7
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
@@ -9,7 +10,7 @@ import { IChatInternalService } from '../../../common';
|
|
|
9
10
|
import { ChatInternalService } from '../../chat/chat.internal.service';
|
|
10
11
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
11
12
|
|
|
12
|
-
import { FileSearchToolComponent } from './components/
|
|
13
|
+
import { FileSearchToolComponent } from './components/ExpandableFileList';
|
|
13
14
|
|
|
14
15
|
const inputSchema = z.object({
|
|
15
16
|
query: z.string().describe('Fuzzy filename to search for'),
|
|
@@ -58,7 +59,7 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
// 使用 OpenSumi 的文件搜索 API
|
|
61
|
-
const searchPattern = args.query;
|
|
62
|
+
const searchPattern = this.normalizeQuery(args.query);
|
|
62
63
|
const searchResults = await this.fileSearchService.find(searchPattern, {
|
|
63
64
|
rootUris: [new URI(workspaceRoots[0].uri).codeUri.fsPath],
|
|
64
65
|
// TODO: 忽略配置
|
|
@@ -71,7 +72,10 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
71
72
|
|
|
72
73
|
const files = searchResults.slice(0, MAX_RESULTS).map((file) => {
|
|
73
74
|
const uri = URI.parse(file);
|
|
74
|
-
return
|
|
75
|
+
return {
|
|
76
|
+
uri: uri.codeUri.fsPath,
|
|
77
|
+
isDirectory: false, // 文件搜索结果都是文件
|
|
78
|
+
};
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
@@ -87,7 +91,7 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
87
91
|
content: [
|
|
88
92
|
{
|
|
89
93
|
type: 'text',
|
|
90
|
-
text: `${files.join('\n')}\n${
|
|
94
|
+
text: `${files.map((f) => f.uri).join('\n')}\n${
|
|
91
95
|
searchResults.length > MAX_RESULTS
|
|
92
96
|
? `\nFound ${searchResults.length} files matching "${args.query}", only return the first ${MAX_RESULTS} results`
|
|
93
97
|
: ''
|
|
@@ -96,4 +100,10 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
96
100
|
],
|
|
97
101
|
};
|
|
98
102
|
}
|
|
103
|
+
|
|
104
|
+
private normalizeQuery(query: string): string {
|
|
105
|
+
const nonBlank = query.trim().replace(/\s/g, '');
|
|
106
|
+
const validated = getValidateInput(nonBlank);
|
|
107
|
+
return validated;
|
|
108
|
+
}
|
|
99
109
|
}
|
|
@@ -29,6 +29,7 @@ export class GetDiagnosticsByPathTool implements MCPServerContribution {
|
|
|
29
29
|
getToolDefinition(): MCPToolDefinition {
|
|
30
30
|
return {
|
|
31
31
|
name: 'get_diagnostics_by_path',
|
|
32
|
+
label: 'Get Diagnostics',
|
|
32
33
|
description:
|
|
33
34
|
'Retrieves diagnostic information (errors, warnings, etc.) from a specific file in the project. ' +
|
|
34
35
|
'Use this tool to get information about problems in any project file. ' +
|
|
@@ -10,7 +10,7 @@ import { IChatInternalService } from '../../../common';
|
|
|
10
10
|
import { ChatInternalService } from '../../chat/chat.internal.service';
|
|
11
11
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
12
12
|
|
|
13
|
-
import { GrepSearchToolComponent } from './components/
|
|
13
|
+
import { GrepSearchToolComponent } from './components/ExpandableFileList';
|
|
14
14
|
|
|
15
15
|
const inputSchema = z.object({
|
|
16
16
|
query: z.string().describe('The regex pattern to search for'),
|
|
@@ -90,7 +90,7 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
const results: string[] = [];
|
|
93
|
-
const files: string
|
|
93
|
+
const files: Array<{ uri: string; isDirectory: boolean }> = [];
|
|
94
94
|
for (const [fileUri, result] of this.searchService.searchResults.entries()) {
|
|
95
95
|
results.push(
|
|
96
96
|
`File: ${fileUri}\n${result
|
|
@@ -103,7 +103,10 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
103
103
|
.map((r) => `Line: ${r.line}\nContent: ${r.lineText || r.renderLineText}`)
|
|
104
104
|
.join('\n')}`,
|
|
105
105
|
);
|
|
106
|
-
files.push(
|
|
106
|
+
files.push({
|
|
107
|
+
uri: fileUri,
|
|
108
|
+
isDirectory: false, // grep 搜索结果都是文件
|
|
109
|
+
});
|
|
107
110
|
}
|
|
108
111
|
deferred.resolve(results.join('\n\n'));
|
|
109
112
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
@@ -14,7 +14,7 @@ export class EditFileHandler {
|
|
|
14
14
|
|
|
15
15
|
async handler(params: { targetFile: string; codeEdit: string; instructions?: string }, toolCallId: string) {
|
|
16
16
|
const { targetFile, codeEdit } = params;
|
|
17
|
-
const block = this.applyService.registerCodeBlock(targetFile, codeEdit, toolCallId);
|
|
17
|
+
const block = await this.applyService.registerCodeBlock(targetFile, codeEdit, toolCallId);
|
|
18
18
|
const blockData = await this.applyService.apply(block);
|
|
19
19
|
return blockData;
|
|
20
20
|
}
|
|
@@ -56,6 +56,10 @@ export class ListDirHandler {
|
|
|
56
56
|
@Autowired(IFileServiceClient)
|
|
57
57
|
private readonly fileSystemService: IFileServiceClient;
|
|
58
58
|
|
|
59
|
+
getWorkspaceDir(): string {
|
|
60
|
+
return this.appConfig.workspaceDir;
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
async handler(args: { relativeWorkspacePath: string }) {
|
|
60
64
|
const { relativeWorkspacePath } = args;
|
|
61
65
|
if (!relativeWorkspacePath) {
|
|
@@ -49,6 +49,7 @@ export class RunCommandHandler {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
52
|
+
logger.appendLine(`Executing command: ${args.command}`);
|
|
52
53
|
if (args.require_user_approval) {
|
|
53
54
|
const def = new Deferred<boolean>();
|
|
54
55
|
this.approvalDeferredMap.set(args.toolCallId, def);
|
|
@@ -89,6 +90,7 @@ export class RunCommandHandler {
|
|
|
89
90
|
content: result,
|
|
90
91
|
});
|
|
91
92
|
|
|
93
|
+
logger.appendLine(`Command ${args.command} finished with exit code: ${e.code}`);
|
|
92
94
|
terminalClient.term.writeln(
|
|
93
95
|
`\n${color.italic}> Command ${args.command} executed successfully. Terminal will close in ${
|
|
94
96
|
3000 / 1000
|