@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
|
@@ -44,10 +44,13 @@ export enum EComputerMode {
|
|
|
44
44
|
|
|
45
45
|
const inlineStreamDiffComputer = new InlineStreamDiffComputer();
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Abstract base class for inline streaming diff handlers
|
|
49
|
+
*/
|
|
47
50
|
@Injectable({ multiple: true })
|
|
48
|
-
export class
|
|
51
|
+
export abstract class BaseInlineStreamDiffHandler extends Disposable implements IInlineDiffPreviewerNode {
|
|
49
52
|
@Autowired(INJECTOR_TOKEN)
|
|
50
|
-
|
|
53
|
+
protected readonly injector: Injector;
|
|
51
54
|
|
|
52
55
|
protected readonly _onDidEditChange = this.registerDispose(new Emitter<void>());
|
|
53
56
|
public readonly onDidEditChange: Event<void> = this._onDidEditChange.event;
|
|
@@ -57,15 +60,14 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
57
60
|
|
|
58
61
|
public previewerOptions: IDiffPreviewerOptions;
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
protected savedModel: ITextModel;
|
|
64
|
+
protected virtualModel: ITextModel;
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
protected rawSavedTextLines: string[];
|
|
67
|
+
protected rawOriginTextLinesTokens: LineTokens[] | undefined;
|
|
68
|
+
protected undoRedoGroup: UndoRedoGroup = new UndoRedoGroup();
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
private readonly finallyDiffModel: ISettableObservable<IComputeDiffData | undefined> = observableValue(
|
|
70
|
+
protected readonly finallyDiffModel: ISettableObservable<IComputeDiffData | undefined> = observableValue(
|
|
69
71
|
this,
|
|
70
72
|
undefined,
|
|
71
73
|
);
|
|
@@ -73,14 +75,15 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
73
75
|
public livePreviewDiffDecorationModel: LivePreviewDiffDecorationModel;
|
|
74
76
|
|
|
75
77
|
public get uri() {
|
|
76
|
-
return this.
|
|
78
|
+
return this.savedModel.uri;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
constructor(
|
|
81
|
+
constructor(protected readonly monacoEditor: ICodeEditor) {
|
|
80
82
|
super();
|
|
81
83
|
|
|
82
84
|
const modelService = StandaloneServices.get(IModelService);
|
|
83
|
-
|
|
85
|
+
const savedModel = this.monacoEditor.getModel()!;
|
|
86
|
+
const setModel = modelService.createModel(
|
|
84
87
|
'',
|
|
85
88
|
null,
|
|
86
89
|
Uri.from({
|
|
@@ -89,7 +92,8 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
89
92
|
}),
|
|
90
93
|
true,
|
|
91
94
|
);
|
|
92
|
-
this.
|
|
95
|
+
this.savedModel = savedModel;
|
|
96
|
+
this.virtualModel = setModel;
|
|
93
97
|
|
|
94
98
|
this.livePreviewDiffDecorationModel = this.injector.get(LivePreviewDiffDecorationModel, [this.monacoEditor]);
|
|
95
99
|
this.addDispose(this.livePreviewDiffDecorationModel);
|
|
@@ -113,45 +117,21 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
113
117
|
});
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
initialize(selection: Selection): void
|
|
117
|
-
const eol = this.originalModel.getEOL();
|
|
118
|
-
const startPosition = selection.getStartPosition();
|
|
119
|
-
const endPosition = selection.getEndPosition();
|
|
120
|
-
|
|
121
|
-
this.rawOriginalTextLines = this.originalModel
|
|
122
|
-
.getValueInRange(Range.fromPositions(startPosition, endPosition))
|
|
123
|
-
.split(eol);
|
|
124
|
-
|
|
125
|
-
this.rawOriginalTextLinesTokens = this.rawOriginalTextLines.map((_, index) => {
|
|
126
|
-
const lineNumber = startPosition.lineNumber + index;
|
|
127
|
-
this.originalModel.tokenization.forceTokenization(lineNumber);
|
|
128
|
-
const lineTokens = this.originalModel.tokenization.getLineTokens(lineNumber);
|
|
129
|
-
return lineTokens;
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const zone = LineRange.fromRangeInclusive(
|
|
133
|
-
Range.fromPositions(
|
|
134
|
-
{ lineNumber: selection.startLineNumber, column: 1 },
|
|
135
|
-
{ lineNumber: selection.endLineNumber, column: Number.MAX_SAFE_INTEGER },
|
|
136
|
-
),
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
this.livePreviewDiffDecorationModel.initialize(zone);
|
|
140
|
-
}
|
|
120
|
+
abstract initialize(selection: Selection): void;
|
|
141
121
|
|
|
142
122
|
getVirtualModelValue() {
|
|
143
123
|
return this.virtualModel.getValue();
|
|
144
124
|
}
|
|
145
125
|
|
|
146
126
|
getOriginModelValue() {
|
|
147
|
-
return this.
|
|
127
|
+
return this.rawSavedTextLines.join('\n');
|
|
148
128
|
}
|
|
149
129
|
|
|
150
130
|
get onPartialEditWidgetListChange() {
|
|
151
131
|
return this.livePreviewDiffDecorationModel.onPartialEditWidgetListChange;
|
|
152
132
|
}
|
|
153
133
|
|
|
154
|
-
|
|
134
|
+
protected computeDiff(
|
|
155
135
|
originalTextLines: string[],
|
|
156
136
|
newTextLines: string[],
|
|
157
137
|
computerMode: EComputerMode = EComputerMode.default,
|
|
@@ -285,7 +265,12 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
285
265
|
},
|
|
286
266
|
textLines: removedTextLines.map((text, index) => ({
|
|
287
267
|
text,
|
|
288
|
-
lineTokens:
|
|
268
|
+
lineTokens:
|
|
269
|
+
this.rawOriginTextLinesTokens?.[removedLinesOriginalRange.startLineNumber - 1 + index] ||
|
|
270
|
+
LineTokens.createEmpty(text, {
|
|
271
|
+
encodeLanguageId: () => 0,
|
|
272
|
+
decodeLanguageId: () => 'plaintext',
|
|
273
|
+
}),
|
|
289
274
|
})),
|
|
290
275
|
});
|
|
291
276
|
}
|
|
@@ -298,6 +283,11 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
298
283
|
});
|
|
299
284
|
}
|
|
300
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Get the original model for diff operations
|
|
288
|
+
*/
|
|
289
|
+
protected abstract getOriginalModel(): ITextModel;
|
|
290
|
+
|
|
301
291
|
/**
|
|
302
292
|
* 令当前的 inline diff 在流式渲染过程当中使用 pushEditOperations 进行编辑的操作都放在同一组 undo/redo 堆栈里
|
|
303
293
|
* 一旦撤销到最顶层则关闭当前的 inline diff
|
|
@@ -310,22 +300,24 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
310
300
|
});
|
|
311
301
|
}
|
|
312
302
|
|
|
313
|
-
|
|
303
|
+
protected renderDiffEdits(diffModel: IComputeDiffData): void {
|
|
314
304
|
const { activeLine, newFullRangeTextLines, pendingRange } = diffModel;
|
|
315
|
-
const eol = this.originalModel.getEOL();
|
|
316
305
|
const zone = this.getZone();
|
|
317
306
|
|
|
307
|
+
const originalModel = this.getOriginalModel();
|
|
308
|
+
const eol = originalModel.getEOL();
|
|
309
|
+
|
|
318
310
|
const validZone =
|
|
319
311
|
zone.startLineNumber < zone.endLineNumberExclusive
|
|
320
312
|
? new Range(
|
|
321
313
|
zone.startLineNumber,
|
|
322
314
|
1,
|
|
323
315
|
zone.endLineNumberExclusive - 1,
|
|
324
|
-
|
|
316
|
+
originalModel.getLineMaxColumn(zone.endLineNumberExclusive - 1),
|
|
325
317
|
)
|
|
326
318
|
: new Range(zone.startLineNumber, 1, zone.startLineNumber, 1);
|
|
327
319
|
|
|
328
|
-
const newOriginalTextLines =
|
|
320
|
+
const newOriginalTextLines = originalModel.getValueInRange(validZone).split(eol);
|
|
329
321
|
const diffComputation = linesDiffComputers.getDefault().computeDiff(newOriginalTextLines, newFullRangeTextLines, {
|
|
330
322
|
computeMoves: false,
|
|
331
323
|
maxComputationTimeMs: 200,
|
|
@@ -370,7 +362,7 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
370
362
|
validZone.startLineNumber + change.original.startLineNumber - 1,
|
|
371
363
|
1,
|
|
372
364
|
validZone.startLineNumber + change.original.endLineNumberExclusive - 2,
|
|
373
|
-
|
|
365
|
+
originalModel.getLineMaxColumn(validZone.startLineNumber + change.original.endLineNumberExclusive - 2),
|
|
374
366
|
);
|
|
375
367
|
}
|
|
376
368
|
const edit = {
|
|
@@ -381,7 +373,7 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
381
373
|
realTimeChanges.push(edit);
|
|
382
374
|
}
|
|
383
375
|
}
|
|
384
|
-
|
|
376
|
+
originalModel.pushEditOperations(null, realTimeChanges, () => null, this.undoRedoGroup);
|
|
385
377
|
|
|
386
378
|
/**
|
|
387
379
|
* 根据 newFullRangeTextLines 内容长度重新计算 zone,避免超过最大长度,进而影响未选中的代码区域
|
|
@@ -421,17 +413,20 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
421
413
|
this._onDidEditChange.fire();
|
|
422
414
|
}
|
|
423
415
|
|
|
424
|
-
public recompute(computerMode: EComputerMode,
|
|
425
|
-
if (
|
|
426
|
-
this.virtualModel.setValue(
|
|
416
|
+
public recompute(computerMode: EComputerMode, content?: string): IComputeDiffData {
|
|
417
|
+
if (content) {
|
|
418
|
+
this.virtualModel.setValue(content);
|
|
427
419
|
}
|
|
428
420
|
|
|
429
|
-
const
|
|
430
|
-
return this.
|
|
421
|
+
const textLines = this.virtualModel.getLinesContent();
|
|
422
|
+
return this.processDiffComputation(textLines, computerMode);
|
|
431
423
|
}
|
|
432
424
|
|
|
433
|
-
|
|
434
|
-
|
|
425
|
+
protected currentEditLine = 0;
|
|
426
|
+
protected isEditing = false;
|
|
427
|
+
|
|
428
|
+
protected abstract processDiffComputation(currentText: string[], computerMode?: EComputerMode): IComputeDiffData;
|
|
429
|
+
|
|
435
430
|
public async rateRenderEditController(): Promise<void> {
|
|
436
431
|
if (this.isEditing === false) {
|
|
437
432
|
this.isEditing = true;
|
|
@@ -443,19 +438,14 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
443
438
|
|
|
444
439
|
const virtualTextLines = this.virtualModel.getLinesContent();
|
|
445
440
|
const currentText = virtualTextLines.slice(0, this.currentEditLine);
|
|
446
|
-
const currentDiffModel = this.
|
|
447
|
-
transaction((tx) => {
|
|
448
|
-
this.diffModel.set(currentDiffModel, tx);
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
this.onDiffFinishedEmitter.fire(currentDiffModel);
|
|
441
|
+
const currentDiffModel = this.processDiffComputation(currentText);
|
|
452
442
|
|
|
453
|
-
if (this.
|
|
443
|
+
if (this.savedModel.id === this.monacoEditor.getModel()?.id) {
|
|
454
444
|
this.renderDiffEdits(currentDiffModel);
|
|
455
445
|
}
|
|
456
446
|
|
|
457
447
|
this.currentEditLine += 1;
|
|
458
|
-
|
|
448
|
+
// 这个 sleep 会带来潜在的时序问题,如 finallyRender 时模型已经被 dispose
|
|
459
449
|
await sleep(FRAME_THREE);
|
|
460
450
|
}
|
|
461
451
|
|
|
@@ -469,10 +459,7 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
469
459
|
}
|
|
470
460
|
|
|
471
461
|
public addLinesToDiff(newText: string, computerMode: EComputerMode = EComputerMode.default): void {
|
|
472
|
-
|
|
473
|
-
transaction((tx) => {
|
|
474
|
-
this.diffModel.set(diffModel, tx);
|
|
475
|
-
});
|
|
462
|
+
this.recompute(computerMode, newText);
|
|
476
463
|
}
|
|
477
464
|
|
|
478
465
|
public pushRateFinallyDiffStack(diffModel: IComputeDiffData): void {
|
|
@@ -488,14 +475,17 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
488
475
|
public finallyRender(diffModel: IComputeDiffData): void {
|
|
489
476
|
transaction((tx) => {
|
|
490
477
|
this.finallyDiffModel.set(diffModel, tx);
|
|
491
|
-
this.diffModel.set(diffModel, tx);
|
|
492
478
|
});
|
|
493
479
|
|
|
494
|
-
if (this.
|
|
480
|
+
if (this.savedModel.id !== this.monacoEditor.getModel()?.id) {
|
|
495
481
|
return;
|
|
496
482
|
}
|
|
497
483
|
|
|
498
484
|
this.onDiffFinishedEmitter.fire(diffModel);
|
|
485
|
+
|
|
486
|
+
if (this.livePreviewDiffDecorationModel.disposed) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
499
489
|
this.renderPartialEditWidgets(diffModel);
|
|
500
490
|
this.renderDiffEdits(diffModel);
|
|
501
491
|
this.pushStackElement();
|
|
@@ -537,3 +527,84 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
537
527
|
return this.livePreviewDiffDecorationModel.getTotalCodeInfo();
|
|
538
528
|
}
|
|
539
529
|
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Regular inline stream diff handler (non-reverse mode)
|
|
533
|
+
*/
|
|
534
|
+
@Injectable({ multiple: true })
|
|
535
|
+
export class InlineStreamDiffHandler extends BaseInlineStreamDiffHandler {
|
|
536
|
+
initialize(selection: Selection): void {
|
|
537
|
+
const eol = this.savedModel.getEOL();
|
|
538
|
+
const startPosition = selection.getStartPosition();
|
|
539
|
+
const endPosition = selection.getEndPosition();
|
|
540
|
+
|
|
541
|
+
this.rawSavedTextLines = this.savedModel
|
|
542
|
+
.getValueInRange(Range.fromPositions(startPosition, endPosition))
|
|
543
|
+
.split(eol);
|
|
544
|
+
|
|
545
|
+
const zone = LineRange.fromRangeInclusive(
|
|
546
|
+
Range.fromPositions(
|
|
547
|
+
{ lineNumber: selection.startLineNumber, column: 1 },
|
|
548
|
+
{ lineNumber: selection.endLineNumber, column: Number.MAX_SAFE_INTEGER },
|
|
549
|
+
),
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
this.livePreviewDiffDecorationModel.initialize(zone);
|
|
553
|
+
this.rawOriginTextLinesTokens = this.rawSavedTextLines.map((_, index) => {
|
|
554
|
+
const lineNumber = startPosition.lineNumber + index;
|
|
555
|
+
this.savedModel.tokenization.forceTokenization(lineNumber);
|
|
556
|
+
const lineTokens = this.savedModel.tokenization.getLineTokens(lineNumber);
|
|
557
|
+
return lineTokens;
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
protected processDiffComputation(currentText: string[], computerMode?: EComputerMode): IComputeDiffData {
|
|
562
|
+
return this.computeDiff(this.rawSavedTextLines, currentText, computerMode);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
protected getOriginalModel(): ITextModel {
|
|
566
|
+
return this.savedModel;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Reverse inline stream diff handler
|
|
572
|
+
* In reverse mode, the roles of savedModel and virtualModel are swapped
|
|
573
|
+
*/
|
|
574
|
+
@Injectable({ multiple: true })
|
|
575
|
+
export class ReverseInlineStreamDiffHandler extends BaseInlineStreamDiffHandler {
|
|
576
|
+
recompute(computerMode: EComputerMode, content?: string): IComputeDiffData {
|
|
577
|
+
const result = super.recompute(computerMode, content);
|
|
578
|
+
this.rawOriginTextLinesTokens = this.virtualModel.getLinesContent().map((_, index) => {
|
|
579
|
+
const lineNumber = index + 1;
|
|
580
|
+
this.virtualModel.tokenization.forceTokenization(lineNumber);
|
|
581
|
+
const lineTokens = this.virtualModel.tokenization.getLineTokens(lineNumber);
|
|
582
|
+
return lineTokens;
|
|
583
|
+
});
|
|
584
|
+
return result;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
initialize(): void {
|
|
588
|
+
const eol = this.savedModel.getEOL();
|
|
589
|
+
|
|
590
|
+
// reverse 模式不支持 range
|
|
591
|
+
this.rawSavedTextLines = this.savedModel.getValue().split(eol);
|
|
592
|
+
|
|
593
|
+
// TODO: reverse 模式暂不支持 range
|
|
594
|
+
const zone = LineRange.fromRangeInclusive(
|
|
595
|
+
Range.fromPositions(
|
|
596
|
+
{ lineNumber: 1, column: 1 },
|
|
597
|
+
{ lineNumber: this.virtualModel.getLineCount(), column: Number.MAX_SAFE_INTEGER },
|
|
598
|
+
),
|
|
599
|
+
);
|
|
600
|
+
this.livePreviewDiffDecorationModel.initialize(zone);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
protected getOriginalModel(): ITextModel {
|
|
604
|
+
return this.virtualModel;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
protected processDiffComputation(currentText: string[], computerMode?: EComputerMode): IComputeDiffData {
|
|
608
|
+
return this.computeDiff(currentText, this.rawSavedTextLines, computerMode);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
@@ -7,11 +7,13 @@ import {
|
|
|
7
7
|
Emitter,
|
|
8
8
|
Event,
|
|
9
9
|
IAIReporter,
|
|
10
|
+
localize,
|
|
10
11
|
runWhenIdle,
|
|
11
12
|
} from '@opensumi/ide-core-common';
|
|
12
13
|
import { ISingleEditOperation } from '@opensumi/ide-editor';
|
|
13
14
|
import { ICodeEditor, IEditorDecorationsCollection, ITextModel, Position, Range } from '@opensumi/ide-monaco';
|
|
14
15
|
import { StandaloneServices } from '@opensumi/ide-monaco/lib/browser/monaco-api/services';
|
|
16
|
+
import { IMessageService } from '@opensumi/ide-overlay';
|
|
15
17
|
import { EditOperation } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/editOperation';
|
|
16
18
|
import { LineRange } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/lineRange';
|
|
17
19
|
import { ModelDecorationOptions } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model/textModel';
|
|
@@ -67,6 +69,9 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
67
69
|
@Autowired(InlineDiffService)
|
|
68
70
|
private readonly inlineDiffService: InlineDiffService;
|
|
69
71
|
|
|
72
|
+
@Autowired(IMessageService)
|
|
73
|
+
private readonly messageService: IMessageService;
|
|
74
|
+
|
|
70
75
|
private activeLineDec: IEditorDecorationsCollection;
|
|
71
76
|
private pendingRangeDec: IEditorDecorationsCollection;
|
|
72
77
|
private aiNativeContextKey: AINativeContextKey;
|
|
@@ -87,6 +92,10 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
87
92
|
private removedZoneWidgets: RemovedZoneWidget[] = [];
|
|
88
93
|
private zone: LineRange;
|
|
89
94
|
|
|
95
|
+
public get partialEditWidgetCount() {
|
|
96
|
+
return this.partialEditWidgetList.length;
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
constructor(private readonly monacoEditor: ICodeEditor) {
|
|
91
100
|
super();
|
|
92
101
|
this.model = this.monacoEditor.getModel()!;
|
|
@@ -616,7 +625,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
616
625
|
if (this.options.renderRemovedWidgetImmediately) {
|
|
617
626
|
run();
|
|
618
627
|
} else {
|
|
619
|
-
runWhenIdle(run);
|
|
628
|
+
this.addDispose(runWhenIdle(run));
|
|
620
629
|
}
|
|
621
630
|
}
|
|
622
631
|
|
|
@@ -681,6 +690,26 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
681
690
|
}
|
|
682
691
|
}
|
|
683
692
|
|
|
693
|
+
currentChangeIndex: number = 0;
|
|
694
|
+
|
|
695
|
+
revealSiblingChange(direction: 'up' | 'down') {
|
|
696
|
+
this.currentChangeIndex = this.currentChangeIndex + (direction === 'up' ? -1 : 1);
|
|
697
|
+
if (this.currentChangeIndex >= 0 && this.currentChangeIndex < this.partialEditWidgetList.length) {
|
|
698
|
+
const siblingChange = this.partialEditWidgetList[this.currentChangeIndex];
|
|
699
|
+
const pos = siblingChange.getPosition();
|
|
700
|
+
if (pos?.position) {
|
|
701
|
+
this.monacoEditor.revealLineInCenter(pos.position!.lineNumber);
|
|
702
|
+
return this.currentChangeIndex;
|
|
703
|
+
}
|
|
704
|
+
} else {
|
|
705
|
+
this.messageService.info(
|
|
706
|
+
direction === 'up'
|
|
707
|
+
? localize('aiNative.inlineDiff.noMoreChangesUp')
|
|
708
|
+
: localize('aiNative.inlineDiff.noMoreChangesDown'),
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
684
713
|
setPreviewerOptions(options: IModelOptions) {
|
|
685
714
|
this.options = options;
|
|
686
715
|
}
|
package/src/common/index.ts
CHANGED
|
@@ -12,13 +12,18 @@ import {
|
|
|
12
12
|
IMarkdownString,
|
|
13
13
|
Uri,
|
|
14
14
|
} from '@opensumi/ide-core-common';
|
|
15
|
-
import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
16
15
|
import { DESIGN_MENUBAR_CONTAINER_VIEW_ID } from '@opensumi/ide-design/lib/common/constants';
|
|
17
16
|
import { IPosition, ITextModel, InlineCompletionContext } from '@opensumi/ide-monaco/lib/common';
|
|
18
17
|
|
|
19
18
|
import { MCPServerDescription } from './mcp-server-manager';
|
|
20
19
|
import { MCPTool } from './types';
|
|
21
20
|
|
|
21
|
+
import type { CoreMessage } from 'ai';
|
|
22
|
+
|
|
23
|
+
export type { CoreMessage };
|
|
24
|
+
|
|
25
|
+
export * from './model';
|
|
26
|
+
|
|
22
27
|
export const IAINativeService = Symbol('IAINativeService');
|
|
23
28
|
|
|
24
29
|
/**
|
|
@@ -31,6 +36,9 @@ export const AI_CHAT_CONTAINER_ID = 'AI-Chat-Container';
|
|
|
31
36
|
export const AI_CHAT_LOGO_AVATAR_ID = 'AI-Chat-Logo-Avatar';
|
|
32
37
|
export const AI_MENU_BAR_DEBUG_TOOLBAR = 'AI_MENU_BAR_DEBUG_TOOLBAR';
|
|
33
38
|
|
|
39
|
+
// 内置 MCP 服务器名称
|
|
40
|
+
export const BUILTIN_MCP_SERVER_NAME = 'sumi-builtin';
|
|
41
|
+
|
|
34
42
|
/**
|
|
35
43
|
* @deprecated Use {@link DESIGN_MENUBAR_CONTAINER_VIEW_ID} instead
|
|
36
44
|
*/
|
|
@@ -123,9 +131,12 @@ export const ChatProxyServiceToken = Symbol('ChatProxyServiceToken');
|
|
|
123
131
|
export const TokenMCPServerProxyService = Symbol('TokenMCPServerProxyService');
|
|
124
132
|
|
|
125
133
|
export interface ISumiMCPServerBackend {
|
|
126
|
-
initBuiltinMCPServer(): void;
|
|
134
|
+
initBuiltinMCPServer(enabled: boolean): void;
|
|
127
135
|
initExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
128
136
|
getAllMCPTools(): Promise<MCPTool[]>;
|
|
137
|
+
getServers(): Promise<Array<{ name: string; isStarted: boolean }>>;
|
|
138
|
+
startServer(serverName: string): Promise<void>;
|
|
139
|
+
stopServer(serverName: string): Promise<void>;
|
|
129
140
|
}
|
|
130
141
|
|
|
131
142
|
export const SumiMCPServerProxyServicePath = 'SumiMCPServerProxyServicePath';
|
|
@@ -138,7 +149,7 @@ export interface IChatAgentService {
|
|
|
138
149
|
id: string,
|
|
139
150
|
request: IChatAgentRequest,
|
|
140
151
|
progress: (part: IChatProgress) => void,
|
|
141
|
-
history:
|
|
152
|
+
history: CoreMessage[],
|
|
142
153
|
token: CancellationToken,
|
|
143
154
|
): Promise<IChatAgentResult>;
|
|
144
155
|
getAgents(): Array<IChatAgent>;
|
|
@@ -159,7 +170,7 @@ export interface IChatAgent extends IChatAgentData {
|
|
|
159
170
|
invoke(
|
|
160
171
|
request: IChatAgentRequest,
|
|
161
172
|
progress: (part: IChatProgress) => void,
|
|
162
|
-
history:
|
|
173
|
+
history: CoreMessage[],
|
|
163
174
|
token: CancellationToken,
|
|
164
175
|
): Promise<IChatAgentResult>;
|
|
165
176
|
provideFollowups?(sessionId: string, token: CancellationToken): Promise<IChatFollowup[]>;
|
|
@@ -15,13 +15,13 @@ export interface LLMContextService {
|
|
|
15
15
|
*/
|
|
16
16
|
cleanFileContext(): void;
|
|
17
17
|
|
|
18
|
-
onDidContextFilesChangeEvent: Event<FileContext[]>;
|
|
18
|
+
onDidContextFilesChangeEvent: Event<{ viewed: FileContext[]; attached: FileContext[]; version: number }>;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 从 context 中移除文件
|
|
22
22
|
* @param uri URI
|
|
23
23
|
*/
|
|
24
|
-
removeFileFromContext(uri: URI): void;
|
|
24
|
+
removeFileFromContext(uri: URI, isManual?: boolean): void;
|
|
25
25
|
|
|
26
26
|
/** 导出为可序列化格式 */
|
|
27
27
|
serialize(): SerializedContext;
|
|
@@ -30,12 +30,18 @@ export interface LLMContextService {
|
|
|
30
30
|
export interface FileContext {
|
|
31
31
|
uri: URI;
|
|
32
32
|
selection?: [number, number];
|
|
33
|
-
isManual: boolean;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
export const LLMContextServiceToken = Symbol('LLMContextService');
|
|
37
36
|
|
|
37
|
+
export interface AttachFileContext {
|
|
38
|
+
content: string;
|
|
39
|
+
lineErrors: string[];
|
|
40
|
+
path: string;
|
|
41
|
+
language: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
export interface SerializedContext {
|
|
39
45
|
recentlyViewFiles: string[];
|
|
40
|
-
attachedFiles: Array<
|
|
46
|
+
attachedFiles: Array<AttachFileContext>;
|
|
41
47
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
2
|
|
|
3
|
+
export interface IMCPServer {
|
|
4
|
+
isStarted(): boolean;
|
|
5
|
+
start(): Promise<void>;
|
|
6
|
+
getServerName(): string;
|
|
7
|
+
callTool(toolName: string, toolCallId: string, arg_string: string): ReturnType<Client['callTool']>;
|
|
8
|
+
getTools(): ReturnType<Client['listTools']>;
|
|
9
|
+
update(command: string, args?: string[], env?: { [key: string]: string }): void;
|
|
10
|
+
stop(): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
export interface MCPServerManager {
|
|
4
14
|
callTool(
|
|
5
15
|
serverName: string,
|
|
@@ -11,7 +21,7 @@ export interface MCPServerManager {
|
|
|
11
21
|
addOrUpdateServer(description: MCPServerDescription): void;
|
|
12
22
|
// invoke in node.js only
|
|
13
23
|
addOrUpdateServerDirectly(server: any): void;
|
|
14
|
-
initBuiltinServer(builtinMCPServer: any): void;
|
|
24
|
+
initBuiltinServer(builtinMCPServer: any, enabled: boolean): void;
|
|
15
25
|
getTools(serverName: string): ReturnType<Client['listTools']>;
|
|
16
26
|
getServerNames(): Promise<string[]>;
|
|
17
27
|
startServer(serverName: string): Promise<void>;
|
|
@@ -19,6 +29,7 @@ export interface MCPServerManager {
|
|
|
19
29
|
getStartedServers(): Promise<string[]>;
|
|
20
30
|
registerTools(serverName: string): Promise<void>;
|
|
21
31
|
addExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
32
|
+
getServers(): Map<string, IMCPServer>;
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
export type MCPTool = Awaited<ReturnType<MCPServerManager['getTools']>>['tools'][number];
|
|
@@ -45,6 +56,11 @@ export interface MCPServerDescription {
|
|
|
45
56
|
* Optional environment variables to set when starting the server.
|
|
46
57
|
*/
|
|
47
58
|
env?: { [key: string]: string };
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether to enable the MCP server.
|
|
62
|
+
*/
|
|
63
|
+
enabled?: boolean;
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
export const MCPServerManager = Symbol('MCPServerManager');
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface ModelInfo {
|
|
2
|
+
maxTokens?: number;
|
|
3
|
+
contextWindow?: number;
|
|
4
|
+
supportsImages?: boolean;
|
|
5
|
+
temperature?: number;
|
|
6
|
+
topP?: number;
|
|
7
|
+
topK?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const deepSeekModels = {
|
|
11
|
+
'deepseek-chat': {
|
|
12
|
+
maxTokens: 8_000,
|
|
13
|
+
contextWindow: 64_000,
|
|
14
|
+
supportsImages: false,
|
|
15
|
+
},
|
|
16
|
+
'deepseek-reasoner': {
|
|
17
|
+
maxTokens: 8_000,
|
|
18
|
+
contextWindow: 64_000,
|
|
19
|
+
supportsImages: false,
|
|
20
|
+
temperature: 0.7,
|
|
21
|
+
topP: 0.95,
|
|
22
|
+
},
|
|
23
|
+
} as Record<string, ModelInfo>;
|
|
24
|
+
|
|
25
|
+
export const anthropicModels = {
|
|
26
|
+
'claude-3-7-sonnet-20250219': {
|
|
27
|
+
maxTokens: 8192,
|
|
28
|
+
contextWindow: 200_000,
|
|
29
|
+
supportsImages: true,
|
|
30
|
+
},
|
|
31
|
+
'claude-3-5-sonnet-20241022': {
|
|
32
|
+
maxTokens: 8192,
|
|
33
|
+
contextWindow: 200_000,
|
|
34
|
+
supportsImages: true,
|
|
35
|
+
},
|
|
36
|
+
'claude-3-5-haiku-20241022': {
|
|
37
|
+
maxTokens: 8192,
|
|
38
|
+
contextWindow: 200_000,
|
|
39
|
+
supportsImages: false,
|
|
40
|
+
},
|
|
41
|
+
'claude-3-opus-20240229': {
|
|
42
|
+
maxTokens: 4096,
|
|
43
|
+
contextWindow: 200_000,
|
|
44
|
+
supportsImages: true,
|
|
45
|
+
},
|
|
46
|
+
'claude-3-haiku-20240307': {
|
|
47
|
+
maxTokens: 4096,
|
|
48
|
+
contextWindow: 200_000,
|
|
49
|
+
supportsImages: true,
|
|
50
|
+
},
|
|
51
|
+
} as Record<string, ModelInfo>; // as const assertion makes the object deeply readonly
|
|
52
|
+
|
|
53
|
+
export const openAiNativeModels = {
|
|
54
|
+
'o3-mini': {
|
|
55
|
+
maxTokens: 100_000,
|
|
56
|
+
contextWindow: 200_000,
|
|
57
|
+
supportsImages: false,
|
|
58
|
+
},
|
|
59
|
+
// don't support tool use yet
|
|
60
|
+
o1: {
|
|
61
|
+
maxTokens: 100_000,
|
|
62
|
+
contextWindow: 200_000,
|
|
63
|
+
supportsImages: true,
|
|
64
|
+
},
|
|
65
|
+
'o1-preview': {
|
|
66
|
+
maxTokens: 32_768,
|
|
67
|
+
contextWindow: 128_000,
|
|
68
|
+
supportsImages: true,
|
|
69
|
+
},
|
|
70
|
+
'o1-mini': {
|
|
71
|
+
maxTokens: 65_536,
|
|
72
|
+
contextWindow: 128_000,
|
|
73
|
+
supportsImages: true,
|
|
74
|
+
},
|
|
75
|
+
'gpt-4o': {
|
|
76
|
+
maxTokens: 4_096,
|
|
77
|
+
contextWindow: 128_000,
|
|
78
|
+
supportsImages: true,
|
|
79
|
+
},
|
|
80
|
+
'gpt-4o-mini': {
|
|
81
|
+
maxTokens: 16_384,
|
|
82
|
+
contextWindow: 128_000,
|
|
83
|
+
supportsImages: true,
|
|
84
|
+
},
|
|
85
|
+
'gpt-4.5-preview': {
|
|
86
|
+
maxTokens: 16_384,
|
|
87
|
+
contextWindow: 128_000,
|
|
88
|
+
supportsImages: true,
|
|
89
|
+
},
|
|
90
|
+
} as Record<string, ModelInfo>;
|