Skip to content

feat: support MCP Agent #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 51 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,57 +81,57 @@
"yauzl": "^3.1.3"
},
"dependencies": {
"@opensumi/ide-addons": "3.8.0",
"@opensumi/ide-ai-native": "3.8.0",
"@opensumi/ide-comments": "3.8.0",
"@opensumi/ide-core-browser": "3.8.0",
"@opensumi/ide-core-common": "3.8.0",
"@opensumi/ide-core-electron-main": "3.8.0",
"@opensumi/ide-core-node": "3.8.0",
"@opensumi/ide-debug": "3.8.0",
"@opensumi/ide-decoration": "3.8.0",
"@opensumi/ide-design": "3.8.0",
"@opensumi/ide-editor": "3.8.0",
"@opensumi/ide-electron-basic": "3.8.0",
"@opensumi/ide-explorer": "3.8.0",
"@opensumi/ide-express-file-server": "3.8.0",
"@opensumi/ide-extension": "3.8.0",
"@opensumi/ide-extension-manager": "3.8.0",
"@opensumi/ide-extension-storage": "3.8.0",
"@opensumi/ide-file-scheme": "3.8.0",
"@opensumi/ide-file-search": "3.8.0",
"@opensumi/ide-file-service": "3.8.0",
"@opensumi/ide-file-tree-next": "3.8.0",
"@opensumi/ide-i18n": "3.8.0",
"@opensumi/ide-keymaps": "3.8.0",
"@opensumi/ide-logs": "3.8.0",
"@opensumi/ide-main-layout": "3.8.0",
"@opensumi/ide-markdown": "3.8.0",
"@opensumi/ide-markers": "3.8.0",
"@opensumi/ide-menu-bar": "3.8.0",
"@opensumi/ide-monaco": "3.8.0",
"@opensumi/ide-monaco-enhance": "3.8.0",
"@opensumi/ide-opened-editor": "3.8.0",
"@opensumi/ide-outline": "3.8.0",
"@opensumi/ide-output": "3.8.0",
"@opensumi/ide-overlay": "3.8.0",
"@opensumi/ide-preferences": "3.8.0",
"@opensumi/ide-process": "3.8.0",
"@opensumi/ide-quick-open": "3.8.0",
"@opensumi/ide-remote-opener": "3.8.0",
"@opensumi/ide-scm": "3.8.0",
"@opensumi/ide-search": "3.8.0",
"@opensumi/ide-status-bar": "3.8.0",
"@opensumi/ide-storage": "3.8.0",
"@opensumi/ide-task": "3.8.0",
"@opensumi/ide-terminal-next": "3.8.0",
"@opensumi/ide-testing": "3.8.0",
"@opensumi/ide-theme": "3.8.0",
"@opensumi/ide-toolbar": "3.8.0",
"@opensumi/ide-variable": "3.8.0",
"@opensumi/ide-webview": "3.8.0",
"@opensumi/ide-workspace": "3.8.0",
"@opensumi/ide-workspace-edit": "3.8.0",
"@opensumi/ide-addons": "3.8.1-next-1741253659.0",
"@opensumi/ide-ai-native": "3.8.1-next-1741253659.0",
"@opensumi/ide-comments": "3.8.1-next-1741253659.0",
"@opensumi/ide-core-browser": "3.8.1-next-1741253659.0",
"@opensumi/ide-core-common": "3.8.1-next-1741253659.0",
"@opensumi/ide-core-electron-main": "3.8.1-next-1741253659.0",
"@opensumi/ide-core-node": "3.8.1-next-1741253659.0",
"@opensumi/ide-debug": "3.8.1-next-1741253659.0",
"@opensumi/ide-decoration": "3.8.1-next-1741253659.0",
"@opensumi/ide-design": "3.8.1-next-1741253659.0",
"@opensumi/ide-editor": "3.8.1-next-1741253659.0",
"@opensumi/ide-electron-basic": "3.8.1-next-1741253659.0",
"@opensumi/ide-explorer": "3.8.1-next-1741253659.0",
"@opensumi/ide-express-file-server": "3.8.1-next-1741253659.0",
"@opensumi/ide-extension": "3.8.1-next-1741253659.0",
"@opensumi/ide-extension-manager": "3.8.1-next-1741253659.0",
"@opensumi/ide-extension-storage": "3.8.1-next-1741253659.0",
"@opensumi/ide-file-scheme": "3.8.1-next-1741253659.0",
"@opensumi/ide-file-search": "3.8.1-next-1741253659.0",
"@opensumi/ide-file-service": "3.8.1-next-1741253659.0",
"@opensumi/ide-file-tree-next": "3.8.1-next-1741253659.0",
"@opensumi/ide-i18n": "3.8.1-next-1741253659.0",
"@opensumi/ide-keymaps": "3.8.1-next-1741253659.0",
"@opensumi/ide-logs": "3.8.1-next-1741253659.0",
"@opensumi/ide-main-layout": "3.8.1-next-1741253659.0",
"@opensumi/ide-markdown": "3.8.1-next-1741253659.0",
"@opensumi/ide-markers": "3.8.1-next-1741253659.0",
"@opensumi/ide-menu-bar": "3.8.1-next-1741253659.0",
"@opensumi/ide-monaco": "3.8.1-next-1741253659.0",
"@opensumi/ide-monaco-enhance": "3.8.1-next-1741253659.0",
"@opensumi/ide-opened-editor": "3.8.1-next-1741253659.0",
"@opensumi/ide-outline": "3.8.1-next-1741253659.0",
"@opensumi/ide-output": "3.8.1-next-1741253659.0",
"@opensumi/ide-overlay": "3.8.1-next-1741253659.0",
"@opensumi/ide-preferences": "3.8.1-next-1741253659.0",
"@opensumi/ide-process": "3.8.1-next-1741253659.0",
"@opensumi/ide-quick-open": "3.8.1-next-1741253659.0",
"@opensumi/ide-remote-opener": "3.8.1-next-1741253659.0",
"@opensumi/ide-scm": "3.8.1-next-1741253659.0",
"@opensumi/ide-search": "3.8.1-next-1741253659.0",
"@opensumi/ide-status-bar": "3.8.1-next-1741253659.0",
"@opensumi/ide-storage": "3.8.1-next-1741253659.0",
"@opensumi/ide-task": "3.8.1-next-1741253659.0",
"@opensumi/ide-terminal-next": "3.8.1-next-1741253659.0",
"@opensumi/ide-testing": "3.8.1-next-1741253659.0",
"@opensumi/ide-theme": "3.8.1-next-1741253659.0",
"@opensumi/ide-toolbar": "3.8.1-next-1741253659.0",
"@opensumi/ide-variable": "3.8.1-next-1741253659.0",
"@opensumi/ide-webview": "3.8.1-next-1741253659.0",
"@opensumi/ide-workspace": "3.8.1-next-1741253659.0",
"@opensumi/ide-workspace-edit": "3.8.1-next-1741253659.0",
"@opensumi/tree-sitter-wasm": "1.1.2",
"@vscode/spdlog": "^0.15.0",
"buffer": "^6.0.3",
Expand Down
105 changes: 20 additions & 85 deletions src/ai/browser/ai-model.contribution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Autowired } from '@opensumi/di'
import { AI_NATIVE_SETTING_GROUP_ID, localize, MaybePromise, Delayer, CommandService } from '@opensumi/ide-core-common';
import { AI_NATIVE_SETTING_GROUP_ID, localize, MaybePromise, Delayer, CommandService, AINativeSettingSectionsId } from '@opensumi/ide-core-common';
import { Domain, PreferenceContribution, PreferenceSchema, ClientAppContribution, IClientApp, PreferenceService, COMMON_COMMANDS, IPreferenceSettingsService } from '@opensumi/ide-core-browser'
import { ISettingRegistry, SettingContribution } from '@opensumi/ide-preferences';
import { AIModelServicePath, IAIModelServiceProxy, ModelSettingId } from '../common'
Expand All @@ -18,46 +18,6 @@ const aiNativePreferenceSchema: PreferenceSchema = {
[ModelSettingId.apiKey]: {
type: 'string',
},
[ModelSettingId.chatModelName]: {
type: 'string',
},
[ModelSettingId.chatSystemPrompt]: {
type: 'string',
},
[ModelSettingId.chatMaxTokens]: {
type: 'number',
minimum: 0,
defaultValue: 1024,
description: localize('preference.ai.model.maxTokens.description'),
},
[ModelSettingId.chatTemperature]: {
type: 'string',
// minimum: 0,
// maximum: 1,
defaultValue: '0.20',
description: localize('preference.ai.model.temperature.description'),
},
[ModelSettingId.chatPresencePenalty]: {
type: 'string',
// minimum: -2.0,
// maximum: 2.0,
defaultValue: '1.0',
description: localize('preference.ai.model.presencePenalty.description'),
},
[ModelSettingId.chatFrequencyPenalty]: {
type: 'string',
// minimum: -2.0,
// maximum: 2.0,
defaultValue: '1.0',
description: localize('preference.ai.model.frequencyPenalty.description'),
},
[ModelSettingId.chatTopP]: {
type: 'string',
// minimum: 0,
// maximum: 1,
defaultValue: '1',
description: localize('preference.ai.model.topP.description'),
},
[ModelSettingId.codeModelName]: {
type: 'string',
description: localize('preference.ai.model.code.modelName.tooltip')
Expand Down Expand Up @@ -145,11 +105,8 @@ export class AIModelContribution implements PreferenceContribution, SettingContr
delayer.trigger(() => this.setModeConfig(values))
})
})
this.checkModelConfig(values).then((valid) => {
if (valid) {
delayer.trigger(() => this.setModeConfig(values))
}
})
delayer.trigger(() => this.setModeConfig(values));
this.checkModelConfig();
}

registerSetting(registry: ISettingRegistry): void {
Expand All @@ -164,34 +121,6 @@ export class AIModelContribution implements PreferenceContribution, SettingContr
id: ModelSettingId.apiKey,
localized: 'preference.ai.model.apiKey',
},
{
id: ModelSettingId.chatModelName,
localized: 'preference.ai.model.chat.modelName',
},
{
id: ModelSettingId.chatSystemPrompt,
localized: 'preference.ai.model.chat.systemPrompt',
},
{
id: ModelSettingId.chatMaxTokens,
localized: 'preference.ai.model.chat.maxTokens',
},
{
id: ModelSettingId.chatTemperature,
localized: 'preference.ai.model.chat.temperature',
},
{
id: ModelSettingId.chatPresencePenalty,
localized: 'preference.ai.model.chat.presencePenalty',
},
{
id: ModelSettingId.chatFrequencyPenalty,
localized: 'preference.ai.model.chat.frequencyPenalty',
},
{
id: ModelSettingId.chatTopP,
localized: 'preference.ai.model.chat.topP',
},
{
id: ModelSettingId.codeModelName,
localized: 'preference.ai.model.code.modelName',
Expand Down Expand Up @@ -228,18 +157,24 @@ export class AIModelContribution implements PreferenceContribution, SettingContr
});
}

private async checkModelConfig(values: Record<string, any>) {
if (values.baseUrl && values.chatModelName) {
return true
}
const res = await this.messageService.info(localize('ai.model.noConfig'), [
localize('ai.model.go')
])
if (res === localize('ai.model.go')) {
await this.commandService.executeCommand(COMMON_COMMANDS.OPEN_PREFERENCES.id)
this.preferenceSettingsService.scrollToPreference(ModelSettingId.baseUrl)
private async checkModelConfig() {
const requirePreference = [
AINativeSettingSectionsId.DeepseekApiKey,
AINativeSettingSectionsId.OpenaiApiKey,
AINativeSettingSectionsId.AnthropicApiKey,
];

const hasRequirePreference = requirePreference.some(preference => !!this.preferenceService.getValid(preference));
if (!hasRequirePreference) {
this.preferenceService.has(AINativeSettingSectionsId.DeepseekApiKey);
const res = await this.messageService.info(localize('ai.model.noConfig'), [
localize('ai.model.go')
]);
if (res === localize('ai.model.go')) {
await this.commandService.executeCommand(COMMON_COMMANDS.OPEN_PREFERENCES.id)
this.preferenceSettingsService.scrollToPreference(AINativeSettingSectionsId.LLMModelSelection);
}
}
return false
}

private setModeConfig(values: Record<string, any>) {
Expand Down
Loading