@opensumi/ide-ai-native 3.8.1-next-1741080291.0 → 3.8.1-next-1741091353.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 +0 -3
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +1 -45
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts +8 -0
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +32 -5
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +4 -0
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +3 -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 +5 -9
- package/lib/browser/chat/chat-proxy.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 +13 -39
- 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 +25 -1
- package/lib/browser/components/ChatInput.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/chat-history.module.less +2 -1
- package/lib/browser/components/components.module.less +20 -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/layout/layout.module.less +4 -4
- package/lib/browser/mcp/base-apply.service.d.ts +18 -7
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +185 -65
- package/lib/browser/mcp/base-apply.service.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/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 +1 -0
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +3 -0
- 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 +1 -7
- package/lib/browser/preferences/schema.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 +0 -1
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -2
- 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/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/types.d.ts +1 -0
- package/lib/common/types.d.ts.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 +1 -4
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +6 -7
- 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/openai/openai-language-model.d.ts +4 -5
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +7 -8
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +23 -24
- package/src/browser/ai-core.contribution.ts +1 -56
- package/src/browser/chat/chat-agent.service.ts +38 -7
- package/src/browser/chat/chat-manager.service.ts +6 -0
- package/src/browser/chat/chat-model.ts +11 -6
- package/src/browser/chat/chat-proxy.service.ts +6 -9
- package/src/browser/chat/chat.module.less +1 -2
- package/src/browser/chat/chat.view.tsx +14 -72
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatInput.tsx +67 -3
- package/src/browser/components/ChatToolRender.tsx +1 -2
- package/src/browser/components/chat-history.module.less +2 -1
- package/src/browser/components/components.module.less +20 -0
- package/src/browser/context/llm-context.service.ts +93 -54
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +222 -67
- 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/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 +4 -0
- package/src/browser/preferences/schema.ts +1 -7
- 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 +0 -2
- package/src/common/llm-context.ts +10 -4
- package/src/common/prompts/context-prompt-provider.ts +38 -29
- package/src/common/types.ts +1 -0
- package/src/node/anthropic/anthropic-language-model.ts +2 -7
- package/src/node/base-language-model.ts +12 -10
- package/src/node/deepseek/deepseek-language-model.ts +2 -7
- package/src/node/openai/openai-language-model.ts +9 -10
- 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/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/tools/components/SearchResult.tsx +0 -92
- package/src/common/model.ts +0 -90
- package/src/node/openai-compatible/openai-compatible-language-model.ts +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-language-model.js","sourceRoot":"","sources":["../../../src/node/openai/openai-language-model.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"openai-language-model.js","sourceRoot":"","sources":["../../../src/node/openai/openai-language-model.ts"],"names":[],"mappings":";;;;AAAA,iEAA6F;AAG7F,qCAA0C;AAC1C,+DAA4F;AAE5F,gEAA2D;AAE9C,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAGlE,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,uCAAiB;IACtC,kBAAkB,CAAC,OAA6B;QACxD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,iDAAiD,2CAAyB,CAAC,YAAY,GAAG,CAAC,CAAC;QAC9G,CAAC;QACD,OAAO,IAAA,0CAAsB,EAAC;YAC5B,MAAM;YACN,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,mDAAmD;YAC/E,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAES,kBAAkB,CAAC,QAAkC,EAAE,OAAgB;QAC/E,OAAO,QAAQ,CAAC,OAAO,IAAI,UAAU,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAhBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAU,GAAE;GACA,WAAW,CAgBvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.8.1-next-
|
|
3
|
+
"version": "3.8.1-next-1741091353.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -21,29 +21,28 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@ai-sdk/anthropic": "^1.1.9",
|
|
23
23
|
"@ai-sdk/deepseek": "^0.1.11",
|
|
24
|
-
"@ai-sdk/openai": "^1.1.9",
|
|
25
24
|
"@ai-sdk/openai-compatible": "^0.1.11",
|
|
26
25
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
27
|
-
"@opensumi/ide-addons": "3.8.1-next-
|
|
28
|
-
"@opensumi/ide-components": "3.8.1-next-
|
|
29
|
-
"@opensumi/ide-connection": "3.8.1-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.1-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.1-next-
|
|
32
|
-
"@opensumi/ide-debug": "3.8.1-next-
|
|
33
|
-
"@opensumi/ide-design": "3.8.1-next-
|
|
34
|
-
"@opensumi/ide-editor": "3.8.1-next-
|
|
35
|
-
"@opensumi/ide-file-search": "3.8.1-next-
|
|
36
|
-
"@opensumi/ide-file-service": "3.8.1-next-
|
|
37
|
-
"@opensumi/ide-main-layout": "3.8.1-next-
|
|
38
|
-
"@opensumi/ide-markers": "3.8.1-next-
|
|
39
|
-
"@opensumi/ide-monaco": "3.8.1-next-
|
|
40
|
-
"@opensumi/ide-overlay": "3.8.1-next-
|
|
41
|
-
"@opensumi/ide-preferences": "3.8.1-next-
|
|
42
|
-
"@opensumi/ide-search": "3.8.1-next-
|
|
43
|
-
"@opensumi/ide-terminal-next": "3.8.1-next-
|
|
44
|
-
"@opensumi/ide-theme": "3.8.1-next-
|
|
45
|
-
"@opensumi/ide-utils": "3.8.1-next-
|
|
46
|
-
"@opensumi/ide-workspace": "3.8.1-next-
|
|
26
|
+
"@opensumi/ide-addons": "3.8.1-next-1741091353.0",
|
|
27
|
+
"@opensumi/ide-components": "3.8.1-next-1741091353.0",
|
|
28
|
+
"@opensumi/ide-connection": "3.8.1-next-1741091353.0",
|
|
29
|
+
"@opensumi/ide-core-common": "3.8.1-next-1741091353.0",
|
|
30
|
+
"@opensumi/ide-core-node": "3.8.1-next-1741091353.0",
|
|
31
|
+
"@opensumi/ide-debug": "3.8.1-next-1741091353.0",
|
|
32
|
+
"@opensumi/ide-design": "3.8.1-next-1741091353.0",
|
|
33
|
+
"@opensumi/ide-editor": "3.8.1-next-1741091353.0",
|
|
34
|
+
"@opensumi/ide-file-search": "3.8.1-next-1741091353.0",
|
|
35
|
+
"@opensumi/ide-file-service": "3.8.1-next-1741091353.0",
|
|
36
|
+
"@opensumi/ide-main-layout": "3.8.1-next-1741091353.0",
|
|
37
|
+
"@opensumi/ide-markers": "3.8.1-next-1741091353.0",
|
|
38
|
+
"@opensumi/ide-monaco": "3.8.1-next-1741091353.0",
|
|
39
|
+
"@opensumi/ide-overlay": "3.8.1-next-1741091353.0",
|
|
40
|
+
"@opensumi/ide-preferences": "3.8.1-next-1741091353.0",
|
|
41
|
+
"@opensumi/ide-search": "3.8.1-next-1741091353.0",
|
|
42
|
+
"@opensumi/ide-terminal-next": "3.8.1-next-1741091353.0",
|
|
43
|
+
"@opensumi/ide-theme": "3.8.1-next-1741091353.0",
|
|
44
|
+
"@opensumi/ide-utils": "3.8.1-next-1741091353.0",
|
|
45
|
+
"@opensumi/ide-workspace": "3.8.1-next-1741091353.0",
|
|
47
46
|
"@xterm/xterm": "5.5.0",
|
|
48
47
|
"ai": "^4.1.45",
|
|
49
48
|
"ansi-regex": "^2.0.0",
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
"zod-to-json-schema": "^3.24.1"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
|
-
"@opensumi/ide-core-browser": "3.8.1-next-
|
|
60
|
+
"@opensumi/ide-core-browser": "3.8.1-next-1741091353.0"
|
|
62
61
|
},
|
|
63
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4134fdda0b299adad482b64b0dbabad013e36dc3"
|
|
64
63
|
}
|
|
@@ -14,12 +14,10 @@ import {
|
|
|
14
14
|
Domain,
|
|
15
15
|
IAIInlineChatService,
|
|
16
16
|
IEditorExtensionContribution,
|
|
17
|
-
IPreferenceSettingsService,
|
|
18
17
|
KeybindingContribution,
|
|
19
18
|
KeybindingRegistry,
|
|
20
19
|
KeybindingScope,
|
|
21
20
|
MonacoContribution,
|
|
22
|
-
PreferenceSchemaProvider,
|
|
23
21
|
PreferenceService,
|
|
24
22
|
SlotLocation,
|
|
25
23
|
SlotRendererContribution,
|
|
@@ -84,9 +82,6 @@ import {
|
|
|
84
82
|
IChatManagerService,
|
|
85
83
|
ISumiMCPServerBackend,
|
|
86
84
|
SumiMCPServerProxyServicePath,
|
|
87
|
-
anthropicModels,
|
|
88
|
-
deepSeekModels,
|
|
89
|
-
openAiNativeModels,
|
|
90
85
|
} from '../common';
|
|
91
86
|
import { MCPServerDescription } from '../common/mcp-server-manager';
|
|
92
87
|
|
|
@@ -214,12 +209,6 @@ export class AINativeBrowserContribution
|
|
|
214
209
|
@Autowired(CommandService)
|
|
215
210
|
private readonly commandService: CommandService;
|
|
216
211
|
|
|
217
|
-
@Autowired(PreferenceSchemaProvider)
|
|
218
|
-
private preferenceSchemaProvider: PreferenceSchemaProvider;
|
|
219
|
-
|
|
220
|
-
@Autowired(IPreferenceSettingsService)
|
|
221
|
-
private preferenceSettings: IPreferenceSettingsService;
|
|
222
|
-
|
|
223
212
|
@Autowired(PreferenceService)
|
|
224
213
|
private readonly preferenceService: PreferenceService;
|
|
225
214
|
|
|
@@ -378,46 +367,6 @@ export class AINativeBrowserContribution
|
|
|
378
367
|
if (externalServers.length > 0) {
|
|
379
368
|
this.sumiMCPServerBackendProxy.initExternalMCPServers(externalServers);
|
|
380
369
|
}
|
|
381
|
-
|
|
382
|
-
if (this.aiNativeConfigService.capabilities.supportsCustomLLMSettings) {
|
|
383
|
-
this.preferenceService.onSpecificPreferenceChange(AINativeSettingSectionsId.LLMModelSelection, (change) => {
|
|
384
|
-
const model = this.getModelByName(change.newValue);
|
|
385
|
-
const modelIds = model ? Object.keys(model) : [];
|
|
386
|
-
const defaultModelId = modelIds.length ? modelIds[0] : '';
|
|
387
|
-
const currentSchemas = this.preferenceSchemaProvider.getPreferenceProperty(AINativeSettingSectionsId.ModelID);
|
|
388
|
-
this.preferenceSchemaProvider.setSchema(
|
|
389
|
-
{
|
|
390
|
-
properties: {
|
|
391
|
-
[AINativeSettingSectionsId.ModelID]: {
|
|
392
|
-
...currentSchemas,
|
|
393
|
-
default: defaultModelId,
|
|
394
|
-
defaultValue: defaultModelId,
|
|
395
|
-
enum: modelIds.length ? modelIds : undefined,
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
true,
|
|
400
|
-
);
|
|
401
|
-
this.preferenceService.set(AINativeSettingSectionsId.ModelID, defaultModelId, change.scope);
|
|
402
|
-
this.preferenceSettings.setEnumLabels(
|
|
403
|
-
AINativeSettingSectionsId.ModelID,
|
|
404
|
-
modelIds.reduce((obj, item) => ({ ...obj, [item]: item }), {}),
|
|
405
|
-
);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
private getModelByName(modelName: string) {
|
|
412
|
-
switch (modelName) {
|
|
413
|
-
case 'deepseek':
|
|
414
|
-
return deepSeekModels;
|
|
415
|
-
case 'anthropic':
|
|
416
|
-
return anthropicModels;
|
|
417
|
-
case 'openai':
|
|
418
|
-
return openAiNativeModels;
|
|
419
|
-
default:
|
|
420
|
-
return undefined;
|
|
421
370
|
}
|
|
422
371
|
}
|
|
423
372
|
|
|
@@ -525,10 +474,6 @@ export class AINativeBrowserContribution
|
|
|
525
474
|
id: AINativeSettingSectionsId.LLMModelSelection,
|
|
526
475
|
localized: 'preference.ai.native.llm.model.selection',
|
|
527
476
|
},
|
|
528
|
-
{
|
|
529
|
-
id: AINativeSettingSectionsId.ModelID,
|
|
530
|
-
localized: 'preference.ai.native.llm.model.id',
|
|
531
|
-
},
|
|
532
477
|
{
|
|
533
478
|
id: AINativeSettingSectionsId.DeepseekApiKey,
|
|
534
479
|
localized: 'preference.ai.native.deepseek.apiKey',
|
|
@@ -604,7 +549,7 @@ export class AINativeBrowserContribution
|
|
|
604
549
|
id: INLINE_DIFF_MANAGER_WIDGET_ID,
|
|
605
550
|
component: InlineDiffManager,
|
|
606
551
|
displaysOnResource: (resource) => {
|
|
607
|
-
if (this.applyService.getUriPendingCodeBlock(resource.uri)) {
|
|
552
|
+
if (this.injector.hasInstance(BaseApplyService) && this.applyService.getUriPendingCodeBlock(resource.uri)) {
|
|
608
553
|
return true;
|
|
609
554
|
}
|
|
610
555
|
return false;
|
|
@@ -4,16 +4,15 @@ import { Autowired, Injectable } from '@opensumi/di';
|
|
|
4
4
|
import {
|
|
5
5
|
CancellationToken,
|
|
6
6
|
ChatFeatureRegistryToken,
|
|
7
|
+
ChatMessageRole,
|
|
7
8
|
ChatServiceToken,
|
|
8
9
|
Disposable,
|
|
9
10
|
Emitter,
|
|
10
|
-
IChatContent,
|
|
11
11
|
IChatProgress,
|
|
12
12
|
IDisposable,
|
|
13
13
|
ILogger,
|
|
14
14
|
toDisposable,
|
|
15
15
|
} from '@opensumi/ide-core-common';
|
|
16
|
-
import { ChatMessageRole } from '@opensumi/ide-core-common';
|
|
17
16
|
import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
18
17
|
|
|
19
18
|
import {
|
|
@@ -26,6 +25,8 @@ import {
|
|
|
26
25
|
IChatFollowup,
|
|
27
26
|
IChatMessageStructure,
|
|
28
27
|
} from '../../common';
|
|
28
|
+
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
29
|
+
import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
|
|
29
30
|
import { IChatFeatureRegistry } from '../types';
|
|
30
31
|
|
|
31
32
|
import { ChatService } from './chat.api.service';
|
|
@@ -36,6 +37,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
36
37
|
|
|
37
38
|
private defaultAgentId: string | undefined;
|
|
38
39
|
|
|
40
|
+
private initialUserMessageMap: Map<string, string> = new Map();
|
|
41
|
+
|
|
42
|
+
private shouldUpdateContext = false;
|
|
43
|
+
|
|
44
|
+
private contextVersion: number;
|
|
45
|
+
|
|
39
46
|
private readonly _onDidChangeAgents = new Emitter<void>();
|
|
40
47
|
readonly onDidChangeAgents = this._onDidChangeAgents.event;
|
|
41
48
|
|
|
@@ -45,6 +52,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
45
52
|
@Autowired(ILogger)
|
|
46
53
|
logger: ILogger;
|
|
47
54
|
|
|
55
|
+
@Autowired(LLMContextServiceToken)
|
|
56
|
+
protected readonly contextService: LLMContextService;
|
|
57
|
+
|
|
58
|
+
@Autowired(ChatAgentPromptProvider)
|
|
59
|
+
protected readonly promptProvider: ChatAgentPromptProvider;
|
|
60
|
+
|
|
48
61
|
@Autowired(ChatServiceToken)
|
|
49
62
|
private aiChatService: ChatService;
|
|
50
63
|
|
|
@@ -54,6 +67,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
54
67
|
constructor() {
|
|
55
68
|
super();
|
|
56
69
|
this.addDispose(this._onDidChangeAgents);
|
|
70
|
+
this.addDispose(this.contextService.onDidContextFilesChangeEvent((event) => {
|
|
71
|
+
if (event.version !== this.contextVersion) {
|
|
72
|
+
this.contextVersion = event.version;
|
|
73
|
+
this.shouldUpdateContext = true;
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
registerAgent(agent: IChatAgent): IDisposable {
|
|
@@ -120,17 +139,29 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
120
139
|
if (!data) {
|
|
121
140
|
throw new Error(`No agent with id ${id}`);
|
|
122
141
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
142
|
+
|
|
143
|
+
// 发送第一条消息时携带初始 context
|
|
144
|
+
if (!this.initialUserMessageMap.has(request.sessionId)) {
|
|
145
|
+
this.initialUserMessageMap.set(request.sessionId, request.message);
|
|
146
|
+
const rawMessage = request.message;
|
|
147
|
+
request.message = this.provideContextMessage(rawMessage);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (this.shouldUpdateContext) {
|
|
151
|
+
request.message = this.provideContextMessage(request.message);
|
|
152
|
+
this.shouldUpdateContext = false;
|
|
128
153
|
}
|
|
129
154
|
|
|
130
155
|
const result = await data.agent.invoke(request, progress, history, token);
|
|
131
156
|
return result;
|
|
132
157
|
}
|
|
133
158
|
|
|
159
|
+
private provideContextMessage(message: string) {
|
|
160
|
+
const context = this.contextService.serialize();
|
|
161
|
+
const fullMessage = this.promptProvider.provideContextPrompt(context, message);
|
|
162
|
+
return fullMessage;
|
|
163
|
+
}
|
|
164
|
+
|
|
134
165
|
populateChatInput(id: string, message: IChatMessageStructure) {
|
|
135
166
|
this.aiChatService.sendMessage({
|
|
136
167
|
...message,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
STORAGE_NAMESPACE,
|
|
11
11
|
StorageProvider,
|
|
12
12
|
debounce,
|
|
13
|
+
formatLocalize,
|
|
13
14
|
} from '@opensumi/ide-core-common';
|
|
14
15
|
import { ChatMessageRole, IChatMessage, IHistoryChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
15
16
|
|
|
@@ -34,6 +35,8 @@ interface ISessionModel {
|
|
|
34
35
|
}[];
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
const MAX_SESSION_COUNT = 20;
|
|
39
|
+
|
|
37
40
|
@Injectable()
|
|
38
41
|
export class ChatManagerService extends Disposable {
|
|
39
42
|
#sessionModels = this.registerDispose(new DisposableMap<string, ChatModel>());
|
|
@@ -100,6 +103,9 @@ export class ChatManagerService extends Disposable {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
startSession() {
|
|
106
|
+
if (this.#sessionModels.size >= MAX_SESSION_COUNT) {
|
|
107
|
+
throw new Error(formatLocalize('aiNative.chat.session.max', MAX_SESSION_COUNT.toString()));
|
|
108
|
+
}
|
|
103
109
|
const model = new ChatModel();
|
|
104
110
|
this.#sessionModels.set(model.sessionId, model);
|
|
105
111
|
this.listenSession(model);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
2
|
import {
|
|
3
3
|
Disposable,
|
|
4
4
|
Emitter,
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
IChatProgress,
|
|
9
9
|
IChatToolContent,
|
|
10
10
|
IChatTreeData,
|
|
11
|
-
ILogger,
|
|
12
|
-
memoize,
|
|
13
11
|
uuid,
|
|
14
12
|
} from '@opensumi/ide-core-common';
|
|
15
13
|
import { MarkdownString, isMarkdownString } from '@opensumi/monaco-editor-core/esm/vs/base/common/htmlContent';
|
|
@@ -274,13 +272,18 @@ export class ChatRequestModel implements IChatRequestModel {
|
|
|
274
272
|
export class ChatModel extends Disposable implements IChatModel {
|
|
275
273
|
private static requestIdPool = 0;
|
|
276
274
|
|
|
277
|
-
constructor(initParams?: {
|
|
275
|
+
constructor(initParams?: {
|
|
276
|
+
sessionId?: string;
|
|
277
|
+
history?: MsgHistoryManager;
|
|
278
|
+
requests?: ChatRequestModel[];
|
|
279
|
+
}) {
|
|
278
280
|
super();
|
|
279
281
|
this.#sessionId = initParams?.sessionId ?? uuid();
|
|
280
282
|
this.history = initParams?.history ?? new MsgHistoryManager();
|
|
281
283
|
if (initParams?.requests) {
|
|
282
284
|
this.#requests = new Map(initParams.requests.map((r) => [r.requestId, r]));
|
|
283
285
|
}
|
|
286
|
+
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
#sessionId: string;
|
|
@@ -300,9 +303,11 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
300
303
|
readonly history: MsgHistoryManager;
|
|
301
304
|
|
|
302
305
|
addRequest(message: IChatRequestMessage): ChatRequestModel {
|
|
306
|
+
const msg = message;
|
|
307
|
+
|
|
303
308
|
const requestId = `${this.sessionId}_request_${ChatModel.requestIdPool++}`;
|
|
304
|
-
const response = new ChatResponseModel(requestId, this,
|
|
305
|
-
const request = new ChatRequestModel(requestId, this,
|
|
309
|
+
const response = new ChatResponseModel(requestId, this, msg.agentId);
|
|
310
|
+
const request = new ChatRequestModel(requestId, this, msg, response);
|
|
306
311
|
|
|
307
312
|
this.#requests.set(requestId, request);
|
|
308
313
|
return request;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
IAIReporter,
|
|
13
13
|
IApplicationService,
|
|
14
14
|
IChatProgress,
|
|
15
|
-
|
|
15
|
+
getOperatingSystemName,
|
|
16
16
|
} from '@opensumi/ide-core-common';
|
|
17
17
|
import { AINativeSettingSectionsId } from '@opensumi/ide-core-common/lib/settings/ai-native';
|
|
18
18
|
import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
@@ -92,7 +92,7 @@ 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
|
|
95
|
+
`\n\n<user_info>\nThe user's OS is ${getOperatingSystemName()}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.\n</user_info>`,
|
|
96
96
|
},
|
|
97
97
|
invoke: async (
|
|
98
98
|
request: IChatAgentRequest,
|
|
@@ -115,21 +115,18 @@ export class ChatProxyService extends Disposable {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const model = this.preferenceService.get<string>(AINativeSettingSectionsId.LLMModelSelection);
|
|
118
|
-
const modelId = this.preferenceService.get<string>(AINativeSettingSectionsId.ModelID);
|
|
119
118
|
let apiKey: string = '';
|
|
120
119
|
let baseURL: string = '';
|
|
121
120
|
if (model === 'deepseek') {
|
|
122
121
|
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.DeepseekApiKey, '');
|
|
123
122
|
} else if (model === 'openai') {
|
|
124
123
|
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiApiKey, '');
|
|
125
|
-
} else if (model === 'anthropic') {
|
|
126
|
-
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.AnthropicApiKey, '');
|
|
127
|
-
} else {
|
|
128
|
-
// openai-compatible 为兜底
|
|
129
|
-
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiApiKey, '');
|
|
130
124
|
baseURL = this.preferenceService.get<string>(AINativeSettingSectionsId.OpenaiBaseURL, '');
|
|
125
|
+
} else {
|
|
126
|
+
apiKey = this.preferenceService.get<string>(AINativeSettingSectionsId.AnthropicApiKey, '');
|
|
131
127
|
}
|
|
132
128
|
const MAX_INPUT_TOKENS = 30720;
|
|
129
|
+
const agent = this.chatAgentService.getAgent(ChatProxyService.AGENT_ID);
|
|
133
130
|
const stream = await this.aiBackService.requestStream(
|
|
134
131
|
prompt,
|
|
135
132
|
{
|
|
@@ -139,8 +136,8 @@ export class ChatProxyService extends Disposable {
|
|
|
139
136
|
clientId: this.applicationService.clientId,
|
|
140
137
|
apiKey,
|
|
141
138
|
model,
|
|
142
|
-
modelId,
|
|
143
139
|
baseURL,
|
|
140
|
+
system: agent?.metadata.systemPrompt,
|
|
144
141
|
},
|
|
145
142
|
token,
|
|
146
143
|
);
|
|
@@ -279,7 +279,6 @@
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
|
|
283
282
|
.chat_tips_container {
|
|
284
283
|
display: flex;
|
|
285
284
|
align-items: center;
|
|
@@ -290,6 +289,6 @@
|
|
|
290
289
|
}
|
|
291
290
|
|
|
292
291
|
.chat_history {
|
|
293
|
-
width: calc(100% -
|
|
292
|
+
width: calc(100% - 40px);
|
|
294
293
|
color: var(--design-text-foreground);
|
|
295
294
|
}
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
AINativeConfigService,
|
|
6
6
|
CommandService,
|
|
7
7
|
getIcon,
|
|
8
|
-
useEventEffect,
|
|
9
8
|
useInjectable,
|
|
10
9
|
useUpdateOnEvent,
|
|
11
10
|
} from '@opensumi/ide-core-browser';
|
|
@@ -32,7 +31,7 @@ import {
|
|
|
32
31
|
uuid,
|
|
33
32
|
} from '@opensumi/ide-core-common';
|
|
34
33
|
import { IMainLayoutService } from '@opensumi/ide-main-layout';
|
|
35
|
-
import { IDialogService } from '@opensumi/ide-overlay';
|
|
34
|
+
import { IDialogService, IMessageService } from '@opensumi/ide-overlay';
|
|
36
35
|
|
|
37
36
|
import 'react-chat-elements/dist/main.css';
|
|
38
37
|
import {
|
|
@@ -42,8 +41,6 @@ import {
|
|
|
42
41
|
IChatMessageStructure,
|
|
43
42
|
TokenMCPServerProxyService,
|
|
44
43
|
} from '../../common';
|
|
45
|
-
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
46
|
-
import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
|
|
47
44
|
import { ChatContext } from '../components/ChatContext';
|
|
48
45
|
import { CodeBlockWrapperInput } from '../components/ChatEditor';
|
|
49
46
|
import ChatHistory, { IChatHistoryItem } from '../components/ChatHistory';
|
|
@@ -82,18 +79,12 @@ export const AIChatView = () => {
|
|
|
82
79
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
83
80
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
84
81
|
const chatRenderRegistry = useInjectable<ChatRenderRegistry>(ChatRenderRegistryToken);
|
|
85
|
-
const contextService = useInjectable<LLMContextService>(LLMContextServiceToken);
|
|
86
|
-
const promptProvider = useInjectable<ChatAgentPromptProvider>(ChatAgentPromptProvider);
|
|
87
|
-
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
88
82
|
|
|
89
83
|
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
|
|
90
84
|
const msgHistoryManager = aiChatService.sessionModel.history;
|
|
91
85
|
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
92
86
|
const autoScroll = React.useRef<boolean>(true);
|
|
93
87
|
const chatInputRef = React.useRef<{ setInputValue: (v: string) => void } | null>(null);
|
|
94
|
-
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
95
|
-
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
96
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
97
88
|
|
|
98
89
|
const [shortcutCommands, setShortcutCommands] = React.useState<ChatSlashCommandItemModel[]>([]);
|
|
99
90
|
|
|
@@ -115,8 +106,6 @@ export const AIChatView = () => {
|
|
|
115
106
|
const [defaultAgentId, setDefaultAgentId] = React.useState<string>('');
|
|
116
107
|
const [command, setCommand] = React.useState('');
|
|
117
108
|
const [theme, setTheme] = React.useState<string | null>(null);
|
|
118
|
-
const [mcpToolsCount, setMcpToolsCount] = React.useState<number>(0);
|
|
119
|
-
const [mcpServersCount, setMcpServersCount] = React.useState<number>(0);
|
|
120
109
|
|
|
121
110
|
React.useEffect(() => {
|
|
122
111
|
const featureSlashCommands = chatFeatureRegistry.getAllShortcutSlashCommand();
|
|
@@ -537,10 +526,7 @@ export const AIChatView = () => {
|
|
|
537
526
|
const { message, agentId, command, reportExtra } = value;
|
|
538
527
|
const { actionType, actionSource } = reportExtra || {};
|
|
539
528
|
|
|
540
|
-
const
|
|
541
|
-
const fullMessage = await promptProvider.provideContextPrompt(context, message);
|
|
542
|
-
|
|
543
|
-
const request = aiChatService.createRequest(fullMessage, agentId!, command);
|
|
529
|
+
const request = aiChatService.createRequest(message, agentId!, command);
|
|
544
530
|
if (!request) {
|
|
545
531
|
return;
|
|
546
532
|
}
|
|
@@ -689,32 +675,6 @@ export const AIChatView = () => {
|
|
|
689
675
|
};
|
|
690
676
|
}, [aiChatService.sessionModel]);
|
|
691
677
|
|
|
692
|
-
useEventEffect(
|
|
693
|
-
mcpServerProxyService.onChangeMCPServers,
|
|
694
|
-
() => {
|
|
695
|
-
mcpServerProxyService.getAllMCPTools().then((tools) => {
|
|
696
|
-
setMcpToolsCount(tools.length);
|
|
697
|
-
});
|
|
698
|
-
mcpServerProxyService.$getServers().then((servers) => {
|
|
699
|
-
setMcpServersCount(servers.length);
|
|
700
|
-
});
|
|
701
|
-
},
|
|
702
|
-
[mcpServerProxyService],
|
|
703
|
-
);
|
|
704
|
-
|
|
705
|
-
const handleShowMCPTools = React.useCallback(async () => {
|
|
706
|
-
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
707
|
-
dialogService.open({
|
|
708
|
-
message: <MCPToolsDialog tools={tools} />,
|
|
709
|
-
type: MessageType.Empty,
|
|
710
|
-
buttons: ['关闭'],
|
|
711
|
-
});
|
|
712
|
-
}, [mcpServerProxyService, dialogService]);
|
|
713
|
-
|
|
714
|
-
const handleShowMCPConfig = React.useCallback(() => {
|
|
715
|
-
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
716
|
-
}, [commandService]);
|
|
717
|
-
|
|
718
678
|
return (
|
|
719
679
|
<div id={styles.ai_chat_view}>
|
|
720
680
|
<div className={styles.header_container}>
|
|
@@ -754,18 +714,6 @@ export const AIChatView = () => {
|
|
|
754
714
|
</Popover>
|
|
755
715
|
))}
|
|
756
716
|
</div>
|
|
757
|
-
<div className={styles.header_operate_right}>
|
|
758
|
-
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
759
|
-
<>
|
|
760
|
-
<div className={styles.tag} onClick={handleShowMCPConfig}>
|
|
761
|
-
{`MCP Servers: ${mcpServersCount}`}
|
|
762
|
-
</div>
|
|
763
|
-
<div className={styles.tag} onClick={handleShowMCPTools}>
|
|
764
|
-
{`MCP Tools: ${mcpToolsCount}`}
|
|
765
|
-
</div>
|
|
766
|
-
</>
|
|
767
|
-
)}
|
|
768
|
-
</div>
|
|
769
717
|
</div>
|
|
770
718
|
<ChatInputWrapperRender
|
|
771
719
|
onSend={(value, agentId, command) =>
|
|
@@ -808,11 +756,18 @@ export function DefaultChatViewHeader({
|
|
|
808
756
|
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
809
757
|
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
810
758
|
const aiChatService = useInjectable<ChatInternalService>(IChatInternalService);
|
|
759
|
+
const messageService = useInjectable<IMessageService>(IMessageService);
|
|
760
|
+
const commandService = useInjectable<CommandService>(CommandService);
|
|
761
|
+
|
|
811
762
|
const [historyList, setHistoryList] = React.useState<IChatHistoryItem[]>([]);
|
|
812
763
|
const [currentTitle, setCurrentTitle] = React.useState<string>('');
|
|
813
764
|
const handleNewChat = React.useCallback(() => {
|
|
814
765
|
if (aiChatService.sessionModel.history.getMessages().length > 0) {
|
|
815
|
-
|
|
766
|
+
try {
|
|
767
|
+
aiChatService.createSessionModel();
|
|
768
|
+
} catch (error) {
|
|
769
|
+
messageService.error(error.message);
|
|
770
|
+
}
|
|
816
771
|
}
|
|
817
772
|
}, [aiChatService]);
|
|
818
773
|
const handleHistoryItemSelect = React.useCallback(
|
|
@@ -828,6 +783,10 @@ export function DefaultChatViewHeader({
|
|
|
828
783
|
[aiChatService],
|
|
829
784
|
);
|
|
830
785
|
|
|
786
|
+
const handleShowMCPConfig = React.useCallback(() => {
|
|
787
|
+
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
788
|
+
}, [commandService]);
|
|
789
|
+
|
|
831
790
|
const handleShowMCPTools = React.useCallback(async () => {
|
|
832
791
|
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
833
792
|
dialogService.open({
|
|
@@ -916,23 +875,6 @@ export function DefaultChatViewHeader({
|
|
|
916
875
|
ariaLabel={localize('aiNative.operate.clear.title')}
|
|
917
876
|
/>
|
|
918
877
|
</Popover>
|
|
919
|
-
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
920
|
-
<Popover
|
|
921
|
-
overlayClassName={styles.popover_icon}
|
|
922
|
-
id={'ai-chat-header-tools'}
|
|
923
|
-
position={PopoverPosition.left}
|
|
924
|
-
title={localize('aiNative.operate.tools.title')}
|
|
925
|
-
>
|
|
926
|
-
<EnhanceIcon
|
|
927
|
-
wrapperClassName={styles.action_btn}
|
|
928
|
-
className={getIcon('menubar-tool')}
|
|
929
|
-
onClick={handleShowMCPTools}
|
|
930
|
-
tabIndex={0}
|
|
931
|
-
role='button'
|
|
932
|
-
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
933
|
-
/>
|
|
934
|
-
</Popover>
|
|
935
|
-
)}
|
|
936
878
|
<Popover
|
|
937
879
|
overlayClassName={styles.popover_icon}
|
|
938
880
|
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(files);
|
|
42
|
+
updateAddedFiles([...files.attached]);
|
|
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, true);
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
63
63
|
const onDidClickFile = useCallback((uri: URI) => {
|