@opensumi/ide-ai-native 3.8.1-next-1740726474.0 → 3.8.1-next-1740735952.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 +1 -4
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +1 -20
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +0 -6
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +1 -31
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +0 -2
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +2 -8
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +0 -1
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +0 -3
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.module.less +2 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +38 -6
- 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/ChatHistory.d.ts +1 -0
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +14 -14
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +1 -25
- 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 +3 -2
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/{chat-history.module.less → chat-history.css} +1 -1
- package/lib/browser/components/components.module.less +0 -20
- package/lib/browser/context/llm-context.service.d.ts +5 -16
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +47 -78
- 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 +40 -31
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +167 -233
- 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 +41 -55
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/components/index.module.less +3 -23
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +0 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/editFile.js +1 -1
- package/lib/browser/mcp/tools/editFile.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +0 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts +1 -5
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +4 -4
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +0 -2
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +0 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +0 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +2 -12
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/types.d.ts +1 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff-widget.module.less +0 -12
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +0 -2
- 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 +4 -11
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/common/llm-context.d.ts +9 -12
- 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 +3 -4
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +22 -33
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +0 -17
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.map +1 -1
- package/lib/node/base-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +3 -54
- package/lib/node/base-language-model.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/ai-core.contribution.ts +1 -25
- package/src/browser/chat/chat-manager.service.ts +1 -29
- package/src/browser/chat/chat-model.ts +3 -18
- package/src/browser/chat/chat.internal.service.ts +0 -4
- package/src/browser/chat/chat.module.less +2 -1
- package/src/browser/chat/chat.view.tsx +70 -7
- package/src/browser/components/ChatContext/index.tsx +2 -2
- package/src/browser/components/ChatHistory.tsx +15 -21
- package/src/browser/components/ChatInput.tsx +4 -67
- package/src/browser/components/ChatToolRender.tsx +2 -1
- package/src/browser/components/{chat-history.module.less → chat-history.css} +1 -1
- package/src/browser/components/components.module.less +0 -20
- package/src/browser/context/llm-context.service.ts +54 -90
- package/src/browser/layout/layout.module.less +4 -4
- package/src/browser/mcp/base-apply.service.ts +213 -266
- package/src/browser/mcp/tools/components/EditFile.tsx +60 -82
- package/src/browser/mcp/tools/components/index.module.less +3 -23
- package/src/browser/mcp/tools/createNewFileWithText.ts +0 -1
- package/src/browser/mcp/tools/editFile.ts +2 -2
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -1
- package/src/browser/mcp/tools/handlers/EditFile.ts +4 -4
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -2
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -1
- package/src/browser/model/msg-history-manager.ts +2 -12
- package/src/browser/types.ts +1 -1
- package/src/browser/widget/inline-diff/inline-diff-widget.module.less +0 -12
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +4 -13
- package/src/common/llm-context.ts +4 -10
- package/src/common/prompts/context-prompt-provider.ts +29 -38
- package/src/common/types.ts +0 -20
- package/src/node/base-language-model.ts +1 -63
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts +0 -6
- package/lib/browser/widget/inline-diff/inline-diff-manager.d.ts.map +0 -1
- package/lib/browser/widget/inline-diff/inline-diff-manager.js +0 -27
- package/lib/browser/widget/inline-diff/inline-diff-manager.js.map +0 -1
- package/src/browser/widget/inline-diff/inline-diff-manager.tsx +0 -38
|
@@ -9,13 +9,10 @@ import {
|
|
|
9
9
|
IStorage,
|
|
10
10
|
STORAGE_NAMESPACE,
|
|
11
11
|
StorageProvider,
|
|
12
|
-
debounce,
|
|
13
12
|
} from '@opensumi/ide-core-common';
|
|
14
13
|
import { ChatMessageRole, IChatMessage, IHistoryChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
15
14
|
|
|
16
15
|
import { IChatAgentService, IChatFollowup, IChatRequestMessage, IChatResponseErrorDetails } from '../../common';
|
|
17
|
-
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
18
|
-
import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
|
|
19
16
|
import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
20
17
|
|
|
21
18
|
import { ChatModel, ChatRequestModel, ChatResponseModel, IChatProgressResponseContent } from './chat-model';
|
|
@@ -52,12 +49,6 @@ export class ChatManagerService extends Disposable {
|
|
|
52
49
|
@Autowired(StorageProvider)
|
|
53
50
|
private storageProvider: StorageProvider;
|
|
54
51
|
|
|
55
|
-
@Autowired(ChatAgentPromptProvider)
|
|
56
|
-
protected readonly promptProvider: ChatAgentPromptProvider;
|
|
57
|
-
|
|
58
|
-
@Autowired(LLMContextServiceToken)
|
|
59
|
-
protected readonly contextService: LLMContextService;
|
|
60
|
-
|
|
61
52
|
private _chatStorage: IStorage;
|
|
62
53
|
|
|
63
54
|
protected fromJSON(data: ISessionModel[]) {
|
|
@@ -98,7 +89,6 @@ export class ChatManagerService extends Disposable {
|
|
|
98
89
|
const savedSessions = this.fromJSON(sessionsModelData);
|
|
99
90
|
savedSessions.forEach((session) => {
|
|
100
91
|
this.#sessionModels.set(session.sessionId, session);
|
|
101
|
-
this.listenSession(session);
|
|
102
92
|
});
|
|
103
93
|
await this.storageInitEmitter.fireAndAwait();
|
|
104
94
|
}
|
|
@@ -108,20 +98,11 @@ export class ChatManagerService extends Disposable {
|
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
startSession() {
|
|
111
|
-
const model = new ChatModel(
|
|
112
|
-
provideContext: this.provideContextPrompt.bind(this),
|
|
113
|
-
});
|
|
101
|
+
const model = new ChatModel();
|
|
114
102
|
this.#sessionModels.set(model.sessionId, model);
|
|
115
|
-
this.listenSession(model);
|
|
116
103
|
return model;
|
|
117
104
|
}
|
|
118
105
|
|
|
119
|
-
private provideContextPrompt(message: string) {
|
|
120
|
-
const context = this.contextService.serialize();
|
|
121
|
-
const fullMessage = this.promptProvider.provideContextPrompt(context, message);
|
|
122
|
-
return fullMessage;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
106
|
getSession(sessionId: string): ChatModel | undefined {
|
|
126
107
|
return this.#sessionModels.get(sessionId);
|
|
127
108
|
}
|
|
@@ -215,15 +196,6 @@ export class ChatManagerService extends Disposable {
|
|
|
215
196
|
}
|
|
216
197
|
}
|
|
217
198
|
|
|
218
|
-
protected listenSession(session: ChatModel) {
|
|
219
|
-
this.addDispose(
|
|
220
|
-
session.history.onMessageAdditionalChange(() => {
|
|
221
|
-
this.saveSessions();
|
|
222
|
-
}),
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
@debounce(1000)
|
|
227
199
|
protected saveSessions() {
|
|
228
200
|
this._chatStorage.set('sessionModels', this.getSessions());
|
|
229
201
|
}
|
|
@@ -274,22 +274,13 @@ export class ChatRequestModel implements IChatRequestModel {
|
|
|
274
274
|
export class ChatModel extends Disposable implements IChatModel {
|
|
275
275
|
private static requestIdPool = 0;
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
constructor(initParams?: {
|
|
280
|
-
sessionId?: string;
|
|
281
|
-
history?: MsgHistoryManager;
|
|
282
|
-
requests?: ChatRequestModel[];
|
|
283
|
-
provideContext?: (msg: string) => string;
|
|
284
|
-
}) {
|
|
277
|
+
constructor(initParams?: { sessionId?: string; history?: MsgHistoryManager; requests?: ChatRequestModel[] }) {
|
|
285
278
|
super();
|
|
286
279
|
this.#sessionId = initParams?.sessionId ?? uuid();
|
|
287
280
|
this.history = initParams?.history ?? new MsgHistoryManager();
|
|
288
281
|
if (initParams?.requests) {
|
|
289
282
|
this.#requests = new Map(initParams.requests.map((r) => [r.requestId, r]));
|
|
290
283
|
}
|
|
291
|
-
|
|
292
|
-
this.provideContextPrompt = initParams?.provideContext;
|
|
293
284
|
}
|
|
294
285
|
|
|
295
286
|
#sessionId: string;
|
|
@@ -309,15 +300,9 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
309
300
|
readonly history: MsgHistoryManager;
|
|
310
301
|
|
|
311
302
|
addRequest(message: IChatRequestMessage): ChatRequestModel {
|
|
312
|
-
const msg = message;
|
|
313
|
-
// first msg
|
|
314
|
-
if (this.provideContextPrompt) {
|
|
315
|
-
msg.prompt = this.provideContextPrompt(msg.prompt);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
303
|
const requestId = `${this.sessionId}_request_${ChatModel.requestIdPool++}`;
|
|
319
|
-
const response = new ChatResponseModel(requestId, this,
|
|
320
|
-
const request = new ChatRequestModel(requestId, this,
|
|
304
|
+
const response = new ChatResponseModel(requestId, this, message.agentId);
|
|
305
|
+
const request = new ChatRequestModel(requestId, this, message, response);
|
|
321
306
|
|
|
322
307
|
this.#requests.set(requestId, request);
|
|
323
308
|
return request;
|
|
@@ -94,10 +94,6 @@ export class ChatInternalService extends Disposable {
|
|
|
94
94
|
return this.chatManagerService.getSessions();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
getSession(sessionId: string) {
|
|
98
|
-
return this.chatManagerService.getSession(sessionId);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
97
|
activateSession(sessionId: string) {
|
|
102
98
|
const targetSession = this.chatManagerService.getSession(sessionId);
|
|
103
99
|
if (!targetSession) {
|
|
@@ -279,6 +279,7 @@
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
|
|
282
283
|
.chat_tips_container {
|
|
283
284
|
display: flex;
|
|
284
285
|
align-items: center;
|
|
@@ -289,6 +290,6 @@
|
|
|
289
290
|
}
|
|
290
291
|
|
|
291
292
|
.chat_history {
|
|
292
|
-
width: calc(100% -
|
|
293
|
+
width: calc(100% - 60px);
|
|
293
294
|
color: var(--design-text-foreground);
|
|
294
295
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
AINativeConfigService,
|
|
6
6
|
CommandService,
|
|
7
7
|
getIcon,
|
|
8
|
+
useEventEffect,
|
|
8
9
|
useInjectable,
|
|
9
10
|
useUpdateOnEvent,
|
|
10
11
|
} from '@opensumi/ide-core-browser';
|
|
@@ -41,6 +42,8 @@ import {
|
|
|
41
42
|
IChatMessageStructure,
|
|
42
43
|
TokenMCPServerProxyService,
|
|
43
44
|
} from '../../common';
|
|
45
|
+
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
46
|
+
import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
|
|
44
47
|
import { ChatContext } from '../components/ChatContext';
|
|
45
48
|
import { CodeBlockWrapperInput } from '../components/ChatEditor';
|
|
46
49
|
import ChatHistory, { IChatHistoryItem } from '../components/ChatHistory';
|
|
@@ -79,11 +82,17 @@ export const AIChatView = () => {
|
|
|
79
82
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
80
83
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
81
84
|
const chatRenderRegistry = useInjectable<ChatRenderRegistry>(ChatRenderRegistryToken);
|
|
85
|
+
const contextService = useInjectable<LLMContextService>(LLMContextServiceToken);
|
|
86
|
+
const promptProvider = useInjectable<ChatAgentPromptProvider>(ChatAgentPromptProvider);
|
|
87
|
+
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
82
88
|
|
|
83
89
|
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
|
|
84
90
|
const msgHistoryManager = aiChatService.sessionModel.history;
|
|
85
91
|
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
86
92
|
const chatInputRef = React.useRef<{ setInputValue: (v: string) => void } | null>(null);
|
|
93
|
+
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
94
|
+
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
95
|
+
const commandService = useInjectable<CommandService>(CommandService);
|
|
87
96
|
|
|
88
97
|
const [shortcutCommands, setShortcutCommands] = React.useState<ChatSlashCommandItemModel[]>([]);
|
|
89
98
|
|
|
@@ -105,6 +114,8 @@ export const AIChatView = () => {
|
|
|
105
114
|
const [defaultAgentId, setDefaultAgentId] = React.useState<string>('');
|
|
106
115
|
const [command, setCommand] = React.useState('');
|
|
107
116
|
const [theme, setTheme] = React.useState<string | null>(null);
|
|
117
|
+
const [mcpToolsCount, setMcpToolsCount] = React.useState<number>(0);
|
|
118
|
+
const [mcpServersCount, setMcpServersCount] = React.useState<number>(0);
|
|
108
119
|
|
|
109
120
|
React.useEffect(() => {
|
|
110
121
|
const featureSlashCommands = chatFeatureRegistry.getAllShortcutSlashCommand();
|
|
@@ -504,7 +515,10 @@ export const AIChatView = () => {
|
|
|
504
515
|
const { message, agentId, command, reportExtra } = value;
|
|
505
516
|
const { actionType, actionSource } = reportExtra || {};
|
|
506
517
|
|
|
507
|
-
const
|
|
518
|
+
const context = contextService.serialize();
|
|
519
|
+
const fullMessage = await promptProvider.provideContextPrompt(context, message);
|
|
520
|
+
|
|
521
|
+
const request = aiChatService.createRequest(fullMessage, agentId!, command);
|
|
508
522
|
if (!request) {
|
|
509
523
|
return;
|
|
510
524
|
}
|
|
@@ -653,6 +667,32 @@ export const AIChatView = () => {
|
|
|
653
667
|
};
|
|
654
668
|
}, [aiChatService.sessionModel]);
|
|
655
669
|
|
|
670
|
+
useEventEffect(
|
|
671
|
+
mcpServerProxyService.onChangeMCPServers,
|
|
672
|
+
() => {
|
|
673
|
+
mcpServerProxyService.getAllMCPTools().then((tools) => {
|
|
674
|
+
setMcpToolsCount(tools.length);
|
|
675
|
+
});
|
|
676
|
+
mcpServerProxyService.$getServers().then((servers) => {
|
|
677
|
+
setMcpServersCount(servers.length);
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
[mcpServerProxyService],
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
const handleShowMCPTools = React.useCallback(async () => {
|
|
684
|
+
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
685
|
+
dialogService.open({
|
|
686
|
+
message: <MCPToolsDialog tools={tools} />,
|
|
687
|
+
type: MessageType.Empty,
|
|
688
|
+
buttons: ['关闭'],
|
|
689
|
+
});
|
|
690
|
+
}, [mcpServerProxyService, dialogService]);
|
|
691
|
+
|
|
692
|
+
const handleShowMCPConfig = React.useCallback(() => {
|
|
693
|
+
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
694
|
+
}, [commandService]);
|
|
695
|
+
|
|
656
696
|
return (
|
|
657
697
|
<div id={styles.ai_chat_view}>
|
|
658
698
|
<div className={styles.header_container}>
|
|
@@ -692,6 +732,18 @@ export const AIChatView = () => {
|
|
|
692
732
|
</Popover>
|
|
693
733
|
))}
|
|
694
734
|
</div>
|
|
735
|
+
<div className={styles.header_operate_right}>
|
|
736
|
+
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
737
|
+
<>
|
|
738
|
+
<div className={styles.tag} onClick={handleShowMCPConfig}>
|
|
739
|
+
{`MCP Servers: ${mcpServersCount}`}
|
|
740
|
+
</div>
|
|
741
|
+
<div className={styles.tag} onClick={handleShowMCPTools}>
|
|
742
|
+
{`MCP Tools: ${mcpToolsCount}`}
|
|
743
|
+
</div>
|
|
744
|
+
</>
|
|
745
|
+
)}
|
|
746
|
+
</div>
|
|
695
747
|
</div>
|
|
696
748
|
<ChatInputWrapperRender
|
|
697
749
|
onSend={(value, agentId, command) =>
|
|
@@ -734,8 +786,6 @@ export function DefaultChatViewHeader({
|
|
|
734
786
|
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
735
787
|
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
736
788
|
const aiChatService = useInjectable<ChatInternalService>(IChatInternalService);
|
|
737
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
738
|
-
|
|
739
789
|
const [historyList, setHistoryList] = React.useState<IChatHistoryItem[]>([]);
|
|
740
790
|
const [currentTitle, setCurrentTitle] = React.useState<string>('');
|
|
741
791
|
const handleNewChat = React.useCallback(() => {
|
|
@@ -756,10 +806,6 @@ export function DefaultChatViewHeader({
|
|
|
756
806
|
[aiChatService],
|
|
757
807
|
);
|
|
758
808
|
|
|
759
|
-
const handleShowMCPConfig = React.useCallback(() => {
|
|
760
|
-
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
761
|
-
}, [commandService]);
|
|
762
|
-
|
|
763
809
|
const handleShowMCPTools = React.useCallback(async () => {
|
|
764
810
|
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
765
811
|
dialogService.open({
|
|
@@ -848,6 +894,23 @@ export function DefaultChatViewHeader({
|
|
|
848
894
|
ariaLabel={localize('aiNative.operate.clear.title')}
|
|
849
895
|
/>
|
|
850
896
|
</Popover>
|
|
897
|
+
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
898
|
+
<Popover
|
|
899
|
+
overlayClassName={styles.popover_icon}
|
|
900
|
+
id={'ai-chat-header-tools'}
|
|
901
|
+
position={PopoverPosition.left}
|
|
902
|
+
title={localize('aiNative.operate.tools.title')}
|
|
903
|
+
>
|
|
904
|
+
<EnhanceIcon
|
|
905
|
+
wrapperClassName={styles.action_btn}
|
|
906
|
+
className={getIcon('menubar-tool')}
|
|
907
|
+
onClick={handleShowMCPTools}
|
|
908
|
+
tabIndex={0}
|
|
909
|
+
role='button'
|
|
910
|
+
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
911
|
+
/>
|
|
912
|
+
</Popover>
|
|
913
|
+
)}
|
|
851
914
|
<Popover
|
|
852
915
|
overlayClassName={styles.popover_icon}
|
|
853
916
|
id={'ai-chat-header-close'}
|
|
@@ -39,7 +39,7 @@ export const ChatContext = memo(() => {
|
|
|
39
39
|
50,
|
|
40
40
|
)((files) => {
|
|
41
41
|
if (files) {
|
|
42
|
-
updateAddedFiles(
|
|
42
|
+
updateAddedFiles(files);
|
|
43
43
|
}
|
|
44
44
|
}, contextService);
|
|
45
45
|
|
|
@@ -57,7 +57,7 @@ export const ChatContext = memo(() => {
|
|
|
57
57
|
}, []);
|
|
58
58
|
|
|
59
59
|
const onDidDeselect = useCallback((uri: URI) => {
|
|
60
|
-
contextService.removeFileFromContext(uri
|
|
60
|
+
contextService.removeFileFromContext(uri);
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
63
63
|
const onDidClickFile = useCallback((uri: URI) => {
|
|
@@ -2,11 +2,10 @@ import cls from 'classnames';
|
|
|
2
2
|
import React, { FC, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { Icon, Input, Loading, Popover, PopoverPosition, PopoverTriggerType, getIcon } from '@opensumi/ide-components';
|
|
5
|
+
import './chat-history.css';
|
|
5
6
|
import { localize } from '@opensumi/ide-core-browser';
|
|
6
7
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
7
8
|
|
|
8
|
-
import styles from './chat-history.module.less';
|
|
9
|
-
|
|
10
9
|
export interface IChatHistoryItem {
|
|
11
10
|
id: string;
|
|
12
11
|
title: string;
|
|
@@ -163,25 +162,22 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
163
162
|
(item: IChatHistoryItem) => (
|
|
164
163
|
<div
|
|
165
164
|
key={item.id}
|
|
166
|
-
className={cls(
|
|
167
|
-
styles['dm-chat-history-item'],
|
|
168
|
-
item.id === currentId ? styles['dm-chat-history-item-selected'] : '',
|
|
169
|
-
)}
|
|
165
|
+
className={cls('dm-chat-history-item', item.id === currentId ? 'dm-chat-history-item-selected' : '')}
|
|
170
166
|
onClick={() => handleHistoryItemSelect(item)}
|
|
171
167
|
>
|
|
172
|
-
<div className=
|
|
168
|
+
<div className='dm-chat-history-item-content'>
|
|
173
169
|
{item.loading ? (
|
|
174
170
|
<Loading />
|
|
175
171
|
) : (
|
|
176
172
|
<Icon icon='message' style={{ width: '16px', height: '16px', marginRight: 4 }} />
|
|
177
173
|
)}
|
|
178
174
|
{!historyTitleEditable?.[item.id] ? (
|
|
179
|
-
<span id={`dm-chat-history-item-title-${item.id}`} className=
|
|
175
|
+
<span id={`dm-chat-history-item-title-${item.id}`} className='dm-chat-history-item-title'>
|
|
180
176
|
{item.title}
|
|
181
177
|
</span>
|
|
182
178
|
) : (
|
|
183
179
|
<Input
|
|
184
|
-
className=
|
|
180
|
+
className='dm-chat-history-item-title'
|
|
185
181
|
defaultValue={item.title}
|
|
186
182
|
ref={inputRef}
|
|
187
183
|
onPressEnter={(e: any) => {
|
|
@@ -191,7 +187,7 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
191
187
|
/>
|
|
192
188
|
)}
|
|
193
189
|
</div>
|
|
194
|
-
<div className=
|
|
190
|
+
<div className='dm-chat-history-item-actions'>
|
|
195
191
|
{/* <EditOutlined
|
|
196
192
|
title={localize('aiNative.operate.chatHistory.edit')}
|
|
197
193
|
style={{ marginRight: 8 }}
|
|
@@ -202,7 +198,7 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
202
198
|
}}
|
|
203
199
|
/> */}
|
|
204
200
|
<EnhanceIcon
|
|
205
|
-
className={cls(
|
|
201
|
+
className={cls('dm-chat-history-item-actions-delete', getIcon('delete'))}
|
|
206
202
|
onClick={(e) => {
|
|
207
203
|
e.preventDefault();
|
|
208
204
|
e.stopPropagation();
|
|
@@ -241,10 +237,10 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
241
237
|
value={searchValue}
|
|
242
238
|
onChange={handleSearchChange}
|
|
243
239
|
/>
|
|
244
|
-
<div className=
|
|
240
|
+
<div className='dm-chat-history-list'>
|
|
245
241
|
{groupedHistoryList.map((group) => (
|
|
246
242
|
<div key={group.key} style={{ padding: '4px' }}>
|
|
247
|
-
<div className=
|
|
243
|
+
<div className='dm-chat-history-time'>{group.key}</div>
|
|
248
244
|
{group.items.map(renderHistoryItem)}
|
|
249
245
|
</div>
|
|
250
246
|
))}
|
|
@@ -257,11 +253,11 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
257
253
|
const getPopupContainer = useCallback((triggerNode: HTMLElement) => triggerNode.parentElement!, []);
|
|
258
254
|
|
|
259
255
|
return (
|
|
260
|
-
<div className={cls(
|
|
261
|
-
<div className=
|
|
256
|
+
<div className={cls('dm-chat-history-header', className)}>
|
|
257
|
+
<div className='dm-chat-history-header-title'>
|
|
262
258
|
<span>{title}</span>
|
|
263
259
|
</div>
|
|
264
|
-
<div className=
|
|
260
|
+
<div className='dm-chat-history-header-actions'>
|
|
265
261
|
<Popover
|
|
266
262
|
id='dm-chat-history-header-actions-history'
|
|
267
263
|
content={renderHistory()}
|
|
@@ -271,12 +267,10 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
271
267
|
getPopupContainer={getPopupContainer}
|
|
272
268
|
>
|
|
273
269
|
<div
|
|
274
|
-
className=
|
|
270
|
+
className='dm-chat-history-header-actions-history'
|
|
275
271
|
title={localize('aiNative.operate.chatHistory.title')}
|
|
276
272
|
>
|
|
277
|
-
<EnhanceIcon
|
|
278
|
-
className={cls(styles['dm-chat-history-header-actions-history'], 'codicon codicon-history')}
|
|
279
|
-
/>
|
|
273
|
+
<EnhanceIcon className={cls('dm-chat-history-header-actions-history', 'codicon codicon-history')} />
|
|
280
274
|
</div>
|
|
281
275
|
</Popover>
|
|
282
276
|
<Popover
|
|
@@ -285,7 +279,7 @@ const ChatHistory: FC<IChatHistoryProps> = memo(
|
|
|
285
279
|
title={localize('aiNative.operate.newChat.title')}
|
|
286
280
|
>
|
|
287
281
|
<EnhanceIcon
|
|
288
|
-
className={cls(
|
|
282
|
+
className={cls('dm-chat-history-header-actions-new', getIcon('plus'))}
|
|
289
283
|
onClick={handleNewChat}
|
|
290
284
|
/>
|
|
291
285
|
</Popover>
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import cls from 'classnames';
|
|
2
2
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useInjectable, useLatest } from '@opensumi/ide-core-browser';
|
|
5
5
|
import { Icon, Popover, PopoverPosition, getIcon } from '@opensumi/ide-core-browser/lib/components';
|
|
6
6
|
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
7
7
|
import { InteractiveInput } from '@opensumi/ide-core-browser/lib/components/ai-native/interactive-input/index';
|
|
8
|
-
import {
|
|
9
|
-
ChatAgentViewServiceToken,
|
|
10
|
-
ChatFeatureRegistryToken,
|
|
11
|
-
MessageType,
|
|
12
|
-
localize,
|
|
13
|
-
runWhenIdle,
|
|
14
|
-
} from '@opensumi/ide-core-common';
|
|
15
|
-
import { CommandService } from '@opensumi/ide-core-common/lib/command';
|
|
8
|
+
import { ChatAgentViewServiceToken, ChatFeatureRegistryToken, localize, runWhenIdle } from '@opensumi/ide-core-common';
|
|
16
9
|
import { MonacoCommandRegistry } from '@opensumi/ide-editor/lib/browser/monaco-contrib/command/command.service';
|
|
17
|
-
import { IDialogService } from '@opensumi/ide-overlay';
|
|
18
10
|
|
|
19
|
-
import { AT_SIGN_SYMBOL, IChatAgentService, SLASH_SYMBOL
|
|
11
|
+
import { AT_SIGN_SYMBOL, IChatAgentService, SLASH_SYMBOL } from '../../common';
|
|
20
12
|
import { ChatAgentViewService } from '../chat/chat-agent.view.service';
|
|
21
13
|
import { ChatSlashCommandItemModel } from '../chat/chat-model';
|
|
22
14
|
import { ChatProxyService } from '../chat/chat-proxy.service';
|
|
23
15
|
import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
24
|
-
import { OPEN_MCP_CONFIG_COMMAND } from '../mcp/config/mcp-config.commands';
|
|
25
|
-
import { MCPServerProxyService } from '../mcp/mcp-server-proxy.service';
|
|
26
|
-
import { MCPToolsDialog } from '../mcp/mcp-tools-dialog.view';
|
|
27
16
|
import { IChatSlashCommandItem } from '../types';
|
|
28
17
|
|
|
18
|
+
import { ChatContext } from './ChatContext';
|
|
29
19
|
import styles from './components.module.less';
|
|
30
20
|
|
|
31
21
|
const INSTRUCTION_BOTTOM = 8;
|
|
@@ -205,29 +195,12 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
205
195
|
const [isExpand, setIsExpand] = useState(false);
|
|
206
196
|
const [placeholder, setPlaceHolder] = useState(localize('aiNative.chat.input.placeholder.default'));
|
|
207
197
|
|
|
208
|
-
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
209
|
-
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
210
|
-
const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
|
|
211
198
|
const monacoCommandRegistry = useInjectable<MonacoCommandRegistry>(MonacoCommandRegistry);
|
|
212
199
|
const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
|
|
213
200
|
const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
|
|
214
|
-
const commandService = useInjectable<CommandService>(CommandService);
|
|
215
201
|
|
|
216
202
|
const currentAgentIdRef = useLatest(agentId);
|
|
217
203
|
|
|
218
|
-
const handleShowMCPConfig = React.useCallback(() => {
|
|
219
|
-
commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
|
|
220
|
-
}, [commandService]);
|
|
221
|
-
|
|
222
|
-
const handleShowMCPTools = React.useCallback(async () => {
|
|
223
|
-
const tools = await mcpServerProxyService.getAllMCPTools();
|
|
224
|
-
dialogService.open({
|
|
225
|
-
message: <MCPToolsDialog tools={tools} />,
|
|
226
|
-
type: MessageType.Empty,
|
|
227
|
-
buttons: ['关闭'],
|
|
228
|
-
});
|
|
229
|
-
}, [mcpServerProxyService, dialogService]);
|
|
230
|
-
|
|
231
204
|
useImperativeHandle(ref, () => ({
|
|
232
205
|
setInputValue: (v: string) => {
|
|
233
206
|
setValue(v);
|
|
@@ -489,42 +462,6 @@ export const ChatInput = React.forwardRef((props: IChatInputProps, ref) => {
|
|
|
489
462
|
height={inputHeight}
|
|
490
463
|
popoverPosition={PopoverPosition.left}
|
|
491
464
|
/>
|
|
492
|
-
<div className={styles.chat_input_footer}>
|
|
493
|
-
{aiNativeConfigService.capabilities.supportsMCP && (
|
|
494
|
-
<div className={styles.mcp_desc}>
|
|
495
|
-
<Popover
|
|
496
|
-
overlayClassName={styles.popover_icon}
|
|
497
|
-
id={'ai-chat-header-mcp-server'}
|
|
498
|
-
position={PopoverPosition.left}
|
|
499
|
-
title={'MCP Server'}
|
|
500
|
-
>
|
|
501
|
-
<EnhanceIcon
|
|
502
|
-
wrapperClassName={styles.action_btn}
|
|
503
|
-
className={'codicon codicon-server'}
|
|
504
|
-
onClick={handleShowMCPConfig}
|
|
505
|
-
tabIndex={0}
|
|
506
|
-
role='button'
|
|
507
|
-
ariaLabel={'MCP Server'}
|
|
508
|
-
/>
|
|
509
|
-
</Popover>
|
|
510
|
-
<Popover
|
|
511
|
-
overlayClassName={styles.popover_icon}
|
|
512
|
-
id={'ai-chat-header-tools'}
|
|
513
|
-
position={PopoverPosition.left}
|
|
514
|
-
title={localize('aiNative.operate.tools.title')}
|
|
515
|
-
>
|
|
516
|
-
<EnhanceIcon
|
|
517
|
-
wrapperClassName={styles.action_btn}
|
|
518
|
-
className={getIcon('menubar-tool')}
|
|
519
|
-
onClick={handleShowMCPTools}
|
|
520
|
-
tabIndex={0}
|
|
521
|
-
role='button'
|
|
522
|
-
ariaLabel={localize('aiNative.operate.tools.title')}
|
|
523
|
-
/>
|
|
524
|
-
</Popover>
|
|
525
|
-
</div>
|
|
526
|
-
)}
|
|
527
|
-
</div>
|
|
528
465
|
</div>
|
|
529
466
|
);
|
|
530
467
|
});
|
|
@@ -67,12 +67,13 @@ export const ChatToolRender = (props: { value: IChatToolContent['content']; mess
|
|
|
67
67
|
<div className={styles['chat-tool-render']}>
|
|
68
68
|
<div className={styles['tool-header']} onClick={toggleExpand}>
|
|
69
69
|
<div className={styles['tool-name']}>
|
|
70
|
-
<
|
|
70
|
+
<span className={cls(styles['expand-icon'], { [styles.expanded]: isExpanded })}>▶</span>
|
|
71
71
|
{label}
|
|
72
72
|
</div>
|
|
73
73
|
{value.state && (
|
|
74
74
|
<div className={styles['tool-state']}>
|
|
75
75
|
<span className={styles['state-icon']}>{stateInfo.icon}</span>
|
|
76
|
+
<span className={styles['state-label']}>{stateInfo.label}</span>
|
|
76
77
|
</div>
|
|
77
78
|
)}
|
|
78
79
|
</div>
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
.chat_input_container {
|
|
97
97
|
position: relative;
|
|
98
98
|
border-radius: 9px;
|
|
99
|
-
padding: 10px 0px 0px 0px;
|
|
100
99
|
border: 1px solid var(--kt-input-border);
|
|
101
100
|
background-color: var(--design-chatInput-background);
|
|
102
101
|
&.active {
|
|
@@ -506,22 +505,3 @@
|
|
|
506
505
|
}
|
|
507
506
|
}
|
|
508
507
|
}
|
|
509
|
-
|
|
510
|
-
.chat_input_footer {
|
|
511
|
-
padding: 0px 10px;
|
|
512
|
-
display: flex;
|
|
513
|
-
align-items: center;
|
|
514
|
-
font-size: 12px;
|
|
515
|
-
|
|
516
|
-
.model_selector {
|
|
517
|
-
display: flex;
|
|
518
|
-
font-size: 11px;
|
|
519
|
-
align-items: center;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
.mcp_desc {
|
|
523
|
-
padding: 5px 0px;
|
|
524
|
-
display: flex;
|
|
525
|
-
align-items: center;
|
|
526
|
-
}
|
|
527
|
-
}
|