@opensumi/ide-ai-native 3.9.1-next-1749538805.0 → 3.9.1-next-1749540423.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.map +1 -1
- package/lib/browser/ai-core.contribution.js +4 -9
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/apply.service.d.ts +0 -3
- package/lib/browser/chat/apply.service.d.ts.map +1 -1
- package/lib/browser/chat/apply.service.js +0 -47
- package/lib/browser/chat/apply.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +0 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +3 -9
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +1 -8
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +76 -113
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +2 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +57 -50
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +1 -4
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +0 -6
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +10 -50
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.js +2 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +1 -2
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +30 -148
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +2 -2
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +2 -7
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +0 -25
- package/lib/browser/components/components.module.less +8 -37
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +14 -150
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +1 -165
- package/lib/browser/components/mention-input/types.d.ts +1 -28
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +0 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +2 -21
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +20 -162
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +4 -6
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/tabbar.view.d.ts +1 -1
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +12 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +4 -5
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +5 -23
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +1 -3
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +0 -4
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +1 -7
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts +3 -1
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +40 -14
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/fileSearch.js +5 -9
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
- package/lib/browser/mcp/tools/grepSearch.js +10 -22
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts +1 -11
- package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/RunCommand.js +4 -11
- package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +15 -19
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -47
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +2 -127
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -5
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +1 -12
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/index.d.ts +1 -5
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -2
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +0 -19
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/model.d.ts +0 -1
- package/lib/common/model.d.ts.map +1 -1
- package/lib/common/model.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +2 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +29 -35
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -5
- package/lib/common/utils.js.map +1 -1
- package/lib/node/anthropic/anthropic-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts +1 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +2 -12
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/deepseek/deepseek-language-model.d.ts +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +1 -3
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +1 -7
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +1 -3
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +2 -14
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.sse.d.ts +1 -187
- package/lib/node/mcp-server.sse.d.ts.map +1 -1
- package/lib/node/mcp-server.sse.js +2 -2
- package/lib/node/mcp-server.sse.js.map +1 -1
- package/lib/node/mcp-server.stdio.d.ts +1 -187
- package/lib/node/mcp-server.stdio.d.ts.map +1 -1
- package/package.json +26 -27
- package/src/browser/ai-core.contribution.ts +4 -14
- package/src/browser/chat/apply.service.ts +1 -62
- package/src/browser/chat/chat-manager.service.ts +7 -16
- package/src/browser/chat/chat-model.ts +73 -130
- package/src/browser/chat/chat-proxy.service.ts +81 -68
- package/src/browser/chat/chat.feature.registry.ts +1 -17
- package/src/browser/chat/chat.view.tsx +12 -73
- package/src/browser/components/ChatEditor.tsx +1 -1
- package/src/browser/components/ChatHistory.tsx +1 -2
- package/src/browser/components/ChatMentionInput.tsx +35 -180
- package/src/browser/components/ChatReply.tsx +4 -4
- package/src/browser/components/ChatToolRender.module.less +0 -25
- package/src/browser/components/ChatToolRender.tsx +2 -10
- package/src/browser/components/components.module.less +8 -37
- package/src/browser/components/mention-input/mention-input.module.less +1 -165
- package/src/browser/components/mention-input/mention-input.tsx +31 -232
- package/src/browser/components/mention-input/types.ts +0 -29
- package/src/browser/context/llm-context.service.ts +21 -182
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +0 -8
- package/src/browser/layout/ai-layout.tsx +8 -12
- package/src/browser/layout/tabbar.view.tsx +23 -10
- package/src/browser/mcp/base-apply.service.ts +10 -30
- package/src/browser/mcp/mcp-server-proxy.service.ts +1 -6
- package/src/browser/mcp/mcp-server.feature.registry.ts +1 -6
- package/src/browser/mcp/tools/createNewFileWithText.ts +46 -17
- package/src/browser/mcp/tools/fileSearch.ts +5 -8
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/grepSearch.ts +21 -32
- package/src/browser/mcp/tools/handlers/ListDir.ts +2 -2
- package/src/browser/mcp/tools/handlers/ReadFile.ts +2 -2
- package/src/browser/mcp/tools/handlers/RunCommand.ts +14 -21
- package/src/browser/mcp/tools/listDir.ts +12 -15
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +2 -181
- package/src/browser/preferences/schema.ts +0 -5
- package/src/browser/types.ts +0 -18
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +1 -0
- package/src/common/index.ts +1 -6
- package/src/common/llm-context.ts +0 -23
- package/src/common/model.ts +0 -1
- package/src/common/prompts/context-prompt-provider.ts +40 -55
- package/src/common/types.ts +0 -18
- package/src/common/utils.ts +1 -4
- package/src/node/base-language-model.ts +14 -11
- package/src/node/mcp/sumi-mcp-server.ts +2 -10
- package/src/node/mcp-server-manager-impl.ts +2 -17
- package/src/node/mcp-server.sse.ts +2 -1
- package/lib/browser/components/mention-input/mention-select.d.ts +0 -28
- package/lib/browser/components/mention-input/mention-select.d.ts.map +0 -1
- package/lib/browser/components/mention-input/mention-select.js +0 -136
- package/lib/browser/components/mention-input/mention-select.js.map +0 -1
- package/lib/browser/components/mention-input/mention-select.module.less +0 -297
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.d.ts +0 -15
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.js +0 -53
- package/lib/browser/mcp/tools/handlers/CreateNewFileWithText.js.map +0 -1
- package/lib/browser/rules/rules.contribution.d.ts +0 -29
- package/lib/browser/rules/rules.contribution.d.ts.map +0 -1
- package/lib/browser/rules/rules.contribution.js +0 -94
- package/lib/browser/rules/rules.contribution.js.map +0 -1
- package/lib/browser/rules/rules.module.less +0 -175
- package/lib/browser/rules/rules.service.d.ts +0 -25
- package/lib/browser/rules/rules.service.d.ts.map +0 -1
- package/lib/browser/rules/rules.service.js +0 -180
- package/lib/browser/rules/rules.service.js.map +0 -1
- package/lib/browser/rules/rules.view.d.ts +0 -3
- package/lib/browser/rules/rules.view.d.ts.map +0 -1
- package/lib/browser/rules/rules.view.js +0 -76
- package/lib/browser/rules/rules.view.js.map +0 -1
- package/lib/common/image-compression.d.ts +0 -25
- package/lib/common/image-compression.d.ts.map +0 -1
- package/lib/common/image-compression.js +0 -153
- package/lib/common/image-compression.js.map +0 -1
- package/lib/common/mdc-parser.d.ts +0 -60
- package/lib/common/mdc-parser.d.ts.map +0 -1
- package/lib/common/mdc-parser.js +0 -246
- package/lib/common/mdc-parser.js.map +0 -1
- package/lib/common/prompts/system-prompt.d.ts +0 -2
- package/lib/common/prompts/system-prompt.d.ts.map +0 -1
- package/lib/common/prompts/system-prompt.js +0 -5
- package/lib/common/prompts/system-prompt.js.map +0 -1
- package/src/browser/components/mention-input/mention-select.module.less +0 -297
- package/src/browser/components/mention-input/mention-select.tsx +0 -256
- package/src/browser/mcp/tools/handlers/CreateNewFileWithText.ts +0 -49
- package/src/browser/rules/rules.contribution.ts +0 -105
- package/src/browser/rules/rules.module.less +0 -175
- package/src/browser/rules/rules.service.ts +0 -189
- package/src/browser/rules/rules.view.tsx +0 -127
- package/src/common/image-compression.ts +0 -174
- package/src/common/mdc-parser.ts +0 -295
- package/src/common/prompts/system-prompt.ts +0 -2
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
|
-
import { Domain } from '@opensumi/ide-core-common';
|
|
4
|
+
import { Domain, URI, path } from '@opensumi/ide-core-common';
|
|
5
|
+
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
6
|
+
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
5
7
|
|
|
6
8
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
9
|
+
import { BaseApplyService } from '../base-apply.service';
|
|
7
10
|
|
|
8
11
|
import { EditFileToolComponent } from './components/EditFile';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
code_edit: z.string().describe('The content to write into the new file'),
|
|
15
|
-
})
|
|
16
|
-
.transform((data) => ({
|
|
17
|
-
targetFile: data.target_file,
|
|
18
|
-
codeEdit: data.code_edit,
|
|
19
|
-
}));
|
|
12
|
+
|
|
13
|
+
const inputSchema = z.object({
|
|
14
|
+
target_file: z.string().describe('The relative path where the file should be created'),
|
|
15
|
+
code_edit: z.string().describe('The content to write into the new file'),
|
|
16
|
+
});
|
|
20
17
|
|
|
21
18
|
@Domain(MCPServerContribution)
|
|
22
19
|
export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
23
|
-
@Autowired(
|
|
24
|
-
private readonly
|
|
20
|
+
@Autowired(IWorkspaceService)
|
|
21
|
+
private readonly workspaceService: IWorkspaceService;
|
|
22
|
+
|
|
23
|
+
@Autowired(IFileServiceClient)
|
|
24
|
+
private readonly fileService: IFileServiceClient;
|
|
25
|
+
|
|
26
|
+
@Autowired(BaseApplyService)
|
|
27
|
+
private applyService: BaseApplyService;
|
|
25
28
|
|
|
26
29
|
registerMCPServer(registry: IMCPServerRegistry): void {
|
|
27
30
|
registry.registerMCPTool(this.getToolDefinition());
|
|
@@ -47,10 +50,36 @@ export class CreateNewFileWithTextTool implements MCPServerContribution {
|
|
|
47
50
|
|
|
48
51
|
private async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
49
52
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
// 获取工作区根目录
|
|
54
|
+
const workspaceRoots = this.workspaceService.tryGetRoots();
|
|
55
|
+
if (!workspaceRoots || workspaceRoots.length === 0) {
|
|
56
|
+
logger.appendLine('Error: Cannot determine project directory');
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: 'text', text: "can't find project dir" }],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 构建完整的文件路径
|
|
64
|
+
const rootUri = URI.parse(workspaceRoots[0].uri);
|
|
65
|
+
const fullPath = path.join(rootUri.codeUri.fsPath, args.target_file);
|
|
66
|
+
const fileUri = URI.file(fullPath);
|
|
67
|
+
|
|
68
|
+
// 创建父目录
|
|
69
|
+
const parentDir = path.dirname(fullPath);
|
|
70
|
+
const parentUri = URI.file(parentDir);
|
|
71
|
+
await this.fileService.createFolder(parentUri.toString());
|
|
72
|
+
|
|
73
|
+
// 创建文件
|
|
74
|
+
await this.fileService.createFile(fileUri.toString());
|
|
75
|
+
|
|
76
|
+
// 使用 applyService 写入文件内容
|
|
77
|
+
const codeBlock = await this.applyService.registerCodeBlock(args.target_file, args.code_edit, args.toolCallId);
|
|
78
|
+
await this.applyService.apply(codeBlock);
|
|
79
|
+
|
|
80
|
+
logger.appendLine(`Successfully created file at: ${args.target_file}`);
|
|
52
81
|
return {
|
|
53
|
-
content: [{ type: 'text', text: '
|
|
82
|
+
content: [{ type: 'text', text: 'ok' }],
|
|
54
83
|
};
|
|
55
84
|
} catch (error) {
|
|
56
85
|
logger.appendLine(`Error during file creation: ${error}`);
|
|
@@ -80,14 +80,11 @@ export class FileSearchTool implements MCPServerContribution {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|
|
83
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
|
|
84
|
+
[args.toolCallId]: {
|
|
85
|
+
files,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
91
88
|
|
|
92
89
|
logger.appendLine(`Found ${files.length} files matching "${args.query}"`);
|
|
93
90
|
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired } from '@opensumi/di';
|
|
5
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
8
8
|
import { URI as MonacoURI } from '@opensumi/monaco-editor-core/esm/vs/base/common/uri';
|
|
@@ -2,7 +2,7 @@ import * as path from 'path';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Autowired } from '@opensumi/di';
|
|
5
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
6
6
|
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
7
7
|
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
8
8
|
import { IWorkspaceService } from '@opensumi/ide-workspace';
|
|
@@ -12,27 +12,19 @@ import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition
|
|
|
12
12
|
|
|
13
13
|
import { GrepSearchToolComponent } from './components/ExpandableFileList';
|
|
14
14
|
|
|
15
|
-
const inputSchema = z
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
.transform((data) => ({
|
|
30
|
-
query: data.query,
|
|
31
|
-
caseSensitive: data.case_sensitive,
|
|
32
|
-
includePattern: data.include_pattern,
|
|
33
|
-
excludePattern: data.exclude_pattern,
|
|
34
|
-
explanation: data.explanation,
|
|
35
|
-
}));
|
|
15
|
+
const inputSchema = z.object({
|
|
16
|
+
query: z.string().describe('The regex pattern to search for'),
|
|
17
|
+
case_sensitive: z.boolean().optional().describe('Whether the search should be case sensitive'),
|
|
18
|
+
include_pattern: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('Glob pattern for files to include (e.g. "*.ts" for TypeScript files)'),
|
|
22
|
+
exclude_pattern: z.string().optional().describe('Glob pattern for files to exclude'),
|
|
23
|
+
explanation: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
|
|
27
|
+
});
|
|
36
28
|
|
|
37
29
|
const MAX_RESULTS = 50;
|
|
38
30
|
|
|
@@ -80,9 +72,9 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
80
72
|
await this.searchService.doSearch(
|
|
81
73
|
searchPattern,
|
|
82
74
|
{
|
|
83
|
-
isMatchCase: !!args.
|
|
84
|
-
include: args.
|
|
85
|
-
exclude: args.
|
|
75
|
+
isMatchCase: !!args.case_sensitive,
|
|
76
|
+
include: args.include_pattern?.split(','),
|
|
77
|
+
exclude: args.exclude_pattern?.split(','),
|
|
86
78
|
maxResults: MAX_RESULTS,
|
|
87
79
|
isUseRegexp: true,
|
|
88
80
|
isToggleOpen: false,
|
|
@@ -119,14 +111,11 @@ export class GrepSearchTool implements MCPServerContribution {
|
|
|
119
111
|
}
|
|
120
112
|
deferred.resolve(results.join('\n\n'));
|
|
121
113
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
}
|
|
114
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
|
|
115
|
+
[args.toolCallId]: {
|
|
116
|
+
files,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
130
119
|
});
|
|
131
120
|
const text = await deferred.promise;
|
|
132
121
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { AppConfig,
|
|
2
|
+
import { AppConfig, Throttler, URI } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -67,7 +67,7 @@ export class ListDirHandler {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// 解析相对路径
|
|
70
|
-
const absolutePath =
|
|
70
|
+
const absolutePath = `${this.appConfig.workspaceDir}/${relativeWorkspacePath}`;
|
|
71
71
|
const fileStat = await this.fileSystemService.getFileStat(absolutePath, true);
|
|
72
72
|
// 验证路径有效性
|
|
73
73
|
if (!fileStat || !fileStat.isDirectory) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { FileSearchQuickCommandHandler } from '@opensumi/ide-addons/lib/browser/file-search.contribution';
|
|
3
3
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
4
|
-
import { CancellationToken, URI
|
|
4
|
+
import { CancellationToken, URI } from '@opensumi/ide-core-common';
|
|
5
5
|
import { IEditorDocumentModelRef, IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser';
|
|
6
6
|
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
7
7
|
|
|
@@ -107,7 +107,7 @@ export class FileHandler {
|
|
|
107
107
|
throw new Error('No read file parameters provided. Need to give at least the path.');
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
const uri = new URI(
|
|
110
|
+
const uri = new URI(`${this.appConfig.workspaceDir}/${fileParams.relativeWorkspacePath}`);
|
|
111
111
|
if (!uri) {
|
|
112
112
|
const similarFiles = await this.findSimilarFiles(fileParams.relativeWorkspacePath, 3);
|
|
113
113
|
throw this.createFileNotFoundError(fileParams.relativeWorkspacePath, similarFiles);
|
|
@@ -13,25 +13,18 @@ const color = {
|
|
|
13
13
|
reset: '\x1b[0m',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const inputSchema = z
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
.transform((data) => ({
|
|
30
|
-
command: data.command,
|
|
31
|
-
isBackground: data.is_background,
|
|
32
|
-
explanation: data.explanation,
|
|
33
|
-
requireUserApproval: data.require_user_approval,
|
|
34
|
-
}));
|
|
16
|
+
export const inputSchema = z.object({
|
|
17
|
+
command: z.string().describe('The terminal command to execute'),
|
|
18
|
+
is_background: z.boolean().describe('Whether the command should be run in the background'),
|
|
19
|
+
explanation: z
|
|
20
|
+
.string()
|
|
21
|
+
.describe('One sentence explanation as to why this command needs to be run and how it contributes to the goal.'),
|
|
22
|
+
require_user_approval: z
|
|
23
|
+
.boolean()
|
|
24
|
+
.describe(
|
|
25
|
+
"Whether the user must approve the command before it is executed. Only set this to false if the command is safe and if it matches the user's requirements for commands that should be executed automatically.",
|
|
26
|
+
),
|
|
27
|
+
});
|
|
35
28
|
|
|
36
29
|
@Injectable()
|
|
37
30
|
export class RunCommandHandler {
|
|
@@ -73,7 +66,7 @@ export class RunCommandHandler {
|
|
|
73
66
|
|
|
74
67
|
async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
|
|
75
68
|
logger.appendLine(`Executing command: ${args.command}`);
|
|
76
|
-
if (this.isAlwaysApproval(args.
|
|
69
|
+
if (this.isAlwaysApproval(args.require_user_approval)) {
|
|
77
70
|
const def = new Deferred<boolean>();
|
|
78
71
|
this.approvalDeferredMap.set(args.toolCallId, def);
|
|
79
72
|
const approval = await def.promise;
|
|
@@ -100,7 +93,7 @@ export class RunCommandHandler {
|
|
|
100
93
|
const result: { type: string; text: string }[] = [];
|
|
101
94
|
const def = new Deferred<{ isError?: boolean; content: { type: string; text: string }[] }>();
|
|
102
95
|
|
|
103
|
-
if (args.
|
|
96
|
+
if (args.is_background) {
|
|
104
97
|
def.resolve({
|
|
105
98
|
isError: false,
|
|
106
99
|
content: [{ type: 'text', text: `Successful run command ${args.command} in background.` }],
|
|
@@ -63,21 +63,18 @@ export class ListDirTool implements MCPServerContribution {
|
|
|
63
63
|
|
|
64
64
|
// 设置消息的附加数据
|
|
65
65
|
const messages = this.chatInternalService.sessionModel.history.getMessages();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
}
|
|
66
|
+
this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
|
|
67
|
+
[args.toolCallId]: {
|
|
68
|
+
files: fileUris,
|
|
69
|
+
title: `Listed directory "${args.relativeWorkspacePath}"`,
|
|
70
|
+
details: result.files.map((file) => ({
|
|
71
|
+
type: file.isDirectory ? 'dir' : 'file',
|
|
72
|
+
name: file.name,
|
|
73
|
+
info: file.isDirectory ? `${file.numChildren ?? '?'} items` : `${file.size}KB, ${file.numLines} lines`,
|
|
74
|
+
lastModified: file.lastModified,
|
|
75
|
+
})),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
81
78
|
|
|
82
79
|
logger.appendLine(`Listed ${fileUris.length} files in directory "${args.relativeWorkspacePath}"`);
|
|
83
80
|
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
|
|
3
3
|
import { Autowired } from '@opensumi/di';
|
|
4
4
|
import { AppConfig } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { Domain } from '@opensumi/ide-core-common';
|
|
5
|
+
import { Deferred, Domain } from '@opensumi/ide-core-common';
|
|
6
6
|
import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next/lib/common/controller';
|
|
7
7
|
|
|
8
8
|
import { IMCPServerRegistry, MCPLogger, MCPServerContribution, MCPToolDefinition } from '../../types';
|
|
@@ -1,61 +1,11 @@
|
|
|
1
1
|
import { Disposable, Emitter, Event, uuid } from '@opensumi/ide-core-common';
|
|
2
2
|
import { ChatMessageRole, IHistoryChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
|
|
3
3
|
|
|
4
|
-
import { ChatFeatureRegistry } from '../chat/chat.feature.registry';
|
|
5
|
-
|
|
6
4
|
type IExcludeMessage = Omit<IHistoryChatMessage, 'id' | 'order'>;
|
|
7
5
|
|
|
8
|
-
interface IMemoryConfig {
|
|
9
|
-
shortTermSize: number; // 最近消息窗口大小(10条)
|
|
10
|
-
bufferSize: number; // 缓冲区大小(5条)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface IMemorySummary {
|
|
14
|
-
content: string;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
messageIds: string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface IToolCallInfo {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
args: Record<string, any>;
|
|
23
|
-
result: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface MessageBufferManager {
|
|
27
|
-
messages: IHistoryChatMessage[];
|
|
28
|
-
add(message: IHistoryChatMessage): void;
|
|
29
|
-
clear(): void;
|
|
30
|
-
size(): number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class SimpleMessageBuffer implements MessageBufferManager {
|
|
34
|
-
private _messages: IHistoryChatMessage[] = [];
|
|
35
|
-
|
|
36
|
-
get messages(): IHistoryChatMessage[] {
|
|
37
|
-
return this._messages;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
add(message: IHistoryChatMessage): void {
|
|
41
|
-
this._messages.push(message);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
clear(): void {
|
|
45
|
-
this._messages = [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
size(): number {
|
|
49
|
-
return this._messages.length;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
6
|
export class MsgHistoryManager extends Disposable {
|
|
54
7
|
private messageMap: Map<string, IHistoryChatMessage> = new Map();
|
|
55
8
|
private messageAdditionalMap: Map<string, Record<string, any>> = new Map();
|
|
56
|
-
private memorySummaries: IMemorySummary[] = [];
|
|
57
|
-
private toolCallMap: Map<string, IToolCallInfo> = new Map();
|
|
58
|
-
private isCompressing = false; // 添加压缩锁,防止重复压缩
|
|
59
9
|
|
|
60
10
|
private readonly _onMessageChange = new Emitter<IHistoryChatMessage[]>();
|
|
61
11
|
public readonly onMessageChange: Event<IHistoryChatMessage[]> = this._onMessageChange.event;
|
|
@@ -63,33 +13,11 @@ export class MsgHistoryManager extends Disposable {
|
|
|
63
13
|
private readonly _onMessageAdditionalChange = new Emitter<Record<string, any>>();
|
|
64
14
|
public readonly onMessageAdditionalChange: Event<Record<string, any>> = this._onMessageAdditionalChange.event;
|
|
65
15
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
memoryConfig: IMemoryConfig = {
|
|
69
|
-
shortTermSize: 10,
|
|
70
|
-
bufferSize: 5,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
74
|
-
private chatFeatureRegistry: ChatFeatureRegistry,
|
|
75
|
-
data?: {
|
|
76
|
-
additional: Record<string, any>;
|
|
77
|
-
messages: IHistoryChatMessage[];
|
|
78
|
-
toolCalls?: Record<string, IToolCallInfo>;
|
|
79
|
-
memorySummaries?: IMemorySummary[];
|
|
80
|
-
},
|
|
81
|
-
) {
|
|
16
|
+
constructor(data?: { additional: Record<string, any>; messages: IHistoryChatMessage[] }) {
|
|
82
17
|
super();
|
|
83
|
-
this.messageBuffer = new SimpleMessageBuffer();
|
|
84
18
|
if (data) {
|
|
85
19
|
this.messageMap = new Map(data.messages.map((item) => [item.id, item]));
|
|
86
20
|
this.messageAdditionalMap = new Map(Object.entries(data.additional));
|
|
87
|
-
if (data.toolCalls) {
|
|
88
|
-
this.toolCallMap = new Map(Object.entries(data.toolCalls));
|
|
89
|
-
}
|
|
90
|
-
if (data.memorySummaries) {
|
|
91
|
-
this.memorySummaries = data.memorySummaries;
|
|
92
|
-
}
|
|
93
21
|
}
|
|
94
22
|
}
|
|
95
23
|
|
|
@@ -105,91 +33,6 @@ export class MsgHistoryManager extends Disposable {
|
|
|
105
33
|
public clearMessages() {
|
|
106
34
|
this.messageMap.clear();
|
|
107
35
|
this.messageAdditionalMap.clear();
|
|
108
|
-
this.memorySummaries = [];
|
|
109
|
-
this.toolCallMap.clear();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 压缩历史消息的方法:
|
|
114
|
-
* 1. 保持最新的10条消息不变
|
|
115
|
-
* 2. 当累积了5条超出限制的消息时,对这5条(最早的消息)进行总结
|
|
116
|
-
* 3. 总结完成后删除这5条消息
|
|
117
|
-
* 4. 重复这个过程,确保消息数量始终在可控范围内
|
|
118
|
-
*/
|
|
119
|
-
private async compressMemory() {
|
|
120
|
-
// 如果正在压缩中,直接返回
|
|
121
|
-
if (this.isCompressing) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const messages = this.messageList;
|
|
126
|
-
// 只有当消息总数超过短期记忆限制时才进行压缩
|
|
127
|
-
if (messages.length <= this.memoryConfig.shortTermSize) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
this.isCompressing = true;
|
|
133
|
-
|
|
134
|
-
// 1. 获取超出短期记忆限制的最新一条消息
|
|
135
|
-
const latestExcessMessage = messages[messages.length - this.memoryConfig.shortTermSize - 1];
|
|
136
|
-
|
|
137
|
-
// 如果这条消息已经被总结过,就不需要再处理
|
|
138
|
-
if (latestExcessMessage.isSummarized) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 2. 将这条消息添加到缓冲区
|
|
143
|
-
this.messageBuffer.add(latestExcessMessage);
|
|
144
|
-
|
|
145
|
-
// 3. 当缓冲区达到指定大小时,进行总结
|
|
146
|
-
if (this.messageBuffer.size() >= this.memoryConfig.bufferSize) {
|
|
147
|
-
const messagesToSummarize = this.messageBuffer.messages;
|
|
148
|
-
|
|
149
|
-
const summaryProvider = this.chatFeatureRegistry.getMessageSummaryProvider?.();
|
|
150
|
-
if (summaryProvider) {
|
|
151
|
-
const messageContents = messagesToSummarize.map((msg) => ({
|
|
152
|
-
role: msg.role,
|
|
153
|
-
content: msg.content,
|
|
154
|
-
}));
|
|
155
|
-
|
|
156
|
-
const memorize = await summaryProvider.generateMemorizedMessage(messageContents);
|
|
157
|
-
if (memorize) {
|
|
158
|
-
// 添加新的记忆总结
|
|
159
|
-
this.memorySummaries.push({
|
|
160
|
-
content: memorize,
|
|
161
|
-
timestamp: Date.now(),
|
|
162
|
-
messageIds: messagesToSummarize.map((msg) => msg.id),
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// 标记消息为已总结
|
|
166
|
-
for (const msg of messagesToSummarize) {
|
|
167
|
-
const existingMsg = this.messageMap.get(msg.id);
|
|
168
|
-
if (existingMsg) {
|
|
169
|
-
this.messageMap.set(msg.id, {
|
|
170
|
-
...existingMsg,
|
|
171
|
-
isSummarized: true,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// 清空缓冲区
|
|
177
|
-
this.messageBuffer.clear();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} finally {
|
|
182
|
-
this.isCompressing = false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
public addToolCall(toolCall: IToolCallInfo): void {
|
|
187
|
-
this.toolCallMap.set(toolCall.id, toolCall);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public getToolCall(id: string): IToolCallInfo | undefined {
|
|
191
|
-
const toolCall = this.toolCallMap.get(id);
|
|
192
|
-
return toolCall;
|
|
193
36
|
}
|
|
194
37
|
|
|
195
38
|
private doAddMessage(message: IExcludeMessage): string {
|
|
@@ -205,19 +48,11 @@ export class MsgHistoryManager extends Disposable {
|
|
|
205
48
|
|
|
206
49
|
this.messageMap.set(id, msg);
|
|
207
50
|
|
|
208
|
-
// 在添加新消息后尝试压缩记忆
|
|
209
|
-
this.compressMemory().catch((error) => {
|
|
210
|
-
// eslint-disable-next-line no-console
|
|
211
|
-
console.error('[MsgHistoryManager] Error compressing memory', error);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// 无论压缩是否完成,都触发消息变更事件
|
|
215
51
|
this._onMessageChange.fire(this.getMessages());
|
|
216
52
|
return id;
|
|
217
53
|
}
|
|
218
54
|
|
|
219
55
|
private get messageList(): IHistoryChatMessage[] {
|
|
220
|
-
// 按 order 升序排序,保持消息的原始顺序
|
|
221
56
|
return Array.from(this.messageMap.values()).sort((a, b) => a.order - b.order);
|
|
222
57
|
}
|
|
223
58
|
|
|
@@ -230,17 +65,6 @@ export class MsgHistoryManager extends Disposable {
|
|
|
230
65
|
return this.messageList;
|
|
231
66
|
}
|
|
232
67
|
|
|
233
|
-
public getMemorySummaries(): IMemorySummary[] {
|
|
234
|
-
return this.memorySummaries;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public setMemoryConfig(config: Partial<IMemoryConfig>) {
|
|
238
|
-
this.memoryConfig = {
|
|
239
|
-
...this.memoryConfig,
|
|
240
|
-
...config,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
68
|
public addUserMessage(
|
|
245
69
|
message: Required<Pick<IExcludeMessage, 'agentId' | 'agentCommand' | 'content' | 'relationId' | 'images'>>,
|
|
246
70
|
): string {
|
|
@@ -294,12 +118,9 @@ export class MsgHistoryManager extends Disposable {
|
|
|
294
118
|
}
|
|
295
119
|
|
|
296
120
|
toJSON() {
|
|
297
|
-
|
|
121
|
+
return {
|
|
298
122
|
messages: this.getMessages(),
|
|
299
123
|
additional: Object.fromEntries(this.messageAdditionalMap.entries()),
|
|
300
|
-
memorySummaries: this.memorySummaries,
|
|
301
|
-
toolCalls: Object.fromEntries(this.toolCallMap.entries()),
|
|
302
124
|
};
|
|
303
|
-
return data;
|
|
304
125
|
}
|
|
305
126
|
}
|
|
@@ -177,10 +177,5 @@ export const aiNativePreferenceSchema: PreferenceSchema = {
|
|
|
177
177
|
type: 'string',
|
|
178
178
|
description: '%preference.ai.native.chat.system.prompt.description%',
|
|
179
179
|
},
|
|
180
|
-
[AINativeSettingSectionsId.GlobalRules]: {
|
|
181
|
-
type: 'string',
|
|
182
|
-
default: '',
|
|
183
|
-
description: '%preference.ai.native.globalRules.description%',
|
|
184
|
-
},
|
|
185
180
|
},
|
|
186
181
|
};
|
package/src/browser/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { ZodSchema } from 'zod';
|
|
|
5
5
|
import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native/index';
|
|
6
6
|
import {
|
|
7
7
|
CancellationToken,
|
|
8
|
-
ChatMessageRole,
|
|
9
8
|
ChatResponse,
|
|
10
9
|
Deferred,
|
|
11
10
|
IAICompletionOption,
|
|
@@ -135,8 +134,6 @@ export interface IChatFeatureRegistry {
|
|
|
135
134
|
registerImageUploadProvider(provider: IImageUploadProvider): void;
|
|
136
135
|
registerWelcome(content: IChatWelcomeMessageContent | React.ReactNode, sampleQuestions?: ISampleQuestions[]): void;
|
|
137
136
|
registerSlashCommand(command: IChatSlashCommandItem, handler: IChatSlashCommandHandler): void;
|
|
138
|
-
|
|
139
|
-
registerMessageSummaryProvider(provider: IMessageSummaryProvider): void;
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
export type ChatWelcomeRender = (props: {
|
|
@@ -301,21 +298,6 @@ export interface IImageUploadProvider {
|
|
|
301
298
|
imageUpload(file: File): Promise<DataContent | URL>;
|
|
302
299
|
}
|
|
303
300
|
|
|
304
|
-
export interface IMessageSummaryProvider {
|
|
305
|
-
getMessageSummary(
|
|
306
|
-
messages: Array<{
|
|
307
|
-
role: ChatMessageRole;
|
|
308
|
-
content: string;
|
|
309
|
-
}>,
|
|
310
|
-
): Promise<string | undefined>;
|
|
311
|
-
generateMemorizedMessage(
|
|
312
|
-
messages: Array<{
|
|
313
|
-
role: ChatMessageRole;
|
|
314
|
-
content: string;
|
|
315
|
-
}>,
|
|
316
|
-
): Promise<string | undefined>;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
301
|
export const AINativeCoreContribution = Symbol('AINativeCoreContribution');
|
|
320
302
|
|
|
321
303
|
export interface AINativeCoreContribution {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Position,
|
|
14
14
|
} from '@opensumi/ide-monaco';
|
|
15
15
|
import { ReactInlineContentWidget } from '@opensumi/ide-monaco/lib/browser/ai-native/BaseInlineContentWidget';
|
|
16
|
+
import { URI } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
16
17
|
import { ContentWidgetPositionPreference } from '@opensumi/ide-monaco/lib/browser/monaco-exports/editor';
|
|
17
18
|
import { EditorOption } from '@opensumi/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
18
19
|
import { IScrollEvent } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorCommon';
|
package/src/common/index.ts
CHANGED
|
@@ -15,9 +15,8 @@ import {
|
|
|
15
15
|
import { DESIGN_MENUBAR_CONTAINER_VIEW_ID } from '@opensumi/ide-design/lib/common/constants';
|
|
16
16
|
import { IPosition, ITextModel, InlineCompletionContext } from '@opensumi/ide-monaco/lib/common';
|
|
17
17
|
|
|
18
|
-
import { ImageCompressionOptions } from './image-compression';
|
|
19
18
|
import { IMCPServer, MCPServerDescription } from './mcp-server-manager';
|
|
20
|
-
import {
|
|
19
|
+
import { IPartialEditEvent, MCPTool } from './types';
|
|
21
20
|
|
|
22
21
|
import type { CoreMessage } from 'ai';
|
|
23
22
|
|
|
@@ -153,7 +152,6 @@ export interface ISumiMCPServerBackend {
|
|
|
153
152
|
$removeServer(name: string): void;
|
|
154
153
|
$syncServer(name: string): Promise<void>;
|
|
155
154
|
$getMCPServerByName(name: string): IMCPServer | undefined;
|
|
156
|
-
$compressToolResult(result: IMCPToolResult, options: ImageCompressionOptions): Promise<IMCPToolResult>;
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
export const SumiMCPServerProxyServicePath = 'SumiMCPServerProxyServicePath';
|
|
@@ -333,6 +331,3 @@ export interface IInlineDiffService {
|
|
|
333
331
|
}
|
|
334
332
|
|
|
335
333
|
export const InlineDiffServiceToken = Symbol('InlineDiffService');
|
|
336
|
-
|
|
337
|
-
export * from './tool-invocation-registry';
|
|
338
|
-
export * from './mdc-parser';
|