@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,304 +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_agents_1 = require("./chat-agents");
27
- const chat_content_deserializer_1 = require("./chat-content-deserializer");
28
- const change_set_element_deserializer_1 = require("./change-set-element-deserializer");
29
- describe('Chat Auto-Save Mechanism', () => {
30
- let chatService;
31
- let sessionStore;
32
- let container;
33
- class MockChatSessionStore {
34
- constructor() {
35
- this.saveCount = 0;
36
- this.savedSessions = [];
37
- this.lastSaveTimes = new Map();
38
- }
39
- async storeSessions(...sessions) {
40
- this.saveCount++;
41
- this.savedSessions = sessions;
42
- // Track save times per session
43
- sessions.forEach(session => {
44
- const id = 'model' in session ? session.model.id : session.id;
45
- this.lastSaveTimes.set(id, Date.now());
46
- });
47
- }
48
- async readSession(sessionId) {
49
- return undefined;
50
- }
51
- async deleteSession(sessionId) {
52
- // No-op for mock
53
- }
54
- async clearAllSessions() {
55
- this.savedSessions = [];
56
- this.saveCount = 0;
57
- this.lastSaveTimes.clear();
58
- }
59
- async getSessionIndex() {
60
- return {};
61
- }
62
- async setSessionTitle(sessionId, title) {
63
- // No-op for mock
64
- }
65
- reset() {
66
- this.saveCount = 0;
67
- this.savedSessions = [];
68
- this.lastSaveTimes.clear();
69
- }
70
- }
71
- class MockChatAgentService {
72
- constructor() {
73
- this.testAgent = {
74
- id: 'test-agent',
75
- name: 'Test Agent',
76
- invoke: () => Promise.resolve()
77
- };
78
- }
79
- getAgent() {
80
- return this.testAgent;
81
- }
82
- getAgents() {
83
- return [this.testAgent];
84
- }
85
- }
86
- class MockChatRequestParser {
87
- parseChatRequest() {
88
- return Promise.resolve({
89
- request: { text: 'test' },
90
- parts: [{
91
- kind: 'text',
92
- text: 'test',
93
- promptText: 'test',
94
- range: { start: 0, endExclusive: 4 }
95
- }],
96
- toolRequests: new Map(),
97
- variables: []
98
- });
99
- }
100
- }
101
- class MockAIVariableService {
102
- resolveVariables() {
103
- return Promise.resolve([]);
104
- }
105
- resolveVariable() {
106
- return Promise.resolve(undefined);
107
- }
108
- }
109
- class MockLogger {
110
- error() { }
111
- warn() { }
112
- info() { }
113
- debug() { }
114
- }
115
- beforeEach(() => {
116
- container = new inversify_1.Container();
117
- sessionStore = new MockChatSessionStore();
118
- container.bind(chat_session_store_1.ChatSessionStore).toConstantValue(sessionStore);
119
- container.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
120
- container.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
121
- container.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
122
- container.bind(core_1.ILogger).toConstantValue(new MockLogger());
123
- // Bind deserializer registries
124
- const contentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
125
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(contentRegistry);
126
- container.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(contentRegistry);
127
- container.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
128
- container.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
129
- chatService = container.get(chat_service_1.ChatServiceImpl);
130
- });
131
- describe('Auto-save on response completion', () => {
132
- it('should auto-save when response is complete', async () => {
133
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
134
- const initialSaveCount = sessionStore.saveCount;
135
- // Send a request
136
- const invocation = await chatService.sendRequest(session.id, { text: 'Test request' });
137
- const responseModel = await invocation.responseCreated;
138
- // Complete the response
139
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
- responseModel.complete();
141
- // Wait for auto-save to complete (debounce is 500ms + execution time)
142
- await new Promise(resolve => setTimeout(resolve, 700));
143
- // Verify session was auto-saved
144
- (0, chai_1.expect)(sessionStore.saveCount).to.be.greaterThan(initialSaveCount);
145
- });
146
- it('should auto-save when response has error', async () => {
147
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
148
- const initialSaveCount = sessionStore.saveCount;
149
- // Send a request that will error
150
- const invocation = await chatService.sendRequest(session.id, { text: 'Test request' });
151
- const responseModel = await invocation.responseCreated;
152
- // Simulate error
153
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
- responseModel.error(new Error('Test error'));
155
- // Wait for auto-save to complete (debounce is 500ms + execution time)
156
- await new Promise(resolve => setTimeout(resolve, 700));
157
- // Verify session was auto-saved even on error
158
- (0, chai_1.expect)(sessionStore.saveCount).to.be.greaterThan(initialSaveCount);
159
- });
160
- });
161
- describe('Auto-save on changeset updates', () => {
162
- it('should auto-save when changeset elements are updated', async () => {
163
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
164
- // Add a request so the session is not empty
165
- await chatService.sendRequest(session.id, { text: 'Test request' });
166
- sessionStore.reset();
167
- // Trigger changeset update event via model's internal emitter
168
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
169
- session.model._onDidChangeEmitter.fire({ kind: 'updateChangeSet', elements: [] });
170
- // Wait for auto-save to complete (debounce is 500ms + execution time)
171
- await new Promise(resolve => setTimeout(resolve, 700));
172
- // Verify session was auto-saved
173
- (0, chai_1.expect)(sessionStore.saveCount).to.be.greaterThan(0);
174
- });
175
- it('should not auto-save on non-changeset events', async () => {
176
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
177
- sessionStore.reset();
178
- // Trigger other kind of event (like 'addRequest')
179
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
180
- session.model._onDidChangeEmitter.fire({ kind: 'addRequest' });
181
- // Wait to ensure no save happens
182
- await new Promise(resolve => setTimeout(resolve, 10));
183
- // Verify no auto-save occurred
184
- (0, chai_1.expect)(sessionStore.saveCount).to.equal(0);
185
- });
186
- });
187
- describe('Auto-save for all sessions', () => {
188
- it('should save all non-empty sessions', async () => {
189
- const session1 = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
190
- const session2 = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
191
- sessionStore.reset();
192
- // Send requests to both sessions
193
- const invocation1 = await chatService.sendRequest(session1.id, { text: 'Request 1' });
194
- const invocation2 = await chatService.sendRequest(session2.id, { text: 'Request 2' });
195
- // Complete both responses
196
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
- (await invocation1.responseCreated).complete();
198
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
199
- (await invocation2.responseCreated).complete();
200
- // Wait for auto-save to complete (debounce is 500ms + execution time)
201
- await new Promise(resolve => setTimeout(resolve, 700));
202
- // Verify both sessions were saved (check lastSaveTimes since sessions are saved individually)
203
- (0, chai_1.expect)(sessionStore.saveCount).to.be.greaterThan(0);
204
- (0, chai_1.expect)(sessionStore.lastSaveTimes.has(session1.id)).to.be.true;
205
- (0, chai_1.expect)(sessionStore.lastSaveTimes.has(session2.id)).to.be.true;
206
- });
207
- it('should not save empty sessions', async () => {
208
- // Create session without any requests
209
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
210
- sessionStore.reset();
211
- // Manually trigger save
212
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
213
- await chatService.saveSession(session.id);
214
- // Verify empty session was not saved
215
- const savedSessionIds = sessionStore.savedSessions.map(s => 'model' in s ? s.model.id : s.id);
216
- (0, chai_1.expect)(savedSessionIds).to.not.include(session.id);
217
- });
218
- });
219
- describe('Auto-save without session store', () => {
220
- it('should handle auto-save gracefully when session store unavailable', async () => {
221
- // Create service without session store
222
- const containerWithoutStore = new inversify_1.Container();
223
- containerWithoutStore.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
224
- containerWithoutStore.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
225
- containerWithoutStore.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
226
- containerWithoutStore.bind(core_1.ILogger).toConstantValue(new MockLogger());
227
- // Bind deserializer registries
228
- const contentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
229
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(contentRegistry);
230
- containerWithoutStore.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(contentRegistry);
231
- containerWithoutStore.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
232
- containerWithoutStore.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
233
- const serviceWithoutStore = containerWithoutStore.get(chat_service_1.ChatServiceImpl);
234
- // Create session and send request
235
- const session = serviceWithoutStore.createSession(chat_agents_1.ChatAgentLocation.Panel);
236
- const invocation = await serviceWithoutStore.sendRequest(session.id, { text: 'Test' });
237
- // Complete response - should not throw even without session store
238
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
239
- (await invocation.responseCreated).complete();
240
- // Wait to ensure no errors
241
- await new Promise(resolve => setTimeout(resolve, 10));
242
- // No assertion needed - we're just verifying no exception is thrown
243
- });
244
- });
245
- describe('Auto-save setup for restored sessions', () => {
246
- it('should set up auto-save for restored sessions', async () => {
247
- // Create and save a session
248
- const session1 = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
249
- await chatService.sendRequest(session1.id, { text: 'Test' });
250
- const serialized = session1.model.toSerializable();
251
- // Create new service instance
252
- const newContainer = new inversify_1.Container();
253
- const newSessionStore = new MockChatSessionStore();
254
- newContainer.bind(chat_session_store_1.ChatSessionStore).toConstantValue(newSessionStore);
255
- newContainer.bind(chat_agent_service_1.ChatAgentService).toConstantValue(new MockChatAgentService());
256
- newContainer.bind(chat_request_parser_1.ChatRequestParser).toConstantValue(new MockChatRequestParser());
257
- newContainer.bind(ai_core_1.AIVariableService).toConstantValue(new MockAIVariableService());
258
- newContainer.bind(core_1.ILogger).toConstantValue(new MockLogger());
259
- // Bind deserializer registries
260
- const newContentRegistry = new chat_content_deserializer_1.ChatContentDeserializerRegistryImpl();
261
- new chat_content_deserializer_1.DefaultChatContentDeserializerContribution().registerDeserializers(newContentRegistry);
262
- newContainer.bind(chat_content_deserializer_1.ChatContentDeserializerRegistry).toConstantValue(newContentRegistry);
263
- newContainer.bind(change_set_element_deserializer_1.ChangeSetElementDeserializerRegistry).toConstantValue(new change_set_element_deserializer_1.ChangeSetElementDeserializerRegistryImpl());
264
- newContainer.bind(chat_service_1.ChatServiceImpl).toSelf().inSingletonScope();
265
- const newChatService = newContainer.get(chat_service_1.ChatServiceImpl);
266
- // Mock readSession to return the serialized data
267
- newSessionStore.readSession = async (id) => ({
268
- version: 1,
269
- model: serialized,
270
- pinnedAgentId: undefined,
271
- saveDate: Date.now()
272
- });
273
- // Restore the session
274
- const restoredSession = await newChatService.getOrRestoreSession(serialized.sessionId);
275
- (0, chai_1.expect)(restoredSession).to.not.be.undefined;
276
- newSessionStore.reset();
277
- // Trigger changeset update on restored session
278
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- restoredSession.model._onDidChangeEmitter.fire({ kind: 'updateChangeSet', elements: [] });
280
- // Wait for auto-save (debounce is 500ms + execution time)
281
- await new Promise(resolve => setTimeout(resolve, 700));
282
- // Verify auto-save was set up and triggered
283
- (0, chai_1.expect)(newSessionStore.saveCount).to.be.greaterThan(0);
284
- });
285
- });
286
- describe('Multiple auto-save triggers', () => {
287
- it('should handle multiple rapid auto-save triggers', async () => {
288
- const session = chatService.createSession(chat_agents_1.ChatAgentLocation.Panel);
289
- // Add a request so the session is not empty
290
- await chatService.sendRequest(session.id, { text: 'Test request' });
291
- sessionStore.reset();
292
- // Trigger multiple changeset updates rapidly
293
- for (let i = 0; i < 5; i++) {
294
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
295
- session.model._onDidChangeEmitter.fire({ kind: 'updateChangeSet', elements: [] });
296
- }
297
- // Wait for all saves to complete (debounce is 500ms + execution time)
298
- await new Promise(resolve => setTimeout(resolve, 700));
299
- // Verify saves were triggered (implementation batches them)
300
- (0, chai_1.expect)(sessionStore.saveCount).to.be.greaterThan(0);
301
- });
302
- });
303
- });
304
- //# sourceMappingURL=chat-auto-save.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-auto-save.spec.js","sourceRoot":"","sources":["../../src/common/chat-auto-save.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACx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;IACP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACzC,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,OAAO,GAAG,WAAW,CAAC,aAAa,CAAC,+BAAiB,CAAC,KAAK,CAAC,CAAC;YACnE,4CAA4C;YAC5C,MAAM,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;YACpE,YAAY,CAAC,KAAK,EAAE,CAAC;YAErB,6CAA6C;YAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzB,8DAA8D;gBAC7D,OAAO,CAAC,KAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/F,CAAC;YAED,sEAAsE;YACtE,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;YAEvD,4DAA4D;YAC5D,IAAA,aAAM,EAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,161 +0,0 @@
1
- import { ChatResponseContent } from './chat-model';
2
- import { SerializableChatResponseContentData } from './chat-model-serialization';
3
- import { ContributionProvider, ILogger, MaybePromise } from '@theia/core';
4
- export declare const ChatContentDeserializer: unique symbol;
5
- /**
6
- * A deserializer for a specific kind of chat response content.
7
- *
8
- * Deserializers are responsible for reconstructing `ChatResponseContent` instances
9
- * from their serialized data representations. Each deserializer handles a single
10
- * content type identified by its `kind` property.
11
- *
12
- * @template T The type of the data object that this deserializer can process.
13
- *
14
- * @example
15
- * ```typescript
16
- * const textDeserializer: ChatContentDeserializer<TextContentData> = {
17
- * kind: 'text',
18
- * deserialize: (data) => new TextChatResponseContentImpl(data.content)
19
- * };
20
- * ```
21
- */
22
- export interface ChatContentDeserializer<T = unknown> {
23
- /**
24
- * The unique identifier for the content type this deserializer handles.
25
- * This must match the `kind` property of the serialized content data.
26
- */
27
- readonly kind: string;
28
- /**
29
- * Deserializes the given data into a `ChatResponseContent` instance.
30
- *
31
- * @param data The serialized data to deserialize. The structure depends on the content kind.
32
- * @returns The deserialized content, or a Promise that resolves to the deserialized content.
33
- */
34
- deserialize(data: T): MaybePromise<ChatResponseContent>;
35
- }
36
- /**
37
- * Contribution point for registering chat content deserializers.
38
- *
39
- * Implement this interface to contribute custom deserializers for application-specific
40
- * or extension-specific chat response content types. Multiple contributions can be
41
- * registered, and all will be collected via the contribution provider pattern.
42
- *
43
- * @example
44
- * ```typescript
45
- * @injectable()
46
- * export class MyDeserializerContribution implements ChatContentDeserializerContribution {
47
- * registerDeserializers(registry: ChatContentDeserializerRegistry): void {
48
- * registry.register({
49
- * kind: 'customContent',
50
- * deserialize: (data: CustomContentData) =>
51
- * new CustomContentImpl(data.title, data.items)
52
- * });
53
- * }
54
- * }
55
- *
56
- * // In your module:
57
- * bind(ChatContentDeserializerContribution).to(MyDeserializerContribution).inSingletonScope();
58
- * ```
59
- *
60
- * @see {@link ChatContentDeserializerRegistry} for the registry that collects deserializers
61
- * @see {@link DefaultChatContentDeserializerContribution} for built-in content type deserializers
62
- */
63
- export interface ChatContentDeserializerContribution {
64
- /**
65
- * Registers one or more deserializers with the provided registry.
66
- *
67
- * This method is called during the registry's initialization phase (at `@postConstruct()` time).
68
- *
69
- * @param registry The registry to register deserializers with
70
- */
71
- registerDeserializers(registry: ChatContentDeserializerRegistry): void;
72
- }
73
- export declare const ChatContentDeserializerContribution: unique symbol;
74
- /**
75
- * Registry for chat content deserializers.
76
- *
77
- * This registry maintains a collection of deserializers for different content types
78
- * and provides methods to register new deserializers and deserialize content data.
79
- *
80
- * @example
81
- * ```typescript
82
- * // Usage in a service:
83
- * @inject(ChatContentDeserializerRegistry)
84
- * protected deserializerRegistry: ChatContentDeserializerRegistry;
85
- *
86
- * async restoreContent(): Promise<void> {
87
- * const restoredContent = this.deserializerRegistry.deserialize(serializedData);
88
- * }
89
- * ```
90
- *
91
- * @see {@link ChatContentDeserializerContribution} for how to contribute deserializers
92
- * @see {@link ChatContentDeserializerRegistryImpl} for the default implementation
93
- */
94
- export interface ChatContentDeserializerRegistry {
95
- /**
96
- * Registers a deserializer for a specific content kind.
97
- *
98
- * If a deserializer for the same kind is already registered, it will be replaced.
99
- *
100
- * @param deserializer The deserializer to register
101
- */
102
- register(deserializer: ChatContentDeserializer<unknown>): void;
103
- /**
104
- * Deserializes the given serialized content data into a `ChatResponseContent` instance.
105
- *
106
- * The registry looks up the appropriate deserializer based on the `kind` property
107
- * of the serialized data and delegates to that deserializer's `deserialize` method.
108
- *
109
- * If no deserializer is found for the content kind, an `UnknownChatResponseContentImpl`
110
- * instance is returned with the original data and fallback message preserved.
111
- * A warning is also logged with the missing kind and available kinds.
112
- *
113
- * @param serialized The serialized content data to deserialize
114
- * @returns The deserialized content, or a Promise that resolves to the deserialized content
115
- */
116
- deserialize(serialized: SerializableChatResponseContentData): MaybePromise<ChatResponseContent>;
117
- }
118
- export declare const ChatContentDeserializerRegistry: unique symbol;
119
- /**
120
- * Default implementation of the chat content deserializer registry.
121
- *
122
- * This registry collects deserializers from all bound `ChatContentDeserializerContribution`
123
- * instances during its post-construction initialization phase. Deserializers are stored
124
- * in a map keyed by their content kind.
125
- *
126
- * The registry handles unknown content types gracefully by returning an
127
- * `UnknownChatResponseContentImpl` instance when no deserializer is found,
128
- * ensuring that chat sessions can still be loaded even if some content types
129
- * are no longer supported or available.
130
- *
131
- * @see {@link ChatContentDeserializerRegistry} for the interface definition
132
- */
133
- export declare class ChatContentDeserializerRegistryImpl implements ChatContentDeserializerRegistry {
134
- /**
135
- * Map of registered deserializers, keyed by content kind.
136
- */
137
- protected deserializers: Map<string, ChatContentDeserializer<unknown>>;
138
- protected readonly deserializerContributions: ContributionProvider<ChatContentDeserializerContribution>;
139
- protected readonly logger: ILogger;
140
- /**
141
- * Initializes the registry by collecting deserializers from all contributions.
142
- * This method is automatically called after construction due to the `@postConstruct` decorator.
143
- */
144
- protected initDeserializers(): void;
145
- register(deserializer: ChatContentDeserializer): void;
146
- deserialize(serialized: SerializableChatResponseContentData): MaybePromise<ChatResponseContent>;
147
- }
148
- /**
149
- * Default implementation of the chat content deserializer contribution.
150
- *
151
- * This contribution registers deserializers for all built-in content types supported
152
- * by Theia AI.
153
- *
154
- * Note that some content types have limitations when deserialized from persistence.
155
- *
156
- * @see {@link ChatContentDeserializerContribution} for the contribution interface
157
- */
158
- export declare class DefaultChatContentDeserializerContribution implements ChatContentDeserializerContribution {
159
- registerDeserializers(registry: ChatContentDeserializerRegistry): void;
160
- }
161
- //# sourceMappingURL=chat-content-deserializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-content-deserializer.d.ts","sourceRoot":"","sources":["../../src/common/chat-content-deserializer.ts"],"names":[],"mappings":"AAiBA,OAAO,EACH,mBAAmB,EAwBtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1E,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,OAAO;IAChD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,mCAAmC;IAChD;;;;;;OAMG;IACH,qBAAqB,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAC1E;AACD,eAAO,MAAM,mCAAmC,eAAgD,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,+BAA+B;IAC5C;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAE/D;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,UAAU,EAAE,mCAAmC,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;CACnG;AACD,eAAO,MAAM,+BAA+B,eAA4C,CAAC;AAEzF;;;;;;;;;;;;;GAaG;AACH,qBACa,mCAAoC,YAAW,+BAA+B;IACvF;;OAEG;IACH,SAAS,CAAC,aAAa,gDAA8C;IAGrE,SAAS,CAAC,QAAQ,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,mCAAmC,CAAC,CAAC;IAGxG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC;;;OAGG;IAEH,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAMnC,QAAQ,CAAC,YAAY,EAAE,uBAAuB,GAAG,IAAI;IAIrD,WAAW,CAAC,UAAU,EAAE,mCAAmC,GAAG,YAAY,CAAC,mBAAmB,CAAC;CAYlG;AAED;;;;;;;;;GASG;AACH,qBACa,0CAA2C,YAAW,mCAAmC;IAClG,qBAAqB,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI;CA2FzE"}
@@ -1,166 +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
- exports.DefaultChatContentDeserializerContribution = exports.ChatContentDeserializerRegistryImpl = exports.ChatContentDeserializerRegistry = exports.ChatContentDeserializerContribution = exports.ChatContentDeserializer = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const chat_model_1 = require("./chat-model");
22
- const core_1 = require("@theia/core");
23
- exports.ChatContentDeserializer = Symbol('ChatContentDeserializer');
24
- exports.ChatContentDeserializerContribution = Symbol('ChatContentDeserializerContribution');
25
- exports.ChatContentDeserializerRegistry = Symbol('ChatContentDeserializerRegistry');
26
- /**
27
- * Default implementation of the chat content deserializer registry.
28
- *
29
- * This registry collects deserializers from all bound `ChatContentDeserializerContribution`
30
- * instances during its post-construction initialization phase. Deserializers are stored
31
- * in a map keyed by their content kind.
32
- *
33
- * The registry handles unknown content types gracefully by returning an
34
- * `UnknownChatResponseContentImpl` instance when no deserializer is found,
35
- * ensuring that chat sessions can still be loaded even if some content types
36
- * are no longer supported or available.
37
- *
38
- * @see {@link ChatContentDeserializerRegistry} for the interface definition
39
- */
40
- let ChatContentDeserializerRegistryImpl = class ChatContentDeserializerRegistryImpl {
41
- constructor() {
42
- /**
43
- * Map of registered deserializers, keyed by content kind.
44
- */
45
- this.deserializers = new Map();
46
- }
47
- /**
48
- * Initializes the registry by collecting deserializers from all contributions.
49
- * This method is automatically called after construction due to the `@postConstruct` decorator.
50
- */
51
- initDeserializers() {
52
- for (const contribution of this.deserializerContributions.getContributions()) {
53
- contribution.registerDeserializers(this);
54
- }
55
- }
56
- register(deserializer) {
57
- this.deserializers.set(deserializer.kind, deserializer);
58
- }
59
- deserialize(serialized) {
60
- const deserializer = this.deserializers.get(serialized.kind);
61
- if (!deserializer) {
62
- this.logger.warn('No deserializer found for kind:', serialized.kind, 'Available kinds:', Array.from(this.deserializers.keys()));
63
- return new chat_model_1.UnknownChatResponseContentImpl(serialized.kind, serialized.fallbackMessage, serialized.data);
64
- }
65
- return deserializer.deserialize(serialized.data);
66
- }
67
- };
68
- exports.ChatContentDeserializerRegistryImpl = ChatContentDeserializerRegistryImpl;
69
- tslib_1.__decorate([
70
- (0, inversify_1.inject)(core_1.ContributionProvider),
71
- (0, inversify_1.named)(exports.ChatContentDeserializerContribution),
72
- tslib_1.__metadata("design:type", Object)
73
- ], ChatContentDeserializerRegistryImpl.prototype, "deserializerContributions", void 0);
74
- tslib_1.__decorate([
75
- (0, inversify_1.inject)(core_1.ILogger),
76
- (0, inversify_1.named)('ChatContentDeserializerRegistry'),
77
- tslib_1.__metadata("design:type", Object)
78
- ], ChatContentDeserializerRegistryImpl.prototype, "logger", void 0);
79
- tslib_1.__decorate([
80
- (0, inversify_1.postConstruct)(),
81
- tslib_1.__metadata("design:type", Function),
82
- tslib_1.__metadata("design:paramtypes", []),
83
- tslib_1.__metadata("design:returntype", void 0)
84
- ], ChatContentDeserializerRegistryImpl.prototype, "initDeserializers", null);
85
- exports.ChatContentDeserializerRegistryImpl = ChatContentDeserializerRegistryImpl = tslib_1.__decorate([
86
- (0, inversify_1.injectable)()
87
- ], ChatContentDeserializerRegistryImpl);
88
- /**
89
- * Default implementation of the chat content deserializer contribution.
90
- *
91
- * This contribution registers deserializers for all built-in content types supported
92
- * by Theia AI.
93
- *
94
- * Note that some content types have limitations when deserialized from persistence.
95
- *
96
- * @see {@link ChatContentDeserializerContribution} for the contribution interface
97
- */
98
- let DefaultChatContentDeserializerContribution = class DefaultChatContentDeserializerContribution {
99
- registerDeserializers(registry) {
100
- registry.register({
101
- kind: 'text',
102
- deserialize: (data) => new chat_model_1.TextChatResponseContentImpl(data.content)
103
- });
104
- registry.register({
105
- kind: 'thinking',
106
- deserialize: (data) => new chat_model_1.ThinkingChatResponseContentImpl(data.content, data.signature)
107
- });
108
- registry.register({
109
- kind: 'markdownContent',
110
- deserialize: (data) => new chat_model_1.MarkdownChatResponseContentImpl(data.content)
111
- });
112
- registry.register({
113
- kind: 'informational',
114
- deserialize: (data) => new chat_model_1.InformationalChatResponseContentImpl(data.content)
115
- });
116
- registry.register({
117
- kind: 'code',
118
- deserialize: (data) => new chat_model_1.CodeChatResponseContentImpl(data.code, data.language, data.location)
119
- });
120
- registry.register({
121
- kind: 'toolCall',
122
- deserialize: (data) => new chat_model_1.ToolCallChatResponseContentImpl(data.id, data.name, data.arguments, data.finished, data.result)
123
- });
124
- registry.register({
125
- kind: 'command',
126
- deserialize: (data) => {
127
- const command = data.commandId ? { id: data.commandId } : undefined;
128
- // Cannot restore customCallback since it contains a function
129
- return new chat_model_1.CommandChatResponseContentImpl(command, undefined, data.arguments);
130
- }
131
- });
132
- registry.register({
133
- kind: 'horizontal',
134
- deserialize: async (data) => {
135
- const childContentPromises = data.content.map(child => registry.deserialize(child));
136
- const childContent = Promise.all(childContentPromises);
137
- return new chat_model_1.HorizontalLayoutChatResponseContentImpl(await childContent);
138
- }
139
- });
140
- registry.register({
141
- kind: 'progress',
142
- deserialize: (data) => new chat_model_1.ProgressChatResponseContentImpl(data.message)
143
- });
144
- registry.register({
145
- kind: 'error',
146
- deserialize: (data) => {
147
- const error = new Error(data.message);
148
- if (data.stack) {
149
- error.stack = data.stack;
150
- }
151
- return new chat_model_1.ErrorChatResponseContentImpl(error);
152
- }
153
- });
154
- registry.register({
155
- kind: 'question',
156
- deserialize: (data) =>
157
- // Restore in read-only mode (no handler/request)
158
- new chat_model_1.QuestionResponseContentImpl(data.question, data.options, undefined, undefined, data.selectedOption)
159
- });
160
- }
161
- };
162
- exports.DefaultChatContentDeserializerContribution = DefaultChatContentDeserializerContribution;
163
- exports.DefaultChatContentDeserializerContribution = DefaultChatContentDeserializerContribution = tslib_1.__decorate([
164
- (0, inversify_1.injectable)()
165
- ], DefaultChatContentDeserializerContribution);
166
- //# sourceMappingURL=chat-content-deserializer.js.map