@theia/ai-chat 1.55.1 → 1.57.0-next.22

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 (54) hide show
  1. package/README.md +2 -1
  2. package/lib/common/chat-agents.d.ts +12 -4
  3. package/lib/common/chat-agents.d.ts.map +1 -1
  4. package/lib/common/chat-agents.js +37 -46
  5. package/lib/common/chat-agents.js.map +1 -1
  6. package/lib/common/chat-history-entry.d.ts +7 -0
  7. package/lib/common/chat-history-entry.d.ts.map +1 -0
  8. package/lib/common/chat-history-entry.js +42 -0
  9. package/lib/common/chat-history-entry.js.map +1 -0
  10. package/lib/common/chat-model-util.d.ts +7 -0
  11. package/lib/common/chat-model-util.d.ts.map +1 -0
  12. package/lib/common/chat-model-util.js +50 -0
  13. package/lib/common/chat-model-util.js.map +1 -0
  14. package/lib/common/chat-model.d.ts +59 -0
  15. package/lib/common/chat-model.d.ts.map +1 -1
  16. package/lib/common/chat-model.js +70 -2
  17. package/lib/common/chat-model.js.map +1 -1
  18. package/lib/common/command-chat-agents.d.ts.map +1 -1
  19. package/lib/common/command-chat-agents.js +3 -1
  20. package/lib/common/command-chat-agents.js.map +1 -1
  21. package/lib/common/index.d.ts +1 -0
  22. package/lib/common/index.d.ts.map +1 -1
  23. package/lib/common/index.js +1 -0
  24. package/lib/common/index.js.map +1 -1
  25. package/lib/common/orchestrator-chat-agent.d.ts.map +1 -1
  26. package/lib/common/orchestrator-chat-agent.js +16 -14
  27. package/lib/common/orchestrator-chat-agent.js.map +1 -1
  28. package/lib/common/parse-contents.d.ts +2 -2
  29. package/lib/common/parse-contents.d.ts.map +1 -1
  30. package/lib/common/parse-contents.js +4 -4
  31. package/lib/common/parse-contents.js.map +1 -1
  32. package/lib/common/parse-contents.spec.d.ts.map +1 -1
  33. package/lib/common/parse-contents.spec.js +14 -13
  34. package/lib/common/parse-contents.spec.js.map +1 -1
  35. package/lib/common/response-content-matcher.d.ts +3 -3
  36. package/lib/common/response-content-matcher.d.ts.map +1 -1
  37. package/lib/common/response-content-matcher.js +2 -2
  38. package/lib/common/response-content-matcher.js.map +1 -1
  39. package/lib/common/universal-chat-agent.d.ts +1 -0
  40. package/lib/common/universal-chat-agent.d.ts.map +1 -1
  41. package/lib/common/universal-chat-agent.js +10 -3
  42. package/lib/common/universal-chat-agent.js.map +1 -1
  43. package/package.json +8 -8
  44. package/src/common/chat-agents.ts +44 -54
  45. package/src/common/chat-history-entry.ts +47 -0
  46. package/src/common/chat-model-util.ts +44 -0
  47. package/src/common/chat-model.ts +89 -0
  48. package/src/common/command-chat-agents.ts +3 -1
  49. package/src/common/index.ts +1 -0
  50. package/src/common/orchestrator-chat-agent.ts +17 -14
  51. package/src/common/parse-contents.spec.ts +16 -14
  52. package/src/common/parse-contents.ts +5 -4
  53. package/src/common/response-content-matcher.ts +4 -3
  54. package/src/common/universal-chat-agent.ts +10 -2
@@ -1 +1 @@
1
- {"version":3,"file":"response-content-matcher.d.ts","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,mBAAmB,EAGtB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,mBAAmB,CAAC;AAE9E,eAAO,MAAM,sBAAsB,EAAE,sBACW,CAAC;AAEjD;;;;;GAKG;AACH,qBACa,6BAA6B;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB;CAG/C;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAQhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AACvF,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CAC/C;AAED,qBACa,qCAAsC,YAAW,8BAA8B;IACxF,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAwB;CACtE"}
1
+ {"version":3,"file":"response-content-matcher.d.ts","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,oBAAoB,EACpB,mBAAmB,EAGtB,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,KAAK,mBAAmB,CAAC;AAE7G,eAAO,MAAM,sBAAsB,EAAE,sBACW,CAAC;AAEjD;;;;;GAKG;AACH,qBACa,6BAA6B;IACtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,mBAAmB;CAG9E;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,cAAc,EAAE,sBAAsB,CAAC;CAC1C;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAQhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,8BAA8B,eAA2C,CAAC;AACvF,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CAC/C;AAED,qBACa,qCAAsC,YAAW,8BAA8B;IACxF,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAwB;CACtE"}
@@ -28,8 +28,8 @@ exports.MarkdownContentFactory = MarkdownContentFactory;
28
28
  * @see MarkdownChatResponseContentImpl
29
29
  */
30
30
  let DefaultResponseContentFactory = class DefaultResponseContentFactory {
31
- create(content) {
32
- return (0, exports.MarkdownContentFactory)(content);
31
+ create(content, request) {
32
+ return (0, exports.MarkdownContentFactory)(content, request);
33
33
  }
34
34
  };
35
35
  exports.DefaultResponseContentFactory = DefaultResponseContentFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"response-content-matcher.js","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6CAIsB;AACtB,4DAA0D;AAInD,MAAM,sBAAsB,GAA2B,CAAC,OAAe,EAAE,EAAE,CAC9E,IAAI,4CAA+B,CAAC,OAAO,CAAC,CAAC;AADpC,QAAA,sBAAsB,0BACc;AAEjD;;;;;GAKG;AAEI,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,MAAM,CAAC,OAAe;QAClB,OAAO,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAA;AAJY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,sBAAU,GAAE;GACA,6BAA6B,CAIzC;AAkBY,QAAA,kBAAkB,GAA2B;IACtD,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,QAAQ;IACb,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE;;QAChC,MAAM,QAAQ,GAAG,CAAA,MAAA,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAG,CAAC,CAAC,KAAI,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QACtD,OAAO,IAAI,wCAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;CACJ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAMhF,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QACM,aAAQ,GAA6B,CAAC,0BAAkB,CAAC,CAAC;IACvE,CAAC;CAAA,CAAA;AAFY,sFAAqC;gDAArC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAEjD"}
1
+ {"version":3,"file":"response-content-matcher.js","sourceRoot":"","sources":["../../src/common/response-content-matcher.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6CAKsB;AACtB,4DAA0D;AAInD,MAAM,sBAAsB,GAA2B,CAAC,OAAe,EAAE,EAAE,CAC9E,IAAI,4CAA+B,CAAC,OAAO,CAAC,CAAC;AADpC,QAAA,sBAAsB,0BACc;AAEjD;;;;;GAKG;AAEI,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IACtC,MAAM,CAAC,OAAe,EAAE,OAA6B;QACjD,OAAO,IAAA,8BAAsB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AAJY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,sBAAU,GAAE;GACA,6BAA6B,CAIzC;AAkBY,QAAA,kBAAkB,GAA2B;IACtD,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,QAAQ;IACb,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE;;QAChC,MAAM,QAAQ,GAAG,CAAA,MAAA,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAG,CAAC,CAAC,KAAI,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QACtD,OAAO,IAAI,wCAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;CACJ,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,8BAA8B,GAAG,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAMhF,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAA3C;QACM,aAAQ,GAA6B,CAAC,0BAAkB,CAAC,CAAC;IACvE,CAAC;CAAA,CAAA;AAFY,sFAAqC;gDAArC,qCAAqC;IADjD,IAAA,sBAAU,GAAE;GACA,qCAAqC,CAEjD"}
@@ -2,6 +2,7 @@ import { AgentSpecificVariables } from '@theia/ai-core';
2
2
  import { PromptTemplate } from '@theia/ai-core/lib/common';
3
3
  import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
4
4
  export declare const universalTemplate: PromptTemplate;
5
+ export declare const universalTemplateVariant: PromptTemplate;
5
6
  export declare class UniversalChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
6
7
  name: string;
7
8
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"universal-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/universal-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACJ,cAAc,EAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEpG,eAAO,MAAM,iBAAiB,EAAE,cAqD/B,CAAC;AAEF,qBACa,kBAAmB,SAAQ,8BAA+B,YAAW,SAAS;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;;cAkBjC,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;CAKvG"}
1
+ {"version":3,"file":"universal-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/universal-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACJ,cAAc,EAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEpG,eAAO,MAAM,iBAAiB,EAAE,cAuD/B,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,cAItC,CAAC;AAEF,qBACa,kBAAmB,SAAQ,8BAA+B,YAAW,SAAS;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;;cAkBjC,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;CAKvG"}
@@ -15,13 +15,15 @@
15
15
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
16
  // *****************************************************************************
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.UniversalChatAgent = exports.universalTemplate = void 0;
18
+ exports.UniversalChatAgent = exports.universalTemplateVariant = exports.universalTemplate = void 0;
19
19
  const tslib_1 = require("tslib");
20
20
  const inversify_1 = require("@theia/core/shared/inversify");
21
21
  const chat_agents_1 = require("./chat-agents");
22
22
  exports.universalTemplate = {
23
23
  id: 'universal-system',
24
- template: `# Instructions
24
+ template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
25
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
26
+ # Instructions
25
27
 
26
28
  You are an AI assistant integrated into the Theia IDE, specifically designed to help software developers by
27
29
  providing concise and accurate answers to programming-related questions. Your role is to enhance the
@@ -73,6 +75,11 @@ simple solutions.
73
75
  **Answer:** "I'm here to assist with programming-related queries. For other topics, please refer to a specialized source."
74
76
  `
75
77
  };
78
+ exports.universalTemplateVariant = {
79
+ id: 'universal-system-empty',
80
+ template: '',
81
+ variantOf: exports.universalTemplate.id,
82
+ };
76
83
  let UniversalChatAgent = class UniversalChatAgent extends chat_agents_1.AbstractStreamParsingChatAgent {
77
84
  constructor() {
78
85
  super('Universal', [{
@@ -85,7 +92,7 @@ let UniversalChatAgent = class UniversalChatAgent extends chat_agents_1.Abstract
85
92
  + 'questions the user might ask. The universal agent currently does not have any context by default, i.e. it cannot '
86
93
  + 'access the current user context or the workspace.';
87
94
  this.variables = [];
88
- this.promptTemplates = [exports.universalTemplate];
95
+ this.promptTemplates = [exports.universalTemplate, exports.universalTemplateVariant];
89
96
  this.functions = [];
90
97
  this.agentSpecificVariables = [];
91
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"universal-chat-agent.js","sourceRoot":"","sources":["../../src/common/universal-chat-agent.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAMhF,4DAA0D;AAC1D,+CAAoG;AAEvF,QAAA,iBAAiB,GAAmB;IAC9C,EAAE,EAAE,kBAAkB;IACtB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDZ;CACA,CAAC;AAGK,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,4CAA8B;IAQnE;QACG,KAAK,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,eAAe;aAC7B,CAAC,EAAE,MAAM,CAAC,CAAC;QACZ,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,uFAAuF;cACrG,8GAA8G;cAC9G,mHAAmH;cACnH,mDAAmD,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,CAAC,yBAAiB,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC;IACpC,CAAC;IAEkB,KAAK,CAAC,2BAA2B;QACjD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,yBAAiB,CAAC,EAAE,CAAC,CAAC;QAChF,OAAO,cAAc,CAAC,CAAC,CAAC,sCAAwB,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,CAAC;CAEH,CAAA;AA7BY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;;GACA,kBAAkB,CA6B9B"}
1
+ {"version":3,"file":"universal-chat-agent.js","sourceRoot":"","sources":["../../src/common/universal-chat-agent.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAMhF,4DAA0D;AAC1D,+CAAoG;AAEvF,QAAA,iBAAiB,GAAmB;IAC9C,EAAE,EAAE,kBAAkB;IACtB,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDZ;CACA,CAAC;AAEW,QAAA,wBAAwB,GAAmB;IACrD,EAAE,EAAE,wBAAwB;IAC5B,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,yBAAiB,CAAC,EAAE;CACjC,CAAC;AAGK,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,4CAA8B;IAQnE;QACG,KAAK,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,eAAe;aAC7B,CAAC,EAAE,MAAM,CAAC,CAAC;QACZ,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,uFAAuF;cACrG,8GAA8G;cAC9G,mHAAmH;cACnH,mDAAmD,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,CAAC,yBAAiB,EAAE,gCAAwB,CAAC,CAAC;QACrE,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC;IACpC,CAAC;IAEkB,KAAK,CAAC,2BAA2B;QACjD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,yBAAiB,CAAC,EAAE,CAAC,CAAC;QAChF,OAAO,cAAc,CAAC,CAAC,CAAC,sCAAwB,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3G,CAAC;CAEH,CAAA;AA7BY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;;GACA,kBAAkB,CA6B9B"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@theia/ai-chat",
3
- "version": "1.55.1",
3
+ "version": "1.57.0-next.22+35d458a96",
4
4
  "description": "Theia - AI Chat Extension",
5
5
  "dependencies": {
6
- "@theia/ai-core": "1.55.1",
7
- "@theia/ai-history": "1.55.1",
8
- "@theia/core": "1.55.1",
9
- "@theia/filesystem": "1.55.1",
10
- "@theia/workspace": "1.55.1",
6
+ "@theia/ai-core": "1.57.0-next.22+35d458a96",
7
+ "@theia/ai-history": "1.57.0-next.22+35d458a96",
8
+ "@theia/core": "1.57.0-next.22+35d458a96",
9
+ "@theia/filesystem": "1.57.0-next.22+35d458a96",
10
+ "@theia/workspace": "1.57.0-next.22+35d458a96",
11
11
  "minimatch": "^5.1.0",
12
12
  "tslib": "^2.6.2"
13
13
  },
@@ -45,10 +45,10 @@
45
45
  "watch": "theiaext watch"
46
46
  },
47
47
  "devDependencies": {
48
- "@theia/ext-scripts": "1.55.1"
48
+ "@theia/ext-scripts": "1.56.0"
49
49
  },
50
50
  "nyc": {
51
51
  "extends": "../../configs/nyc.json"
52
52
  },
53
- "gitHead": "be4713a778be16ba831af63a6fbd43b2301e882d"
53
+ "gitHead": "35d458a961212de264d9579305d984147fa55618"
54
54
  }
@@ -39,7 +39,7 @@ import {
39
39
  MessageActor,
40
40
  } from '@theia/ai-core/lib/common';
41
41
  import { CancellationToken, CancellationTokenSource, ContributionProvider, ILogger, isArray } from '@theia/core';
42
- import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify';
42
+ import { inject, injectable, named, postConstruct, unmanaged } from '@theia/core/shared/inversify';
43
43
  import { ChatAgentService } from './chat-agent-service';
44
44
  import {
45
45
  ChatModel,
@@ -52,6 +52,7 @@ import {
52
52
  } from './chat-model';
53
53
  import { findFirstMatch, parseContents } from './parse-contents';
54
54
  import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
55
+ import { ChatHistoryEntry } from './chat-history-entry';
55
56
 
56
57
  /**
57
58
  * A conversation consists of a sequence of ChatMessages.
@@ -132,18 +133,23 @@ export abstract class AbstractChatAgent {
132
133
  protected defaultContentFactory: DefaultResponseContentFactory;
133
134
 
134
135
  constructor(
135
- public id: string,
136
- public languageModelRequirements: LanguageModelRequirement[],
137
- protected defaultLanguageModelPurpose: string,
138
- public iconClass: string = 'codicon codicon-copilot',
139
- public locations: ChatAgentLocation[] = ChatAgentLocation.ALL,
140
- public tags: String[] = ['Chat'],
141
- public defaultLogging: boolean = true) {
136
+ @unmanaged() public id: string,
137
+ @unmanaged() public languageModelRequirements: LanguageModelRequirement[],
138
+ @unmanaged() protected defaultLanguageModelPurpose: string,
139
+ @unmanaged() public iconClass: string = 'codicon codicon-copilot',
140
+ @unmanaged() public locations: ChatAgentLocation[] = ChatAgentLocation.ALL,
141
+ @unmanaged() public tags: string[] = ['Chat'],
142
+ @unmanaged() public defaultLogging: boolean = true) {
142
143
  }
143
144
 
144
145
  @postConstruct()
145
146
  init(): void {
146
- this.contentMatchers = this.contentMatcherProviders.getContributions().flatMap(provider => provider.matchers);
147
+ this.initializeContentMatchers();
148
+ }
149
+
150
+ protected initializeContentMatchers(): void {
151
+ const contributedContentMatchers = this.contentMatcherProviders.getContributions().flatMap(provider => provider.matchers);
152
+ this.contentMatchers.push(...contributedContentMatchers);
147
153
  }
148
154
 
149
155
  async invoke(request: ChatRequestModelImpl): Promise<void> {
@@ -152,19 +158,19 @@ export abstract class AbstractChatAgent {
152
158
  if (!languageModel) {
153
159
  throw new Error('Couldn\'t find a matching language model. Please check your setup!');
154
160
  }
161
+
162
+ const systemMessageDescription = await this.getSystemMessageDescription();
155
163
  const messages = await this.getMessages(request.session);
156
164
  if (this.defaultLogging) {
157
- this.recordingService.recordRequest({
158
- agentId: this.id,
159
- sessionId: request.session.id,
160
- timestamp: Date.now(),
161
- requestId: request.id,
162
- request: request.request.text,
163
- messages
164
- });
165
+ this.recordingService.recordRequest(
166
+ ChatHistoryEntry.fromRequest(
167
+ this.id, request, {
168
+ messages,
169
+ systemMessage: systemMessageDescription?.text
170
+ })
171
+ );
165
172
  }
166
173
 
167
- const systemMessageDescription = await this.getSystemMessageDescription();
168
174
  const tools: Map<string, ToolRequest> = new Map();
169
175
  if (systemMessageDescription) {
170
176
  const systemMsg: ChatMessage = {
@@ -194,24 +200,19 @@ export abstract class AbstractChatAgent {
194
200
  cancellationToken.token
195
201
  );
196
202
  await this.addContentsToResponse(languageModelResponse, request);
197
- request.response.complete();
203
+ await this.onResponseComplete(request);
198
204
  if (this.defaultLogging) {
199
- this.recordingService.recordResponse({
200
- agentId: this.id,
201
- sessionId: request.session.id,
202
- timestamp: Date.now(),
203
- requestId: request.response.requestId,
204
- response: request.response.response.asString()
205
- });
205
+ this.recordingService.recordResponse(ChatHistoryEntry.fromResponse(this.id, request));
206
206
  }
207
207
  } catch (e) {
208
208
  this.handleError(request, e);
209
209
  }
210
210
  }
211
211
 
212
- protected parseContents(text: string): ChatResponseContent[] {
212
+ protected parseContents(text: string, request: ChatRequestModelImpl): ChatResponseContent[] {
213
213
  return parseContents(
214
214
  text,
215
+ request,
215
216
  this.contentMatchers,
216
217
  this.defaultContentFactory?.create.bind(this.defaultContentFactory)
217
218
  );
@@ -295,6 +296,16 @@ export abstract class AbstractChatAgent {
295
296
  return undefined;
296
297
  }
297
298
 
299
+ /**
300
+ * Invoked after the response by the LLM completed successfully.
301
+ *
302
+ * The default implementation sets the state of the response to `complete`.
303
+ * Subclasses may override this method to perform additional actions or keep the response open for processing further requests.
304
+ */
305
+ protected async onResponseComplete(request: ChatRequestModelImpl): Promise<void> {
306
+ return request.response.complete();
307
+ }
308
+
298
309
  protected abstract addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void>;
299
310
  }
300
311
 
@@ -318,33 +329,12 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
318
329
 
319
330
  protected override async addContentsToResponse(languageModelResponse: LanguageModelResponse, request: ChatRequestModelImpl): Promise<void> {
320
331
  if (isLanguageModelTextResponse(languageModelResponse)) {
321
- const contents = this.parseContents(languageModelResponse.text);
332
+ const contents = this.parseContents(languageModelResponse.text, request);
322
333
  request.response.response.addContents(contents);
323
- request.response.complete();
324
- if (this.defaultLogging) {
325
- this.recordingService.recordResponse({
326
- agentId: this.id,
327
- sessionId: request.session.id,
328
- timestamp: Date.now(),
329
- requestId: request.response.requestId,
330
- response: request.response.response.asString()
331
-
332
- });
333
- }
334
334
  return;
335
335
  }
336
336
  if (isLanguageModelStreamResponse(languageModelResponse)) {
337
337
  await this.addStreamResponse(languageModelResponse, request);
338
- request.response.complete();
339
- if (this.defaultLogging) {
340
- this.recordingService.recordResponse({
341
- agentId: this.id,
342
- sessionId: request.session.id,
343
- timestamp: Date.now(),
344
- requestId: request.response.requestId,
345
- response: request.response.response.asString()
346
- });
347
- }
348
338
  return;
349
339
  }
350
340
  this.logger.error(
@@ -359,7 +349,7 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
359
349
 
360
350
  protected async addStreamResponse(languageModelResponse: LanguageModelStreamResponse, request: ChatRequestModelImpl): Promise<void> {
361
351
  for await (const token of languageModelResponse.stream) {
362
- const newContents = this.parse(token, request.response.response.content);
352
+ const newContents = this.parse(token, request);
363
353
  if (isArray(newContents)) {
364
354
  request.response.response.addContents(newContents);
365
355
  } else {
@@ -375,7 +365,7 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
375
365
  return;
376
366
  }
377
367
 
378
- const result: ChatResponseContent[] = findFirstMatch(this.contentMatchers, text) ? this.parseContents(text) : [];
368
+ const result: ChatResponseContent[] = findFirstMatch(this.contentMatchers, text) ? this.parseContents(text, request) : [];
379
369
  if (result.length > 0) {
380
370
  request.response.response.addContents(result);
381
371
  } else {
@@ -384,11 +374,11 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
384
374
  }
385
375
  }
386
376
 
387
- protected parse(token: LanguageModelStreamResponsePart, previousContent: ChatResponseContent[]): ChatResponseContent | ChatResponseContent[] {
377
+ protected parse(token: LanguageModelStreamResponsePart, request: ChatRequestModelImpl): ChatResponseContent | ChatResponseContent[] {
388
378
  const content = token.content;
389
379
  // eslint-disable-next-line no-null/no-null
390
380
  if (content !== undefined && content !== null) {
391
- return this.defaultContentFactory.create(content);
381
+ return this.defaultContentFactory.create(content, request);
392
382
  }
393
383
  const toolCalls = token.tool_calls;
394
384
  if (toolCalls !== undefined) {
@@ -396,7 +386,7 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
396
386
  new ToolCallChatResponseContentImpl(toolCall.id, toolCall.function?.name, toolCall.function?.arguments, toolCall.finished, toolCall.result));
397
387
  return toolCallContents;
398
388
  }
399
- return this.defaultContentFactory.create('');
389
+ return this.defaultContentFactory.create('', request);
400
390
  }
401
391
 
402
392
  }
@@ -0,0 +1,47 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
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 { CommunicationRequestEntryParam, CommunicationResponseEntryParam } from '@theia/ai-core/lib/common/communication-recording-service';
18
+ import { ChatRequestModel } from './chat-model';
19
+
20
+ export namespace ChatHistoryEntry {
21
+ export function fromRequest(
22
+ agentId: string,
23
+ request: ChatRequestModel,
24
+ args: Partial<CommunicationRequestEntryParam> = {}
25
+ ): CommunicationRequestEntryParam {
26
+ return {
27
+ agentId: agentId,
28
+ sessionId: request.session.id,
29
+ requestId: request.id,
30
+ request: request.request.text,
31
+ ...args,
32
+ };
33
+ }
34
+ export function fromResponse(
35
+ agentId: string,
36
+ request: ChatRequestModel,
37
+ args: Partial<CommunicationResponseEntryParam> = {}
38
+ ): CommunicationResponseEntryParam {
39
+ return {
40
+ agentId: agentId,
41
+ sessionId: request.session.id,
42
+ requestId: request.id,
43
+ response: request.response.response.asString(),
44
+ ...args,
45
+ };
46
+ }
47
+ }
@@ -0,0 +1,44 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
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
+ import { ChatProgressMessage, ChatRequestModel, ChatResponse, ChatResponseContent, ChatResponseModel, QuestionResponseContent } from './chat-model';
17
+
18
+ export function lastResponseContent(request: ChatRequestModel): ChatResponseContent | undefined {
19
+ return lastContentOfResponse(request.response?.response);
20
+ }
21
+
22
+ export function lastContentOfResponse(response: ChatResponse | undefined): ChatResponseContent | undefined {
23
+ const content = response?.content;
24
+ return content && content.length > 0 ? content[content.length - 1] : undefined;
25
+ }
26
+
27
+ export function lastProgressMessage(request: ChatRequestModel): ChatProgressMessage | undefined {
28
+ return lastProgressMessageOfResponse(request.response);
29
+ }
30
+
31
+ export function lastProgressMessageOfResponse(response: ChatResponseModel | undefined): ChatProgressMessage | undefined {
32
+ const progressMessages = response?.progressMessages;
33
+ return progressMessages && progressMessages.length > 0 ? progressMessages[progressMessages.length - 1] : undefined;
34
+ }
35
+
36
+ export function unansweredQuestions(request: ChatRequestModel): QuestionResponseContent[] {
37
+ const response = request.response;
38
+ return unansweredQuestionsOfResponse(response);
39
+ }
40
+
41
+ function unansweredQuestionsOfResponse(response: ChatResponseModel | undefined): QuestionResponseContent[] {
42
+ if (!response || !response.response) { return []; }
43
+ return response.response.content.filter((c): c is QuestionResponseContent => QuestionResponseContent.is(c) && c.selectedOption === undefined);
44
+ }
@@ -80,6 +80,7 @@ export interface ChatProgressMessage {
80
80
  kind: 'progressMessage';
81
81
  id: string;
82
82
  status: 'inProgress' | 'completed' | 'failed';
83
+ show: 'untilFirstContent' | 'whileIncomplete' | 'forever';
83
84
  content: string;
84
85
  }
85
86
 
@@ -279,6 +280,42 @@ export namespace ErrorChatResponseContent {
279
280
  }
280
281
  }
281
282
 
283
+ export type QuestionResponseHandler = (
284
+ selectedOption: { text: string, value?: string },
285
+ ) => void;
286
+
287
+ export interface QuestionResponseContent extends ChatResponseContent {
288
+ kind: 'question';
289
+ question: string;
290
+ options: { text: string, value?: string }[];
291
+ selectedOption?: { text: string, value?: string };
292
+ handler: QuestionResponseHandler;
293
+ request: ChatRequestModelImpl;
294
+ }
295
+
296
+ export namespace QuestionResponseContent {
297
+ export function is(obj: unknown): obj is QuestionResponseContent {
298
+ return (
299
+ ChatResponseContent.is(obj) &&
300
+ obj.kind === 'question' &&
301
+ 'question' in obj &&
302
+ typeof (obj as { question: unknown }).question === 'string' &&
303
+ 'options' in obj &&
304
+ Array.isArray((obj as { options: unknown }).options) &&
305
+ (obj as { options: unknown[] }).options.every(option =>
306
+ typeof option === 'object' &&
307
+ option && 'text' in option &&
308
+ typeof (option as { text: unknown }).text === 'string' &&
309
+ ('value' in option ? typeof (option as { value: unknown }).value === 'string' || typeof (option as { value: unknown }).value === 'undefined' : true)
310
+ ) &&
311
+ 'handler' in obj &&
312
+ typeof (obj as { handler: unknown }).handler === 'function' &&
313
+ 'request' in obj &&
314
+ obj.request instanceof ChatRequestModelImpl
315
+ );
316
+ }
317
+ }
318
+
282
319
  export interface ChatResponse {
283
320
  readonly content: ChatResponseContent[];
284
321
  asString(): string;
@@ -292,6 +329,7 @@ export interface ChatResponseModel {
292
329
  readonly response: ChatResponse;
293
330
  readonly isComplete: boolean;
294
331
  readonly isCanceled: boolean;
332
+ readonly isWaitingForInput: boolean;
295
333
  readonly isError: boolean;
296
334
  readonly agentId?: string
297
335
  readonly errorObject?: Error;
@@ -602,6 +640,31 @@ export class HorizontalLayoutChatResponseContentImpl implements HorizontalLayout
602
640
  }
603
641
  }
604
642
 
643
+ /**
644
+ * Default implementation for the QuestionResponseContent.
645
+ */
646
+ export class QuestionResponseContentImpl implements QuestionResponseContent {
647
+ readonly kind = 'question';
648
+ protected _selectedOption: { text: string; value?: string } | undefined;
649
+ constructor(public question: string, public options: { text: string, value?: string }[],
650
+ public request: ChatRequestModelImpl, public handler: QuestionResponseHandler) {
651
+ }
652
+ set selectedOption(option: { text: string; value?: string; } | undefined) {
653
+ this._selectedOption = option;
654
+ this.request.response.response.responseContentChanged();
655
+ }
656
+ get selectedOption(): { text: string; value?: string; } | undefined {
657
+ return this._selectedOption;
658
+ }
659
+ asString?(): string | undefined {
660
+ return `Question: ${this.question}
661
+ ${this.selectedOption ? `Answer: ${this.selectedOption?.text}` : 'No answer'}`;
662
+ }
663
+ merge?(): boolean {
664
+ return false;
665
+ }
666
+ }
667
+
605
668
  class ChatResponseImpl implements ChatResponse {
606
669
  protected readonly _onDidChangeEmitter = new Emitter<void>();
607
670
  onDidChange: Event<void> = this._onDidChangeEmitter.event;
@@ -654,6 +717,11 @@ class ChatResponseImpl implements ChatResponse {
654
717
  this._updateResponseRepresentation();
655
718
  }
656
719
 
720
+ responseContentChanged(): void {
721
+ this._updateResponseRepresentation();
722
+ this._onDidChangeEmitter.fire();
723
+ }
724
+
657
725
  protected _updateResponseRepresentation(): void {
658
726
  this._responseRepresentation = this._content
659
727
  .map(responseContent => {
@@ -688,6 +756,7 @@ class ChatResponseModelImpl implements ChatResponseModel {
688
756
  protected _response: ChatResponseImpl;
689
757
  protected _isComplete: boolean;
690
758
  protected _isCanceled: boolean;
759
+ protected _isWaitingForInput: boolean;
691
760
  protected _agentId?: string;
692
761
  protected _isError: boolean;
693
762
  protected _errorObject: Error | undefined;
@@ -702,6 +771,7 @@ class ChatResponseModelImpl implements ChatResponseModel {
702
771
  this._response = response;
703
772
  this._isComplete = false;
704
773
  this._isCanceled = false;
774
+ this._isWaitingForInput = false;
705
775
  this._agentId = agentId;
706
776
  }
707
777
 
@@ -728,6 +798,7 @@ class ChatResponseModelImpl implements ChatResponseModel {
728
798
  kind: 'progressMessage',
729
799
  id,
730
800
  status: message.status ?? 'inProgress',
801
+ show: message.show ?? 'untilFirstContent',
731
802
  ...message,
732
803
  };
733
804
  this._progressMessages.push(newMessage);
@@ -759,6 +830,10 @@ class ChatResponseModelImpl implements ChatResponseModel {
759
830
  return this._isCanceled;
760
831
  }
761
832
 
833
+ get isWaitingForInput(): boolean {
834
+ return this._isWaitingForInput;
835
+ }
836
+
762
837
  get agentId(): string | undefined {
763
838
  return this._agentId;
764
839
  }
@@ -769,17 +844,31 @@ class ChatResponseModelImpl implements ChatResponseModel {
769
844
 
770
845
  complete(): void {
771
846
  this._isComplete = true;
847
+ this._isWaitingForInput = false;
772
848
  this._onDidChangeEmitter.fire();
773
849
  }
774
850
 
775
851
  cancel(): void {
776
852
  this._isComplete = true;
777
853
  this._isCanceled = true;
854
+ this._isWaitingForInput = false;
778
855
  this._onDidChangeEmitter.fire();
779
856
  }
857
+
858
+ waitForInput(): void {
859
+ this._isWaitingForInput = true;
860
+ this._onDidChangeEmitter.fire();
861
+ }
862
+
863
+ stopWaitingForInput(): void {
864
+ this._isWaitingForInput = false;
865
+ this._onDidChangeEmitter.fire();
866
+ }
867
+
780
868
  error(error: Error): void {
781
869
  this._isComplete = true;
782
870
  this._isCanceled = false;
871
+ this._isWaitingForInput = false;
783
872
  this._isError = true;
784
873
  this._errorObject = error;
785
874
  this._onDidChangeEmitter.fire();
@@ -36,7 +36,9 @@ import {
36
36
 
37
37
  export const commandTemplate: PromptTemplate = {
38
38
  id: 'command-system',
39
- template: `# System Prompt
39
+ template: `{{!-- Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
40
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
41
+ # System Prompt
40
42
 
41
43
  You are a service that helps users find commands to execute in an IDE.
42
44
  You reply with stringified JSON Objects that tell the user which command to execute and its arguments, if any.
@@ -16,6 +16,7 @@
16
16
  export * from './chat-agents';
17
17
  export * from './chat-agent-service';
18
18
  export * from './chat-model';
19
+ export * from './chat-model-util';
19
20
  export * from './chat-request-parser';
20
21
  export * from './chat-service';
21
22
  export * from './command-chat-agents';