@theia/ai-core 1.64.0-next.35 → 1.64.1

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 (74) hide show
  1. package/README.md +3 -0
  2. package/lib/browser/ai-activation-service.d.ts +22 -9
  3. package/lib/browser/ai-activation-service.d.ts.map +1 -1
  4. package/lib/browser/ai-activation-service.js +18 -35
  5. package/lib/browser/ai-activation-service.js.map +1 -1
  6. package/lib/browser/ai-core-frontend-module.d.ts.map +1 -1
  7. package/lib/browser/ai-core-frontend-module.js +9 -4
  8. package/lib/browser/ai-core-frontend-module.js.map +1 -1
  9. package/lib/browser/ai-core-preferences.d.ts +1 -2
  10. package/lib/browser/ai-core-preferences.d.ts.map +1 -1
  11. package/lib/browser/ai-core-preferences.js +25 -20
  12. package/lib/browser/ai-core-preferences.js.map +1 -1
  13. package/lib/browser/ai-settings-service.d.ts +3 -1
  14. package/lib/browser/ai-settings-service.d.ts.map +1 -1
  15. package/lib/browser/ai-settings-service.js +24 -2
  16. package/lib/browser/ai-settings-service.js.map +1 -1
  17. package/lib/browser/ai-view-contribution.js +1 -1
  18. package/lib/browser/ai-view-contribution.js.map +1 -1
  19. package/lib/browser/frontend-language-model-alias-registry.d.ts +31 -0
  20. package/lib/browser/frontend-language-model-alias-registry.d.ts.map +1 -0
  21. package/lib/browser/frontend-language-model-alias-registry.js +170 -0
  22. package/lib/browser/frontend-language-model-alias-registry.js.map +1 -0
  23. package/lib/browser/frontend-language-model-registry.d.ts +11 -4
  24. package/lib/browser/frontend-language-model-registry.d.ts.map +1 -1
  25. package/lib/browser/frontend-language-model-registry.js +48 -6
  26. package/lib/browser/frontend-language-model-registry.js.map +1 -1
  27. package/lib/browser/index.d.ts +1 -0
  28. package/lib/browser/index.d.ts.map +1 -1
  29. package/lib/browser/index.js +1 -0
  30. package/lib/browser/index.js.map +1 -1
  31. package/lib/common/index.d.ts +1 -0
  32. package/lib/common/index.d.ts.map +1 -1
  33. package/lib/common/index.js +1 -0
  34. package/lib/common/index.js.map +1 -1
  35. package/lib/common/language-model-alias.d.ts +58 -0
  36. package/lib/common/language-model-alias.d.ts.map +1 -0
  37. package/lib/common/language-model-alias.js +20 -0
  38. package/lib/common/language-model-alias.js.map +1 -0
  39. package/lib/common/language-model.d.ts +24 -2
  40. package/lib/common/language-model.d.ts.map +1 -1
  41. package/lib/common/language-model.js +15 -3
  42. package/lib/common/language-model.js.map +1 -1
  43. package/lib/common/prompt-service.d.ts +19 -9
  44. package/lib/common/prompt-service.d.ts.map +1 -1
  45. package/lib/common/prompt-service.js +77 -31
  46. package/lib/common/prompt-service.js.map +1 -1
  47. package/lib/common/protocol.d.ts +4 -0
  48. package/lib/common/protocol.d.ts.map +1 -1
  49. package/lib/common/protocol.js.map +1 -1
  50. package/lib/node/ai-core-backend-module.js +2 -2
  51. package/lib/node/ai-core-backend-module.js.map +1 -1
  52. package/lib/node/backend-language-model-registry.d.ts +2 -1
  53. package/lib/node/backend-language-model-registry.d.ts.map +1 -1
  54. package/lib/node/backend-language-model-registry.js +12 -5
  55. package/lib/node/backend-language-model-registry.js.map +1 -1
  56. package/lib/node/language-model-frontend-delegate.d.ts.map +1 -1
  57. package/lib/node/language-model-frontend-delegate.js +1 -1
  58. package/lib/node/language-model-frontend-delegate.js.map +1 -1
  59. package/package.json +10 -10
  60. package/src/browser/ai-activation-service.ts +26 -34
  61. package/src/browser/ai-core-frontend-module.ts +16 -8
  62. package/src/browser/ai-core-preferences.ts +28 -21
  63. package/src/browser/ai-settings-service.ts +23 -4
  64. package/src/browser/frontend-language-model-alias-registry.ts +166 -0
  65. package/src/browser/frontend-language-model-registry.ts +53 -9
  66. package/src/browser/index.ts +1 -0
  67. package/src/common/index.ts +1 -0
  68. package/src/common/language-model-alias.ts +76 -0
  69. package/src/common/language-model.ts +42 -4
  70. package/src/common/prompt-service.ts +91 -37
  71. package/src/common/protocol.ts +4 -0
  72. package/src/node/ai-core-backend-module.ts +3 -3
  73. package/src/node/backend-language-model-registry.ts +9 -1
  74. package/src/node/language-model-frontend-delegate.ts +2 -2
@@ -32,7 +32,7 @@ let LanguageModelRegistryFrontendDelegateImpl = class LanguageModelRegistryFront
32
32
  exports.LanguageModelRegistryFrontendDelegateImpl = LanguageModelRegistryFrontendDelegateImpl;
33
33
  tslib_1.__decorate([
34
34
  (0, inversify_1.inject)(common_1.LanguageModelRegistry),
35
- tslib_1.__metadata("design:type", backend_language_model_registry_1.BackendLanguageModelRegistry)
35
+ tslib_1.__metadata("design:type", backend_language_model_registry_1.BackendLanguageModelRegistryImpl)
36
36
  ], LanguageModelRegistryFrontendDelegateImpl.prototype, "registry", void 0);
37
37
  exports.LanguageModelRegistryFrontendDelegateImpl = LanguageModelRegistryFrontendDelegateImpl = tslib_1.__decorate([
38
38
  (0, inversify_1.injectable)()
@@ -1 +1 @@
1
- {"version":3,"file":"language-model-frontend-delegate.js","sourceRoot":"","sources":["../../src/node/language-model-frontend-delegate.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAClE,sCAAgG;AAChG,sCAamB;AACnB,uFAAiF;AAG1E,IAAM,yCAAyC,GAA/C,MAAM,yCAAyC;IAKlD,SAAS,CAAC,MAAmC;QACzC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,4BAA4B;QAC9B,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACtG,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;CACJ,CAAA;AAxEY,8EAAiC;AAGlC;IADP,IAAA,kBAAM,EAAC,8BAAqB,CAAC;;mEACU;AAGhC;IADP,IAAA,kBAAM,EAAC,cAAO,CAAC;;iEACQ;4CANf,iCAAiC;IAD7C,IAAA,sBAAU,GAAE;GACA,iCAAiC,CAwE7C"}
1
+ {"version":3,"file":"language-model-frontend-delegate.js","sourceRoot":"","sources":["../../src/node/language-model-frontend-delegate.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAClE,sCAAgG;AAChG,sCAamB;AACnB,uFAAqF;AAG9E,IAAM,yCAAyC,GAA/C,MAAM,yCAAyC;IAKlD,SAAS,CAAC,MAAmC;QACzC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,4BAA4B;QAC9B,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACtG,CAAC;CACJ,CAAA;AAZY,8FAAyC;AAG1C;IADP,IAAA,kBAAM,EAAC,8BAAqB,CAAC;sCACZ,kEAAgC;2EAAC;oDAH1C,yCAAyC;IADrD,IAAA,sBAAU,GAAE;GACA,yCAAyC,CAYrD;AAGM,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAAvC;QASK,gCAA2B,GAAyC,IAAI,GAAG,EAAE,CAAC;IA+D1F,CAAC;IA7DG,SAAS,CAAC,MAAmC;QACzC,IAAI,CAAC,sBAAsB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- AI Core",
5
5
  "dependencies": {
6
- "@theia/core": "1.64.0-next.35+c964c3040",
7
- "@theia/editor": "1.64.0-next.35+c964c3040",
8
- "@theia/filesystem": "1.64.0-next.35+c964c3040",
9
- "@theia/monaco": "1.64.0-next.35+c964c3040",
6
+ "@theia/core": "1.64.1",
7
+ "@theia/editor": "1.64.1",
8
+ "@theia/filesystem": "1.64.1",
9
+ "@theia/monaco": "1.64.1",
10
10
  "@theia/monaco-editor-core": "1.96.302",
11
- "@theia/output": "1.64.0-next.35+c964c3040",
12
- "@theia/variable-resolver": "1.64.0-next.35+c964c3040",
13
- "@theia/workspace": "1.64.0-next.35+c964c3040",
11
+ "@theia/output": "1.64.1",
12
+ "@theia/variable-resolver": "1.64.1",
13
+ "@theia/workspace": "1.64.1",
14
14
  "@types/js-yaml": "^4.0.9",
15
15
  "fast-deep-equal": "^3.1.3",
16
16
  "js-yaml": "^4.1.0",
@@ -53,10 +53,10 @@
53
53
  "watch": "theiaext watch"
54
54
  },
55
55
  "devDependencies": {
56
- "@theia/ext-scripts": "1.63.0"
56
+ "@theia/ext-scripts": "1.64.1"
57
57
  },
58
58
  "nyc": {
59
59
  "extends": "../../configs/nyc.json"
60
60
  },
61
- "gitHead": "c964c30402a92d5ba662fcafa839af99d8760f53"
61
+ "gitHead": "63e84b05db2d2eda0add659f67e9552887b0da8e"
62
62
  }
@@ -14,54 +14,46 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
  import { inject, injectable } from '@theia/core/shared/inversify';
17
- import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
18
- import { Emitter, MaybePromise, Event, } from '@theia/core';
19
- import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
20
- import { PREFERENCE_NAME_ENABLE_AI } from './ai-core-preferences';
17
+ import { Emitter, Event, } from '@theia/core';
18
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
19
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
20
+
21
+ export const AIActivationService = Symbol('AIActivationService');
22
+ /**
23
+ * AIActivationService is used to manage the activation state of AI features in Theia.
24
+ */
25
+ export interface AIActivationService {
26
+ isActive: boolean;
27
+ onDidChangeActiveStatus: Event<boolean>;
28
+ }
21
29
 
22
30
  /**
23
31
  * Context key for the AI features. It is set to `true` if the feature is enabled.
24
32
  */
25
- // We reuse the enablement preference for the context key
26
- export const ENABLE_AI_CONTEXT_KEY = PREFERENCE_NAME_ENABLE_AI;
33
+ export const ENABLE_AI_CONTEXT_KEY = 'ai-features.AiEnable.enableAI';
27
34
 
35
+ /**
36
+ * Default implementation of AIActivationService marks the feature active by default.
37
+ *
38
+ * Adopters may override this implementation to provide custom activation logic.
39
+ *
40
+ * Note that '@theia/ai-ide' also overrides this service to provide activation based on preferences,
41
+ * disabling the feature by default.
42
+ */
28
43
  @injectable()
29
- export class AIActivationService implements FrontendApplicationContribution {
44
+ export class AIActivationServiceImpl implements AIActivationService, FrontendApplicationContribution {
45
+
30
46
  @inject(ContextKeyService)
31
47
  protected readonly contextKeyService: ContextKeyService;
32
48
 
33
- @inject(PreferenceService)
34
- protected preferenceService: PreferenceService;
35
-
36
- protected isAiEnabledKey: ContextKey<boolean>;
49
+ isActive: boolean = true;
37
50
 
38
51
  protected onDidChangeAIEnabled = new Emitter<boolean>();
39
52
  get onDidChangeActiveStatus(): Event<boolean> {
40
53
  return this.onDidChangeAIEnabled.event;
41
54
  }
42
55
 
43
- get isActive(): boolean {
44
- return this.isAiEnabledKey.get() ?? false;
45
- }
46
-
47
- protected updateEnableValue(value: boolean): void {
48
- if (value !== this.isAiEnabledKey.get()) {
49
- this.isAiEnabledKey.set(value);
50
- this.onDidChangeAIEnabled.fire(value);
51
- }
52
- }
53
-
54
- initialize(): MaybePromise<void> {
55
- this.isAiEnabledKey = this.contextKeyService.createKey(ENABLE_AI_CONTEXT_KEY, false);
56
- // make sure we don't miss once preferences are ready
57
- this.preferenceService.ready.then(() => {
58
- const enableValue = this.preferenceService.get<boolean>(PREFERENCE_NAME_ENABLE_AI, false);
59
- this.updateEnableValue(enableValue);
60
- });
61
- this.preferenceService.onPreferenceChanged(e => {
62
- if (e.preferenceName === PREFERENCE_NAME_ENABLE_AI) {
63
- this.updateEnableValue(e.newValue);
64
- }
65
- });
56
+ initialize(): void {
57
+ this.contextKeyService.createKey(ENABLE_AI_CONTEXT_KEY, true);
66
58
  }
67
59
  }
@@ -20,6 +20,8 @@ import {
20
20
  ServiceConnectionProvider,
21
21
  } from '@theia/core/lib/browser/messaging/service-connection-provider';
22
22
  import { ContainerModule } from '@theia/core/shared/inversify';
23
+ import { DefaultLanguageModelAliasRegistry } from './frontend-language-model-alias-registry';
24
+ import { LanguageModelAliasRegistry } from '../common/language-model-alias';
23
25
  import {
24
26
  AIVariableContribution,
25
27
  AIVariableService,
@@ -42,18 +44,18 @@ import {
42
44
  TokenUsageServiceClient,
43
45
  AIVariableResourceResolver,
44
46
  ConfigurableInMemoryResources,
45
- Agent
47
+ Agent,
48
+ FrontendLanguageModelRegistry
46
49
  } from '../common';
47
50
  import {
48
51
  FrontendLanguageModelRegistryImpl,
49
52
  LanguageModelDelegateClientImpl,
50
53
  } from './frontend-language-model-registry';
51
- import { FrontendApplicationContribution, LabelProviderContribution, PreferenceContribution } from '@theia/core/lib/browser';
54
+ import { FrontendApplicationContribution, LabelProviderContribution } from '@theia/core/lib/browser';
52
55
  import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
53
56
  import { LanguageGrammarDefinitionContribution } from '@theia/monaco/lib/browser/textmate';
54
57
  import { AICoreFrontendApplicationContribution } from './ai-core-frontend-application-contribution';
55
58
  import { bindAICorePreferences } from './ai-core-preferences';
56
- import { AgentSettingsPreferenceSchema } from './agent-preferences';
57
59
  import { AISettingsServiceImpl } from './ai-settings-service';
58
60
  import { DefaultPromptFragmentCustomizationService } from './frontend-prompt-customization-service';
59
61
  import { DefaultFrontendVariableService, FrontendVariableService } from './frontend-variable-service';
@@ -63,7 +65,7 @@ import { TheiaVariableContribution } from './theia-variable-contribution';
63
65
  import { TodayVariableContribution } from '../common/today-variable-contribution';
64
66
  import { AgentsVariableContribution } from '../common/agents-variable-contribution';
65
67
  import { OpenEditorsVariableContribution } from './open-editors-variable-contribution';
66
- import { AIActivationService } from './ai-activation-service';
68
+ import { AIActivationService, AIActivationServiceImpl } from './ai-activation-service';
67
69
  import { AgentService, AgentServiceImpl } from '../common/agent-service';
68
70
  import { AICommandHandlerFactory } from './ai-command-handler-factory';
69
71
  import { AISettingsService } from '../common/settings-service';
@@ -83,6 +85,7 @@ export default new ContainerModule(bind => {
83
85
  bindContributionProvider(bind, LanguageModelProvider);
84
86
 
85
87
  bind(FrontendLanguageModelRegistryImpl).toSelf().inSingletonScope();
88
+ bind(FrontendLanguageModelRegistry).toService(FrontendLanguageModelRegistryImpl);
86
89
  bind(LanguageModelRegistry).toService(FrontendLanguageModelRegistryImpl);
87
90
 
88
91
  bind(LanguageModelDelegateClientImpl).toSelf().inSingletonScope();
@@ -106,7 +109,6 @@ export default new ContainerModule(bind => {
106
109
  .inSingletonScope();
107
110
 
108
111
  bindAICorePreferences(bind);
109
- bind(PreferenceContribution).toConstantValue({ schema: AgentSettingsPreferenceSchema });
110
112
 
111
113
  bind(DefaultPromptFragmentCustomizationService).toSelf().inSingletonScope();
112
114
  bind(PromptFragmentCustomizationService).toService(DefaultPromptFragmentCustomizationService);
@@ -118,7 +120,8 @@ export default new ContainerModule(bind => {
118
120
  bind(CommandContribution).toService(PromptTemplateContribution);
119
121
  bind(TabBarToolbarContribution).toService(PromptTemplateContribution);
120
122
 
121
- bind(AISettingsService).to(AISettingsServiceImpl).inRequestScope();
123
+ bind(AISettingsServiceImpl).toSelf().inSingletonScope();
124
+ bind(AISettingsService).toService(AISettingsServiceImpl);
122
125
  bindContributionProvider(bind, AIVariableContribution);
123
126
  bind(DefaultFrontendVariableService).toSelf().inSingletonScope();
124
127
  bind(FrontendVariableService).toService(DefaultFrontendVariableService);
@@ -139,13 +142,15 @@ export default new ContainerModule(bind => {
139
142
  bind(ToolInvocationRegistry).to(ToolInvocationRegistryImpl).inSingletonScope();
140
143
  bindContributionProvider(bind, ToolProvider);
141
144
 
142
- bind(AIActivationService).toSelf().inSingletonScope();
145
+ bind(AIActivationServiceImpl).toSelf().inSingletonScope();
146
+ bind(AIActivationService).toService(AIActivationServiceImpl);
143
147
  bind(FrontendApplicationContribution).toService(AIActivationService);
148
+
144
149
  bind(AgentServiceImpl).toSelf().inSingletonScope();
145
150
  bind(AgentService).toService(AgentServiceImpl);
146
151
 
147
152
  bind(AICommandHandlerFactory).toFactory<CommandHandler>(context => (handler: CommandHandler) => {
148
- const activationService = context.container.get(AIActivationService);
153
+ const activationService = context.container.get<AIActivationService>(AIActivationService);
149
154
  return {
150
155
  execute: (...args: unknown[]) => handler.execute(...args),
151
156
  isEnabled: (...args: unknown[]) => activationService.isActive && (handler.isEnabled?.(...args) ?? true),
@@ -162,6 +167,9 @@ export default new ContainerModule(bind => {
162
167
  bind(TokenUsageFrontendService).to(TokenUsageFrontendServiceImpl).inSingletonScope();
163
168
  bind(TokenUsageServiceClient).to(TokenUsageServiceClientImpl).inSingletonScope();
164
169
 
170
+ bind(DefaultLanguageModelAliasRegistry).toSelf().inSingletonScope();
171
+ bind(LanguageModelAliasRegistry).toService(DefaultLanguageModelAliasRegistry);
172
+
165
173
  bind(TokenUsageService).toDynamicValue(ctx => {
166
174
  const connection = ctx.container.get<ServiceConnectionProvider>(RemoteConnectionProvider);
167
175
  const client = ctx.container.get<TokenUsageServiceClient>(TokenUsageServiceClient);
@@ -15,7 +15,7 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { nls } from '@theia/core';
18
- import { PreferenceContribution, PreferenceProxy, PreferenceSchema } from '@theia/core/lib/browser';
18
+ import { PreferenceProxy, PreferenceSchema } from '@theia/core/lib/browser';
19
19
  import { PreferenceProxyFactory } from '@theia/core/lib/browser/preferences/injectable-preference-proxy';
20
20
  import { interfaces } from '@theia/core/shared/inversify';
21
21
  import {
@@ -24,32 +24,17 @@ import {
24
24
  NotificationType
25
25
  } from '../common/notification-types';
26
26
 
27
- export const AI_CORE_PREFERENCES_TITLE = nls.localize('theia/ai/core/prefs/title', '✨ AI Features [Alpha]');
28
- export const PREFERENCE_NAME_ENABLE_AI = 'ai-features.AiEnable.enableAI';
27
+ export const AI_CORE_PREFERENCES_TITLE = nls.localize('theia/ai/core/prefs/title', '✨ AI Features [Beta]');
29
28
  export const PREFERENCE_NAME_PROMPT_TEMPLATES = 'ai-features.promptTemplates.promptTemplatesFolder';
30
29
  export const PREFERENCE_NAME_REQUEST_SETTINGS = 'ai-features.modelSettings.requestSettings';
31
30
  export const PREFERENCE_NAME_MAX_RETRIES = 'ai-features.modelSettings.maxRetries';
32
31
  export const PREFERENCE_NAME_DEFAULT_NOTIFICATION_TYPE = 'ai-features.notifications.default';
33
32
 
33
+ export const LANGUAGE_MODEL_ALIASES_PREFERENCE = 'ai-features.languageModelAliases';
34
+
34
35
  export const aiCorePreferenceSchema: PreferenceSchema = {
35
36
  type: 'object',
36
37
  properties: {
37
- [PREFERENCE_NAME_ENABLE_AI]: {
38
- title: AI_CORE_PREFERENCES_TITLE,
39
- markdownDescription: nls.localize('theia/ai/core/enableAI/mdDescription',
40
- '❗ This setting allows you to access the latest AI capabilities (Alpha version).\
41
- \n\
42
- Please note that these features are in an alpha phase, which means they may \
43
- undergo changes and will be further improved. It is important to be aware that these features may generate\
44
- continuous requests to the language models (LLMs) you provide access to. This might incur costs that you\
45
- need to monitor closely. By enabling this option, you acknowledge these risks.\
46
- \n\
47
- **Please note! The settings below in this section will only take effect\n\
48
- once the main feature setting is enabled. After enabling the feature, you need to configure at least one\
49
- LLM provider below. Also see [the documentation](https://theia-ide.org/docs/user_ai/)**.'),
50
- type: 'boolean',
51
- default: false,
52
- },
53
38
  [PREFERENCE_NAME_PROMPT_TEMPLATES]: {
54
39
  title: AI_CORE_PREFERENCES_TITLE,
55
40
  description: nls.localize('theia/ai/core/promptTemplates/description',
@@ -148,12 +133,35 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
148
133
  type: 'string',
149
134
  enum: [...NOTIFICATION_TYPES],
150
135
  default: NOTIFICATION_TYPE_OFF
136
+ },
137
+ [LANGUAGE_MODEL_ALIASES_PREFERENCE]: {
138
+ title: nls.localize('theia/ai/core/preference/languageModelAliases/title', 'Language Model Aliases'),
139
+ markdownDescription: nls.localize('theia/ai/core/preference/languageModelAliases/description', 'Configure models for each language model alias in the \
140
+ [AI Configuration View]({0}). Alternatiely you can set the settings manually in the settings.json: \n\
141
+ ```\n\
142
+ "default/code": {\n\
143
+ "selectedModel": "anthropic/claude-opus-4-20250514"\n\
144
+ }\n\```',
145
+ 'command:aiConfiguration:open'
146
+ ),
147
+ type: 'object',
148
+ additionalProperties: {
149
+ type: 'object',
150
+ properties: {
151
+ selectedModel: {
152
+ type: 'string',
153
+ description: nls.localize('theia/ai/core/preference/languageModelAliases/selectedModel', 'The user-selected model for this alias.')
154
+ }
155
+ },
156
+ required: ['selectedModel'],
157
+ additionalProperties: false
158
+ },
159
+ default: {},
151
160
  }
152
161
  }
153
162
  };
154
163
 
155
164
  export interface AICoreConfiguration {
156
- [PREFERENCE_NAME_ENABLE_AI]: boolean | undefined;
157
165
  [PREFERENCE_NAME_PROMPT_TEMPLATES]: string | undefined;
158
166
  [PREFERENCE_NAME_REQUEST_SETTINGS]: Array<RequestSetting> | undefined;
159
167
  [PREFERENCE_NAME_MAX_RETRIES]: number | undefined;
@@ -180,7 +188,6 @@ export function bindAICorePreferences(bind: interfaces.Bind): void {
180
188
  const factory = ctx.container.get<PreferenceProxyFactory>(PreferenceProxyFactory);
181
189
  return factory(aiCorePreferenceSchema);
182
190
  }).inSingletonScope();
183
- bind(PreferenceContribution).toConstantValue({ schema: aiCorePreferenceSchema });
184
191
  }
185
192
 
186
193
  /**
@@ -13,14 +13,18 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
- import { DisposableCollection, Emitter, Event } from '@theia/core';
16
+ import { DisposableCollection, Emitter, Event, ILogger } from '@theia/core';
17
17
  import { PreferenceScope, PreferenceService } from '@theia/core/lib/browser';
18
- import { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
19
19
  import { JSONObject } from '@theia/core/shared/@lumino/coreutils';
20
20
  import { AISettings, AISettingsService, AgentSettings } from '../common';
21
21
 
22
22
  @injectable()
23
23
  export class AISettingsServiceImpl implements AISettingsService {
24
+
25
+ @inject(ILogger)
26
+ protected readonly logger: ILogger;
27
+
24
28
  @inject(PreferenceService) protected preferenceService: PreferenceService;
25
29
  static readonly PREFERENCE_NAME = 'ai-features.agentSettings';
26
30
 
@@ -29,12 +33,27 @@ export class AISettingsServiceImpl implements AISettingsService {
29
33
  protected readonly onDidChangeEmitter = new Emitter<void>();
30
34
  onDidChange: Event<void> = this.onDidChangeEmitter.event;
31
35
 
36
+ @postConstruct()
37
+ protected init(): void {
38
+ this.toDispose.push(
39
+ this.preferenceService.onPreferenceChanged(event => {
40
+ if (event.preferenceName === AISettingsServiceImpl.PREFERENCE_NAME) {
41
+ this.onDidChangeEmitter.fire();
42
+ }
43
+ })
44
+ );
45
+ }
46
+
32
47
  async updateAgentSettings(agent: string, agentSettings: Partial<AgentSettings>): Promise<void> {
33
48
  const settings = await this.getSettings();
34
49
  const newAgentSettings = { ...settings[agent], ...agentSettings };
35
50
  settings[agent] = newAgentSettings;
36
- this.preferenceService.set(AISettingsServiceImpl.PREFERENCE_NAME, settings, PreferenceScope.User);
37
- this.onDidChangeEmitter.fire();
51
+ try {
52
+ await this.preferenceService.set(AISettingsServiceImpl.PREFERENCE_NAME, settings, PreferenceScope.User);
53
+ } catch (e) {
54
+ this.onDidChangeEmitter.fire();
55
+ this.logger.warn('Updating the preferences was unsuccessful: ' + e);
56
+ }
38
57
  }
39
58
 
40
59
  async getAgentSettings(agent: string): Promise<AgentSettings | undefined> {
@@ -0,0 +1,166 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024-2025 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import { Emitter, Event } from '@theia/core';
19
+ import { LanguageModelAlias, LanguageModelAliasRegistry } from '../common/language-model-alias';
20
+ import { PreferenceScope, PreferenceService } from '@theia/core/lib/browser';
21
+ import { LANGUAGE_MODEL_ALIASES_PREFERENCE } from './ai-core-preferences';
22
+ import { Deferred } from '@theia/core/lib/common/promise-util';
23
+
24
+ @injectable()
25
+ export class DefaultLanguageModelAliasRegistry implements LanguageModelAliasRegistry {
26
+
27
+ protected aliases: LanguageModelAlias[] = [
28
+ {
29
+ id: 'default/code',
30
+ defaultModelIds: [
31
+ 'anthropic/claude-3-7-sonnet-latest',
32
+ 'openai/gpt-4.1',
33
+ 'google/gemini-2.5-pro-exp-03-25'
34
+ ],
35
+ description: 'Optimized for code understanding and generation tasks.'
36
+ },
37
+ {
38
+ id: 'default/universal',
39
+ defaultModelIds: [
40
+ 'openai/gpt-4o',
41
+ 'anthropic/claude-3-7-sonnet-latest',
42
+ 'google/gemini-2.5-pro-exp-03-25'
43
+ ],
44
+ description: 'Well-balanced for both code and general language use.'
45
+ },
46
+ {
47
+ id: 'default/code-completion',
48
+ defaultModelIds: [
49
+ 'openai/gpt-4.1',
50
+ 'anthropic/claude-3-7-sonnet-latest',
51
+ 'google/gemini-2.5-pro-exp-03-25'
52
+ ],
53
+ description: 'Best suited for code autocompletion scenarios.'
54
+ },
55
+ {
56
+ id: 'default/summarize',
57
+ defaultModelIds: [
58
+ 'openai/gpt-4.1',
59
+ 'anthropic/claude-3-7-sonnet-latest',
60
+ 'google/gemini-2.5-pro-exp-03-25'
61
+ ],
62
+ description: 'Models prioritized for summarization and condensation of content.'
63
+ }
64
+ ];
65
+ protected readonly onDidChangeEmitter = new Emitter<void>();
66
+ readonly onDidChange: Event<void> = this.onDidChangeEmitter.event;
67
+
68
+ @inject(PreferenceService)
69
+ protected readonly preferenceService: PreferenceService;
70
+
71
+ protected readonly _ready = new Deferred<void>();
72
+ get ready(): Promise<void> {
73
+ return this._ready.promise;
74
+ }
75
+
76
+ @postConstruct()
77
+ protected init(): void {
78
+ this.preferenceService.ready.then(() => {
79
+ this.loadFromPreference();
80
+ this.preferenceService.onPreferenceChanged(ev => {
81
+ if (ev.preferenceName === LANGUAGE_MODEL_ALIASES_PREFERENCE) {
82
+ this.loadFromPreference();
83
+ }
84
+ });
85
+ this._ready.resolve();
86
+ }, err => {
87
+ this._ready.reject(err);
88
+ });
89
+ }
90
+
91
+ addAlias(alias: LanguageModelAlias): void {
92
+ const idx = this.aliases.findIndex(a => a.id === alias.id);
93
+ if (idx !== -1) {
94
+ this.aliases[idx] = alias;
95
+ } else {
96
+ this.aliases.push(alias);
97
+ }
98
+ this.saveToPreference();
99
+ this.onDidChangeEmitter.fire();
100
+ }
101
+
102
+ removeAlias(id: string): void {
103
+ const idx = this.aliases.findIndex(a => a.id === id);
104
+ if (idx !== -1) {
105
+ this.aliases.splice(idx, 1);
106
+ this.saveToPreference();
107
+ this.onDidChangeEmitter.fire();
108
+ }
109
+ }
110
+
111
+ getAliases(): LanguageModelAlias[] {
112
+ return [...this.aliases];
113
+ }
114
+
115
+ resolveAlias(id: string): string[] | undefined {
116
+ const alias = this.aliases.find(a => a.id === id);
117
+ if (!alias) {
118
+ return undefined;
119
+ }
120
+ if (alias.selectedModelId) {
121
+ return [alias.selectedModelId];
122
+ }
123
+ return alias.defaultModelIds;
124
+ }
125
+
126
+ /**
127
+ * Set the selected model for the given alias id.
128
+ * Updates the alias' selectedModelId to the given modelId, persists, and fires onDidChange.
129
+ */
130
+ selectModelForAlias(aliasId: string, modelId: string): void {
131
+ const alias = this.aliases.find(a => a.id === aliasId);
132
+ if (alias) {
133
+ alias.selectedModelId = modelId;
134
+ this.saveToPreference();
135
+ this.onDidChangeEmitter.fire();
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Load aliases from the persisted setting
141
+ */
142
+ protected loadFromPreference(): void {
143
+ const stored = this.preferenceService.get<{ [name: string]: { selectedModel: string } }>(LANGUAGE_MODEL_ALIASES_PREFERENCE) || {};
144
+ this.aliases.forEach(alias => {
145
+ if (stored[alias.id] && stored[alias.id].selectedModel) {
146
+ alias.selectedModelId = stored[alias.id].selectedModel;
147
+ } else {
148
+ delete alias.selectedModelId;
149
+ }
150
+ });
151
+ }
152
+
153
+ /**
154
+ * Persist the current aliases and their selected models to the setting
155
+ */
156
+ protected saveToPreference(): void {
157
+ const map: { [name: string]: { selectedModel: string } } = {};
158
+ for (const alias of this.aliases) {
159
+ if (alias.selectedModelId) {
160
+ map[alias.id] = { selectedModel: alias.selectedModelId };
161
+ }
162
+ }
163
+ this.preferenceService.set(LANGUAGE_MODEL_ALIASES_PREFERENCE, map, PreferenceScope.User);
164
+ }
165
+ }
166
+
@@ -27,13 +27,14 @@ import {
27
27
  import {
28
28
  AISettingsService,
29
29
  DefaultLanguageModelRegistryImpl,
30
+ FrontendLanguageModelRegistry,
30
31
  isLanguageModelParsedResponse,
31
32
  isLanguageModelStreamResponse,
32
33
  isLanguageModelStreamResponseDelegate,
33
34
  isLanguageModelTextResponse,
34
- isModelMatching,
35
35
  isTextResponsePart,
36
36
  LanguageModel,
37
+ LanguageModelAliasRegistry,
37
38
  LanguageModelDelegateClient,
38
39
  LanguageModelFrontendDelegate,
39
40
  LanguageModelMetaData,
@@ -43,12 +44,15 @@ import {
43
44
  LanguageModelResponse,
44
45
  LanguageModelSelector,
45
46
  LanguageModelStreamResponsePart,
46
- ToolCallResult,
47
+ ToolCallResult
47
48
  } from '../common';
48
49
 
49
50
  @injectable()
50
51
  export class LanguageModelDelegateClientImpl
51
52
  implements LanguageModelDelegateClient, LanguageModelRegistryClient {
53
+ onLanguageModelUpdated(id: string): void {
54
+ this.receiver.onLanguageModelUpdated(id);
55
+ }
52
56
  protected receiver: FrontendLanguageModelRegistryImpl;
53
57
 
54
58
  setReceiver(receiver: FrontendLanguageModelRegistryImpl): void {
@@ -85,7 +89,11 @@ interface StreamState {
85
89
 
86
90
  @injectable()
87
91
  export class FrontendLanguageModelRegistryImpl
88
- extends DefaultLanguageModelRegistryImpl {
92
+ extends DefaultLanguageModelRegistryImpl
93
+ implements FrontendLanguageModelRegistry {
94
+
95
+ @inject(LanguageModelAliasRegistry)
96
+ protected aliasRegistry: LanguageModelAliasRegistry;
89
97
 
90
98
  // called by backend
91
99
  languageModelAdded(metadata: LanguageModelMetaData): void {
@@ -95,6 +103,28 @@ export class FrontendLanguageModelRegistryImpl
95
103
  languageModelRemoved(id: string): void {
96
104
  this.removeLanguageModels([id]);
97
105
  }
106
+
107
+ // called by backend when a model is updated
108
+ onLanguageModelUpdated(id: string): void {
109
+ this.updateLanguageModelFromBackend(id);
110
+ }
111
+
112
+ /**
113
+ * Fetch the updated model metadata from the backend and update the registry.
114
+ */
115
+ protected async updateLanguageModelFromBackend(id: string): Promise<void> {
116
+ try {
117
+ const backendModels = await this.registryDelegate.getLanguageModelDescriptions();
118
+ const updated = backendModels.find((m: { id: string }) => m.id === id);
119
+ if (updated) {
120
+ // Remove the old model and add the updated one
121
+ this.removeLanguageModels([id]);
122
+ this.addLanguageModels([updated]);
123
+ }
124
+ } catch (err) {
125
+ this.logger.error('Failed to update language model from backend', err);
126
+ }
127
+ }
98
128
  @inject(LanguageModelRegistryFrontendDelegate)
99
129
  protected registryDelegate: LanguageModelRegistryFrontendDelegate;
100
130
 
@@ -312,20 +342,34 @@ export class FrontendLanguageModelRegistryImpl
312
342
  streamState.reject?.(error);
313
343
  }
314
344
 
315
- override async selectLanguageModels(request: LanguageModelSelector): Promise<LanguageModel[]> {
345
+ override async selectLanguageModels(request: LanguageModelSelector): Promise<LanguageModel[] | undefined> {
316
346
  await this.initialized;
317
347
  const userSettings = (await this.settingsService.getAgentSettings(request.agent))?.languageModelRequirements?.find(req => req.purpose === request.purpose);
318
- if (userSettings?.identifier) {
319
- const model = await this.getLanguageModel(userSettings.identifier);
348
+ const identifier = userSettings?.identifier ?? request.identifier;
349
+ if (identifier) {
350
+ const model = await this.getReadyLanguageModel(identifier);
320
351
  if (model) {
321
352
  return [model];
322
353
  }
323
354
  }
324
- return this.languageModels.filter(model => isModelMatching(request, model));
355
+ // Previously we returned the default model here, but this is not really transparent for the user so we do not select any model here.
356
+ return undefined;
325
357
  }
326
358
 
327
- override async selectLanguageModel(request: LanguageModelSelector): Promise<LanguageModel | undefined> {
328
- return (await this.selectLanguageModels(request))[0];
359
+ async getReadyLanguageModel(idOrAlias: string): Promise<LanguageModel | undefined> {
360
+ await this.aliasRegistry.ready;
361
+ const modelIds = this.aliasRegistry.resolveAlias(idOrAlias);
362
+ if (modelIds) {
363
+ for (const modelId of modelIds) {
364
+ const model = await this.getLanguageModel(modelId);
365
+ if (model?.status.status === 'ready') {
366
+ return model;
367
+ }
368
+ }
369
+ return undefined;
370
+ }
371
+ const languageModel = await this.getLanguageModel(idOrAlias);
372
+ return languageModel?.status.status === 'ready' ? languageModel : undefined;
329
373
  }
330
374
  }
331
375