@opensumi/ide-ai-native 3.9.1-next-1749204089.0 → 3.9.1-next-1749538805.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.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +9 -4
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/apply.service.d.ts +3 -0
- package/lib/browser/chat/apply.service.d.ts.map +1 -1
- package/lib/browser/chat/apply.service.js +47 -0
- package/lib/browser/chat/apply.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 +9 -3
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +8 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +113 -76
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +0 -2
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +50 -57
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +4 -1
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +6 -0
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +50 -10
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.js +2 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +2 -1
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +148 -30
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +2 -2
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +7 -2
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +25 -0
- package/lib/browser/components/components.module.less +37 -8
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +150 -14
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +165 -1
- package/lib/browser/components/mention-input/mention-select.d.ts +28 -0
- package/lib/browser/components/mention-input/mention-select.d.ts.map +1 -0
- package/lib/browser/components/mention-input/mention-select.js +136 -0
- package/lib/browser/components/mention-input/mention-select.js.map +1 -0
- package/lib/browser/components/mention-input/mention-select.module.less +297 -0
- package/lib/browser/components/mention-input/types.d.ts +28 -1
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +1 -0
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +21 -2
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +162 -20
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +7 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +6 -4
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/tabbar.view.d.ts +1 -1
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +5 -12
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +5 -4
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +23 -5
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +3 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +4 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +7 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +1 -3
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +14 -40
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.js +9 -5
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.js +22 -10
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.d.ts +15 -0
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.js +53 -0
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts +11 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +11 -4
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +19 -15
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +47 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +127 -2
- 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 +5 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/rules/rules.contribution.d.ts +29 -0
- package/lib/browser/rules/rules.contribution.d.ts.map +1 -0
- package/lib/browser/rules/rules.contribution.js +94 -0
- package/lib/browser/rules/rules.contribution.js.map +1 -0
- package/lib/browser/rules/rules.module.less +175 -0
- package/lib/browser/rules/rules.service.d.ts +25 -0
- package/lib/browser/rules/rules.service.d.ts.map +1 -0
- package/lib/browser/rules/rules.service.js +180 -0
- package/lib/browser/rules/rules.service.js.map +1 -0
- package/lib/browser/rules/rules.view.d.ts +3 -0
- package/lib/browser/rules/rules.view.d.ts.map +1 -0
- package/lib/browser/rules/rules.view.js +76 -0
- package/lib/browser/rules/rules.view.js.map +1 -0
- package/lib/browser/types.d.ts +12 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/image-compression.d.ts +25 -0
- package/lib/common/image-compression.d.ts.map +1 -0
- package/lib/common/image-compression.js +153 -0
- package/lib/common/image-compression.js.map +1 -0
- package/lib/common/index.d.ts +5 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +19 -0
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/mdc-parser.d.ts +60 -0
- package/lib/common/mdc-parser.d.ts.map +1 -0
- package/lib/common/mdc-parser.js +246 -0
- package/lib/common/mdc-parser.js.map +1 -0
- package/lib/common/model.d.ts +1 -0
- package/lib/common/model.d.ts.map +1 -1
- package/lib/common/model.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +0 -2
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +35 -29
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/prompts/system-prompt.d.ts +2 -0
- package/lib/common/prompts/system-prompt.d.ts.map +1 -0
- package/lib/common/prompts/system-prompt.js +5 -0
- package/lib/common/prompts/system-prompt.js.map +1 -0
- package/lib/common/types.d.ts +21 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +5 -2
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts +2 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +12 -2
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +3 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +7 -1
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +3 -1
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +14 -2
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.sse.d.ts +187 -1
- package/lib/node/mcp-server.sse.d.ts.map +1 -1
- package/lib/node/mcp-server.sse.js +2 -2
- package/lib/node/mcp-server.sse.js.map +1 -1
- package/lib/node/mcp-server.stdio.d.ts +187 -1
- package/lib/node/mcp-server.stdio.d.ts.map +1 -1
- package/package.json +27 -26
- package/src/browser/ai-core.contribution.ts +14 -4
- package/src/browser/chat/apply.service.ts +62 -1
- package/src/browser/chat/chat-manager.service.ts +16 -7
- package/src/browser/chat/chat-model.ts +130 -73
- package/src/browser/chat/chat-proxy.service.ts +68 -81
- package/src/browser/chat/chat.feature.registry.ts +17 -1
- package/src/browser/chat/chat.view.tsx +73 -12
- package/src/browser/components/ChatEditor.tsx +1 -1
- package/src/browser/components/ChatHistory.tsx +2 -1
- package/src/browser/components/ChatMentionInput.tsx +180 -35
- package/src/browser/components/ChatReply.tsx +4 -4
- package/src/browser/components/ChatToolRender.module.less +25 -0
- package/src/browser/components/ChatToolRender.tsx +10 -2
- package/src/browser/components/components.module.less +37 -8
- package/src/browser/components/mention-input/mention-input.module.less +165 -1
- package/src/browser/components/mention-input/mention-input.tsx +232 -31
- package/src/browser/components/mention-input/mention-select.module.less +297 -0
- package/src/browser/components/mention-input/mention-select.tsx +256 -0
- package/src/browser/components/mention-input/types.ts +29 -0
- package/src/browser/context/llm-context.service.ts +182 -21
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +8 -0
- package/src/browser/layout/ai-layout.tsx +12 -8
- package/src/browser/layout/tabbar.view.tsx +10 -23
- package/src/browser/mcp/base-apply.service.ts +30 -10
- package/src/browser/mcp/mcp-server-proxy.service.ts +6 -1
- package/src/browser/mcp/mcp-server.feature.registry.ts +6 -1
- package/src/browser/mcp/tools/createNewFileWithText.ts +17 -46
- package/src/browser/mcp/tools/fileSearch.ts +8 -5
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/grepSearch.ts +32 -21
- package/src/browser/mcp/tools/handlers/CreateNewFileWithText.ts +49 -0
- package/src/browser/mcp/tools/handlers/ListDir.ts +2 -2
- package/src/browser/mcp/tools/handlers/ReadFile.ts +2 -2
- package/src/browser/mcp/tools/handlers/RunCommand.ts +21 -14
- package/src/browser/mcp/tools/listDir.ts +15 -12
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +181 -2
- package/src/browser/preferences/schema.ts +5 -0
- package/src/browser/rules/rules.contribution.ts +105 -0
- package/src/browser/rules/rules.module.less +175 -0
- package/src/browser/rules/rules.service.ts +189 -0
- package/src/browser/rules/rules.view.tsx +127 -0
- package/src/browser/types.ts +18 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +0 -1
- package/src/common/image-compression.ts +174 -0
- package/src/common/index.ts +6 -1
- package/src/common/llm-context.ts +23 -0
- package/src/common/mdc-parser.ts +295 -0
- package/src/common/model.ts +1 -0
- package/src/common/prompts/context-prompt-provider.ts +55 -40
- package/src/common/prompts/system-prompt.ts +2 -0
- package/src/common/types.ts +18 -0
- package/src/common/utils.ts +4 -1
- package/src/node/base-language-model.ts +11 -14
- package/src/node/mcp/sumi-mcp-server.ts +10 -2
- package/src/node/mcp-server-manager-impl.ts +17 -2
- package/src/node/mcp-server.sse.ts +1 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { SlotRenderer, useInjectable } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { SlotLocation, SlotRenderer, useInjectable } from '@opensumi/ide-core-browser';
|
|
4
4
|
import { BoxPanel, SplitPanel, getStorageValue } from '@opensumi/ide-core-browser/lib/components';
|
|
5
5
|
import { DesignLayoutConfig } from '@opensumi/ide-core-browser/lib/layout/constants';
|
|
6
6
|
|
|
@@ -32,9 +32,9 @@ export const AILayout = () => {
|
|
|
32
32
|
resizeHandleClassName={'design-slot_resize_horizontal'}
|
|
33
33
|
>
|
|
34
34
|
<SlotRenderer
|
|
35
|
-
slot=
|
|
35
|
+
slot={SlotLocation.view}
|
|
36
36
|
isTabbar={true}
|
|
37
|
-
defaultSize={layout.
|
|
37
|
+
defaultSize={layout[SlotLocation.view]?.currentId ? layout[SlotLocation.view]?.size || 310 : 49}
|
|
38
38
|
minResize={280}
|
|
39
39
|
minSize={49}
|
|
40
40
|
/>
|
|
@@ -42,16 +42,20 @@ export const AILayout = () => {
|
|
|
42
42
|
<SlotRenderer flex={2} flexGrow={1} minResize={200} slot='main' />
|
|
43
43
|
<SlotRenderer
|
|
44
44
|
flex={1}
|
|
45
|
-
defaultSize={layout.
|
|
45
|
+
defaultSize={layout[SlotLocation.panel]?.currentId ? layout[SlotLocation.panel]?.size : 24}
|
|
46
46
|
minResize={160}
|
|
47
|
-
slot=
|
|
47
|
+
slot={SlotLocation.panel}
|
|
48
48
|
isTabbar={true}
|
|
49
49
|
/>
|
|
50
50
|
</SplitPanel>
|
|
51
51
|
<SlotRenderer
|
|
52
|
-
slot=
|
|
52
|
+
slot={SlotLocation.extendView}
|
|
53
53
|
isTabbar={true}
|
|
54
|
-
defaultSize={
|
|
54
|
+
defaultSize={
|
|
55
|
+
layout[SlotLocation.extendView]?.currentId
|
|
56
|
+
? layout[SlotLocation.extendView]?.size || 360
|
|
57
|
+
: defaultRightSize
|
|
58
|
+
}
|
|
55
59
|
minResize={280}
|
|
56
60
|
minSize={defaultRightSize}
|
|
57
61
|
/>
|
|
@@ -59,7 +63,7 @@ export const AILayout = () => {
|
|
|
59
63
|
<SlotRenderer
|
|
60
64
|
slot={AI_CHAT_VIEW_ID}
|
|
61
65
|
isTabbar={true}
|
|
62
|
-
defaultSize={layout
|
|
66
|
+
defaultSize={layout['AI-Chat']?.currentId ? layout['AI-Chat']?.size || 360 : 0}
|
|
63
67
|
maxResize={420}
|
|
64
68
|
minResize={280}
|
|
65
69
|
minSize={0}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cls from 'classnames';
|
|
2
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useMemo } from 'react';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
ComponentRegistryInfo,
|
|
@@ -29,25 +29,18 @@ import {
|
|
|
29
29
|
TabbarViewBase,
|
|
30
30
|
} from '@opensumi/ide-main-layout/lib/browser/tabbar/bar.view';
|
|
31
31
|
import { BaseTabPanelView, ContainerView } from '@opensumi/ide-main-layout/lib/browser/tabbar/panel.view';
|
|
32
|
-
import { TabRendererBase
|
|
32
|
+
import { TabRendererBase } from '@opensumi/ide-main-layout/lib/browser/tabbar/renderer.view';
|
|
33
33
|
import { TabbarService, TabbarServiceFactory } from '@opensumi/ide-main-layout/lib/browser/tabbar/tabbar.service';
|
|
34
34
|
|
|
35
35
|
import { AI_CHAT_VIEW_ID } from '../../common';
|
|
36
36
|
|
|
37
37
|
import styles from './layout.module.less';
|
|
38
38
|
|
|
39
|
-
const ChatTabbarRenderer: React.FC = () =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [tabbarService]);
|
|
45
|
-
return (
|
|
46
|
-
<div style={{ width: 0 }}>
|
|
47
|
-
<TabbarViewBase tabSize={0} MoreTabView={IconElipses} TabView={IconTabView} barSize={0} panelBorderSize={1} />
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
39
|
+
const ChatTabbarRenderer: React.FC = () => (
|
|
40
|
+
<div style={{ width: 0 }}>
|
|
41
|
+
<TabbarViewBase tabSize={0} MoreTabView={IconElipses} TabView={IconTabView} barSize={0} panelBorderSize={0} />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
51
44
|
|
|
52
45
|
export const AIChatTabRenderer = ({
|
|
53
46
|
className,
|
|
@@ -110,7 +103,7 @@ export const AILeftTabRenderer = ({
|
|
|
110
103
|
const AILeftTabbarRenderer: React.FC = () => {
|
|
111
104
|
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
|
|
112
105
|
|
|
113
|
-
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.
|
|
106
|
+
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.extendView);
|
|
114
107
|
const currentContainerId = useAutorun(tabbarService.currentContainerId);
|
|
115
108
|
|
|
116
109
|
const extraMenus = React.useMemo(() => layoutService.getExtraMenu(), [layoutService]);
|
|
@@ -154,14 +147,8 @@ const AILeftTabbarRenderer: React.FC = () => {
|
|
|
154
147
|
);
|
|
155
148
|
};
|
|
156
149
|
|
|
157
|
-
export const AIRightTabRenderer = ({
|
|
158
|
-
|
|
159
|
-
components,
|
|
160
|
-
}: {
|
|
161
|
-
className: string;
|
|
162
|
-
components: ComponentRegistryInfo[];
|
|
163
|
-
}) => {
|
|
164
|
-
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.right);
|
|
150
|
+
export const AIRightTabRenderer = ({ components }: { className: string; components: ComponentRegistryInfo[] }) => {
|
|
151
|
+
const tabbarService: TabbarService = useInjectable(TabbarServiceFactory)(SlotLocation.extendView);
|
|
165
152
|
const designLayoutConfig = useInjectable<DesignLayoutConfig>(DesignLayoutConfig);
|
|
166
153
|
|
|
167
154
|
const handleClose = useCallback(() => {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
AppConfig,
|
|
9
9
|
IAIReporter,
|
|
10
10
|
IChatProgress,
|
|
11
|
-
IMarker,
|
|
12
11
|
MarkerSeverity,
|
|
13
12
|
OnEvent,
|
|
14
13
|
WithEventBus,
|
|
@@ -63,6 +62,8 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
63
62
|
|
|
64
63
|
private currentSessionId?: string;
|
|
65
64
|
|
|
65
|
+
protected abstract postApplyHandler(editor: ICodeEditor): Promise<void>;
|
|
66
|
+
|
|
66
67
|
constructor() {
|
|
67
68
|
super();
|
|
68
69
|
this.addDispose(
|
|
@@ -313,10 +314,26 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
313
314
|
);
|
|
314
315
|
codeBlock.updatedCode = res.updatedCode;
|
|
315
316
|
codeBlock.status = 'pending';
|
|
317
|
+
|
|
318
|
+
// apply 结果流式输出完成后,自动尝试修复代码中的 lint 错误
|
|
319
|
+
if (this.postApplyHandler && typeof this.postApplyHandler === 'function') {
|
|
320
|
+
try {
|
|
321
|
+
await this.postApplyHandler(result.group.codeEditor.monacoEditor);
|
|
322
|
+
} catch (error) {}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const textModel = result.group.codeEditor.monacoEditor.getModel();
|
|
326
|
+
const diagnosticInfos = this.getDiagnosticInfos(textModel!.uri.toString(), res.result?.rangesFromDiffHunk || []);
|
|
327
|
+
|
|
316
328
|
// 用户实际接受的 apply 结果
|
|
317
|
-
|
|
318
|
-
|
|
329
|
+
if (res.result) {
|
|
330
|
+
codeBlock.applyResult = {
|
|
331
|
+
diff: res.result?.diff,
|
|
332
|
+
diagnosticInfos,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
319
335
|
|
|
336
|
+
this.updateCodeBlock(codeBlock);
|
|
320
337
|
return codeBlock;
|
|
321
338
|
} catch (err) {
|
|
322
339
|
codeBlock.status = 'failed';
|
|
@@ -336,8 +353,8 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
336
353
|
codeBlock: CodeBlockData,
|
|
337
354
|
updatedContentOrStream: string | SumiReadableStream<IChatProgress>,
|
|
338
355
|
range?: Range,
|
|
339
|
-
): Promise<{ result?: { diff: string;
|
|
340
|
-
const deferred = new Deferred<{ result?: { diff: string;
|
|
356
|
+
): Promise<{ result?: { diff: string; rangesFromDiffHunk: Range[] }; updatedCode: string }> {
|
|
357
|
+
const deferred = new Deferred<{ result?: { diff: string; rangesFromDiffHunk: Range[] }; updatedCode: string }>();
|
|
341
358
|
const inlineDiffController = InlineDiffController.get(editor)!;
|
|
342
359
|
range = range || editor.getModel()!.getFullModelRange();
|
|
343
360
|
|
|
@@ -373,7 +390,11 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
373
390
|
|
|
374
391
|
this.listenPartialEdit(editor.getModel()!, codeBlock).then((result) => {
|
|
375
392
|
if (result) {
|
|
376
|
-
|
|
393
|
+
const diagnosticInfos = this.getDiagnosticInfos(editor.getModel()!.uri.toString(), rangesFromDiffHunk);
|
|
394
|
+
codeBlock.applyResult = {
|
|
395
|
+
diff: result.diff,
|
|
396
|
+
diagnosticInfos,
|
|
397
|
+
};
|
|
377
398
|
}
|
|
378
399
|
this.updateCodeBlock(codeBlock);
|
|
379
400
|
this.editorService.save(URI.file(path.join(this.appConfig.workspaceDir, codeBlock.relativePath)));
|
|
@@ -384,11 +405,10 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
384
405
|
updatedContent,
|
|
385
406
|
codeBlock.relativePath,
|
|
386
407
|
);
|
|
387
|
-
const diagnosticInfos = this.getDiagnosticInfos(editor.getModel()!.uri.toString(), rangesFromDiffHunk);
|
|
388
408
|
deferred.resolve({
|
|
389
409
|
result: {
|
|
390
410
|
diff,
|
|
391
|
-
|
|
411
|
+
rangesFromDiffHunk,
|
|
392
412
|
},
|
|
393
413
|
updatedCode: updatedContent,
|
|
394
414
|
});
|
|
@@ -534,7 +554,7 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
534
554
|
}
|
|
535
555
|
|
|
536
556
|
protected listenPartialEdit(model: ITextModel, codeBlock: CodeBlockData) {
|
|
537
|
-
const deferred = new Deferred<{ diff: string;
|
|
557
|
+
const deferred = new Deferred<{ diff: string; rangesFromDiffHunk: Range[] }>();
|
|
538
558
|
const uriString = model.uri.toString();
|
|
539
559
|
const toDispose = this.inlineDiffService.onPartialEdit((event) => {
|
|
540
560
|
if (
|
|
@@ -574,7 +594,7 @@ export abstract class BaseApplyService extends WithEventBus {
|
|
|
574
594
|
});
|
|
575
595
|
deferred.resolve({
|
|
576
596
|
diff,
|
|
577
|
-
|
|
597
|
+
rangesFromDiffHunk,
|
|
578
598
|
});
|
|
579
599
|
} else {
|
|
580
600
|
// 用户全部取消
|
|
@@ -5,7 +5,8 @@ import { ILogger } from '@opensumi/ide-core-browser';
|
|
|
5
5
|
import { Emitter, Event } from '@opensumi/ide-core-common';
|
|
6
6
|
|
|
7
7
|
import { BUILTIN_MCP_SERVER_NAME, ISumiMCPServerBackend, SumiMCPServerProxyServicePath } from '../../common';
|
|
8
|
-
import {
|
|
8
|
+
import { ImageCompressionOptions, compressToolResultSmart } from '../../common/image-compression';
|
|
9
|
+
import { IMCPServerProxyService, IMCPToolResult } from '../../common/types';
|
|
9
10
|
import { IMCPServerRegistry, TokenMCPServerRegistry } from '../types';
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
@@ -64,4 +65,8 @@ export class MCPServerProxyService implements IMCPServerProxyService {
|
|
|
64
65
|
async $stopServer(serverName: string) {
|
|
65
66
|
await this.sumiMCPServerProxyService.$stopServer(serverName);
|
|
66
67
|
}
|
|
68
|
+
|
|
69
|
+
async $compressToolResult(result: IMCPToolResult, options: ImageCompressionOptions) {
|
|
70
|
+
return compressToolResultSmart(result, options);
|
|
71
|
+
}
|
|
67
72
|
}
|
|
@@ -44,7 +44,12 @@ export class MCPServerRegistry implements IMCPServerRegistry {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
registerMCPTool(tool: MCPToolDefinition): void {
|
|
47
|
-
this.tools.
|
|
47
|
+
const existingIndex = this.tools.findIndex((t) => t.name === tool.name);
|
|
48
|
+
if (existingIndex !== -1) {
|
|
49
|
+
this.tools[existingIndex] = tool;
|
|
50
|
+
} else {
|
|
51
|
+
this.tools.push(tool);
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
registerToolComponent(
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import { Domain
|
|
5
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
6
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
4
|
+
import { Domain } from '@opensumi/ide-core-common';
|
|
7
5
|
|
|
8
6
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
9
|
-
import { BaseApplyService } from '../base-apply.service';
|
|
10
7
|
|
|
11
8
|
import { EditFileToolComponent } from './components/EditFile';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import { CreateNewFileWithTextHandler } from './handlers/CreateNewFileWithText';
|
|
10
|
+
|
|
11
|
+
const inputSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
target_file: z.string().describe('The relative path where the file should be created'),
|
|
14
|
+
code_edit: z.string().describe('The content to write into the new file'),
|
|
15
|
+
})
|
|
16
|
+
.transform((data) => ({
|
|
17
|
+
targetFile: data.target_file,
|
|
18
|
+
codeEdit: data.code_edit,
|
|
19
|
+
}));
|
|
17
20
|
|
|
18
21
|
@Domain(MCPServerContribution)
|
|
19
22
|
export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
20
|
-
@Autowired(
|
|
21
|
-
private readonly
|
|
22
|
-
|
|
23
|
-
@Autowired(IFileServiceClient)
|
|
24
|
-
private readonly fileService: IFileServiceClient;
|
|
25
|
-
|
|
26
|
-
@Autowired(BaseApplyService)
|
|
27
|
-
private applyService: BaseApplyService;
|
|
23
|
+
@Autowired(CreateNewFileWithTextHandler)
|
|
24
|
+
private readonly createNewFileWithTextHandler: CreateNewFileWithTextHandler;
|
|
28
25
|
|
|
29
26
|
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
30
27
|
registry.registerMCPTool(this.getToolDefinition());
|
|
@@ -50,36 +47,10 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
50
47
|
|
|
51
48
|
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
52
49
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
56
|
-
logger.appendLine('Error: Cannot determine project directory');
|
|
57
|
-
return {
|
|
58
|
-
content: [{ type: 'text', text: "can't find project dir" }],
|
|
59
|
-
isError: true,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 构建完整的文件路径
|
|
64
|
-
const rootUri = URI.parse(workspaceRoots[0].uri);
|
|
65
|
-
const fullPath = path.join(rootUri.codeUri.fsPath, args.target_file);
|
|
66
|
-
const fileUri = URI.file(fullPath);
|
|
67
|
-
|
|
68
|
-
// 创建父目录
|
|
69
|
-
const parentDir = path.dirname(fullPath);
|
|
70
|
-
const parentUri = URI.file(parentDir);
|
|
71
|
-
await this.fileService.createFolder(parentUri.toString());
|
|
72
|
-
|
|
73
|
-
// 创建文件
|
|
74
|
-
await this.fileService.createFile(fileUri.toString());
|
|
75
|
-
|
|
76
|
-
// 使用 applyService 写入文件内容
|
|
77
|
-
const codeBlock = await this.applyService.registerCodeBlock(args.target_file, args.code_edit, args.toolCallId);
|
|
78
|
-
await this.applyService.apply(codeBlock);
|
|
79
|
-
|
|
80
|
-
logger.appendLine(`Successfully created file at: ${args.target_file}`);
|
|
50
|
+
await this.createNewFileWithTextHandler.handler(args, args.toolCallId);
|
|
51
|
+
logger.appendLine(`Successfully created file at: ${args.targetFile}`);
|
|
81
52
|
return {
|
|
82
|
-
content: [{ type: 'text', text: '
|
|
53
|
+
content: [{ type: 'text', text: 'create file with text success' }],
|
|
83
54
|
};
|
|
84
55
|
} catch (error) {
|
|
85
56
|
logger.appendLine(`Error during file creation: ${error}`);
|
|
@@ -80,11 +80,14 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
const messageId = messages[messages.length - 1]?.id;
|
|
84
|
+
if (messageId) {
|
|
85
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
|
|
86
|
+
[args.toolCallId]: {
|
|
87
|
+
files,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
88
91
|
|
|
89
92
|
logger.appendLine(`Found ${files.length} files matching "${args.query}"`);
|
|
90
93
|
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired
|
|
5
|
+
import { Autowired } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
8
8
|
import { URI as MonacoURI } from '@opensumi/monaco-editor-core/esm/vs/base/common/uri';
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired
|
|
5
|
+
import { Autowired } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
8
8
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
@@ -12,19 +12,27 @@ import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition
|
|
|
12
12
|
|
|
13
13
|
import { GrepSearchToolComponent } from './components/ExpandableFileList';
|
|
14
14
|
|
|
15
|
-
const inputSchema = z
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
const inputSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
query: z.string().describe('The regex pattern to search for'),
|
|
18
|
+
case_sensitive: z.boolean().optional().describe('Whether the search should be case sensitive'),
|
|
19
|
+
include_pattern: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),
|
|
23
|
+
exclude_pattern: z.string().optional().describe('Glob pattern for files to exclude'),
|
|
24
|
+
explanation: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
28
|
+
})
|
|
29
|
+
.transform((data) => ({
|
|
30
|
+
query: data.query,
|
|
31
|
+
caseSensitive: data.case_sensitive,
|
|
32
|
+
includePattern: data.include_pattern,
|
|
33
|
+
excludePattern: data.exclude_pattern,
|
|
34
|
+
explanation: data.explanation,
|
|
35
|
+
}));
|
|
28
36
|
|
|
29
37
|
const MAX_RESULTS = 50;
|
|
30
38
|
|
|
@@ -72,9 +80,9 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
72
80
|
await this.searchService.doSearch(
|
|
73
81
|
searchPattern,
|
|
74
82
|
{
|
|
75
|
-
isMatchCase: !!args.
|
|
76
|
-
include: args.
|
|
77
|
-
exclude: args.
|
|
83
|
+
isMatchCase: !!args.caseSensitive,
|
|
84
|
+
include: args.includePattern?.split(','),
|
|
85
|
+
exclude: args.excludePattern?.split(','),
|
|
78
86
|
maxResults: MAX_RESULTS,
|
|
79
87
|
isUseRegexp: true,
|
|
80
88
|
isToggleOpen: false,
|
|
@@ -111,11 +119,14 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
111
119
|
}
|
|
112
120
|
deferred.resolve(results.join('\n\n'));
|
|
113
121
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
const messageId = messages[messages.length - 1]?.id;
|
|
123
|
+
if (messageId) {
|
|
124
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
|
|
125
|
+
[args.toolCallId]: {
|
|
126
|
+
files,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
119
130
|
});
|
|
120
131
|
const text = await deferred.promise;
|
|
121
132
|
return {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import { URI, path } from '@opensumi/ide-core-common';
|
|
3
|
+
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
4
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
5
|
+
|
|
6
|
+
import { CodeBlockData } from '../../../../common/types';
|
|
7
|
+
import { BaseApplyService } from '../../base-apply.service';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 创建新文件处理器
|
|
11
|
+
* 用于处理创建新文件并写入内容的操作
|
|
12
|
+
*/
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class CreateNewFileWithTextHandler {
|
|
15
|
+
@Autowired(IWorkspaceService)
|
|
16
|
+
private readonly workspaceService: IWorkspaceService;
|
|
17
|
+
|
|
18
|
+
@Autowired(IFileServiceClient)
|
|
19
|
+
private readonly fileService: IFileServiceClient;
|
|
20
|
+
|
|
21
|
+
@Autowired(BaseApplyService)
|
|
22
|
+
private applyService: BaseApplyService;
|
|
23
|
+
|
|
24
|
+
async handler(params: { targetFile: string; codeEdit: string }, toolCallId: string): Promise<CodeBlockData> {
|
|
25
|
+
// 获取工作区根目录
|
|
26
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
27
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
28
|
+
throw new Error("can't find project dir");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 构建完整的文件路径
|
|
32
|
+
const rootUri = URI.parse(workspaceRoots[0].uri);
|
|
33
|
+
const fullPath = path.join(rootUri.codeUri.fsPath, params.targetFile);
|
|
34
|
+
const fileUri = URI.file(fullPath);
|
|
35
|
+
|
|
36
|
+
// 创建父目录
|
|
37
|
+
const parentDir = path.dirname(fullPath);
|
|
38
|
+
const parentUri = URI.file(parentDir);
|
|
39
|
+
await this.fileService.createFolder(parentUri.toString());
|
|
40
|
+
|
|
41
|
+
// 创建文件
|
|
42
|
+
await this.fileService.createFile(fileUri.toString());
|
|
43
|
+
|
|
44
|
+
// 使用 applyService 写入文件内容
|
|
45
|
+
const codeBlock = await this.applyService.registerCodeBlock(params.targetFile, params.codeEdit, toolCallId);
|
|
46
|
+
await this.applyService.apply(codeBlock);
|
|
47
|
+
return codeBlock;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { AppConfig,
|
|
2
|
+
import { AppConfig, URI, path } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -67,7 +67,7 @@ export class ListDirHandler {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// 解析相对路径
|
|
70
|
-
const absolutePath =
|
|
70
|
+
const absolutePath = path.join(this.appConfig.workspaceDir, relativeWorkspacePath);
|
|
71
71
|
const fileStat = await this.fileSystemService.getFileStat(absolutePath, true);
|
|
72
72
|
// 验证路径有效性
|
|
73
73
|
if (!fileStat || !fileStat.isDirectory) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { FileSearchQuickCommandHandler } from '@opensumi/ide-addons/lib/browser/file-search.contribution';
|
|
3
3
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
4
|
-
import { CancellationToken, URI } from '@opensumi/ide-core-common';
|
|
4
|
+
import { CancellationToken, URI, path } from '@opensumi/ide-core-common';
|
|
5
5
|
import { IEditorDocumentModelRef, IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser';
|
|
6
6
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
7
7
|
|
|
@@ -107,7 +107,7 @@ export class FileHandler {
|
|
|
107
107
|
throw new Error('No read file parameters provided. Need to give at least the path.');
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const uri = new URI(
|
|
110
|
+
const uri = new URI(path.join(this.appConfig.workspaceDir, fileParams.relativeWorkspacePath));
|
|
111
111
|
if (!uri) {
|
|
112
112
|
const similarFiles = await this.findSimilarFiles(fileParams.relativeWorkspacePath, 3);
|
|
113
113
|
throw this.createFileNotFoundError(fileParams.relativeWorkspacePath, similarFiles);
|
|
@@ -13,18 +13,25 @@ const color = {
|
|
|
13
13
|
reset: '\x1b[0m',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const inputSchema = z
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
export const inputSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
command: z.string().describe('The terminal command to execute'),
|
|
19
|
+
is_background: z.boolean().describe('Whether the command should be run in the background'),
|
|
20
|
+
explanation: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe('One sentence explanation as to why this command needs to be run and how it contributes to the goal.'),
|
|
23
|
+
require_user_approval: z
|
|
24
|
+
.boolean()
|
|
25
|
+
.describe(
|
|
26
|
+
"Whether the user must approve the command before it is executed. Only set this to false if the command is safe and if it matches the user's requirements for commands that should be executed automatically.",
|
|
27
|
+
),
|
|
28
|
+
})
|
|
29
|
+
.transform((data) => ({
|
|
30
|
+
command: data.command,
|
|
31
|
+
isBackground: data.is_background,
|
|
32
|
+
explanation: data.explanation,
|
|
33
|
+
requireUserApproval: data.require_user_approval,
|
|
34
|
+
}));
|
|
28
35
|
|
|
29
36
|
@Injectable()
|
|
30
37
|
export class RunCommandHandler {
|
|
@@ -66,7 +73,7 @@ export class RunCommandHandler {
|
|
|
66
73
|
|
|
67
74
|
async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
68
75
|
logger.appendLine(`Executing command: ${args.command}`);
|
|
69
|
-
if (this.isAlwaysApproval(args.
|
|
76
|
+
if (this.isAlwaysApproval(args.requireUserApproval)) {
|
|
70
77
|
const def = new Deferred<boolean>();
|
|
71
78
|
this.approvalDeferredMap.set(args.toolCallId, def);
|
|
72
79
|
const approval = await def.promise;
|
|
@@ -93,7 +100,7 @@ export class RunCommandHandler {
|
|
|
93
100
|
const result: { type: string; text: string }[] = [];
|
|
94
101
|
const def = new Deferred<{ isError?: boolean; content: { type: string; text: string }[] }>();
|
|
95
102
|
|
|
96
|
-
if (args.
|
|
103
|
+
if (args.isBackground) {
|
|
97
104
|
def.resolve({
|
|
98
105
|
isError: false,
|
|
99
106
|
content: [{ type: 'text', text: `Successful run command ${args.command} in background.` }],
|
|
@@ -63,18 +63,21 @@ export class ListDirTool implements MCPServerContribution {
|
|
|
63
63
|
|
|
64
64
|
// 设置消息的附加数据
|
|
65
65
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
const messageId = messages[messages.length - 1]?.id;
|
|
67
|
+
if (messageId) {
|
|
68
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
|
|
69
|
+
[args.toolCallId]: {
|
|
70
|
+
files: fileUris,
|
|
71
|
+
title: `Listed directory "${args.relativeWorkspacePath}"`,
|
|
72
|
+
details: result.files.map((file) => ({
|
|
73
|
+
type: file.isDirectory ? 'dir' : 'file',
|
|
74
|
+
name: file.name,
|
|
75
|
+
info: file.isDirectory ? `${file.numChildren ?? '?'} items` : `${file.size}KB, ${file.numLines} lines`,
|
|
76
|
+
lastModified: file.lastModified,
|
|
77
|
+
})),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
78
81
|
|
|
79
82
|
logger.appendLine(`Listed ${fileUris.length} files in directory "${args.relativeWorkspacePath}"`);
|
|
80
83
|
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
4
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
5
|
-
import {
|
|
5
|
+
import { Domain } from '@opensumi/ide-core-common';
|
|
6
6
|
import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next/lib/common/controller';
|
|
7
7
|
|
|
8
8
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|