@theia/ai-chat 1.67.0-next.3 → 1.67.0-next.56

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 (250) hide show
  1. package/README.md +1 -0
  2. package/package.json +9 -9
  3. package/{lib/common/context-variables.js → src/browser/context-file-validation-service.ts} +19 -7
  4. package/lib/browser/agent-delegation-tool.d.ts +0 -25
  5. package/lib/browser/agent-delegation-tool.d.ts.map +0 -1
  6. package/lib/browser/agent-delegation-tool.js +0 -196
  7. package/lib/browser/agent-delegation-tool.js.map +0 -1
  8. package/lib/browser/ai-chat-frontend-contribution.d.ts +0 -11
  9. package/lib/browser/ai-chat-frontend-contribution.d.ts.map +0 -1
  10. package/lib/browser/ai-chat-frontend-contribution.js +0 -56
  11. package/lib/browser/ai-chat-frontend-contribution.js.map +0 -1
  12. package/lib/browser/ai-chat-frontend-module.d.ts +0 -4
  13. package/lib/browser/ai-chat-frontend-module.d.ts.map +0 -1
  14. package/lib/browser/ai-chat-frontend-module.js +0 -143
  15. package/lib/browser/ai-chat-frontend-module.js.map +0 -1
  16. package/lib/browser/change-set-decorator-service.d.ts +0 -24
  17. package/lib/browser/change-set-decorator-service.d.ts.map +0 -1
  18. package/lib/browser/change-set-decorator-service.js +0 -66
  19. package/lib/browser/change-set-decorator-service.js.map +0 -1
  20. package/lib/browser/change-set-file-element-deserializer.d.ts +0 -7
  21. package/lib/browser/change-set-file-element-deserializer.d.ts.map +0 -1
  22. package/lib/browser/change-set-file-element-deserializer.js +0 -61
  23. package/lib/browser/change-set-file-element-deserializer.js.map +0 -1
  24. package/lib/browser/change-set-file-element.d.ts +0 -122
  25. package/lib/browser/change-set-file-element.d.ts.map +0 -1
  26. package/lib/browser/change-set-file-element.js +0 -435
  27. package/lib/browser/change-set-file-element.js.map +0 -1
  28. package/lib/browser/change-set-file-resource.d.ts +0 -4
  29. package/lib/browser/change-set-file-resource.d.ts.map +0 -1
  30. package/lib/browser/change-set-file-resource.js +0 -24
  31. package/lib/browser/change-set-file-resource.js.map +0 -1
  32. package/lib/browser/change-set-file-service.d.ts +0 -32
  33. package/lib/browser/change-set-file-service.d.ts.map +0 -1
  34. package/lib/browser/change-set-file-service.js +0 -161
  35. package/lib/browser/change-set-file-service.js.map +0 -1
  36. package/lib/browser/change-set-variable.d.ts +0 -11
  37. package/lib/browser/change-set-variable.d.ts.map +0 -1
  38. package/lib/browser/change-set-variable.js +0 -64
  39. package/lib/browser/change-set-variable.js.map +0 -1
  40. package/lib/browser/chat-session-store-impl.d.ts +0 -36
  41. package/lib/browser/chat-session-store-impl.d.ts.map +0 -1
  42. package/lib/browser/chat-session-store-impl.js +0 -287
  43. package/lib/browser/chat-session-store-impl.js.map +0 -1
  44. package/lib/browser/chat-tool-preference-bindings.d.ts +0 -34
  45. package/lib/browser/chat-tool-preference-bindings.d.ts.map +0 -1
  46. package/lib/browser/chat-tool-preference-bindings.js +0 -122
  47. package/lib/browser/chat-tool-preference-bindings.js.map +0 -1
  48. package/lib/browser/chat-tool-request-service.d.ts +0 -21
  49. package/lib/browser/chat-tool-request-service.d.ts.map +0 -1
  50. package/lib/browser/chat-tool-request-service.js +0 -90
  51. package/lib/browser/chat-tool-request-service.js.map +0 -1
  52. package/lib/browser/context-file-variable-label-provider.d.ts +0 -14
  53. package/lib/browser/context-file-variable-label-provider.d.ts.map +0 -1
  54. package/lib/browser/context-file-variable-label-provider.js +0 -63
  55. package/lib/browser/context-file-variable-label-provider.js.map +0 -1
  56. package/lib/browser/context-variable-label-provider.d.ts +0 -9
  57. package/lib/browser/context-variable-label-provider.d.ts.map +0 -1
  58. package/lib/browser/context-variable-label-provider.js +0 -55
  59. package/lib/browser/context-variable-label-provider.js.map +0 -1
  60. package/lib/browser/custom-agent-factory.d.ts +0 -4
  61. package/lib/browser/custom-agent-factory.d.ts.map +0 -1
  62. package/lib/browser/custom-agent-factory.js +0 -20
  63. package/lib/browser/custom-agent-factory.js.map +0 -1
  64. package/lib/browser/custom-agent-frontend-application-contribution.d.ts +0 -13
  65. package/lib/browser/custom-agent-frontend-application-contribution.d.ts.map +0 -1
  66. package/lib/browser/custom-agent-frontend-application-contribution.js +0 -83
  67. package/lib/browser/custom-agent-frontend-application-contribution.js.map +0 -1
  68. package/lib/browser/delegation-response-content.d.ts +0 -20
  69. package/lib/browser/delegation-response-content.d.ts.map +0 -1
  70. package/lib/browser/delegation-response-content.js +0 -47
  71. package/lib/browser/delegation-response-content.js.map +0 -1
  72. package/lib/browser/file-chat-variable-contribution.d.ts +0 -32
  73. package/lib/browser/file-chat-variable-contribution.d.ts.map +0 -1
  74. package/lib/browser/file-chat-variable-contribution.js +0 -241
  75. package/lib/browser/file-chat-variable-contribution.js.map +0 -1
  76. package/lib/browser/frontend-chat-service.d.ts +0 -15
  77. package/lib/browser/frontend-chat-service.d.ts.map +0 -1
  78. package/lib/browser/frontend-chat-service.js +0 -72
  79. package/lib/browser/frontend-chat-service.js.map +0 -1
  80. package/lib/browser/image-context-variable-contribution.d.ts +0 -27
  81. package/lib/browser/image-context-variable-contribution.d.ts.map +0 -1
  82. package/lib/browser/image-context-variable-contribution.js +0 -149
  83. package/lib/browser/image-context-variable-contribution.js.map +0 -1
  84. package/lib/browser/task-context-service.d.ts +0 -46
  85. package/lib/browser/task-context-service.d.ts.map +0 -1
  86. package/lib/browser/task-context-service.js +0 -256
  87. package/lib/browser/task-context-service.js.map +0 -1
  88. package/lib/browser/task-context-storage-service.d.ts +0 -19
  89. package/lib/browser/task-context-storage-service.d.ts.map +0 -1
  90. package/lib/browser/task-context-storage-service.js +0 -80
  91. package/lib/browser/task-context-storage-service.js.map +0 -1
  92. package/lib/browser/task-context-variable-contribution.d.ts +0 -20
  93. package/lib/browser/task-context-variable-contribution.d.ts.map +0 -1
  94. package/lib/browser/task-context-variable-contribution.js +0 -101
  95. package/lib/browser/task-context-variable-contribution.js.map +0 -1
  96. package/lib/browser/task-context-variable-label-provider.d.ts +0 -21
  97. package/lib/browser/task-context-variable-label-provider.d.ts.map +0 -1
  98. package/lib/browser/task-context-variable-label-provider.js +0 -83
  99. package/lib/browser/task-context-variable-label-provider.js.map +0 -1
  100. package/lib/browser/task-context-variable.d.ts +0 -3
  101. package/lib/browser/task-context-variable.d.ts.map +0 -1
  102. package/lib/browser/task-context-variable.js +0 -33
  103. package/lib/browser/task-context-variable.js.map +0 -1
  104. package/lib/common/ai-chat-preferences.d.ts +0 -5
  105. package/lib/common/ai-chat-preferences.d.ts.map +0 -1
  106. package/lib/common/ai-chat-preferences.js +0 -40
  107. package/lib/common/ai-chat-preferences.js.map +0 -1
  108. package/lib/common/change-set-element-deserializer.d.ts +0 -30
  109. package/lib/common/change-set-element-deserializer.d.ts.map +0 -1
  110. package/lib/common/change-set-element-deserializer.js +0 -81
  111. package/lib/common/change-set-element-deserializer.js.map +0 -1
  112. package/lib/common/change-set.d.ts +0 -85
  113. package/lib/common/change-set.d.ts.map +0 -1
  114. package/lib/common/change-set.js +0 -133
  115. package/lib/common/change-set.js.map +0 -1
  116. package/lib/common/chat-agent-service.d.ts +0 -46
  117. package/lib/common/chat-agent-service.d.ts.map +0 -1
  118. package/lib/common/chat-agent-service.js +0 -79
  119. package/lib/common/chat-agent-service.js.map +0 -1
  120. package/lib/common/chat-agents-variable-contribution.d.ts +0 -17
  121. package/lib/common/chat-agents-variable-contribution.d.ts.map +0 -1
  122. package/lib/common/chat-agents-variable-contribution.js +0 -67
  123. package/lib/common/chat-agents-variable-contribution.js.map +0 -1
  124. package/lib/common/chat-agents.d.ts +0 -138
  125. package/lib/common/chat-agents.d.ts.map +0 -1
  126. package/lib/common/chat-agents.js +0 -428
  127. package/lib/common/chat-agents.js.map +0 -1
  128. package/lib/common/chat-auto-save.spec.d.ts +0 -2
  129. package/lib/common/chat-auto-save.spec.d.ts.map +0 -1
  130. package/lib/common/chat-auto-save.spec.js +0 -304
  131. package/lib/common/chat-auto-save.spec.js.map +0 -1
  132. package/lib/common/chat-content-deserializer.d.ts +0 -161
  133. package/lib/common/chat-content-deserializer.d.ts.map +0 -1
  134. package/lib/common/chat-content-deserializer.js +0 -166
  135. package/lib/common/chat-content-deserializer.js.map +0 -1
  136. package/lib/common/chat-content-deserializer.spec.d.ts +0 -2
  137. package/lib/common/chat-content-deserializer.spec.d.ts.map +0 -1
  138. package/lib/common/chat-content-deserializer.spec.js +0 -307
  139. package/lib/common/chat-content-deserializer.spec.js.map +0 -1
  140. package/lib/common/chat-model-serialization.d.ts +0 -110
  141. package/lib/common/chat-model-serialization.d.ts.map +0 -1
  142. package/lib/common/chat-model-serialization.js +0 -20
  143. package/lib/common/chat-model-serialization.js.map +0 -1
  144. package/lib/common/chat-model-serialization.spec.d.ts +0 -2
  145. package/lib/common/chat-model-serialization.spec.d.ts.map +0 -1
  146. package/lib/common/chat-model-serialization.spec.js +0 -278
  147. package/lib/common/chat-model-serialization.spec.js.map +0 -1
  148. package/lib/common/chat-model-util.d.ts +0 -7
  149. package/lib/common/chat-model-util.d.ts.map +0 -1
  150. package/lib/common/chat-model-util.js +0 -50
  151. package/lib/common/chat-model-util.js.map +0 -1
  152. package/lib/common/chat-model.d.ts +0 -923
  153. package/lib/common/chat-model.d.ts.map +0 -1
  154. package/lib/common/chat-model.js +0 -1791
  155. package/lib/common/chat-model.js.map +0 -1
  156. package/lib/common/chat-request-parser.d.ts +0 -38
  157. package/lib/common/chat-request-parser.d.ts.map +0 -1
  158. package/lib/common/chat-request-parser.js +0 -230
  159. package/lib/common/chat-request-parser.js.map +0 -1
  160. package/lib/common/chat-request-parser.spec.d.ts +0 -2
  161. package/lib/common/chat-request-parser.spec.d.ts.map +0 -1
  162. package/lib/common/chat-request-parser.spec.js +0 -235
  163. package/lib/common/chat-request-parser.spec.js.map +0 -1
  164. package/lib/common/chat-service-deletion.spec.d.ts +0 -2
  165. package/lib/common/chat-service-deletion.spec.d.ts.map +0 -1
  166. package/lib/common/chat-service-deletion.spec.js +0 -221
  167. package/lib/common/chat-service-deletion.spec.js.map +0 -1
  168. package/lib/common/chat-service.d.ts +0 -153
  169. package/lib/common/chat-service.d.ts.map +0 -1
  170. package/lib/common/chat-service.js +0 -474
  171. package/lib/common/chat-service.js.map +0 -1
  172. package/lib/common/chat-session-naming-prompt-template.d.ts +0 -3
  173. package/lib/common/chat-session-naming-prompt-template.d.ts.map +0 -1
  174. package/lib/common/chat-session-naming-prompt-template.js +0 -31
  175. package/lib/common/chat-session-naming-prompt-template.js.map +0 -1
  176. package/lib/common/chat-session-naming-service.d.ts +0 -26
  177. package/lib/common/chat-session-naming-service.d.ts.map +0 -1
  178. package/lib/common/chat-session-naming-service.js +0 -119
  179. package/lib/common/chat-session-naming-service.js.map +0 -1
  180. package/lib/common/chat-session-store.d.ts +0 -43
  181. package/lib/common/chat-session-store.d.ts.map +0 -1
  182. package/lib/common/chat-session-store.js +0 -20
  183. package/lib/common/chat-session-store.js.map +0 -1
  184. package/lib/common/chat-session-summary-agent-prompt.d.ts +0 -8
  185. package/lib/common/chat-session-summary-agent-prompt.d.ts.map +0 -1
  186. package/lib/common/chat-session-summary-agent-prompt.js +0 -33
  187. package/lib/common/chat-session-summary-agent-prompt.js.map +0 -1
  188. package/lib/common/chat-session-summary-agent.d.ts +0 -16
  189. package/lib/common/chat-session-summary-agent.d.ts.map +0 -1
  190. package/lib/common/chat-session-summary-agent.js +0 -48
  191. package/lib/common/chat-session-summary-agent.js.map +0 -1
  192. package/lib/common/chat-string-utils.d.ts +0 -3
  193. package/lib/common/chat-string-utils.d.ts.map +0 -1
  194. package/lib/common/chat-string-utils.js +0 -27
  195. package/lib/common/chat-string-utils.js.map +0 -1
  196. package/lib/common/chat-tool-preferences.d.ts +0 -23
  197. package/lib/common/chat-tool-preferences.d.ts.map +0 -1
  198. package/lib/common/chat-tool-preferences.js +0 -68
  199. package/lib/common/chat-tool-preferences.js.map +0 -1
  200. package/lib/common/chat-tool-request-service.d.ts +0 -18
  201. package/lib/common/chat-tool-request-service.d.ts.map +0 -1
  202. package/lib/common/chat-tool-request-service.js +0 -52
  203. package/lib/common/chat-tool-request-service.js.map +0 -1
  204. package/lib/common/context-details-variable.d.ts +0 -9
  205. package/lib/common/context-details-variable.d.ts.map +0 -1
  206. package/lib/common/context-details-variable.js +0 -57
  207. package/lib/common/context-details-variable.js.map +0 -1
  208. package/lib/common/context-summary-variable.d.ts +0 -9
  209. package/lib/common/context-summary-variable.d.ts.map +0 -1
  210. package/lib/common/context-summary-variable.js +0 -57
  211. package/lib/common/context-summary-variable.js.map +0 -1
  212. package/lib/common/context-variables.d.ts +0 -4
  213. package/lib/common/context-variables.d.ts.map +0 -1
  214. package/lib/common/context-variables.js.map +0 -1
  215. package/lib/common/custom-chat-agent.d.ts +0 -10
  216. package/lib/common/custom-chat-agent.d.ts.map +0 -1
  217. package/lib/common/custom-chat-agent.js +0 -40
  218. package/lib/common/custom-chat-agent.js.map +0 -1
  219. package/lib/common/image-context-variable.d.ts +0 -29
  220. package/lib/common/image-context-variable.d.ts.map +0 -1
  221. package/lib/common/image-context-variable.js +0 -114
  222. package/lib/common/image-context-variable.js.map +0 -1
  223. package/lib/common/index.d.ts +0 -13
  224. package/lib/common/index.d.ts.map +0 -1
  225. package/lib/common/index.js +0 -31
  226. package/lib/common/index.js.map +0 -1
  227. package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts +0 -2
  228. package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts.map +0 -1
  229. package/lib/common/parse-contents-with-incomplete-parts.spec.js +0 -103
  230. package/lib/common/parse-contents-with-incomplete-parts.spec.js.map +0 -1
  231. package/lib/common/parse-contents.d.ts +0 -12
  232. package/lib/common/parse-contents.d.ts.map +0 -1
  233. package/lib/common/parse-contents.js +0 -107
  234. package/lib/common/parse-contents.js.map +0 -1
  235. package/lib/common/parse-contents.spec.d.ts +0 -10
  236. package/lib/common/parse-contents.spec.d.ts.map +0 -1
  237. package/lib/common/parse-contents.spec.js +0 -146
  238. package/lib/common/parse-contents.spec.js.map +0 -1
  239. package/lib/common/parsed-chat-request.d.ts +0 -66
  240. package/lib/common/parsed-chat-request.d.ts.map +0 -1
  241. package/lib/common/parsed-chat-request.js +0 -83
  242. package/lib/common/parsed-chat-request.js.map +0 -1
  243. package/lib/common/response-content-matcher.d.ts +0 -69
  244. package/lib/common/response-content-matcher.d.ts.map +0 -1
  245. package/lib/common/response-content-matcher.js +0 -97
  246. package/lib/common/response-content-matcher.js.map +0 -1
  247. package/lib/node/ai-chat-backend-module.d.ts +0 -4
  248. package/lib/node/ai-chat-backend-module.d.ts.map +0 -1
  249. package/lib/node/ai-chat-backend-module.js +0 -26
  250. package/lib/node/ai-chat-backend-module.js.map +0 -1
@@ -1,235 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const sinon = require("sinon");
19
- const chat_agent_service_1 = require("./chat-agent-service");
20
- const chat_request_parser_1 = require("./chat-request-parser");
21
- const chat_agents_1 = require("./chat-agents");
22
- const chai_1 = require("chai");
23
- const ai_core_1 = require("@theia/ai-core");
24
- const core_1 = require("@theia/core");
25
- const parsed_chat_request_1 = require("./parsed-chat-request");
26
- describe('ChatRequestParserImpl', () => {
27
- const chatAgentService = sinon.createStubInstance(chat_agent_service_1.ChatAgentServiceImpl);
28
- const variableService = sinon.createStubInstance(ai_core_1.DefaultAIVariableService);
29
- const toolInvocationRegistry = sinon.createStubInstance(ai_core_1.ToolInvocationRegistryImpl);
30
- const logger = sinon.createStubInstance(core_1.Logger);
31
- const parser = new chat_request_parser_1.ChatRequestParserImpl(chatAgentService, variableService, toolInvocationRegistry, logger);
32
- beforeEach(() => {
33
- // Reset our stubs before each test
34
- sinon.reset();
35
- });
36
- it('parses simple text', async () => {
37
- const req = {
38
- text: 'What is the best pizza topping?'
39
- };
40
- const context = { variables: [] };
41
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
42
- (0, chai_1.expect)(result.parts).to.deep.contain({
43
- text: 'What is the best pizza topping?',
44
- range: { start: 0, endExclusive: 31 }
45
- });
46
- });
47
- it('parses text with variable name', async () => {
48
- const req = {
49
- text: 'What is the #best pizza topping?'
50
- };
51
- const context = { variables: [] };
52
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
53
- (0, chai_1.expect)(result).to.deep.contain({
54
- parts: [{
55
- text: 'What is the ',
56
- range: { start: 0, endExclusive: 12 }
57
- }, {
58
- variableName: 'best',
59
- variableArg: undefined,
60
- range: { start: 12, endExclusive: 17 }
61
- }, {
62
- text: ' pizza topping?',
63
- range: { start: 17, endExclusive: 32 }
64
- }]
65
- });
66
- });
67
- it('parses text with variable name with argument', async () => {
68
- const req = {
69
- text: 'What is the #best:by-poll pizza topping?'
70
- };
71
- const context = { variables: [] };
72
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
73
- (0, chai_1.expect)(result).to.deep.contain({
74
- parts: [{
75
- text: 'What is the ',
76
- range: { start: 0, endExclusive: 12 }
77
- }, {
78
- variableName: 'best',
79
- variableArg: 'by-poll',
80
- range: { start: 12, endExclusive: 25 }
81
- }, {
82
- text: ' pizza topping?',
83
- range: { start: 25, endExclusive: 40 }
84
- }]
85
- });
86
- });
87
- it('parses text with variable name with numeric argument', async () => {
88
- const req = {
89
- text: '#size-class:2'
90
- };
91
- const context = { variables: [] };
92
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
93
- (0, chai_1.expect)(result.parts[0]).to.contain({
94
- variableName: 'size-class',
95
- variableArg: '2'
96
- });
97
- });
98
- it('parses text with variable name with POSIX path argument', async () => {
99
- const req = {
100
- text: '#file:/path/to/file.ext'
101
- };
102
- const context = { variables: [] };
103
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
104
- (0, chai_1.expect)(result.parts[0]).to.contain({
105
- variableName: 'file',
106
- variableArg: '/path/to/file.ext'
107
- });
108
- });
109
- it('parses text with variable name with Win32 path argument', async () => {
110
- const req = {
111
- text: '#file:c:\\path\\to\\file.ext'
112
- };
113
- const context = { variables: [] };
114
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
115
- (0, chai_1.expect)(result.parts[0]).to.contain({
116
- variableName: 'file',
117
- variableArg: 'c:\\path\\to\\file.ext'
118
- });
119
- });
120
- it('resolves variable and extracts tool functions from resolved variable', async () => {
121
- // Set up two test tool requests that will be referenced in the variable content
122
- const testTool1 = {
123
- id: 'testTool1',
124
- name: 'Test Tool 1',
125
- handler: async () => undefined,
126
- parameters: {
127
- type: 'object',
128
- properties: {}
129
- },
130
- };
131
- const testTool2 = {
132
- id: 'testTool2',
133
- name: 'Test Tool 2',
134
- handler: async () => undefined,
135
- parameters: {
136
- type: 'object',
137
- properties: {}
138
- },
139
- };
140
- // Configure the tool registry to return our test tools
141
- toolInvocationRegistry.getFunction.withArgs(testTool1.id).returns(testTool1);
142
- toolInvocationRegistry.getFunction.withArgs(testTool2.id).returns(testTool2);
143
- // Set up the test variable to include in the request
144
- const testVariable = {
145
- id: 'testVariable',
146
- name: 'testVariable',
147
- description: 'A test variable',
148
- };
149
- // Configure the variable service to return our test variable
150
- // One tool reference uses chat format and one uses prompt format because the parser needs to handle both.
151
- variableService.getVariable.withArgs(testVariable.name).returns(testVariable);
152
- variableService.resolveVariable.withArgs({ variable: testVariable.name, arg: 'myarg' }, sinon.match.any).resolves({
153
- variable: testVariable,
154
- arg: 'myarg',
155
- value: 'This is a test with ~testTool1 and **~{testTool2}** and more text.',
156
- });
157
- // Create a request with the test variable
158
- const req = {
159
- text: 'Test with #testVariable:myarg'
160
- };
161
- const context = { variables: [] };
162
- // Parse the request
163
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
164
- // Verify the variable part contains the correct properties
165
- (0, chai_1.expect)(result.parts.length).to.equal(2);
166
- (0, chai_1.expect)(result.parts[0] instanceof parsed_chat_request_1.ParsedChatRequestTextPart).to.be.true;
167
- (0, chai_1.expect)(result.parts[1] instanceof parsed_chat_request_1.ParsedChatRequestVariablePart).to.be.true;
168
- const variablePart = result.parts[1];
169
- (0, chai_1.expect)(variablePart).to.have.property('resolution');
170
- (0, chai_1.expect)(variablePart.resolution).to.deep.equal({
171
- variable: testVariable,
172
- arg: 'myarg',
173
- value: 'This is a test with ~testTool1 and **~{testTool2}** and more text.',
174
- });
175
- // Verify both tool functions were extracted from the variable content
176
- (0, chai_1.expect)(result.toolRequests.size).to.equal(2);
177
- (0, chai_1.expect)(result.toolRequests.has(testTool1.id)).to.be.true;
178
- (0, chai_1.expect)(result.toolRequests.has(testTool2.id)).to.be.true;
179
- // Verify the result contains the tool requests returned by the registry
180
- (0, chai_1.expect)(result.toolRequests.get(testTool1.id)).to.deep.equal(testTool1);
181
- (0, chai_1.expect)(result.toolRequests.get(testTool2.id)).to.deep.equal(testTool2);
182
- });
183
- it('parses simple command without arguments', async () => {
184
- const req = {
185
- text: '/hello'
186
- };
187
- const context = { variables: [] };
188
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
189
- (0, chai_1.expect)(result.parts.length).to.equal(1);
190
- (0, chai_1.expect)(result.parts[0] instanceof parsed_chat_request_1.ParsedChatRequestVariablePart).to.be.true;
191
- const varPart = result.parts[0];
192
- (0, chai_1.expect)(varPart.variableName).to.equal('prompt');
193
- (0, chai_1.expect)(varPart.variableArg).to.equal('hello');
194
- });
195
- it('parses command with single argument', async () => {
196
- const req = {
197
- text: '/explain topic'
198
- };
199
- const context = { variables: [] };
200
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
201
- (0, chai_1.expect)(result.parts.length).to.equal(1);
202
- const varPart = result.parts[0];
203
- (0, chai_1.expect)(varPart.variableName).to.equal('prompt');
204
- (0, chai_1.expect)(varPart.variableArg).to.equal('explain|topic');
205
- });
206
- it('parses command with multiple arguments', async () => {
207
- const req = {
208
- text: '/compare item1 item2'
209
- };
210
- const context = { variables: [] };
211
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
212
- const varPart = result.parts[0];
213
- (0, chai_1.expect)(varPart.variableName).to.equal('prompt');
214
- (0, chai_1.expect)(varPart.variableArg).to.equal('compare|item1 item2');
215
- });
216
- it('parses command with quoted arguments', async () => {
217
- const req = {
218
- text: '/cmd "arg with spaces" other'
219
- };
220
- const context = { variables: [] };
221
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
222
- const varPart = result.parts[0];
223
- (0, chai_1.expect)(varPart.variableArg).to.equal('cmd|"arg with spaces" other');
224
- });
225
- it('handles command with escaped quotes', async () => {
226
- const req = {
227
- text: '/cmd "arg with \\"quote\\"" other'
228
- };
229
- const context = { variables: [] };
230
- const result = await parser.parseChatRequest(req, chat_agents_1.ChatAgentLocation.Panel, context);
231
- const varPart = result.parts[0];
232
- (0, chai_1.expect)(varPart.variableArg).to.equal('cmd|"arg with \\"quote\\"" other');
233
- });
234
- });
235
- //# sourceMappingURL=chat-request-parser.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-request-parser.spec.js","sourceRoot":"","sources":["../../src/common/chat-request-parser.spec.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;AAC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CAAmC;SAC5C,CAAC;QACF,MAAM,OAAO,GAAgB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,+BAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEpF,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAkC,CAAC;QACjE,IAAA,aAAM,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=chat-service-deletion.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-service-deletion.spec.d.ts","sourceRoot":"","sources":["../../src/common/chat-service-deletion.spec.ts"],"names":[],"mappings":""}
@@ -1,221 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2025 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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const chai_1 = require("chai");
19
- const inversify_1 = require("@theia/core/shared/inversify");
20
- const chat_service_1 = require("./chat-service");
21
- const chat_session_store_1 = require("./chat-session-store");
22
- const chat_agent_service_1 = require("./chat-agent-service");
23
- const chat_request_parser_1 = require("./chat-request-parser");
24
- const ai_core_1 = require("@theia/ai-core");
25
- const core_1 = require("@theia/core");
26
- const chat_content_deserializer_1 = require("./chat-content-deserializer");
27
- const change_set_element_deserializer_1 = require("./change-set-element-deserializer");
28
- const chat_agents_1 = require("./chat-agents");
29
- describe('ChatService Session Deletion', () => {
30
- let chatService;
31
- let sessionStore;
32
- let container;
33
- class MockChatSessionStore {
34
- constructor() {
35
- this.deletedSessions = [];
36
- this.storedSessions = [];
37
- }
38
- async storeSessions(...sessions) {
39
- this.storedSessions = sessions;
40
- }
41
- async readSession(sessionId) {
42
- return undefined;
43
- }
44
- async deleteSession(sessionId) {
45
- this.deletedSessions.push(sessionId);
46
- }
47
- async clearAllSessions() {
48
- this.deletedSessions = [];
49
- this.storedSessions = [];
50
- }
51
- async getSessionIndex() {
52
- return {};
53
- }
54
- async setSessionTitle(sessionId, title) {
55
- }
56
- }
57
- class MockChatAgentService {
58
- getAgent() {
59
- return undefined;
60
- }
61
- getAgents() {
62
- return [];
63
- }
64
- }
65
- class MockChatRequestParser {
66
- parseChatRequest() {
67
- return { parts: [], text: '' };
68
- }
69
- }
70
- class MockAIVariableService {
71
- resolveVariables() {
72
- return Promise.resolve([]);
73
- }
74
- }
75
- class MockLogger {
76
- error() { }
77
- warn() { }
78
- info() { }
79
- debug() { }
80
- }
81
- beforeEach(() => {
82
- container = new inversify_1.Container();
83
- sessionStore = new MockChatSessionStore();
84
- container.bind(chat_session_store_1.ChatSessionStore).toConstantValue(sessionStore);
85
- container.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
86
- container.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
87
- container.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
88
- container.bind(core_1.ILogger).toConstantValue(new MockLogger());
89
- // Bind deserializer registries
90
- const contentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
91
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(contentRegistry);
92
- container.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(contentRegistry);
93
- container.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
94
- container.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
95
- chatService = container.get(chat_service_1.ChatServiceImpl);
96
- });
97
- describe('deleteSession', () => {
98
- it('should delete session from memory and persistent storage', async () => {
99
- // Create a session
100
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
101
- (0, chai_1.expect)(chatService.getSessions()).to.have.lengthOf(1);
102
- // Delete the session (now returns a Promise)
103
- await chatService.deleteSession(session.id);
104
- // Verify it's removed from memory
105
- (0, chai_1.expect)(chatService.getSessions()).to.have.lengthOf(0);
106
- // Verify it's deleted from persistent storage
107
- (0, chai_1.expect)(sessionStore.deletedSessions).to.include(session.id);
108
- });
109
- it('should emit SessionDeletedEvent when session is deleted', done => {
110
- // Create a session
111
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
112
- // Listen for deletion event
113
- chatService.onSessionEvent(event => {
114
- if (event.type === 'deleted') {
115
- (0, chai_1.expect)(event.sessionId).to.equal(session.id);
116
- done();
117
- }
118
- });
119
- // Delete the session
120
- chatService.deleteSession(session.id);
121
- });
122
- it('should handle deletion when session store is not available', async () => {
123
- // Create a new service without session store
124
- const containerWithoutStore = new inversify_1.Container();
125
- containerWithoutStore.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
126
- containerWithoutStore.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
127
- containerWithoutStore.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
128
- containerWithoutStore.bind(core_1.ILogger).toConstantValue(new MockLogger());
129
- // Bind deserializer registries
130
- const contentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
131
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(contentRegistry);
132
- containerWithoutStore.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(contentRegistry);
133
- containerWithoutStore.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
134
- containerWithoutStore.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
135
- const serviceWithoutStore = containerWithoutStore.get(chat_service_1.ChatServiceImpl);
136
- // Create and delete a session - should not throw
137
- const session = serviceWithoutStore.createSession(chat_agents_1.ChatAgentLocation.Panel);
138
- await serviceWithoutStore.deleteSession(session.id);
139
- // Verify session is still removed from memory
140
- (0, chai_1.expect)(serviceWithoutStore.getSessions()).to.have.lengthOf(0);
141
- });
142
- it('should attempt storage deletion even for non-existent in-memory sessions', async () => {
143
- const initialDeletedCount = sessionStore.deletedSessions.length;
144
- const nonExistentId = 'non-existent-id';
145
- // Try to delete non-existent session (could be a persisted-only session)
146
- await chatService.deleteSession(nonExistentId);
147
- // Verify storage deletion was attempted even though session not in memory
148
- (0, chai_1.expect)(sessionStore.deletedSessions).to.include(nonExistentId);
149
- (0, chai_1.expect)(sessionStore.deletedSessions).to.have.lengthOf(initialDeletedCount + 1);
150
- });
151
- it('should handle deleting active session', () => {
152
- var _a;
153
- // Create two sessions
154
- const session1 = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
155
- const session2 = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
156
- // Ensure session2 is active (it should be by default as the latest)
157
- (0, chai_1.expect)((_a = chatService.getActiveSession()) === null || _a === void 0 ? void 0 : _a.id).to.equal(session2.id);
158
- // Delete session1 (not active)
159
- chatService.deleteSession(session1.id);
160
- // Verify session2 is still active
161
- const activeSession = chatService.getActiveSession();
162
- (0, chai_1.expect)(activeSession).to.not.be.undefined;
163
- (0, chai_1.expect)(activeSession === null || activeSession === void 0 ? void 0 : activeSession.id).to.equal(session2.id);
164
- });
165
- it('should handle storage deletion errors gracefully', async () => {
166
- // Create a session store that throws errors
167
- const errorStore = new MockChatSessionStore();
168
- errorStore.deleteSession = async () => {
169
- throw new Error('Storage error');
170
- };
171
- const errorContainer = new inversify_1.Container();
172
- errorContainer.bind(chat_session_store_1.ChatSessionStore).toConstantValue(errorStore);
173
- errorContainer.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
174
- errorContainer.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
175
- errorContainer.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
176
- errorContainer.bind(core_1.ILogger).toConstantValue(new MockLogger());
177
- // Bind deserializer registries
178
- const contentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
179
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(contentRegistry);
180
- errorContainer.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(contentRegistry);
181
- errorContainer.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
182
- errorContainer.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
183
- const errorService = errorContainer.get(chat_service_1.ChatServiceImpl);
184
- // Create and delete a session - should not throw even with storage error
185
- const session = errorService.createSession(chat_agents_1.ChatAgentLocation.Panel);
186
- await errorService.deleteSession(session.id);
187
- // Verify session is still removed from memory despite storage error
188
- (0, chai_1.expect)(errorService.getSessions()).to.have.lengthOf(0);
189
- });
190
- it('should delete persisted-only sessions (not loaded in memory)', async () => {
191
- // This simulates deleting a session from the "Show Chats..." dialog
192
- // when the session is persisted but not currently loaded into memory
193
- const persistedSessionId = 'persisted-session-123';
194
- // Verify session is not in memory
195
- (0, chai_1.expect)(chatService.getSessions().find(s => s.id === persistedSessionId)).to.be.undefined;
196
- // Delete the persisted-only session
197
- await chatService.deleteSession(persistedSessionId);
198
- // Verify it was still deleted from storage (even though not in memory)
199
- (0, chai_1.expect)(sessionStore.deletedSessions).to.include(persistedSessionId);
200
- });
201
- it('should not fire SessionDeletedEvent for persisted-only sessions', async () => {
202
- // When deleting a persisted-only session (not in memory),
203
- // we shouldn't fire the event since no in-memory state changed
204
- const persistedSessionId = 'persisted-session-456';
205
- let eventFired = false;
206
- // Listen for deletion event
207
- chatService.onSessionEvent(event => {
208
- if (event.type === 'deleted' && event.sessionId === persistedSessionId) {
209
- eventFired = true;
210
- }
211
- });
212
- // Delete the persisted-only session
213
- await chatService.deleteSession(persistedSessionId);
214
- // Event should not have been fired since session wasn't in memory
215
- (0, chai_1.expect)(eventFired).to.be.false;
216
- // But storage deletion should still have happened
217
- (0, chai_1.expect)(sessionStore.deletedSessions).to.include(persistedSessionId);
218
- });
219
- });
220
- });
221
- //# sourceMappingURL=chat-service-deletion.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-service-deletion.spec.js","sourceRoot":"","sources":["../../src/common/chat-service-deletion.spec.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;;AAEhF,+BAA8B;AAC9B,4DAAyD;AACzD,iDAAiD;AACjD,6DAAiG;AACjG,6DAAwD;AACxD,+DAA0D;AAC1D,4CAAmD;AACnD,sCAAsC;AACtC,2EAA+J;AAC/J,uFAAmI;AACnI,+CAAkD;AAIlD,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC1C,IAAI,WAA4B,CAAC;IACjC,IAAI,YAAkC,CAAC;IACvC,IAAI,SAAoB,CAAC;IAEzB,MAAM,oBAAoB;QAA1B;YACW,oBAAe,GAAa,EAAE,CAAC;YAC/B,mBAAc,GAA6C,EAAE,CAAC;QAyBzE,CAAC;QAvBG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AC,CAAC"}
@@ -1,153 +0,0 @@
1
- import { AIVariableResolutionRequest, AIVariableService } from '@theia/ai-core';
2
- import { Emitter, ILogger, URI } from '@theia/core';
3
- import { Event } from '@theia/core/shared/vscode-languageserver-protocol';
4
- import { ChatAgentService } from './chat-agent-service';
5
- import { ChatAgent, ChatAgentLocation, ChatSessionContext } from './chat-agents';
6
- import { ChatContext, ChatModel, ChatRequest, ChatRequestModel, ChatResponseModel, MutableChatModel, MutableChatRequestModel } from './chat-model';
7
- import { ChatRequestParser } from './chat-request-parser';
8
- import { ChatSessionNamingService } from './chat-session-naming-service';
9
- import { ParsedChatRequest, ParsedChatRequestAgentPart } from './parsed-chat-request';
10
- import { ChatSessionIndex, ChatSessionStore } from './chat-session-store';
11
- import { ChatContentDeserializerRegistry } from './chat-content-deserializer';
12
- import { ChangeSetElementDeserializerRegistry } from './change-set-element-deserializer';
13
- import { SerializableChangeSetElement, SerializedChatModel } from './chat-model-serialization';
14
- export interface ChatRequestInvocation {
15
- /**
16
- * Promise which completes once the request preprocessing is complete.
17
- */
18
- requestCompleted: Promise<ChatRequestModel>;
19
- /**
20
- * Promise which completes once a response is expected to arrive.
21
- */
22
- responseCreated: Promise<ChatResponseModel>;
23
- /**
24
- * Promise which completes once the response is complete.
25
- */
26
- responseCompleted: Promise<ChatResponseModel>;
27
- }
28
- export interface ChatSession {
29
- id: string;
30
- title?: string;
31
- lastInteraction?: Date;
32
- model: ChatModel;
33
- isActive: boolean;
34
- pinnedAgent?: ChatAgent;
35
- }
36
- export interface ActiveSessionChangedEvent {
37
- type: 'activeChange';
38
- sessionId: string | undefined;
39
- focus?: boolean;
40
- }
41
- export declare function isActiveSessionChangedEvent(obj: unknown): obj is ActiveSessionChangedEvent;
42
- export interface SessionCreatedEvent {
43
- type: 'created';
44
- sessionId: string;
45
- }
46
- export declare function isSessionCreatedEvent(obj: unknown): obj is SessionCreatedEvent;
47
- export interface SessionDeletedEvent {
48
- type: 'deleted';
49
- sessionId: string;
50
- }
51
- export declare function isSessionDeletedEvent(obj: unknown): obj is SessionDeletedEvent;
52
- export interface SessionOptions {
53
- focus?: boolean;
54
- }
55
- /**
56
- * The default chat agent to invoke
57
- */
58
- export declare const DefaultChatAgentId: unique symbol;
59
- export interface DefaultChatAgentId {
60
- id: string;
61
- }
62
- /**
63
- * In case no fitting chat agent is available, this one will be used (if it is itself available)
64
- */
65
- export declare const FallbackChatAgentId: unique symbol;
66
- export interface FallbackChatAgentId {
67
- id: string;
68
- }
69
- export declare const PinChatAgent: unique symbol;
70
- export type PinChatAgent = boolean;
71
- export declare const ChatService: unique symbol;
72
- export declare const ChatServiceFactory: unique symbol;
73
- export interface ChatService {
74
- onSessionEvent: Event<ActiveSessionChangedEvent | SessionCreatedEvent | SessionDeletedEvent>;
75
- getSession(id: string): ChatSession | undefined;
76
- getSessions(): ChatSession[];
77
- createSession(location?: ChatAgentLocation, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession;
78
- deleteSession(sessionId: string): Promise<void>;
79
- getActiveSession(): ChatSession | undefined;
80
- setActiveSession(sessionId: string, options?: SessionOptions): void;
81
- sendRequest(sessionId: string, request: ChatRequest): Promise<ChatRequestInvocation | undefined>;
82
- deleteChangeSet(sessionId: string): void;
83
- deleteChangeSetElement(sessionId: string, uri: URI): void;
84
- cancelRequest(sessionId: string, requestId: string): Promise<void>;
85
- getAgent(parsedRequest: ParsedChatRequest, session: ChatSession): ChatAgent | undefined;
86
- /**
87
- * Get an existing session or restore from storage
88
- */
89
- getOrRestoreSession(sessionId: string): Promise<ChatSession | undefined>;
90
- /**
91
- * Get all persisted session metadata
92
- */
93
- getPersistedSessions(): Promise<ChatSessionIndex>;
94
- }
95
- interface ChatSessionInternal extends ChatSession {
96
- model: MutableChatModel;
97
- }
98
- export declare class ChatServiceImpl implements ChatService {
99
- protected readonly onSessionEventEmitter: Emitter<ActiveSessionChangedEvent | SessionCreatedEvent | SessionDeletedEvent>;
100
- onSessionEvent: import("@theia/core").Event<ActiveSessionChangedEvent | SessionCreatedEvent | SessionDeletedEvent>;
101
- protected chatAgentService: ChatAgentService;
102
- protected defaultChatAgentId: DefaultChatAgentId | undefined;
103
- protected fallbackChatAgentId: FallbackChatAgentId | undefined;
104
- protected chatSessionNamingService: ChatSessionNamingService | undefined;
105
- protected pinChatAgent: boolean | undefined;
106
- protected chatRequestParser: ChatRequestParser;
107
- protected variableService: AIVariableService;
108
- protected logger: ILogger;
109
- protected sessionStore: ChatSessionStore | undefined;
110
- protected deserializerRegistry: ChatContentDeserializerRegistry;
111
- protected changeSetElementDeserializerRegistry: ChangeSetElementDeserializerRegistry;
112
- protected _sessions: ChatSessionInternal[];
113
- getSessions(): ChatSessionInternal[];
114
- getSession(id: string): ChatSessionInternal | undefined;
115
- createSession(location?: ChatAgentLocation, options?: SessionOptions, pinnedAgent?: ChatAgent): ChatSession;
116
- deleteSession(sessionId: string): Promise<void>;
117
- getActiveSession(): ChatSession | undefined;
118
- setActiveSession(sessionId: string | undefined, options?: SessionOptions): void;
119
- sendRequest(sessionId: string, request: ChatRequest): Promise<ChatRequestInvocation | undefined>;
120
- protected cancelIncompleteRequests(session: ChatSessionInternal): void;
121
- protected updateSessionMetadata(session: ChatSessionInternal, request: MutableChatRequestModel): void;
122
- protected resolveChatContext(resolutionRequests: readonly AIVariableResolutionRequest[], context: ChatSessionContext): Promise<ChatContext>;
123
- cancelRequest(sessionId: string, requestId: string): Promise<void>;
124
- getAgent(parsedRequest: ParsedChatRequest, session: ChatSession): ChatAgent | undefined;
125
- /**
126
- * Determines if chat agent pinning is enabled.
127
- * Can be overridden by subclasses to provide different logic (e.g., using preferences).
128
- */
129
- protected isPinChatAgentEnabled(): boolean;
130
- /**
131
- * Check if an agent is pinned, and use it if no other agent is mentioned.
132
- */
133
- protected getPinnedAgent(parsedRequest: ParsedChatRequest, session: ChatSession, agent: ChatAgent | undefined): ChatAgent | undefined;
134
- protected initialAgentSelection(parsedRequest: ParsedChatRequest): ChatAgent | undefined;
135
- protected getMentionedAgent(parsedRequest: ParsedChatRequest): ParsedChatRequestAgentPart | undefined;
136
- deleteChangeSet(sessionId: string): void;
137
- deleteChangeSetElement(sessionId: string, uri: URI): void;
138
- protected saveSession(sessionId: string): void;
139
- /**
140
- * Set up auto-save for a session by listening to model changes.
141
- */
142
- protected setupAutoSaveForSession(session: ChatSessionInternal): void;
143
- getOrRestoreSession(sessionId: string): Promise<ChatSession | undefined>;
144
- getPersistedSessions(): Promise<ChatSessionIndex>;
145
- /**
146
- * Deserialize response content and restore changesets.
147
- * Called after basic chat model structure was created.
148
- */
149
- protected restoreSessionData(model: MutableChatModel, data: SerializedChatModel): Promise<void>;
150
- protected restoreChangeSetElements(requestModel: MutableChatRequestModel, elements: SerializableChangeSetElement[], sessionId: string): Promise<void>;
151
- }
152
- export {};
153
- //# sourceMappingURL=chat-service.d.ts.map