@opensumi/ide-ai-native 3.8.3-next-1741848368.0 → 3.8.3-next-1741917543.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/chat/chat-agent.service.d.ts +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +7 -7
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +31 -69
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/{chat-context/context-selector.d.ts → ChatContext/ContextSelector.d.ts} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/{chat-context/context-selector.js → ChatContext/ContextSelector.js} +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/{chat-context → ChatContext}/index.js +2 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatEditor.d.ts +2 -11
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +6 -66
- 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 +15 -15
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatThinking.d.ts +1 -1
- package/lib/browser/components/ChatThinking.d.ts.map +1 -1
- package/lib/browser/components/ChatThinking.js +2 -8
- package/lib/browser/components/ChatThinking.js.map +1 -1
- package/lib/browser/components/change-list.module.less +0 -2
- package/lib/browser/components/chat-history.module.less +16 -33
- package/lib/browser/components/components.module.less +2 -32
- package/lib/browser/context/llm-context.service.d.ts +2 -10
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +2 -71
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +9 -2
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/common/llm-context.d.ts +1 -15
- 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 +2 -12
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +30 -95
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +1 -9
- package/lib/common/utils.js.map +1 -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/package.json +23 -23
- package/src/browser/chat/chat-agent.service.ts +7 -7
- package/src/browser/chat/chat.view.tsx +24 -81
- package/src/browser/components/{chat-context → ChatContext}/index.tsx +1 -1
- package/src/browser/components/ChatEditor.tsx +9 -126
- package/src/browser/components/ChatHistory.tsx +30 -16
- package/src/browser/components/ChatThinking.tsx +4 -10
- package/src/browser/components/change-list.module.less +0 -2
- package/src/browser/components/chat-history.module.less +16 -33
- package/src/browser/components/components.module.less +2 -32
- package/src/browser/context/llm-context.service.ts +3 -81
- package/src/browser/mcp/base-apply.service.ts +9 -2
- package/src/common/llm-context.ts +1 -16
- package/src/common/prompts/context-prompt-provider.ts +36 -130
- package/src/common/utils.ts +0 -8
- package/src/node/mcp-server.sse.ts +2 -1
- package/lib/browser/components/ChatMentionInput.d.ts +0 -25
- package/lib/browser/components/ChatMentionInput.d.ts.map +0 -1
- package/lib/browser/components/ChatMentionInput.js +0 -229
- package/lib/browser/components/ChatMentionInput.js.map +0 -1
- package/lib/browser/components/chat-context/context-selector.d.ts.map +0 -1
- package/lib/browser/components/chat-context/context-selector.js.map +0 -1
- package/lib/browser/components/chat-context/index.d.ts.map +0 -1
- package/lib/browser/components/chat-context/index.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.d.ts +0 -5
- package/lib/browser/components/mention-input/mention-input.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-input.js +0 -763
- package/lib/browser/components/mention-input/mention-input.js.map +0 -1
- package/lib/browser/components/mention-input/mention-input.module.less +0 -333
- package/lib/browser/components/mention-input/mention-item.d.ts +0 -10
- package/lib/browser/components/mention-input/mention-item.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-item.js +0 -16
- package/lib/browser/components/mention-input/mention-item.js.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.d.ts +0 -15
- package/lib/browser/components/mention-input/mention-panel.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-panel.js +0 -49
- package/lib/browser/components/mention-input/mention-panel.js.map +0 -1
- package/lib/browser/components/mention-input/types.d.ts +0 -78
- package/lib/browser/components/mention-input/types.d.ts.map +0 -1
- package/lib/browser/components/mention-input/types.js +0 -16
- package/lib/browser/components/mention-input/types.js.map +0 -1
- package/src/browser/components/ChatMentionInput.tsx +0 -276
- package/src/browser/components/mention-input/mention-input.module.less +0 -333
- package/src/browser/components/mention-input/mention-input.tsx +0 -952
- package/src/browser/components/mention-input/mention-item.tsx +0 -24
- package/src/browser/components/mention-input/mention-panel.tsx +0 -89
- package/src/browser/components/mention-input/types.ts +0 -84
- /package/lib/browser/components/{chat-context → ChatContext}/index.d.ts +0 -0
- /package/lib/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
- /package/src/browser/components/{chat-context/context-selector.tsx → ChatContext/ContextSelector.tsx} +0 -0
- /package/src/browser/components/{chat-context → ChatContext}/style.module.less +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.sse.d.ts","sourceRoot":"","sources":["../../src/node/mcp-server.sse.ts"],"names":[],"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D,KAAK,qBAAqB,KAAK,sCAAsC,KAAK,qBAAqB,KAAK,8BAA8B,KAAK,qCAAqC,KAAK,6BAA6B,KAAK;sBAAsD,KAAK;kBAAiD,KAAK;;IAlBjrjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5B"}
|
|
@@ -4,7 +4,6 @@ exports.SSEMCPServer = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// have to import with extension since the exports map is ./* -> ./dist/cjs/*
|
|
6
6
|
const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
|
|
7
|
-
const sse_js_1 = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
8
7
|
const eventsource_1 = require("eventsource");
|
|
9
8
|
const package_json_1 = tslib_1.__importDefault(require("../../package.json"));
|
|
10
9
|
global.EventSource = eventsource_1.EventSource;
|
|
@@ -27,7 +26,8 @@ class SSEMCPServer {
|
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.log(`Starting server "${this.name}" with serverHost: ${this.serverHost}`);
|
|
30
|
-
const
|
|
29
|
+
const SSEClientTransport = (await import('@modelcontextprotocol/sdk/client/sse.js')).SSEClientTransport;
|
|
30
|
+
const transport = new SSEClientTransport(new URL(this.serverHost));
|
|
31
31
|
transport.onerror = (error) => {
|
|
32
32
|
var _a;
|
|
33
33
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error('Transport Error:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.sse.js","sourceRoot":"","sources":["../../src/node/mcp-server.sse.ts"],"names":[],"mappings":";;;;AAAA,6EAA6E;AAC7E,wEAAmE;AACnE,
|
|
1
|
+
{"version":3,"file":"mcp-server.sse.js","sourceRoot":"","sources":["../../src/node/mcp-server.sse.ts"],"names":[],"mappings":";;;;AAAA,6EAA6E;AAC7E,wE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CAAC,MAAM,0CAAE,GAAG,CAAC,wBAAwB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,CAAC,8BAA8B,IAAI,CAAC,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,eAAe,IAAI,CAAC,IAAI,WAAW,CAAC,CAAC;QACtD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CACF;AA3FD,oCA2FC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.8.3-next-
|
|
3
|
+
"version": "3.8.3-next-1741917543.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -24,26 +24,26 @@
|
|
|
24
24
|
"@ai-sdk/openai": "^1.1.9",
|
|
25
25
|
"@ai-sdk/openai-compatible": "^0.1.11",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
27
|
-
"@opensumi/ide-addons": "3.8.3-next-
|
|
28
|
-
"@opensumi/ide-components": "3.8.3-next-
|
|
29
|
-
"@opensumi/ide-connection": "3.8.3-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.8.3-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.8.3-next-
|
|
32
|
-
"@opensumi/ide-debug": "3.8.3-next-
|
|
33
|
-
"@opensumi/ide-design": "3.8.3-next-
|
|
34
|
-
"@opensumi/ide-editor": "3.8.3-next-
|
|
35
|
-
"@opensumi/ide-file-search": "3.8.3-next-
|
|
36
|
-
"@opensumi/ide-file-service": "3.8.3-next-
|
|
37
|
-
"@opensumi/ide-main-layout": "3.8.3-next-
|
|
38
|
-
"@opensumi/ide-markers": "3.8.3-next-
|
|
39
|
-
"@opensumi/ide-monaco": "3.8.3-next-
|
|
40
|
-
"@opensumi/ide-overlay": "3.8.3-next-
|
|
41
|
-
"@opensumi/ide-preferences": "3.8.3-next-
|
|
42
|
-
"@opensumi/ide-search": "3.8.3-next-
|
|
43
|
-
"@opensumi/ide-terminal-next": "3.8.3-next-
|
|
44
|
-
"@opensumi/ide-theme": "3.8.3-next-
|
|
45
|
-
"@opensumi/ide-utils": "3.8.3-next-
|
|
46
|
-
"@opensumi/ide-workspace": "3.8.3-next-
|
|
27
|
+
"@opensumi/ide-addons": "3.8.3-next-1741917543.0",
|
|
28
|
+
"@opensumi/ide-components": "3.8.3-next-1741917543.0",
|
|
29
|
+
"@opensumi/ide-connection": "3.8.3-next-1741917543.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.8.3-next-1741917543.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.8.3-next-1741917543.0",
|
|
32
|
+
"@opensumi/ide-debug": "3.8.3-next-1741917543.0",
|
|
33
|
+
"@opensumi/ide-design": "3.8.3-next-1741917543.0",
|
|
34
|
+
"@opensumi/ide-editor": "3.8.3-next-1741917543.0",
|
|
35
|
+
"@opensumi/ide-file-search": "3.8.3-next-1741917543.0",
|
|
36
|
+
"@opensumi/ide-file-service": "3.8.3-next-1741917543.0",
|
|
37
|
+
"@opensumi/ide-main-layout": "3.8.3-next-1741917543.0",
|
|
38
|
+
"@opensumi/ide-markers": "3.8.3-next-1741917543.0",
|
|
39
|
+
"@opensumi/ide-monaco": "3.8.3-next-1741917543.0",
|
|
40
|
+
"@opensumi/ide-overlay": "3.8.3-next-1741917543.0",
|
|
41
|
+
"@opensumi/ide-preferences": "3.8.3-next-1741917543.0",
|
|
42
|
+
"@opensumi/ide-search": "3.8.3-next-1741917543.0",
|
|
43
|
+
"@opensumi/ide-terminal-next": "3.8.3-next-1741917543.0",
|
|
44
|
+
"@opensumi/ide-theme": "3.8.3-next-1741917543.0",
|
|
45
|
+
"@opensumi/ide-utils": "3.8.3-next-1741917543.0",
|
|
46
|
+
"@opensumi/ide-workspace": "3.8.3-next-1741917543.0",
|
|
47
47
|
"@xterm/xterm": "5.5.0",
|
|
48
48
|
"ai": "^4.1.45",
|
|
49
49
|
"ansi-regex": "^2.0.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"zod-to-json-schema": "^3.24.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@opensumi/ide-core-browser": "3.8.3-next-
|
|
63
|
+
"@opensumi/ide-core-browser": "3.8.3-next-1741917543.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "34335cefe1cc3f2c0e65bcf3dcb97ba5b2280300"
|
|
66
66
|
}
|
|
@@ -59,7 +59,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
59
59
|
private readonly aiReporter: IAIReporter;
|
|
60
60
|
|
|
61
61
|
@Autowired(LLMContextServiceToken)
|
|
62
|
-
protected readonly
|
|
62
|
+
protected readonly contextService: LLMContextService;
|
|
63
63
|
|
|
64
64
|
@Autowired(ChatAgentPromptProvider)
|
|
65
65
|
protected readonly promptProvider: ChatAgentPromptProvider;
|
|
@@ -74,7 +74,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
74
74
|
super();
|
|
75
75
|
this.addDispose(this._onDidChangeAgents);
|
|
76
76
|
this.addDispose(
|
|
77
|
-
this.
|
|
77
|
+
this.contextService.onDidContextFilesChangeEvent((event) => {
|
|
78
78
|
if (event.version !== this.contextVersion) {
|
|
79
79
|
this.contextVersion = event.version;
|
|
80
80
|
this.shouldUpdateContext = true;
|
|
@@ -152,9 +152,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
152
152
|
if (!this.initialUserMessageMap.has(request.sessionId)) {
|
|
153
153
|
this.initialUserMessageMap.set(request.sessionId, request.message);
|
|
154
154
|
const rawMessage = request.message;
|
|
155
|
-
request.message =
|
|
155
|
+
request.message = this.provideContextMessage(rawMessage, request.sessionId);
|
|
156
156
|
} else if (this.shouldUpdateContext || request.regenerate || history.length === 0) {
|
|
157
|
-
request.message =
|
|
157
|
+
request.message = this.provideContextMessage(request.message, request.sessionId);
|
|
158
158
|
this.shouldUpdateContext = false;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -162,9 +162,9 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
|
|
|
162
162
|
return result;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
private
|
|
166
|
-
const context =
|
|
167
|
-
const fullMessage =
|
|
165
|
+
private provideContextMessage(message: string, sessionId: string) {
|
|
166
|
+
const context = this.contextService.serialize();
|
|
167
|
+
const fullMessage = this.promptProvider.provideContextPrompt(context, message);
|
|
168
168
|
this.aiReporter.send({
|
|
169
169
|
msgType: AIServiceType.Chat,
|
|
170
170
|
actionType: ActionTypeEnum.ContextEnhance,
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MessageList } from 'react-chat-elements';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
AINativeConfigService,
|
|
6
|
-
AppConfig,
|
|
7
|
-
LabelService,
|
|
8
|
-
getIcon,
|
|
9
|
-
useInjectable,
|
|
10
|
-
useUpdateOnEvent,
|
|
11
|
-
} from '@opensumi/ide-core-browser';
|
|
4
|
+
import { AppConfig, getIcon, useInjectable, useUpdateOnEvent } from '@opensumi/ide-core-browser';
|
|
12
5
|
import { Popover, PopoverPosition } from '@opensumi/ide-core-browser/lib/components';
|
|
13
6
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
14
7
|
import {
|
|
@@ -21,7 +14,6 @@ import {
|
|
|
21
14
|
ChatMessageRole,
|
|
22
15
|
ChatRenderRegistryToken,
|
|
23
16
|
ChatServiceToken,
|
|
24
|
-
CommandService,
|
|
25
17
|
Disposable,
|
|
26
18
|
DisposableCollection,
|
|
27
19
|
IAIReporter,
|
|
@@ -36,19 +28,16 @@ import {
|
|
|
36
28
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
37
29
|
import { IMainLayoutService } from '@opensumi/ide-main-layout';
|
|
38
30
|
import { IMessageService } from '@opensumi/ide-overlay';
|
|
39
|
-
import 'react-chat-elements/dist/main.css';
|
|
40
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
41
31
|
|
|
32
|
+
import 'react-chat-elements/dist/main.css';
|
|
42
33
|
import { AI_CHAT_VIEW_ID, IChatAgentService, IChatInternalService, IChatMessageStructure } from '../../common';
|
|
43
|
-
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
44
34
|
import { CodeBlockData } from '../../common/types';
|
|
45
|
-
import { cleanAttachedTextWrapper } from '../../common/utils';
|
|
46
35
|
import { FileChange, FileListDisplay } from '../components/ChangeList';
|
|
36
|
+
import { ChatContext } from '../components/ChatContext';
|
|
47
37
|
import { CodeBlockWrapperInput } from '../components/ChatEditor';
|
|
48
38
|
import ChatHistory, { IChatHistoryItem } from '../components/ChatHistory';
|
|
49
39
|
import { ChatInput } from '../components/ChatInput';
|
|
50
40
|
import { ChatMarkdown } from '../components/ChatMarkdown';
|
|
51
|
-
import { ChatMentionInput } from '../components/ChatMentionInput';
|
|
52
41
|
import { ChatNotify, ChatReply } from '../components/ChatReply';
|
|
53
42
|
import { SlashCustomRender } from '../components/SlashCustomRender';
|
|
54
43
|
import { MessageData, createMessageByAI, createMessageByUser } from '../components/utils';
|
|
@@ -116,8 +105,6 @@ export const AIChatView = () => {
|
|
|
116
105
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
117
106
|
const chatRenderRegistry = useInjectable<ChatRenderRegistry>(ChatRenderRegistryToken);
|
|
118
107
|
const mcpServerRegistry = useInjectable<IMCPServerRegistry>(TokenMCPServerRegistry);
|
|
119
|
-
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
120
|
-
const llmContextService = useInjectable<LLMContextService>(LLMContextServiceToken);
|
|
121
108
|
|
|
122
109
|
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
|
|
123
110
|
const msgHistoryManager = aiChatService.sessionModel.history;
|
|
@@ -127,9 +114,6 @@ export const AIChatView = () => {
|
|
|
127
114
|
const editorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
|
|
128
115
|
const appConfig = useInjectable<AppConfig>(AppConfig);
|
|
129
116
|
const applyService = useInjectable<BaseApplyService>(BaseApplyService);
|
|
130
|
-
const labelService = useInjectable<LabelService>(LabelService);
|
|
131
|
-
const workspaceService = useInjectable<IWorkspaceService>(IWorkspaceService);
|
|
132
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
133
117
|
const [shortcutCommands, setShortcutCommands] = React.useState<ChatSlashCommandItemModel[]>([]);
|
|
134
118
|
|
|
135
119
|
const [changeList, setChangeList] = React.useState<FileChange[]>(getFileChanges(applyService.getSessionCodeBlocks()));
|
|
@@ -200,9 +184,6 @@ export const AIChatView = () => {
|
|
|
200
184
|
if (chatRenderRegistry.chatInputRender) {
|
|
201
185
|
return chatRenderRegistry.chatInputRender;
|
|
202
186
|
}
|
|
203
|
-
if (aiNativeConfigService.capabilities.supportsMCP) {
|
|
204
|
-
return ChatMentionInput;
|
|
205
|
-
}
|
|
206
187
|
return ChatInput;
|
|
207
188
|
}, [chatRenderRegistry.chatInputRender]);
|
|
208
189
|
|
|
@@ -281,7 +262,7 @@ export const AIChatView = () => {
|
|
|
281
262
|
if (loading) {
|
|
282
263
|
return;
|
|
283
264
|
}
|
|
284
|
-
await handleSend(message
|
|
265
|
+
await handleSend(message);
|
|
285
266
|
} else {
|
|
286
267
|
if (message.agentId) {
|
|
287
268
|
setAgentId(message.agentId);
|
|
@@ -368,9 +349,6 @@ export const AIChatView = () => {
|
|
|
368
349
|
text={message}
|
|
369
350
|
agentId={visibleAgentId}
|
|
370
351
|
command={command}
|
|
371
|
-
labelService={labelService}
|
|
372
|
-
workspaceService={workspaceService}
|
|
373
|
-
commandService={commandService}
|
|
374
352
|
/>
|
|
375
353
|
),
|
|
376
354
|
},
|
|
@@ -476,15 +454,7 @@ export const AIChatView = () => {
|
|
|
476
454
|
text: ChatUserRoleRender ? (
|
|
477
455
|
<ChatUserRoleRender content={message} agentId={visibleAgentId} command={command} />
|
|
478
456
|
) : (
|
|
479
|
-
<CodeBlockWrapperInput
|
|
480
|
-
labelService={labelService}
|
|
481
|
-
relationId={relationId}
|
|
482
|
-
text={message}
|
|
483
|
-
agentId={visibleAgentId}
|
|
484
|
-
command={command}
|
|
485
|
-
workspaceService={workspaceService}
|
|
486
|
-
commandService={commandService}
|
|
487
|
-
/>
|
|
457
|
+
<CodeBlockWrapperInput relationId={relationId} text={message} agentId={visibleAgentId} command={command} />
|
|
488
458
|
),
|
|
489
459
|
},
|
|
490
460
|
styles.chat_message_code,
|
|
@@ -664,50 +634,15 @@ export const AIChatView = () => {
|
|
|
664
634
|
msgId,
|
|
665
635
|
});
|
|
666
636
|
},
|
|
667
|
-
[chatRenderRegistry, chatRenderRegistry.chatUserRoleRender, msgHistoryManager, scrollToBottom
|
|
637
|
+
[chatRenderRegistry, chatRenderRegistry.chatUserRoleRender, msgHistoryManager, scrollToBottom],
|
|
668
638
|
);
|
|
669
639
|
|
|
670
640
|
const handleSend = React.useCallback(
|
|
671
|
-
async (
|
|
672
|
-
const reportExtra =
|
|
673
|
-
actionSource: ActionSourceEnum.Chat,
|
|
674
|
-
actionType: ActionTypeEnum.Send,
|
|
675
|
-
};
|
|
676
|
-
agentId = agentId ? agentId : ChatProxyService.AGENT_ID;
|
|
677
|
-
// 提取并替换 {{@file:xxx}} 中的文件内容
|
|
678
|
-
let processedContent = message;
|
|
679
|
-
const filePattern = /\{\{@file:(.*?)\}\}/g;
|
|
680
|
-
const fileMatches = message.match(filePattern);
|
|
681
|
-
let isCleanContext = false;
|
|
682
|
-
if (fileMatches) {
|
|
683
|
-
for (const match of fileMatches) {
|
|
684
|
-
const filePath = match.replace(/\{\{@file:(.*?)\}\}/, '$1');
|
|
685
|
-
if (filePath && !isCleanContext) {
|
|
686
|
-
isCleanContext = true;
|
|
687
|
-
llmContextService.cleanFileContext();
|
|
688
|
-
}
|
|
689
|
-
const fileUri = new URI(filePath);
|
|
690
|
-
llmContextService.addFileToContext(fileUri, undefined, true);
|
|
691
|
-
const relativePath = (await workspaceService.asRelativePath(fileUri))?.path || fileUri.displayName;
|
|
692
|
-
// 获取文件内容
|
|
693
|
-
// 替换占位符,后续支持自定义渲染时可替换为自定义渲染标签
|
|
694
|
-
processedContent = processedContent.replace(match, `\`<attached_file>${relativePath}\``);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
641
|
+
async (value: IChatMessageStructure) => {
|
|
642
|
+
const { message, command, reportExtra } = value;
|
|
697
643
|
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
if (folderMatches) {
|
|
701
|
-
for (const match of folderMatches) {
|
|
702
|
-
const folderPath = match.replace(/\{\{@folder:(.*?)\}\}/, '$1');
|
|
703
|
-
const folderUri = new URI(folderPath);
|
|
704
|
-
llmContextService.addFolderToContext(folderUri);
|
|
705
|
-
const relativePath = (await workspaceService.asRelativePath(folderUri))?.path || folderUri.displayName;
|
|
706
|
-
// 替换占位符,后续支持自定义渲染时可替换为自定义渲染标签
|
|
707
|
-
processedContent = processedContent.replace(match, `\`<attached_folder>${relativePath}\``);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return handleAgentReply({ message: processedContent, agentId, command, reportExtra });
|
|
644
|
+
const agentId = value.agentId ? value.agentId : ChatProxyService.AGENT_ID;
|
|
645
|
+
return handleAgentReply({ message, agentId, command, reportExtra });
|
|
711
646
|
},
|
|
712
647
|
[handleAgentReply],
|
|
713
648
|
);
|
|
@@ -824,6 +759,7 @@ export const AIChatView = () => {
|
|
|
824
759
|
</div>
|
|
825
760
|
) : null}
|
|
826
761
|
<div className={styles.chat_input_wrap}>
|
|
762
|
+
<ChatContext />
|
|
827
763
|
<div className={styles.header_operate}>
|
|
828
764
|
<div className={styles.header_operate_left}>
|
|
829
765
|
{shortcutCommands.map((command) => (
|
|
@@ -854,7 +790,17 @@ export const AIChatView = () => {
|
|
|
854
790
|
/>
|
|
855
791
|
)}
|
|
856
792
|
<ChatInputWrapperRender
|
|
857
|
-
onSend={
|
|
793
|
+
onSend={(value, agentId, command) =>
|
|
794
|
+
handleSend({
|
|
795
|
+
message: value,
|
|
796
|
+
agentId,
|
|
797
|
+
command,
|
|
798
|
+
reportExtra: {
|
|
799
|
+
actionSource: ActionSourceEnum.Chat,
|
|
800
|
+
actionType: ActionTypeEnum.Send,
|
|
801
|
+
},
|
|
802
|
+
})
|
|
803
|
+
}
|
|
858
804
|
disabled={loading}
|
|
859
805
|
enableOptions={true}
|
|
860
806
|
theme={theme}
|
|
@@ -911,15 +857,12 @@ export function DefaultChatViewHeader({
|
|
|
911
857
|
const getHistoryList = () => {
|
|
912
858
|
const currentMessages = aiChatService.sessionModel.history.getMessages();
|
|
913
859
|
const latestUserMessage = currentMessages.findLast((m) => m.role === ChatMessageRole.User);
|
|
914
|
-
setCurrentTitle(
|
|
915
|
-
latestUserMessage ? cleanAttachedTextWrapper(latestUserMessage.content).slice(0, MAX_TITLE_LENGTH) : '',
|
|
916
|
-
);
|
|
860
|
+
setCurrentTitle(latestUserMessage ? latestUserMessage.content.slice(0, MAX_TITLE_LENGTH) : '');
|
|
917
861
|
setHistoryList(
|
|
918
862
|
aiChatService.getSessions().map((session) => {
|
|
919
863
|
const history = session.history;
|
|
920
864
|
const messages = history.getMessages();
|
|
921
|
-
const title =
|
|
922
|
-
messages.length > 0 ? cleanAttachedTextWrapper(messages[0].content).slice(0, MAX_TITLE_LENGTH) : '';
|
|
865
|
+
const title = messages.length > 0 ? messages[0].content.slice(0, MAX_TITLE_LENGTH) : '';
|
|
923
866
|
const updatedAt = messages.length > 0 ? messages[messages.length - 1].replyStartTime || 0 : 0;
|
|
924
867
|
// const loading = session.requests[session.requests.length - 1]?.response.isComplete;
|
|
925
868
|
return {
|
|
@@ -15,7 +15,7 @@ import { WorkbenchEditorService } from '@opensumi/ide-editor/lib/browser/types';
|
|
|
15
15
|
|
|
16
16
|
import { FileContext, LLMContextService, LLMContextServiceToken } from '../../../common/llm-context';
|
|
17
17
|
|
|
18
|
-
import { ContextSelector } from './
|
|
18
|
+
import { ContextSelector } from './ContextSelector';
|
|
19
19
|
import styles from './style.module.less';
|
|
20
20
|
|
|
21
21
|
const getCollapsedHeight = () => ({ height: 0, opacity: 0 });
|
|
@@ -2,24 +2,14 @@ import capitalize from 'lodash/capitalize';
|
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import Highlight from 'react-highlight';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
FILE_COMMANDS,
|
|
8
|
-
IClipboardService,
|
|
9
|
-
LabelService,
|
|
10
|
-
getIcon,
|
|
11
|
-
useInjectable,
|
|
12
|
-
uuid,
|
|
13
|
-
} from '@opensumi/ide-core-browser';
|
|
14
|
-
import { Icon, Popover } from '@opensumi/ide-core-browser/lib/components';
|
|
5
|
+
import { IClipboardService, getIcon, useInjectable, uuid } from '@opensumi/ide-core-browser';
|
|
6
|
+
import { Popover } from '@opensumi/ide-core-browser/lib/components';
|
|
15
7
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
16
8
|
import {
|
|
17
9
|
ActionSourceEnum,
|
|
18
10
|
ActionTypeEnum,
|
|
19
11
|
ChatFeatureRegistryToken,
|
|
20
|
-
CommandService,
|
|
21
12
|
IAIReporter,
|
|
22
|
-
URI,
|
|
23
13
|
localize,
|
|
24
14
|
runWhenIdle,
|
|
25
15
|
} from '@opensumi/ide-core-common';
|
|
@@ -32,9 +22,6 @@ import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
|
32
22
|
|
|
33
23
|
import styles from './components.module.less';
|
|
34
24
|
import { highLightLanguageSupport } from './highLight';
|
|
35
|
-
import { MentionType } from './mention-input/types';
|
|
36
|
-
|
|
37
|
-
import type { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
38
25
|
|
|
39
26
|
import './highlightTheme.less';
|
|
40
27
|
|
|
@@ -152,56 +139,16 @@ const CodeBlock = ({
|
|
|
152
139
|
renderText,
|
|
153
140
|
agentId = '',
|
|
154
141
|
command = '',
|
|
155
|
-
labelService,
|
|
156
|
-
commandService,
|
|
157
|
-
workspaceService,
|
|
158
142
|
}: {
|
|
159
143
|
content?: string;
|
|
160
144
|
relationId: string;
|
|
161
145
|
renderText?: (t: string) => React.ReactNode;
|
|
162
146
|
agentId?: string;
|
|
163
147
|
command?: string;
|
|
164
|
-
labelService?: LabelService;
|
|
165
|
-
commandService?: CommandService;
|
|
166
|
-
workspaceService?: IWorkspaceService;
|
|
167
148
|
}) => {
|
|
168
149
|
const rgInlineCode = /`([^`]+)`/g;
|
|
169
150
|
const rgBlockCode = /```([^]+?)```/g;
|
|
170
151
|
const rgBlockCodeBefore = /```([^]+)?/g;
|
|
171
|
-
const rgAttachedFile = /<attached_file>(.*)/g;
|
|
172
|
-
const rgAttachedFolder = /<attached_folder>(.*)/g;
|
|
173
|
-
const handleAttachmentClick = useCallback(
|
|
174
|
-
async (text: string, type: MentionType) => {
|
|
175
|
-
const roots = await workspaceService?.roots;
|
|
176
|
-
let uri;
|
|
177
|
-
if (!roots) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
for (const root of roots) {
|
|
181
|
-
uri = new URI(root.uri).resolve(text);
|
|
182
|
-
try {
|
|
183
|
-
await commandService?.executeCommand(FILE_COMMANDS.LOCATION.id, uri);
|
|
184
|
-
if (type === MentionType.FILE) {
|
|
185
|
-
await commandService?.executeCommand(EDITOR_COMMANDS.OPEN_RESOURCE.id, uri);
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
} catch {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
[commandService, workspaceService],
|
|
194
|
-
);
|
|
195
|
-
const renderAttachment = (text: string, isFolder = false, key: string) => (
|
|
196
|
-
<span
|
|
197
|
-
className={styles.attachment}
|
|
198
|
-
key={key}
|
|
199
|
-
onClick={() => handleAttachmentClick(text, isFolder ? MentionType.FOLDER : MentionType.FILE)}
|
|
200
|
-
>
|
|
201
|
-
<Icon iconClass={isFolder ? getIcon('folder') : labelService?.getIcon(new URI(text || 'file'))} />
|
|
202
|
-
<span className={styles.attachment_text}>{text}</span>
|
|
203
|
-
</span>
|
|
204
|
-
);
|
|
205
152
|
|
|
206
153
|
const renderCodeEditor = (content: string) => {
|
|
207
154
|
const language = content.split('\n')[0].trim().toLowerCase();
|
|
@@ -246,47 +193,11 @@ const CodeBlock = ({
|
|
|
246
193
|
renderedContent.push(text);
|
|
247
194
|
}
|
|
248
195
|
} else {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
let lastIndex = 0;
|
|
255
|
-
const fragments: (string | React.ReactNode)[] = [];
|
|
256
|
-
|
|
257
|
-
// 处理文件标记
|
|
258
|
-
fileMatches.forEach((match, matchIndex) => {
|
|
259
|
-
if (match.index !== undefined) {
|
|
260
|
-
const spanText = processedText.slice(lastIndex, match.index);
|
|
261
|
-
if (spanText) {
|
|
262
|
-
fragments.push(<span key={`${index}-${matchIndex}`}>{spanText}</span>);
|
|
263
|
-
}
|
|
264
|
-
fragments.push(renderAttachment(match[1], false, `${index}-tag-${matchIndex}`));
|
|
265
|
-
lastIndex = match.index + match[0].length;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// 处理文件夹标记
|
|
270
|
-
folderMatches.forEach((match, matchIndex) => {
|
|
271
|
-
if (match.index !== undefined) {
|
|
272
|
-
const spanText = processedText.slice(lastIndex, match.index);
|
|
273
|
-
if (spanText) {
|
|
274
|
-
fragments.push(<span key={`${index}-${matchIndex}`}>{spanText}</span>);
|
|
275
|
-
}
|
|
276
|
-
fragments.push(renderAttachment(match[1], true, `${index}-tag-${matchIndex}`));
|
|
277
|
-
lastIndex = match.index + match[0].length;
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
fragments.push(processedText.slice(lastIndex));
|
|
282
|
-
renderedContent.push(...fragments);
|
|
283
|
-
} else {
|
|
284
|
-
renderedContent.push(
|
|
285
|
-
<span className={styles.code_inline} key={index}>
|
|
286
|
-
{text}
|
|
287
|
-
</span>,
|
|
288
|
-
);
|
|
289
|
-
}
|
|
196
|
+
renderedContent.push(
|
|
197
|
+
<span className={styles.code_inline} key={index}>
|
|
198
|
+
{text}
|
|
199
|
+
</span>,
|
|
200
|
+
);
|
|
290
201
|
}
|
|
291
202
|
});
|
|
292
203
|
} else {
|
|
@@ -305,29 +216,15 @@ export const CodeBlockWrapper = ({
|
|
|
305
216
|
renderText,
|
|
306
217
|
relationId,
|
|
307
218
|
agentId,
|
|
308
|
-
labelService,
|
|
309
|
-
commandService,
|
|
310
|
-
workspaceService,
|
|
311
219
|
}: {
|
|
312
220
|
text?: string;
|
|
313
221
|
relationId: string;
|
|
314
222
|
renderText?: (t: string) => React.ReactNode;
|
|
315
223
|
agentId?: string;
|
|
316
|
-
labelService?: LabelService;
|
|
317
|
-
commandService?: CommandService;
|
|
318
|
-
workspaceService?: IWorkspaceService;
|
|
319
224
|
}) => (
|
|
320
225
|
<div className={styles.ai_chat_code_wrapper}>
|
|
321
226
|
<div className={styles.render_text}>
|
|
322
|
-
<CodeBlock
|
|
323
|
-
content={text}
|
|
324
|
-
labelService={labelService}
|
|
325
|
-
renderText={renderText}
|
|
326
|
-
relationId={relationId}
|
|
327
|
-
agentId={agentId}
|
|
328
|
-
commandService={commandService}
|
|
329
|
-
workspaceService={workspaceService}
|
|
330
|
-
/>
|
|
227
|
+
<CodeBlock content={text} renderText={renderText} relationId={relationId} agentId={agentId} />
|
|
331
228
|
</div>
|
|
332
229
|
</div>
|
|
333
230
|
);
|
|
@@ -337,17 +234,11 @@ export const CodeBlockWrapperInput = ({
|
|
|
337
234
|
relationId,
|
|
338
235
|
agentId,
|
|
339
236
|
command,
|
|
340
|
-
labelService,
|
|
341
|
-
workspaceService,
|
|
342
|
-
commandService,
|
|
343
237
|
}: {
|
|
344
238
|
text: string;
|
|
345
239
|
relationId: string;
|
|
346
240
|
agentId?: string;
|
|
347
241
|
command?: string;
|
|
348
|
-
labelService?: LabelService;
|
|
349
|
-
workspaceService?: IWorkspaceService;
|
|
350
|
-
commandService?: CommandService;
|
|
351
242
|
}) => {
|
|
352
243
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
353
244
|
const [tag, setTag] = useState<string>('');
|
|
@@ -380,15 +271,7 @@ export const CodeBlockWrapperInput = ({
|
|
|
380
271
|
</div>
|
|
381
272
|
)}
|
|
382
273
|
{command && <div className={styles.tag}>/ {command}</div>}
|
|
383
|
-
<CodeBlock
|
|
384
|
-
content={txt}
|
|
385
|
-
labelService={labelService}
|
|
386
|
-
relationId={relationId}
|
|
387
|
-
agentId={agentId}
|
|
388
|
-
command={command}
|
|
389
|
-
workspaceService={workspaceService}
|
|
390
|
-
commandService={commandService}
|
|
391
|
-
/>
|
|
274
|
+
<CodeBlock content={txt} relationId={relationId} agentId={agentId} command={command} />
|
|
392
275
|
</div>
|
|
393
276
|
</div>
|
|
394
277
|
);
|