@opensumi/ide-ai-native 3.9.1-next-1747791726.0 → 3.9.1-next-1747836538.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 (44) hide show
  1. package/lib/browser/chat/apply.service.d.ts +0 -3
  2. package/lib/browser/chat/apply.service.d.ts.map +1 -1
  3. package/lib/browser/chat/apply.service.js +0 -47
  4. package/lib/browser/chat/apply.service.js.map +1 -1
  5. package/lib/browser/components/utils.d.ts +2 -2
  6. package/lib/browser/mcp/base-apply.service.d.ts +2 -3
  7. package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
  8. package/lib/browser/mcp/base-apply.service.js +5 -23
  9. package/lib/browser/mcp/base-apply.service.js.map +1 -1
  10. package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
  11. package/lib/browser/mcp/mcp-server.feature.registry.js +7 -1
  12. package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
  13. package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
  14. package/lib/browser/mcp/tools/createNewFileWithText.js +10 -5
  15. package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
  16. package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -1
  17. package/lib/browser/mcp/tools/fileSearch.js +9 -5
  18. package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
  19. package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
  20. package/lib/browser/mcp/tools/grepSearch.js +22 -10
  21. package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
  22. package/lib/browser/mcp/tools/handlers/RunCommand.d.ts +11 -1
  23. package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
  24. package/lib/browser/mcp/tools/handlers/RunCommand.js +11 -4
  25. package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
  26. package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
  27. package/lib/browser/mcp/tools/listDir.js +19 -15
  28. package/lib/browser/mcp/tools/listDir.js.map +1 -1
  29. package/lib/node/mcp-server.sse.d.ts +187 -1
  30. package/lib/node/mcp-server.sse.d.ts.map +1 -1
  31. package/lib/node/mcp-server.sse.js +2 -2
  32. package/lib/node/mcp-server.sse.js.map +1 -1
  33. package/lib/node/mcp-server.stdio.d.ts +187 -1
  34. package/lib/node/mcp-server.stdio.d.ts.map +1 -1
  35. package/package.json +25 -25
  36. package/src/browser/chat/apply.service.ts +1 -62
  37. package/src/browser/mcp/base-apply.service.ts +9 -30
  38. package/src/browser/mcp/mcp-server.feature.registry.ts +6 -1
  39. package/src/browser/mcp/tools/createNewFileWithText.ts +12 -7
  40. package/src/browser/mcp/tools/fileSearch.ts +8 -5
  41. package/src/browser/mcp/tools/grepSearch.ts +32 -21
  42. package/src/browser/mcp/tools/handlers/RunCommand.ts +21 -14
  43. package/src/browser/mcp/tools/listDir.ts +15 -12
  44. package/src/node/mcp-server.sse.ts +1 -2
@@ -13,18 +13,25 @@ const color = {
13
13
  reset: '\x1b[0m',
14
14
  };
15
15
 
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
- });
16
+ export const inputSchema = z
17
+ .object({
18
+ command: z.string().describe('The terminal command to execute'),
19
+ is_background: z.boolean().describe('Whether the command should be run in the background'),
20
+ explanation: z
21
+ .string()
22
+ .describe('One sentence explanation as to why this command needs to be run and how it contributes to the goal.'),
23
+ require_user_approval: z
24
+ .boolean()
25
+ .describe(
26
+ "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.",
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
+ }));
28
35
 
29
36
  @Injectable()
30
37
  export class RunCommandHandler {
@@ -66,7 +73,7 @@ export class RunCommandHandler {
66
73
 
67
74
  async handler(args: z.infer<typeof inputSchema> & { toolCallId: string }, logger: MCPLogger) {
68
75
  logger.appendLine(`Executing command: ${args.command}`);
69
- if (this.isAlwaysApproval(args.require_user_approval)) {
76
+ if (this.isAlwaysApproval(args.requireUserApproval)) {
70
77
  const def = new Deferred<boolean>();
71
78
  this.approvalDeferredMap.set(args.toolCallId, def);
72
79
  const approval = await def.promise;
@@ -93,7 +100,7 @@ export class RunCommandHandler {
93
100
  const result: { type: string; text: string }[] = [];
94
101
  const def = new Deferred<{ isError?: boolean; content: { type: string; text: string }[] }>();
95
102
 
96
- if (args.is_background) {
103
+ if (args.isBackground) {
97
104
  def.resolve({
98
105
  isError: false,
99
106
  content: [{ type: 'text', text: `Successful run command ${args.command} in background.` }],
@@ -63,18 +63,21 @@ export class ListDirTool implements MCPServerContribution {
63
63
 
64
64
  // 设置消息的附加数据
65
65
  const messages = this.chatInternalService.sessionModel.history.getMessages();
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
- });
66
+ const messageId = messages[messages.length - 1]?.id;
67
+ if (messageId) {
68
+ this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
69
+ [args.toolCallId]: {
70
+ files: fileUris,
71
+ title: `Listed directory "${args.relativeWorkspacePath}"`,
72
+ details: result.files.map((file) => ({
73
+ type: file.isDirectory ? 'dir' : 'file',
74
+ name: file.name,
75
+ info: file.isDirectory ? `${file.numChildren ?? '?'} items` : `${file.size}KB, ${file.numLines} lines`,
76
+ lastModified: file.lastModified,
77
+ })),
78
+ },
79
+ });
80
+ }
78
81
 
79
82
  logger.appendLine(`Listed ${fileUris.length} files in directory "${args.relativeWorkspacePath}"`);
80
83
 
@@ -1,5 +1,6 @@
1
1
  // have to import with extension since the exports map is ./* -> ./dist/cjs/*
2
2
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
3
+ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
3
4
  import { EventSource } from 'eventsource';
4
5
 
5
6
  import { ILogger } from '@opensumi/ide-core-common';
@@ -47,8 +48,6 @@ export class SSEMCPServer implements IMCPServer {
47
48
  }
48
49
  this.logger?.log(`Starting server "${this.name}" with url: ${this.url}`);
49
50
 
50
- const SSEClientTransport = (await import('@modelcontextprotocol/sdk/client/sse.js')).SSEClientTransport;
51
-
52
51
  const transport = new SSEClientTransport(new URL(this.url), this.transportOptions);
53
52
 
54
53
  transport.onerror = (error) => {