@opensumi/ide-ai-native 3.9.1-next-1747733557.0 → 3.9.1-next-1747829468.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 (35) hide show
  1. package/lib/browser/chat/apply.service.d.ts +0 -2
  2. package/lib/browser/chat/apply.service.d.ts.map +1 -1
  3. package/lib/browser/chat/apply.service.js +0 -3
  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 +0 -1
  7. package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
  8. package/lib/browser/mcp/base-apply.service.js +0 -7
  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/fileSearch.d.ts.map +1 -1
  14. package/lib/browser/mcp/tools/fileSearch.js +9 -5
  15. package/lib/browser/mcp/tools/fileSearch.js.map +1 -1
  16. package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -1
  17. package/lib/browser/mcp/tools/grepSearch.js +9 -5
  18. package/lib/browser/mcp/tools/grepSearch.js.map +1 -1
  19. package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
  20. package/lib/browser/mcp/tools/listDir.js +19 -15
  21. package/lib/browser/mcp/tools/listDir.js.map +1 -1
  22. package/lib/node/mcp-server.sse.d.ts +187 -1
  23. package/lib/node/mcp-server.sse.d.ts.map +1 -1
  24. package/lib/node/mcp-server.sse.js +2 -2
  25. package/lib/node/mcp-server.sse.js.map +1 -1
  26. package/lib/node/mcp-server.stdio.d.ts +187 -1
  27. package/lib/node/mcp-server.stdio.d.ts.map +1 -1
  28. package/package.json +25 -25
  29. package/src/browser/chat/apply.service.ts +0 -5
  30. package/src/browser/mcp/base-apply.service.ts +0 -9
  31. package/src/browser/mcp/mcp-server.feature.registry.ts +6 -1
  32. package/src/browser/mcp/tools/fileSearch.ts +8 -5
  33. package/src/browser/mcp/tools/grepSearch.ts +8 -5
  34. package/src/browser/mcp/tools/listDir.ts +15 -12
  35. package/src/node/mcp-server.sse.ts +1 -2
@@ -1,7 +1,6 @@
1
1
  import { Autowired, Injectable } from '@opensumi/di';
2
2
  import { AIBackSerivcePath, IAIBackService, IChatProgress, URI, path } from '@opensumi/ide-core-browser';
3
3
  import { IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser';
4
- import { ICodeEditor } from '@opensumi/ide-monaco';
5
4
  import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream';
6
5
  import { Range } from '@opensumi/monaco-editor-core';
7
6
 
@@ -13,10 +12,6 @@ import { ChatProxyService } from './chat-proxy.service';
13
12
 
14
13
  @Injectable()
15
14
  export class ApplyService extends BaseApplyService {
16
- protected postApplyHandler(editor: ICodeEditor): Promise<void> {
17
- return Promise.resolve();
18
- }
19
-
20
15
  @Autowired(IEditorDocumentModelService)
21
16
  private readonly modelService: IEditorDocumentModelService;
22
17
 
@@ -63,8 +63,6 @@ export abstract class BaseApplyService extends WithEventBus {
63
63
 
64
64
  private currentSessionId?: string;
65
65
 
66
- protected abstract postApplyHandler(editor: ICodeEditor): Promise<void>;
67
-
68
66
  constructor() {
69
67
  super();
70
68
  this.addDispose(
@@ -319,13 +317,6 @@ export abstract class BaseApplyService extends WithEventBus {
319
317
  codeBlock.applyResult = res.result;
320
318
  this.updateCodeBlock(codeBlock);
321
319
 
322
- // apply 结果流式输出完成后,自动尝试修复代码中的 lint 错误
323
- if (this.postApplyHandler && typeof this.postApplyHandler === 'function') {
324
- try {
325
- await this.postApplyHandler(result.group.codeEditor.monacoEditor);
326
- } catch (error) {}
327
- }
328
-
329
320
  return codeBlock;
330
321
  } catch (err) {
331
322
  codeBlock.status = 'failed';
@@ -44,7 +44,12 @@ export class MCPServerRegistry implements IMCPServerRegistry {
44
44
  }
45
45
 
46
46
  registerMCPTool(tool: MCPToolDefinition): void {
47
- this.tools.push(tool);
47
+ const existingIndex = this.tools.findIndex((t) => t.name === tool.name);
48
+ if (existingIndex !== -1) {
49
+ this.tools[existingIndex] = tool;
50
+ } else {
51
+ this.tools.push(tool);
52
+ }
48
53
  }
49
54
 
50
55
  registerToolComponent(
@@ -80,11 +80,14 @@ export class FileSearchTool implements MCPServerContribution {
80
80
  });
81
81
 
82
82
  const messages = this.chatInternalService.sessionModel.history.getMessages();
83
- this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
84
- [args.toolCallId]: {
85
- files,
86
- },
87
- });
83
+ const messageId = messages[messages.length - 1]?.id;
84
+ if (messageId) {
85
+ this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
86
+ [args.toolCallId]: {
87
+ files,
88
+ },
89
+ });
90
+ }
88
91
 
89
92
  logger.appendLine(`Found ${files.length} files matching "${args.query}"`);
90
93
 
@@ -111,11 +111,14 @@ export class GrepSearchTool implements MCPServerContribution {
111
111
  }
112
112
  deferred.resolve(results.join('\n\n'));
113
113
  const messages = this.chatInternalService.sessionModel.history.getMessages();
114
- this.chatInternalService.sessionModel.history.setMessageAdditional(messages[messages.length - 1].id, {
115
- [args.toolCallId]: {
116
- files,
117
- },
118
- });
114
+ const messageId = messages[messages.length - 1]?.id;
115
+ if (messageId) {
116
+ this.chatInternalService.sessionModel.history.setMessageAdditional(messageId, {
117
+ [args.toolCallId]: {
118
+ files,
119
+ },
120
+ });
121
+ }
119
122
  });
120
123
  const text = await deferred.promise;
121
124
  return {
@@ -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) => {