@theia/ai-chat 1.67.0-next.13 → 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 (254) hide show
  1. package/README.md +1 -0
  2. package/package.json +9 -9
  3. package/lib/browser/agent-delegation-tool.d.ts +0 -25
  4. package/lib/browser/agent-delegation-tool.d.ts.map +0 -1
  5. package/lib/browser/agent-delegation-tool.js +0 -196
  6. package/lib/browser/agent-delegation-tool.js.map +0 -1
  7. package/lib/browser/ai-chat-frontend-contribution.d.ts +0 -11
  8. package/lib/browser/ai-chat-frontend-contribution.d.ts.map +0 -1
  9. package/lib/browser/ai-chat-frontend-contribution.js +0 -56
  10. package/lib/browser/ai-chat-frontend-contribution.js.map +0 -1
  11. package/lib/browser/ai-chat-frontend-module.d.ts +0 -4
  12. package/lib/browser/ai-chat-frontend-module.d.ts.map +0 -1
  13. package/lib/browser/ai-chat-frontend-module.js +0 -143
  14. package/lib/browser/ai-chat-frontend-module.js.map +0 -1
  15. package/lib/browser/change-set-decorator-service.d.ts +0 -24
  16. package/lib/browser/change-set-decorator-service.d.ts.map +0 -1
  17. package/lib/browser/change-set-decorator-service.js +0 -66
  18. package/lib/browser/change-set-decorator-service.js.map +0 -1
  19. package/lib/browser/change-set-file-element-deserializer.d.ts +0 -7
  20. package/lib/browser/change-set-file-element-deserializer.d.ts.map +0 -1
  21. package/lib/browser/change-set-file-element-deserializer.js +0 -61
  22. package/lib/browser/change-set-file-element-deserializer.js.map +0 -1
  23. package/lib/browser/change-set-file-element.d.ts +0 -122
  24. package/lib/browser/change-set-file-element.d.ts.map +0 -1
  25. package/lib/browser/change-set-file-element.js +0 -435
  26. package/lib/browser/change-set-file-element.js.map +0 -1
  27. package/lib/browser/change-set-file-resource.d.ts +0 -4
  28. package/lib/browser/change-set-file-resource.d.ts.map +0 -1
  29. package/lib/browser/change-set-file-resource.js +0 -24
  30. package/lib/browser/change-set-file-resource.js.map +0 -1
  31. package/lib/browser/change-set-file-service.d.ts +0 -32
  32. package/lib/browser/change-set-file-service.d.ts.map +0 -1
  33. package/lib/browser/change-set-file-service.js +0 -161
  34. package/lib/browser/change-set-file-service.js.map +0 -1
  35. package/lib/browser/change-set-variable.d.ts +0 -11
  36. package/lib/browser/change-set-variable.d.ts.map +0 -1
  37. package/lib/browser/change-set-variable.js +0 -64
  38. package/lib/browser/change-set-variable.js.map +0 -1
  39. package/lib/browser/chat-session-store-impl.d.ts +0 -36
  40. package/lib/browser/chat-session-store-impl.d.ts.map +0 -1
  41. package/lib/browser/chat-session-store-impl.js +0 -287
  42. package/lib/browser/chat-session-store-impl.js.map +0 -1
  43. package/lib/browser/chat-tool-preference-bindings.d.ts +0 -34
  44. package/lib/browser/chat-tool-preference-bindings.d.ts.map +0 -1
  45. package/lib/browser/chat-tool-preference-bindings.js +0 -122
  46. package/lib/browser/chat-tool-preference-bindings.js.map +0 -1
  47. package/lib/browser/chat-tool-request-service.d.ts +0 -21
  48. package/lib/browser/chat-tool-request-service.d.ts.map +0 -1
  49. package/lib/browser/chat-tool-request-service.js +0 -90
  50. package/lib/browser/chat-tool-request-service.js.map +0 -1
  51. package/lib/browser/context-file-validation-service.d.ts +0 -15
  52. package/lib/browser/context-file-validation-service.d.ts.map +0 -1
  53. package/lib/browser/context-file-validation-service.js +0 -26
  54. package/lib/browser/context-file-validation-service.js.map +0 -1
  55. package/lib/browser/context-file-variable-label-provider.d.ts +0 -14
  56. package/lib/browser/context-file-variable-label-provider.d.ts.map +0 -1
  57. package/lib/browser/context-file-variable-label-provider.js +0 -63
  58. package/lib/browser/context-file-variable-label-provider.js.map +0 -1
  59. package/lib/browser/context-variable-label-provider.d.ts +0 -9
  60. package/lib/browser/context-variable-label-provider.d.ts.map +0 -1
  61. package/lib/browser/context-variable-label-provider.js +0 -55
  62. package/lib/browser/context-variable-label-provider.js.map +0 -1
  63. package/lib/browser/custom-agent-factory.d.ts +0 -4
  64. package/lib/browser/custom-agent-factory.d.ts.map +0 -1
  65. package/lib/browser/custom-agent-factory.js +0 -20
  66. package/lib/browser/custom-agent-factory.js.map +0 -1
  67. package/lib/browser/custom-agent-frontend-application-contribution.d.ts +0 -13
  68. package/lib/browser/custom-agent-frontend-application-contribution.d.ts.map +0 -1
  69. package/lib/browser/custom-agent-frontend-application-contribution.js +0 -83
  70. package/lib/browser/custom-agent-frontend-application-contribution.js.map +0 -1
  71. package/lib/browser/delegation-response-content.d.ts +0 -20
  72. package/lib/browser/delegation-response-content.d.ts.map +0 -1
  73. package/lib/browser/delegation-response-content.js +0 -47
  74. package/lib/browser/delegation-response-content.js.map +0 -1
  75. package/lib/browser/file-chat-variable-contribution.d.ts +0 -32
  76. package/lib/browser/file-chat-variable-contribution.d.ts.map +0 -1
  77. package/lib/browser/file-chat-variable-contribution.js +0 -241
  78. package/lib/browser/file-chat-variable-contribution.js.map +0 -1
  79. package/lib/browser/frontend-chat-service.d.ts +0 -15
  80. package/lib/browser/frontend-chat-service.d.ts.map +0 -1
  81. package/lib/browser/frontend-chat-service.js +0 -72
  82. package/lib/browser/frontend-chat-service.js.map +0 -1
  83. package/lib/browser/image-context-variable-contribution.d.ts +0 -27
  84. package/lib/browser/image-context-variable-contribution.d.ts.map +0 -1
  85. package/lib/browser/image-context-variable-contribution.js +0 -149
  86. package/lib/browser/image-context-variable-contribution.js.map +0 -1
  87. package/lib/browser/task-context-service.d.ts +0 -46
  88. package/lib/browser/task-context-service.d.ts.map +0 -1
  89. package/lib/browser/task-context-service.js +0 -256
  90. package/lib/browser/task-context-service.js.map +0 -1
  91. package/lib/browser/task-context-storage-service.d.ts +0 -19
  92. package/lib/browser/task-context-storage-service.d.ts.map +0 -1
  93. package/lib/browser/task-context-storage-service.js +0 -80
  94. package/lib/browser/task-context-storage-service.js.map +0 -1
  95. package/lib/browser/task-context-variable-contribution.d.ts +0 -20
  96. package/lib/browser/task-context-variable-contribution.d.ts.map +0 -1
  97. package/lib/browser/task-context-variable-contribution.js +0 -101
  98. package/lib/browser/task-context-variable-contribution.js.map +0 -1
  99. package/lib/browser/task-context-variable-label-provider.d.ts +0 -21
  100. package/lib/browser/task-context-variable-label-provider.d.ts.map +0 -1
  101. package/lib/browser/task-context-variable-label-provider.js +0 -83
  102. package/lib/browser/task-context-variable-label-provider.js.map +0 -1
  103. package/lib/browser/task-context-variable.d.ts +0 -3
  104. package/lib/browser/task-context-variable.d.ts.map +0 -1
  105. package/lib/browser/task-context-variable.js +0 -33
  106. package/lib/browser/task-context-variable.js.map +0 -1
  107. package/lib/common/ai-chat-preferences.d.ts +0 -5
  108. package/lib/common/ai-chat-preferences.d.ts.map +0 -1
  109. package/lib/common/ai-chat-preferences.js +0 -40
  110. package/lib/common/ai-chat-preferences.js.map +0 -1
  111. package/lib/common/change-set-element-deserializer.d.ts +0 -30
  112. package/lib/common/change-set-element-deserializer.d.ts.map +0 -1
  113. package/lib/common/change-set-element-deserializer.js +0 -81
  114. package/lib/common/change-set-element-deserializer.js.map +0 -1
  115. package/lib/common/change-set.d.ts +0 -85
  116. package/lib/common/change-set.d.ts.map +0 -1
  117. package/lib/common/change-set.js +0 -133
  118. package/lib/common/change-set.js.map +0 -1
  119. package/lib/common/chat-agent-service.d.ts +0 -46
  120. package/lib/common/chat-agent-service.d.ts.map +0 -1
  121. package/lib/common/chat-agent-service.js +0 -79
  122. package/lib/common/chat-agent-service.js.map +0 -1
  123. package/lib/common/chat-agents-variable-contribution.d.ts +0 -17
  124. package/lib/common/chat-agents-variable-contribution.d.ts.map +0 -1
  125. package/lib/common/chat-agents-variable-contribution.js +0 -67
  126. package/lib/common/chat-agents-variable-contribution.js.map +0 -1
  127. package/lib/common/chat-agents.d.ts +0 -138
  128. package/lib/common/chat-agents.d.ts.map +0 -1
  129. package/lib/common/chat-agents.js +0 -428
  130. package/lib/common/chat-agents.js.map +0 -1
  131. package/lib/common/chat-auto-save.spec.d.ts +0 -2
  132. package/lib/common/chat-auto-save.spec.d.ts.map +0 -1
  133. package/lib/common/chat-auto-save.spec.js +0 -304
  134. package/lib/common/chat-auto-save.spec.js.map +0 -1
  135. package/lib/common/chat-content-deserializer.d.ts +0 -161
  136. package/lib/common/chat-content-deserializer.d.ts.map +0 -1
  137. package/lib/common/chat-content-deserializer.js +0 -166
  138. package/lib/common/chat-content-deserializer.js.map +0 -1
  139. package/lib/common/chat-content-deserializer.spec.d.ts +0 -2
  140. package/lib/common/chat-content-deserializer.spec.d.ts.map +0 -1
  141. package/lib/common/chat-content-deserializer.spec.js +0 -307
  142. package/lib/common/chat-content-deserializer.spec.js.map +0 -1
  143. package/lib/common/chat-model-serialization.d.ts +0 -110
  144. package/lib/common/chat-model-serialization.d.ts.map +0 -1
  145. package/lib/common/chat-model-serialization.js +0 -20
  146. package/lib/common/chat-model-serialization.js.map +0 -1
  147. package/lib/common/chat-model-serialization.spec.d.ts +0 -2
  148. package/lib/common/chat-model-serialization.spec.d.ts.map +0 -1
  149. package/lib/common/chat-model-serialization.spec.js +0 -278
  150. package/lib/common/chat-model-serialization.spec.js.map +0 -1
  151. package/lib/common/chat-model-util.d.ts +0 -7
  152. package/lib/common/chat-model-util.d.ts.map +0 -1
  153. package/lib/common/chat-model-util.js +0 -50
  154. package/lib/common/chat-model-util.js.map +0 -1
  155. package/lib/common/chat-model.d.ts +0 -923
  156. package/lib/common/chat-model.d.ts.map +0 -1
  157. package/lib/common/chat-model.js +0 -1791
  158. package/lib/common/chat-model.js.map +0 -1
  159. package/lib/common/chat-request-parser.d.ts +0 -38
  160. package/lib/common/chat-request-parser.d.ts.map +0 -1
  161. package/lib/common/chat-request-parser.js +0 -230
  162. package/lib/common/chat-request-parser.js.map +0 -1
  163. package/lib/common/chat-request-parser.spec.d.ts +0 -2
  164. package/lib/common/chat-request-parser.spec.d.ts.map +0 -1
  165. package/lib/common/chat-request-parser.spec.js +0 -235
  166. package/lib/common/chat-request-parser.spec.js.map +0 -1
  167. package/lib/common/chat-service-deletion.spec.d.ts +0 -2
  168. package/lib/common/chat-service-deletion.spec.d.ts.map +0 -1
  169. package/lib/common/chat-service-deletion.spec.js +0 -221
  170. package/lib/common/chat-service-deletion.spec.js.map +0 -1
  171. package/lib/common/chat-service.d.ts +0 -153
  172. package/lib/common/chat-service.d.ts.map +0 -1
  173. package/lib/common/chat-service.js +0 -474
  174. package/lib/common/chat-service.js.map +0 -1
  175. package/lib/common/chat-session-naming-prompt-template.d.ts +0 -3
  176. package/lib/common/chat-session-naming-prompt-template.d.ts.map +0 -1
  177. package/lib/common/chat-session-naming-prompt-template.js +0 -31
  178. package/lib/common/chat-session-naming-prompt-template.js.map +0 -1
  179. package/lib/common/chat-session-naming-service.d.ts +0 -26
  180. package/lib/common/chat-session-naming-service.d.ts.map +0 -1
  181. package/lib/common/chat-session-naming-service.js +0 -119
  182. package/lib/common/chat-session-naming-service.js.map +0 -1
  183. package/lib/common/chat-session-store.d.ts +0 -43
  184. package/lib/common/chat-session-store.d.ts.map +0 -1
  185. package/lib/common/chat-session-store.js +0 -20
  186. package/lib/common/chat-session-store.js.map +0 -1
  187. package/lib/common/chat-session-summary-agent-prompt.d.ts +0 -8
  188. package/lib/common/chat-session-summary-agent-prompt.d.ts.map +0 -1
  189. package/lib/common/chat-session-summary-agent-prompt.js +0 -33
  190. package/lib/common/chat-session-summary-agent-prompt.js.map +0 -1
  191. package/lib/common/chat-session-summary-agent.d.ts +0 -16
  192. package/lib/common/chat-session-summary-agent.d.ts.map +0 -1
  193. package/lib/common/chat-session-summary-agent.js +0 -48
  194. package/lib/common/chat-session-summary-agent.js.map +0 -1
  195. package/lib/common/chat-string-utils.d.ts +0 -3
  196. package/lib/common/chat-string-utils.d.ts.map +0 -1
  197. package/lib/common/chat-string-utils.js +0 -27
  198. package/lib/common/chat-string-utils.js.map +0 -1
  199. package/lib/common/chat-tool-preferences.d.ts +0 -23
  200. package/lib/common/chat-tool-preferences.d.ts.map +0 -1
  201. package/lib/common/chat-tool-preferences.js +0 -68
  202. package/lib/common/chat-tool-preferences.js.map +0 -1
  203. package/lib/common/chat-tool-request-service.d.ts +0 -18
  204. package/lib/common/chat-tool-request-service.d.ts.map +0 -1
  205. package/lib/common/chat-tool-request-service.js +0 -52
  206. package/lib/common/chat-tool-request-service.js.map +0 -1
  207. package/lib/common/context-details-variable.d.ts +0 -9
  208. package/lib/common/context-details-variable.d.ts.map +0 -1
  209. package/lib/common/context-details-variable.js +0 -57
  210. package/lib/common/context-details-variable.js.map +0 -1
  211. package/lib/common/context-summary-variable.d.ts +0 -9
  212. package/lib/common/context-summary-variable.d.ts.map +0 -1
  213. package/lib/common/context-summary-variable.js +0 -57
  214. package/lib/common/context-summary-variable.js.map +0 -1
  215. package/lib/common/context-variables.d.ts +0 -4
  216. package/lib/common/context-variables.d.ts.map +0 -1
  217. package/lib/common/context-variables.js +0 -22
  218. package/lib/common/context-variables.js.map +0 -1
  219. package/lib/common/custom-chat-agent.d.ts +0 -10
  220. package/lib/common/custom-chat-agent.d.ts.map +0 -1
  221. package/lib/common/custom-chat-agent.js +0 -40
  222. package/lib/common/custom-chat-agent.js.map +0 -1
  223. package/lib/common/image-context-variable.d.ts +0 -29
  224. package/lib/common/image-context-variable.d.ts.map +0 -1
  225. package/lib/common/image-context-variable.js +0 -114
  226. package/lib/common/image-context-variable.js.map +0 -1
  227. package/lib/common/index.d.ts +0 -13
  228. package/lib/common/index.d.ts.map +0 -1
  229. package/lib/common/index.js +0 -31
  230. package/lib/common/index.js.map +0 -1
  231. package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts +0 -2
  232. package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts.map +0 -1
  233. package/lib/common/parse-contents-with-incomplete-parts.spec.js +0 -103
  234. package/lib/common/parse-contents-with-incomplete-parts.spec.js.map +0 -1
  235. package/lib/common/parse-contents.d.ts +0 -12
  236. package/lib/common/parse-contents.d.ts.map +0 -1
  237. package/lib/common/parse-contents.js +0 -107
  238. package/lib/common/parse-contents.js.map +0 -1
  239. package/lib/common/parse-contents.spec.d.ts +0 -10
  240. package/lib/common/parse-contents.spec.d.ts.map +0 -1
  241. package/lib/common/parse-contents.spec.js +0 -146
  242. package/lib/common/parse-contents.spec.js.map +0 -1
  243. package/lib/common/parsed-chat-request.d.ts +0 -66
  244. package/lib/common/parsed-chat-request.d.ts.map +0 -1
  245. package/lib/common/parsed-chat-request.js +0 -83
  246. package/lib/common/parsed-chat-request.js.map +0 -1
  247. package/lib/common/response-content-matcher.d.ts +0 -69
  248. package/lib/common/response-content-matcher.d.ts.map +0 -1
  249. package/lib/common/response-content-matcher.js +0 -97
  250. package/lib/common/response-content-matcher.js.map +0 -1
  251. package/lib/node/ai-chat-backend-module.d.ts +0 -4
  252. package/lib/node/ai-chat-backend-module.d.ts.map +0 -1
  253. package/lib/node/ai-chat-backend-module.js +0 -26
  254. package/lib/node/ai-chat-backend-module.js.map +0 -1
@@ -1,287 +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.ChatSessionStoreImpl = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
22
- const browser_1 = require("@theia/workspace/lib/browser");
23
- const env_variables_1 = require("@theia/core/lib/common/env-variables");
24
- const browser_2 = require("@theia/core/lib/browser");
25
- const core_1 = require("@theia/core");
26
- const buffer_1 = require("@theia/core/lib/common/buffer");
27
- const logger_1 = require("@theia/core/lib/common/logger");
28
- const chat_model_serialization_1 = require("../common/chat-model-serialization");
29
- const MAX_SESSIONS = 25;
30
- const INDEX_FILE = 'index.json';
31
- let ChatSessionStoreImpl = class ChatSessionStoreImpl {
32
- constructor() {
33
- this.storePromise = Promise.resolve();
34
- }
35
- async storeSessions(...sessions) {
36
- this.storePromise = this.storePromise.then(async () => {
37
- const root = await this.getStorageRoot();
38
- this.logger.debug('Starting to store sessions', { totalSessions: sessions.length, storageRoot: root.toString() });
39
- // Normalize to SessionWithTitle and filter empty sessions
40
- const nonEmptySessions = sessions
41
- .map(s => this.isChatModelWithMetadata(s) ? { ...s, saveDate: Date.now() } : { model: s, saveDate: Date.now() })
42
- .filter(s => !s.model.isEmpty());
43
- this.logger.debug('Filtered empty sessions', { nonEmptySessions: nonEmptySessions.length });
44
- // Write each session as JSON file
45
- for (const session of nonEmptySessions) {
46
- const sessionFile = root.resolve(`${session.model.id}.json`);
47
- const modelData = session.model.toSerializable();
48
- // Wrap model data with persistence metadata
49
- const data = {
50
- version: chat_model_serialization_1.CHAT_DATA_VERSION,
51
- title: session.title,
52
- pinnedAgentId: session.pinnedAgentId,
53
- saveDate: session.saveDate,
54
- model: modelData
55
- };
56
- this.logger.debug('Writing session to file', {
57
- sessionId: session.model.id,
58
- title: data.title,
59
- filePath: sessionFile.toString(),
60
- requestCount: modelData.requests.length,
61
- responseCount: modelData.responses.length,
62
- pinnedAgentId: data.pinnedAgentId,
63
- version: data.version
64
- });
65
- await this.fileService.writeFile(sessionFile, buffer_1.BinaryBuffer.fromString(JSON.stringify(data, undefined, 2)));
66
- }
67
- // Update index with metadata
68
- await this.updateIndex(nonEmptySessions);
69
- // Trim to max sessions
70
- await this.trimSessions();
71
- this.logger.debug('Finished storing sessions');
72
- });
73
- return this.storePromise;
74
- }
75
- isChatModelWithMetadata(session) {
76
- return 'model' in session;
77
- }
78
- async readSession(sessionId) {
79
- const root = await this.getStorageRoot();
80
- const sessionFile = root.resolve(`${sessionId}.json`);
81
- this.logger.debug('Reading session from file', { sessionId, filePath: sessionFile.toString() });
82
- try {
83
- const content = await this.fileService.readFile(sessionFile);
84
- const parsedData = JSON.parse(content.value.toString());
85
- const data = this.migrateData(parsedData);
86
- this.logger.debug('Successfully read session', {
87
- sessionId,
88
- requestCount: data.model.requests.length,
89
- responseCount: data.model.responses.length,
90
- version: data.version
91
- });
92
- return data;
93
- }
94
- catch (e) {
95
- this.logger.debug('Failed to read session', { sessionId, error: e });
96
- return undefined;
97
- }
98
- }
99
- async deleteSession(sessionId) {
100
- this.storePromise = this.storePromise.then(async () => {
101
- const root = await this.getStorageRoot();
102
- const sessionFile = root.resolve(`${sessionId}.json`);
103
- this.logger.debug('Deleting session', { sessionId, filePath: sessionFile.toString() });
104
- try {
105
- await this.fileService.delete(sessionFile);
106
- this.logger.debug('Session file deleted', { sessionId });
107
- }
108
- catch (e) {
109
- this.logger.debug('Failed to delete session file (may not exist)', { sessionId, error: e });
110
- }
111
- // Update index
112
- const index = await this.loadIndex();
113
- delete index[sessionId];
114
- await this.saveIndex(index);
115
- this.logger.debug('Session removed from index', { sessionId });
116
- });
117
- return this.storePromise;
118
- }
119
- async clearAllSessions() {
120
- this.storePromise = this.storePromise.then(async () => {
121
- const root = await this.getStorageRoot();
122
- try {
123
- await this.fileService.delete(root, { recursive: true });
124
- await this.fileService.createFolder(root);
125
- }
126
- catch (e) {
127
- // Ignore errors
128
- }
129
- this.indexCache = {};
130
- await this.saveIndex({});
131
- });
132
- return this.storePromise;
133
- }
134
- async getSessionIndex() {
135
- const index = await this.loadIndex();
136
- this.logger.debug('Retrieved session index', { sessionCount: Object.keys(index).length });
137
- return index;
138
- }
139
- async setSessionTitle(sessionId, title) {
140
- this.storePromise = this.storePromise.then(async () => {
141
- const index = await this.loadIndex();
142
- if (index[sessionId]) {
143
- index[sessionId].title = title;
144
- await this.saveIndex(index);
145
- }
146
- });
147
- return this.storePromise;
148
- }
149
- async getStorageRoot() {
150
- if (this.storageRoot) {
151
- return this.storageRoot;
152
- }
153
- const configDir = await this.envServer.getConfigDirUri();
154
- this.storageRoot = new core_1.URI(configDir).resolve('chatSessions');
155
- try {
156
- await this.fileService.createFolder(this.storageRoot);
157
- }
158
- catch (e) {
159
- // Folder may already exist
160
- }
161
- return this.storageRoot;
162
- }
163
- async updateIndex(sessions) {
164
- const index = await this.loadIndex();
165
- for (const session of sessions) {
166
- const data = session.model.toSerializable();
167
- const { model, ...metadata } = session;
168
- const previousData = index[model.id];
169
- index[model.id] = {
170
- ...previousData,
171
- sessionId: model.id,
172
- location: data.location,
173
- ...metadata
174
- };
175
- }
176
- await this.saveIndex(index);
177
- }
178
- async trimSessions() {
179
- const index = await this.loadIndex();
180
- const sessions = Object.values(index);
181
- if (sessions.length <= MAX_SESSIONS) {
182
- return;
183
- }
184
- this.logger.debug('Trimming sessions', { currentCount: sessions.length, maxSessions: MAX_SESSIONS });
185
- // Sort by save date
186
- sessions.sort((a, b) => a.saveDate - b.saveDate);
187
- // Delete oldest sessions
188
- const sessionsToDelete = sessions.slice(0, sessions.length - MAX_SESSIONS);
189
- this.logger.debug('Deleting oldest sessions', { deleteCount: sessionsToDelete.length, sessionIds: sessionsToDelete.map(s => s.sessionId) });
190
- for (const session of sessionsToDelete) {
191
- await this.deleteSession(session.sessionId);
192
- }
193
- }
194
- async loadIndex() {
195
- if (this.indexCache) {
196
- return this.indexCache;
197
- }
198
- const root = await this.getStorageRoot();
199
- const indexFile = root.resolve(INDEX_FILE);
200
- try {
201
- const content = await this.fileService.readFile(indexFile);
202
- const rawIndex = JSON.parse(content.value.toString());
203
- // Validate and clean up index entries
204
- const validatedIndex = {};
205
- let hasInvalidEntries = false;
206
- for (const [sessionId, metadata] of Object.entries(rawIndex)) {
207
- // Check if entry has required fields and valid values
208
- if (this.isValidMetadata(metadata)) {
209
- validatedIndex[sessionId] = metadata;
210
- }
211
- else {
212
- hasInvalidEntries = true;
213
- this.logger.warn('Removing invalid session metadata from index', {
214
- sessionId,
215
- metadata
216
- });
217
- }
218
- }
219
- // If we removed any entries, persist the cleaned index
220
- if (hasInvalidEntries) {
221
- this.logger.info('Index cleaned up, removing invalid entries');
222
- await this.fileService.writeFile(indexFile, buffer_1.BinaryBuffer.fromString(JSON.stringify(validatedIndex, undefined, 2)));
223
- }
224
- this.indexCache = validatedIndex;
225
- return this.indexCache;
226
- }
227
- catch (e) {
228
- this.indexCache = {};
229
- return this.indexCache;
230
- }
231
- }
232
- isValidMetadata(metadata) {
233
- if (!metadata || typeof metadata !== 'object') {
234
- return false;
235
- }
236
- const m = metadata;
237
- // Check required fields exist and have correct types
238
- return typeof m.sessionId === 'string' &&
239
- typeof m.title === 'string' &&
240
- typeof m.saveDate === 'number' &&
241
- typeof m.location === 'string' &&
242
- // Ensure saveDate is a valid timestamp
243
- !isNaN(m.saveDate) &&
244
- m.saveDate > 0;
245
- }
246
- async saveIndex(index) {
247
- this.indexCache = index;
248
- const root = await this.getStorageRoot();
249
- const indexFile = root.resolve(INDEX_FILE);
250
- await this.fileService.writeFile(indexFile, buffer_1.BinaryBuffer.fromString(JSON.stringify(index, undefined, 2)));
251
- }
252
- migrateData(data) {
253
- const parsed = data;
254
- // Defensive check for unexpected future versions
255
- if (parsed.version && parsed.version > chat_model_serialization_1.CHAT_DATA_VERSION) {
256
- this.logger.warn(`Session data version ${parsed.version} is newer than supported ${chat_model_serialization_1.CHAT_DATA_VERSION}. ` +
257
- 'Data may not load correctly.');
258
- }
259
- return parsed;
260
- }
261
- };
262
- exports.ChatSessionStoreImpl = ChatSessionStoreImpl;
263
- tslib_1.__decorate([
264
- (0, inversify_1.inject)(file_service_1.FileService),
265
- tslib_1.__metadata("design:type", file_service_1.FileService)
266
- ], ChatSessionStoreImpl.prototype, "fileService", void 0);
267
- tslib_1.__decorate([
268
- (0, inversify_1.inject)(browser_1.WorkspaceService),
269
- tslib_1.__metadata("design:type", browser_1.WorkspaceService)
270
- ], ChatSessionStoreImpl.prototype, "workspaceService", void 0);
271
- tslib_1.__decorate([
272
- (0, inversify_1.inject)(env_variables_1.EnvVariablesServer),
273
- tslib_1.__metadata("design:type", Object)
274
- ], ChatSessionStoreImpl.prototype, "envServer", void 0);
275
- tslib_1.__decorate([
276
- (0, inversify_1.inject)(browser_2.StorageService),
277
- tslib_1.__metadata("design:type", Object)
278
- ], ChatSessionStoreImpl.prototype, "storageService", void 0);
279
- tslib_1.__decorate([
280
- (0, inversify_1.inject)(logger_1.ILogger),
281
- (0, inversify_1.named)('ChatSessionStore'),
282
- tslib_1.__metadata("design:type", Object)
283
- ], ChatSessionStoreImpl.prototype, "logger", void 0);
284
- exports.ChatSessionStoreImpl = ChatSessionStoreImpl = tslib_1.__decorate([
285
- (0, inversify_1.injectable)()
286
- ], ChatSessionStoreImpl);
287
- //# sourceMappingURL=chat-session-store-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-session-store-impl.js","sourceRoot":"","sources":["../../src/browser/chat-session-store-impl.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,4DAAyE;AACzE,6EAAyE;AACzE,0DAAgE;AAChE,wEAA0E;AAC1E,qDAAyD;AACzD,sCAAkC;AAClC,0DAA6D;AAC7D,0DAAwD;AAGxD,iFAA2F;AAE3F,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,YAAY,CAAC;AAGzB,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAA1B;QAkBO,iBAAY,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAmR9D,CAAC;IAjRG,KAAK,CAAC,aAAa,CAAC,GAAG,QAAkD;QACrE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CA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AAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAC/D,CAAC;IACN,CAAC;IAES,WAAW,CAAC,IAAa;QAC/B,MAAM,MAAM,GAAG,IAA0B,CAAC;QAE1C,iDAAiD;QACjD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,GAAG,4CAAiB,EAAE,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,wBAAwB,MAAM,CAAC,OAAO,4BAA4B,4CAAiB,IAAI;gBACvF,8BAA8B,CACjC,CAAC;QACN,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AArSY,oDAAoB;AAEV;IADlB,IAAA,kBAAM,EAAC,0BAAW,CAAC;sCACY,0BAAW;yDAAC;AAGzB;IADlB,IAAA,kBAAM,EAAC,0BAAgB,CAAC;sCACY,0BAAgB;8DAAC;AAGnC;IADlB,IAAA,kBAAM,EAAC,kCAAkB,CAAC;;uDACsB;AAG9B;IADlB,IAAA,kBAAM,EAAC,wBAAc,CAAC;;4DAC2B;AAG/B;IADlB,IAAA,kBAAM,EAAC,gBAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,kBAAkB,CAAC;;oDACR;+BAd1B,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAqShC"}
@@ -1,34 +0,0 @@
1
- import { PreferenceService } from '@theia/core/lib/common/preferences';
2
- import { ToolConfirmationMode, ChatToolPreferences } from '../common/chat-tool-preferences';
3
- /**
4
- * Utility class to manage tool confirmation settings
5
- */
6
- export declare class ToolConfirmationManager {
7
- protected readonly preferences: ChatToolPreferences;
8
- protected readonly preferenceService: PreferenceService;
9
- protected sessionOverrides: Map<string, Map<string, ToolConfirmationMode>>;
10
- /**
11
- * Get the confirmation mode for a specific tool, considering session overrides first (per chat)
12
- */
13
- getConfirmationMode(toolId: string, chatId: string): ToolConfirmationMode;
14
- /**
15
- * Set the confirmation mode for a specific tool (persisted)
16
- */
17
- setConfirmationMode(toolId: string, mode: ToolConfirmationMode): void;
18
- /**
19
- * Set the confirmation mode for a specific tool for this session only (not persisted, per chat)
20
- */
21
- setSessionConfirmationMode(toolId: string, mode: ToolConfirmationMode, chatId: string): void;
22
- /**
23
- * Clear all session overrides for a specific chat, or all if no chatId is given
24
- */
25
- clearSessionOverrides(chatId?: string): void;
26
- /**
27
- * Get all tool confirmation settings
28
- */
29
- getAllConfirmationSettings(): {
30
- [toolId: string]: ToolConfirmationMode;
31
- };
32
- resetAllConfirmationModeSettings(): void;
33
- }
34
- //# sourceMappingURL=chat-tool-preference-bindings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-tool-preference-bindings.d.ts","sourceRoot":"","sources":["../../src/browser/chat-tool-preference-bindings.ts"],"names":[],"mappings":"AAiBA,OAAO,EACH,iBAAiB,EACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAgC,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE1H;;GAEG;AACH,qBACa,uBAAuB;IAEhC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAGpD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAa;IAEvF;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAezE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAqBrE;;OAEG;IACH,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAS5F;;OAEG;IACH,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ5C;;OAEG;IACH,0BAA0B,IAAI;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE;IAIxE,gCAAgC,IAAI,IAAI;CAQ3C"}
@@ -1,122 +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.ToolConfirmationManager = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const preferences_1 = require("@theia/core/lib/common/preferences");
22
- const chat_tool_preferences_1 = require("../common/chat-tool-preferences");
23
- /**
24
- * Utility class to manage tool confirmation settings
25
- */
26
- let ToolConfirmationManager = class ToolConfirmationManager {
27
- constructor() {
28
- // In-memory session overrides (not persisted), per chat
29
- this.sessionOverrides = new Map();
30
- }
31
- /**
32
- * Get the confirmation mode for a specific tool, considering session overrides first (per chat)
33
- */
34
- getConfirmationMode(toolId, chatId) {
35
- const chatMap = this.sessionOverrides.get(chatId);
36
- if (chatMap && chatMap.has(toolId)) {
37
- return chatMap.get(toolId);
38
- }
39
- const toolConfirmation = this.preferences[chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE];
40
- if (toolConfirmation[toolId]) {
41
- return toolConfirmation[toolId];
42
- }
43
- if (toolConfirmation['*']) {
44
- return toolConfirmation['*'];
45
- }
46
- return chat_tool_preferences_1.ToolConfirmationMode.ALWAYS_ALLOW; // Default to Always Allow
47
- }
48
- /**
49
- * Set the confirmation mode for a specific tool (persisted)
50
- */
51
- setConfirmationMode(toolId, mode) {
52
- const current = this.preferences[chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE] || {};
53
- // Determine the global default (star entry), or fallback to schema default
54
- let starMode = current['*'];
55
- if (starMode === undefined) {
56
- starMode = chat_tool_preferences_1.ToolConfirmationMode.ALWAYS_ALLOW;
57
- }
58
- if (mode === starMode) {
59
- // Remove the toolId entry if it exists
60
- if (toolId in current) {
61
- const { [toolId]: _, ...rest } = current;
62
- this.preferenceService.updateValue(chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE, rest);
63
- }
64
- // else, nothing to update
65
- }
66
- else {
67
- // Set or update the toolId entry
68
- const updated = { ...current, [toolId]: mode };
69
- this.preferenceService.updateValue(chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE, updated);
70
- }
71
- }
72
- /**
73
- * Set the confirmation mode for a specific tool for this session only (not persisted, per chat)
74
- */
75
- setSessionConfirmationMode(toolId, mode, chatId) {
76
- let chatMap = this.sessionOverrides.get(chatId);
77
- if (!chatMap) {
78
- chatMap = new Map();
79
- this.sessionOverrides.set(chatId, chatMap);
80
- }
81
- chatMap.set(toolId, mode);
82
- }
83
- /**
84
- * Clear all session overrides for a specific chat, or all if no chatId is given
85
- */
86
- clearSessionOverrides(chatId) {
87
- if (chatId) {
88
- this.sessionOverrides.delete(chatId);
89
- }
90
- else {
91
- this.sessionOverrides.clear();
92
- }
93
- }
94
- /**
95
- * Get all tool confirmation settings
96
- */
97
- getAllConfirmationSettings() {
98
- return this.preferences[chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE] || {};
99
- }
100
- resetAllConfirmationModeSettings() {
101
- const current = this.preferences[chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE] || {};
102
- if ('*' in current) {
103
- this.preferenceService.updateValue(chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE, { '*': current['*'] });
104
- }
105
- else {
106
- this.preferenceService.updateValue(chat_tool_preferences_1.TOOL_CONFIRMATION_PREFERENCE, {});
107
- }
108
- }
109
- };
110
- exports.ToolConfirmationManager = ToolConfirmationManager;
111
- tslib_1.__decorate([
112
- (0, inversify_1.inject)(chat_tool_preferences_1.ChatToolPreferences),
113
- tslib_1.__metadata("design:type", Object)
114
- ], ToolConfirmationManager.prototype, "preferences", void 0);
115
- tslib_1.__decorate([
116
- (0, inversify_1.inject)(preferences_1.PreferenceService),
117
- tslib_1.__metadata("design:type", Object)
118
- ], ToolConfirmationManager.prototype, "preferenceService", void 0);
119
- exports.ToolConfirmationManager = ToolConfirmationManager = tslib_1.__decorate([
120
- (0, inversify_1.injectable)()
121
- ], ToolConfirmationManager);
122
- //# sourceMappingURL=chat-tool-preference-bindings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-tool-preference-bindings.js","sourceRoot":"","sources":["../../src/browser/chat-tool-preference-bindings.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,4DAAkE;AAClE,oEAE4C;AAC5C,2EAA0H;AAE1H;;GAEG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAA7B;QAOH,wDAAwD;QAC9C,qBAAgB,GAAmD,IAAI,GAAG,EAAE,CAAC;IAkF3F,CAAC;IAhFG;;OAEG;IACH,mBAAmB,CAAC,MAAc,EAAE,MAAc;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,OAAO,IAAI,OAAO,CAAC,GA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ADlB,IAAA,kBAAM,EAAC,+BAAiB,CAAC;;kEAC8B;kCAL/C,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CA0FnC"}
@@ -1,21 +0,0 @@
1
- import { ToolRequest } from '@theia/ai-core';
2
- import { ChatToolRequestService, ChatToolRequest } from '../common/chat-tool-request-service';
3
- import { MutableChatRequestModel, ToolCallChatResponseContent } from '../common/chat-model';
4
- import { ChatToolPreferences } from '../common/chat-tool-preferences';
5
- import { ToolConfirmationManager } from './chat-tool-preference-bindings';
6
- /**
7
- * Frontend-specific implementation of ChatToolRequestService that handles tool confirmation
8
- */
9
- export declare class FrontendChatToolRequestService extends ChatToolRequestService {
10
- protected readonly confirmationManager: ToolConfirmationManager;
11
- protected readonly preferences: ChatToolPreferences;
12
- protected toChatToolRequest(toolRequest: ToolRequest, request: MutableChatRequestModel): ChatToolRequest;
13
- /**
14
- * Find existing tool call content or create a new one for confirmation tracking
15
- *
16
- * Looks for ToolCallChatResponseContent nodes where the name field matches the toolRequest id.
17
- * Starts from the back of the content array to find the most recent match.
18
- */
19
- protected findToolCallContent(toolRequest: ToolRequest, arguments_: string, request: MutableChatRequestModel): ToolCallChatResponseContent;
20
- }
21
- //# sourceMappingURL=chat-tool-request-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-tool-request-service.d.ts","sourceRoot":"","sources":["../../src/browser/chat-tool-request-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAwB,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;GAEG;AACH,qBACa,8BAA+B,SAAQ,sBAAsB;IAGtE,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,uBAAuB,CAAC;IAGhE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;cAEjC,iBAAiB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,uBAAuB,GAAG,eAAe;IAgCjH;;;;;OAKG;IACH,SAAS,CAAC,mBAAmB,CACzB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,uBAAuB,GACjC,2BAA2B;CAgBjC"}
@@ -1,90 +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.FrontendChatToolRequestService = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const chat_tool_request_service_1 = require("../common/chat-tool-request-service");
22
- const chat_model_1 = require("../common/chat-model");
23
- const chat_tool_preferences_1 = require("../common/chat-tool-preferences");
24
- const chat_tool_preference_bindings_1 = require("./chat-tool-preference-bindings");
25
- /**
26
- * Frontend-specific implementation of ChatToolRequestService that handles tool confirmation
27
- */
28
- let FrontendChatToolRequestService = class FrontendChatToolRequestService extends chat_tool_request_service_1.ChatToolRequestService {
29
- toChatToolRequest(toolRequest, request) {
30
- const confirmationMode = this.confirmationManager.getConfirmationMode(toolRequest.id, request.session.id);
31
- return {
32
- ...toolRequest,
33
- handler: async (arg_string) => {
34
- switch (confirmationMode) {
35
- case chat_tool_preferences_1.ToolConfirmationMode.DISABLED:
36
- return { denied: true, message: `Tool ${toolRequest.id} is disabled` };
37
- case chat_tool_preferences_1.ToolConfirmationMode.ALWAYS_ALLOW:
38
- // Execute immediately without confirmation
39
- return toolRequest.handler(arg_string, request);
40
- case chat_tool_preferences_1.ToolConfirmationMode.CONFIRM:
41
- default:
42
- // Create confirmation requirement
43
- const toolCallContent = this.findToolCallContent(toolRequest, arg_string, request);
44
- const confirmed = await toolCallContent.confirmed;
45
- if (confirmed) {
46
- return toolRequest.handler(arg_string, request);
47
- }
48
- else {
49
- // Return an object indicating the user denied the tool execution
50
- // instead of throwing an error
51
- return { denied: true, message: `Tool execution denied by user: ${toolRequest.id}` };
52
- }
53
- }
54
- }
55
- };
56
- }
57
- /**
58
- * Find existing tool call content or create a new one for confirmation tracking
59
- *
60
- * Looks for ToolCallChatResponseContent nodes where the name field matches the toolRequest id.
61
- * Starts from the back of the content array to find the most recent match.
62
- */
63
- findToolCallContent(toolRequest, arguments_, request) {
64
- // Look for existing tool call content with matching ID
65
- const response = request.response.response;
66
- const contentArray = response.content;
67
- // Start from the end of the array and find the first match
68
- for (let i = contentArray.length - 1; i >= 0; i--) {
69
- const content = contentArray[i];
70
- if (chat_model_1.ToolCallChatResponseContent.is(content) &&
71
- content.name === toolRequest.id) {
72
- return content;
73
- }
74
- }
75
- throw new Error(`Tool call content for tool ${toolRequest.id} not found in the response`);
76
- }
77
- };
78
- exports.FrontendChatToolRequestService = FrontendChatToolRequestService;
79
- tslib_1.__decorate([
80
- (0, inversify_1.inject)(chat_tool_preference_bindings_1.ToolConfirmationManager),
81
- tslib_1.__metadata("design:type", chat_tool_preference_bindings_1.ToolConfirmationManager)
82
- ], FrontendChatToolRequestService.prototype, "confirmationManager", void 0);
83
- tslib_1.__decorate([
84
- (0, inversify_1.inject)(chat_tool_preferences_1.ChatToolPreferences),
85
- tslib_1.__metadata("design:type", Object)
86
- ], FrontendChatToolRequestService.prototype, "preferences", void 0);
87
- exports.FrontendChatToolRequestService = FrontendChatToolRequestService = tslib_1.__decorate([
88
- (0, inversify_1.injectable)()
89
- ], FrontendChatToolRequestService);
90
- //# sourceMappingURL=chat-tool-request-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat-tool-request-service.js","sourceRoot":"","sources":["../../src/browser/chat-tool-request-service.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;;;;AAGhF,4DAAkE;AAClE,mFAA8F;AAC9F,qDAA4F;AAC5F,2EAA4F;AAC5F,mFAA0E;AAE1E;;GAEG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,kDAAsB;IAQnD,iBAAiB,CAAC,WAAwB,EAAE,OAAgC;QAC3F,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE1G,OAAO;YACH,GAAG,WAAW;YACd,OAAO,EAAE,KAAK,EAAE,UAAkB,EAAE,EAAE;gBAClC,QAAQ,gBAAgB,EAAE,CAAC;oBACvB,KAAK,4CAAoB,CAAC,QAAQ;wBAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;oBAE3E,KAAK,4CAAoB,CAAC,YAAY;wBAClC,2CAA2C;wBAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;oBAEpD,KAAK,4CAAoB,CAAC,OAAO,CA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B,IAAA,kBAAM,EAAC,2CAAmB,CAAC;;mEACwB;yCAN3C,8BAA8B;IAD1C,IAAA,sBAAU,GAAE;GACA,8BAA8B,CAkE1C"}
@@ -1,15 +0,0 @@
1
- import { URI } from '@theia/core';
2
- export declare enum FileValidationState {
3
- VALID = "valid",
4
- INVALID_SECONDARY = "invalid-secondary",
5
- INVALID_NOT_FOUND = "invalid-not-found"
6
- }
7
- export interface FileValidationResult {
8
- state: FileValidationState;
9
- message?: string;
10
- }
11
- export interface ContextFileValidationService {
12
- validateFile(pathOrUri: string | URI): Promise<FileValidationResult>;
13
- }
14
- export declare const ContextFileValidationService: unique symbol;
15
- //# sourceMappingURL=context-file-validation-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-file-validation-service.d.ts","sourceRoot":"","sources":["../../src/browser/context-file-validation-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,oBAAY,mBAAmB;IAC3B,KAAK,UAAU;IACf,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IACzC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,4BAA4B,eAAyC,CAAC"}
@@ -1,26 +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.ContextFileValidationService = exports.FileValidationState = void 0;
19
- var FileValidationState;
20
- (function (FileValidationState) {
21
- FileValidationState["VALID"] = "valid";
22
- FileValidationState["INVALID_SECONDARY"] = "invalid-secondary";
23
- FileValidationState["INVALID_NOT_FOUND"] = "invalid-not-found";
24
- })(FileValidationState || (exports.FileValidationState = FileValidationState = {}));
25
- exports.ContextFileValidationService = Symbol('ContextFileValidationService');
26
- //# sourceMappingURL=context-file-validation-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-file-validation-service.js","sourceRoot":"","sources":["../../src/browser/context-file-validation-service.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;;;AAIhF,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC3B,sCAAe,CAAA;IACf,8DAAuC,CAAA;IACvC,8DAAuC,CAAA;AAC3C,CAAC,EAJW,mBAAmB,mCAAnB,mBAAmB,QAI9B;AAWY,QAAA,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC"}