@opensumi/ide-ai-native 3.8.1-next-1740725107.0 → 3.8.1-next-1740735826.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-manager.service.d.ts +0 -5
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +1 -18
- 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.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/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 +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/tools/components/index.module.less +0 -1
- 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/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/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/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 -34
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/chat/chat-manager.service.ts +1 -17
- package/src/browser/chat/chat-model.ts +3 -18
- 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/ChatInput.tsx +4 -67
- package/src/browser/components/ChatToolRender.tsx +2 -1
- package/src/browser/components/chat-history.module.less +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/tools/components/index.module.less +0 -1
- package/src/browser/mcp/tools/createNewFileWithText.ts +0 -1
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +0 -1
- package/src/browser/mcp/tools/handlers/RunCommand.ts +0 -2
- package/src/browser/mcp/tools/runTerminalCmd.ts +0 -1
- package/src/common/llm-context.ts +4 -10
- package/src/common/prompts/context-prompt-provider.ts +29 -39
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,IAAI,IAAI,CAAC;IAE5B,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEnF;;OAEG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB,4BAA4B,EAAE,KAAK,CAAC
|
|
1
|
+
{"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,IAAI,IAAI,CAAC;IAE5B,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEnF;;OAEG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB,4BAA4B,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;IAEnD;;;OAGG;IACH,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAEtC,gBAAgB;IAChB,SAAS,IAAI,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,eAA8B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;AAmCa,QAAA,sBAAsB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MaybePromise } from '@opensumi/ide-core-common/lib/utils';
|
|
2
2
|
import { SerializedContext } from '../llm-context';
|
|
3
3
|
export declare const ChatAgentPromptProvider: unique symbol;
|
|
4
4
|
export interface ChatAgentPromptProvider {
|
|
@@ -6,10 +6,9 @@ export interface ChatAgentPromptProvider {
|
|
|
6
6
|
* 提供上下文提示
|
|
7
7
|
* @param context 上下文
|
|
8
8
|
*/
|
|
9
|
-
provideContextPrompt(context: SerializedContext, userMessage: string): string
|
|
9
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
10
10
|
}
|
|
11
11
|
export declare class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
|
|
12
|
-
|
|
13
|
-
provideContextPrompt(context: SerializedContext, userMessage: string): string;
|
|
12
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=context-prompt-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;CAC7F;AAED,qBACa,8BAA+B,YAAW,uBAAuB;IAC5E,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;CA4B5F"}
|
|
@@ -3,47 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultChatAgentPromptProvider = exports.ChatAgentPromptProvider = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const di_1 = require("@opensumi/di");
|
|
6
|
-
const types_1 = require("@opensumi/ide-editor/lib/browser/types");
|
|
7
6
|
exports.ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
8
7
|
let DefaultChatAgentPromptProvider = class DefaultChatAgentPromptProvider {
|
|
9
8
|
provideContextPrompt(context, userMessage) {
|
|
10
|
-
const editor = this.workbenchEditorService.currentEditor;
|
|
11
|
-
const currentModel = editor === null || editor === void 0 ? void 0 : editor.currentDocumentModel;
|
|
12
|
-
currentModel;
|
|
13
9
|
return `
|
|
14
|
-
<additional_data>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
${context.recentlyViewFiles.map((file, idx) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</additional_data>
|
|
37
|
-
<user_query>
|
|
38
|
-
${userMessage}
|
|
39
|
-
</user_query>`;
|
|
10
|
+
<additional_data>
|
|
11
|
+
Below are some potentially helpful/relevant pieces of information for figuring out to respond
|
|
12
|
+
<recently_viewed_files>
|
|
13
|
+
${context.recentlyViewFiles.map((file, idx) => `${idx + 1} : ${file}`)}
|
|
14
|
+
</recently_viewed_files>
|
|
15
|
+
<attached_files>
|
|
16
|
+
${context.attachedFiles.map((file) => `
|
|
17
|
+
<file_contents>
|
|
18
|
+
\`\`\`${file.language} ${file.path}
|
|
19
|
+
${file.content}
|
|
20
|
+
\`\`\`
|
|
21
|
+
</file_contents>
|
|
22
|
+
<linter_errors>
|
|
23
|
+
${file.lineErrors.join('\n')}
|
|
24
|
+
</linter_errors>
|
|
25
|
+
`)}
|
|
26
|
+
|
|
27
|
+
</attached_files>
|
|
28
|
+
</additional_data>
|
|
29
|
+
<user_query>
|
|
30
|
+
${userMessage}
|
|
31
|
+
</user_query>`;
|
|
40
32
|
}
|
|
41
33
|
};
|
|
42
34
|
exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider;
|
|
43
|
-
tslib_1.__decorate([
|
|
44
|
-
(0, di_1.Autowired)(types_1.WorkbenchEditorService),
|
|
45
|
-
tslib_1.__metadata("design:type", types_1.WorkbenchEditorService)
|
|
46
|
-
], DefaultChatAgentPromptProvider.prototype, "workbenchEditorService", void 0);
|
|
47
35
|
exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider = tslib_1.__decorate([
|
|
48
36
|
(0, di_1.Injectable)()
|
|
49
37
|
], DefaultChatAgentPromptProvider);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAK7B,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QAClE,OAAO;;;;YAIC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;;;YAGpE,OAAO,CAAC,aAAa,CAAC,GAAG,CACzB,CAAC,IAAI,EAAE,EAAE,CACP;;kBAEI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI;YAChC,IAAI,CAAC,OAAO;;;;YAIZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;WAE3B,CACA;;;;;YAKC,WAAW;wBACC,CAAC;IACvB,CAAC;CACF,CAAA;AA7BY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,eAAU,GAAE;GACA,8BAA8B,CA6B1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.8.1-next-
|
|
3
|
+
"version": "3.8.1-next-1740735826.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -23,26 +23,26 @@
|
|
|
23
23
|
"@ai-sdk/deepseek": "^0.1.11",
|
|
24
24
|
"@ai-sdk/openai-compatible": "^0.1.11",
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
26
|
-
"@opensumi/ide-addons": "3.8.1-next-
|
|
27
|
-
"@opensumi/ide-components": "3.8.1-next-
|
|
28
|
-
"@opensumi/ide-connection": "3.8.1-next-
|
|
29
|
-
"@opensumi/ide-core-common": "3.8.1-next-
|
|
30
|
-
"@opensumi/ide-core-node": "3.8.1-next-
|
|
31
|
-
"@opensumi/ide-debug": "3.8.1-next-
|
|
32
|
-
"@opensumi/ide-design": "3.8.1-next-
|
|
33
|
-
"@opensumi/ide-editor": "3.8.1-next-
|
|
34
|
-
"@opensumi/ide-file-search": "3.8.1-next-
|
|
35
|
-
"@opensumi/ide-file-service": "3.8.1-next-
|
|
36
|
-
"@opensumi/ide-main-layout": "3.8.1-next-
|
|
37
|
-
"@opensumi/ide-markers": "3.8.1-next-
|
|
38
|
-
"@opensumi/ide-monaco": "3.8.1-next-
|
|
39
|
-
"@opensumi/ide-overlay": "3.8.1-next-
|
|
40
|
-
"@opensumi/ide-preferences": "3.8.1-next-
|
|
41
|
-
"@opensumi/ide-search": "3.8.1-next-
|
|
42
|
-
"@opensumi/ide-terminal-next": "3.8.1-next-
|
|
43
|
-
"@opensumi/ide-theme": "3.8.1-next-
|
|
44
|
-
"@opensumi/ide-utils": "3.8.1-next-
|
|
45
|
-
"@opensumi/ide-workspace": "3.8.1-next-
|
|
26
|
+
"@opensumi/ide-addons": "3.8.1-next-1740735826.0",
|
|
27
|
+
"@opensumi/ide-components": "3.8.1-next-1740735826.0",
|
|
28
|
+
"@opensumi/ide-connection": "3.8.1-next-1740735826.0",
|
|
29
|
+
"@opensumi/ide-core-common": "3.8.1-next-1740735826.0",
|
|
30
|
+
"@opensumi/ide-core-node": "3.8.1-next-1740735826.0",
|
|
31
|
+
"@opensumi/ide-debug": "3.8.1-next-1740735826.0",
|
|
32
|
+
"@opensumi/ide-design": "3.8.1-next-1740735826.0",
|
|
33
|
+
"@opensumi/ide-editor": "3.8.1-next-1740735826.0",
|
|
34
|
+
"@opensumi/ide-file-search": "3.8.1-next-1740735826.0",
|
|
35
|
+
"@opensumi/ide-file-service": "3.8.1-next-1740735826.0",
|
|
36
|
+
"@opensumi/ide-main-layout": "3.8.1-next-1740735826.0",
|
|
37
|
+
"@opensumi/ide-markers": "3.8.1-next-1740735826.0",
|
|
38
|
+
"@opensumi/ide-monaco": "3.8.1-next-1740735826.0",
|
|
39
|
+
"@opensumi/ide-overlay": "3.8.1-next-1740735826.0",
|
|
40
|
+
"@opensumi/ide-preferences": "3.8.1-next-1740735826.0",
|
|
41
|
+
"@opensumi/ide-search": "3.8.1-next-1740735826.0",
|
|
42
|
+
"@opensumi/ide-terminal-next": "3.8.1-next-1740735826.0",
|
|
43
|
+
"@opensumi/ide-theme": "3.8.1-next-1740735826.0",
|
|
44
|
+
"@opensumi/ide-utils": "3.8.1-next-1740735826.0",
|
|
45
|
+
"@opensumi/ide-workspace": "3.8.1-next-1740735826.0",
|
|
46
46
|
"@xterm/xterm": "5.5.0",
|
|
47
47
|
"ai": "^4.1.45",
|
|
48
48
|
"ansi-regex": "^2.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"zod-to-json-schema": "^3.24.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@opensumi/ide-core-browser": "3.8.1-next-
|
|
60
|
+
"@opensumi/ide-core-browser": "3.8.1-next-1740735826.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "d65885df2186f12fb5af31ef3677faec843830c5"
|
|
63
63
|
}
|
|
@@ -14,8 +14,6 @@ import {
|
|
|
14
14
|
import { ChatMessageRole, IChatMessage, IHistoryChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
15
15
|
|
|
16
16
|
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
17
|
import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
20
18
|
|
|
21
19
|
import { ChatModel, ChatRequestModel, ChatResponseModel, IChatProgressResponseContent } from './chat-model';
|
|
@@ -52,12 +50,6 @@ export class ChatManagerService extends Disposable {
|
|
|
52
50
|
@Autowired(StorageProvider)
|
|
53
51
|
private storageProvider: StorageProvider;
|
|
54
52
|
|
|
55
|
-
@Autowired(ChatAgentPromptProvider)
|
|
56
|
-
protected readonly promptProvider: ChatAgentPromptProvider;
|
|
57
|
-
|
|
58
|
-
@Autowired(LLMContextServiceToken)
|
|
59
|
-
protected readonly contextService: LLMContextService;
|
|
60
|
-
|
|
61
53
|
private _chatStorage: IStorage;
|
|
62
54
|
|
|
63
55
|
protected fromJSON(data: ISessionModel[]) {
|
|
@@ -108,20 +100,12 @@ export class ChatManagerService extends Disposable {
|
|
|
108
100
|
}
|
|
109
101
|
|
|
110
102
|
startSession() {
|
|
111
|
-
const model = new ChatModel(
|
|
112
|
-
provideContext: this.provideContextPrompt.bind(this),
|
|
113
|
-
});
|
|
103
|
+
const model = new ChatModel();
|
|
114
104
|
this.#sessionModels.set(model.sessionId, model);
|
|
115
105
|
this.listenSession(model);
|
|
116
106
|
return model;
|
|
117
107
|
}
|
|
118
108
|
|
|
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
109
|
getSession(sessionId: string): ChatModel | undefined {
|
|
126
110
|
return this.#sessionModels.get(sessionId);
|
|
127
111
|
}
|
|
@@ -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;
|
|
@@ -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) => {
|
|
@@ -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
|
-
}
|