@opensumi/ide-ai-native 3.7.2-next-1739859371.0 → 3.7.2-next-1739945875.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 +3 -0
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +68 -2
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +2 -2
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +16 -5
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +4 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +43 -0
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +29 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/ContextSelector.d.ts +12 -0
- package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/ContextSelector.js +113 -0
- package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
- package/lib/browser/components/ChatContext/index.d.ts +4 -0
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
- package/lib/browser/components/ChatContext/index.js +84 -0
- package/lib/browser/components/ChatContext/index.js.map +1 -0
- package/lib/browser/components/ChatContext/style.module.less +189 -0
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +25 -0
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +6 -0
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -0
- package/lib/browser/components/ChatToolRender.js +53 -0
- package/lib/browser/components/ChatToolRender.js.map +1 -0
- package/lib/browser/components/ChatToolRender.module.less +86 -0
- package/lib/browser/components/components.module.less +32 -31
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.contribution.d.ts +7 -0
- package/lib/browser/context/llm-context.contribution.d.ts.map +1 -0
- package/lib/browser/context/llm-context.contribution.js +21 -0
- package/lib/browser/context/llm-context.contribution.js.map +1 -0
- package/lib/browser/context/llm-context.service.d.ts +24 -0
- package/lib/browser/context/llm-context.service.d.ts.map +1 -0
- package/lib/browser/context/llm-context.service.js +136 -0
- package/lib/browser/context/llm-context.service.js.map +1 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +2 -2
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +4 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +7 -0
- package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts +11 -3
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +56 -3
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +25 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js +56 -0
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +16 -0
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js +53 -0
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts +8 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.d.ts.map +1 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js +16 -0
- package/lib/browser/mcp/mcp-tools-dialog.view.js.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +9 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js +83 -0
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts +9 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +1 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +92 -0
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +8 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js +49 -0
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts +10 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +119 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts +9 -0
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js +97 -0
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts +11 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +119 -0
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +8 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +50 -0
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts +8 -0
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +1 -0
- package/lib/browser/mcp/tools/getSelectedText.js +57 -0
- package/lib/browser/mcp/tools/getSelectedText.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts +21 -0
- package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js +112 -0
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +47 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js +147 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts +8 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -0
- package/lib/browser/mcp/tools/listDir.js +65 -0
- package/lib/browser/mcp/tools/listDir.js.map +1 -0
- package/lib/browser/mcp/tools/readFile.d.ts +8 -0
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/readFile.js +82 -0
- package/lib/browser/mcp/tools/readFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +79 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +8 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +1 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +84 -0
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts +18 -0
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js +96 -0
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -0
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +60 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +64 -3
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +5 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +1 -1
- package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
- package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
- package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
- package/lib/common/index.d.ts +9 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +37 -0
- package/lib/common/llm-context.d.ts.map +1 -0
- package/lib/common/llm-context.js +5 -0
- package/lib/common/llm-context.js.map +1 -0
- package/lib/common/mcp-server-manager.d.ts +40 -0
- package/lib/common/mcp-server-manager.d.ts.map +1 -0
- package/lib/common/mcp-server-manager.js +6 -0
- package/lib/common/mcp-server-manager.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +91 -0
- package/lib/common/tool-invocation-registry.d.ts.map +1 -0
- package/lib/common/tool-invocation-registry.js +90 -0
- package/lib/common/tool-invocation-registry.js.map +1 -0
- package/lib/common/types.d.ts +17 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +9 -0
- package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -0
- package/lib/node/anthropic/anthropic-language-model.js +26 -0
- package/lib/node/anthropic/anthropic-language-model.js.map +1 -0
- package/lib/node/base-language-model.d.ts +14 -0
- package/lib/node/base-language-model.d.ts.map +1 -0
- package/lib/node/base-language-model.js +136 -0
- package/lib/node/base-language-model.js.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts +9 -0
- package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -0
- package/lib/node/deepseek/deepseek-language-model.js +26 -0
- package/lib/node/deepseek/deepseek-language-model.js.map +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +19 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +91 -0
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -0
- package/lib/node/mcp/sumi-mcp-server.js +172 -0
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -0
- package/lib/node/mcp-server-manager-impl.d.ts +27 -0
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -0
- package/lib/node/mcp-server-manager-impl.js +127 -0
- package/lib/node/mcp-server-manager-impl.js.map +1 -0
- package/lib/node/mcp-server.d.ts +207 -0
- package/lib/node/mcp-server.d.ts.map +1 -0
- package/lib/node/mcp-server.js +91 -0
- package/lib/node/mcp-server.js.map +1 -0
- package/lib/node/openai/openai-language-model.d.ts +9 -0
- package/lib/node/openai/openai-language-model.d.ts.map +1 -0
- package/lib/node/openai/openai-language-model.js +29 -0
- package/lib/node/openai/openai-language-model.js.map +1 -0
- package/package.json +34 -22
- package/src/browser/ai-core.contribution.ts +77 -1
- package/src/browser/chat/chat-model.ts +24 -6
- package/src/browser/chat/chat-proxy.service.ts +42 -0
- package/src/browser/chat/chat.view.tsx +59 -6
- package/src/browser/components/ChatContext/ContextSelector.tsx +177 -0
- package/src/browser/components/ChatContext/index.tsx +135 -0
- package/src/browser/components/ChatContext/style.module.less +189 -0
- package/src/browser/components/ChatInput.tsx +1 -0
- package/src/browser/components/ChatReply.tsx +32 -0
- package/src/browser/components/ChatToolRender.module.less +86 -0
- package/src/browser/components/ChatToolRender.tsx +77 -0
- package/src/browser/components/components.module.less +32 -31
- package/src/browser/context/llm-context.contribution.ts +14 -0
- package/src/browser/context/llm-context.service.ts +156 -0
- package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +2 -3
- package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +11 -0
- package/src/browser/index.ts +68 -4
- package/src/browser/mcp/mcp-server-proxy.service.ts +53 -0
- package/src/browser/mcp/mcp-server.feature.registry.ts +54 -0
- package/src/browser/mcp/mcp-tools-dialog.module.less +44 -0
- package/src/browser/mcp/mcp-tools-dialog.view.tsx +24 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +83 -0
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +93 -0
- package/src/browser/mcp/tools/getCurrentFilePath.ts +49 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +123 -0
- package/src/browser/mcp/tools/getFileTextByPath.ts +97 -0
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +121 -0
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +50 -0
- package/src/browser/mcp/tools/getSelectedText.ts +57 -0
- package/src/browser/mcp/tools/handlers/ListDir.ts +117 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +174 -0
- package/src/browser/mcp/tools/listDir.ts +66 -0
- package/src/browser/mcp/tools/readFile.ts +82 -0
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +80 -0
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +91 -0
- package/src/browser/mcp/tools/runTerminalCmd.ts +107 -0
- package/src/browser/preferences/schema.ts +60 -0
- package/src/browser/types.ts +92 -3
- package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +1 -1
- package/src/browser/widget/inline-diff/inline-diff.controller.ts +1 -1
- package/src/browser/widget/inline-input/inline-input.controller.ts +1 -1
- package/src/common/index.ts +14 -0
- package/src/common/llm-context.ts +41 -0
- package/src/common/mcp-server-manager.ts +46 -0
- package/src/common/tool-invocation-registry.ts +170 -0
- package/src/common/types.ts +22 -0
- package/src/node/anthropic/anthropic-language-model.ts +25 -0
- package/src/node/base-language-model.ts +163 -0
- package/src/node/deepseek/deepseek-language-model.ts +25 -0
- package/src/node/index.ts +21 -0
- package/src/node/mcp/sumi-mcp-server.ts +197 -0
- package/src/node/mcp-server-manager-impl.ts +148 -0
- package/src/node/mcp-server.ts +126 -0
- package/src/node/openai/openai-language-model.ts +25 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Collapse, { Panel } from 'rc-collapse';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import 'rc-collapse/assets/index.css';
|
|
5
|
+
|
|
6
|
+
import { Icon } from '@opensumi/ide-components/lib/icon/icon';
|
|
7
|
+
import { Popover, getIcon } from '@opensumi/ide-core-browser/lib/components';
|
|
8
|
+
import { EnhanceIcon } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
9
|
+
import { useInjectable } from '@opensumi/ide-core-browser/lib/react-hooks/injectable-hooks';
|
|
10
|
+
import { AppConfig } from '@opensumi/ide-core-browser/lib/react-providers/config-provider';
|
|
11
|
+
import { LabelService } from '@opensumi/ide-core-browser/lib/services/label-service';
|
|
12
|
+
import { localize } from '@opensumi/ide-core-common/lib/localize';
|
|
13
|
+
import { Event, URI } from '@opensumi/ide-core-common/lib/utils';
|
|
14
|
+
import { WorkbenchEditorService } from '@opensumi/ide-editor/lib/browser/types';
|
|
15
|
+
|
|
16
|
+
import { FileContext, LLMContextService, LLMContextServiceToken } from '../../../common/llm-context';
|
|
17
|
+
|
|
18
|
+
import { ContextSelector } from './ContextSelector';
|
|
19
|
+
import styles from './style.module.less';
|
|
20
|
+
|
|
21
|
+
export const ChatContext = memo(() => {
|
|
22
|
+
const [addedFiles, updateAddedFiles] = useState<FileContext[]>([]);
|
|
23
|
+
const [contextOverlay, toggleContextOverlay] = useState(false);
|
|
24
|
+
|
|
25
|
+
const labelService = useInjectable<LabelService>(LabelService);
|
|
26
|
+
const appConfig = useInjectable<AppConfig>(AppConfig);
|
|
27
|
+
const workbenchEditorService = useInjectable<WorkbenchEditorService>(WorkbenchEditorService);
|
|
28
|
+
const contextService = useInjectable<LLMContextService>(LLMContextServiceToken);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const disposable = Event.debounce(
|
|
32
|
+
contextService.onDidContextFilesChangeEvent,
|
|
33
|
+
(_, e) => e!,
|
|
34
|
+
50,
|
|
35
|
+
)((files) => {
|
|
36
|
+
if (files) {
|
|
37
|
+
updateAddedFiles(files);
|
|
38
|
+
}
|
|
39
|
+
}, contextService);
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
disposable.dispose();
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
const openContextOverlay = useCallback(() => {
|
|
47
|
+
toggleContextOverlay(true);
|
|
48
|
+
}, [addedFiles]);
|
|
49
|
+
|
|
50
|
+
const onDidSelect = useCallback((uri: URI) => {
|
|
51
|
+
contextService.addFileToContext(uri, undefined, true);
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
const onDidDeselect = useCallback((uri: URI) => {
|
|
55
|
+
contextService.removeFileFromContext(uri);
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const onDidClickFile = useCallback((uri: URI) => {
|
|
59
|
+
workbenchEditorService.open(uri);
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const onDidCleanFiles = useCallback((e) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
contextService.cleanFileContext();
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
const onDidRemoveFile = useCallback((e, uri: URI) => {
|
|
69
|
+
e.stopPropagation();
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
onDidDeselect(uri);
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className={styles.chat_context}>
|
|
76
|
+
<Collapse
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
expandIcon={({ isActive }) => (isActive ? <Icon icon='down' /> : <Icon icon='right' />)}
|
|
79
|
+
defaultActiveKey={['context-panel']}
|
|
80
|
+
onChange={() => {}}
|
|
81
|
+
>
|
|
82
|
+
<Panel
|
|
83
|
+
header={
|
|
84
|
+
<div className={styles.context_header}>
|
|
85
|
+
<h3 className={styles.chat_context_title}>Context</h3>
|
|
86
|
+
<Popover
|
|
87
|
+
overlayClassName={styles.popover_icon}
|
|
88
|
+
id={'ai-context-header-clear'}
|
|
89
|
+
title={localize('aiNative.operate.clear.title')}
|
|
90
|
+
>
|
|
91
|
+
<EnhanceIcon
|
|
92
|
+
wrapperClassName={styles.action_btn}
|
|
93
|
+
className={getIcon('clear')}
|
|
94
|
+
onClick={onDidCleanFiles}
|
|
95
|
+
tabIndex={0}
|
|
96
|
+
role='button'
|
|
97
|
+
ariaLabel={localize('aiNative.operate.clear.title')}
|
|
98
|
+
/>
|
|
99
|
+
</Popover>
|
|
100
|
+
</div>
|
|
101
|
+
}
|
|
102
|
+
key='context-panel'
|
|
103
|
+
>
|
|
104
|
+
<div className={styles.file_list}>
|
|
105
|
+
{addedFiles.map((file) => (
|
|
106
|
+
<div className={styles.selected_item} key={file.uri.toString()} onClick={() => onDidClickFile(file.uri)}>
|
|
107
|
+
<Icon iconClass={labelService.getIcon(file.uri)} />
|
|
108
|
+
<span className={styles.basename}>
|
|
109
|
+
{file.uri.path.base}
|
|
110
|
+
{file.selection ? ` (${file.selection[0]}-${file.selection[1]})` : ''}
|
|
111
|
+
</span>
|
|
112
|
+
<span className={styles.dir}>
|
|
113
|
+
{URI.file(appConfig.workspaceDir).relative(file.uri.parent)?.toString()}
|
|
114
|
+
</span>
|
|
115
|
+
<Icon icon='close' className={styles.close_icon} onClick={(e) => onDidRemoveFile(e, file.uri)} />
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
<div className={styles.add_context} onClick={openContextOverlay}>
|
|
120
|
+
<Icon icon='add' />
|
|
121
|
+
Add Files
|
|
122
|
+
</div>
|
|
123
|
+
</Panel>
|
|
124
|
+
</Collapse>
|
|
125
|
+
{contextOverlay && (
|
|
126
|
+
<ContextSelector
|
|
127
|
+
onDidClose={() => toggleContextOverlay(false)}
|
|
128
|
+
onDidDeselect={onDidDeselect}
|
|
129
|
+
onDidSelect={onDidSelect}
|
|
130
|
+
addedFiles={addedFiles}
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
.chat_context {
|
|
2
|
+
position: relative;
|
|
3
|
+
margin-bottom: 10px;
|
|
4
|
+
background-color: var(--design-chatInput-background);
|
|
5
|
+
padding: 10px;
|
|
6
|
+
border-radius: 4px;
|
|
7
|
+
border: 1px solid var(--design-borderColor);
|
|
8
|
+
|
|
9
|
+
:global(.rc-collapse) {
|
|
10
|
+
background-color: transparent !important;
|
|
11
|
+
border-radius: none !important;
|
|
12
|
+
border: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:global(.rc-collapse-title) {
|
|
16
|
+
flex: 1 !important;
|
|
17
|
+
line-height: 22px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:global(.rc-collapse-expand-icon) {
|
|
21
|
+
line-height: 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:global(.rc-collapse-header) {
|
|
25
|
+
padding: 0px !important;
|
|
26
|
+
line-height: 1 !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:global(.rc-collapse-content) {
|
|
30
|
+
padding: 0px !important;
|
|
31
|
+
background-color: transparent !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.context_header {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
|
|
39
|
+
.chat_context_title {
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
font-size: 11px;
|
|
42
|
+
margin-bottom: 0px;
|
|
43
|
+
color: var(--descriptionForeground);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.context_selector {
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 0px;
|
|
50
|
+
bottom: 40px;
|
|
51
|
+
background-color: var(--design-container-background);
|
|
52
|
+
padding: 10px;
|
|
53
|
+
width: 100%;
|
|
54
|
+
padding: 0px;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
height: 350px;
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
user-select: none;
|
|
60
|
+
box-shadow: 0px 9px 28px 8px var(--design-boxShadow-primary), 0px 3px 6px -4px var(--design-boxShadow-secondary),
|
|
61
|
+
0px 6px 16px 0px var(--design-boxShadow-tertiary) !important;
|
|
62
|
+
|
|
63
|
+
.context_list {
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
overflow-y: auto;
|
|
66
|
+
|
|
67
|
+
.list_desc {
|
|
68
|
+
margin: 0px 10px;
|
|
69
|
+
height: 30px;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
font-weight: bold;
|
|
73
|
+
color: var(--descriptionForeground);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.candidate_file {
|
|
77
|
+
padding: 0px 10px;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
height: 24px;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
|
|
83
|
+
&:hover {
|
|
84
|
+
background-color: var(--button-hoverBackground);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.basename {
|
|
88
|
+
color: var(--foreground);
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
text-overflow: ellipsis;
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
margin-left: 5px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.dir {
|
|
96
|
+
color: var(--descriptionForeground);
|
|
97
|
+
margin-left: 15px;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.active {
|
|
105
|
+
background-color: var(--editor-background);
|
|
106
|
+
color: var(--foreground);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.context_search_layer {
|
|
111
|
+
position: absolute;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
background-color: var(--inputOption-hoverBackground);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.file_list {
|
|
119
|
+
margin-top: 5px;
|
|
120
|
+
max-height: 300px;
|
|
121
|
+
overflow-x: hidden;
|
|
122
|
+
overflow-y: auto;
|
|
123
|
+
|
|
124
|
+
.selected_item {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
font-size: 11px;
|
|
128
|
+
margin-right: 5px;
|
|
129
|
+
width: 100%;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
text-overflow: ellipsis;
|
|
132
|
+
padding: 0px 4px;
|
|
133
|
+
margin-bottom: 4px;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
transition: all 0.2s;
|
|
136
|
+
|
|
137
|
+
.close_icon {
|
|
138
|
+
font-size: 12px !important;
|
|
139
|
+
margin-left: auto;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
:global(.kt-icon) {
|
|
143
|
+
display: flex;
|
|
144
|
+
font-size: 11px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.basename {
|
|
148
|
+
margin-left: 4px;
|
|
149
|
+
color: var(--editor-foreground);
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
text-overflow: ellipsis;
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
width: 75%;
|
|
154
|
+
|
|
155
|
+
&:hover {
|
|
156
|
+
color: var(--badge-foreground);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.dir {
|
|
161
|
+
color: var(--descriptionForeground);
|
|
162
|
+
margin-left: 15px;
|
|
163
|
+
text-overflow: ellipsis;
|
|
164
|
+
overflow: hidden;
|
|
165
|
+
white-space: nowrap;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.add_context {
|
|
171
|
+
display: inline-flex;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
border-radius: 4px;
|
|
175
|
+
font-size: 11px;
|
|
176
|
+
margin-right: 5px;
|
|
177
|
+
height: 24px;
|
|
178
|
+
margin-top: 10px;
|
|
179
|
+
align-items: center;
|
|
180
|
+
user-select: none;
|
|
181
|
+
transition: all 0.2s;
|
|
182
|
+
color: var(--design-text-foreground);
|
|
183
|
+
padding: 0px 5px;
|
|
184
|
+
|
|
185
|
+
&:hover {
|
|
186
|
+
border-color: var(--kt-selectOption-activeBorder);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -15,6 +15,7 @@ import { ChatProxyService } from '../chat/chat-proxy.service';
|
|
|
15
15
|
import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
16
16
|
import { IChatSlashCommandItem } from '../types';
|
|
17
17
|
|
|
18
|
+
import { ChatContext } from './ChatContext';
|
|
18
19
|
import styles from './components.module.less';
|
|
19
20
|
|
|
20
21
|
const INSTRUCTION_BOTTOM = 8;
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
IChatComponent,
|
|
39
39
|
IChatContent,
|
|
40
40
|
IChatResponseProgressFileTreeData,
|
|
41
|
+
IChatToolContent,
|
|
41
42
|
URI,
|
|
42
43
|
} from '@opensumi/ide-core-common';
|
|
43
44
|
import { IIconService } from '@opensumi/ide-theme';
|
|
@@ -148,6 +149,33 @@ const TreeRenderer = (props: { treeData: IChatResponseProgressFileTreeData }) =>
|
|
|
148
149
|
);
|
|
149
150
|
};
|
|
150
151
|
|
|
152
|
+
const ToolCallRender = (props: { toolCall: IChatToolContent['content'] }) => {
|
|
153
|
+
const { toolCall } = props;
|
|
154
|
+
const chatAgentViewService = useInjectable<IChatAgentViewService>(ChatAgentViewServiceToken);
|
|
155
|
+
const [node, setNode] = useState<React.JSX.Element | null>(null);
|
|
156
|
+
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
const config = chatAgentViewService.getChatComponent('toolCall');
|
|
159
|
+
if (config) {
|
|
160
|
+
const { component: Component, initialProps } = config;
|
|
161
|
+
setNode(<Component {...initialProps} value={toolCall} />);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
setNode(
|
|
165
|
+
<div>
|
|
166
|
+
<Loading />
|
|
167
|
+
<span style={{ marginLeft: 4 }}>正在加载组件</span>
|
|
168
|
+
</div>,
|
|
169
|
+
);
|
|
170
|
+
const deferred = chatAgentViewService.getChatComponentDeferred('toolCall')!;
|
|
171
|
+
deferred.promise.then(({ component: Component, initialProps }) => {
|
|
172
|
+
setNode(<Component {...initialProps} value={toolCall} />);
|
|
173
|
+
});
|
|
174
|
+
}, [toolCall.state]);
|
|
175
|
+
|
|
176
|
+
return node;
|
|
177
|
+
};
|
|
178
|
+
|
|
151
179
|
const ComponentRender = (props: { component: string; value?: unknown }) => {
|
|
152
180
|
const chatAgentViewService = useInjectable<IChatAgentViewService>(ChatAgentViewServiceToken);
|
|
153
181
|
const [node, setNode] = useState<React.JSX.Element | null>(null);
|
|
@@ -274,6 +302,8 @@ export const ChatReply = (props: IChatReplyProps) => {
|
|
|
274
302
|
<ComponentRender component={componentId} value={value} />
|
|
275
303
|
);
|
|
276
304
|
|
|
305
|
+
const renderToolCall = (toolCall: IChatToolContent['content']) => <ToolCallRender toolCall={toolCall} />;
|
|
306
|
+
|
|
277
307
|
const contentNode = React.useMemo(
|
|
278
308
|
() =>
|
|
279
309
|
request.response.responseContents.map((item, index) => {
|
|
@@ -284,6 +314,8 @@ export const ChatReply = (props: IChatReplyProps) => {
|
|
|
284
314
|
node = renderTreeData(item.treeData);
|
|
285
315
|
} else if (item.kind === 'component') {
|
|
286
316
|
node = renderComponent(item.component, item.value);
|
|
317
|
+
} else if (item.kind === 'toolCall') {
|
|
318
|
+
node = renderToolCall(item.content);
|
|
287
319
|
} else {
|
|
288
320
|
node = renderMarkdown(item.content);
|
|
289
321
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.chat-tool-render {
|
|
2
|
+
margin: 8px 0;
|
|
3
|
+
border: 1px solid var(--design-borderColor);
|
|
4
|
+
border-radius: 6px;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
.tool-header {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
padding: 8px 12px;
|
|
12
|
+
background-color: var(--design-block-background);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
user-select: none;
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: var(--design-block-hoverBackground);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tool-name {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
font-weight: 500;
|
|
25
|
+
color: var(--design-text-foreground);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.expand-icon {
|
|
29
|
+
display: inline-block;
|
|
30
|
+
margin-right: 8px;
|
|
31
|
+
transition: transform 0.2s;
|
|
32
|
+
color: var(--design-text-placeholderForeground);
|
|
33
|
+
|
|
34
|
+
&.expanded {
|
|
35
|
+
transform: rotate(90deg);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tool-state {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
font-size: 12px;
|
|
43
|
+
color: var(--design-text-placeholderForeground);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.state-icon {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
margin-right: 6px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.loading-icon {
|
|
53
|
+
width: 12px;
|
|
54
|
+
height: 12px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.state-label {
|
|
58
|
+
margin-left: 4px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.tool-content {
|
|
62
|
+
max-height: 0;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
transition: max-height 0.3s ease-out;
|
|
65
|
+
background-color: var(--design-container-background);
|
|
66
|
+
|
|
67
|
+
&.expanded {
|
|
68
|
+
max-height: 1000px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tool-arguments,
|
|
73
|
+
.tool-result {
|
|
74
|
+
padding: 12px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.section-label {
|
|
78
|
+
font-size: 12px;
|
|
79
|
+
color: var(--design-text-placeholderForeground);
|
|
80
|
+
margin-bottom: 8px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.tool-result {
|
|
84
|
+
border-top: 1px solid var(--design-borderColor);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import cls from 'classnames';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Icon } from '@opensumi/ide-core-browser/lib/components';
|
|
5
|
+
import { Loading } from '@opensumi/ide-core-browser/lib/components/ai-native';
|
|
6
|
+
import { IChatToolContent, uuid } from '@opensumi/ide-core-common';
|
|
7
|
+
|
|
8
|
+
import { CodeEditorWithHighlight } from './ChatEditor';
|
|
9
|
+
import styles from './ChatToolRender.module.less';
|
|
10
|
+
|
|
11
|
+
export const ChatToolRender = (props: { value: IChatToolContent['content'] }) => {
|
|
12
|
+
const { value } = props;
|
|
13
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
14
|
+
|
|
15
|
+
if (!value || !value.function || !value.id) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const getStateInfo = (state?: string): { label: string; icon: React.ReactNode } => {
|
|
20
|
+
switch (state) {
|
|
21
|
+
case 'streaming-start':
|
|
22
|
+
case 'streaming':
|
|
23
|
+
return { label: 'Generating', icon: <Loading /> };
|
|
24
|
+
case 'complete':
|
|
25
|
+
return { label: 'Complete', icon: <Icon iconClass="codicon codicon-check" /> };
|
|
26
|
+
case 'result':
|
|
27
|
+
return { label: 'Result Ready', icon: <Icon iconClass="codicon codicon-check-all" /> };
|
|
28
|
+
default:
|
|
29
|
+
return { label: state || 'Unknown', icon: <Icon iconClass="codicon codicon-question" /> };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const toggleExpand = () => {
|
|
34
|
+
setIsExpanded(!isExpanded);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const stateInfo = getStateInfo(value.state);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={styles['chat-tool-render']}>
|
|
41
|
+
<div className={styles['tool-header']} onClick={toggleExpand}>
|
|
42
|
+
<div className={styles['tool-name']}>
|
|
43
|
+
<span className={cls(styles['expand-icon'], { [styles.expanded]: isExpanded })}>▶</span>
|
|
44
|
+
{value?.function?.name}
|
|
45
|
+
</div>
|
|
46
|
+
{value.state && (
|
|
47
|
+
<div className={styles['tool-state']}>
|
|
48
|
+
<span className={styles['state-icon']}>{stateInfo.icon}</span>
|
|
49
|
+
<span className={styles['state-label']}>{stateInfo.label}</span>
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
</div>
|
|
53
|
+
<div className={cls(styles['tool-content'], { [styles.expanded]: isExpanded })}>
|
|
54
|
+
{value?.function?.arguments && (
|
|
55
|
+
<div className={styles['tool-arguments']}>
|
|
56
|
+
<div className={styles['section-label']}>Arguments</div>
|
|
57
|
+
<CodeEditorWithHighlight
|
|
58
|
+
input={value?.function?.arguments}
|
|
59
|
+
language={'json'}
|
|
60
|
+
relationId={uuid(4)}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
{value?.result && (
|
|
65
|
+
<div className={styles['tool-result']}>
|
|
66
|
+
<div className={styles['section-label']}>Result</div>
|
|
67
|
+
<CodeEditorWithHighlight
|
|
68
|
+
input={value.result}
|
|
69
|
+
language={'json'}
|
|
70
|
+
relationId={uuid(4)}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -244,44 +244,45 @@
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
.
|
|
247
|
+
.monaco_wrapper {
|
|
248
248
|
position: relative;
|
|
249
|
-
min-width:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
line-height: 18px;
|
|
262
|
-
&::-webkit-scrollbar {
|
|
263
|
-
width: auto;
|
|
264
|
-
height: 4px;
|
|
265
|
-
}
|
|
249
|
+
min-width: 130px;
|
|
250
|
+
> pre {
|
|
251
|
+
margin-bottom: 10px;
|
|
252
|
+
}
|
|
253
|
+
.editor {
|
|
254
|
+
border-radius: 8px;
|
|
255
|
+
font-size: 12px;
|
|
256
|
+
padding: 32px 8px 8px 8px;
|
|
257
|
+
line-height: 18px;
|
|
258
|
+
&::-webkit-scrollbar {
|
|
259
|
+
width: auto;
|
|
260
|
+
height: 4px;
|
|
266
261
|
}
|
|
262
|
+
}
|
|
267
263
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
264
|
+
.action_toolbar {
|
|
265
|
+
display: flex;
|
|
266
|
+
position: absolute;
|
|
267
|
+
right: 8px;
|
|
268
|
+
top: 6px;
|
|
269
|
+
z-index: 100;
|
|
270
|
+
height: 20px;
|
|
271
|
+
align-items: center;
|
|
272
|
+
overflow: hidden;
|
|
277
273
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
274
|
+
:global {
|
|
275
|
+
.kt-popover {
|
|
276
|
+
height: inherit;
|
|
282
277
|
}
|
|
283
278
|
}
|
|
284
279
|
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.code_block {
|
|
283
|
+
position: relative;
|
|
284
|
+
min-width: 100px;
|
|
285
|
+
margin-top: 4px;
|
|
285
286
|
|
|
286
287
|
:global {
|
|
287
288
|
.hljs {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import { ClientAppContribution, Domain } from '@opensumi/ide-core-browser';
|
|
3
|
+
|
|
4
|
+
import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
|
|
5
|
+
|
|
6
|
+
@Domain(ClientAppContribution)
|
|
7
|
+
export class LlmContextContribution implements ClientAppContribution {
|
|
8
|
+
@Autowired(LLMContextServiceToken)
|
|
9
|
+
protected readonly llmContextService: LLMContextService;
|
|
10
|
+
|
|
11
|
+
initialize() {
|
|
12
|
+
this.llmContextService.startAutoCollection();
|
|
13
|
+
}
|
|
14
|
+
}
|