diff --git a/packages/ai-core/src/browser/ai-settings-service.ts b/packages/ai-core/src/browser/ai-settings-service.ts index cc4f8d5aa3739..f4c2ea5124688 100644 --- a/packages/ai-core/src/browser/ai-settings-service.ts +++ b/packages/ai-core/src/browser/ai-settings-service.ts @@ -22,7 +22,7 @@ import { AISettings, AISettingsService, AgentSettings } from '../common'; @injectable() export class AISettingsServiceImpl implements AISettingsService { @inject(PreferenceService) protected preferenceService: PreferenceService; - static readonly PREFERENCE_NAME = 'ai.settings'; + static readonly PREFERENCE_NAME = 'ai-features.agentSettings'; protected toDispose = new DisposableCollection(); @@ -31,21 +31,20 @@ export class AISettingsServiceImpl implements AISettingsService { async updateAgentSettings(agent: string, agentSettings: Partial): Promise { const settings = await this.getSettings(); - const newAgentSettings = { ...settings.agents[agent], ...agentSettings }; - settings.agents[agent] = newAgentSettings; + const newAgentSettings = { ...settings[agent], ...agentSettings }; + settings[agent] = newAgentSettings; this.preferenceService.set(AISettingsServiceImpl.PREFERENCE_NAME, settings, PreferenceScope.User); this.onDidChangeEmitter.fire(); } async getAgentSettings(agent: string): Promise { const settings = await this.getSettings(); - return settings.agents[agent]; + return settings[agent]; } async getSettings(): Promise { await this.preferenceService.ready; const pref = this.preferenceService.inspect(AISettingsServiceImpl.PREFERENCE_NAME); - return pref?.value ? pref.value : { agents: {} }; + return pref?.value ? pref.value : {}; } - } diff --git a/packages/ai-core/src/common/agent-service.ts b/packages/ai-core/src/common/agent-service.ts index e892a3c0ddfaf..1038864bf81e3 100644 --- a/packages/ai-core/src/common/agent-service.ts +++ b/packages/ai-core/src/common/agent-service.ts @@ -66,8 +66,7 @@ export class AgentServiceImpl implements AgentService { @postConstruct() protected init(): void { this.aiSettingsService?.getSettings().then(settings => { - const allAgentsSettings = settings.agents; - Object.entries(allAgentsSettings).forEach(([agentId, agentSettings]) => { + Object.entries(settings).forEach(([agentId, agentSettings]) => { if (agentSettings.enable === false) { this.disabledAgents.add(agentId); } diff --git a/packages/ai-core/src/common/settings-service.ts b/packages/ai-core/src/common/settings-service.ts index 72d98c546b9d9..2c8f204b96643 100644 --- a/packages/ai-core/src/common/settings-service.ts +++ b/packages/ai-core/src/common/settings-service.ts @@ -17,16 +17,16 @@ import { Event } from '@theia/core'; import { LanguageModelRequirement } from './language-model'; export const AISettingsService = Symbol('AISettingsService'); +/** + * Service to store and retrieve settings on a per-agent basis. + */ export interface AISettingsService { updateAgentSettings(agent: string, agentSettings: Partial): Promise; getAgentSettings(agent: string): Promise; getSettings(): Promise; onDidChange: Event; } -export interface AISettings { - agents: Record -} - +export type AISettings = Record; export interface AgentSettings { languageModelRequirements: LanguageModelRequirement[]; enable: boolean;