@opensumi/ide-ai-native 3.8.2-next-1741413805.0 → 3.8.2-next-1741418699.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/chat/apply.service.js +1 -1
- package/lib/browser/chat/apply.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +2 -3
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +18 -12
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +27 -15
- package/lib/browser/mcp/base-apply.service.d.ts +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +3 -5
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.view.d.ts.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.view.js +21 -7
- package/lib/browser/mcp/config/components/mcp-config.view.js.map +1 -1
- package/lib/browser/mcp/config/components/mcp-server-form.d.ts.map +1 -1
- package/lib/browser/mcp/config/components/mcp-server-form.js +33 -25
- package/lib/browser/mcp/config/components/mcp-server-form.js.map +1 -1
- package/lib/browser/mcp/config/mcp-config.contribution.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/EditFile.js +2 -2
- package/lib/browser/mcp/tools/handlers/EditFile.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/chat/apply.service.ts +1 -1
- package/src/browser/chat/chat.view.tsx +2 -5
- package/src/browser/components/ChatToolRender.module.less +27 -15
- package/src/browser/components/ChatToolRender.tsx +14 -12
- package/src/browser/mcp/base-apply.service.ts +3 -10
- package/src/browser/mcp/config/components/mcp-config.view.tsx +24 -9
- package/src/browser/mcp/config/components/mcp-server-form.tsx +68 -54
- package/src/browser/mcp/config/mcp-config.contribution.ts +1 -1
- package/src/browser/mcp/tools/handlers/EditFile.ts +2 -2
|
@@ -67,35 +67,75 @@ export const MCPServerForm: FC<Props> = ({ visible, initialData, onSave, onCance
|
|
|
67
67
|
);
|
|
68
68
|
}, [initialData]);
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
70
|
+
const validateForm = useCallback(
|
|
71
|
+
(formData: MCPServerFormData) => {
|
|
72
|
+
if (formData.name.trim() === '') {
|
|
73
|
+
messageService.error(localize('ai.native.mcp.name.isRequired'));
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
!initialData &&
|
|
78
|
+
existingServers.some((server) => server.name.toLocaleLowerCase() === formData.name.toLocaleLowerCase())
|
|
79
|
+
) {
|
|
80
|
+
messageService.error(formatLocalize('ai.native.mcp.serverNameExists', formData.name));
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (formData.type === MCP_SERVER_TYPE.SSE) {
|
|
84
|
+
const isServerHostValid = formData.serverHost?.trim() !== '';
|
|
85
|
+
if (!isServerHostValid) {
|
|
86
|
+
messageService.error(localize('ai.native.mcp.serverHost.isRequired'));
|
|
87
|
+
}
|
|
88
|
+
return isServerHostValid;
|
|
89
|
+
}
|
|
90
|
+
const isCommandValid = formData.command?.trim() !== '';
|
|
91
|
+
if (!isCommandValid) {
|
|
92
|
+
messageService.error(localize('ai.native.mcp.command.isRequired'));
|
|
93
|
+
}
|
|
94
|
+
return isCommandValid;
|
|
95
|
+
},
|
|
96
|
+
[existingServers, initialData],
|
|
97
|
+
);
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
const handleSubmit = useCallback(
|
|
100
|
+
(e: FormEvent) => {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
const isValid = validateForm(formData);
|
|
103
|
+
if (!isValid) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const form = {
|
|
107
|
+
...formData,
|
|
108
|
+
};
|
|
109
|
+
if (formData.type === MCP_SERVER_TYPE.SSE) {
|
|
110
|
+
form.serverHost = form.serverHost?.trim();
|
|
111
|
+
} else {
|
|
112
|
+
const args = argsText.split(' ').filter(Boolean);
|
|
113
|
+
const env = envText
|
|
114
|
+
.split('\n')
|
|
115
|
+
.filter(Boolean)
|
|
116
|
+
.reduce((acc, line) => {
|
|
117
|
+
const [key, value] = line.split('=');
|
|
118
|
+
if (key && value) {
|
|
119
|
+
acc[key.trim()] = value.trim();
|
|
120
|
+
}
|
|
121
|
+
return acc;
|
|
122
|
+
}, {} as Record<string, string>);
|
|
123
|
+
form.args = args;
|
|
124
|
+
form.env = env;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setFormData({
|
|
128
|
+
...formData,
|
|
129
|
+
command: '',
|
|
130
|
+
serverHost: '',
|
|
131
|
+
args: [],
|
|
132
|
+
env: {},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
onSave(form);
|
|
136
|
+
},
|
|
137
|
+
[formData, argsText, envText, onSave, validateForm],
|
|
138
|
+
);
|
|
99
139
|
|
|
100
140
|
const handleCommandChange = useCallback(
|
|
101
141
|
(e: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -183,32 +223,6 @@ export const MCPServerForm: FC<Props> = ({ visible, initialData, onSave, onCance
|
|
|
183
223
|
}
|
|
184
224
|
}, [formData, argsText, envText]);
|
|
185
225
|
|
|
186
|
-
const validateForm = useCallback(
|
|
187
|
-
(formData: MCPServerFormData) => {
|
|
188
|
-
if (formData.name.trim() === '') {
|
|
189
|
-
messageService.error(localize('ai.native.mcp.name.isRequired'));
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
if (existingServers.some((server) => server.name.toLocaleLowerCase() === formData.name.toLocaleLowerCase())) {
|
|
193
|
-
messageService.error(formatLocalize('ai.native.mcp.serverNameExists', formData.name));
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
if (formData.type === MCP_SERVER_TYPE.SSE) {
|
|
197
|
-
const isServerHostValid = formData.serverHost?.trim() !== '';
|
|
198
|
-
if (!isServerHostValid) {
|
|
199
|
-
messageService.error(localize('ai.native.mcp.serverHost.isRequired'));
|
|
200
|
-
}
|
|
201
|
-
return isServerHostValid;
|
|
202
|
-
}
|
|
203
|
-
const isCommandValid = formData.command?.trim() !== '';
|
|
204
|
-
if (!isCommandValid) {
|
|
205
|
-
messageService.error(localize('ai.native.mcp.command.isRequired'));
|
|
206
|
-
}
|
|
207
|
-
return isCommandValid;
|
|
208
|
-
},
|
|
209
|
-
[existingServers],
|
|
210
|
-
);
|
|
211
|
-
|
|
212
226
|
return (
|
|
213
227
|
<Modal
|
|
214
228
|
title={initialData ? localize('ai.native.mcp.editMCPServer.title') : localize('ai.native.mcp.addMCPServer.title')}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Autowired } from '@opensumi/di';
|
|
2
2
|
import { LabelService } from '@opensumi/ide-core-browser/lib/services';
|
|
3
|
-
import { Domain,
|
|
3
|
+
import { Domain, URI } from '@opensumi/ide-core-common';
|
|
4
4
|
import {
|
|
5
5
|
BrowserEditorContribution,
|
|
6
6
|
EditorComponentRegistry,
|
|
@@ -13,8 +13,8 @@ export class EditFileHandler {
|
|
|
13
13
|
private applyService: BaseApplyService;
|
|
14
14
|
|
|
15
15
|
async handler(params: { targetFile: string; codeEdit: string; instructions?: string }, toolCallId: string) {
|
|
16
|
-
const { targetFile, codeEdit
|
|
17
|
-
const block = await this.applyService.registerCodeBlock(targetFile, codeEdit, toolCallId
|
|
16
|
+
const { targetFile, codeEdit } = params;
|
|
17
|
+
const block = await this.applyService.registerCodeBlock(targetFile, codeEdit, toolCallId);
|
|
18
18
|
const blockData = await this.applyService.apply(block);
|
|
19
19
|
return blockData;
|
|
20
20
|
}
|