@theia/ai-core 1.71.0-next.8 → 1.71.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.
Files changed (79) hide show
  1. package/lib/browser/ai-activation-service.d.ts +9 -0
  2. package/lib/browser/ai-activation-service.d.ts.map +1 -1
  3. package/lib/browser/ai-activation-service.js +5 -0
  4. package/lib/browser/ai-activation-service.js.map +1 -1
  5. package/lib/browser/ai-core-frontend-module.d.ts.map +1 -1
  6. package/lib/browser/ai-core-frontend-module.js +5 -1
  7. package/lib/browser/ai-core-frontend-module.js.map +1 -1
  8. package/lib/browser/ai-settings-service.d.ts +2 -0
  9. package/lib/browser/ai-settings-service.d.ts.map +1 -1
  10. package/lib/browser/ai-settings-service.js +8 -1
  11. package/lib/browser/ai-settings-service.js.map +1 -1
  12. package/lib/browser/frontend-language-model-alias-registry.d.ts +2 -0
  13. package/lib/browser/frontend-language-model-alias-registry.d.ts.map +1 -1
  14. package/lib/browser/frontend-language-model-alias-registry.js +18 -9
  15. package/lib/browser/frontend-language-model-alias-registry.js.map +1 -1
  16. package/lib/browser/frontend-language-model-service.d.ts +6 -4
  17. package/lib/browser/frontend-language-model-service.d.ts.map +1 -1
  18. package/lib/browser/frontend-language-model-service.js +34 -16
  19. package/lib/browser/frontend-language-model-service.js.map +1 -1
  20. package/lib/browser/frontend-prompt-customization-service.d.ts +7 -0
  21. package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -1
  22. package/lib/browser/frontend-prompt-customization-service.js +39 -13
  23. package/lib/browser/frontend-prompt-customization-service.js.map +1 -1
  24. package/lib/browser/product-name-variable-contribution.d.ts +9 -0
  25. package/lib/browser/product-name-variable-contribution.d.ts.map +1 -0
  26. package/lib/browser/product-name-variable-contribution.js +49 -0
  27. package/lib/browser/product-name-variable-contribution.js.map +1 -0
  28. package/lib/browser/product-name-variable-contribution.spec.d.ts +2 -0
  29. package/lib/browser/product-name-variable-contribution.spec.d.ts.map +1 -0
  30. package/lib/browser/product-name-variable-contribution.spec.js +50 -0
  31. package/lib/browser/product-name-variable-contribution.spec.js.map +1 -0
  32. package/lib/browser/skill-prompt-coordinator.d.ts +1 -1
  33. package/lib/browser/skill-prompt-coordinator.d.ts.map +1 -1
  34. package/lib/browser/skill-prompt-coordinator.js +3 -1
  35. package/lib/browser/skill-prompt-coordinator.js.map +1 -1
  36. package/lib/browser/skill-service.d.ts +5 -0
  37. package/lib/browser/skill-service.d.ts.map +1 -1
  38. package/lib/browser/skill-service.js +6 -0
  39. package/lib/browser/skill-service.js.map +1 -1
  40. package/lib/browser/skills-variable-contribution.spec.js +2 -1
  41. package/lib/browser/skills-variable-contribution.spec.js.map +1 -1
  42. package/lib/browser/trust-aware-preference-reader.d.ts +38 -0
  43. package/lib/browser/trust-aware-preference-reader.d.ts.map +1 -0
  44. package/lib/browser/trust-aware-preference-reader.js +114 -0
  45. package/lib/browser/trust-aware-preference-reader.js.map +1 -0
  46. package/lib/browser/trust-aware-preference-reader.spec.d.ts +2 -0
  47. package/lib/browser/trust-aware-preference-reader.spec.d.ts.map +1 -0
  48. package/lib/browser/trust-aware-preference-reader.spec.js +251 -0
  49. package/lib/browser/trust-aware-preference-reader.spec.js.map +1 -0
  50. package/lib/common/ai-core-preferences.d.ts +5 -7
  51. package/lib/common/ai-core-preferences.d.ts.map +1 -1
  52. package/lib/common/ai-core-preferences.js +34 -37
  53. package/lib/common/ai-core-preferences.js.map +1 -1
  54. package/lib/common/language-model.d.ts +25 -4
  55. package/lib/common/language-model.d.ts.map +1 -1
  56. package/lib/common/language-model.js.map +1 -1
  57. package/lib/common/settings-service.d.ts +7 -1
  58. package/lib/common/settings-service.d.ts.map +1 -1
  59. package/lib/node/backend-language-model-registry.d.ts.map +1 -1
  60. package/lib/node/backend-language-model-registry.js +1 -0
  61. package/lib/node/backend-language-model-registry.js.map +1 -1
  62. package/package.json +12 -12
  63. package/src/browser/ai-activation-service.ts +16 -0
  64. package/src/browser/ai-core-frontend-module.ts +6 -1
  65. package/src/browser/ai-settings-service.ts +10 -1
  66. package/src/browser/frontend-language-model-alias-registry.ts +17 -9
  67. package/src/browser/frontend-language-model-service.ts +36 -20
  68. package/src/browser/frontend-prompt-customization-service.ts +38 -15
  69. package/src/browser/product-name-variable-contribution.spec.ts +68 -0
  70. package/src/browser/product-name-variable-contribution.ts +47 -0
  71. package/src/browser/skill-prompt-coordinator.ts +4 -1
  72. package/src/browser/skill-service.ts +10 -0
  73. package/src/browser/skills-variable-contribution.spec.ts +2 -1
  74. package/src/browser/trust-aware-preference-reader.spec.ts +304 -0
  75. package/src/browser/trust-aware-preference-reader.ts +108 -0
  76. package/src/common/ai-core-preferences.ts +38 -41
  77. package/src/common/language-model.ts +28 -4
  78. package/src/common/settings-service.ts +7 -1
  79. package/src/node/backend-language-model-registry.ts +1 -0
@@ -24,12 +24,13 @@ import {
24
24
  NOTIFICATION_TYPE_DESCRIPTIONS,
25
25
  NotificationType
26
26
  } from './notification-types';
27
+ import { ReasoningSettings } from './language-model';
27
28
  import { PreferenceSchema } from '@theia/core/lib/common/preferences/preference-schema';
28
29
 
29
30
  export const AI_CORE_PREFERENCES_TITLE = nls.localize('theia/ai-core/preferences/title', 'AI Features');
30
31
  export const PREFERENCE_NAME_PROMPT_TEMPLATES = 'ai-features.promptTemplates.promptTemplatesFolder';
31
32
  export const PREFERENCE_NAME_REQUEST_SETTINGS = 'ai-features.modelSettings.requestSettings';
32
- export const PREFERENCE_NAME_THINKING_MODE = 'ai-features.thinkingMode.defaults';
33
+ export const PREFERENCE_NAME_REASONING = 'ai-features.reasoning.defaults';
33
34
  export const PREFERENCE_NAME_MAX_RETRIES = 'ai-features.modelSettings.maxRetries';
34
35
  export const PREFERENCE_NAME_DEFAULT_NOTIFICATION_TYPE = 'ai-features.notifications.default';
35
36
  export const PREFERENCE_NAME_SKILL_DIRECTORIES = 'ai-features.skills.skillDirectories';
@@ -149,19 +150,30 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
149
150
  },
150
151
  default: []
151
152
  },
152
- [PREFERENCE_NAME_THINKING_MODE]: {
153
- title: nls.localize('theia/ai/core/thinkingMode/title', 'Thinking Mode Settings'),
154
- markdownDescription: nls.localize('theia/ai/core/thinkingMode/mdDescription',
155
- 'Allows specifying thinking mode settings for models that support extended thinking capabilities.\n\
156
- Each setting consists of:\n\
157
- - `scope`: Defines when the setting applies:\n\
158
- - `modelId` (optional): The model ID to match\n\
159
- - `providerId` (optional): The provider ID to match\n\
160
- - `agentId` (optional): The agent ID to match\n\
161
- - `thinkingMode`: Thinking mode configuration:\n\
162
- - `enabled` (boolean): Whether thinking mode is enabled\n\
163
- - `budgetTokens` (number, optional): Maximum tokens for thinking (if supported by the model)\n\
164
- Settings are matched based on specificity (agent: 100, model: 10, provider: 1 points).'),
153
+ [PREFERENCE_NAME_REASONING]: {
154
+ title: nls.localize('theia/ai/core/reasoning/title', 'Reasoning Defaults'),
155
+ markdownDescription: nls.localize('theia/ai/core/reasoning/mdDescription',
156
+ 'Default value for the chat input\'s reasoning selector, applied to models that support reasoning.\n\n'
157
+ + 'This is a UI-level setting: the chosen level is translated to the provider\'s native API parameters'
158
+ + ' at request time (e.g. Anthropic `thinking` / `output_config.effort`, OpenAI `reasoning.effort`,'
159
+ + ' Gemini `thinkingConfig`) and takes precedence over any raw values supplied via'
160
+ + ' `#ai-features.modelSettings.requestSettings#` for the same fields.\n\n'
161
+ + 'Each entry consists of:\n'
162
+ + '- `scope`: Defines when the setting applies (`modelId`, `providerId`, `agentId`).\n'
163
+ + '- `reasoning.level`: One of `off`, `minimal`, `low`, `medium`, `high`, `auto`.\n\n'
164
+ + 'Precedence at runtime (highest first): session override via the selector this preference →'
165
+ + ' the model\'s declared default. Whichever the selector displays is what gets sent. To override'
166
+ + ' a provider\'s reasoning field manually via `#ai-features.modelSettings.requestSettings#`, set'
167
+ + ' `reasoning.level` to `off` here so the level-based translation is disabled.\n\n'
168
+ + 'Entries are matched based on scope specificity (agent: 100, model: 10, provider: 1 points).\n\n'
169
+ + 'Example:\n'
170
+ + '```json\n'
171
+ + '[\n'
172
+ + ' { "scope": { "providerId": "anthropic" }, "reasoning": { "level": "medium" } },\n'
173
+ + ' { "scope": { "modelId": "openai/gpt-5" }, "reasoning": { "level": "high" } },\n'
174
+ + ' { "scope": { "agentId": "Coder" }, "reasoning": { "level": "off" } }\n'
175
+ + ']\n'
176
+ + '```'),
165
177
  type: 'array',
166
178
  items: {
167
179
  type: 'object',
@@ -169,37 +181,22 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
169
181
  scope: {
170
182
  type: 'object',
171
183
  properties: {
172
- modelId: {
173
- type: 'string',
174
- description: nls.localize('theia/ai/core/thinkingMode/scope/modelId/description', 'The (optional) model id')
175
- },
176
- providerId: {
177
- type: 'string',
178
- description: nls.localize('theia/ai/core/thinkingMode/scope/providerId/description', 'The (optional) provider id to apply the settings to.')
179
- },
180
- agentId: {
181
- type: 'string',
182
- description: nls.localize('theia/ai/core/thinkingMode/scope/agentId/description', 'The (optional) agent id to apply the settings to.')
183
- }
184
+ modelId: { type: 'string' },
185
+ providerId: { type: 'string' },
186
+ agentId: { type: 'string' }
184
187
  }
185
188
  },
186
- thinkingMode: {
189
+ reasoning: {
187
190
  type: 'object',
188
191
  additionalProperties: false,
189
- description: nls.localize('theia/ai/core/thinkingMode/thinkingMode/description', 'Thinking mode configuration.'),
190
192
  properties: {
191
- enabled: {
192
- type: 'boolean',
193
- default: false,
194
- description: nls.localize('theia/ai/core/thinkingMode/thinkingMode/enabled/description', 'Whether thinking mode is enabled.')
195
- },
196
- budgetTokens: {
197
- type: 'number',
198
- description: nls.localize('theia/ai/core/thinkingMode/thinkingMode/budgetTokens/description',
199
- 'Maximum tokens to use for thinking. Only applicable if the model supports thinking budget.')
193
+ level: {
194
+ type: 'string',
195
+ enum: ['off', 'minimal', 'low', 'medium', 'high', 'auto'],
196
+ default: 'auto'
200
197
  }
201
198
  },
202
- required: ['enabled']
199
+ required: ['level']
203
200
  }
204
201
  },
205
202
  additionalProperties: false
@@ -236,7 +233,7 @@ export const aiCorePreferenceSchema: PreferenceSchema = {
236
233
  export interface AICoreConfiguration {
237
234
  [PREFERENCE_NAME_PROMPT_TEMPLATES]: string | undefined;
238
235
  [PREFERENCE_NAME_REQUEST_SETTINGS]: Array<RequestSetting> | undefined;
239
- [PREFERENCE_NAME_THINKING_MODE]: Array<ThinkingModeSetting> | undefined;
236
+ [PREFERENCE_NAME_REASONING]: Array<ReasoningPreferenceEntry> | undefined;
240
237
  [PREFERENCE_NAME_MAX_RETRIES]: number | undefined;
241
238
  [PREFERENCE_NAME_DEFAULT_NOTIFICATION_TYPE]: NotificationType | undefined;
242
239
  [PREFERENCE_NAME_SKILL_DIRECTORIES]: string[] | undefined;
@@ -254,9 +251,9 @@ export interface Scope {
254
251
  agentId?: string;
255
252
  }
256
253
 
257
- export interface ThinkingModeSetting {
254
+ export interface ReasoningPreferenceEntry {
258
255
  scope?: Scope;
259
- thinkingMode?: { enabled: boolean; budgetTokens?: number };
256
+ reasoning?: ReasoningSettings;
260
257
  }
261
258
 
262
259
  export const AICorePreferences = Symbol('AICorePreferences');
@@ -19,9 +19,27 @@ import { inject, injectable, named, postConstruct } from '@theia/core/shared/inv
19
19
 
20
20
  export type MessageActor = 'user' | 'ai' | 'system';
21
21
 
22
- export interface ThinkingModeSettings {
23
- enabled: boolean;
24
- budgetTokens?: number;
22
+ /** Provider-agnostic reasoning level; each provider maps this to its native API. */
23
+ export type ReasoningLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'auto';
24
+
25
+ export interface ReasoningSettings {
26
+ level: ReasoningLevel;
27
+ }
28
+
29
+ /**
30
+ * Shape of a model's reasoning parameter in its native API.
31
+ * - `'effort'`: discrete effort enum.
32
+ * - `'budget'`: numeric token budget.
33
+ */
34
+ export type ReasoningApi = 'effort' | 'budget';
35
+
36
+ /**
37
+ * Declares a model's reasoning capabilities. When unset, the chat UI hides the
38
+ * reasoning selector and providers ignore the `reasoning` field on requests.
39
+ */
40
+ export interface ReasoningSupport {
41
+ readonly supportedLevels: ReadonlyArray<ReasoningLevel>;
42
+ readonly defaultLevel?: ReasoningLevel;
25
43
  }
26
44
 
27
45
  export type LanguageModelMessage = TextMessage | ThinkingMessage | ToolUseMessage | ToolResultMessage | ImageMessage;
@@ -272,7 +290,8 @@ export interface LanguageModelRequest {
272
290
  response_format?: { type: 'text' } | { type: 'json_object' } | ResponseFormatJsonSchema;
273
291
  settings?: { [key: string]: unknown };
274
292
  clientSettings?: { keepToolCalls: boolean; keepThinking: boolean };
275
- thinkingMode?: ThinkingModeSettings;
293
+ /** Provider-agnostic reasoning configuration; providers translate it to their native API. */
294
+ reasoning?: ReasoningSettings;
276
295
  }
277
296
  export interface ResponseFormatJsonSchema {
278
297
  type: 'json_schema';
@@ -323,6 +342,7 @@ export interface UserRequest extends LanguageModelRequest {
323
342
 
324
343
  export interface LanguageModelTextResponse {
325
344
  text: string;
345
+ usage?: UsageResponsePart;
326
346
  }
327
347
  export const isLanguageModelTextResponse = (obj: unknown): obj is LanguageModelTextResponse =>
328
348
  !!(obj && typeof obj === 'object' && 'text' in obj && typeof (obj as { text: unknown }).text === 'string');
@@ -335,6 +355,8 @@ export const isLanguageModelStreamResponsePart = (part: unknown): part is Langua
335
355
  export interface UsageResponsePart {
336
356
  input_tokens: number;
337
357
  output_tokens: number;
358
+ cache_creation_input_tokens?: number;
359
+ cache_read_input_tokens?: number;
338
360
  }
339
361
  export const isUsageResponsePart = (part: unknown): part is UsageResponsePart =>
340
362
  !!(part && typeof part === 'object' &&
@@ -414,6 +436,7 @@ export const isLanguageModelStreamResponse = (obj: unknown): obj is LanguageMode
414
436
  export interface LanguageModelParsedResponse {
415
437
  parsed: unknown;
416
438
  content: string;
439
+ usage?: UsageResponsePart;
417
440
  }
418
441
  export const isLanguageModelParsedResponse = (obj: unknown): obj is LanguageModelParsedResponse =>
419
442
  !!(obj && typeof obj === 'object' && 'parsed' in obj && 'content' in obj);
@@ -437,6 +460,7 @@ export interface LanguageModelMetaData {
437
460
  readonly maxInputTokens?: number;
438
461
  readonly maxOutputTokens?: number;
439
462
  readonly status: LanguageModelStatus;
463
+ readonly reasoningSupport?: ReasoningSupport;
440
464
  }
441
465
 
442
466
  export namespace LanguageModelMetaData {
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
  import { Event } from '@theia/core';
17
- import { LanguageModelRequirement } from './language-model';
17
+ import { LanguageModelRequirement, ReasoningSettings } from './language-model';
18
18
  import { NotificationType } from './notification-types';
19
19
  import { GenericCapabilitySelections } from './capability-utils';
20
20
 
@@ -58,4 +58,10 @@ export interface AgentSettings {
58
58
  * Stores selected IDs for each capability type.
59
59
  */
60
60
  genericCapabilitySelections?: GenericCapabilitySelections;
61
+ /**
62
+ * Persisted reasoning selection for this agent. When set, the chat input's reasoning selector
63
+ * is initialized to this value at session start instead of falling back to the preference
64
+ * default or the model's declared default.
65
+ */
66
+ reasoning?: ReasoningSettings;
61
67
  }
@@ -62,6 +62,7 @@ export class BackendLanguageModelRegistryImpl extends DefaultLanguageModelRegist
62
62
  family: model.family,
63
63
  maxInputTokens: model.maxInputTokens,
64
64
  maxOutputTokens: model.maxOutputTokens,
65
+ reasoningSupport: model.reasoningSupport,
65
66
  };
66
67
  }
67
68
  }