@opensumi/ide-ai-native 3.7.2-next-1739859371.0 → 3.7.2-next-1740013940.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.
Files changed (243) hide show
  1. package/lib/browser/ai-core.contribution.d.ts +3 -0
  2. package/lib/browser/ai-core.contribution.d.ts.map +1 -1
  3. package/lib/browser/ai-core.contribution.js +68 -2
  4. package/lib/browser/ai-core.contribution.js.map +1 -1
  5. package/lib/browser/chat/chat-model.d.ts +2 -2
  6. package/lib/browser/chat/chat-model.d.ts.map +1 -1
  7. package/lib/browser/chat/chat-model.js +16 -5
  8. package/lib/browser/chat/chat-model.js.map +1 -1
  9. package/lib/browser/chat/chat-proxy.service.d.ts +4 -0
  10. package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
  11. package/lib/browser/chat/chat-proxy.service.js +43 -0
  12. package/lib/browser/chat/chat-proxy.service.js.map +1 -1
  13. package/lib/browser/chat/chat.view.d.ts.map +1 -1
  14. package/lib/browser/chat/chat.view.js +29 -2
  15. package/lib/browser/chat/chat.view.js.map +1 -1
  16. package/lib/browser/components/ChatContext/ContextSelector.d.ts +12 -0
  17. package/lib/browser/components/ChatContext/ContextSelector.d.ts.map +1 -0
  18. package/lib/browser/components/ChatContext/ContextSelector.js +113 -0
  19. package/lib/browser/components/ChatContext/ContextSelector.js.map +1 -0
  20. package/lib/browser/components/ChatContext/index.d.ts +4 -0
  21. package/lib/browser/components/ChatContext/index.d.ts.map +1 -0
  22. package/lib/browser/components/ChatContext/index.js +84 -0
  23. package/lib/browser/components/ChatContext/index.js.map +1 -0
  24. package/lib/browser/components/ChatContext/style.module.less +189 -0
  25. package/lib/browser/components/ChatInput.d.ts.map +1 -1
  26. package/lib/browser/components/ChatInput.js.map +1 -1
  27. package/lib/browser/components/ChatReply.d.ts.map +1 -1
  28. package/lib/browser/components/ChatReply.js +25 -0
  29. package/lib/browser/components/ChatReply.js.map +1 -1
  30. package/lib/browser/components/ChatToolRender.d.ts +6 -0
  31. package/lib/browser/components/ChatToolRender.d.ts.map +1 -0
  32. package/lib/browser/components/ChatToolRender.js +53 -0
  33. package/lib/browser/components/ChatToolRender.js.map +1 -0
  34. package/lib/browser/components/ChatToolRender.module.less +86 -0
  35. package/lib/browser/components/components.module.less +32 -31
  36. package/lib/browser/components/utils.d.ts +2 -2
  37. package/lib/browser/context/llm-context.contribution.d.ts +7 -0
  38. package/lib/browser/context/llm-context.contribution.d.ts.map +1 -0
  39. package/lib/browser/context/llm-context.contribution.js +21 -0
  40. package/lib/browser/context/llm-context.contribution.js.map +1 -0
  41. package/lib/browser/context/llm-context.service.d.ts +24 -0
  42. package/lib/browser/context/llm-context.service.d.ts.map +1 -0
  43. package/lib/browser/context/llm-context.service.js +136 -0
  44. package/lib/browser/context/llm-context.service.js.map +1 -0
  45. package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts +2 -2
  46. package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.d.ts.map +1 -1
  47. package/lib/browser/contrib/intelligent-completions/intelligent-completions.controller.js.map +1 -1
  48. package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts +4 -0
  49. package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.d.ts.map +1 -1
  50. package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js +7 -0
  51. package/lib/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.js.map +1 -1
  52. package/lib/browser/index.d.ts +11 -3
  53. package/lib/browser/index.d.ts.map +1 -1
  54. package/lib/browser/index.js +56 -3
  55. package/lib/browser/index.js.map +1 -1
  56. package/lib/browser/mcp/mcp-server-proxy.service.d.ts +25 -0
  57. package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -0
  58. package/lib/browser/mcp/mcp-server-proxy.service.js +56 -0
  59. package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -0
  60. package/lib/browser/mcp/mcp-server.feature.registry.d.ts +16 -0
  61. package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -0
  62. package/lib/browser/mcp/mcp-server.feature.registry.js +53 -0
  63. package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -0
  64. package/lib/browser/mcp/mcp-tools-dialog.module.less +44 -0
  65. package/lib/browser/mcp/mcp-tools-dialog.view.d.ts +8 -0
  66. package/lib/browser/mcp/mcp-tools-dialog.view.d.ts.map +1 -0
  67. package/lib/browser/mcp/mcp-tools-dialog.view.js +16 -0
  68. package/lib/browser/mcp/mcp-tools-dialog.view.js.map +1 -0
  69. package/lib/browser/mcp/tools/createNewFileWithText.d.ts +9 -0
  70. package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -0
  71. package/lib/browser/mcp/tools/createNewFileWithText.js +83 -0
  72. package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -0
  73. package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts +9 -0
  74. package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +1 -0
  75. package/lib/browser/mcp/tools/findFilesByNameSubstring.js +92 -0
  76. package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +1 -0
  77. package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +8 -0
  78. package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +1 -0
  79. package/lib/browser/mcp/tools/getCurrentFilePath.js +49 -0
  80. package/lib/browser/mcp/tools/getCurrentFilePath.js.map +1 -0
  81. package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts +10 -0
  82. package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -0
  83. package/lib/browser/mcp/tools/getDiagnosticsByPath.js +119 -0
  84. package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -0
  85. package/lib/browser/mcp/tools/getFileTextByPath.d.ts +9 -0
  86. package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +1 -0
  87. package/lib/browser/mcp/tools/getFileTextByPath.js +97 -0
  88. package/lib/browser/mcp/tools/getFileTextByPath.js.map +1 -0
  89. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts +11 -0
  90. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -0
  91. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +119 -0
  92. package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -0
  93. package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +8 -0
  94. package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +1 -0
  95. package/lib/browser/mcp/tools/getOpenEditorFileText.js +50 -0
  96. package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +1 -0
  97. package/lib/browser/mcp/tools/getSelectedText.d.ts +8 -0
  98. package/lib/browser/mcp/tools/getSelectedText.d.ts.map +1 -0
  99. package/lib/browser/mcp/tools/getSelectedText.js +57 -0
  100. package/lib/browser/mcp/tools/getSelectedText.js.map +1 -0
  101. package/lib/browser/mcp/tools/handlers/ListDir.d.ts +21 -0
  102. package/lib/browser/mcp/tools/handlers/ListDir.d.ts.map +1 -0
  103. package/lib/browser/mcp/tools/handlers/ListDir.js +112 -0
  104. package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -0
  105. package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +47 -0
  106. package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -0
  107. package/lib/browser/mcp/tools/handlers/ReadFile.js +147 -0
  108. package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -0
  109. package/lib/browser/mcp/tools/listDir.d.ts +8 -0
  110. package/lib/browser/mcp/tools/listDir.d.ts.map +1 -0
  111. package/lib/browser/mcp/tools/listDir.js +65 -0
  112. package/lib/browser/mcp/tools/listDir.js.map +1 -0
  113. package/lib/browser/mcp/tools/readFile.d.ts +8 -0
  114. package/lib/browser/mcp/tools/readFile.d.ts.map +1 -0
  115. package/lib/browser/mcp/tools/readFile.js +82 -0
  116. package/lib/browser/mcp/tools/readFile.js.map +1 -0
  117. package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +8 -0
  118. package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +1 -0
  119. package/lib/browser/mcp/tools/replaceOpenEditorFile.js +79 -0
  120. package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +1 -0
  121. package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +8 -0
  122. package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +1 -0
  123. package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +84 -0
  124. package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +1 -0
  125. package/lib/browser/mcp/tools/runTerminalCmd.d.ts +18 -0
  126. package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -0
  127. package/lib/browser/mcp/tools/runTerminalCmd.js +96 -0
  128. package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -0
  129. package/lib/browser/preferences/schema.d.ts.map +1 -1
  130. package/lib/browser/preferences/schema.js +60 -0
  131. package/lib/browser/preferences/schema.js.map +1 -1
  132. package/lib/browser/types.d.ts +64 -3
  133. package/lib/browser/types.d.ts.map +1 -1
  134. package/lib/browser/types.js +5 -1
  135. package/lib/browser/types.js.map +1 -1
  136. package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js +1 -1
  137. package/lib/browser/widget/inline-chat/inline-chat-editor.controller.js.map +1 -1
  138. package/lib/browser/widget/inline-diff/inline-diff.controller.d.ts.map +1 -1
  139. package/lib/browser/widget/inline-input/inline-input.controller.d.ts.map +1 -1
  140. package/lib/common/index.d.ts +9 -0
  141. package/lib/common/index.d.ts.map +1 -1
  142. package/lib/common/index.js +4 -1
  143. package/lib/common/index.js.map +1 -1
  144. package/lib/common/llm-context.d.ts +37 -0
  145. package/lib/common/llm-context.d.ts.map +1 -0
  146. package/lib/common/llm-context.js +5 -0
  147. package/lib/common/llm-context.js.map +1 -0
  148. package/lib/common/mcp-server-manager.d.ts +40 -0
  149. package/lib/common/mcp-server-manager.d.ts.map +1 -0
  150. package/lib/common/mcp-server-manager.js +6 -0
  151. package/lib/common/mcp-server-manager.js.map +1 -0
  152. package/lib/common/tool-invocation-registry.d.ts +91 -0
  153. package/lib/common/tool-invocation-registry.d.ts.map +1 -0
  154. package/lib/common/tool-invocation-registry.js +90 -0
  155. package/lib/common/tool-invocation-registry.js.map +1 -0
  156. package/lib/common/types.d.ts +17 -0
  157. package/lib/common/types.d.ts.map +1 -1
  158. package/lib/node/anthropic/anthropic-language-model.d.ts +9 -0
  159. package/lib/node/anthropic/anthropic-language-model.d.ts.map +1 -0
  160. package/lib/node/anthropic/anthropic-language-model.js +26 -0
  161. package/lib/node/anthropic/anthropic-language-model.js.map +1 -0
  162. package/lib/node/base-language-model.d.ts +14 -0
  163. package/lib/node/base-language-model.d.ts.map +1 -0
  164. package/lib/node/base-language-model.js +136 -0
  165. package/lib/node/base-language-model.js.map +1 -0
  166. package/lib/node/deepseek/deepseek-language-model.d.ts +9 -0
  167. package/lib/node/deepseek/deepseek-language-model.d.ts.map +1 -0
  168. package/lib/node/deepseek/deepseek-language-model.js +26 -0
  169. package/lib/node/deepseek/deepseek-language-model.js.map +1 -0
  170. package/lib/node/index.d.ts.map +1 -1
  171. package/lib/node/index.js +19 -0
  172. package/lib/node/index.js.map +1 -1
  173. package/lib/node/mcp/sumi-mcp-server.d.ts +91 -0
  174. package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -0
  175. package/lib/node/mcp/sumi-mcp-server.js +172 -0
  176. package/lib/node/mcp/sumi-mcp-server.js.map +1 -0
  177. package/lib/node/mcp-server-manager-impl.d.ts +27 -0
  178. package/lib/node/mcp-server-manager-impl.d.ts.map +1 -0
  179. package/lib/node/mcp-server-manager-impl.js +127 -0
  180. package/lib/node/mcp-server-manager-impl.js.map +1 -0
  181. package/lib/node/mcp-server.d.ts +207 -0
  182. package/lib/node/mcp-server.d.ts.map +1 -0
  183. package/lib/node/mcp-server.js +91 -0
  184. package/lib/node/mcp-server.js.map +1 -0
  185. package/lib/node/openai/openai-language-model.d.ts +9 -0
  186. package/lib/node/openai/openai-language-model.d.ts.map +1 -0
  187. package/lib/node/openai/openai-language-model.js +29 -0
  188. package/lib/node/openai/openai-language-model.js.map +1 -0
  189. package/package.json +34 -22
  190. package/src/browser/ai-core.contribution.ts +77 -1
  191. package/src/browser/chat/chat-model.ts +24 -6
  192. package/src/browser/chat/chat-proxy.service.ts +42 -0
  193. package/src/browser/chat/chat.view.tsx +59 -6
  194. package/src/browser/components/ChatContext/ContextSelector.tsx +177 -0
  195. package/src/browser/components/ChatContext/index.tsx +135 -0
  196. package/src/browser/components/ChatContext/style.module.less +189 -0
  197. package/src/browser/components/ChatInput.tsx +1 -0
  198. package/src/browser/components/ChatReply.tsx +32 -0
  199. package/src/browser/components/ChatToolRender.module.less +86 -0
  200. package/src/browser/components/ChatToolRender.tsx +77 -0
  201. package/src/browser/components/components.module.less +32 -31
  202. package/src/browser/context/llm-context.contribution.ts +14 -0
  203. package/src/browser/context/llm-context.service.ts +156 -0
  204. package/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts +2 -3
  205. package/src/browser/contrib/intelligent-completions/intelligent-completions.feature.registry.ts +11 -0
  206. package/src/browser/index.ts +68 -4
  207. package/src/browser/mcp/mcp-server-proxy.service.ts +53 -0
  208. package/src/browser/mcp/mcp-server.feature.registry.ts +54 -0
  209. package/src/browser/mcp/mcp-tools-dialog.module.less +44 -0
  210. package/src/browser/mcp/mcp-tools-dialog.view.tsx +24 -0
  211. package/src/browser/mcp/tools/createNewFileWithText.ts +83 -0
  212. package/src/browser/mcp/tools/findFilesByNameSubstring.ts +93 -0
  213. package/src/browser/mcp/tools/getCurrentFilePath.ts +49 -0
  214. package/src/browser/mcp/tools/getDiagnosticsByPath.ts +123 -0
  215. package/src/browser/mcp/tools/getFileTextByPath.ts +97 -0
  216. package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +121 -0
  217. package/src/browser/mcp/tools/getOpenEditorFileText.ts +50 -0
  218. package/src/browser/mcp/tools/getSelectedText.ts +57 -0
  219. package/src/browser/mcp/tools/handlers/ListDir.ts +117 -0
  220. package/src/browser/mcp/tools/handlers/ReadFile.ts +174 -0
  221. package/src/browser/mcp/tools/listDir.ts +66 -0
  222. package/src/browser/mcp/tools/readFile.ts +82 -0
  223. package/src/browser/mcp/tools/replaceOpenEditorFile.ts +80 -0
  224. package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +91 -0
  225. package/src/browser/mcp/tools/runTerminalCmd.ts +107 -0
  226. package/src/browser/preferences/schema.ts +60 -0
  227. package/src/browser/types.ts +92 -3
  228. package/src/browser/widget/inline-chat/inline-chat-editor.controller.ts +1 -1
  229. package/src/browser/widget/inline-diff/inline-diff.controller.ts +1 -1
  230. package/src/browser/widget/inline-input/inline-input.controller.ts +1 -1
  231. package/src/common/index.ts +14 -0
  232. package/src/common/llm-context.ts +41 -0
  233. package/src/common/mcp-server-manager.ts +46 -0
  234. package/src/common/tool-invocation-registry.ts +170 -0
  235. package/src/common/types.ts +22 -0
  236. package/src/node/anthropic/anthropic-language-model.ts +25 -0
  237. package/src/node/base-language-model.ts +163 -0
  238. package/src/node/deepseek/deepseek-language-model.ts +25 -0
  239. package/src/node/index.ts +21 -0
  240. package/src/node/mcp/sumi-mcp-server.ts +197 -0
  241. package/src/node/mcp-server-manager-impl.ts +148 -0
  242. package/src/node/mcp-server.ts +126 -0
  243. package/src/node/openai/openai-language-model.ts +25 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReadFileTool = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const zod_1 = require("zod");
6
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
7
+ const di_1 = require("@opensumi/di");
8
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
9
+ const types_1 = require("../../types");
10
+ const ReadFile_1 = require("./handlers/ReadFile");
11
+ const inputSchema = zod_1.z
12
+ .object({
13
+ relative_workspace_path: zod_1.z.string().describe('The path of the file to read, relative to the workspace root.'),
14
+ should_read_entire_file: zod_1.z.boolean().describe('Whether to read the entire file. Defaults to false.'),
15
+ start_line_one_indexed: zod_1.z.number().describe('The one-indexed line number to start reading from (inclusive).'),
16
+ end_line_one_indexed_inclusive: zod_1.z.number().describe('The one-indexed line number to end reading at (inclusive).'),
17
+ explanation: zod_1.z
18
+ .string()
19
+ .describe('One sentence explanation as to why this tool is being used, and how it contributes to the goal.'),
20
+ })
21
+ .transform((data) => ({
22
+ relativeWorkspacePath: data.relative_workspace_path,
23
+ readEntireFile: data.should_read_entire_file,
24
+ startLineOneIndexed: data.start_line_one_indexed,
25
+ endLineOneIndexedInclusive: data.end_line_one_indexed_inclusive,
26
+ }));
27
+ let ReadFileTool = class ReadFileTool {
28
+ registerMCPServer(registry) {
29
+ registry.registerMCPTool(this.getToolDefinition());
30
+ }
31
+ getToolDefinition() {
32
+ return {
33
+ name: 'read_file',
34
+ description: `Read the contents of a file (and the outline).
35
+
36
+ When using this tool to gather information, it's your responsibility to ensure you have the COMPLETE context. Each time you call this command you should:
37
+ 1) Assess if contents viewed are sufficient to proceed with the task.
38
+ 2) Take note of lines not shown.
39
+ 3) If file contents viewed are insufficient, and you suspect they may be in lines not shown, proactively call the tool again to view those lines.
40
+ 4) When in doubt, call this tool again to gather more information. Partial file views may miss critical dependencies, imports, or functionality.
41
+
42
+ If reading a range of lines is not enough, you may choose to read the entire file.
43
+ Reading entire files is often wasteful and slow, especially for large files (i.e. more than a few hundred lines). So you should use this option sparingly.
44
+ Reading the entire file is not allowed in most cases. You are only allowed to read the entire file if it has been edited or manually attached to the conversation by the user.`,
45
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
46
+ handler: this.handler.bind(this),
47
+ };
48
+ }
49
+ async handler(args, logger) {
50
+ // TODO: 应该添加统一的 validate 逻辑
51
+ args = inputSchema.parse(args);
52
+ const result = await this.fileHandler.readFile(args);
53
+ return {
54
+ content: [
55
+ {
56
+ type: 'text',
57
+ text: result.didShortenLineRange
58
+ ? `Contents of ${result.relativeWorkspacePath}, from line ${args.startLineOneIndexed}-${args.endLineOneIndexedInclusive}:
59
+
60
+ \`\`\`
61
+ // ${result.relativeWorkspacePath.split('/').pop()}
62
+ ${result.contents}
63
+ \`\`\``
64
+ : `Full contents of ${args.relativeWorkspacePath}:
65
+
66
+ \`\`\`
67
+ ${result.contents}
68
+ \`\`\``,
69
+ },
70
+ ],
71
+ };
72
+ }
73
+ };
74
+ exports.ReadFileTool = ReadFileTool;
75
+ tslib_1.__decorate([
76
+ (0, di_1.Autowired)(ReadFile_1.FileHandler),
77
+ tslib_1.__metadata("design:type", ReadFile_1.FileHandler)
78
+ ], ReadFileTool.prototype, "fileHandler", void 0);
79
+ exports.ReadFileTool = ReadFileTool = tslib_1.__decorate([
80
+ (0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
81
+ ], ReadFileTool);
82
+ //# sourceMappingURL=readFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFile.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/readFile.ts"],"names":[],"mappings":";;;;AAAA,6BAAwB;AACxB,2DAAqD;AAErD,qCAAyC;AACzC,+DAAmD;AAEnD,uCAAsG;AAEtG,kDAAkD;AAElD,MAAM,WAAW,GAAG,OAAC;KAClB,MAAM,CAAC;IACN,uBAAuB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;IAC7G,uBAAuB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACpG,sBAAsB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IAC7G,8BAA8B,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4DAA4D,CA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AAC,oBAAoB,IAAI,CAAC,qBAAqB;;;EAG1D,MAAM,CAAC,QAAQ;OACV;iBACE;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,oCAAY;AAEN;IADhB,IAAA,cAAS,EAAC,sBAAW,CAAC;sCACO,sBAAW;iDAAC;uBAF/B,YAAY;IADxB,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,YAAY,CAqDxB"}
@@ -0,0 +1,8 @@
1
+ import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
2
+ export declare class ReplaceOpenEditorFileTool implements MCPServerContribution {
3
+ private readonly editorService;
4
+ registerMCPServer(registry: IMCPServerRegistry): void;
5
+ getToolDefinition(): MCPToolDefinition;
6
+ private handler;
7
+ }
8
+ //# sourceMappingURL=replaceOpenEditorFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceOpenEditorFile.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/replaceOpenEditorFile.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMtG,qBACa,yBAA0B,YAAW,qBAAqB;IAErE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAgBxB,OAAO;CAyCtB"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReplaceOpenEditorFileTool = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const zod_1 = require("zod");
6
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
7
+ const di_1 = require("@opensumi/di");
8
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
9
+ const ide_editor_1 = require("@opensumi/ide-editor");
10
+ const types_1 = require("../../types");
11
+ const inputSchema = zod_1.z.object({
12
+ text: zod_1.z.string().describe('The new content to replace the entire file with'),
13
+ });
14
+ let ReplaceOpenEditorFileTool = class ReplaceOpenEditorFileTool {
15
+ registerMCPServer(registry) {
16
+ registry.registerMCPTool(this.getToolDefinition());
17
+ }
18
+ getToolDefinition() {
19
+ return {
20
+ name: 'replace_open_in_editor_file_text',
21
+ description: 'Replaces the entire content of the currently active file in the IDE editor with specified new text. ' +
22
+ 'Use this tool when you need to completely overwrite the current file\'s content. ' +
23
+ 'Requires a text parameter containing the new content. ' +
24
+ 'Returns one of three possible responses: ' +
25
+ '"ok" if the file content was successfully replaced, ' +
26
+ '"no file open" if no editor is active, ' +
27
+ '"unknown error" if the operation fails.',
28
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
29
+ handler: this.handler.bind(this),
30
+ };
31
+ }
32
+ async handler(args, logger) {
33
+ try {
34
+ const editor = this.editorService.currentEditor;
35
+ if (!editor || !editor.monacoEditor) {
36
+ logger.appendLine('Error: No active text editor found');
37
+ return {
38
+ content: [{ type: 'text', text: 'no file open' }],
39
+ isError: true,
40
+ };
41
+ }
42
+ // Get the model and its full range
43
+ const model = editor.monacoEditor.getModel();
44
+ if (!model) {
45
+ logger.appendLine('Error: No model found for current editor');
46
+ return {
47
+ content: [{ type: 'text', text: 'unknown error' }],
48
+ isError: true,
49
+ };
50
+ }
51
+ const fullRange = model.getFullModelRange();
52
+ // Execute the replacement
53
+ editor.monacoEditor.executeEdits('mcp.tool.replace-file', [{
54
+ range: fullRange,
55
+ text: args.text,
56
+ }]);
57
+ logger.appendLine('Successfully replaced file content');
58
+ return {
59
+ content: [{ type: 'text', text: 'ok' }],
60
+ };
61
+ }
62
+ catch (error) {
63
+ logger.appendLine(`Error during file content replacement: ${error}`);
64
+ return {
65
+ content: [{ type: 'text', text: 'unknown error' }],
66
+ isError: true,
67
+ };
68
+ }
69
+ }
70
+ };
71
+ exports.ReplaceOpenEditorFileTool = ReplaceOpenEditorFileTool;
72
+ tslib_1.__decorate([
73
+ (0, di_1.Autowired)(ide_editor_1.WorkbenchEditorService),
74
+ tslib_1.__metadata("design:type", ide_editor_1.WorkbenchEditorService)
75
+ ], ReplaceOpenEditorFileTool.prototype, "editorService", void 0);
76
+ exports.ReplaceOpenEditorFileTool = ReplaceOpenEditorFileTool = tslib_1.__decorate([
77
+ (0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
78
+ ], ReplaceOpenEditorFileTool);
79
+ //# sourceMappingURL=replaceOpenEditorFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceOpenEditorFile.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/replaceOpenEditorFile.ts"],"names":[],"mappings":";;;;AAAA,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAmD;AACnD,qDAA8D;AAE9D,uCAAsG;AAEtG,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;CAC7E,CAAC,CAAC;AAGI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAIpC,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB;QACf,OAAO;YACL,IAAI,EAAE,kCAAkC;YACxC,WAAW,EACT,sGAAsG;gBACtG,mFAAmF;gBACnF,wDAAwD;gBACxD,2CAA2C;gBAC3C,sDAAsD;gBACtD,yCAAyC;gBACzC,yCAAyC;YAC3C,WAAW,EAAE,IAAA,oCAAe,EAAC,WAAW,CAAC;YACzC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;SACjC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAiC,EAAE,MAAiB;QACxE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,a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C;IACH,CAAC;CACF,CAAA;AAjEY,8DAAyB;AAEnB;IADhB,IAAA,cAAS,EAAC,mCAAsB,CAAC;sCACF,mCAAsB;gEAAC;oCAF5C,yBAAyB;IADrC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,yBAAyB,CAiErC"}
@@ -0,0 +1,8 @@
1
+ import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
2
+ export declare class ReplaceOpenEditorFileByDiffPreviewerTool implements MCPServerContribution {
3
+ private readonly editorService;
4
+ registerMCPServer(registry: IMCPServerRegistry): void;
5
+ getToolDefinition(): MCPToolDefinition;
6
+ private handler;
7
+ }
8
+ //# sourceMappingURL=replaceOpenEditorFileByDiffPreviewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceOpenEditorFileByDiffPreviewer.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQtG,qBACa,wCAAyC,YAAW,qBAAqB;IAEpF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;YAgBxB,OAAO;CAiDtB"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReplaceOpenEditorFileByDiffPreviewerTool = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const zod_1 = require("zod");
6
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
7
+ const di_1 = require("@opensumi/di");
8
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
9
+ const ide_editor_1 = require("@opensumi/ide-editor");
10
+ const selection_1 = require("@opensumi/monaco-editor-core/esm/vs/editor/common/core/selection");
11
+ const types_1 = require("../../types");
12
+ const inline_diff_controller_1 = require("../../widget/inline-diff/inline-diff.controller");
13
+ const inputSchema = zod_1.z.object({
14
+ text: zod_1.z.string().describe('The new content to replace the entire file with'),
15
+ });
16
+ let ReplaceOpenEditorFileByDiffPreviewerTool = class ReplaceOpenEditorFileByDiffPreviewerTool {
17
+ registerMCPServer(registry) {
18
+ registry.registerMCPTool(this.getToolDefinition());
19
+ }
20
+ getToolDefinition() {
21
+ return {
22
+ name: 'replace_open_in_editor_file_text',
23
+ description: 'Replaces the entire content of the currently active file in the IDE editor with specified new text using diff previewer. ' +
24
+ "Use this tool when you need to completely overwrite the current file's content with diff preview. " +
25
+ 'Requires a text parameter containing the new content. ' +
26
+ 'Returns one of three possible responses: ' +
27
+ '"ok" if the file content was successfully replaced, ' +
28
+ '"no file open" if no editor is active, ' +
29
+ '"unknown error" if the operation fails.',
30
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
31
+ handler: this.handler.bind(this),
32
+ };
33
+ }
34
+ async handler(args, logger) {
35
+ try {
36
+ const editor = this.editorService.currentEditor;
37
+ if (!editor || !editor.monacoEditor) {
38
+ logger.appendLine('Error: No active text editor found');
39
+ return {
40
+ content: [{ type: 'text', text: 'no file open' }],
41
+ isError: true,
42
+ };
43
+ }
44
+ // Get the model and its full range
45
+ const model = editor.monacoEditor.getModel();
46
+ if (!model) {
47
+ logger.appendLine('Error: No model found for current editor');
48
+ return {
49
+ content: [{ type: 'text', text: 'unknown error' }],
50
+ isError: true,
51
+ };
52
+ }
53
+ const fullRange = model.getFullModelRange();
54
+ const inlineDiffHandler = inline_diff_controller_1.InlineDiffController.get(editor.monacoEditor);
55
+ // Create diff previewer
56
+ const previewer = inlineDiffHandler.createDiffPreviewer(editor.monacoEditor, selection_1.Selection.fromRange(fullRange, selection_1.SelectionDirection.LTR), {
57
+ disposeWhenEditorClosed: false,
58
+ renderRemovedWidgetImmediately: true,
59
+ });
60
+ // Set the new content
61
+ previewer.setValue(args.text);
62
+ logger.appendLine('Successfully created diff preview with new content');
63
+ return {
64
+ content: [{ type: 'text', text: 'ok' }],
65
+ };
66
+ }
67
+ catch (error) {
68
+ logger.appendLine(`Error during file content replacement: ${error}`);
69
+ return {
70
+ content: [{ type: 'text', text: 'unknown error' }],
71
+ isError: true,
72
+ };
73
+ }
74
+ }
75
+ };
76
+ exports.ReplaceOpenEditorFileByDiffPreviewerTool = ReplaceOpenEditorFileByDiffPreviewerTool;
77
+ tslib_1.__decorate([
78
+ (0, di_1.Autowired)(ide_editor_1.WorkbenchEditorService),
79
+ tslib_1.__metadata("design:type", ide_editor_1.WorkbenchEditorService)
80
+ ], ReplaceOpenEditorFileByDiffPreviewerTool.prototype, "editorService", void 0);
81
+ exports.ReplaceOpenEditorFileByDiffPreviewerTool = ReplaceOpenEditorFileByDiffPreviewerTool = tslib_1.__decorate([
82
+ (0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
83
+ ], ReplaceOpenEditorFileByDiffPreviewerTool);
84
+ //# sourceMappingURL=replaceOpenEditorFileByDiffPreviewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceOpenEditorFileByDiffPreviewer.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts"],"names":[],"mappings":";;;;AAAA,6BAAwB;AACxB,2DAAqD;AAErD,qCAAqD;AACrD,+DAAmD;AACnD,qDAA8D;AAC9D,gGAAiH;AAEjH,uCAAsG;AAEtG,4FAAuF;AAEvF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;CAC7E,CAAC,CAAC;AAGI,IAAM,wCAAwC,GAA9C,MAAM,wCAAwC;IAInD,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB;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,EACnB,qBAAS,CAAC,SAAS,CAAC,SAAS,EAAE,8BAAkB,CAAC,GAAG,CAAC,EACtD;gBACE,uBAAuB,EAAE,KAAK;gBAC9B,8BAA8B,EAAE,IAAI;aACrC,CACyB,CAAC;YAE7B,sBAAsB;YACtB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE9B,MAAM,CAAC,UAAU,CAAC,oDAAoD,CAAC,CAAC;YACxE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aACxC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,UAAU,CAAC,0CAA0C,KAAK,EAAE,CAAC,CAAC;YACrE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;gBAClD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAzEY,4FAAwC;AAElC;IADhB,IAAA,cAAS,EAAC,mCAAsB,CAAC;sCACF,mCAAsB;+EAAC;mDAF5C,wCAAwC;IADpD,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,wCAAwC,CAyEpD"}
@@ -0,0 +1,18 @@
1
+ import { AppConfig } from '@opensumi/ide-core-browser';
2
+ import { ITerminalController, ITerminalGroupViewService } from '@opensumi/ide-terminal-next/lib/common/controller';
3
+ import { IMCPServerRegistry, MCPServerContribution, MCPToolDefinition } from '../../types';
4
+ export declare class RunTerminalCommandTool implements MCPServerContribution {
5
+ protected readonly terminalController: ITerminalController;
6
+ protected readonly appConfig: AppConfig;
7
+ protected readonly terminalView: ITerminalGroupViewService;
8
+ private terminalId;
9
+ registerMCPServer(registry: IMCPServerRegistry): void;
10
+ getToolDefinition(): MCPToolDefinition;
11
+ getShellLaunchConfig(command: string): {
12
+ name: string;
13
+ cwd: string;
14
+ args: string[];
15
+ };
16
+ private handler;
17
+ }
18
+ //# sourceMappingURL=runTerminalCmd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runTerminalCmd.d.ts","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/runTerminalCmd.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAEnH,OAAO,EAAE,kBAAkB,EAAa,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAoBtG,qBACa,sBAAuB,YAAW,qBAAqB;IAElE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IAG3D,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAGxC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,yBAAyB,CAAC;IAE3D,OAAO,CAAC,UAAU,CAAK;IAEvB,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAIrD,iBAAiB,IAAI,iBAAiB;IAUtC,oBAAoB,CAAC,OAAO,EAAE,MAAM;;;;;YAQtB,OAAO;CA2CtB"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunTerminalCommandTool = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const zod_1 = require("zod");
6
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
7
+ const di_1 = require("@opensumi/di");
8
+ const ide_core_browser_1 = require("@opensumi/ide-core-browser");
9
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
10
+ const controller_1 = require("@opensumi/ide-terminal-next/lib/common/controller");
11
+ const types_1 = require("../../types");
12
+ const color = {
13
+ italic: '\x1b[3m',
14
+ reset: '\x1b[0m',
15
+ };
16
+ const inputSchema = zod_1.z.object({
17
+ command: zod_1.z.string().describe('The terminal command to execute'),
18
+ is_background: zod_1.z.boolean().describe('Whether the command should be run in the background'),
19
+ explanation: zod_1.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: zod_1.z
23
+ .boolean()
24
+ .describe("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."),
25
+ });
26
+ let RunTerminalCommandTool = class RunTerminalCommandTool {
27
+ constructor() {
28
+ this.terminalId = 0;
29
+ }
30
+ registerMCPServer(registry) {
31
+ registry.registerMCPTool(this.getToolDefinition());
32
+ }
33
+ getToolDefinition() {
34
+ return {
35
+ name: 'run_terminal_cmd',
36
+ description: "PROPOSE a command to run on behalf of the user.\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\n\nAdhere to these rules:\n1. Based on the contents of the conversation, you will be told if you are in the same shell as a previous step or a new shell.\n2. If in a new shell, you should `cd` to the right directory and do necessary setup in addition to running the command.\n3. If in the same shell, the state will persist, no need to do things like `cd` to the same directory.\n4. For ANY commands that would use a pager, you should append ` | cat` to the command (or whatever is appropriate). You MUST do this for: git, less, head, tail, more, etc.\n5. For commands that are long running/expected to run indefinitely until interruption, please run them in the background. To run jobs in the background, set `is_background` to true rather than changing the details of the command.\n6. Dont include any newlines in the command.",
37
+ inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema),
38
+ handler: this.handler.bind(this),
39
+ };
40
+ }
41
+ getShellLaunchConfig(command) {
42
+ return {
43
+ name: `MCP:Terminal_${this.terminalId++}`,
44
+ cwd: this.appConfig.workspaceDir,
45
+ args: ['-c', command],
46
+ };
47
+ }
48
+ async handler(args, logger) {
49
+ if (args.require_user_approval) {
50
+ // FIXME: support approval
51
+ }
52
+ const terminalClient = await this.terminalController.createTerminalWithWidget({
53
+ config: this.getShellLaunchConfig(args.command),
54
+ closeWhenExited: false,
55
+ });
56
+ this.terminalController.showTerminalPanel();
57
+ const result = [];
58
+ const def = new ide_core_common_1.Deferred();
59
+ terminalClient.onOutput((e) => {
60
+ result.push({
61
+ type: 'output',
62
+ text: e.data.toString(),
63
+ });
64
+ });
65
+ terminalClient.onExit((e) => {
66
+ const isError = e.code !== 0;
67
+ def.resolve({
68
+ isError,
69
+ content: result,
70
+ });
71
+ terminalClient.term.writeln(`\n${color.italic}> Command ${args.command} executed successfully. Terminal will close in ${3000 / 1000} seconds.${color.reset}\n`);
72
+ setTimeout(() => {
73
+ terminalClient.dispose();
74
+ this.terminalView.removeWidget(terminalClient.id);
75
+ }, 3000);
76
+ });
77
+ return def.promise;
78
+ }
79
+ };
80
+ exports.RunTerminalCommandTool = RunTerminalCommandTool;
81
+ tslib_1.__decorate([
82
+ (0, di_1.Autowired)(controller_1.ITerminalController),
83
+ tslib_1.__metadata("design:type", Object)
84
+ ], RunTerminalCommandTool.prototype, "terminalController", void 0);
85
+ tslib_1.__decorate([
86
+ (0, di_1.Autowired)(ide_core_browser_1.AppConfig),
87
+ tslib_1.__metadata("design:type", Object)
88
+ ], RunTerminalCommandTool.prototype, "appConfig", void 0);
89
+ tslib_1.__decorate([
90
+ (0, di_1.Autowired)(controller_1.ITerminalGroupViewService),
91
+ tslib_1.__metadata("design:type", Object)
92
+ ], RunTerminalCommandTool.prototype, "terminalView", void 0);
93
+ exports.RunTerminalCommandTool = RunTerminalCommandTool = tslib_1.__decorate([
94
+ (0, ide_core_common_1.Domain)(types_1.MCPServerContribution)
95
+ ], RunTerminalCommandTool);
96
+ //# sourceMappingURL=runTerminalCmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runTerminalCmd.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/runTerminalCmd.ts"],"names":[],"mappings":";;;;AAAA,6BAAwB;AACxB,2DAAqD;AAErD,qCAAyC;AACzC,iEAAuD;AACvD,+DAA6D;AAC7D,kFAAmH;AAEnH,uCAAsG;AAEtG,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,SAAS;IACjB,KAAK,EA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yB,CAAC;;4DACsB;iCARhD,sBAAsB;IADlC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,sBAAsB,CA6ElC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGzF,oBAAY,sBAAsB;IAChC,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,EAAE,gBAyDtC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAGzF,oBAAY,sBAAsB;IAChC,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,EAAE,gBAqHtC,CAAC"}
@@ -60,6 +60,66 @@ exports.aiNativePreferenceSchema = {
60
60
  type: 'boolean',
61
61
  default: false,
62
62
  },
63
+ [ide_core_browser_1.AINativeSettingSectionsId.LLMModelSelection]: {
64
+ type: 'string',
65
+ default: 'deepseek',
66
+ enum: ['deepseek', 'anthropic', 'openai'],
67
+ description: (0, ide_core_common_1.localize)('preference.ai.native.llm.model.selection.description'),
68
+ },
69
+ [ide_core_browser_1.AINativeSettingSectionsId.DeepseekApiKey]: {
70
+ type: 'string',
71
+ default: '',
72
+ description: (0, ide_core_common_1.localize)('preference.ai.native.deepseek.apiKey.description'),
73
+ },
74
+ [ide_core_browser_1.AINativeSettingSectionsId.AnthropicApiKey]: {
75
+ type: 'string',
76
+ default: '',
77
+ description: (0, ide_core_common_1.localize)('preference.ai.native.anthropic.apiKey.description'),
78
+ },
79
+ [ide_core_browser_1.AINativeSettingSectionsId.OpenaiApiKey]: {
80
+ type: 'string',
81
+ default: '',
82
+ description: (0, ide_core_common_1.localize)('preference.ai.native.openai.apiKey.description'),
83
+ },
84
+ [ide_core_browser_1.AINativeSettingSectionsId.OpenaiBaseURL]: {
85
+ type: 'string',
86
+ default: '',
87
+ description: (0, ide_core_common_1.localize)('preference.ai.native.openai.baseURL.description'),
88
+ },
89
+ [ide_core_browser_1.AINativeSettingSectionsId.MCPServers]: {
90
+ type: 'array',
91
+ default: [],
92
+ description: (0, ide_core_common_1.localize)('preference.ai.native.mcp.servers.description'),
93
+ items: {
94
+ type: 'object',
95
+ required: ['name', 'command', 'args'],
96
+ properties: {
97
+ name: {
98
+ type: 'string',
99
+ description: (0, ide_core_common_1.localize)('preference.ai.native.mcp.servers.name.description'),
100
+ },
101
+ command: {
102
+ type: 'string',
103
+ description: (0, ide_core_common_1.localize)('preference.ai.native.mcp.servers.command.description'),
104
+ },
105
+ args: {
106
+ type: 'array',
107
+ items: {
108
+ type: 'string',
109
+ },
110
+ description: (0, ide_core_common_1.localize)('preference.ai.native.mcp.servers.args.description'),
111
+ },
112
+ env: {
113
+ type: 'object',
114
+ additionalProperties: {
115
+ type: 'string',
116
+ },
117
+ description: (0, ide_core_common_1.localize)('preference.ai.native.mcp.servers.env.description'),
118
+ default: {},
119
+ },
120
+ },
121
+ },
122
+ },
63
123
  [ide_core_browser_1.AINativeSettingSectionsId.CodeEditsTyping]: {
64
124
  type: 'boolean',
65
125
  default: false,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":";;;AAAA,iEAAyF;AACzF,+DAAqD;AAErD,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,mDAAyB,CAAA;IACzB,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAEY,QAAA,wBAAwB,GAAqB;IACxD,UAAU,EAAE;QACV,CAAC,4CAAyB,CAAC,qBAAqB,CAAC,EAAE;YACjD,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,sBAAs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a,CAAC,EAAE;YACzC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,IAAA,0BAAQ,EAAC,iDAAiD,CAAC;SACzE;QACD,CAAC,4CAAyB,CAAC,UAAU,CAAC,EAAE;YACtC,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,IAAA,0BAAQ,EAAC,8CAA8C,CAAC;YACrE,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC;gBACrC,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,IAAA,0BAAQ,EAAC,mDAAmD,CAAC;qBAC3E;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,IAAA,0BAAQ,EAAC,sDAAsD,CAAC;qBAC9E;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;wBACD,WAAW,EAAE,IAAA,0BAAQ,EAAC,mDAAmD,CAAC;qBAC3E;oBACD,GAAG,EAAE;wBACH,IAAI,EAAE,QAAQ;wBACd,oBAAoB,EAAE;4BACpB,IAAI,EAAE,QAAQ;yBACf;wBACD,WAAW,EAAE,IAAA,0BAAQ,EAAC,kDAAkD,CAAC;wBACzE,OAAO,EAAE,EAAE;qBACZ;iBACF;aACF;SACF;QACD,CAAC,4CAAyB,CAAC,eAAe,CAAC,EAAE;YAC3C,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;SACf;KACF;CACF,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native/index';
3
3
  import { CancellationToken, ChatResponse, Deferred, IAICompletionOption, IAICompletionResultModel, IDisposable, IPosition, IResolveConflictHandler, MaybePromise, MergeConflictEditorMode } from '@opensumi/ide-core-common';
4
- import { ICodeEditor, IRange, ISelection, ITextModel, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
4
+ import { ICodeEditor, IRange, ISelection, ITextModel, InlineEditProvider, NewSymbolNamesProvider, Position } from '@opensumi/ide-monaco';
5
5
  import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
6
6
  import { IMarker } from '@opensumi/monaco-editor-core/esm/vs/platform/markers/common/markers';
7
7
  import { IChatWelcomeMessageContent, ISampleQuestions, ITerminalCommandSuggestionDesc } from '../common';
8
+ import { SerializedContext } from '../common/llm-context';
8
9
  import { ICodeEditsContextBean, ICodeEditsResult, IIntelligentCompletionsResult } from './contrib/intelligent-completions';
9
10
  import { BaseTerminalDetectionLineMatcher } from './contrib/terminal/matcher';
10
11
  import { InlineChatController } from './widget/inline-chat/inline-chat-controller';
@@ -176,14 +177,30 @@ export interface ITerminalProviderRegistry {
176
177
  }
177
178
  export type IIntelligentCompletionProvider = (editor: ICodeEditor, position: IPosition, contextBean: IAICompletionOption, token: CancellationToken) => MaybePromise<IIntelligentCompletionsResult>;
178
179
  export type ICodeEditsProvider = (editor: ICodeEditor, position: IPosition, contextBean: ICodeEditsContextBean, token: CancellationToken) => MaybePromise<ICodeEditsResult | undefined>;
180
+ export type IIntelligentInlineEditProvider = (editor: ICodeEditor, position: IPosition, contextBean: IAICompletionOption, token: CancellationToken) => MaybePromise<IIntelligentCompletionsResult>;
181
+ /**
182
+ * Interface for registering intelligent completion providers and code edits providers.
183
+ */
179
184
  export interface IIntelligentCompletionsRegistry {
180
185
  /**
181
- * @deprecated use registerInlineCompletionProvider API
186
+ * Registers an intelligent completion provider.
187
+ * @deprecated Use the `registerInlineCompletionsProvider` method instead.
188
+ * @param provider - The intelligent completion provider to register.
182
189
  */
183
190
  registerIntelligentCompletionProvider(provider: IIntelligentCompletionProvider): void;
191
+ /**
192
+ * Registers an inline completions provider.
193
+ * @param provider - The intelligent completion provider to register.
194
+ */
184
195
  registerInlineCompletionsProvider(provider: IIntelligentCompletionProvider): void;
185
196
  /**
186
- * 注册 code edits 功能
197
+ * Registers an inline edit provider.
198
+ * @param provider The inline edit provider to register.
199
+ */
200
+ registerInlineEditProvider(provider: InlineEditProvider): void;
201
+ /**
202
+ * Registers a code edits provider.
203
+ * @param provider - The code edits provider to register.
187
204
  */
188
205
  registerCodeEditsProvider(provider: ICodeEditsProvider): void;
189
206
  }
@@ -224,6 +241,42 @@ export interface AINativeCoreContribution {
224
241
  * proposed api
225
242
  */
226
243
  registerIntelligentCompletionFeature?(registry: IIntelligentCompletionsRegistry): void;
244
+ /**
245
+ * 注册 Agent 模式下的 chat prompt provider
246
+ * @param provider
247
+ */
248
+ registerChatAgentPromptProvider?(): void;
249
+ }
250
+ export declare const MCPServerContribution: unique symbol;
251
+ export declare const TokenMCPServerRegistry: unique symbol;
252
+ export interface MCPServerContribution {
253
+ registerMCPServer(registry: IMCPServerRegistry): void;
254
+ }
255
+ export interface MCPLogger {
256
+ appendLine(message: string): void;
257
+ }
258
+ export interface MCPToolDefinition {
259
+ name: string;
260
+ description: string;
261
+ inputSchema: any;
262
+ handler: (args: any, logger: MCPLogger) => Promise<{
263
+ content: {
264
+ type: string;
265
+ text: string;
266
+ }[];
267
+ isError?: boolean;
268
+ }>;
269
+ }
270
+ export interface IMCPServerRegistry {
271
+ registerMCPTool(tool: MCPToolDefinition): void;
272
+ getMCPTools(): MCPToolDefinition[];
273
+ callMCPTool(name: string, args: any): Promise<{
274
+ content: {
275
+ type: string;
276
+ text: string;
277
+ }[];
278
+ isError?: boolean;
279
+ }>;
227
280
  }
228
281
  export interface IChatComponentConfig {
229
282
  id: string;
@@ -247,5 +300,13 @@ export interface IAIMiddleware {
247
300
  provideInlineCompletions?: IProvideInlineCompletionsSignature;
248
301
  };
249
302
  }
303
+ export declare const ChatAgentPromptProvider: unique symbol;
304
+ export interface ChatAgentPromptProvider {
305
+ /**
306
+ * 提供上下文提示
307
+ * @param context 上下文
308
+ */
309
+ provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
310
+ }
250
311
  export {};
251
312
  //# sourceMappingURL=types.d.ts.map