@opensumi/ide-ai-native 3.8.3-next-1742194253.0 → 3.8.3-next-1742203639.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.js +2 -2
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +3 -2
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +11 -2
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +1 -0
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +4 -1
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +6 -0
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts +1 -1
- package/lib/browser/chat/chat.internal.service.d.ts.map +1 -1
- package/lib/browser/chat/chat.internal.service.js +2 -2
- 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 +10 -7
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.d.ts +2 -1
- package/lib/browser/components/ChatEditor.d.ts.map +1 -1
- package/lib/browser/components/ChatEditor.js +5 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatInput.d.ts +1 -1
- package/lib/browser/components/ChatInput.d.ts.map +1 -1
- package/lib/browser/components/ChatInput.js +1 -1
- package/lib/browser/components/ChatInput.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts +3 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +54 -3
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/components.module.less +49 -0
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +21 -9
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/types.d.ts +3 -1
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/mcp/config/components/mcp-config.view.js +2 -2
- 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 +8 -1
- package/lib/browser/mcp/config/components/mcp-server-form.js.map +1 -1
- package/lib/browser/mcp/config/mcp-config.contribution.d.ts.map +1 -1
- package/lib/browser/mcp/config/mcp-config.contribution.js +3 -2
- package/lib/browser/mcp/config/mcp-config.contribution.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +4 -4
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -1
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/types.d.ts +7 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/common/index.d.ts +14 -8
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/node/base-language-model.d.ts +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +15 -4
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +9 -9
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +9 -9
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +2 -0
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +14 -2
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/package.json +23 -23
- package/src/browser/ai-core.contribution.ts +2 -2
- package/src/browser/chat/chat-manager.service.ts +3 -2
- package/src/browser/chat/chat-model.ts +10 -2
- package/src/browser/chat/chat-proxy.service.ts +1 -0
- package/src/browser/chat/chat.feature.registry.ts +10 -1
- package/src/browser/chat/chat.internal.service.ts +2 -2
- package/src/browser/chat/chat.view.tsx +18 -8
- package/src/browser/components/ChatEditor.tsx +8 -0
- package/src/browser/components/ChatInput.tsx +2 -2
- package/src/browser/components/ChatMentionInput.tsx +100 -6
- package/src/browser/components/components.module.less +49 -0
- package/src/browser/components/mention-input/mention-input.tsx +24 -8
- package/src/browser/components/mention-input/types.ts +3 -1
- package/src/browser/context/llm-context.service.ts +2 -0
- package/src/browser/mcp/config/components/mcp-config.view.tsx +2 -2
- package/src/browser/mcp/config/components/mcp-server-form.tsx +8 -1
- package/src/browser/mcp/config/mcp-config.contribution.ts +4 -3
- package/src/browser/mcp/mcp-server-proxy.service.ts +4 -4
- package/src/browser/model/msg-history-manager.ts +1 -1
- package/src/browser/types.ts +8 -1
- package/src/common/index.ts +14 -8
- package/src/common/llm-context.ts +2 -0
- package/src/node/base-language-model.ts +25 -3
- package/src/node/mcp/sumi-mcp-server.ts +9 -9
- package/src/node/mcp-server-manager-impl.ts +17 -2
package/src/browser/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataContent } from 'ai';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { ZodSchema } from 'zod';
|
|
3
4
|
|
|
@@ -129,6 +130,7 @@ export interface IChatSlashCommandHandler {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
export interface IChatFeatureRegistry {
|
|
133
|
+
registerImageUploadProvider(provider: IImageUploadProvider): void;
|
|
132
134
|
registerWelcome(content: IChatWelcomeMessageContent | React.ReactNode, sampleQuestions?: ISampleQuestions[]): void;
|
|
133
135
|
registerSlashCommand(command: IChatSlashCommandItem, handler: IChatSlashCommandHandler): void;
|
|
134
136
|
}
|
|
@@ -140,13 +142,14 @@ export type ChatWelcomeRender = (props: {
|
|
|
140
142
|
export type ChatAIRoleRender = (props: { content: string }) => React.ReactElement | React.JSX.Element;
|
|
141
143
|
export type ChatUserRoleRender = (props: {
|
|
142
144
|
content: string;
|
|
145
|
+
images?: string[];
|
|
143
146
|
agentId?: string;
|
|
144
147
|
command?: string;
|
|
145
148
|
}) => React.ReactElement | React.JSX.Element;
|
|
146
149
|
export type ChatThinkingRender = (props: { thinkingText?: string }) => React.ReactElement | React.JSX.Element;
|
|
147
150
|
export type ChatThinkingResultRender = (props: { thinkingResult?: string }) => React.ReactElement | React.JSX.Element;
|
|
148
151
|
export type ChatInputRender = (props: {
|
|
149
|
-
onSend: (value: string, agentId?: string, command?: string) => void;
|
|
152
|
+
onSend: (value: string, images?: string[], agentId?: string, command?: string) => void;
|
|
150
153
|
onValueChange?: (value: string) => void;
|
|
151
154
|
onExpand?: (value: boolean) => void;
|
|
152
155
|
placeholder?: string;
|
|
@@ -289,6 +292,10 @@ export interface IProblemFixProviderRegistry {
|
|
|
289
292
|
registerHoverFixProvider(handler: IHoverFixHandler): void;
|
|
290
293
|
}
|
|
291
294
|
|
|
295
|
+
export interface IImageUploadProvider {
|
|
296
|
+
imageUpload(file: File): Promise<DataContent | URL>;
|
|
297
|
+
}
|
|
298
|
+
|
|
292
299
|
export const AINativeCoreContribution = Symbol('AINativeCoreContribution');
|
|
293
300
|
|
|
294
301
|
export interface AINativeCoreContribution {
|
package/src/common/index.ts
CHANGED
|
@@ -52,6 +52,10 @@ export interface IChatMessageStructure {
|
|
|
52
52
|
* 用于 chat 面板展示
|
|
53
53
|
*/
|
|
54
54
|
message: string;
|
|
55
|
+
/**
|
|
56
|
+
* 图片
|
|
57
|
+
*/
|
|
58
|
+
images?: string[];
|
|
55
59
|
/**
|
|
56
60
|
* 实际调用的 prompt
|
|
57
61
|
*/
|
|
@@ -131,10 +135,10 @@ export const ChatProxyServiceToken = Symbol('ChatProxyServiceToken');
|
|
|
131
135
|
export const TokenMCPServerProxyService = Symbol('TokenMCPServerProxyService');
|
|
132
136
|
|
|
133
137
|
export interface ISumiMCPServerBackend {
|
|
134
|
-
initBuiltinMCPServer(enabled: boolean): void;
|
|
135
|
-
initExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
136
|
-
getAllMCPTools(): Promise<MCPTool[]>;
|
|
137
|
-
getServers(): Promise<
|
|
138
|
+
$initBuiltinMCPServer(enabled: boolean): void;
|
|
139
|
+
$initExternalMCPServers(servers: MCPServerDescription[]): void;
|
|
140
|
+
$getAllMCPTools(): Promise<MCPTool[]>;
|
|
141
|
+
$getServers(): Promise<
|
|
138
142
|
Array<{
|
|
139
143
|
name: string;
|
|
140
144
|
isStarted: boolean;
|
|
@@ -142,10 +146,10 @@ export interface ISumiMCPServerBackend {
|
|
|
142
146
|
tools: MCPTool[];
|
|
143
147
|
}>
|
|
144
148
|
>;
|
|
145
|
-
startServer(serverName: string): Promise<void>;
|
|
146
|
-
stopServer(serverName: string): Promise<void>;
|
|
147
|
-
addOrUpdateServer(description: MCPServerDescription): void;
|
|
148
|
-
removeServer(name: string): void;
|
|
149
|
+
$startServer(serverName: string): Promise<void>;
|
|
150
|
+
$stopServer(serverName: string): Promise<void>;
|
|
151
|
+
$addOrUpdateServer(description: MCPServerDescription): void;
|
|
152
|
+
$removeServer(name: string): void;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
export const SumiMCPServerProxyServicePath = 'SumiMCPServerProxyServicePath';
|
|
@@ -207,6 +211,7 @@ export interface IChatAgentRequest {
|
|
|
207
211
|
requestId: string;
|
|
208
212
|
command?: string;
|
|
209
213
|
message: string;
|
|
214
|
+
images?: string[];
|
|
210
215
|
regenerate?: boolean;
|
|
211
216
|
}
|
|
212
217
|
|
|
@@ -244,6 +249,7 @@ export type IChatFollowup = IChatReplyFollowup | IChatResponseCommandFollowup;
|
|
|
244
249
|
|
|
245
250
|
export interface IChatRequestMessage {
|
|
246
251
|
prompt: string;
|
|
252
|
+
images?: string[];
|
|
247
253
|
agentId: string;
|
|
248
254
|
command?: string;
|
|
249
255
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CoreMessage,
|
|
3
|
+
CoreUserMessage,
|
|
4
|
+
ImagePart,
|
|
5
|
+
TextPart,
|
|
6
|
+
ToolExecutionOptions,
|
|
7
|
+
jsonSchema,
|
|
8
|
+
streamText,
|
|
9
|
+
tool,
|
|
10
|
+
} from 'ai';
|
|
2
11
|
|
|
3
12
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
13
|
import { IAIBackServiceOption } from '@opensumi/ide-core-common';
|
|
@@ -48,6 +57,7 @@ export abstract class BaseLanguageModel {
|
|
|
48
57
|
options.trimTexts,
|
|
49
58
|
options.system,
|
|
50
59
|
options.maxTokens,
|
|
60
|
+
options.images,
|
|
51
61
|
cancellationToken,
|
|
52
62
|
);
|
|
53
63
|
}
|
|
@@ -77,6 +87,7 @@ export abstract class BaseLanguageModel {
|
|
|
77
87
|
trimTexts?: [string, string],
|
|
78
88
|
systemPrompt?: string,
|
|
79
89
|
maxTokens?: number,
|
|
90
|
+
images?: string[],
|
|
80
91
|
cancellationToken?: CancellationToken,
|
|
81
92
|
): Promise<any> {
|
|
82
93
|
try {
|
|
@@ -89,7 +100,18 @@ export abstract class BaseLanguageModel {
|
|
|
89
100
|
});
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
const messages: CoreMessage[] = [
|
|
103
|
+
const messages: CoreMessage[] = [
|
|
104
|
+
...history,
|
|
105
|
+
{
|
|
106
|
+
role: 'user',
|
|
107
|
+
content: images?.length
|
|
108
|
+
? [
|
|
109
|
+
{ type: 'text', text: request } as TextPart,
|
|
110
|
+
...images.map((image) => ({ type: 'image', image: new URL(image) } as ImagePart)),
|
|
111
|
+
]
|
|
112
|
+
: request,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
93
115
|
const modelInfo = modelId ? this.getModelInfo(modelId) : undefined;
|
|
94
116
|
const stream = streamText({
|
|
95
117
|
model: this.getModelIdentifier(provider, modelId),
|
|
@@ -101,9 +123,9 @@ export abstract class BaseLanguageModel {
|
|
|
101
123
|
maxTokens,
|
|
102
124
|
temperature: modelInfo?.temperature || 0,
|
|
103
125
|
topP: modelInfo?.topP || 0.8,
|
|
104
|
-
topK: modelInfo?.topK || 1,
|
|
105
126
|
system: systemPrompt,
|
|
106
127
|
providerOptions,
|
|
128
|
+
...(!images?.length && { topK: modelInfo?.topK || 1 }),
|
|
107
129
|
});
|
|
108
130
|
|
|
109
131
|
// 状态跟踪变量
|
|
@@ -72,7 +72,7 @@ export class SumiMCPServerBackend extends RPCService<IMCPServerProxyService> imp
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// TODO 这里涉及到 Chat Stream Call 中带上 ClientID,具体方案需要进一步讨论
|
|
75
|
-
async getAllMCPTools(): Promise<MCPTool[]> {
|
|
75
|
+
async $getAllMCPTools(): Promise<MCPTool[]> {
|
|
76
76
|
const registry = this.toolInvocationRegistryManager.getRegistry(this.clientId);
|
|
77
77
|
return registry.getAllFunctions().map((tool) => ({
|
|
78
78
|
name: tool.name || 'no-name',
|
|
@@ -82,20 +82,20 @@ export class SumiMCPServerBackend extends RPCService<IMCPServerProxyService> imp
|
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
public async initBuiltinMCPServer(enabled: boolean) {
|
|
85
|
+
public async $initBuiltinMCPServer(enabled: boolean) {
|
|
86
86
|
const builtinMCPServer = new BuiltinMCPServer(this, this.logger);
|
|
87
87
|
this.mcpServerManager.setClientId(this.clientId);
|
|
88
88
|
await this.mcpServerManager.initBuiltinServer(builtinMCPServer, enabled);
|
|
89
89
|
this.client?.$updateMCPServers();
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
public async initExternalMCPServers(servers: MCPServerDescription[]) {
|
|
92
|
+
public async $initExternalMCPServers(servers: MCPServerDescription[]) {
|
|
93
93
|
this.mcpServerManager.setClientId(this.clientId);
|
|
94
94
|
await this.mcpServerManager.addExternalMCPServers(servers);
|
|
95
95
|
this.client?.$updateMCPServers();
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
async initExposedMCPServer() {
|
|
98
|
+
async $initExposedMCPServer() {
|
|
99
99
|
// 初始化 MCP Server
|
|
100
100
|
this.server = new Server(
|
|
101
101
|
{
|
|
@@ -132,7 +132,7 @@ export class SumiMCPServerBackend extends RPCService<IMCPServerProxyService> imp
|
|
|
132
132
|
return this.server;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
async getServers() {
|
|
135
|
+
async $getServers() {
|
|
136
136
|
const servers = Array.from(this.mcpServerManager.getServers().entries());
|
|
137
137
|
const serverInfos = await Promise.all(
|
|
138
138
|
servers.map(async ([serverName, server]) => {
|
|
@@ -193,21 +193,21 @@ export class SumiMCPServerBackend extends RPCService<IMCPServerProxyService> imp
|
|
|
193
193
|
return builtinServer ? [builtinServer, ...otherServers] : otherServers;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
async startServer(serverName: string) {
|
|
196
|
+
async $startServer(serverName: string) {
|
|
197
197
|
await this.mcpServerManager.startServer(serverName);
|
|
198
198
|
this.client?.$updateMCPServers();
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
async stopServer(serverName: string) {
|
|
201
|
+
async $stopServer(serverName: string) {
|
|
202
202
|
await this.mcpServerManager.stopServer(serverName);
|
|
203
203
|
this.client?.$updateMCPServers();
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
public addOrUpdateServer(description: MCPServerDescription) {
|
|
206
|
+
public $addOrUpdateServer(description: MCPServerDescription) {
|
|
207
207
|
this.mcpServerManager.addOrUpdateServer(description);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
public removeServer(name: string) {
|
|
210
|
+
public $removeServer(name: string) {
|
|
211
211
|
this.mcpServerManager.removeServer(name);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ToolExecutionOptions } from 'ai';
|
|
2
2
|
|
|
3
3
|
import { ILogger } from '@opensumi/ide-core-common';
|
|
4
|
+
import { getShellPath } from '@opensumi/ide-core-node';
|
|
4
5
|
|
|
5
6
|
import { IMCPServer, MCPServerDescription, MCPServerManager, MCPTool } from '../common/mcp-server-manager';
|
|
6
7
|
import { IToolInvocationRegistryManager, ToolRequest } from '../common/tool-invocation-registry';
|
|
@@ -17,6 +18,8 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
17
18
|
// 当前实例对应的 clientId
|
|
18
19
|
private clientId: string;
|
|
19
20
|
|
|
21
|
+
private shellPath: string | undefined;
|
|
22
|
+
|
|
20
23
|
getServers(): Map<string, IMCPServer> {
|
|
21
24
|
return this.servers;
|
|
22
25
|
}
|
|
@@ -26,6 +29,13 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
26
29
|
private readonly logger: ILogger,
|
|
27
30
|
) {}
|
|
28
31
|
|
|
32
|
+
async updateShellPath() {
|
|
33
|
+
const shellPath = await getShellPath();
|
|
34
|
+
if (shellPath) {
|
|
35
|
+
this.shellPath = shellPath;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
setClientId(clientId: string) {
|
|
30
40
|
this.clientId = clientId;
|
|
31
41
|
}
|
|
@@ -132,10 +142,14 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
132
142
|
const existingServer = this.servers.get(description.name);
|
|
133
143
|
if (description.type === MCP_SERVER_TYPE.STDIO) {
|
|
134
144
|
const { name, command, args, env } = description;
|
|
145
|
+
const envs = {
|
|
146
|
+
...env,
|
|
147
|
+
PATH: this.shellPath || process.env.PATH || '',
|
|
148
|
+
};
|
|
135
149
|
if (existingServer) {
|
|
136
|
-
existingServer.update(command, args,
|
|
150
|
+
existingServer.update(command, args, envs);
|
|
137
151
|
} else {
|
|
138
|
-
const newServer = new StdioMCPServer(name, command, args,
|
|
152
|
+
const newServer = new StdioMCPServer(name, command, args, envs, this.logger);
|
|
139
153
|
this.servers.set(name, newServer);
|
|
140
154
|
}
|
|
141
155
|
} else if (description.type === MCP_SERVER_TYPE.SSE) {
|
|
@@ -163,6 +177,7 @@ export class MCPServerManagerImpl implements MCPServerManager {
|
|
|
163
177
|
}
|
|
164
178
|
|
|
165
179
|
async addExternalMCPServers(servers: MCPServerDescription[]): Promise<void> {
|
|
180
|
+
await this.updateShellPath();
|
|
166
181
|
for (const server of servers) {
|
|
167
182
|
this.addOrUpdateServer(server);
|
|
168
183
|
if (!server.enabled) {
|