@theia/ai-chat 1.58.2 → 1.59.0-next.62

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 (103) hide show
  1. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
  2. package/lib/browser/ai-chat-frontend-module.js +10 -13
  3. package/lib/browser/ai-chat-frontend-module.js.map +1 -1
  4. package/lib/browser/ai-chat-preferences.d.ts +1 -0
  5. package/lib/browser/ai-chat-preferences.d.ts.map +1 -1
  6. package/lib/browser/ai-chat-preferences.js +12 -3
  7. package/lib/browser/ai-chat-preferences.js.map +1 -1
  8. package/lib/browser/change-set-file-element.d.ts +24 -6
  9. package/lib/browser/change-set-file-element.d.ts.map +1 -1
  10. package/lib/browser/change-set-file-element.js +105 -15
  11. package/lib/browser/change-set-file-element.js.map +1 -1
  12. package/lib/browser/change-set-file-resource.d.ts +40 -8
  13. package/lib/browser/change-set-file-resource.d.ts.map +1 -1
  14. package/lib/browser/change-set-file-resource.js +123 -37
  15. package/lib/browser/change-set-file-resource.js.map +1 -1
  16. package/lib/browser/change-set-file-service.d.ts +9 -3
  17. package/lib/browser/change-set-file-service.d.ts.map +1 -1
  18. package/lib/browser/change-set-file-service.js +35 -13
  19. package/lib/browser/change-set-file-service.js.map +1 -1
  20. package/lib/browser/context-file-variable-label-provider.d.ts +14 -0
  21. package/lib/browser/context-file-variable-label-provider.d.ts.map +1 -0
  22. package/lib/browser/context-file-variable-label-provider.js +63 -0
  23. package/lib/browser/context-file-variable-label-provider.js.map +1 -0
  24. package/lib/browser/context-variable-label-provider.d.ts +9 -0
  25. package/lib/browser/context-variable-label-provider.d.ts.map +1 -0
  26. package/lib/browser/context-variable-label-provider.js +55 -0
  27. package/lib/browser/context-variable-label-provider.js.map +1 -0
  28. package/lib/browser/file-chat-variable-contribution.d.ts +18 -0
  29. package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -0
  30. package/lib/browser/file-chat-variable-contribution.js +135 -0
  31. package/lib/browser/file-chat-variable-contribution.js.map +1 -0
  32. package/lib/browser/frontend-chat-service.d.ts +10 -3
  33. package/lib/browser/frontend-chat-service.d.ts.map +1 -1
  34. package/lib/browser/frontend-chat-service.js +39 -19
  35. package/lib/browser/frontend-chat-service.js.map +1 -1
  36. package/lib/common/chat-agents.d.ts +47 -24
  37. package/lib/common/chat-agents.d.ts.map +1 -1
  38. package/lib/common/chat-agents.js +50 -19
  39. package/lib/common/chat-agents.js.map +1 -1
  40. package/lib/common/chat-history-entry.js +1 -1
  41. package/lib/common/chat-history-entry.js.map +1 -1
  42. package/lib/common/chat-model.d.ts +58 -35
  43. package/lib/common/chat-model.d.ts.map +1 -1
  44. package/lib/common/chat-model.js +96 -53
  45. package/lib/common/chat-model.js.map +1 -1
  46. package/lib/common/chat-service.d.ts +32 -12
  47. package/lib/common/chat-service.d.ts.map +1 -1
  48. package/lib/common/chat-service.js +77 -19
  49. package/lib/common/chat-service.js.map +1 -1
  50. package/lib/common/chat-tool-request-service.d.ts +5 -5
  51. package/lib/common/chat-tool-request-service.d.ts.map +1 -1
  52. package/lib/common/chat-tool-request-service.js.map +1 -1
  53. package/lib/common/custom-chat-agent.d.ts +7 -10
  54. package/lib/common/custom-chat-agent.d.ts.map +1 -1
  55. package/lib/common/custom-chat-agent.js +7 -11
  56. package/lib/common/custom-chat-agent.js.map +1 -1
  57. package/lib/common/index.d.ts +0 -3
  58. package/lib/common/index.d.ts.map +1 -1
  59. package/lib/common/index.js +0 -3
  60. package/lib/common/index.js.map +1 -1
  61. package/lib/common/parse-contents.d.ts +2 -2
  62. package/lib/common/parse-contents.d.ts.map +1 -1
  63. package/lib/common/parse-contents.js.map +1 -1
  64. package/lib/common/parse-contents.spec.d.ts.map +1 -1
  65. package/lib/common/parse-contents.spec.js.map +1 -1
  66. package/lib/common/response-content-matcher.d.ts +3 -3
  67. package/lib/common/response-content-matcher.d.ts.map +1 -1
  68. package/lib/common/response-content-matcher.js.map +1 -1
  69. package/package.json +12 -10
  70. package/src/browser/ai-chat-frontend-module.ts +14 -18
  71. package/src/browser/ai-chat-preferences.ts +13 -2
  72. package/src/browser/change-set-file-element.ts +99 -20
  73. package/src/browser/change-set-file-resource.ts +125 -39
  74. package/src/browser/change-set-file-service.ts +38 -16
  75. package/src/browser/context-file-variable-label-provider.ts +62 -0
  76. package/src/browser/context-variable-label-provider.ts +56 -0
  77. package/src/browser/file-chat-variable-contribution.ts +143 -0
  78. package/src/browser/frontend-chat-service.ts +40 -26
  79. package/src/common/chat-agents.ts +72 -27
  80. package/src/common/chat-history-entry.ts +1 -1
  81. package/src/common/chat-model.ts +138 -74
  82. package/src/common/chat-service.ts +96 -23
  83. package/src/common/chat-tool-request-service.ts +5 -5
  84. package/src/common/custom-chat-agent.ts +8 -20
  85. package/src/common/index.ts +0 -3
  86. package/src/common/parse-contents.spec.ts +2 -2
  87. package/src/common/parse-contents.ts +2 -2
  88. package/src/common/response-content-matcher.ts +3 -3
  89. package/lib/common/command-chat-agents.d.ts +0 -33
  90. package/lib/common/command-chat-agents.d.ts.map +0 -1
  91. package/lib/common/command-chat-agents.js +0 -329
  92. package/lib/common/command-chat-agents.js.map +0 -1
  93. package/lib/common/orchestrator-chat-agent.d.ts +0 -22
  94. package/lib/common/orchestrator-chat-agent.d.ts.map +0 -1
  95. package/lib/common/orchestrator-chat-agent.js +0 -167
  96. package/lib/common/orchestrator-chat-agent.js.map +0 -1
  97. package/lib/common/universal-chat-agent.d.ts +0 -16
  98. package/lib/common/universal-chat-agent.d.ts.map +0 -1
  99. package/lib/common/universal-chat-agent.js +0 -109
  100. package/lib/common/universal-chat-agent.js.map +0 -1
  101. package/src/common/command-chat-agents.ts +0 -354
  102. package/src/common/orchestrator-chat-agent.ts +0 -179
  103. package/src/common/universal-chat-agent.ts +0 -117
@@ -19,22 +19,23 @@
19
19
  *--------------------------------------------------------------------------------------------*/
20
20
  // Partially copied from https://github.com/microsoft/vscode/blob/a2cab7255c0df424027be05d58e1b7b941f4ea60/src/vs/workbench/contrib/chat/common/chatService.ts
21
21
 
22
+ import { AIVariableResolutionRequest, AIVariableService, ResolvedAIContextVariable } from '@theia/ai-core';
23
+ import { Emitter, ILogger, generateUuid } from '@theia/core';
22
24
  import { inject, injectable, optional } from '@theia/core/shared/inversify';
25
+ import { Event } from '@theia/core/shared/vscode-languageserver-protocol';
26
+ import { ChatAgentService } from './chat-agent-service';
27
+ import { ChatAgent, ChatAgentLocation } from './chat-agents';
23
28
  import {
24
29
  ChatModel,
25
- ChatModelImpl,
30
+ MutableChatModel,
26
31
  ChatRequest,
27
32
  ChatRequestModel,
28
33
  ChatResponseModel,
29
- ErrorChatResponseModelImpl,
34
+ ErrorChatResponseModel,
35
+ ChatContext,
30
36
  } from './chat-model';
31
- import { ChatAgentService } from './chat-agent-service';
32
- import { Emitter, ILogger, generateUuid } from '@theia/core';
33
37
  import { ChatRequestParser } from './chat-request-parser';
34
- import { ChatAgent, ChatAgentLocation } from './chat-agents';
35
- import { ParsedChatRequestAgentPart, ParsedChatRequestVariablePart, ParsedChatRequest } from './parsed-chat-request';
36
- import { AIVariableService } from '@theia/ai-core';
37
- import { Event } from '@theia/core/shared/vscode-languageserver-protocol';
38
+ import { ParsedChatRequest, ParsedChatRequestAgentPart, ParsedChatRequestVariablePart } from './parsed-chat-request';
38
39
 
39
40
  export interface ChatRequestInvocation {
40
41
  /**
@@ -56,6 +57,11 @@ export interface ChatSession {
56
57
  title?: string;
57
58
  model: ChatModel;
58
59
  isActive: boolean;
60
+ pinnedAgent?: ChatAgent;
61
+ }
62
+
63
+ export interface ChatContextRequest {
64
+ variableRequests: AIVariableResolutionRequest[]
59
65
  }
60
66
 
61
67
  export interface ActiveSessionChangedEvent {
@@ -67,24 +73,39 @@ export interface SessionOptions {
67
73
  focus?: boolean;
68
74
  }
69
75
 
76
+ /**
77
+ * The default chat agent to invoke
78
+ */
70
79
  export const DefaultChatAgentId = Symbol('DefaultChatAgentId');
71
80
  export interface DefaultChatAgentId {
72
81
  id: string;
73
82
  }
74
83
 
84
+ /**
85
+ * In case no fitting chat agent is available, this one will be used (if it is itself available)
86
+ */
87
+ export const FallbackChatAgentId = Symbol('FallbackChatAgentId');
88
+ export interface FallbackChatAgentId {
89
+ id: string;
90
+ }
91
+
92
+ export const PinChatAgent = Symbol('PinChatAgent');
93
+ export type PinChatAgent = boolean;
94
+
75
95
  export const ChatService = Symbol('ChatService');
76
96
  export interface ChatService {
77
97
  onActiveSessionChanged: Event<ActiveSessionChangedEvent>
78
98
 
79
99
  getSession(id: string): ChatSession | undefined;
80
100
  getSessions(): ChatSession[];
81
- createSession(location?: ChatAgentLocation, options?: SessionOptions): ChatSession;
101
+ createSession(location?: ChatAgentLocation, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession;
82
102
  deleteSession(sessionId: string): void;
83
103
  setActiveSession(sessionId: string, options?: SessionOptions): void;
84
104
 
85
105
  sendRequest(
86
106
  sessionId: string,
87
- request: ChatRequest
107
+ request: ChatRequest,
108
+ requestedContext?: ChatContextRequest
88
109
  ): Promise<ChatRequestInvocation | undefined>;
89
110
 
90
111
  deleteChangeSet(sessionId: string): void;
@@ -94,7 +115,7 @@ export interface ChatService {
94
115
  }
95
116
 
96
117
  interface ChatSessionInternal extends ChatSession {
97
- model: ChatModelImpl;
118
+ model: MutableChatModel;
98
119
  }
99
120
 
100
121
  @injectable()
@@ -108,6 +129,12 @@ export class ChatServiceImpl implements ChatService {
108
129
  @inject(DefaultChatAgentId) @optional()
109
130
  protected defaultChatAgentId: DefaultChatAgentId | undefined;
110
131
 
132
+ @inject(FallbackChatAgentId) @optional()
133
+ protected fallbackChatAgentId: FallbackChatAgentId | undefined;
134
+
135
+ @inject(PinChatAgent) @optional()
136
+ protected pinChatAgent: boolean | undefined;
137
+
111
138
  @inject(ChatRequestParser)
112
139
  protected chatRequestParser: ChatRequestParser;
113
140
 
@@ -127,12 +154,13 @@ export class ChatServiceImpl implements ChatService {
127
154
  return this._sessions.find(session => session.id === id);
128
155
  }
129
156
 
130
- createSession(location = ChatAgentLocation.Panel, options?: SessionOptions): ChatSession {
131
- const model = new ChatModelImpl(location);
157
+ createSession(location = ChatAgentLocation.Panel, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession {
158
+ const model = new MutableChatModel(location);
132
159
  const session: ChatSessionInternal = {
133
160
  id: model.id,
134
161
  model,
135
- isActive: true
162
+ isActive: true,
163
+ pinnedAgent
136
164
  };
137
165
  this._sessions.push(session);
138
166
  this.setActiveSession(session.id, options);
@@ -140,11 +168,15 @@ export class ChatServiceImpl implements ChatService {
140
168
  }
141
169
 
142
170
  deleteSession(sessionId: string): void {
171
+ const sessionIndex = this._sessions.findIndex(candidate => candidate.id === sessionId);
172
+ if (~sessionIndex) { return; }
173
+ const session = this._sessions[sessionIndex];
143
174
  // If the removed session is the active one, set the newest one as active
144
- if (this.getSession(sessionId)?.isActive) {
175
+ if (session.isActive) {
145
176
  this.setActiveSession(this._sessions[this._sessions.length - 1]?.id);
146
177
  }
147
- this._sessions = this._sessions.filter(item => item.id !== sessionId);
178
+ session.model.dispose();
179
+ this._sessions.splice(sessionIndex, 1);
148
180
  }
149
181
 
150
182
  setActiveSession(sessionId: string | undefined, options?: SessionOptions): void {
@@ -156,7 +188,8 @@ export class ChatServiceImpl implements ChatService {
156
188
 
157
189
  async sendRequest(
158
190
  sessionId: string,
159
- request: ChatRequest
191
+ request: ChatRequest,
192
+ requestedContext: ChatContextRequest = { variableRequests: [] }
160
193
  ): Promise<ChatRequestInvocation | undefined> {
161
194
  const session = this.getSession(sessionId);
162
195
  if (!session) {
@@ -165,19 +198,21 @@ export class ChatServiceImpl implements ChatService {
165
198
  session.title = request.text;
166
199
 
167
200
  const parsedRequest = this.chatRequestParser.parseChatRequest(request, session.model.location);
201
+ const agent = this.getAgent(parsedRequest, session);
168
202
 
169
- const agent = this.getAgent(parsedRequest);
170
203
  if (agent === undefined) {
171
204
  const error = 'No ChatAgents available to handle request!';
172
205
  this.logger.error(error);
173
- const chatResponseModel = new ErrorChatResponseModelImpl(generateUuid(), new Error(error));
206
+ const chatResponseModel = new ErrorChatResponseModel(generateUuid(), new Error(error));
174
207
  return {
175
208
  requestCompleted: Promise.reject(error),
176
209
  responseCreated: Promise.reject(error),
177
210
  responseCompleted: Promise.resolve(chatResponseModel),
178
211
  };
179
212
  }
180
- const requestModel = session.model.addRequest(parsedRequest, agent?.id);
213
+
214
+ const resolvedContext = await this.resolveChatContext(requestedContext, request, session);
215
+ const requestModel = session.model.addRequest(parsedRequest, agent?.id, resolvedContext);
181
216
 
182
217
  for (const part of parsedRequest.parts) {
183
218
  if (part instanceof ParsedChatRequestVariablePart) {
@@ -224,18 +259,56 @@ export class ChatServiceImpl implements ChatService {
224
259
  return invocation;
225
260
  }
226
261
 
262
+ protected async resolveChatContext(
263
+ requestedContext: ChatContextRequest,
264
+ request: ChatRequest,
265
+ session: ChatSessionInternal
266
+ ): Promise<ChatContext> {
267
+ const resolvedVariables = await Promise.all(
268
+ requestedContext.variableRequests.map(async contextVariable => {
269
+ const resolvedVariable = await this.variableService.resolveVariable(contextVariable, { request, model: session });
270
+ if (ResolvedAIContextVariable.is(resolvedVariable)) {
271
+ return resolvedVariable;
272
+ }
273
+ return undefined;
274
+ })
275
+ ).then(results => results.filter((result): result is ResolvedAIContextVariable => result !== undefined));
276
+ return { variables: resolvedVariables };
277
+ }
278
+
227
279
  async cancelRequest(sessionId: string, requestId: string): Promise<void> {
228
280
  return this.getSession(sessionId)?.model.getRequest(requestId)?.response.cancel();
229
281
  }
230
282
 
231
- protected getAgent(parsedRequest: ParsedChatRequest): ChatAgent | undefined {
283
+ protected getAgent(parsedRequest: ParsedChatRequest, session: ChatSession): ChatAgent | undefined {
284
+ let agent = this.initialAgentSelection(parsedRequest);
285
+ if (this.pinChatAgent === false) {
286
+ return agent;
287
+ }
288
+ if (!session.pinnedAgent && agent && agent.id !== this.defaultChatAgentId?.id) {
289
+ session.pinnedAgent = agent;
290
+ } else if (session.pinnedAgent && this.getMentionedAgent(parsedRequest) === undefined) {
291
+ agent = session.pinnedAgent;
292
+ }
293
+ return agent;
294
+ }
295
+
296
+ protected initialAgentSelection(parsedRequest: ParsedChatRequest): ChatAgent | undefined {
232
297
  const agentPart = this.getMentionedAgent(parsedRequest);
233
298
  if (agentPart) {
234
299
  return this.chatAgentService.getAgent(agentPart.agentId);
235
300
  }
301
+ let chatAgent = undefined;
236
302
  if (this.defaultChatAgentId) {
237
- return this.chatAgentService.getAgent(this.defaultChatAgentId.id);
303
+ chatAgent = this.chatAgentService.getAgent(this.defaultChatAgentId.id);
304
+ }
305
+ if (!chatAgent && this.fallbackChatAgentId) {
306
+ chatAgent = this.chatAgentService.getAgent(this.fallbackChatAgentId.id);
307
+ }
308
+ if (chatAgent) {
309
+ return chatAgent;
238
310
  }
311
+ this.logger.warn('Neither the default chat agent nor the fallback chat agent are configured or available. Falling back to the first registered agent');
239
312
  return this.chatAgentService.getAgents()[0] ?? undefined;
240
313
  }
241
314
 
@@ -248,6 +321,6 @@ export class ChatServiceImpl implements ChatService {
248
321
  }
249
322
 
250
323
  deleteChangeSetElement(sessionId: string, index: number): void {
251
- this.getSession(sessionId)?.model.changeSet?.removeElement(index);
324
+ this.getSession(sessionId)?.model.changeSet?.removeElements(index);
252
325
  }
253
326
  }
@@ -16,12 +16,12 @@
16
16
 
17
17
  import { ToolRequest } from '@theia/ai-core';
18
18
  import { injectable } from '@theia/core/shared/inversify';
19
- import { ChatRequestModelImpl } from './chat-model';
19
+ import { MutableChatRequestModel } from './chat-model';
20
20
 
21
21
  export interface ChatToolRequest extends ToolRequest {
22
22
  handler: (
23
23
  arg_string: string,
24
- context: ChatRequestModelImpl,
24
+ context: MutableChatRequestModel,
25
25
  ) => Promise<unknown>;
26
26
  }
27
27
 
@@ -34,7 +34,7 @@ export interface ChatToolRequest extends ToolRequest {
34
34
  @injectable()
35
35
  export class ChatToolRequestService {
36
36
 
37
- getChatToolRequests(request: ChatRequestModelImpl): ChatToolRequest[] {
37
+ getChatToolRequests(request: MutableChatRequestModel): ChatToolRequest[] {
38
38
  const toolRequests = request.message.toolRequests.size > 0 ? [...request.message.toolRequests.values()] : undefined;
39
39
  if (!toolRequests) {
40
40
  return [];
@@ -42,14 +42,14 @@ export class ChatToolRequestService {
42
42
  return this.toChatToolRequests(toolRequests, request);
43
43
  }
44
44
 
45
- toChatToolRequests(toolRequests: ToolRequest[] | undefined, request: ChatRequestModelImpl): ChatToolRequest[] {
45
+ toChatToolRequests(toolRequests: ToolRequest[] | undefined, request: MutableChatRequestModel): ChatToolRequest[] {
46
46
  if (!toolRequests) {
47
47
  return [];
48
48
  }
49
49
  return toolRequests.map(toolRequest => this.toChatToolRequest(toolRequest, request));
50
50
  }
51
51
 
52
- protected toChatToolRequest(toolRequest: ToolRequest, request: ChatRequestModelImpl): ChatToolRequest {
52
+ protected toChatToolRequest(toolRequest: ToolRequest, request: MutableChatRequestModel): ChatToolRequest {
53
53
  return {
54
54
  ...toolRequest,
55
55
  handler: async (arg_string: string) => toolRequest.handler(arg_string, request)
@@ -14,29 +14,17 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
18
- import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
17
+ import { LanguageModelRequirement } from '@theia/ai-core';
18
+ import { AbstractStreamParsingChatAgent } from './chat-agents';
19
19
  import { injectable } from '@theia/core/shared/inversify';
20
20
 
21
21
  @injectable()
22
- export class CustomChatAgent
23
- extends AbstractStreamParsingChatAgent
24
- implements ChatAgent {
25
- name: string;
26
- description: string;
27
- readonly variables: string[] = [];
28
- readonly functions: string[] = [];
29
- readonly promptTemplates: PromptTemplate[] = [];
30
- readonly agentSpecificVariables: AgentSpecificVariables[] = [];
31
-
32
- constructor(
33
- ) {
34
- super('CustomChatAgent', [{ purpose: 'chat' }], 'chat');
35
- }
36
- protected override async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
37
- const resolvedPrompt = await this.promptService.getPrompt(`${this.name}_prompt`);
38
- return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
39
- }
22
+ export class CustomChatAgent extends AbstractStreamParsingChatAgent {
23
+ id: string = 'CustomChatAgent';
24
+ name: string = 'CustomChatAgent';
25
+ languageModelRequirements: LanguageModelRequirement[] = [{ purpose: 'chat' }];
26
+ protected defaultLanguageModelPurpose: string = 'chat';
27
+ protected override systemPromptId: string = `${this.name}_prompt`;
40
28
 
41
29
  set prompt(prompt: string) {
42
30
  this.promptTemplates.push({ id: `${this.name}_prompt`, template: prompt });
@@ -19,8 +19,5 @@ export * from './chat-model';
19
19
  export * from './chat-model-util';
20
20
  export * from './chat-request-parser';
21
21
  export * from './chat-service';
22
- export * from './command-chat-agents';
23
22
  export * from './custom-chat-agent';
24
23
  export * from './parsed-chat-request';
25
- export * from './orchestrator-chat-agent';
26
- export * from './universal-chat-agent';
@@ -15,7 +15,7 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { expect } from 'chai';
18
- import { ChatRequestModelImpl, ChatResponseContent, CodeChatResponseContentImpl, MarkdownChatResponseContentImpl } from './chat-model';
18
+ import { MutableChatRequestModel, ChatResponseContent, CodeChatResponseContentImpl, MarkdownChatResponseContentImpl } from './chat-model';
19
19
  import { parseContents } from './parse-contents';
20
20
  import { CodeContentMatcher, ResponseContentMatcher } from './response-content-matcher';
21
21
 
@@ -33,7 +33,7 @@ export const CommandContentMatcher: ResponseContentMatcher = {
33
33
  }
34
34
  };
35
35
 
36
- const fakeRequest = {} as ChatRequestModelImpl;
36
+ const fakeRequest = {} as MutableChatRequestModel;
37
37
 
38
38
  describe('parseContents', () => {
39
39
  it('should parse code content', () => {
@@ -13,7 +13,7 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  */
16
- import { ChatRequestModelImpl, ChatResponseContent } from './chat-model';
16
+ import { MutableChatRequestModel, ChatResponseContent } from './chat-model';
17
17
  import { CodeContentMatcher, MarkdownContentFactory, ResponseContentFactory, ResponseContentMatcher } from './response-content-matcher';
18
18
 
19
19
  interface Match {
@@ -24,7 +24,7 @@ interface Match {
24
24
 
25
25
  export function parseContents(
26
26
  text: string,
27
- request: ChatRequestModelImpl,
27
+ request: MutableChatRequestModel,
28
28
  contentMatchers: ResponseContentMatcher[] = [CodeContentMatcher],
29
29
  defaultContentFactory: ResponseContentFactory = MarkdownContentFactory
30
30
  ): ChatResponseContent[] {
@@ -14,14 +14,14 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  */
16
16
  import {
17
- ChatRequestModelImpl,
17
+ MutableChatRequestModel,
18
18
  ChatResponseContent,
19
19
  CodeChatResponseContentImpl,
20
20
  MarkdownChatResponseContentImpl
21
21
  } from './chat-model';
22
22
  import { injectable } from '@theia/core/shared/inversify';
23
23
 
24
- export type ResponseContentFactory = (content: string, request: ChatRequestModelImpl) => ChatResponseContent;
24
+ export type ResponseContentFactory = (content: string, request: MutableChatRequestModel) => ChatResponseContent;
25
25
 
26
26
  export const MarkdownContentFactory: ResponseContentFactory = (content: string) =>
27
27
  new MarkdownChatResponseContentImpl(content);
@@ -34,7 +34,7 @@ export const MarkdownContentFactory: ResponseContentFactory = (content: string)
34
34
  */
35
35
  @injectable()
36
36
  export class DefaultResponseContentFactory {
37
- create(content: string, request: ChatRequestModelImpl): ChatResponseContent {
37
+ create(content: string, request: MutableChatRequestModel): ChatResponseContent {
38
38
  return MarkdownContentFactory(content, request);
39
39
  }
40
40
  }
@@ -1,33 +0,0 @@
1
- import { AbstractTextToModelParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
2
- import { PromptTemplate, AgentSpecificVariables } from '@theia/ai-core';
3
- import { ChatRequestModelImpl, ChatResponseContent } from './chat-model';
4
- import { CommandRegistry, MessageService } from '@theia/core';
5
- export declare const commandTemplate: PromptTemplate;
6
- interface ParsedCommand {
7
- type: 'theia-command' | 'custom-handler' | 'no-command';
8
- commandId: string;
9
- arguments?: string[];
10
- message?: string;
11
- }
12
- export declare class CommandChatAgent extends AbstractTextToModelParsingChatAgent<ParsedCommand> implements ChatAgent {
13
- protected commandRegistry: CommandRegistry;
14
- protected messageService: MessageService;
15
- readonly name: string;
16
- readonly description: string;
17
- readonly variables: string[];
18
- readonly promptTemplates: PromptTemplate[];
19
- readonly functions: string[];
20
- readonly agentSpecificVariables: AgentSpecificVariables[];
21
- constructor();
22
- protected getSystemMessageDescription(): Promise<SystemMessageDescription | undefined>;
23
- /**
24
- * @param text the text received from the language model
25
- * @returns the parsed command if the text contained a valid command.
26
- * If there was no json in the text, return a no-command response.
27
- */
28
- protected parseTextResponse(text: string): Promise<ParsedCommand>;
29
- protected createResponseContent(parsedCommand: ParsedCommand, request: ChatRequestModelImpl): ChatResponseContent;
30
- protected commandCallback(...commandArgs: unknown[]): Promise<void>;
31
- }
32
- export {};
33
- //# sourceMappingURL=command-chat-agents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-chat-agents.d.ts","sourceRoot":"","sources":["../../src/common/command-chat-agents.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mCAAmC,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EACH,cAAc,EACd,sBAAsB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EAKtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,eAAe,EACf,cAAc,EAEjB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,eAAe,EAAE,cA8M5B,CAAC;AAEH,UAAU,aAAa;IACnB,IAAI,EAAE,eAAe,GAAG,gBAAgB,GAAG,YAAY,CAAA;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBACa,gBAAiB,SAAQ,mCAAmC,CAAC,aAAa,CAAE,YAAW,SAAS;IAEzG,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAE3C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;;cAqB1C,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAc5F;;;;OAIG;cACa,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAUvE,SAAS,CAAC,qBAAqB,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,oBAAoB,GAAG,mBAAmB;cAqCjG,eAAe,CAAC,GAAG,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAI5E"}