@opensumi/ide-ai-native 3.8.1-next-1741232004.0 → 3.8.1-next-1741250387.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 +0 -5
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +9 -71
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts +3 -11
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +5 -43
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +0 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +8 -6
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +1 -4
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +2 -57
- 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 +6 -13
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.api.service.d.ts +2 -1
- package/lib/browser/chat/chat.api.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.api.service.js +4 -0
- package/lib/browser/chat/chat.api.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +0 -2
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +0 -3
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +2 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -46
- 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 +1 -29
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +1 -6
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +2 -0
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +10 -2
- 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 +3 -2
- 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 +1 -2
- package/lib/browser/components/components.module.less +0 -22
- package/lib/browser/context/llm-context.service.d.ts +5 -18
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +47 -81
- 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 +1 -2
- package/lib/browser/contrib/intelligent-completions/index.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/index.js +1 -4
- 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 +5 -6
- 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 +2 -4
- 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 +11 -23
- 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 +0 -4
- 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 +11 -26
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +103 -255
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +0 -6
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +1 -10
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +0 -8
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +3 -28
- 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 +9 -15
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +11 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/{ExpandableFileList.js → SearchResult.js} +19 -29
- package/lib/browser/mcp/tools/components/SearchResult.js.map +1 -0
- package/lib/browser/mcp/tools/components/Terminal.d.ts.map +1 -1
- package/lib/browser/mcp/tools/components/Terminal.js +2 -10
- package/lib/browser/mcp/tools/components/Terminal.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +0 -4
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +11 -19
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts +0 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.js +5 -14
- 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 +0 -1
- 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 +3 -6
- 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 +0 -1
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js +0 -3
- 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 +0 -2
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/listDir.d.ts +0 -1
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +4 -35
- 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 +0 -1
- 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 +10 -4
- 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 +2 -22
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +0 -4
- 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 +1 -6
- 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 +8 -68
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts +4 -10
- package/lib/browser/widget/inline-diff/inline-diff-previewer.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js +3 -14
- package/lib/browser/widget/inline-diff/inline-diff-previewer.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- 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 +5 -10
- 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 +17 -46
- 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 +53 -110
- 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 +0 -4
- 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 +1 -26
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +4 -13
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -5
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +9 -13
- 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 +1 -17
- package/lib/common/mcp-server-manager.d.ts.map +1 -1
- package/lib/common/mcp-server-manager.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +3 -4
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +22 -33
- 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 +0 -8
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +1 -2
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +1 -3
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.js +2 -6
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -1
- package/lib/node/base-language-model.d.ts +3 -6
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +31 -14
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +1 -3
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.js +2 -6
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +3 -17
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +6 -59
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +3 -4
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +6 -26
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.d.ts +16 -5
- package/lib/node/mcp-server.d.ts.map +1 -1
- package/lib/node/mcp-server.js +6 -12
- package/lib/node/mcp-server.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +2 -4
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +4 -6
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +26 -27
- package/src/browser/ai-core.contextkeys.ts +3 -3
- package/src/browser/ai-core.contribution.ts +12 -89
- package/src/browser/chat/chat-agent.service.ts +9 -53
- package/src/browser/chat/chat-manager.service.ts +8 -10
- package/src/browser/chat/chat-model.ts +5 -63
- package/src/browser/chat/chat-proxy.service.ts +8 -16
- package/src/browser/chat/chat.api.service.ts +5 -1
- package/src/browser/chat/chat.internal.service.ts +0 -4
- package/src/browser/chat/chat.module.less +2 -1
- package/src/browser/chat/chat.view.tsx +69 -63
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatInput.tsx +6 -81
- package/src/browser/components/ChatReply.tsx +6 -6
- package/src/browser/components/ChatThinking.tsx +9 -3
- package/src/browser/components/ChatToolRender.tsx +2 -1
- package/src/browser/components/WelcomeMsg.tsx +1 -1
- package/src/browser/components/chat-history.module.less +1 -2
- package/src/browser/components/components.module.less +0 -22
- package/src/browser/context/llm-context.service.ts +54 -100
- 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 +1 -5
- package/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts +3 -3
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +6 -7
- package/src/browser/contrib/intelligent-completions/view/code-edits-previewer.ts +2 -4
- package/src/browser/contrib/intelligent-completions/view/default.ts +19 -34
- package/src/browser/index.ts +0 -4
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +109 -306
- package/src/browser/mcp/mcp-server-proxy.service.ts +2 -14
- package/src/browser/mcp/mcp-server.feature.registry.ts +4 -35
- package/src/browser/mcp/tools/components/EditFile.tsx +9 -16
- package/src/browser/mcp/tools/components/SearchResult.tsx +92 -0
- package/src/browser/mcp/tools/components/Terminal.tsx +2 -13
- package/src/browser/mcp/tools/components/index.module.less +0 -4
- package/src/browser/mcp/tools/createNewFileWithText.ts +12 -21
- package/src/browser/mcp/tools/fileSearch.ts +4 -14
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -1
- package/src/browser/mcp/tools/grepSearch.ts +3 -6
- package/src/browser/mcp/tools/handlers/EditFile.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +0 -4
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -2
- package/src/browser/mcp/tools/listDir.ts +5 -36
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -1
- package/src/browser/model/msg-history-manager.ts +11 -5
- package/src/browser/preferences/schema.ts +2 -22
- package/src/browser/types.ts +0 -1
- package/src/browser/widget/inline-chat/inline-chat-controller.ts +1 -5
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +21 -143
- package/src/browser/widget/inline-diff/inline-diff-previewer.ts +7 -25
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +4 -25
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +8 -16
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +68 -139
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -30
- package/src/common/index.ts +4 -15
- package/src/common/llm-context.ts +4 -10
- package/src/common/mcp-server-manager.ts +1 -17
- package/src/common/prompts/context-prompt-provider.ts +29 -38
- package/src/common/tool-invocation-registry.ts +2 -2
- package/src/common/types.ts +0 -8
- package/src/common/utils.ts +1 -3
- package/src/node/anthropic/anthropic-language-model.ts +2 -7
- package/src/node/base-language-model.ts +38 -25
- package/src/node/deepseek/deepseek-language-model.ts +2 -7
- package/src/node/mcp/sumi-mcp-server.ts +9 -67
- package/src/node/mcp-server-manager-impl.ts +9 -30
- package/src/node/mcp-server.ts +14 -11
- package/src/node/openai/openai-language-model.ts +4 -8
- package/lib/browser/mcp/config/components/mcp-config.module.less +0 -178
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts +0 -3
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +0 -1
- package/lib/browser/mcp/config/components/mcp-config.view.js +0 -150
- package/lib/browser/mcp/config/components/mcp-config.view.js.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts +0 -16
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.js +0 -84
- package/lib/browser/mcp/config/components/mcp-server-form.js.map +0 -1
- package/lib/browser/mcp/config/components/mcp-server-form.module.less +0 -78
- package/lib/browser/mcp/config/mcp-config.commands.d.ts +0 -10
- package/lib/browser/mcp/config/mcp-config.commands.d.ts.map +0 -1
- package/lib/browser/mcp/config/mcp-config.commands.js +0 -35
- package/lib/browser/mcp/config/mcp-config.commands.js.map +0 -1
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts +0 -16
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts.map +0 -1
- package/lib/browser/mcp/config/mcp-config.contribution.js +0 -62
- package/lib/browser/mcp/config/mcp-config.contribution.js.map +0 -1
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts +0 -13
- package/lib/browser/mcp/tools/components/ExpandableFileList.d.ts.map +0 -1
- package/lib/browser/mcp/tools/components/ExpandableFileList.js.map +0 -1
- package/lib/common/model.d.ts +0 -12
- package/lib/common/model.d.ts.map +0 -1
- package/lib/common/model.js +0 -83
- package/lib/common/model.js.map +0 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts +0 -10
- package/lib/node/openai-compatible/openai-compatible-language-model.d.ts.map +0 -1
- package/lib/node/openai-compatible/openai-compatible-language-model.js +0 -32
- package/lib/node/openai-compatible/openai-compatible-language-model.js.map +0 -1
- package/src/browser/mcp/config/components/mcp-config.module.less +0 -178
- package/src/browser/mcp/config/components/mcp-config.view.tsx +0 -215
- package/src/browser/mcp/config/components/mcp-server-form.module.less +0 -78
- package/src/browser/mcp/config/components/mcp-server-form.tsx +0 -144
- package/src/browser/mcp/config/mcp-config.commands.ts +0 -29
- package/src/browser/mcp/config/mcp-config.contribution.ts +0 -65
- package/src/browser/mcp/tools/components/ExpandableFileList.tsx +0 -133
- package/src/common/model.ts +0 -90
- package/src/node/openai-compatible/openai-compatible-language-model.ts +0 -30
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@opensumi/di';
|
|
1
|
+
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
2
|
import {
|
|
3
3
|
Disposable,
|
|
4
4
|
Emitter,
|
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
IChatProgress,
|
|
9
9
|
IChatToolContent,
|
|
10
10
|
IChatTreeData,
|
|
11
|
+
ILogger,
|
|
12
|
+
memoize,
|
|
11
13
|
uuid,
|
|
12
14
|
} from '@opensumi/ide-core-common';
|
|
13
15
|
import { MarkdownString, isMarkdownString } from '@opensumi/monaco-editor-core/esm/vs/base/common/htmlContent';
|
|
14
16
|
|
|
15
17
|
import {
|
|
16
|
-
CoreMessage,
|
|
17
18
|
IChatFollowup,
|
|
18
19
|
IChatModel,
|
|
19
20
|
IChatRequestMessage,
|
|
@@ -26,8 +27,6 @@ import {
|
|
|
26
27
|
import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
27
28
|
import { IChatSlashCommandItem } from '../types';
|
|
28
29
|
|
|
29
|
-
import type { TextPart, ToolCallPart } from 'ai';
|
|
30
|
-
|
|
31
30
|
export type IChatProgressResponseContent =
|
|
32
31
|
| IChatMarkdownContent
|
|
33
32
|
| IChatAsyncContent
|
|
@@ -89,7 +88,6 @@ export class ChatResponseModel extends Disposable {
|
|
|
89
88
|
isComplete: boolean;
|
|
90
89
|
isCanceled: boolean;
|
|
91
90
|
responseContents: IChatProgressResponseContent[];
|
|
92
|
-
responseParts: IChatProgressResponseContent[];
|
|
93
91
|
responseText: string;
|
|
94
92
|
errorDetails: IChatResponseErrorDetails | undefined;
|
|
95
93
|
followups: IChatFollowup[] | undefined;
|
|
@@ -99,7 +97,6 @@ export class ChatResponseModel extends Disposable {
|
|
|
99
97
|
this.#requestId = requestId;
|
|
100
98
|
if (initParams) {
|
|
101
99
|
this.#responseContents = initParams.responseContents;
|
|
102
|
-
this.#responseParts = initParams.responseParts || [];
|
|
103
100
|
this.#responseText = initParams.responseText;
|
|
104
101
|
this.#isComplete = initParams.isComplete;
|
|
105
102
|
this.#isCanceled = initParams.isCanceled;
|
|
@@ -244,7 +241,6 @@ export class ChatResponseModel extends Disposable {
|
|
|
244
241
|
isCanceled: this.isCanceled,
|
|
245
242
|
responseContents: this.responseContents,
|
|
246
243
|
responseText: this.responseText,
|
|
247
|
-
responseParts: this.responseParts,
|
|
248
244
|
errorDetails: this.errorDetails,
|
|
249
245
|
followups: this.followups,
|
|
250
246
|
};
|
|
@@ -303,64 +299,10 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
303
299
|
|
|
304
300
|
readonly history: MsgHistoryManager;
|
|
305
301
|
|
|
306
|
-
get messageHistory() {
|
|
307
|
-
const history: CoreMessage[] = [];
|
|
308
|
-
for (const request of this.requests) {
|
|
309
|
-
if (!request.response.isComplete) {
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
history.push({ role: 'user', content: request.message.prompt });
|
|
313
|
-
for (const part of request.response.responseParts) {
|
|
314
|
-
if (part.kind === 'treeData' || part.kind === 'component') {
|
|
315
|
-
continue;
|
|
316
|
-
}
|
|
317
|
-
if (part.kind !== 'toolCall') {
|
|
318
|
-
history.push({
|
|
319
|
-
role: 'assistant',
|
|
320
|
-
content: [
|
|
321
|
-
{
|
|
322
|
-
type: 'text',
|
|
323
|
-
text: part.kind === 'markdownContent' ? part.content.value : part.content,
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
});
|
|
327
|
-
} else {
|
|
328
|
-
// 直接开始toolCall场景
|
|
329
|
-
if (history[history.length - 1].role !== 'assistant') {
|
|
330
|
-
history.push({
|
|
331
|
-
role: 'assistant',
|
|
332
|
-
content: [],
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
(history[history.length - 1].content as Array<TextPart | ToolCallPart>).push({
|
|
336
|
-
type: 'tool-call',
|
|
337
|
-
toolCallId: part.content.id,
|
|
338
|
-
toolName: part.content.function.name,
|
|
339
|
-
args: JSON.parse(part.content.function.arguments || '{}'),
|
|
340
|
-
});
|
|
341
|
-
history.push({
|
|
342
|
-
role: 'tool',
|
|
343
|
-
content: [
|
|
344
|
-
{
|
|
345
|
-
type: 'tool-result',
|
|
346
|
-
toolCallId: part.content.id,
|
|
347
|
-
toolName: part.content.function.name,
|
|
348
|
-
result: JSON.parse(part.content.result || '{}'),
|
|
349
|
-
},
|
|
350
|
-
],
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return history;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
302
|
addRequest(message: IChatRequestMessage): ChatRequestModel {
|
|
359
|
-
const msg = message;
|
|
360
|
-
|
|
361
303
|
const requestId = `${this.sessionId}_request_${ChatModel.requestIdPool++}`;
|
|
362
|
-
const response = new ChatResponseModel(requestId, this,
|
|
363
|
-
const request = new ChatRequestModel(requestId, this,
|
|
304
|
+
const response = new ChatResponseModel(requestId, this, message.agentId);
|
|
305
|
+
const request = new ChatRequestModel(requestId, this, message, response);
|
|
364
306
|
|
|
365
307
|
this.#requests.set(requestId, request);
|
|
366
308
|
return request;
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
IAIReporter,
|
|
13
13
|
IApplicationService,
|
|
14
14
|
IChatProgress,
|
|
15
|
-
|
|
15
|
+
uuid,
|
|
16
16
|
} from '@opensumi/ide-core-common';
|
|
17
17
|
import { AINativeSettingSectionsId } from '@opensumi/ide-core-common/lib/settings/ai-native';
|
|
18
|
+
import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
18
19
|
import { MonacoCommandRegistry } from '@opensumi/ide-editor/lib/browser/monaco-contrib/command/command.service';
|
|
19
20
|
import { IMessageService } from '@opensumi/ide-overlay';
|
|
20
21
|
import { listenReadable } from '@opensumi/ide-utils/lib/stream';
|
|
21
22
|
|
|
22
23
|
import {
|
|
23
|
-
CoreMessage,
|
|
24
24
|
IChatAgentCommand,
|
|
25
25
|
IChatAgentRequest,
|
|
26
26
|
IChatAgentResult,
|
|
@@ -92,14 +92,12 @@ export class ChatProxyService extends Disposable {
|
|
|
92
92
|
AINativeSettingSectionsId.SystemPrompt,
|
|
93
93
|
'You are a powerful AI coding assistant working in OpenSumi, a top IDE framework. You collaborate with a USER to solve coding tasks, which may involve creating, modifying, or debugging code, or answering questions. When the USER sends a message, relevant context (e.g., open files, cursor position, edit history, linter errors) may be attached. Use this information as needed.\n\n<tool_calling>\nYou have access to tools to assist with tasks. Follow these rules:\n1. Always adhere to the tool call schema and provide all required parameters.\n2. Only use tools explicitly provided; ignore unavailable ones.\n3. Avoid mentioning tool names to the USER (e.g., say "I will edit your file" instead of "I need to use the edit_file tool").\n4. Only call tools when necessary; respond directly if the task is general or you already know the answer.\n5. Explain to the USER why you’re using a tool before calling it.\n</tool_calling>\n\n<making_code_changes>\nWhen modifying code:\n1. Use code edit tools instead of outputting code unless explicitly requested.\n2. Limit tool calls to one per turn.\n3. Ensure generated code is immediately executable by including necessary imports, dependencies, and endpoints.\n4. For new projects, create a dependency management file (e.g., requirements.txt) and a README.\n5. For web apps, design a modern, user-friendly UI.\n6. Avoid generating non-textual or excessively long code.\n7. Read file contents before editing, unless appending a small change or creating a new file.\n8. Fix introduced linter errors if possible, but stop after 3 attempts and ask the USER for guidance.\n9. Reapply reasonable code edits if they weren’t followed initially.\n</making_code_changes>\n\nUse the appropriate tools to fulfill the USER’s request, ensuring all required parameters are provided or inferred from context.',
|
|
94
94
|
) +
|
|
95
|
-
`\n\n<user_info>\nThe user's OS is ${
|
|
96
|
-
this.appConfig.workspaceDir
|
|
97
|
-
}.\n</user_info>`,
|
|
95
|
+
`\n\n<user_info>\nThe user's OS version is ${this.applicationService.frontendOS}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.\n</user_info>`,
|
|
98
96
|
},
|
|
99
97
|
invoke: async (
|
|
100
98
|
request: IChatAgentRequest,
|
|
101
99
|
progress: (part: IChatProgress) => void,
|
|
102
|
-
|
|
100
|
+
_history: IChatMessage[],
|
|
103
101
|
token: CancellationToken,
|
|
104
102
|
): Promise<IChatAgentResult> => {
|
|
105
103
|
this.chatDeferred = new Deferred<void>();
|
|
@@ -117,33 +115,27 @@ export class ChatProxyService extends Disposable {
|
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
const model = this.preferenceService.get<string>(AINativeSettingSectionsId.LLMModelSelection);
|
|
120
|
-
const modelId = this.preferenceService.get<string>(AINativeSettingSectionsId.ModelID);
|
|
121
118
|
let apiKey: string = '';
|
|
122
119
|
let baseURL: string = '';
|
|
123
120
|
if (model === 'deepseek') {
|
|
124
121
|
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.DeepseekApiKey, '');
|
|
125
122
|
} else if (model === 'openai') {
|
|
126
123
|
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiApiKey, '');
|
|
127
|
-
} else if (model === 'anthropic') {
|
|
128
|
-
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.AnthropicApiKey, '');
|
|
129
|
-
} else {
|
|
130
|
-
// openai-compatible 为兜底
|
|
131
|
-
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiApiKey, '');
|
|
132
124
|
baseURL = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiBaseURL, '');
|
|
125
|
+
} else {
|
|
126
|
+
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.AnthropicApiKey, '');
|
|
133
127
|
}
|
|
134
|
-
const
|
|
128
|
+
const MAX_INPUT_TOKENS = 30720;
|
|
135
129
|
const stream = await this.aiBackService.requestStream(
|
|
136
130
|
prompt,
|
|
137
131
|
{
|
|
138
132
|
requestId: request.requestId,
|
|
139
133
|
sessionId: request.sessionId,
|
|
140
|
-
history,
|
|
134
|
+
history: this.aiChatService.getHistoryMessages(MAX_INPUT_TOKENS),
|
|
141
135
|
clientId: this.applicationService.clientId,
|
|
142
136
|
apiKey,
|
|
143
137
|
model,
|
|
144
|
-
modelId,
|
|
145
138
|
baseURL,
|
|
146
|
-
system: agent?.metadata.systemPrompt,
|
|
147
139
|
},
|
|
148
140
|
token,
|
|
149
141
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { Disposable, Emitter, Event } from '@opensumi/ide-core-common';
|
|
3
|
-
import { IChatComponent, IChatContent } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
3
|
+
import { IChatComponent, IChatContent, IHistoryChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
4
4
|
import { IMainLayoutService } from '@opensumi/ide-main-layout';
|
|
5
5
|
|
|
6
6
|
import { AI_CHAT_VIEW_ID, IChatInternalService, IChatMessageListItem, IChatMessageStructure } from '../../common';
|
|
@@ -65,6 +65,10 @@ export class ChatService extends Disposable {
|
|
|
65
65
|
this._onChatMessageListLaunch.fire(list);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
public getHistoryMessages(maxInputTokens?: number): IHistoryChatMessage[] {
|
|
69
|
+
return this.chatInternalService.sessionModel?.history.getMessages(maxInputTokens) || [];
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
public scrollToBottom(): void {
|
|
69
73
|
this._onScrollToBottom.fire();
|
|
70
74
|
}
|
|
@@ -30,9 +30,6 @@ export class ChatInternalService extends Disposable {
|
|
|
30
30
|
private readonly _onCancelRequest = new Emitter<void>();
|
|
31
31
|
public readonly onCancelRequest: Event<void> = this._onCancelRequest.event;
|
|
32
32
|
|
|
33
|
-
private readonly _onWillClearSession = new Emitter<string>();
|
|
34
|
-
public readonly onWillClearSession: Event<string> = this._onWillClearSession.event;
|
|
35
|
-
|
|
36
33
|
private readonly _onRegenerateRequest = new Emitter<void>();
|
|
37
34
|
public readonly onRegenerateRequest: Event<void> = this._onRegenerateRequest.event;
|
|
38
35
|
|
|
@@ -86,7 +83,6 @@ export class ChatInternalService extends Disposable {
|
|
|
86
83
|
|
|
87
84
|
clearSessionModel(sessionId?: string) {
|
|
88
85
|
sessionId = sessionId || this.#sessionModel.sessionId;
|
|
89
|
-
this._onWillClearSession.fire(sessionId);
|
|
90
86
|
this.chatManagerService.clearSession(sessionId);
|
|
91
87
|
if (sessionId === this.#sessionModel.sessionId) {
|
|
92
88
|
this.#sessionModel = this.chatManagerService.startSession();
|
|
@@ -279,6 +279,7 @@
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
|
|
282
283
|
.chat_tips_container {
|
|
283
284
|
display: flex;
|
|
284
285
|
align-items: center;
|
|
@@ -289,6 +290,6 @@
|
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
.chat_history {
|
|
292
|
-
width: calc(100% -
|
|
293
|
+
width: calc(100% - 60px);
|
|
293
294
|
color: var(--design-text-foreground);
|
|
294
295
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MessageList } from 'react-chat-elements';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AINativeConfigService,
|
|
6
|
+
getIcon,
|
|
7
|
+
useEventEffect,
|
|
8
|
+
useInjectable,
|
|
9
|
+
useUpdateOnEvent,
|
|
10
|
+
} from '@opensumi/ide-core-browser';
|
|
5
11
|
import { Popover, PopoverPosition } from '@opensumi/ide-core-browser/lib/components';
|
|
6
12
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
7
13
|
import {
|
|
@@ -19,15 +25,24 @@ import {
|
|
|
19
25
|
IAIReporter,
|
|
20
26
|
IChatComponent,
|
|
21
27
|
IChatContent,
|
|
28
|
+
MessageType,
|
|
22
29
|
formatLocalize,
|
|
23
30
|
localize,
|
|
24
31
|
uuid,
|
|
25
32
|
} from '@opensumi/ide-core-common';
|
|
26
33
|
import { IMainLayoutService } from '@opensumi/ide-main-layout';
|
|
27
|
-
import {
|
|
34
|
+
import { IDialogService } from '@opensumi/ide-overlay';
|
|
28
35
|
|
|
29
36
|
import 'react-chat-elements/dist/main.css';
|
|
30
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
AI_CHAT_VIEW_ID,
|
|
39
|
+
IChatAgentService,
|
|
40
|
+
IChatInternalService,
|
|
41
|
+
IChatMessageStructure,
|
|
42
|
+
TokenMCPServerProxyService,
|
|
43
|
+
} from '../../common';
|
|
44
|
+
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
45
|
+
import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
|
|
31
46
|
import { ChatContext } from '../components/ChatContext';
|
|
32
47
|
import { CodeBlockWrapperInput } from '../components/ChatEditor';
|
|
33
48
|
import ChatHistory, { IChatHistoryItem } from '../components/ChatHistory';
|
|
@@ -37,7 +52,9 @@ import { ChatNotify, ChatReply } from '../components/ChatReply';
|
|
|
37
52
|
import { SlashCustomRender } from '../components/SlashCustomRender';
|
|
38
53
|
import { MessageData, createMessageByAI, createMessageByUser } from '../components/utils';
|
|
39
54
|
import { WelcomeMessage } from '../components/WelcomeMsg';
|
|
40
|
-
import {
|
|
55
|
+
import { MCPServerProxyService } from '../mcp/mcp-server-proxy.service';
|
|
56
|
+
import { MCPToolsDialog } from '../mcp/mcp-tools-dialog.view';
|
|
57
|
+
import { ChatViewHeaderRender, TSlashCommandCustomRender } from '../types';
|
|
41
58
|
|
|
42
59
|
import { ChatRequestModel, ChatSlashCommandItemModel } from './chat-model';
|
|
43
60
|
import { ChatProxyService } from './chat-proxy.service';
|
|
@@ -46,7 +63,6 @@ import { ChatFeatureRegistry } from './chat.feature.registry';
|
|
|
46
63
|
import { ChatInternalService } from './chat.internal.service';
|
|
47
64
|
import styles from './chat.module.less';
|
|
48
65
|
import { ChatRenderRegistry } from './chat.render.registry';
|
|
49
|
-
|
|
50
66
|
const SCROLL_CLASSNAME = 'chat_scroll';
|
|
51
67
|
|
|
52
68
|
interface TDispatchAction {
|
|
@@ -63,12 +79,12 @@ export const AIChatView = () => {
|
|
|
63
79
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
64
80
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
65
81
|
const chatRenderRegistry = useInjectable<ChatRenderRegistry>(ChatRenderRegistryToken);
|
|
66
|
-
const
|
|
82
|
+
const contextService = useInjectable<LLMContextService>(LLMContextServiceToken);
|
|
83
|
+
const promptProvider = useInjectable<ChatAgentPromptProvider>(ChatAgentPromptProvider);
|
|
67
84
|
|
|
68
85
|
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
|
|
69
86
|
const msgHistoryManager = aiChatService.sessionModel.history;
|
|
70
87
|
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
71
|
-
const autoScroll = React.useRef<boolean>(true);
|
|
72
88
|
const chatInputRef = React.useRef<{ setInputValue: (v: string) => void } | null>(null);
|
|
73
89
|
|
|
74
90
|
const [shortcutCommands, setShortcutCommands] = React.useState<ChatSlashCommandItemModel[]>([]);
|
|
@@ -140,29 +156,8 @@ export const AIChatView = () => {
|
|
|
140
156
|
[],
|
|
141
157
|
);
|
|
142
158
|
|
|
143
|
-
const onDidWheel = React.useCallback(
|
|
144
|
-
(e: WheelEvent) => {
|
|
145
|
-
// 向上滚动
|
|
146
|
-
if (e.deltaY < 0) {
|
|
147
|
-
autoScroll.current = false;
|
|
148
|
-
} else {
|
|
149
|
-
autoScroll.current = true;
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
[autoScroll],
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
React.useEffect(() => {
|
|
156
|
-
if (containerRef.current) {
|
|
157
|
-
containerRef.current.addEventListener('wheel', onDidWheel);
|
|
158
|
-
return () => {
|
|
159
|
-
containerRef.current?.removeEventListener('wheel', onDidWheel);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}, [autoScroll]);
|
|
163
|
-
|
|
164
159
|
const scrollToBottom = React.useCallback(() => {
|
|
165
|
-
if (containerRef && containerRef.current
|
|
160
|
+
if (containerRef && containerRef.current) {
|
|
166
161
|
const lastElement = containerRef.current.lastElementChild;
|
|
167
162
|
if (lastElement) {
|
|
168
163
|
lastElement.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
|
@@ -172,7 +167,7 @@ export const AIChatView = () => {
|
|
|
172
167
|
containerRef.current.classList.add(SCROLL_CLASSNAME);
|
|
173
168
|
}
|
|
174
169
|
}
|
|
175
|
-
}, [containerRef
|
|
170
|
+
}, [containerRef]);
|
|
176
171
|
|
|
177
172
|
const handleDispatchMessage = React.useCallback(
|
|
178
173
|
(dispatch: TDispatchAction) => {
|
|
@@ -194,7 +189,7 @@ export const AIChatView = () => {
|
|
|
194
189
|
disposer.addDispose(
|
|
195
190
|
chatApiService.onScrollToBottom(() => {
|
|
196
191
|
requestAnimationFrame(() => {
|
|
197
|
-
|
|
192
|
+
scrollToBottom();
|
|
198
193
|
});
|
|
199
194
|
}),
|
|
200
195
|
);
|
|
@@ -221,9 +216,8 @@ export const AIChatView = () => {
|
|
|
221
216
|
disposer.addDispose(
|
|
222
217
|
chatApiService.onChatReplyMessageLaunch((data) => {
|
|
223
218
|
if (data.kind === 'content') {
|
|
224
|
-
const relationId = aiReporter.start(AIServiceType.
|
|
219
|
+
const relationId = aiReporter.start(AIServiceType.CustomReplay, {
|
|
225
220
|
message: data.content,
|
|
226
|
-
sessionId: aiChatService.sessionModel.sessionId,
|
|
227
221
|
});
|
|
228
222
|
msgHistoryManager.addAssistantMessage({
|
|
229
223
|
content: data.content,
|
|
@@ -231,9 +225,8 @@ export const AIChatView = () => {
|
|
|
231
225
|
});
|
|
232
226
|
renderSimpleMarkdownReply({ chunk: data.content, relationId });
|
|
233
227
|
} else {
|
|
234
|
-
const relationId = aiReporter.start(AIServiceType.
|
|
228
|
+
const relationId = aiReporter.start(AIServiceType.CustomReplay, {
|
|
235
229
|
message: 'component#' + data.component,
|
|
236
|
-
sessionId: aiChatService.sessionModel.sessionId,
|
|
237
230
|
});
|
|
238
231
|
msgHistoryManager.addAssistantMessage({
|
|
239
232
|
componentId: data.component,
|
|
@@ -255,7 +248,6 @@ export const AIChatView = () => {
|
|
|
255
248
|
|
|
256
249
|
const relationId = aiReporter.start(AIServiceType.Chat, {
|
|
257
250
|
message: '',
|
|
258
|
-
sessionId: aiChatService.sessionModel.sessionId,
|
|
259
251
|
});
|
|
260
252
|
|
|
261
253
|
if (role === 'assistant') {
|
|
@@ -514,7 +506,10 @@ export const AIChatView = () => {
|
|
|
514
506
|
const { message, agentId, command, reportExtra } = value;
|
|
515
507
|
const { actionType, actionSource } = reportExtra || {};
|
|
516
508
|
|
|
517
|
-
const
|
|
509
|
+
const context = contextService.serialize();
|
|
510
|
+
const fullMessage = await promptProvider.provideContextPrompt(context, message);
|
|
511
|
+
|
|
512
|
+
const request = aiChatService.createRequest(fullMessage, agentId!, command);
|
|
518
513
|
if (!request) {
|
|
519
514
|
return;
|
|
520
515
|
}
|
|
@@ -524,19 +519,13 @@ export const AIChatView = () => {
|
|
|
524
519
|
|
|
525
520
|
const startTime = Date.now();
|
|
526
521
|
const reportType = ChatProxyService.AGENT_ID === agentId ? AIServiceType.Chat : AIServiceType.Agent;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
actionSource,
|
|
535
|
-
sessionId: aiChatService.sessionModel.sessionId,
|
|
536
|
-
},
|
|
537
|
-
// 由于涉及 tool 调用,超时时间设置长一点
|
|
538
|
-
600 * 1000,
|
|
539
|
-
);
|
|
522
|
+
const relationId = aiReporter.start(command || reportType, {
|
|
523
|
+
message,
|
|
524
|
+
agentId,
|
|
525
|
+
userMessage: message,
|
|
526
|
+
actionType,
|
|
527
|
+
actionSource,
|
|
528
|
+
});
|
|
540
529
|
|
|
541
530
|
msgHistoryManager.addUserMessage({
|
|
542
531
|
content: message,
|
|
@@ -561,12 +550,6 @@ export const AIChatView = () => {
|
|
|
561
550
|
replyStartTime: startTime,
|
|
562
551
|
});
|
|
563
552
|
|
|
564
|
-
// 创建消息时,设置当前活跃的消息信息,便于toolCall打点
|
|
565
|
-
mcpServerRegistry.activeMessageInfo = {
|
|
566
|
-
messageId: msgId,
|
|
567
|
-
sessionId: aiChatService.sessionModel.sessionId,
|
|
568
|
-
};
|
|
569
|
-
|
|
570
553
|
await renderReply({
|
|
571
554
|
startTime,
|
|
572
555
|
relationId,
|
|
@@ -752,18 +735,15 @@ export function DefaultChatViewHeader({
|
|
|
752
735
|
handleClear: () => any;
|
|
753
736
|
handleCloseChatView: () => any;
|
|
754
737
|
}) {
|
|
738
|
+
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
739
|
+
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
740
|
+
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
755
741
|
const aiChatService = useInjectable<ChatInternalService>(IChatInternalService);
|
|
756
|
-
const messageService = useInjectable<IMessageService>(IMessageService);
|
|
757
|
-
|
|
758
742
|
const [historyList, setHistoryList] = React.useState<IChatHistoryItem[]>([]);
|
|
759
743
|
const [currentTitle, setCurrentTitle] = React.useState<string>('');
|
|
760
744
|
const handleNewChat = React.useCallback(() => {
|
|
761
745
|
if (aiChatService.sessionModel.history.getMessages().length > 0) {
|
|
762
|
-
|
|
763
|
-
aiChatService.createSessionModel();
|
|
764
|
-
} catch (error) {
|
|
765
|
-
messageService.error(error.message);
|
|
766
|
-
}
|
|
746
|
+
aiChatService.createSessionModel();
|
|
767
747
|
}
|
|
768
748
|
}, [aiChatService]);
|
|
769
749
|
const handleHistoryItemSelect = React.useCallback(
|
|
@@ -779,6 +759,15 @@ export function DefaultChatViewHeader({
|
|
|
779
759
|
[aiChatService],
|
|
780
760
|
);
|
|
781
761
|
|
|
762
|
+
const handleShowMCPTools = React.useCallback(async () => {
|
|
763
|
+
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
764
|
+
dialogService.open({
|
|
765
|
+
message: <MCPToolsDialog tools={tools} />,
|
|
766
|
+
type: MessageType.Empty,
|
|
767
|
+
buttons: ['关闭'],
|
|
768
|
+
});
|
|
769
|
+
}, [mcpServerProxyService, dialogService]);
|
|
770
|
+
|
|
782
771
|
React.useEffect(() => {
|
|
783
772
|
const getHistoryList = () => {
|
|
784
773
|
const currentMessages = aiChatService.sessionModel.history.getMessages();
|
|
@@ -858,6 +847,23 @@ export function DefaultChatViewHeader({
|
|
|
858
847
|
ariaLabel={localize('aiNative.operate.clear.title')}
|
|
859
848
|
/>
|
|
860
849
|
</Popover>
|
|
850
|
+
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
851
|
+
<Popover
|
|
852
|
+
overlayClassName={styles.popover_icon}
|
|
853
|
+
id={'ai-chat-header-tools'}
|
|
854
|
+
position={PopoverPosition.left}
|
|
855
|
+
title={localize('aiNative.operate.tools.title')}
|
|
856
|
+
>
|
|
857
|
+
<EnhanceIcon
|
|
858
|
+
wrapperClassName={styles.action_btn}
|
|
859
|
+
className={getIcon('menubar-tool')}
|
|
860
|
+
onClick={handleShowMCPTools}
|
|
861
|
+
tabIndex={0}
|
|
862
|
+
role='button'
|
|
863
|
+
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
864
|
+
/>
|
|
865
|
+
</Popover>
|
|
866
|
+
)}
|
|
861
867
|
<Popover
|
|
862
868
|
overlayClassName={styles.popover_icon}
|
|
863
869
|
id={'ai-chat-header-close'}
|
|
@@ -39,7 +39,7 @@ export const ChatContext = memo(() => {
|
|
|
39
39
|
50,
|
|
40
40
|
)((files) => {
|
|
41
41
|
if (files) {
|
|
42
|
-
updateAddedFiles(
|
|
42
|
+
updateAddedFiles(files);
|
|
43
43
|
}
|
|
44
44
|
}, contextService);
|
|
45
45
|
|
|
@@ -57,7 +57,7 @@ export const ChatContext = memo(() => {
|
|
|
57
57
|
}, []);
|
|
58
58
|
|
|
59
59
|
const onDidDeselect = useCallback((uri: URI) => {
|
|
60
|
-
contextService.removeFileFromContext(uri
|
|
60
|
+
contextService.removeFileFromContext(uri);
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
63
63
|
const onDidClickFile = useCallback((uri: URI) => {
|
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import cls from 'classnames';
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useInjectable, useLatest } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { Icon, Popover, PopoverPosition, getIcon } from '@opensumi/ide-core-browser/lib/components';
|
|
6
6
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
7
7
|
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native/interactive-input/index';
|
|
8
|
-
import {
|
|
9
|
-
ChatAgentViewServiceToken,
|
|
10
|
-
ChatFeatureRegistryToken,
|
|
11
|
-
MessageType,
|
|
12
|
-
localize,
|
|
13
|
-
runWhenIdle,
|
|
14
|
-
} from '@opensumi/ide-core-common';
|
|
15
|
-
import { CommandService } from '@opensumi/ide-core-common/lib/command';
|
|
8
|
+
import { ChatAgentViewServiceToken, ChatFeatureRegistryToken, localize, runWhenIdle } from '@opensumi/ide-core-common';
|
|
16
9
|
import { MonacoCommandRegistry } from '@opensumi/ide-editor/lib/browser/monaco-contrib/command/command.service';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
AT_SIGN_SYMBOL,
|
|
21
|
-
IChatAgentService,
|
|
22
|
-
IChatInternalService,
|
|
23
|
-
SLASH_SYMBOL,
|
|
24
|
-
TokenMCPServerProxyService,
|
|
25
|
-
} from '../../common';
|
|
10
|
+
|
|
11
|
+
import { AT_SIGN_SYMBOL, IChatAgentService, SLASH_SYMBOL } from '../../common';
|
|
26
12
|
import { ChatAgentViewService } from '../chat/chat-agent.view.service';
|
|
27
13
|
import { ChatSlashCommandItemModel } from '../chat/chat-model';
|
|
28
14
|
import { ChatProxyService } from '../chat/chat-proxy.service';
|
|
29
15
|
import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
30
|
-
import { ChatInternalService } from '../chat/chat.internal.service';
|
|
31
|
-
import { OPEN_MCP_CONFIG_COMMAND } from '../mcp/config/mcp-config.commands';
|
|
32
|
-
import { MCPServerProxyService } from '../mcp/mcp-server-proxy.service';
|
|
33
|
-
import { MCPToolsDialog } from '../mcp/mcp-tools-dialog.view';
|
|
34
16
|
import { IChatSlashCommandItem } from '../types';
|
|
35
17
|
|
|
18
|
+
import { ChatContext } from './ChatContext';
|
|
36
19
|
import styles from './components.module.less';
|
|
37
20
|
|
|
38
21
|
const INSTRUCTION_BOTTOM = 8;
|
|
@@ -211,30 +194,13 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
211
194
|
const [showExpand, setShowExpand] = useState(false);
|
|
212
195
|
const [isExpand, setIsExpand] = useState(false);
|
|
213
196
|
const [placeholder, setPlaceHolder] = useState(localize('aiNative.chat.input.placeholder.default'));
|
|
214
|
-
|
|
215
|
-
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
216
|
-
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
217
|
-
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
197
|
+
|
|
218
198
|
const monacoCommandRegistry = useInjectable<MonacoCommandRegistry>(MonacoCommandRegistry);
|
|
219
199
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
220
200
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
221
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
222
201
|
|
|
223
202
|
const currentAgentIdRef = useLatest(agentId);
|
|
224
203
|
|
|
225
|
-
const handleShowMCPConfig = React.useCallback(() => {
|
|
226
|
-
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
227
|
-
}, [commandService]);
|
|
228
|
-
|
|
229
|
-
const handleShowMCPTools = React.useCallback(async () => {
|
|
230
|
-
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
231
|
-
dialogService.open({
|
|
232
|
-
message: <MCPToolsDialog tools={tools} />,
|
|
233
|
-
type: MessageType.Empty,
|
|
234
|
-
buttons: [localize('dialog.file.close')],
|
|
235
|
-
});
|
|
236
|
-
}, [mcpServerProxyService, dialogService]);
|
|
237
|
-
|
|
238
204
|
useImperativeHandle(ref, () => ({
|
|
239
205
|
setInputValue: (v: string) => {
|
|
240
206
|
setValue(v);
|
|
@@ -331,10 +297,6 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
331
297
|
}
|
|
332
298
|
}, []);
|
|
333
299
|
|
|
334
|
-
const handleStop = useCallback(() => {
|
|
335
|
-
aiChatService.cancelRequest();
|
|
336
|
-
}, []);
|
|
337
|
-
|
|
338
300
|
const handleSend = useCallback(async () => {
|
|
339
301
|
if (disabled) {
|
|
340
302
|
return;
|
|
@@ -495,48 +457,11 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
495
457
|
disabled={disabled}
|
|
496
458
|
className={styles.input_wrapper}
|
|
497
459
|
onSend={handleSend}
|
|
498
|
-
onStop={handleStop}
|
|
499
460
|
sendBtnClassName={sendBtnClassName}
|
|
500
461
|
onHeightChange={handleHeightChange}
|
|
501
462
|
height={inputHeight}
|
|
502
463
|
popoverPosition={PopoverPosition.left}
|
|
503
464
|
/>
|
|
504
|
-
<div className={styles.chat_input_footer}>
|
|
505
|
-
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
506
|
-
<div className={styles.mcp_desc}>
|
|
507
|
-
<Popover
|
|
508
|
-
overlayClassName={styles.popover_icon}
|
|
509
|
-
id={'ai-chat-header-mcp-server'}
|
|
510
|
-
position={PopoverPosition.left}
|
|
511
|
-
title={'MCP Server'}
|
|
512
|
-
>
|
|
513
|
-
<EnhanceIcon
|
|
514
|
-
wrapperClassName={styles.action_btn}
|
|
515
|
-
className={'codicon codicon-server'}
|
|
516
|
-
onClick={handleShowMCPConfig}
|
|
517
|
-
tabIndex={0}
|
|
518
|
-
role='button'
|
|
519
|
-
ariaLabel={'MCP Server'}
|
|
520
|
-
/>
|
|
521
|
-
</Popover>
|
|
522
|
-
<Popover
|
|
523
|
-
overlayClassName={styles.popover_icon}
|
|
524
|
-
id={'ai-chat-header-tools'}
|
|
525
|
-
position={PopoverPosition.left}
|
|
526
|
-
title={localize('aiNative.operate.tools.title')}
|
|
527
|
-
>
|
|
528
|
-
<EnhanceIcon
|
|
529
|
-
wrapperClassName={styles.action_btn}
|
|
530
|
-
className={getIcon('menubar-tool')}
|
|
531
|
-
onClick={handleShowMCPTools}
|
|
532
|
-
tabIndex={0}
|
|
533
|
-
role='button'
|
|
534
|
-
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
535
|
-
/>
|
|
536
|
-
</Popover>
|
|
537
|
-
</div>
|
|
538
|
-
)}
|
|
539
|
-
</div>
|
|
540
465
|
</div>
|
|
541
466
|
);
|
|
542
467
|
});
|