@opensumi/ide-ai-native 3.7.2-next-1740066619.0 → 3.7.2-next-1740323956.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 -0
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-agent.service.js +6 -0
- package/lib/browser/chat/chat-agent.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +5 -23
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +1 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +8 -1
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +4 -0
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +10 -1
- package/lib/browser/chat/chat.internal.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +2 -2
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatContext/index.d.ts.map +1 -1
- package/lib/browser/components/ChatContext/index.js +18 -2
- package/lib/browser/components/ChatContext/index.js.map +1 -1
- package/lib/browser/components/ChatContext/style.module.less +12 -0
- package/lib/browser/components/ChatEditor.d.ts +1 -0
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +3 -3
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatMarkdown.d.ts +1 -0
- package/lib/browser/components/ChatMarkdown.d.ts.map +1 -1
- package/lib/browser/components/ChatMarkdown.js +2 -2
- package/lib/browser/components/ChatMarkdown.js.map +1 -1
- package/lib/browser/components/ChatReply.d.ts.map +1 -1
- package/lib/browser/components/ChatReply.js +6 -8
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts +1 -0
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +25 -7
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/components.module.less +3 -2
- package/lib/browser/context/llm-context.service.d.ts +1 -0
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +24 -18
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +11 -12
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +67 -0
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -0
- package/lib/browser/mcp/base-apply.service.js +290 -0
- package/lib/browser/mcp/base-apply.service.js.map +1 -0
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +6 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +2 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts +5 -1
- package/lib/browser/mcp/mcp-server.feature.registry.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js +17 -1
- package/lib/browser/mcp/mcp-server.feature.registry.js.map +1 -1
- package/lib/browser/mcp/tools/components/EditFile.d.ts +3 -0
- package/lib/browser/mcp/tools/components/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/EditFile.js +101 -0
- package/lib/browser/mcp/tools/components/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts +11 -0
- package/lib/browser/mcp/tools/components/SearchResult.d.ts.map +1 -0
- package/lib/browser/mcp/tools/components/SearchResult.js +60 -0
- package/lib/browser/mcp/tools/components/SearchResult.js.map +1 -0
- package/lib/browser/mcp/tools/components/index.module.less +132 -0
- package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
- package/lib/browser/mcp/tools/createNewFileWithText.js +1 -2
- package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
- package/lib/browser/mcp/tools/{getSelectedText.d.ts → editFile.d.ts} +3 -3
- package/lib/browser/mcp/tools/editFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/editFile.js +95 -0
- package/lib/browser/mcp/tools/editFile.js.map +1 -0
- package/lib/browser/mcp/tools/{findFilesByNameSubstring.d.ts → fileSearch.d.ts} +3 -2
- package/lib/browser/mcp/tools/fileSearch.d.ts.map +1 -0
- package/lib/browser/mcp/tools/fileSearch.js +94 -0
- package/lib/browser/mcp/tools/fileSearch.js.map +1 -0
- package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js +1 -2
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.d.ts.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js +1 -2
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/{getFileTextByPath.d.ts → grepSearch.d.ts} +4 -3
- package/lib/browser/mcp/tools/grepSearch.d.ts.map +1 -0
- package/lib/browser/mcp/tools/grepSearch.js +118 -0
- package/lib/browser/mcp/tools/grepSearch.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts +10 -0
- package/lib/browser/mcp/tools/handlers/EditFile.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js +28 -0
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts +6 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/handlers/ReadFile.js +14 -0
- package/lib/browser/mcp/tools/handlers/ReadFile.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/utils.d.ts +2 -0
- package/lib/browser/mcp/tools/handlers/utils.d.ts.map +1 -0
- package/lib/browser/mcp/tools/handlers/utils.js +7 -0
- package/lib/browser/mcp/tools/handlers/utils.js.map +1 -0
- package/lib/browser/mcp/tools/listDir.d.ts.map +1 -1
- package/lib/browser/mcp/tools/listDir.js +3 -4
- package/lib/browser/mcp/tools/listDir.js.map +1 -1
- package/lib/browser/mcp/tools/readFile.d.ts.map +1 -1
- package/lib/browser/mcp/tools/readFile.js +3 -4
- package/lib/browser/mcp/tools/readFile.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js +1 -2
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +5 -0
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +14 -0
- 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 +5 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +14 -10
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js +1 -2
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts +1 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js +3 -0
- package/lib/browser/widget/inline-stream-diff/inline-stream-diff.handler.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts +4 -0
- 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/browser/widget/inline-stream-diff/live-preview.decoration.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.decoration.js.map +1 -1
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/mcp-server-manager.d.ts +1 -1
- package/lib/common/mcp-server-manager.d.ts.map +1 -1
- package/lib/common/mcp-server-manager.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +14 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -0
- package/lib/common/prompts/context-prompt-provider.js +38 -0
- package/lib/common/prompts/context-prompt-provider.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +2 -1
- package/lib/common/tool-invocation-registry.d.ts.map +1 -1
- package/lib/common/tool-invocation-registry.js.map +1 -1
- package/lib/common/utils.d.ts +1 -0
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +3 -1
- package/lib/common/utils.js.map +1 -1
- package/lib/node/base-language-model.d.ts +2 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +9 -5
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +5 -2
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +6 -5
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/lib/node/mcp-server.d.ts +2 -2
- package/lib/node/mcp-server.d.ts.map +1 -1
- package/lib/node/mcp-server.js +2 -1
- package/lib/node/mcp-server.js.map +1 -1
- package/lib/node/openai/openai-language-model.d.ts +1 -1
- package/lib/node/openai/openai-language-model.d.ts.map +1 -1
- package/lib/node/openai/openai-language-model.js +2 -2
- package/lib/node/openai/openai-language-model.js.map +1 -1
- package/package.json +24 -25
- package/src/browser/ai-core.contribution.ts +4 -0
- package/src/browser/chat/chat-agent.service.ts +7 -0
- package/src/browser/chat/chat-model.ts +0 -2
- package/src/browser/chat/chat-proxy.service.ts +12 -2
- package/src/browser/chat/chat.internal.service.ts +12 -1
- package/src/browser/chat/chat.view.tsx +2 -1
- package/src/browser/components/ChatContext/index.tsx +19 -3
- package/src/browser/components/ChatContext/style.module.less +12 -0
- package/src/browser/components/ChatEditor.tsx +13 -10
- package/src/browser/components/ChatMarkdown.tsx +3 -1
- package/src/browser/components/ChatReply.tsx +8 -15
- package/src/browser/components/ChatToolRender.tsx +36 -17
- package/src/browser/components/components.module.less +3 -2
- package/src/browser/context/llm-context.service.ts +30 -18
- package/src/browser/index.ts +11 -12
- package/src/browser/mcp/base-apply.service.ts +349 -0
- package/src/browser/mcp/mcp-server-proxy.service.ts +4 -2
- package/src/browser/mcp/mcp-server.feature.registry.ts +27 -4
- package/src/browser/mcp/tools/components/EditFile.tsx +144 -0
- package/src/browser/mcp/tools/components/SearchResult.tsx +92 -0
- package/src/browser/mcp/tools/components/index.module.less +132 -0
- package/src/browser/mcp/tools/createNewFileWithText.ts +1 -2
- package/src/browser/mcp/tools/editFile.ts +100 -0
- package/src/browser/mcp/tools/fileSearch.ts +99 -0
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -2
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -2
- package/src/browser/mcp/tools/grepSearch.ts +121 -0
- package/src/browser/mcp/tools/handlers/EditFile.ts +21 -0
- package/src/browser/mcp/tools/handlers/ReadFile.ts +19 -1
- package/src/browser/mcp/tools/handlers/utils.ts +3 -0
- package/src/browser/mcp/tools/listDir.ts +3 -4
- package/src/browser/mcp/tools/readFile.ts +3 -4
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -2
- package/src/browser/model/msg-history-manager.ts +19 -0
- package/src/browser/preferences/schema.ts +5 -0
- package/src/browser/types.ts +15 -11
- package/src/browser/widget/inline-stream-diff/inline-stream-diff.handler.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +4 -0
- package/src/browser/widget/inline-stream-diff/live-preview.decoration.tsx +1 -0
- package/src/common/index.ts +1 -0
- package/src/common/mcp-server-manager.ts +18 -13
- package/src/common/prompts/context-prompt-provider.ts +46 -0
- package/src/common/tool-invocation-registry.ts +122 -124
- package/src/common/utils.ts +2 -0
- package/src/node/base-language-model.ts +20 -6
- package/src/node/mcp/sumi-mcp-server.ts +5 -2
- package/src/node/mcp-server-manager-impl.ts +13 -5
- package/src/node/mcp-server.ts +3 -2
- package/src/node/openai/openai-language-model.ts +2 -2
- package/lib/browser/mcp/tools/findFilesByNameSubstring.d.ts.map +0 -1
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js +0 -92
- package/lib/browser/mcp/tools/findFilesByNameSubstring.js.map +0 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts +0 -8
- package/lib/browser/mcp/tools/getCurrentFilePath.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getCurrentFilePath.js +0 -49
- package/lib/browser/mcp/tools/getCurrentFilePath.js.map +0 -1
- package/lib/browser/mcp/tools/getFileTextByPath.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getFileTextByPath.js +0 -97
- package/lib/browser/mcp/tools/getFileTextByPath.js.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts +0 -8
- package/lib/browser/mcp/tools/getOpenEditorFileText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getOpenEditorFileText.js +0 -50
- package/lib/browser/mcp/tools/getOpenEditorFileText.js.map +0 -1
- package/lib/browser/mcp/tools/getSelectedText.d.ts.map +0 -1
- package/lib/browser/mcp/tools/getSelectedText.js +0 -57
- package/lib/browser/mcp/tools/getSelectedText.js.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts +0 -8
- package/lib/browser/mcp/tools/replaceOpenEditorFile.d.ts.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js +0 -79
- package/lib/browser/mcp/tools/replaceOpenEditorFile.js.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts +0 -8
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.d.ts.map +0 -1
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js +0 -84
- package/lib/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.js.map +0 -1
- package/src/browser/mcp/tools/findFilesByNameSubstring.ts +0 -93
- package/src/browser/mcp/tools/getCurrentFilePath.ts +0 -49
- package/src/browser/mcp/tools/getFileTextByPath.ts +0 -97
- package/src/browser/mcp/tools/getOpenEditorFileText.ts +0 -50
- package/src/browser/mcp/tools/getSelectedText.ts +0 -57
- package/src/browser/mcp/tools/replaceOpenEditorFile.ts +0 -80
- package/src/browser/mcp/tools/replaceOpenEditorFileByDiffPreviewer.ts +0 -91
|
@@ -8,10 +8,14 @@ type IExcludeMessage = Omit<IHistoryChatMessage, 'id' | 'order'>;
|
|
|
8
8
|
@Injectable({ multiple: false })
|
|
9
9
|
export class MsgHistoryManager extends Disposable {
|
|
10
10
|
private messageMap: Map<string, IHistoryChatMessage> = new Map();
|
|
11
|
+
private messageAdditionalMap: Map<string, Record<string, any>> = new Map();
|
|
11
12
|
|
|
12
13
|
private readonly _onMessageChange = new Emitter<IHistoryChatMessage[]>();
|
|
13
14
|
public readonly onMessageChange: Event<IHistoryChatMessage[]> = this._onMessageChange.event;
|
|
14
15
|
|
|
16
|
+
private readonly _onMessageAdditionalChange = new Emitter<Record<string, any>>();
|
|
17
|
+
public readonly onMessageAdditionalChange: Event<Record<string, any>> = this._onMessageAdditionalChange.event;
|
|
18
|
+
|
|
15
19
|
override dispose(): void {
|
|
16
20
|
this.clearMessages();
|
|
17
21
|
super.dispose();
|
|
@@ -19,6 +23,7 @@ export class MsgHistoryManager extends Disposable {
|
|
|
19
23
|
|
|
20
24
|
public clearMessages() {
|
|
21
25
|
this.messageMap.clear();
|
|
26
|
+
this.messageAdditionalMap.clear();
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
private doAddMessage(message: IExcludeMessage): string {
|
|
@@ -70,4 +75,18 @@ export class MsgHistoryManager extends Disposable {
|
|
|
70
75
|
content: message.content,
|
|
71
76
|
});
|
|
72
77
|
}
|
|
78
|
+
|
|
79
|
+
public setMessageAdditional(id: string, additional: Record<string, any>) {
|
|
80
|
+
if (!this.messageMap.has(id)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.messageAdditionalMap.set(id, additional);
|
|
85
|
+
|
|
86
|
+
this._onMessageAdditionalChange.fire(additional);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public getMessageAdditional(id: string): Record<string, any> {
|
|
90
|
+
return this.messageAdditionalMap.get(id) || {};
|
|
91
|
+
}
|
|
73
92
|
}
|
|
@@ -122,5 +122,10 @@ export const aiNativePreferenceSchema: PreferenceSchema = {
|
|
|
122
122
|
type: 'boolean',
|
|
123
123
|
default: false,
|
|
124
124
|
},
|
|
125
|
+
[AINativeSettingSectionsId.SystemPrompt]: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
default: '',
|
|
128
|
+
description: localize('preference.ai.native.chat.system.prompt.description'),
|
|
129
|
+
},
|
|
125
130
|
},
|
|
126
131
|
};
|
package/src/browser/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
2
3
|
|
|
3
4
|
import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native/index';
|
|
4
5
|
import {
|
|
@@ -349,8 +350,9 @@ export interface MCPLogger {
|
|
|
349
350
|
|
|
350
351
|
export interface MCPToolDefinition {
|
|
351
352
|
name: string;
|
|
353
|
+
label?: string;
|
|
352
354
|
description: string;
|
|
353
|
-
inputSchema: any
|
|
355
|
+
inputSchema: ZodSchema<any>; // JSON Schema
|
|
354
356
|
handler: (
|
|
355
357
|
args: any,
|
|
356
358
|
logger: MCPLogger,
|
|
@@ -360,9 +362,21 @@ export interface MCPToolDefinition {
|
|
|
360
362
|
}>;
|
|
361
363
|
}
|
|
362
364
|
|
|
365
|
+
export interface IMCPServerToolComponentProps {
|
|
366
|
+
state?: 'streaming-start' | 'streaming' | 'complete' | 'result';
|
|
367
|
+
args?: Record<string, any>;
|
|
368
|
+
result?: any;
|
|
369
|
+
index?: number;
|
|
370
|
+
messageId?: string;
|
|
371
|
+
toolCallId?: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
363
374
|
export interface IMCPServerRegistry {
|
|
364
375
|
registerMCPTool(tool: MCPToolDefinition): void;
|
|
365
376
|
getMCPTools(): MCPToolDefinition[];
|
|
377
|
+
getMCPTool(name: string): MCPToolDefinition | undefined;
|
|
378
|
+
registerToolComponent(name: string, component: React.FC<IMCPServerToolComponentProps>): void;
|
|
379
|
+
getToolComponent(name: string): React.FC<IMCPServerToolComponentProps> | undefined;
|
|
366
380
|
callMCPTool(
|
|
367
381
|
name: string,
|
|
368
382
|
args: any,
|
|
@@ -405,13 +419,3 @@ export interface IAIMiddleware {
|
|
|
405
419
|
provideInlineCompletions?: IProvideInlineCompletionsSignature;
|
|
406
420
|
};
|
|
407
421
|
}
|
|
408
|
-
|
|
409
|
-
export const ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
410
|
-
|
|
411
|
-
export interface ChatAgentPromptProvider {
|
|
412
|
-
/**
|
|
413
|
-
* 提供上下文提示
|
|
414
|
-
* @param context 上下文
|
|
415
|
-
*/
|
|
416
|
-
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
417
|
-
}
|
|
@@ -69,6 +69,10 @@ export class InlineStreamDiffHandler extends Disposable implements IInlineDiffPr
|
|
|
69
69
|
|
|
70
70
|
public livePreviewDiffDecorationModel: LivePreviewDiffDecorationModel;
|
|
71
71
|
|
|
72
|
+
public get uri() {
|
|
73
|
+
return this.originalModel.uri;
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
constructor(private readonly monacoEditor: ICodeEditor) {
|
|
73
77
|
super();
|
|
74
78
|
|
|
@@ -426,6 +426,7 @@ export class LivePreviewDiffDecorationModel extends Disposable {
|
|
|
426
426
|
uri: this.model.uri,
|
|
427
427
|
totalPartialEditCount: this.partialEditWidgetList.length,
|
|
428
428
|
resolvedPartialEditCount: this.partialEditWidgetList.filter((w) => w.isHidden).length,
|
|
429
|
+
acceptPartialEditCount: this.partialEditWidgetList.filter((w) => w.isAccepted).length,
|
|
429
430
|
currentPartialEdit: {
|
|
430
431
|
addedLinesCount,
|
|
431
432
|
deletedLinesCount,
|
package/src/common/index.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
2
|
|
|
3
3
|
export interface MCPServerManager {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
callTool(
|
|
5
|
+
serverName: string,
|
|
6
|
+
toolName: string,
|
|
7
|
+
toolCallId: string,
|
|
8
|
+
arg_string: string,
|
|
9
|
+
): ReturnType<Client['callTool']>;
|
|
10
|
+
removeServer(name: string): void;
|
|
11
|
+
addOrUpdateServer(description: MCPServerDescription): void;
|
|
12
|
+
// invoke in node.js only
|
|
13
|
+
addOrUpdateServerDirectly(server: any): void;
|
|
14
|
+
initBuiltinServer(builtinMCPServer: any): void;
|
|
15
|
+
getTools(serverName: string): ReturnType<Client['listTools']>;
|
|
16
|
+
getServerNames(): Promise<string[]>;
|
|
17
|
+
startServer(serverName: string): Promise<void>;
|
|
18
|
+
stopServer(serverName: string): Promise<void>;
|
|
19
|
+
getStartedServers(): Promise<string[]>;
|
|
20
|
+
registerTools(serverName: string): Promise<void>;
|
|
21
|
+
addExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export type MCPTool = Awaited<ReturnType<MCPServerManager['getTools']>>['tools'][number];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { MaybePromise } from '@opensumi/ide-core-common/lib/utils';
|
|
3
|
+
|
|
4
|
+
import { SerializedContext } from '../llm-context';
|
|
5
|
+
|
|
6
|
+
export const ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
7
|
+
|
|
8
|
+
export interface ChatAgentPromptProvider {
|
|
9
|
+
/**
|
|
10
|
+
* 提供上下文提示
|
|
11
|
+
* @param context 上下文
|
|
12
|
+
*/
|
|
13
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
|
|
18
|
+
provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string> {
|
|
19
|
+
return `
|
|
20
|
+
<additional_data>
|
|
21
|
+
Below are some potentially helpful/relevant pieces of information for figuring out to respond
|
|
22
|
+
<recently_viewed_files>
|
|
23
|
+
${context.recentlyViewFiles.map((file, idx) => `${idx + 1} : ${file}`)}
|
|
24
|
+
</recently_viewed_files>
|
|
25
|
+
<attached_files>
|
|
26
|
+
${context.attachedFiles.map(
|
|
27
|
+
(file) =>
|
|
28
|
+
`
|
|
29
|
+
<file_contents>
|
|
30
|
+
\`\`\`${file.language} ${file.path}
|
|
31
|
+
${file.content}
|
|
32
|
+
\`\`\`
|
|
33
|
+
</file_contents>
|
|
34
|
+
<linter_errors>
|
|
35
|
+
${file.lineErrors.join('\n')}
|
|
36
|
+
</linter_errors>
|
|
37
|
+
`,
|
|
38
|
+
)}
|
|
39
|
+
|
|
40
|
+
</attached_files>
|
|
41
|
+
</additional_data>
|
|
42
|
+
<user_query>
|
|
43
|
+
${userMessage}
|
|
44
|
+
</user_query>`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
+
import { ToolExecutionOptions } from 'ai';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
|
|
3
4
|
import { Injectable } from '@opensumi/di';
|
|
4
5
|
|
|
5
|
-
import { MCPToolParameter } from './mcp-server-manager';
|
|
6
|
-
|
|
7
6
|
export const ToolParameterSchema = z.object({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
type: z.enum(['string', 'number', 'boolean', 'object', 'array']),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
enum: z.array(z.any()).optional(),
|
|
10
|
+
items: z.lazy(() => ToolParameterSchema).optional(),
|
|
11
|
+
properties: z.record(z.lazy(() => ToolParameterSchema)).optional(),
|
|
12
|
+
required: z.array(z.string()).optional(),
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
export type ToolParameter = z.infer<typeof ToolParameterSchema>;
|
|
17
16
|
|
|
18
17
|
export interface ToolRequest {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
parameters?: any;
|
|
21
|
+
description?: string;
|
|
22
|
+
handler: (arg_string: string, options?: ToolExecutionOptions) => Promise<any>;
|
|
23
|
+
providerName?: string;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export namespace ToolRequest {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export function isToolParameter(obj: unknown): obj is ToolParameter {
|
|
28
|
+
return ToolParameterSchema.safeParse(obj).success;
|
|
29
|
+
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
export const ToolInvocationRegistry = Symbol('ToolInvocationRegistry');
|
|
@@ -36,135 +35,134 @@ export const ToolInvocationRegistry = Symbol('ToolInvocationRegistry');
|
|
|
36
35
|
* 为 Agent 提供的所有可用函数调用的注册表
|
|
37
36
|
*/
|
|
38
37
|
export interface ToolInvocationRegistry {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
38
|
+
/**
|
|
39
|
+
* 在注册表中注册一个工具
|
|
40
|
+
*
|
|
41
|
+
* @param tool - 要注册的 `ToolRequest` 对象
|
|
42
|
+
*/
|
|
43
|
+
registerTool(tool: ToolRequest): void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 从注册表中获取特定的 `ToolRequest`
|
|
47
|
+
*
|
|
48
|
+
* @param toolId - 要获取的工具的唯一标识符
|
|
49
|
+
* @returns 对应提供的工具 ID 的 `ToolRequest` 对象,
|
|
50
|
+
* 如果在注册表中找不到该工具,则返回 `undefined`
|
|
51
|
+
*/
|
|
52
|
+
getFunction(toolId: string): ToolRequest | undefined;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 从注册表中获取多个 `ToolRequest`
|
|
56
|
+
*
|
|
57
|
+
* @param toolIds - 要获取的工具 ID 列表
|
|
58
|
+
* @returns 指定工具 ID 的 `ToolRequest` 对象数组
|
|
59
|
+
* 如果找不到某个工具 ID,将在返回的数组中跳过该工具
|
|
60
|
+
*/
|
|
61
|
+
getFunctions(...toolIds: string[]): ToolRequest[];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 获取当前注册表中的所有 `ToolRequest`
|
|
65
|
+
*
|
|
66
|
+
* @returns 注册表中所有 `ToolRequest` 对象的数组
|
|
67
|
+
*/
|
|
68
|
+
getAllFunctions(): ToolRequest[];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 注销特定工具提供者的所有工具
|
|
72
|
+
*
|
|
73
|
+
* @param providerName - 要移除其工具的工具提供者名称(在 `ToolRequest` 中指定)
|
|
74
|
+
*/
|
|
75
|
+
unregisterAllTools(providerName: string): void;
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
export const ToolProvider = Symbol('ToolProvider');
|
|
80
79
|
export interface ToolProvider {
|
|
81
|
-
|
|
80
|
+
getTool(): ToolRequest;
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
export class ToolInvocationRegistryImpl implements ToolInvocationRegistry {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
toolsToRemove.forEach((id) => this.tools.delete(id));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
getAllFunctions(): ToolRequest[] {
|
|
98
|
-
return Array.from(this.tools.values());
|
|
84
|
+
private tools: Map<string, ToolRequest> = new Map<string, ToolRequest>();
|
|
85
|
+
|
|
86
|
+
unregisterAllTools(providerName: string): void {
|
|
87
|
+
const toolsToRemove: string[] = [];
|
|
88
|
+
for (const [id, tool] of this.tools.entries()) {
|
|
89
|
+
if (tool.providerName === providerName) {
|
|
90
|
+
toolsToRemove.push(id);
|
|
91
|
+
}
|
|
99
92
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
getFunctions(...toolIds: string[]): ToolRequest[] {
|
|
115
|
-
const tools: ToolRequest[] = toolIds.map((toolId) => {
|
|
116
|
-
const tool = this.tools.get(toolId);
|
|
117
|
-
if (tool) {
|
|
118
|
-
return tool;
|
|
119
|
-
} else {
|
|
120
|
-
throw new Error(`找不到 ID 为 ${toolId} 的函数`);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return tools;
|
|
93
|
+
toolsToRemove.forEach((id) => this.tools.delete(id));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getAllFunctions(): ToolRequest[] {
|
|
97
|
+
return Array.from(this.tools.values());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
registerTool(tool: ToolRequest): void {
|
|
101
|
+
if (this.tools.has(tool.id)) {
|
|
102
|
+
// TODO: 使用适当的日志机制
|
|
103
|
+
this.tools.set(tool.id, tool);
|
|
104
|
+
} else {
|
|
105
|
+
this.tools.set(tool.id, tool);
|
|
124
106
|
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getFunction(toolId: string): ToolRequest | undefined {
|
|
110
|
+
return this.tools.get(toolId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getFunctions(...toolIds: string[]): ToolRequest[] {
|
|
114
|
+
const tools: ToolRequest[] = toolIds.map((toolId) => {
|
|
115
|
+
const tool = this.tools.get(toolId);
|
|
116
|
+
if (tool) {
|
|
117
|
+
return tool;
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error(`找不到 ID 为 ${toolId} 的函数`);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return tools;
|
|
123
|
+
}
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
/**
|
|
128
127
|
* 管理多个 ToolInvocationRegistry 实例的管理器,每个实例与一个 clientId 关联
|
|
129
128
|
*/
|
|
130
129
|
export interface IToolInvocationRegistryManager {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
/**
|
|
131
|
+
* 获取或创建特定 clientId 的 ToolInvocationRegistry
|
|
132
|
+
*/
|
|
133
|
+
getRegistry(clientId: string): ToolInvocationRegistry;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 移除特定 clientId 的 ToolInvocationRegistry
|
|
137
|
+
*/
|
|
138
|
+
removeRegistry(clientId: string): void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 检查特定 clientId 是否存在对应的注册表
|
|
142
|
+
*/
|
|
143
|
+
hasRegistry(clientId: string): boolean;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
export const ToolInvocationRegistryManager = Symbol('ToolInvocationRegistryManager');
|
|
148
147
|
|
|
149
148
|
@Injectable()
|
|
150
149
|
export class ToolInvocationRegistryManagerImpl implements IToolInvocationRegistryManager {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
getRegistry(clientId: string): ToolInvocationRegistry {
|
|
154
|
-
let registry = this.registries.get(clientId);
|
|
155
|
-
if (!registry) {
|
|
156
|
-
registry = new ToolInvocationRegistryImpl();
|
|
157
|
-
this.registries.set(clientId, registry);
|
|
158
|
-
}
|
|
159
|
-
return registry;
|
|
160
|
-
}
|
|
150
|
+
private registries: Map<string, ToolInvocationRegistry> = new Map();
|
|
161
151
|
|
|
162
|
-
|
|
163
|
-
|
|
152
|
+
getRegistry(clientId: string): ToolInvocationRegistry {
|
|
153
|
+
let registry = this.registries.get(clientId);
|
|
154
|
+
if (!registry) {
|
|
155
|
+
registry = new ToolInvocationRegistryImpl();
|
|
156
|
+
this.registries.set(clientId, registry);
|
|
164
157
|
}
|
|
158
|
+
return registry;
|
|
159
|
+
}
|
|
165
160
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
161
|
+
removeRegistry(clientId: string): void {
|
|
162
|
+
this.registries.delete(clientId);
|
|
163
|
+
}
|
|
170
164
|
|
|
165
|
+
hasRegistry(clientId: string): boolean {
|
|
166
|
+
return this.registries.has(clientId);
|
|
167
|
+
}
|
|
168
|
+
}
|
package/src/common/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreMessage, jsonSchema, streamText, tool } from 'ai';
|
|
1
|
+
import { CoreMessage, ToolExecutionOptions, jsonSchema, streamText, tool } from 'ai';
|
|
2
2
|
|
|
3
3
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
4
|
import { ChatMessageRole, IAIBackServiceOption, IChatMessage } from '@opensumi/ide-core-common';
|
|
@@ -52,6 +52,11 @@ export abstract class BaseLanguageModel {
|
|
|
52
52
|
allFunctions,
|
|
53
53
|
chatReadableStream,
|
|
54
54
|
options.history || [],
|
|
55
|
+
options.modelId,
|
|
56
|
+
options.temperature,
|
|
57
|
+
options.topP,
|
|
58
|
+
options.topK,
|
|
59
|
+
options.providerOptions,
|
|
55
60
|
cancellationToken,
|
|
56
61
|
);
|
|
57
62
|
}
|
|
@@ -61,11 +66,12 @@ export abstract class BaseLanguageModel {
|
|
|
61
66
|
description: toolRequest.description || '',
|
|
62
67
|
// TODO 这里应该是 z.object 而不是 JSON Schema
|
|
63
68
|
parameters: jsonSchema(toolRequest.parameters),
|
|
64
|
-
execute: async (args: any) =>
|
|
69
|
+
execute: async (args: any, options: ToolExecutionOptions) =>
|
|
70
|
+
await toolRequest.handler(JSON.stringify(args), options),
|
|
65
71
|
});
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
protected abstract getModelIdentifier(provider: any): any;
|
|
74
|
+
protected abstract getModelIdentifier(provider: any, modelId?: string): any;
|
|
69
75
|
|
|
70
76
|
protected async handleStreamingRequest(
|
|
71
77
|
provider: any,
|
|
@@ -73,6 +79,11 @@ export abstract class BaseLanguageModel {
|
|
|
73
79
|
tools: ToolRequest[],
|
|
74
80
|
chatReadableStream: ChatReadableStream,
|
|
75
81
|
history: IChatMessage[] = [],
|
|
82
|
+
modelId?: string,
|
|
83
|
+
temperature?: number,
|
|
84
|
+
topP?: number,
|
|
85
|
+
topK?: number,
|
|
86
|
+
providerOptions?: Record<string, any>,
|
|
76
87
|
cancellationToken?: CancellationToken,
|
|
77
88
|
): Promise<any> {
|
|
78
89
|
try {
|
|
@@ -92,15 +103,18 @@ export abstract class BaseLanguageModel {
|
|
|
92
103
|
})),
|
|
93
104
|
{ role: 'user', content: request },
|
|
94
105
|
];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
model: this.getModelIdentifier(provider),
|
|
106
|
+
const stream = streamText({
|
|
107
|
+
model: this.getModelIdentifier(provider, modelId),
|
|
98
108
|
maxTokens: 4096,
|
|
99
109
|
tools: aiTools,
|
|
100
110
|
messages,
|
|
101
111
|
abortSignal: abortController.signal,
|
|
102
112
|
experimental_toolCallStreaming: true,
|
|
103
113
|
maxSteps: 12,
|
|
114
|
+
temperature,
|
|
115
|
+
topP: topP || 0.8,
|
|
116
|
+
topK: topK || 1,
|
|
117
|
+
providerOptions,
|
|
104
118
|
});
|
|
105
119
|
|
|
106
120
|
for await (const chunk of stream.fullStream) {
|
|
@@ -156,7 +156,7 @@ export class BuiltinMCPServer implements IMCPServer {
|
|
|
156
156
|
this.started = true;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
async callTool(toolName: string, arg_string: string): Promise<any> {
|
|
159
|
+
async callTool(toolName: string, toolCallId: string, arg_string: string): Promise<any> {
|
|
160
160
|
if (!this.started) {
|
|
161
161
|
throw new Error('MCP Server not started');
|
|
162
162
|
}
|
|
@@ -171,7 +171,10 @@ export class BuiltinMCPServer implements IMCPServer {
|
|
|
171
171
|
);
|
|
172
172
|
throw error;
|
|
173
173
|
}
|
|
174
|
-
return this.sumiMCPServer.callMCPTool(toolName,
|
|
174
|
+
return this.sumiMCPServer.callMCPTool(toolName, {
|
|
175
|
+
...args,
|
|
176
|
+
toolCallId,
|
|
177
|
+
});
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
async getTools(): ReturnType<Client['listTools']> {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ToolExecutionOptions } from 'ai';
|
|
2
|
+
|
|
1
3
|
import { ILogger } from '@opensumi/ide-core-common';
|
|
2
4
|
|
|
3
5
|
import { MCPServerDescription, MCPServerManager, MCPTool } from '../common/mcp-server-manager';
|
|
4
6
|
import { IToolInvocationRegistryManager, ToolRequest } from '../common/tool-invocation-registry';
|
|
7
|
+
import { getToolName } from '../common/utils';
|
|
5
8
|
|
|
6
9
|
import { BuiltinMCPServer } from './mcp/sumi-mcp-server';
|
|
7
10
|
import { IMCPServer, MCPServerImpl } from './mcp-server';
|
|
@@ -41,12 +44,17 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
41
44
|
return startedServers;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
callTool(
|
|
47
|
+
callTool(
|
|
48
|
+
serverName: string,
|
|
49
|
+
toolName: string,
|
|
50
|
+
toolCallId: string,
|
|
51
|
+
arg_string: string,
|
|
52
|
+
): ReturnType<IMCPServer['callTool']> {
|
|
45
53
|
const server = this.servers.get(serverName);
|
|
46
54
|
if (!server) {
|
|
47
55
|
throw new Error(`MCP server "${toolName}" not found.`);
|
|
48
56
|
}
|
|
49
|
-
return server.callTool(toolName, arg_string);
|
|
57
|
+
return server.callTool(toolName, toolCallId, arg_string);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
async startServer(serverName: string): Promise<void> {
|
|
@@ -62,7 +70,7 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
private convertToToolRequest(tool: MCPTool, serverName: string): ToolRequest {
|
|
65
|
-
const id =
|
|
73
|
+
const id = getToolName(tool.name, serverName);
|
|
66
74
|
|
|
67
75
|
return {
|
|
68
76
|
id,
|
|
@@ -70,9 +78,9 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
70
78
|
providerName: serverName,
|
|
71
79
|
parameters: tool.inputSchema,
|
|
72
80
|
description: tool.description,
|
|
73
|
-
handler: async (arg_string: string) => {
|
|
81
|
+
handler: async (arg_string: string, options?: ToolExecutionOptions) => {
|
|
74
82
|
try {
|
|
75
|
-
const res = await this.callTool(serverName, tool.name, arg_string);
|
|
83
|
+
const res = await this.callTool(serverName, tool.name, options?.toolCallId || '', arg_string);
|
|
76
84
|
this.logger.debug(`[MCP: ${serverName}] ${tool.name} called with ${arg_string}`);
|
|
77
85
|
this.logger.debug('Tool execution result:', res);
|
|
78
86
|
return JSON.stringify(res);
|