@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 +0,0 @@
1
- {"version":3,"file":"change-set-decorator-service.js","sourceRoot":"","sources":["../../src/browser/change-set-decorator-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;;;;AAEhF,sCAAwE;AAExE,4DAAyE;AACzE,+DAAgE;AAGhE;;;GAGG;AACU,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAUxD,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAA/B;QAEgB,kCAA6B,GAAG,IAAI,cAAO,EAAQ,CAAC;QAC9D,2BAAsB,GAAG,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC;QASxD,6BAAwB,GAAG,QAAQ,CAAC,GAAG,EAAE;YACxD,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC,EAAE,GAAG,CAAC,CAAC;IA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ribution, ChangeSetElementDeserializerRegistry } from '../common/change-set-element-deserializer';
2
- import { ChangeSetFileElementFactory } from './change-set-file-element';
3
- export declare class ChangeSetFileElementDeserializerContribution implements ChangeSetElementDeserializerContribution {
4
- protected readonly fileElementFactory: ChangeSetFileElementFactory;
5
- registerDeserializers(registry: ChangeSetElementDeserializerRegistry): void;
6
- }
7
- //# sourceMappingURL=change-set-file-element-deserializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-set-file-element-deserializer.d.ts","sourceRoot":"","sources":["../../src/browser/change-set-file-element-deserializer.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,wCAAwC,EAAE,oCAAoC,EAAmC,MAAM,2CAA2C,CAAC;AAE5K,OAAO,EAAwB,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAE9F,qBACa,4CAA6C,YAAW,wCAAwC;IAGzG,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;IAEnE,qBAAqB,CAAC,QAAQ,EAAE,oCAAoC,GAAG,IAAI;CAgC9E"}
@@ -1,61 +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.ChangeSetFileElementDeserializerContribution = void 0;
19
- const tslib_1 = require("tslib");
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const core_1 = require("@theia/core");
22
- const change_set_file_element_1 = require("./change-set-file-element");
23
- let ChangeSetFileElementDeserializerContribution = class ChangeSetFileElementDeserializerContribution {
24
- registerDeserializers(registry) {
25
- registry.register({
26
- kind: 'file',
27
- deserialize: async (serialized, context) => {
28
- const fileData = serialized.data;
29
- // Create ChangeSetElementArgs with all the necessary data
30
- const args = {
31
- uri: new core_1.URI(serialized.uri),
32
- chatSessionId: context.chatSessionId,
33
- requestId: context.requestId,
34
- name: serialized.name,
35
- icon: serialized.icon,
36
- additionalInfo: serialized.additionalInfo,
37
- state: serialized.state,
38
- type: serialized.type,
39
- data: serialized.data,
40
- targetState: fileData === null || fileData === void 0 ? void 0 : fileData.targetState,
41
- originalState: fileData === null || fileData === void 0 ? void 0 : fileData.originalState,
42
- replacements: fileData === null || fileData === void 0 ? void 0 : fileData.replacements
43
- };
44
- // Create the element using the factory
45
- const element = this.fileElementFactory(args);
46
- // Ensure it's initialized before returning
47
- await element.ensureInitialized();
48
- return element;
49
- }
50
- });
51
- }
52
- };
53
- exports.ChangeSetFileElementDeserializerContribution = ChangeSetFileElementDeserializerContribution;
54
- tslib_1.__decorate([
55
- (0, inversify_1.inject)(change_set_file_element_1.ChangeSetFileElementFactory),
56
- tslib_1.__metadata("design:type", Function)
57
- ], ChangeSetFileElementDeserializerContribution.prototype, "fileElementFactory", void 0);
58
- exports.ChangeSetFileElementDeserializerContribution = ChangeSetFileElementDeserializerContribution = tslib_1.__decorate([
59
- (0, inversify_1.injectable)()
60
- ], ChangeSetFileElementDeserializerContribution);
61
- //# sourceMappingURL=change-set-file-element-deserializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-set-file-element-deserializer.js","sourceRoot":"","sources":["../../src/browser/change-set-file-element-deserializer.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAA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AAM,EAAC,qDAA2B,CAAC;;wFAC+B;uDAH1D,4CAA4C;IADxD,IAAA,sBAAU,GAAE;GACA,4CAA4C,CAqCxD"}
@@ -1,122 +0,0 @@
1
- import { ConfigurableInMemoryResources, ConfigurableMutableReferenceResource } from '@theia/ai-core';
2
- import { DisposableCollection, Emitter, URI } from '@theia/core';
3
- import { Replacement } from '@theia/core/lib/common/content-replacer';
4
- import { EditorPreferences } from '@theia/editor/lib/common/editor-preferences';
5
- import { FileSystemPreferences } from '@theia/filesystem/lib/common';
6
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
7
- import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
8
- import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
9
- import { ChangeSetElement } from '../common';
10
- import { SerializableChangeSetElement } from '../common/chat-model-serialization';
11
- import { ChangeSetFileService } from './change-set-file-service';
12
- import { Deferred } from '@theia/core/lib/common/promise-util';
13
- import { MonacoCodeActionService } from '@theia/monaco/lib/browser';
14
- export declare const ChangeSetFileElementFactory: unique symbol;
15
- export type ChangeSetFileElementFactory = (elementProps: ChangeSetElementArgs) => ChangeSetFileElement;
16
- type ChangeSetElementState = ChangeSetElement['state'];
17
- export declare const ChangeSetElementArgs: unique symbol;
18
- export interface ChangeSetElementArgs extends Partial<ChangeSetElement> {
19
- /** The URI of the element, expected to be unique within the same change set. */
20
- uri: URI;
21
- /** The id of the chat session containing this change set element. */
22
- chatSessionId: string;
23
- /** The id of the request with which this change set element is associated. */
24
- requestId: string;
25
- /**
26
- * The state of the file after the changes have been applied.
27
- * If `undefined`, there is no change.
28
- */
29
- targetState?: string;
30
- /**
31
- * The state before the change has been applied. If it is specified, we don't care
32
- * about the state of the original file on disk but just use the specified `originalState`.
33
- * If it isn't specified, we'll derived and observe the state from the file system.
34
- */
35
- originalState?: string;
36
- /**
37
- * An array of replacements used to create the new content for the targetState.
38
- * This is only available if the agent was able to provide replacements and we were able to apply them.
39
- */
40
- replacements?: Replacement[];
41
- }
42
- export declare class ChangeSetFileElement implements ChangeSetElement {
43
- static toReadOnlyUri(baseUri: URI, sessionId: string): URI;
44
- protected readonly elementProps: ChangeSetElementArgs;
45
- protected readonly changeSetFileService: ChangeSetFileService;
46
- protected readonly fileService: FileService;
47
- protected readonly inMemoryResources: ConfigurableInMemoryResources;
48
- protected readonly monacoTextModelService: MonacoTextModelService;
49
- protected readonly editorPreferences: EditorPreferences;
50
- protected readonly fileSystemPreferences: FileSystemPreferences;
51
- protected readonly codeActionService: MonacoCodeActionService;
52
- protected readonly toDispose: DisposableCollection;
53
- protected _state: ChangeSetElementState;
54
- private _originalContent;
55
- protected _initialized: boolean;
56
- protected _initializationPromise: Promise<void> | undefined;
57
- protected _targetStateWithCodeActions: string | undefined;
58
- protected codeActionDeferred?: Deferred<string>;
59
- protected readonly onDidChangeEmitter: Emitter<void>;
60
- readonly onDidChange: import("@theia/core").Event<void>;
61
- protected _readOnlyResource?: ConfigurableMutableReferenceResource;
62
- protected _changeResource?: ConfigurableMutableReferenceResource;
63
- init(): void;
64
- protected initializeAsync(): Promise<void>;
65
- /**
66
- * Ensures that the element is fully initialized before proceeding.
67
- * This includes loading the original content from the file system.
68
- */
69
- ensureInitialized(): Promise<void>;
70
- /**
71
- * Returns true if the element has been fully initialized.
72
- */
73
- get isInitialized(): boolean;
74
- protected obtainOriginalContent(): Promise<void>;
75
- protected getInMemoryUri(uri: URI): ConfigurableMutableReferenceResource;
76
- protected listenForOriginalFileChanges(): void;
77
- get uri(): URI;
78
- protected get readOnlyResource(): ConfigurableMutableReferenceResource;
79
- get readOnlyUri(): URI;
80
- protected get changeResource(): ConfigurableMutableReferenceResource;
81
- get changedUri(): URI;
82
- get name(): string;
83
- get icon(): string | undefined;
84
- get additionalInfo(): string | undefined;
85
- get state(): ChangeSetElementState;
86
- protected set state(value: ChangeSetElementState);
87
- get replacements(): Replacement[] | undefined;
88
- get type(): 'add' | 'modify' | 'delete' | undefined;
89
- get data(): {
90
- [key: string]: unknown;
91
- } | undefined;
92
- get originalContent(): string | undefined;
93
- /**
94
- * Gets the original content of the file asynchronously.
95
- * Ensures initialization is complete before returning the content.
96
- */
97
- getOriginalContent(): Promise<string | undefined>;
98
- get targetState(): string;
99
- get originalTargetState(): string;
100
- open(): Promise<void>;
101
- openChange(): Promise<void>;
102
- apply(contents?: string): Promise<void>;
103
- writeChanges(contents?: string): Promise<void>;
104
- /**
105
- * Applies changes using Monaco utilities, including loading the model for the base file URI,
106
- * setting the value to the intended state, and running code actions on save.
107
- */
108
- protected applyChangesWithMonaco(contents?: string): Promise<void>;
109
- protected applyCodeActionsToTargetState(): Promise<string>;
110
- protected doApplyCodeActionsToTargetState(): Promise<string>;
111
- /**
112
- * Applies formatting preferences like format on save, trim trailing whitespace, and insert final newline.
113
- */
114
- protected applyFormatting(model: MonacoEditorModel, languageId: string, uriStr: string): Promise<void>;
115
- onShow(): void;
116
- revert(): Promise<void>;
117
- confirm(verb: 'Apply' | 'Revert'): Promise<boolean>;
118
- toSerializable(): SerializableChangeSetElement;
119
- dispose(): void;
120
- }
121
- export {};
122
- //# sourceMappingURL=change-set-file-element.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-set-file-element.d.ts","sourceRoot":"","sources":["../../src/browser/change-set-file-element.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,6BAA6B,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAqB,oBAAoB,EAAE,OAAO,EAAO,GAAG,EAAE,MAAM,aAAa,CAAC;AAEzF,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAQzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAE7F,O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E,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B5G,MAAM,IAAI,IAAI;IAUR,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAWvB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAgBzD,cAAc,IAAI,4BAA4B;IAkB9C,OAAO,IAAI,IAAI;CAGlB"}
@@ -1,435 +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
- var ChangeSetFileElement_1;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.ChangeSetFileElement = exports.ChangeSetElementArgs = exports.ChangeSetFileElementFactory = void 0;
20
- const tslib_1 = require("tslib");
21
- const ai_core_1 = require("@theia/ai-core");
22
- const core_1 = require("@theia/core");
23
- const browser_1 = require("@theia/core/lib/browser");
24
- const inversify_1 = require("@theia/core/shared/inversify");
25
- const editor_preferences_1 = require("@theia/editor/lib/common/editor-preferences");
26
- const common_1 = require("@theia/filesystem/lib/common");
27
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
28
- const trimTrailingWhitespaceCommand_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/commands/trimTrailingWhitespaceCommand");
29
- const selection_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/core/selection");
30
- const cursor_1 = require("@theia/monaco-editor-core/esm/vs/editor/common/cursor/cursor");
31
- const format_1 = require("@theia/monaco-editor-core/esm/vs/editor/contrib/format/browser/format");
32
- const standaloneServices_1 = require("@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices");
33
- const instantiation_1 = require("@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation");
34
- const monaco_text_model_service_1 = require("@theia/monaco/lib/browser/monaco-text-model-service");
35
- const monaco_utilities_1 = require("@theia/monaco/lib/browser/monaco-utilities");
36
- const change_set_file_resource_1 = require("./change-set-file-resource");
37
- const change_set_file_service_1 = require("./change-set-file-service");
38
- const promise_util_1 = require("@theia/core/lib/common/promise-util");
39
- const browser_2 = require("@theia/monaco/lib/browser");
40
- exports.ChangeSetFileElementFactory = Symbol('ChangeSetFileElementFactory');
41
- exports.ChangeSetElementArgs = Symbol('ChangeSetElementArgs');
42
- ;
43
- let ChangeSetFileElement = ChangeSetFileElement_1 = class ChangeSetFileElement {
44
- constructor() {
45
- this.toDispose = new core_1.DisposableCollection();
46
- this._initialized = false;
47
- this.onDidChangeEmitter = new core_1.Emitter();
48
- this.onDidChange = this.onDidChangeEmitter.event;
49
- }
50
- static toReadOnlyUri(baseUri, sessionId) {
51
- return baseUri.withScheme('change-set-immutable').withAuthority(sessionId);
52
- }
53
- init() {
54
- this._initializationPromise = this.initializeAsync();
55
- this.toDispose.push(this.onDidChangeEmitter);
56
- }
57
- async initializeAsync() {
58
- await this.obtainOriginalContent();
59
- this.listenForOriginalFileChanges();
60
- this._initialized = true;
61
- }
62
- /**
63
- * Ensures that the element is fully initialized before proceeding.
64
- * This includes loading the original content from the file system.
65
- */
66
- async ensureInitialized() {
67
- await this._initializationPromise;
68
- }
69
- /**
70
- * Returns true if the element has been fully initialized.
71
- */
72
- get isInitialized() {
73
- return this._initialized;
74
- }
75
- async obtainOriginalContent() {
76
- var _a, _b;
77
- this._originalContent = (_a = this.elementProps.originalState) !== null && _a !== void 0 ? _a : await this.changeSetFileService.read(this.uri);
78
- if (this._readOnlyResource) {
79
- this.readOnlyResource.update({ contents: (_b = this._originalContent) !== null && _b !== void 0 ? _b : '' });
80
- }
81
- }
82
- getInMemoryUri(uri) {
83
- try {
84
- return this.inMemoryResources.resolve(uri);
85
- }
86
- catch {
87
- return this.inMemoryResources.add(uri, { contents: '' });
88
- }
89
- }
90
- listenForOriginalFileChanges() {
91
- if (this.elementProps.originalState) {
92
- // if we have an original state, we are not interested in the original file on disk but always use `originalState`
93
- return;
94
- }
95
- this.toDispose.push(this.fileService.onDidFilesChange(async (event) => {
96
- if (!event.contains(this.uri)) {
97
- return;
98
- }
99
- if (!this._initialized && this._initializationPromise) {
100
- // make sure we are initialized
101
- await this._initializationPromise;
102
- }
103
- // If we are applied, the tricky thing becomes the question what to revert to; otherwise, what to apply.
104
- const newContent = await this.changeSetFileService.read(this.uri).catch(() => '');
105
- this.readOnlyResource.update({ contents: newContent });
106
- if (newContent === this._originalContent) {
107
- this.state = 'pending';
108
- }
109
- else if (newContent === this.targetState) {
110
- this.state = 'applied';
111
- }
112
- else {
113
- this.state = 'stale';
114
- }
115
- }));
116
- }
117
- get uri() {
118
- return this.elementProps.uri;
119
- }
120
- get readOnlyResource() {
121
- var _a, _b;
122
- if (!this._readOnlyResource) {
123
- this._readOnlyResource = this.getInMemoryUri(ChangeSetFileElement_1.toReadOnlyUri(this.uri, this.elementProps.chatSessionId));
124
- this._readOnlyResource.update({
125
- autosaveable: false,
126
- readOnly: true,
127
- contents: (_a = this._originalContent) !== null && _a !== void 0 ? _a : ''
128
- });
129
- this.toDispose.push(this._readOnlyResource);
130
- // If not yet initialized, update the resource once initialization completes
131
- if (!this._initialized) {
132
- (_b = this._initializationPromise) === null || _b === void 0 ? void 0 : _b.then(() => {
133
- var _a, _b;
134
- (_a = this._readOnlyResource) === null || _a === void 0 ? void 0 : _a.update({ contents: (_b = this._originalContent) !== null && _b !== void 0 ? _b : '' });
135
- });
136
- }
137
- }
138
- return this._readOnlyResource;
139
- }
140
- get readOnlyUri() {
141
- return this.readOnlyResource.uri;
142
- }
143
- get changeResource() {
144
- if (!this._changeResource) {
145
- this._changeResource = this.getInMemoryUri((0, change_set_file_resource_1.createChangeSetFileUri)(this.elementProps.chatSessionId, this.uri));
146
- this._changeResource.update({ autosaveable: false, contents: this.targetState });
147
- this.applyCodeActionsToTargetState();
148
- this.toDispose.push(this._changeResource);
149
- }
150
- return this._changeResource;
151
- }
152
- get changedUri() {
153
- return this.changeResource.uri;
154
- }
155
- get name() {
156
- var _a;
157
- return (_a = this.elementProps.name) !== null && _a !== void 0 ? _a : this.changeSetFileService.getName(this.uri);
158
- }
159
- get icon() {
160
- var _a;
161
- return (_a = this.elementProps.icon) !== null && _a !== void 0 ? _a : this.changeSetFileService.getIcon(this.uri);
162
- }
163
- get additionalInfo() {
164
- return this.changeSetFileService.getAdditionalInfo(this.uri);
165
- }
166
- get state() {
167
- var _a;
168
- return (_a = this._state) !== null && _a !== void 0 ? _a : this.elementProps.state;
169
- }
170
- set state(value) {
171
- if (this._state !== value) {
172
- this._state = value;
173
- this.onDidChangeEmitter.fire();
174
- }
175
- }
176
- get replacements() {
177
- return this.elementProps.replacements;
178
- }
179
- get type() {
180
- return this.elementProps.type;
181
- }
182
- get data() {
183
- return this.elementProps.data;
184
- }
185
- ;
186
- get originalContent() {
187
- if (!this._initialized && this._initializationPromise) {
188
- console.warn('Accessing originalContent before initialization is complete. Consider using async methods.');
189
- }
190
- return this._originalContent;
191
- }
192
- /**
193
- * Gets the original content of the file asynchronously.
194
- * Ensures initialization is complete before returning the content.
195
- */
196
- async getOriginalContent() {
197
- await this.ensureInitialized();
198
- return this._originalContent;
199
- }
200
- get targetState() {
201
- var _a, _b;
202
- return (_b = (_a = this._targetStateWithCodeActions) !== null && _a !== void 0 ? _a : this.elementProps.targetState) !== null && _b !== void 0 ? _b : '';
203
- }
204
- get originalTargetState() {
205
- var _a;
206
- return (_a = this.elementProps.targetState) !== null && _a !== void 0 ? _a : '';
207
- }
208
- async open() {
209
- await this.ensureInitialized();
210
- this.changeSetFileService.open(this);
211
- }
212
- async openChange() {
213
- await this.ensureInitialized();
214
- this.changeSetFileService.openDiff(this.readOnlyUri, this.changedUri);
215
- }
216
- async apply(contents) {
217
- await this.ensureInitialized();
218
- if (!await this.confirm('Apply')) {
219
- return;
220
- }
221
- if (this.type === 'delete') {
222
- await this.changeSetFileService.delete(this.uri);
223
- this.state = 'applied';
224
- this.changeSetFileService.closeDiff(this.readOnlyUri);
225
- return;
226
- }
227
- // Load Monaco model for the base file URI and apply changes
228
- await this.applyChangesWithMonaco(contents);
229
- this.changeSetFileService.closeDiff(this.readOnlyUri);
230
- }
231
- async writeChanges(contents) {
232
- await this.changeSetFileService.writeFrom(this.changedUri, this.uri, contents !== null && contents !== void 0 ? contents : this.targetState);
233
- this.state = 'applied';
234
- }
235
- /**
236
- * Applies changes using Monaco utilities, including loading the model for the base file URI,
237
- * setting the value to the intended state, and running code actions on save.
238
- */
239
- async applyChangesWithMonaco(contents) {
240
- let modelReference;
241
- try {
242
- modelReference = await this.monacoTextModelService.createModelReference(this.uri);
243
- const model = modelReference.object;
244
- const targetContent = contents !== null && contents !== void 0 ? contents : this.targetState;
245
- model.textEditorModel.setValue(targetContent);
246
- const languageId = model.languageId;
247
- const uriStr = this.uri.toString();
248
- await this.codeActionService.applyOnSaveCodeActions(model.textEditorModel, languageId, uriStr, core_1.CancellationToken.None);
249
- await this.applyFormatting(model, languageId, uriStr);
250
- await model.save();
251
- this.state = 'applied';
252
- }
253
- catch (error) {
254
- console.error('Failed to apply changes with Monaco:', error);
255
- await this.writeChanges(contents);
256
- }
257
- finally {
258
- modelReference === null || modelReference === void 0 ? void 0 : modelReference.dispose();
259
- }
260
- }
261
- applyCodeActionsToTargetState() {
262
- if (!this.codeActionDeferred) {
263
- this.codeActionDeferred = new promise_util_1.Deferred();
264
- this.codeActionDeferred.resolve(this.doApplyCodeActionsToTargetState());
265
- }
266
- return this.codeActionDeferred.promise;
267
- }
268
- async doApplyCodeActionsToTargetState() {
269
- var _a, _b;
270
- const targetState = this.originalTargetState;
271
- if (!targetState) {
272
- this._targetStateWithCodeActions = '';
273
- return this._targetStateWithCodeActions;
274
- }
275
- let tempResource;
276
- let tempModel;
277
- try {
278
- // Create a temporary model to apply code actions
279
- const tempUri = core_1.URI.fromComponents({
280
- scheme: 'untitled',
281
- path: this.uri.path.toString(),
282
- authority: `changeset-${this.elementProps.chatSessionId}`,
283
- query: '',
284
- fragment: ''
285
- });
286
- tempResource = this.getInMemoryUri(tempUri);
287
- tempResource.update({ contents: this.targetState });
288
- tempModel = await this.monacoTextModelService.createModelReference(tempUri);
289
- tempModel.object.suppressOpenEditorWhenDirty = true;
290
- tempModel.object.textEditorModel.setValue(this.targetState);
291
- const languageId = tempModel.object.languageId;
292
- const uriStr = this.uri.toString();
293
- await this.codeActionService.applyOnSaveCodeActions(tempModel.object.textEditorModel, languageId, uriStr, core_1.CancellationToken.None);
294
- // Apply formatting and other editor preferences
295
- await this.applyFormatting(tempModel.object, languageId, uriStr);
296
- this._targetStateWithCodeActions = tempModel.object.textEditorModel.getValue();
297
- if (((_a = this._changeResource) === null || _a === void 0 ? void 0 : _a.contents) === this.elementProps.targetState) {
298
- (_b = this._changeResource) === null || _b === void 0 ? void 0 : _b.update({ contents: this.targetState });
299
- }
300
- }
301
- catch (error) {
302
- console.warn('Failed to apply code actions to target state:', error);
303
- this._targetStateWithCodeActions = targetState;
304
- }
305
- finally {
306
- tempModel === null || tempModel === void 0 ? void 0 : tempModel.dispose();
307
- tempResource === null || tempResource === void 0 ? void 0 : tempResource.dispose();
308
- }
309
- return this.targetState;
310
- }
311
- /**
312
- * Applies formatting preferences like format on save, trim trailing whitespace, and insert final newline.
313
- */
314
- async applyFormatting(model, languageId, uriStr) {
315
- try {
316
- const formatOnSave = this.editorPreferences.get({ preferenceName: 'editor.formatOnSave', overrideIdentifier: languageId }, undefined, uriStr);
317
- if (formatOnSave) {
318
- const instantiation = standaloneServices_1.StandaloneServices.get(instantiation_1.IInstantiationService);
319
- await instantiation.invokeFunction(format_1.formatDocumentWithSelectedProvider, model.textEditorModel, 1 /* FormattingMode.Explicit */, { report() { } }, core_1.CancellationToken.None, true);
320
- }
321
- const trimTrailingWhitespace = this.fileSystemPreferences.get({ preferenceName: 'files.trimTrailingWhitespace', overrideIdentifier: languageId }, undefined, uriStr);
322
- if (trimTrailingWhitespace) {
323
- const ttws = new trimTrailingWhitespaceCommand_1.TrimTrailingWhitespaceCommand(new selection_1.Selection(1, 1, 1, 1), [], false);
324
- cursor_1.CommandExecutor.executeCommands(model.textEditorModel, [], [ttws]);
325
- }
326
- const shouldInsertFinalNewline = this.fileSystemPreferences.get({ preferenceName: 'files.insertFinalNewline', overrideIdentifier: languageId }, undefined, uriStr);
327
- if (shouldInsertFinalNewline) {
328
- (0, monaco_utilities_1.insertFinalNewline)(model);
329
- }
330
- }
331
- catch (error) {
332
- console.warn('Failed to apply formatting:', error);
333
- }
334
- }
335
- onShow() {
336
- this.changeResource.update({
337
- contents: this.targetState,
338
- onSave: async (content) => {
339
- // Use Monaco utilities when saving from the change resource
340
- await this.applyChangesWithMonaco(content);
341
- }
342
- });
343
- }
344
- async revert() {
345
- await this.ensureInitialized();
346
- if (!await this.confirm('Revert')) {
347
- return;
348
- }
349
- this.state = 'pending';
350
- if (this.type === 'add') {
351
- await this.changeSetFileService.delete(this.uri);
352
- }
353
- else if (this._originalContent) {
354
- await this.changeSetFileService.write(this.uri, this._originalContent);
355
- }
356
- }
357
- async confirm(verb) {
358
- if (this._state !== 'stale') {
359
- return true;
360
- }
361
- await this.openChange();
362
- const answer = await new browser_1.ConfirmDialog({
363
- title: verb === 'Apply'
364
- ? core_1.nls.localize('theia/ai/chat/applySuggestion', 'Apply suggestion')
365
- : core_1.nls.localize('theia/ai/chat/revertSuggestion', 'Revert suggestion'),
366
- msg: verb === 'Apply'
367
- ? core_1.nls.localize('theia/ai/chat/confirmApplySuggestion', 'The file {0} has changed since this suggestion was created. Are you certain you wish to apply the change?', this.uri.path.toString())
368
- : core_1.nls.localize('theia/ai/chat/confirmRevertSuggestion', 'The file {0} has changed since this suggestion was created. Are you certain you wish to revert the change?', this.uri.path.toString())
369
- }).open(true);
370
- return !!answer;
371
- }
372
- toSerializable() {
373
- return {
374
- kind: 'file',
375
- uri: this.uri.toString(),
376
- name: this.name,
377
- icon: this.icon,
378
- additionalInfo: this.additionalInfo,
379
- state: this.state,
380
- type: this.type,
381
- data: {
382
- ...this.data,
383
- targetState: this.elementProps.targetState,
384
- originalState: this._originalContent,
385
- replacements: this.replacements
386
- }
387
- };
388
- }
389
- dispose() {
390
- this.toDispose.dispose();
391
- }
392
- };
393
- exports.ChangeSetFileElement = ChangeSetFileElement;
394
- tslib_1.__decorate([
395
- (0, inversify_1.inject)(exports.ChangeSetElementArgs),
396
- tslib_1.__metadata("design:type", Object)
397
- ], ChangeSetFileElement.prototype, "elementProps", void 0);
398
- tslib_1.__decorate([
399
- (0, inversify_1.inject)(change_set_file_service_1.ChangeSetFileService),
400
- tslib_1.__metadata("design:type", change_set_file_service_1.ChangeSetFileService)
401
- ], ChangeSetFileElement.prototype, "changeSetFileService", void 0);
402
- tslib_1.__decorate([
403
- (0, inversify_1.inject)(file_service_1.FileService),
404
- tslib_1.__metadata("design:type", file_service_1.FileService)
405
- ], ChangeSetFileElement.prototype, "fileService", void 0);
406
- tslib_1.__decorate([
407
- (0, inversify_1.inject)(ai_core_1.ConfigurableInMemoryResources),
408
- tslib_1.__metadata("design:type", ai_core_1.ConfigurableInMemoryResources)
409
- ], ChangeSetFileElement.prototype, "inMemoryResources", void 0);
410
- tslib_1.__decorate([
411
- (0, inversify_1.inject)(monaco_text_model_service_1.MonacoTextModelService),
412
- tslib_1.__metadata("design:type", monaco_text_model_service_1.MonacoTextModelService)
413
- ], ChangeSetFileElement.prototype, "monacoTextModelService", void 0);
414
- tslib_1.__decorate([
415
- (0, inversify_1.inject)(editor_preferences_1.EditorPreferences),
416
- tslib_1.__metadata("design:type", Object)
417
- ], ChangeSetFileElement.prototype, "editorPreferences", void 0);
418
- tslib_1.__decorate([
419
- (0, inversify_1.inject)(common_1.FileSystemPreferences),
420
- tslib_1.__metadata("design:type", Object)
421
- ], ChangeSetFileElement.prototype, "fileSystemPreferences", void 0);
422
- tslib_1.__decorate([
423
- (0, inversify_1.inject)(browser_2.MonacoCodeActionService),
424
- tslib_1.__metadata("design:type", Object)
425
- ], ChangeSetFileElement.prototype, "codeActionService", void 0);
426
- tslib_1.__decorate([
427
- (0, inversify_1.postConstruct)(),
428
- tslib_1.__metadata("design:type", Function),
429
- tslib_1.__metadata("design:paramtypes", []),
430
- tslib_1.__metadata("design:returntype", void 0)
431
- ], ChangeSetFileElement.prototype, "init", null);
432
- exports.ChangeSetFileElement = ChangeSetFileElement = ChangeSetFileElement_1 = tslib_1.__decorate([
433
- (0, inversify_1.injectable)()
434
- ], ChangeSetFileElement);
435
- //# sourceMappingURL=change-set-file-element.js.map