@theia/ai-chat 1.61.0-next.8 → 1.61.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 (98) hide show
  1. package/lib/browser/ai-chat-frontend-contribution.d.ts +11 -0
  2. package/lib/browser/ai-chat-frontend-contribution.d.ts.map +1 -0
  3. package/lib/browser/ai-chat-frontend-contribution.js +56 -0
  4. package/lib/browser/ai-chat-frontend-contribution.js.map +1 -0
  5. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
  6. package/lib/browser/ai-chat-frontend-module.js +21 -3
  7. package/lib/browser/ai-chat-frontend-module.js.map +1 -1
  8. package/lib/browser/change-set-decorator-service.d.ts +24 -0
  9. package/lib/browser/change-set-decorator-service.d.ts.map +1 -0
  10. package/lib/browser/change-set-decorator-service.js +66 -0
  11. package/lib/browser/change-set-decorator-service.js.map +1 -0
  12. package/lib/browser/change-set-file-element.d.ts +7 -4
  13. package/lib/browser/change-set-file-element.d.ts.map +1 -1
  14. package/lib/browser/change-set-file-element.js +20 -12
  15. package/lib/browser/change-set-file-element.js.map +1 -1
  16. package/lib/browser/change-set-file-resource.d.ts +1 -42
  17. package/lib/browser/change-set-file-resource.d.ts.map +1 -1
  18. package/lib/browser/change-set-file-resource.js +1 -136
  19. package/lib/browser/change-set-file-resource.js.map +1 -1
  20. package/lib/browser/change-set-variable.d.ts.map +1 -1
  21. package/lib/browser/change-set-variable.js +13 -4
  22. package/lib/browser/change-set-variable.js.map +1 -1
  23. package/lib/browser/context-file-variable-label-provider.js +1 -1
  24. package/lib/browser/context-file-variable-label-provider.js.map +1 -1
  25. package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
  26. package/lib/browser/file-chat-variable-contribution.js +29 -27
  27. package/lib/browser/file-chat-variable-contribution.js.map +1 -1
  28. package/lib/browser/task-context-service.d.ts +40 -0
  29. package/lib/browser/task-context-service.d.ts.map +1 -0
  30. package/lib/browser/task-context-service.js +148 -0
  31. package/lib/browser/task-context-service.js.map +1 -0
  32. package/lib/browser/task-context-storage-service.d.ts +18 -0
  33. package/lib/browser/task-context-storage-service.d.ts.map +1 -0
  34. package/lib/browser/task-context-storage-service.js +77 -0
  35. package/lib/browser/task-context-storage-service.js.map +1 -0
  36. package/lib/browser/task-context-variable-contribution.d.ts +20 -0
  37. package/lib/browser/task-context-variable-contribution.d.ts.map +1 -0
  38. package/lib/browser/task-context-variable-contribution.js +101 -0
  39. package/lib/browser/task-context-variable-contribution.js.map +1 -0
  40. package/lib/browser/task-context-variable-label-provider.d.ts +21 -0
  41. package/lib/browser/task-context-variable-label-provider.d.ts.map +1 -0
  42. package/lib/browser/task-context-variable-label-provider.js +83 -0
  43. package/lib/browser/task-context-variable-label-provider.js.map +1 -0
  44. package/lib/browser/task-context-variable.d.ts +3 -0
  45. package/lib/browser/task-context-variable.d.ts.map +1 -0
  46. package/lib/browser/task-context-variable.js +29 -0
  47. package/lib/browser/task-context-variable.js.map +1 -0
  48. package/lib/common/chat-agents.d.ts +2 -1
  49. package/lib/common/chat-agents.d.ts.map +1 -1
  50. package/lib/common/chat-agents.js +5 -0
  51. package/lib/common/chat-agents.js.map +1 -1
  52. package/lib/common/chat-model.d.ts +173 -8
  53. package/lib/common/chat-model.d.ts.map +1 -1
  54. package/lib/common/chat-model.js +329 -17
  55. package/lib/common/chat-model.js.map +1 -1
  56. package/lib/common/chat-request-parser.d.ts +1 -1
  57. package/lib/common/chat-request-parser.d.ts.map +1 -1
  58. package/lib/common/chat-request-parser.js +1 -1
  59. package/lib/common/chat-request-parser.js.map +1 -1
  60. package/lib/common/chat-service.d.ts +2 -0
  61. package/lib/common/chat-service.d.ts.map +1 -1
  62. package/lib/common/chat-service.js +18 -25
  63. package/lib/common/chat-service.js.map +1 -1
  64. package/lib/common/chat-session-naming-service.d.ts.map +1 -1
  65. package/lib/common/chat-session-naming-service.js +3 -3
  66. package/lib/common/chat-session-naming-service.js.map +1 -1
  67. package/lib/common/chat-session-summary-agent-prompt.d.ts +5 -0
  68. package/lib/common/chat-session-summary-agent-prompt.d.ts.map +1 -0
  69. package/lib/common/chat-session-summary-agent-prompt.js +30 -0
  70. package/lib/common/chat-session-summary-agent-prompt.js.map +1 -0
  71. package/lib/common/chat-session-summary-agent.d.ts +17 -0
  72. package/lib/common/chat-session-summary-agent.d.ts.map +1 -0
  73. package/lib/common/chat-session-summary-agent.js +48 -0
  74. package/lib/common/chat-session-summary-agent.js.map +1 -0
  75. package/lib/common/context-summary-variable.js +1 -1
  76. package/lib/common/context-summary-variable.js.map +1 -1
  77. package/package.json +11 -11
  78. package/src/browser/ai-chat-frontend-contribution.ts +49 -0
  79. package/src/browser/ai-chat-frontend-module.ts +25 -4
  80. package/src/browser/change-set-decorator-service.ts +72 -0
  81. package/src/browser/change-set-file-element.ts +18 -13
  82. package/src/browser/change-set-file-resource.ts +1 -138
  83. package/src/browser/change-set-variable.ts +14 -6
  84. package/src/browser/context-file-variable-label-provider.ts +1 -1
  85. package/src/browser/file-chat-variable-contribution.ts +26 -29
  86. package/src/browser/task-context-service.ts +144 -0
  87. package/src/browser/task-context-storage-service.ts +75 -0
  88. package/src/browser/task-context-variable-contribution.ts +93 -0
  89. package/src/browser/task-context-variable-label-provider.ts +67 -0
  90. package/src/browser/task-context-variable.ts +28 -0
  91. package/src/common/chat-agents.ts +6 -1
  92. package/src/common/chat-model.ts +507 -18
  93. package/src/common/chat-request-parser.ts +2 -2
  94. package/src/common/chat-service.ts +17 -26
  95. package/src/common/chat-session-naming-service.ts +4 -3
  96. package/src/common/chat-session-summary-agent-prompt.ts +28 -0
  97. package/src/common/chat-session-summary-agent.ts +42 -0
  98. package/src/common/context-summary-variable.ts +1 -1
@@ -0,0 +1,93 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2025 EclipseSource GmbH and others.
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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { AIVariableContext, AIVariableOpener, AIVariableResolutionRequest, AIVariableResolver, ResolvedAIContextVariable } from '@theia/ai-core';
19
+ import { AIVariableCompletionContext, FrontendVariableContribution, FrontendVariableService } from '@theia/ai-core/lib/browser';
20
+ import { MaybePromise, QuickInputService, QuickPickItem } from '@theia/core';
21
+ import { ChatService } from '../common';
22
+ import * as monaco from '@theia/monaco-editor-core';
23
+ import { TaskContextService } from './task-context-service';
24
+ import { TASK_CONTEXT_VARIABLE } from './task-context-variable';
25
+ import { VARIABLE_ADD_CONTEXT_COMMAND } from './ai-chat-frontend-contribution';
26
+
27
+ @injectable()
28
+ export class TaskContextVariableContribution implements FrontendVariableContribution, AIVariableResolver, AIVariableOpener {
29
+ @inject(QuickInputService) protected readonly quickInputService: QuickInputService;
30
+ @inject(ChatService) protected readonly chatService: ChatService;
31
+ @inject(TaskContextService) protected readonly taskContextService: TaskContextService;
32
+
33
+ registerVariables(service: FrontendVariableService): void {
34
+ service.registerResolver(TASK_CONTEXT_VARIABLE, this);
35
+ service.registerArgumentPicker(TASK_CONTEXT_VARIABLE, this.pickSession.bind(this));
36
+ service.registerArgumentCompletionProvider(TASK_CONTEXT_VARIABLE, this.provideCompletionItems.bind(this));
37
+ service.registerOpener(TASK_CONTEXT_VARIABLE, this);
38
+ }
39
+
40
+ protected async pickSession(): Promise<string | undefined> {
41
+ const items = this.getItems();
42
+ const selection = await this.quickInputService.showQuickPick(items);
43
+ return selection?.id;
44
+ }
45
+
46
+ protected async provideCompletionItems(
47
+ model: monaco.editor.ITextModel,
48
+ position: monaco.Position,
49
+ matchString?: string
50
+ ): Promise<monaco.languages.CompletionItem[] | undefined> {
51
+ const context = AIVariableCompletionContext.get(TASK_CONTEXT_VARIABLE.name, model, position, matchString);
52
+ if (!context) { return undefined; }
53
+ const { userInput, range, prefix } = context;
54
+ return this.getItems().filter(candidate => QuickPickItem.is(candidate) && candidate.label.startsWith(userInput)).map(({ label, id }: QuickPickItem) => ({
55
+ label,
56
+ kind: monaco.languages.CompletionItemKind.Class,
57
+ range,
58
+ insertText: `${prefix}${id}`,
59
+ detail: id,
60
+ filterText: userInput,
61
+ command: {
62
+ title: VARIABLE_ADD_CONTEXT_COMMAND.label!,
63
+ id: VARIABLE_ADD_CONTEXT_COMMAND.id,
64
+ arguments: [TASK_CONTEXT_VARIABLE.name, id]
65
+ }
66
+ }));
67
+ }
68
+
69
+ protected getItems(): QuickPickItem[] {
70
+ const currentSession = this.chatService.getSessions().find(candidate => candidate.isActive);
71
+ const existingSummaries = this.taskContextService.getAll().filter(candidate => !currentSession || currentSession.id !== candidate.sessionId);
72
+ return existingSummaries;
73
+ }
74
+
75
+ canResolve(request: AIVariableResolutionRequest, context: AIVariableContext): MaybePromise<number> {
76
+ return request.variable.id === TASK_CONTEXT_VARIABLE.id ? 10000 : -5;
77
+ }
78
+
79
+ async resolve(request: AIVariableResolutionRequest, _context: AIVariableContext): Promise<ResolvedAIContextVariable | undefined> {
80
+ if (request.variable.id !== TASK_CONTEXT_VARIABLE.id || !request.arg) { return; }
81
+ const value = await this.taskContextService.getSummary(request.arg).catch(() => undefined);
82
+ return value ? { ...request, value, contextValue: value } : undefined;
83
+ }
84
+
85
+ canOpen(request: AIVariableResolutionRequest, context: AIVariableContext): MaybePromise<number> {
86
+ return this.canResolve(request, context);
87
+ }
88
+
89
+ async open(request: AIVariableResolutionRequest, _context: AIVariableContext): Promise<void> {
90
+ if (request.variable.id !== TASK_CONTEXT_VARIABLE.id || !request.arg) { throw new Error('Unable to service open request.'); }
91
+ return this.taskContextService.open(request.arg);
92
+ }
93
+ }
@@ -0,0 +1,67 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2025 Eclipse GmbH and others.
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 { AIVariableResolutionRequest } from '@theia/ai-core';
18
+ import { URI } from '@theia/core';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { codicon, LabelProviderContribution } from '@theia/core/lib/browser';
21
+ import { TaskContextVariableContribution } from './task-context-variable-contribution';
22
+ import { ChatService } from '../common';
23
+ import { TaskContextService } from './task-context-service';
24
+ import { TASK_CONTEXT_VARIABLE } from './task-context-variable';
25
+
26
+ @injectable()
27
+ export class TaskContextVariableLabelProvider implements LabelProviderContribution {
28
+ @inject(ChatService) protected readonly chatService: ChatService;
29
+ @inject(TaskContextVariableContribution) protected readonly chatVariableContribution: TaskContextVariableContribution;
30
+ @inject(TaskContextService) protected readonly taskContextService: TaskContextService;
31
+ protected isMine(element: object): element is AIVariableResolutionRequest & { arg: string } {
32
+ return AIVariableResolutionRequest.is(element) && element.variable.id === TASK_CONTEXT_VARIABLE.id && !!element.arg;
33
+ }
34
+
35
+ canHandle(element: object): number {
36
+ return this.isMine(element) ? 10 : -1;
37
+ }
38
+
39
+ getIcon(element: object): string | undefined {
40
+ if (!this.isMine(element)) { return undefined; }
41
+ return codicon('clippy');
42
+ }
43
+
44
+ getName(element: object): string | undefined {
45
+ if (!this.isMine(element)) { return undefined; }
46
+ const session = this.chatService.getSession(element.arg);
47
+ return session?.title ?? this.taskContextService.getLabel(element.arg) ?? session?.id ?? element.arg;
48
+ }
49
+
50
+ getLongName(element: object): string | undefined {
51
+ const short = this.getName(element);
52
+ const details = this.getDetails(element);
53
+ return `'${short}' (${details})`;
54
+ }
55
+
56
+ getDetails(element: object): string | undefined {
57
+ if (!this.isMine(element)) { return undefined; }
58
+ return `id: ${element.arg}`;
59
+ }
60
+
61
+ protected getUri(element: object): URI | undefined {
62
+ if (!AIVariableResolutionRequest.is(element)) {
63
+ return undefined;
64
+ }
65
+ return new URI(element.arg);
66
+ }
67
+ }
@@ -0,0 +1,28 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2025 EclipseSource GmbH and others.
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 { AIVariable } from '@theia/ai-core';
18
+ import { codiconArray } from '@theia/core/lib/browser';
19
+
20
+ export const TASK_CONTEXT_VARIABLE: AIVariable = {
21
+ id: 'taskContext',
22
+ description: 'Provides context information for a task, e.g. the plan for completing a task or a summary of a previous sessions',
23
+ name: 'taskContext',
24
+ label: 'Task Context',
25
+ iconClasses: codiconArray('clippy'),
26
+ isContextVariable: true,
27
+ args: [{ name: 'context-id', description: 'The ID of the task context to retrieve, or a chat session to summarize.' }]
28
+ };
@@ -22,6 +22,7 @@
22
22
  import {
23
23
  AgentSpecificVariables,
24
24
  AIVariableContext,
25
+ AIVariableResolutionRequest,
25
26
  CommunicationRecordingService,
26
27
  getTextOfResponse,
27
28
  isTextResponsePart,
@@ -59,7 +60,7 @@ import {
59
60
  MarkdownChatResponseContentImpl,
60
61
  ToolCallChatResponseContentImpl,
61
62
  ChatRequestModel,
62
- ThinkingChatResponseContentImpl
63
+ ThinkingChatResponseContentImpl,
63
64
  } from './chat-model';
64
65
  import { parseContents } from './parse-contents';
65
66
  import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
@@ -91,6 +92,10 @@ export namespace ChatSessionContext {
91
92
  export function is(candidate: unknown): candidate is ChatSessionContext {
92
93
  return typeof candidate === 'object' && !!candidate && 'model' in candidate;
93
94
  }
95
+
96
+ export function getVariables(context: ChatSessionContext): readonly AIVariableResolutionRequest[] {
97
+ return context.request?.context.variables.map(AIVariableResolutionRequest.fromResolved) ?? context.model.context.getVariables();
98
+ }
94
99
  }
95
100
 
96
101
  /**