@theia/ai-chat 1.54.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 (77) hide show
  1. package/README.md +30 -0
  2. package/lib/browser/ai-chat-frontend-module.d.ts +4 -0
  3. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -0
  4. package/lib/browser/ai-chat-frontend-module.js +51 -0
  5. package/lib/browser/ai-chat-frontend-module.js.map +1 -0
  6. package/lib/browser/ai-chat-preferences.d.ts +4 -0
  7. package/lib/browser/ai-chat-preferences.d.ts.map +1 -0
  8. package/lib/browser/ai-chat-preferences.js +32 -0
  9. package/lib/browser/ai-chat-preferences.js.map +1 -0
  10. package/lib/browser/frontend-chat-service.d.ts +8 -0
  11. package/lib/browser/frontend-chat-service.d.ts.map +1 -0
  12. package/lib/browser/frontend-chat-service.js +67 -0
  13. package/lib/browser/frontend-chat-service.js.map +1 -0
  14. package/lib/common/chat-agent-service.d.ts +34 -0
  15. package/lib/common/chat-agent-service.d.ts.map +1 -0
  16. package/lib/common/chat-agent-service.js +75 -0
  17. package/lib/common/chat-agent-service.js.map +1 -0
  18. package/lib/common/chat-agents-variable-contribution.d.ts +17 -0
  19. package/lib/common/chat-agents-variable-contribution.d.ts.map +1 -0
  20. package/lib/common/chat-agents-variable-contribution.js +51 -0
  21. package/lib/common/chat-agents-variable-contribution.js.map +1 -0
  22. package/lib/common/chat-agents.d.ts +86 -0
  23. package/lib/common/chat-agents.d.ts.map +1 -0
  24. package/lib/common/chat-agents.js +307 -0
  25. package/lib/common/chat-agents.js.map +1 -0
  26. package/lib/common/chat-model.d.ts +319 -0
  27. package/lib/common/chat-model.d.ts.map +1 -0
  28. package/lib/common/chat-model.js +527 -0
  29. package/lib/common/chat-model.js.map +1 -0
  30. package/lib/common/chat-request-parser.d.ts +20 -0
  31. package/lib/common/chat-request-parser.d.ts.map +1 -0
  32. package/lib/common/chat-request-parser.js +158 -0
  33. package/lib/common/chat-request-parser.js.map +1 -0
  34. package/lib/common/chat-request-parser.spec.d.ts +2 -0
  35. package/lib/common/chat-request-parser.spec.d.ts.map +1 -0
  36. package/lib/common/chat-request-parser.spec.js +108 -0
  37. package/lib/common/chat-request-parser.spec.js.map +1 -0
  38. package/lib/common/chat-service.d.ts +72 -0
  39. package/lib/common/chat-service.d.ts.map +1 -0
  40. package/lib/common/chat-service.js +170 -0
  41. package/lib/common/chat-service.js.map +1 -0
  42. package/lib/common/command-chat-agents.d.ts +33 -0
  43. package/lib/common/command-chat-agents.d.ts.map +1 -0
  44. package/lib/common/command-chat-agents.js +327 -0
  45. package/lib/common/command-chat-agents.js.map +1 -0
  46. package/lib/common/index.d.ts +10 -0
  47. package/lib/common/index.d.ts.map +1 -0
  48. package/lib/common/index.js +28 -0
  49. package/lib/common/index.js.map +1 -0
  50. package/lib/common/orchestrator-chat-agent.d.ts +22 -0
  51. package/lib/common/orchestrator-chat-agent.d.ts.map +1 -0
  52. package/lib/common/orchestrator-chat-agent.js +140 -0
  53. package/lib/common/orchestrator-chat-agent.js.map +1 -0
  54. package/lib/common/parsed-chat-request.d.ts +66 -0
  55. package/lib/common/parsed-chat-request.d.ts.map +1 -0
  56. package/lib/common/parsed-chat-request.js +83 -0
  57. package/lib/common/parsed-chat-request.js.map +1 -0
  58. package/lib/common/universal-chat-agent.d.ts +15 -0
  59. package/lib/common/universal-chat-agent.d.ts.map +1 -0
  60. package/lib/common/universal-chat-agent.js +102 -0
  61. package/lib/common/universal-chat-agent.js.map +1 -0
  62. package/package.json +54 -0
  63. package/src/browser/ai-chat-frontend-module.ts +66 -0
  64. package/src/browser/ai-chat-preferences.ts +32 -0
  65. package/src/browser/frontend-chat-service.ts +66 -0
  66. package/src/common/chat-agent-service.ts +85 -0
  67. package/src/common/chat-agents-variable-contribution.ts +81 -0
  68. package/src/common/chat-agents.ts +384 -0
  69. package/src/common/chat-model.ts +776 -0
  70. package/src/common/chat-request-parser.spec.ts +120 -0
  71. package/src/common/chat-request-parser.ts +220 -0
  72. package/src/common/chat-service.ts +236 -0
  73. package/src/common/command-chat-agents.ts +352 -0
  74. package/src/common/index.ts +24 -0
  75. package/src/common/orchestrator-chat-agent.ts +151 -0
  76. package/src/common/parsed-chat-request.ts +112 -0
  77. package/src/common/universal-chat-agent.ts +109 -0
@@ -0,0 +1,527 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+ // Partially copied from https://github.com/microsoft/vscode/blob/a2cab7255c0df424027be05d58e1b7b941f4ea60/src/vs/workbench/contrib/chat/common/chatModel.ts
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.ErrorChatResponseModelImpl = exports.HorizontalLayoutChatResponseContentImpl = exports.CommandChatResponseContentImpl = exports.COMMAND_CHAT_RESPONSE_COMMAND = exports.ToolCallChatResponseContentImpl = exports.CodeChatResponseContentImpl = exports.InformationalChatResponseContentImpl = exports.MarkdownChatResponseContentImpl = exports.TextChatResponseContentImpl = exports.ErrorChatResponseContentImpl = exports.ChatRequestModelImpl = exports.ChatModelImpl = exports.ErrorChatResponseContent = exports.ToolCallChatResponseContent = exports.HorizontalLayoutChatResponseContent = exports.CodeChatResponseContent = exports.CommandChatResponseContent = exports.InformationalChatResponseContent = exports.MarkdownChatResponseContent = exports.TextChatResponseContent = exports.Location = exports.ChatResponseContent = void 0;
24
+ const core_1 = require("@theia/core");
25
+ const markdown_rendering_1 = require("@theia/core/lib/common/markdown-rendering");
26
+ const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
27
+ const chat_agents_1 = require("./chat-agents");
28
+ var ChatResponseContent;
29
+ (function (ChatResponseContent) {
30
+ function is(obj) {
31
+ return !!(obj &&
32
+ typeof obj === 'object' &&
33
+ 'kind' in obj &&
34
+ typeof obj.kind === 'string');
35
+ }
36
+ ChatResponseContent.is = is;
37
+ function hasAsString(obj) {
38
+ return typeof obj.asString === 'function';
39
+ }
40
+ ChatResponseContent.hasAsString = hasAsString;
41
+ function hasMerge(obj) {
42
+ return typeof obj.merge === 'function';
43
+ }
44
+ ChatResponseContent.hasMerge = hasMerge;
45
+ })(ChatResponseContent || (exports.ChatResponseContent = ChatResponseContent = {}));
46
+ var Location;
47
+ (function (Location) {
48
+ function is(obj) {
49
+ return !!obj && typeof obj === 'object' &&
50
+ 'uri' in obj && obj.uri instanceof core_1.URI &&
51
+ 'position' in obj && vscode_languageserver_protocol_1.Position.is(obj.position);
52
+ }
53
+ Location.is = is;
54
+ })(Location || (exports.Location = Location = {}));
55
+ var TextChatResponseContent;
56
+ (function (TextChatResponseContent) {
57
+ function is(obj) {
58
+ return (ChatResponseContent.is(obj) &&
59
+ obj.kind === 'text' &&
60
+ 'content' in obj &&
61
+ typeof obj.content === 'string');
62
+ }
63
+ TextChatResponseContent.is = is;
64
+ })(TextChatResponseContent || (exports.TextChatResponseContent = TextChatResponseContent = {}));
65
+ var MarkdownChatResponseContent;
66
+ (function (MarkdownChatResponseContent) {
67
+ function is(obj) {
68
+ return (ChatResponseContent.is(obj) &&
69
+ obj.kind === 'markdownContent' &&
70
+ 'content' in obj &&
71
+ markdown_rendering_1.MarkdownString.is(obj.content));
72
+ }
73
+ MarkdownChatResponseContent.is = is;
74
+ })(MarkdownChatResponseContent || (exports.MarkdownChatResponseContent = MarkdownChatResponseContent = {}));
75
+ var InformationalChatResponseContent;
76
+ (function (InformationalChatResponseContent) {
77
+ function is(obj) {
78
+ return (ChatResponseContent.is(obj) &&
79
+ obj.kind === 'informational' &&
80
+ 'content' in obj &&
81
+ markdown_rendering_1.MarkdownString.is(obj.content));
82
+ }
83
+ InformationalChatResponseContent.is = is;
84
+ })(InformationalChatResponseContent || (exports.InformationalChatResponseContent = InformationalChatResponseContent = {}));
85
+ var CommandChatResponseContent;
86
+ (function (CommandChatResponseContent) {
87
+ function is(obj) {
88
+ return (ChatResponseContent.is(obj) &&
89
+ obj.kind === 'command' &&
90
+ 'command' in obj &&
91
+ core_1.Command.is(obj.command));
92
+ }
93
+ CommandChatResponseContent.is = is;
94
+ })(CommandChatResponseContent || (exports.CommandChatResponseContent = CommandChatResponseContent = {}));
95
+ var CodeChatResponseContent;
96
+ (function (CodeChatResponseContent) {
97
+ function is(obj) {
98
+ return (ChatResponseContent.is(obj) &&
99
+ obj.kind === 'code' &&
100
+ 'code' in obj &&
101
+ typeof obj.code === 'string');
102
+ }
103
+ CodeChatResponseContent.is = is;
104
+ })(CodeChatResponseContent || (exports.CodeChatResponseContent = CodeChatResponseContent = {}));
105
+ var HorizontalLayoutChatResponseContent;
106
+ (function (HorizontalLayoutChatResponseContent) {
107
+ function is(obj) {
108
+ return (ChatResponseContent.is(obj) &&
109
+ obj.kind === 'horizontal' &&
110
+ 'content' in obj &&
111
+ Array.isArray(obj.content) &&
112
+ obj.content.every(ChatResponseContent.is));
113
+ }
114
+ HorizontalLayoutChatResponseContent.is = is;
115
+ })(HorizontalLayoutChatResponseContent || (exports.HorizontalLayoutChatResponseContent = HorizontalLayoutChatResponseContent = {}));
116
+ var ToolCallChatResponseContent;
117
+ (function (ToolCallChatResponseContent) {
118
+ function is(obj) {
119
+ return ChatResponseContent.is(obj) && obj.kind === 'toolCall';
120
+ }
121
+ ToolCallChatResponseContent.is = is;
122
+ })(ToolCallChatResponseContent || (exports.ToolCallChatResponseContent = ToolCallChatResponseContent = {}));
123
+ var ErrorChatResponseContent;
124
+ (function (ErrorChatResponseContent) {
125
+ function is(obj) {
126
+ return (ChatResponseContent.is(obj) &&
127
+ obj.kind === 'error' &&
128
+ 'error' in obj &&
129
+ obj.error instanceof Error);
130
+ }
131
+ ErrorChatResponseContent.is = is;
132
+ })(ErrorChatResponseContent || (exports.ErrorChatResponseContent = ErrorChatResponseContent = {}));
133
+ /**********************
134
+ * Implementations
135
+ **********************/
136
+ class ChatModelImpl {
137
+ constructor(location = chat_agents_1.ChatAgentLocation.Panel) {
138
+ this.location = location;
139
+ this._onDidChangeEmitter = new core_1.Emitter();
140
+ this.onDidChange = this._onDidChangeEmitter.event;
141
+ // TODO accept serialized data as a parameter to restore a previously saved ChatModel
142
+ this._requests = [];
143
+ this._id = (0, core_1.generateUuid)();
144
+ }
145
+ getRequests() {
146
+ return this._requests;
147
+ }
148
+ get id() {
149
+ return this._id;
150
+ }
151
+ addRequest(parsedChatRequest, agentId) {
152
+ const requestModel = new ChatRequestModelImpl(this, parsedChatRequest, agentId);
153
+ this._requests.push(requestModel);
154
+ this._onDidChangeEmitter.fire({
155
+ kind: 'addRequest',
156
+ request: requestModel,
157
+ });
158
+ return requestModel;
159
+ }
160
+ isEmpty() {
161
+ return this._requests.length === 0;
162
+ }
163
+ }
164
+ exports.ChatModelImpl = ChatModelImpl;
165
+ class ChatRequestModelImpl {
166
+ constructor(session, message, agentId) {
167
+ this.message = message;
168
+ // TODO accept serialized data as a parameter to restore a previously saved ChatRequestModel
169
+ this._request = message.request;
170
+ this._id = (0, core_1.generateUuid)();
171
+ this._session = session;
172
+ this._response = new ChatResponseModelImpl(this._id, agentId);
173
+ this._agentId = agentId;
174
+ }
175
+ get id() {
176
+ return this._id;
177
+ }
178
+ get session() {
179
+ return this._session;
180
+ }
181
+ get request() {
182
+ return this._request;
183
+ }
184
+ get response() {
185
+ return this._response;
186
+ }
187
+ get agentId() {
188
+ return this._agentId;
189
+ }
190
+ }
191
+ exports.ChatRequestModelImpl = ChatRequestModelImpl;
192
+ class ErrorChatResponseContentImpl {
193
+ constructor(error) {
194
+ this.kind = 'error';
195
+ this._error = error;
196
+ }
197
+ get error() {
198
+ return this._error;
199
+ }
200
+ asString() {
201
+ return undefined;
202
+ }
203
+ }
204
+ exports.ErrorChatResponseContentImpl = ErrorChatResponseContentImpl;
205
+ class TextChatResponseContentImpl {
206
+ constructor(content) {
207
+ this.kind = 'text';
208
+ this._content = content;
209
+ }
210
+ get content() {
211
+ return this._content;
212
+ }
213
+ asString() {
214
+ return this._content;
215
+ }
216
+ merge(nextChatResponseContent) {
217
+ this._content += nextChatResponseContent.content;
218
+ return true;
219
+ }
220
+ }
221
+ exports.TextChatResponseContentImpl = TextChatResponseContentImpl;
222
+ class MarkdownChatResponseContentImpl {
223
+ constructor(content) {
224
+ this.kind = 'markdownContent';
225
+ this._content = new markdown_rendering_1.MarkdownStringImpl();
226
+ this._content.appendMarkdown(content);
227
+ }
228
+ get content() {
229
+ return this._content;
230
+ }
231
+ asString() {
232
+ return this._content.value;
233
+ }
234
+ merge(nextChatResponseContent) {
235
+ this._content.appendMarkdown(nextChatResponseContent.content.value);
236
+ return true;
237
+ }
238
+ }
239
+ exports.MarkdownChatResponseContentImpl = MarkdownChatResponseContentImpl;
240
+ class InformationalChatResponseContentImpl {
241
+ constructor(content) {
242
+ this.kind = 'informational';
243
+ this._content = new markdown_rendering_1.MarkdownStringImpl(content);
244
+ }
245
+ get content() {
246
+ return this._content;
247
+ }
248
+ asString() {
249
+ return undefined;
250
+ }
251
+ merge(nextChatResponseContent) {
252
+ this._content.appendMarkdown(nextChatResponseContent.content.value);
253
+ return true;
254
+ }
255
+ }
256
+ exports.InformationalChatResponseContentImpl = InformationalChatResponseContentImpl;
257
+ class CodeChatResponseContentImpl {
258
+ constructor(code, language, location) {
259
+ this.kind = 'code';
260
+ this._code = code;
261
+ this._language = language;
262
+ this._location = location;
263
+ }
264
+ get code() {
265
+ return this._code;
266
+ }
267
+ get language() {
268
+ return this._language;
269
+ }
270
+ get location() {
271
+ return this._location;
272
+ }
273
+ asString() {
274
+ var _a;
275
+ return `\`\`\`${(_a = this._language) !== null && _a !== void 0 ? _a : ''}\n${this._code}\n\`\`\``;
276
+ }
277
+ merge(nextChatResponseContent) {
278
+ this._code += `${nextChatResponseContent.code}`;
279
+ return true;
280
+ }
281
+ }
282
+ exports.CodeChatResponseContentImpl = CodeChatResponseContentImpl;
283
+ class ToolCallChatResponseContentImpl {
284
+ constructor(id, name, arg_string, finished, result) {
285
+ this.kind = 'toolCall';
286
+ this._id = id;
287
+ this._name = name;
288
+ this._arguments = arg_string;
289
+ this._finished = finished;
290
+ this._result = result;
291
+ }
292
+ get id() {
293
+ return this._id;
294
+ }
295
+ get name() {
296
+ return this._name;
297
+ }
298
+ get arguments() {
299
+ return this._arguments;
300
+ }
301
+ get finished() {
302
+ return this._finished === undefined ? false : this._finished;
303
+ }
304
+ get result() {
305
+ return this._result;
306
+ }
307
+ asString() {
308
+ var _a;
309
+ return `Tool call: ${this._name}(${(_a = this._arguments) !== null && _a !== void 0 ? _a : ''})`;
310
+ }
311
+ merge(nextChatResponseContent) {
312
+ if (nextChatResponseContent.id === this.id) {
313
+ this._finished = nextChatResponseContent.finished;
314
+ this._result = nextChatResponseContent.result;
315
+ return true;
316
+ }
317
+ if (nextChatResponseContent.name !== undefined) {
318
+ return false;
319
+ }
320
+ if (nextChatResponseContent.arguments === undefined) {
321
+ return false;
322
+ }
323
+ this._arguments += `${nextChatResponseContent.arguments}`;
324
+ return true;
325
+ }
326
+ }
327
+ exports.ToolCallChatResponseContentImpl = ToolCallChatResponseContentImpl;
328
+ exports.COMMAND_CHAT_RESPONSE_COMMAND = {
329
+ id: 'ai-chat.command-chat-response.generic'
330
+ };
331
+ class CommandChatResponseContentImpl {
332
+ constructor(command, customCallback, args) {
333
+ this.command = command;
334
+ this.customCallback = customCallback;
335
+ this.args = args;
336
+ this.kind = 'command';
337
+ }
338
+ get arguments() {
339
+ var _a;
340
+ return (_a = this.args) !== null && _a !== void 0 ? _a : [];
341
+ }
342
+ asString() {
343
+ var _a, _b;
344
+ return ((_a = this.command) === null || _a === void 0 ? void 0 : _a.id) || ((_b = this.customCallback) === null || _b === void 0 ? void 0 : _b.label) || 'command';
345
+ }
346
+ }
347
+ exports.CommandChatResponseContentImpl = CommandChatResponseContentImpl;
348
+ class HorizontalLayoutChatResponseContentImpl {
349
+ constructor(content = []) {
350
+ this.kind = 'horizontal';
351
+ this._content = content;
352
+ }
353
+ get content() {
354
+ return this._content;
355
+ }
356
+ asString() {
357
+ return this._content.map(child => child.asString && child.asString()).join(' ');
358
+ }
359
+ merge(nextChatResponseContent) {
360
+ if (HorizontalLayoutChatResponseContent.is(nextChatResponseContent)) {
361
+ this._content.push(...nextChatResponseContent.content);
362
+ }
363
+ else {
364
+ this._content.push(nextChatResponseContent);
365
+ }
366
+ return true;
367
+ }
368
+ }
369
+ exports.HorizontalLayoutChatResponseContentImpl = HorizontalLayoutChatResponseContentImpl;
370
+ class ChatResponseImpl {
371
+ constructor() {
372
+ this._onDidChangeEmitter = new core_1.Emitter();
373
+ this.onDidChange = this._onDidChangeEmitter.event;
374
+ // TODO accept serialized data as a parameter to restore a previously saved ChatResponse
375
+ this._content = [];
376
+ }
377
+ get content() {
378
+ return this._content;
379
+ }
380
+ addContent(nextContent) {
381
+ var _a;
382
+ // TODO: Support more complex merges affecting different content than the last, e.g. via some kind of ProcessorRegistry
383
+ // TODO: Support more of the built-in VS Code behavior, see
384
+ // https://github.com/microsoft/vscode/blob/a2cab7255c0df424027be05d58e1b7b941f4ea60/src/vs/workbench/contrib/chat/common/chatModel.ts#L188-L244
385
+ if (ToolCallChatResponseContent.is(nextContent) && nextContent.id !== undefined) {
386
+ const fittingTool = this._content.find(c => ToolCallChatResponseContent.is(c) && c.id === nextContent.id);
387
+ if (fittingTool !== undefined) {
388
+ (_a = fittingTool.merge) === null || _a === void 0 ? void 0 : _a.call(fittingTool, nextContent);
389
+ }
390
+ else {
391
+ this._content.push(nextContent);
392
+ }
393
+ }
394
+ else {
395
+ const lastElement = this._content.length > 0
396
+ ? this._content[this._content.length - 1]
397
+ : undefined;
398
+ if ((lastElement === null || lastElement === void 0 ? void 0 : lastElement.kind) === nextContent.kind && ChatResponseContent.hasMerge(lastElement)) {
399
+ const mergeSuccess = lastElement.merge(nextContent);
400
+ if (!mergeSuccess) {
401
+ this._content.push(nextContent);
402
+ }
403
+ }
404
+ else {
405
+ this._content.push(nextContent);
406
+ }
407
+ }
408
+ this._updateResponseRepresentation();
409
+ this._onDidChangeEmitter.fire();
410
+ }
411
+ _updateResponseRepresentation() {
412
+ this._responseRepresentation = this._content
413
+ .map(responseContent => {
414
+ if (ChatResponseContent.hasAsString(responseContent)) {
415
+ return responseContent.asString();
416
+ }
417
+ if (TextChatResponseContent.is(responseContent)) {
418
+ return responseContent.content;
419
+ }
420
+ console.warn('Was not able to map responseContent to a string', responseContent);
421
+ return undefined;
422
+ })
423
+ .filter(text => text !== undefined)
424
+ .join('\n\n');
425
+ }
426
+ asString() {
427
+ return this._responseRepresentation;
428
+ }
429
+ }
430
+ class ChatResponseModelImpl {
431
+ constructor(requestId, agentId) {
432
+ this._onDidChangeEmitter = new core_1.Emitter();
433
+ this.onDidChange = this._onDidChangeEmitter.event;
434
+ // TODO accept serialized data as a parameter to restore a previously saved ChatResponseModel
435
+ this._requestId = requestId;
436
+ this._id = (0, core_1.generateUuid)();
437
+ this._progressMessages = [];
438
+ const response = new ChatResponseImpl();
439
+ response.onDidChange(() => this._onDidChangeEmitter.fire());
440
+ this._response = response;
441
+ this._isComplete = false;
442
+ this._isCanceled = false;
443
+ this._agentId = agentId;
444
+ }
445
+ get id() {
446
+ return this._id;
447
+ }
448
+ get requestId() {
449
+ return this._requestId;
450
+ }
451
+ get progressMessages() {
452
+ return this._progressMessages;
453
+ }
454
+ addProgressMessage(message) {
455
+ var _a, _b;
456
+ const id = (_a = message.id) !== null && _a !== void 0 ? _a : (0, core_1.generateUuid)();
457
+ const existingMessage = this.getProgressMessage(id);
458
+ if (existingMessage) {
459
+ this.updateProgressMessage({ id, ...message });
460
+ return existingMessage;
461
+ }
462
+ const newMessage = {
463
+ kind: 'progressMessage',
464
+ id,
465
+ status: (_b = message.status) !== null && _b !== void 0 ? _b : 'inProgress',
466
+ ...message,
467
+ };
468
+ this._progressMessages.push(newMessage);
469
+ this._onDidChangeEmitter.fire();
470
+ return newMessage;
471
+ }
472
+ getProgressMessage(id) {
473
+ return this._progressMessages.find(message => message.id === id);
474
+ }
475
+ updateProgressMessage(message) {
476
+ const progressMessage = this.getProgressMessage(message.id);
477
+ if (progressMessage) {
478
+ Object.assign(progressMessage, message);
479
+ this._onDidChangeEmitter.fire();
480
+ }
481
+ }
482
+ get response() {
483
+ return this._response;
484
+ }
485
+ get isComplete() {
486
+ return this._isComplete;
487
+ }
488
+ get isCanceled() {
489
+ return this._isCanceled;
490
+ }
491
+ get agentId() {
492
+ return this._agentId;
493
+ }
494
+ overrideAgentId(agentId) {
495
+ this._agentId = agentId;
496
+ }
497
+ complete() {
498
+ this._isComplete = true;
499
+ this._onDidChangeEmitter.fire();
500
+ }
501
+ cancel() {
502
+ this._isComplete = true;
503
+ this._isCanceled = true;
504
+ this._onDidChangeEmitter.fire();
505
+ }
506
+ error(error) {
507
+ this._isComplete = true;
508
+ this._isCanceled = false;
509
+ this._isError = true;
510
+ this._errorObject = error;
511
+ this._onDidChangeEmitter.fire();
512
+ }
513
+ get errorObject() {
514
+ return this._errorObject;
515
+ }
516
+ get isError() {
517
+ return this._isError;
518
+ }
519
+ }
520
+ class ErrorChatResponseModelImpl extends ChatResponseModelImpl {
521
+ constructor(requestId, error, agentId) {
522
+ super(requestId, agentId);
523
+ this.error(error);
524
+ }
525
+ }
526
+ exports.ErrorChatResponseModelImpl = ErrorChatResponseModelImpl;
527
+ //# sourceMappingURL=chat-model.js.map
@@ -0,0 +1 @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KC"}
@@ -0,0 +1,20 @@
1
+ import { ChatAgentService } from './chat-agent-service';
2
+ import { ChatAgentLocation } from './chat-agents';
3
+ import { ChatRequest } from './chat-model';
4
+ import { ParsedChatRequest } from './parsed-chat-request';
5
+ import { AIVariableService, ToolInvocationRegistry } from '@theia/ai-core';
6
+ export declare const ChatRequestParser: unique symbol;
7
+ export interface ChatRequestParser {
8
+ parseChatRequest(request: ChatRequest, location: ChatAgentLocation): ParsedChatRequest;
9
+ }
10
+ export declare class ChatRequestParserImpl {
11
+ private readonly agentService;
12
+ private readonly variableService;
13
+ private readonly toolInvocationRegistry;
14
+ constructor(agentService: ChatAgentService, variableService: AIVariableService, toolInvocationRegistry: ToolInvocationRegistry);
15
+ parseChatRequest(request: ChatRequest, location: ChatAgentLocation): ParsedChatRequest;
16
+ private tryToParseAgent;
17
+ private tryToParseVariable;
18
+ private tryParseFunction;
19
+ }
20
+ //# sourceMappingURL=chat-request-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-request-parser.d.ts","sourceRoot":"","sources":["../../src/common/chat-request-parser.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EASH,iBAAiB,EAEpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAc,iBAAiB,EAAE,sBAAsB,EAAe,MAAM,gBAAgB,CAAC;AAMpG,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAC7D,MAAM,WAAW,iBAAiB;IAC9B,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB,CAAC;CAC1F;AAQD,qBACa,qBAAqB;IAEA,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC5B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,sBAAsB;gBAF5B,YAAY,EAAE,gBAAgB,EAC7B,eAAe,EAAE,iBAAiB,EAC7B,sBAAsB,EAAE,sBAAsB;IAGnG,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB;IA2EtF,OAAO,CAAC,eAAe;IAiDvB,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,gBAAgB;CAgB3B"}