@aws/lsp-codewhisperer 0.0.29 → 0.0.31

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 (232) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/README.md +1 -1
  4. package/out/client/streamingClient/codewhispererStreamingClient.js +1 -0
  5. package/out/client/streamingClient/codewhispererStreamingClient.js.map +1 -1
  6. package/out/index.d.ts +6 -5
  7. package/out/index.js +7 -5
  8. package/out/index.js.map +1 -1
  9. package/out/language-server/agenticChat/agenticChatController.d.ts +40 -0
  10. package/out/language-server/agenticChat/agenticChatController.js +414 -0
  11. package/out/language-server/agenticChat/agenticChatController.js.map +1 -0
  12. package/out/language-server/agenticChat/qAgenticChatServer.d.ts +6 -0
  13. package/out/language-server/agenticChat/qAgenticChatServer.js +96 -0
  14. package/out/language-server/agenticChat/qAgenticChatServer.js.map +1 -0
  15. package/out/language-server/agenticChat/tools/fsRead.d.ts +38 -0
  16. package/out/language-server/agenticChat/tools/fsRead.js +96 -0
  17. package/out/language-server/agenticChat/tools/fsRead.js.map +1 -0
  18. package/out/language-server/agenticChat/tools/fsWrite.d.ts +73 -0
  19. package/out/language-server/agenticChat/tools/fsWrite.js +128 -0
  20. package/out/language-server/agenticChat/tools/fsWrite.js.map +1 -0
  21. package/out/language-server/agenticChat/tools/toolServer.d.ts +2 -0
  22. package/out/language-server/agenticChat/tools/toolServer.js +14 -0
  23. package/out/language-server/agenticChat/tools/toolServer.js.map +1 -0
  24. package/out/language-server/agenticChat/tools/toolShared.d.ts +7 -0
  25. package/out/language-server/agenticChat/tools/toolShared.js +5 -0
  26. package/out/language-server/agenticChat/tools/toolShared.js.map +1 -0
  27. package/out/language-server/chat/agents/docGeneration/constants.d.ts +59 -0
  28. package/out/language-server/chat/agents/docGeneration/constants.js +147 -0
  29. package/out/language-server/chat/agents/docGeneration/constants.js.map +1 -0
  30. package/out/language-server/chat/agents/docGeneration/errors.d.ts +29 -0
  31. package/out/language-server/chat/agents/docGeneration/errors.js +67 -0
  32. package/out/language-server/chat/agents/docGeneration/errors.js.map +1 -0
  33. package/out/language-server/chat/agents/shared/i18n.d.ts +1 -0
  34. package/out/language-server/chat/agents/shared/i18n.js +7 -0
  35. package/out/language-server/chat/agents/shared/i18n.js.map +1 -0
  36. package/out/language-server/chat/agents/shared/types.d.ts +55 -0
  37. package/out/language-server/chat/agents/shared/types.js +46 -0
  38. package/out/language-server/chat/agents/shared/types.js.map +1 -0
  39. package/out/language-server/chat/chatController.d.ts +9 -6
  40. package/out/language-server/chat/chatController.js +74 -27
  41. package/out/language-server/chat/chatController.js.map +1 -1
  42. package/out/language-server/chat/chatEventParser.d.ts +2 -2
  43. package/out/language-server/chat/chatSessionManagementService.d.ts +1 -1
  44. package/out/language-server/chat/chatSessionService.d.ts +1 -1
  45. package/out/language-server/chat/chatSessionService.js +1 -3
  46. package/out/language-server/chat/chatSessionService.js.map +1 -1
  47. package/out/language-server/chat/contexts/documentContext.d.ts +2 -0
  48. package/out/language-server/chat/contexts/documentContext.js +15 -2
  49. package/out/language-server/chat/contexts/documentContext.js.map +1 -1
  50. package/out/language-server/chat/contexts/triggerContext.d.ts +5 -5
  51. package/out/language-server/chat/contexts/triggerContext.js +3 -3
  52. package/out/language-server/chat/contexts/triggerContext.js.map +1 -1
  53. package/out/language-server/{qChatServer.js → chat/qChatServer.js} +15 -11
  54. package/out/language-server/chat/qChatServer.js.map +1 -0
  55. package/out/language-server/chat/telemetry/chatTelemetryController.d.ts +3 -3
  56. package/out/language-server/chat/telemetry/chatTelemetryController.js +3 -3
  57. package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
  58. package/out/language-server/chat/telemetry/clientTelemetry.js +1 -1
  59. package/out/language-server/chat/telemetry/clientTelemetry.js.map +1 -1
  60. package/out/language-server/chat/utils.js +1 -1
  61. package/out/language-server/chat/utils.js.map +1 -1
  62. package/out/language-server/configuration/qConfigurationServer.d.ts +2 -2
  63. package/out/language-server/configuration/qConfigurationServer.js +2 -2
  64. package/out/language-server/configuration/qConfigurationServer.js.map +1 -1
  65. package/out/language-server/{auto-trigger → inline-completion/auto-trigger}/autoTrigger.d.ts +1 -1
  66. package/out/language-server/inline-completion/auto-trigger/autoTrigger.js.map +1 -0
  67. package/out/language-server/{telemetry → inline-completion}/codeDiffTracker.js +1 -1
  68. package/out/language-server/inline-completion/codeDiffTracker.js.map +1 -0
  69. package/out/language-server/{telemetry → inline-completion}/codePercentage.d.ts +1 -1
  70. package/out/language-server/inline-completion/codePercentage.js.map +1 -0
  71. package/out/language-server/inline-completion/codeWhispererServer.d.ts +7 -0
  72. package/out/language-server/{codeWhispererServer.js → inline-completion/codeWhispererServer.js} +37 -75
  73. package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -0
  74. package/out/language-server/inline-completion/mergeRightUtils.js.map +1 -0
  75. package/out/language-server/{session → inline-completion/session}/sessionManager.d.ts +3 -3
  76. package/out/language-server/inline-completion/session/sessionManager.js.map +1 -0
  77. package/out/language-server/netTransform/artifactManager.d.ts +7 -7
  78. package/out/language-server/netTransform/artifactManager.js +86 -46
  79. package/out/language-server/netTransform/artifactManager.js.map +1 -1
  80. package/out/language-server/netTransform/metrics.js +1 -1
  81. package/out/language-server/netTransform/metrics.js.map +1 -1
  82. package/out/language-server/netTransform/models.d.ts +12 -0
  83. package/out/language-server/netTransform/models.js.map +1 -1
  84. package/out/language-server/{netTransformServer.d.ts → netTransform/netTransformServer.d.ts} +1 -1
  85. package/out/language-server/{netTransformServer.js → netTransform/netTransformServer.js} +5 -5
  86. package/out/language-server/netTransform/netTransformServer.js.map +1 -0
  87. package/out/language-server/netTransform/tests/mockData.d.ts +2 -21
  88. package/out/language-server/netTransform/tests/mockData.js +16 -13
  89. package/out/language-server/netTransform/tests/mockData.js.map +1 -1
  90. package/out/language-server/netTransform/transformHandler.d.ts +3 -1
  91. package/out/language-server/netTransform/transformHandler.js +49 -15
  92. package/out/language-server/netTransform/transformHandler.js.map +1 -1
  93. package/out/language-server/{codeWhispererSecurityScanServer.js → securityScan/codeWhispererSecurityScanServer.js} +5 -5
  94. package/out/language-server/securityScan/codeWhispererSecurityScanServer.js.map +1 -0
  95. package/out/language-server/securityScan/dependencyGraph/commonUtil.js.map +1 -0
  96. package/out/language-server/securityScan/dependencyGraph/constants.js.map +1 -0
  97. package/out/language-server/securityScan/dependencyGraph/csharpDependencyGraph.js.map +1 -0
  98. package/out/language-server/securityScan/dependencyGraph/dependencyGraph.js.map +1 -0
  99. package/out/language-server/securityScan/dependencyGraph/dependencyGraphFactory.js.map +1 -0
  100. package/out/language-server/securityScan/securityScanHandler.d.ts +1 -1
  101. package/out/language-server/securityScan/securityScanHandler.js +1 -1
  102. package/out/language-server/securityScan/securityScanHandler.js.map +1 -1
  103. package/out/{language-server → shared}/amazonQServiceManager/AmazonQTokenServiceManager.d.ts +6 -3
  104. package/out/{language-server → shared}/amazonQServiceManager/AmazonQTokenServiceManager.js +48 -84
  105. package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -0
  106. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.d.ts +7 -0
  107. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js.map +1 -0
  108. package/out/shared/amazonQServiceManager/configurationUtils.d.ts +45 -0
  109. package/out/shared/amazonQServiceManager/configurationUtils.js +130 -0
  110. package/out/shared/amazonQServiceManager/configurationUtils.js.map +1 -0
  111. package/out/shared/amazonQServiceManager/errors.js.map +1 -0
  112. package/out/shared/amazonQServiceManager/factories.d.ts +15 -0
  113. package/out/shared/amazonQServiceManager/factories.js +47 -0
  114. package/out/shared/amazonQServiceManager/factories.js.map +1 -0
  115. package/out/{language-server → shared}/amazonQServiceManager/qDeveloperProfiles.d.ts +1 -3
  116. package/out/{language-server → shared}/amazonQServiceManager/qDeveloperProfiles.js +2 -2
  117. package/out/shared/amazonQServiceManager/qDeveloperProfiles.js.map +1 -0
  118. package/out/shared/codeWhispererService.js.map +1 -0
  119. package/out/{language-server → shared}/constants.d.ts +5 -0
  120. package/out/shared/constants.js +16 -0
  121. package/out/shared/constants.js.map +1 -0
  122. package/out/shared/languageDetection.js.map +1 -0
  123. package/out/shared/models/constants.js.map +1 -0
  124. package/out/shared/models/model.js.map +1 -0
  125. package/out/{language-server → shared}/proxy-server.d.ts +1 -0
  126. package/out/shared/proxy-server.js +21 -0
  127. package/out/shared/proxy-server.js.map +1 -0
  128. package/out/shared/streamingClientService.d.ts +10 -0
  129. package/out/shared/streamingClientService.js +42 -0
  130. package/out/shared/streamingClientService.js.map +1 -0
  131. package/out/shared/supplementalContextUtil/codeParsingUtil.js.map +1 -0
  132. package/out/{language-server/utilities → shared}/supplementalContextUtil/crossFileContextUtil.d.ts +1 -1
  133. package/out/{language-server/utilities → shared}/supplementalContextUtil/crossFileContextUtil.js +1 -1
  134. package/out/shared/supplementalContextUtil/crossFileContextUtil.js.map +1 -0
  135. package/out/shared/supplementalContextUtil/rankBm25.js.map +1 -0
  136. package/out/{language-server/utilities → shared}/supplementalContextUtil/supplementalContextUtil.d.ts +1 -1
  137. package/out/shared/supplementalContextUtil/supplementalContextUtil.js.map +1 -0
  138. package/out/shared/telemetry/metric.js.map +1 -0
  139. package/out/{language-server → shared/telemetry}/telemetryService.d.ts +5 -5
  140. package/out/{language-server → shared/telemetry}/telemetryService.js +4 -4
  141. package/out/shared/telemetry/telemetryService.js.map +1 -0
  142. package/out/{language-server → shared}/telemetry/types.d.ts +2 -2
  143. package/out/shared/telemetry/types.js.map +1 -0
  144. package/out/{language-server/utilities → shared}/telemetryUtils.d.ts +1 -1
  145. package/out/shared/telemetryUtils.js.map +1 -0
  146. package/out/shared/testUtils.js.map +1 -0
  147. package/out/shared/utils.js.map +1 -0
  148. package/package.json +4 -4
  149. package/out/constants.d.ts +0 -8
  150. package/out/constants.js +0 -12
  151. package/out/constants.js.map +0 -1
  152. package/out/language-server/amazonQServiceManager/AmazonQTokenServiceManager.js.map +0 -1
  153. package/out/language-server/amazonQServiceManager/BaseAmazonQServiceManager.d.ts +0 -5
  154. package/out/language-server/amazonQServiceManager/BaseAmazonQServiceManager.js.map +0 -1
  155. package/out/language-server/amazonQServiceManager/errors.js.map +0 -1
  156. package/out/language-server/amazonQServiceManager/qDeveloperProfiles.js.map +0 -1
  157. package/out/language-server/auto-trigger/autoTrigger.js.map +0 -1
  158. package/out/language-server/codeWhispererSecurityScanServer.js.map +0 -1
  159. package/out/language-server/codeWhispererServer.d.ts +0 -6
  160. package/out/language-server/codeWhispererServer.js.map +0 -1
  161. package/out/language-server/codeWhispererService.js.map +0 -1
  162. package/out/language-server/constants.js +0 -8
  163. package/out/language-server/constants.js.map +0 -1
  164. package/out/language-server/dependencyGraph/commonUtil.js.map +0 -1
  165. package/out/language-server/dependencyGraph/constants.js.map +0 -1
  166. package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +0 -1
  167. package/out/language-server/dependencyGraph/dependencyGraph.js.map +0 -1
  168. package/out/language-server/dependencyGraph/dependencyGraphFactory.js.map +0 -1
  169. package/out/language-server/languageDetection.js.map +0 -1
  170. package/out/language-server/mergeRightUtils.js.map +0 -1
  171. package/out/language-server/models/constants.js.map +0 -1
  172. package/out/language-server/models/model.js.map +0 -1
  173. package/out/language-server/netTransformServer.js.map +0 -1
  174. package/out/language-server/proxy-server.js +0 -22
  175. package/out/language-server/proxy-server.js.map +0 -1
  176. package/out/language-server/qChatServer.js.map +0 -1
  177. package/out/language-server/session/sessionManager.js.map +0 -1
  178. package/out/language-server/telemetry/codeDiffTracker.js.map +0 -1
  179. package/out/language-server/telemetry/codePercentage.js.map +0 -1
  180. package/out/language-server/telemetry/metric.js.map +0 -1
  181. package/out/language-server/telemetry/types.js.map +0 -1
  182. package/out/language-server/telemetryService.js.map +0 -1
  183. package/out/language-server/testUtils.js.map +0 -1
  184. package/out/language-server/utilities/supplementalContextUtil/codeParsingUtil.js.map +0 -1
  185. package/out/language-server/utilities/supplementalContextUtil/crossFileContextUtil.js.map +0 -1
  186. package/out/language-server/utilities/supplementalContextUtil/rankBm25.js.map +0 -1
  187. package/out/language-server/utilities/supplementalContextUtil/supplementalContextUtil.js.map +0 -1
  188. package/out/language-server/utilities/telemetryUtils.js.map +0 -1
  189. package/out/language-server/utils.js.map +0 -1
  190. /package/out/language-server/{qChatServer.d.ts → chat/qChatServer.d.ts} +0 -0
  191. /package/out/language-server/{auto-trigger → inline-completion/auto-trigger}/autoTrigger.js +0 -0
  192. /package/out/language-server/{auto-trigger → inline-completion/auto-trigger}/coefficients.json +0 -0
  193. /package/out/language-server/{telemetry → inline-completion}/codeDiffTracker.d.ts +0 -0
  194. /package/out/language-server/{telemetry → inline-completion}/codePercentage.js +0 -0
  195. /package/out/language-server/{mergeRightUtils.d.ts → inline-completion/mergeRightUtils.d.ts} +0 -0
  196. /package/out/language-server/{mergeRightUtils.js → inline-completion/mergeRightUtils.js} +0 -0
  197. /package/out/language-server/{session → inline-completion/session}/sessionManager.js +0 -0
  198. /package/out/language-server/{codeWhispererSecurityScanServer.d.ts → securityScan/codeWhispererSecurityScanServer.d.ts} +0 -0
  199. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/commonUtil.d.ts +0 -0
  200. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/commonUtil.js +0 -0
  201. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/constants.d.ts +0 -0
  202. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/constants.js +0 -0
  203. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/csharpDependencyGraph.d.ts +0 -0
  204. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/csharpDependencyGraph.js +0 -0
  205. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/dependencyGraph.d.ts +0 -0
  206. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/dependencyGraph.js +0 -0
  207. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/dependencyGraphFactory.d.ts +0 -0
  208. /package/out/language-server/{dependencyGraph → securityScan/dependencyGraph}/dependencyGraphFactory.js +0 -0
  209. /package/out/{language-server → shared}/amazonQServiceManager/BaseAmazonQServiceManager.js +0 -0
  210. /package/out/{language-server → shared}/amazonQServiceManager/errors.d.ts +0 -0
  211. /package/out/{language-server → shared}/amazonQServiceManager/errors.js +0 -0
  212. /package/out/{language-server → shared}/codeWhispererService.d.ts +0 -0
  213. /package/out/{language-server → shared}/codeWhispererService.js +0 -0
  214. /package/out/{language-server → shared}/languageDetection.d.ts +0 -0
  215. /package/out/{language-server → shared}/languageDetection.js +0 -0
  216. /package/out/{language-server → shared}/models/constants.d.ts +0 -0
  217. /package/out/{language-server → shared}/models/constants.js +0 -0
  218. /package/out/{language-server → shared}/models/model.d.ts +0 -0
  219. /package/out/{language-server → shared}/models/model.js +0 -0
  220. /package/out/{language-server/utilities → shared}/supplementalContextUtil/codeParsingUtil.d.ts +0 -0
  221. /package/out/{language-server/utilities → shared}/supplementalContextUtil/codeParsingUtil.js +0 -0
  222. /package/out/{language-server/utilities → shared}/supplementalContextUtil/rankBm25.d.ts +0 -0
  223. /package/out/{language-server/utilities → shared}/supplementalContextUtil/rankBm25.js +0 -0
  224. /package/out/{language-server/utilities → shared}/supplementalContextUtil/supplementalContextUtil.js +0 -0
  225. /package/out/{language-server → shared}/telemetry/metric.d.ts +0 -0
  226. /package/out/{language-server → shared}/telemetry/metric.js +0 -0
  227. /package/out/{language-server → shared}/telemetry/types.js +0 -0
  228. /package/out/{language-server/utilities → shared}/telemetryUtils.js +0 -0
  229. /package/out/{language-server → shared}/testUtils.d.ts +0 -0
  230. /package/out/{language-server → shared}/testUtils.js +0 -0
  231. /package/out/{language-server → shared}/utils.d.ts +0 -0
  232. /package/out/{language-server → shared}/utils.js +0 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * Copied from ../qChatServer.ts for the purpose of developing a divergent implementation.
4
+ * Will be deleted or merged.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.QAgenticChatServer = void 0;
8
+ const agenticChatController_1 = require("./agenticChatController");
9
+ const chatSessionManagementService_1 = require("../chat/chatSessionManagementService");
10
+ const quickActions_1 = require("../chat/quickActions");
11
+ const telemetryService_1 = require("../../shared/telemetry/telemetryService");
12
+ const telemetryUtils_1 = require("../../shared/telemetryUtils");
13
+ const AmazonQTokenServiceManager_1 = require("../../shared/amazonQServiceManager/AmazonQTokenServiceManager");
14
+ const utils_1 = require("../../shared/utils");
15
+ const errors_1 = require("../../shared/amazonQServiceManager/errors");
16
+ const QAgenticChatServer =
17
+ // prettier-ignore
18
+ () => features => {
19
+ const { chat, credentialsProvider, telemetry, logging, lsp, runtime } = features;
20
+ let amazonQServiceManager;
21
+ let chatController;
22
+ let chatSessionManagementService;
23
+ let telemetryService;
24
+ lsp.addInitializer((params) => {
25
+ return {
26
+ capabilities: {},
27
+ awsServerCapabilities: {
28
+ chatOptions: {
29
+ quickActions: {
30
+ quickActionsCommandGroups: [
31
+ {
32
+ commands: [quickActions_1.HELP_QUICK_ACTION, quickActions_1.CLEAR_QUICK_ACTION],
33
+ },
34
+ ],
35
+ },
36
+ },
37
+ },
38
+ };
39
+ });
40
+ const updateConfigurationHandler = async () => {
41
+ const amazonQConfig = await amazonQServiceManager.handleDidChangeConfiguration();
42
+ chatController.updateConfiguration(amazonQConfig);
43
+ };
44
+ lsp.onInitialized(async () => {
45
+ // Initialize service manager and inject it to chatSessionManagementService to pass it down
46
+ amazonQServiceManager = AmazonQTokenServiceManager_1.AmazonQTokenServiceManager.getInstance(features);
47
+ chatSessionManagementService = chatSessionManagementService_1.ChatSessionManagementService
48
+ .getInstance()
49
+ .withAmazonQServiceManager(amazonQServiceManager);
50
+ telemetryService = new telemetryService_1.TelemetryService(amazonQServiceManager, credentialsProvider, telemetry, logging);
51
+ const clientParams = (0, utils_1.safeGet)(lsp.getClientInitializeParams(), new errors_1.AmazonQServiceInitializationError('TelemetryService initialized before LSP connection was initialized.'));
52
+ telemetryService.updateUserContext((0, telemetryUtils_1.makeUserContextObject)(clientParams, runtime.platform, 'CHAT'));
53
+ chatController = new agenticChatController_1.AgenticChatController(chatSessionManagementService, features, telemetryService, amazonQServiceManager);
54
+ await updateConfigurationHandler();
55
+ });
56
+ lsp.didChangeConfiguration(updateConfigurationHandler);
57
+ chat.onTabAdd(params => {
58
+ logging.log(`Adding tab: ${params.tabId}`);
59
+ return chatController.onTabAdd(params);
60
+ });
61
+ chat.onTabChange(params => {
62
+ logging.log(`Changing to tab: ${params.tabId}`);
63
+ return chatController.onTabChange(params);
64
+ });
65
+ chat.onTabRemove(params => {
66
+ logging.log(`Removing tab: ${params.tabId}`);
67
+ return chatController.onTabRemove(params);
68
+ });
69
+ chat.onEndChat((...params) => {
70
+ logging.log('Received end chat request');
71
+ return chatController.onEndChat(...params);
72
+ });
73
+ chat.onChatPrompt((...params) => {
74
+ logging.log('Received chat prompt');
75
+ return chatController.onChatPrompt(...params);
76
+ });
77
+ chat.onInlineChatPrompt((...params) => {
78
+ logging.log('Received inline chat prompt');
79
+ return chatController.onInlineChatPrompt(...params);
80
+ });
81
+ chat.onQuickAction((...params) => {
82
+ return chatController.onQuickAction(...params);
83
+ });
84
+ chat.onSendFeedback(params => {
85
+ return chatController.onSendFeedback(params);
86
+ });
87
+ chat.onCodeInsertToCursorPosition(params => {
88
+ return chatController.onCodeInsertToCursorPosition(params);
89
+ });
90
+ logging.log('Q Chat server has been initialized');
91
+ return () => {
92
+ chatController?.dispose();
93
+ };
94
+ };
95
+ exports.QAgenticChatServer = QAgenticChatServer;
96
+ //# sourceMappingURL=qAgenticChatServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qAgenticChatServer.js","sourceRoot":"","sources":["../../../src/language-server/agenticChat/qAgenticChatServer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mEAA+D;AAC/D,uFAAmF;AACnF,uDAA4E;AAC5E,8EAA0E;AAC1E,gEAAmE;AACnE,8G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AAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACnC,OAAO,cAAc,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kBAAkB,CAAC,CAAC,GAAG,MAAM,EAAE,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1C,OAAO,cAAc,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,MAAM,EAAE,EAAE;QAC7B,OAAO,cAAc,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,4BAA4B,CAAC,MAAM,CAAC,EAAE;QACvC,OAAO,cAAc,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAA;IAEjD,OAAO,GAAG,EAAE;QACR,cAAc,EAAE,OAAO,EAAE,CAAA;IAC7B,CAAC,CAAA;AACL,CAAC,CAAA;AA3GQ,QAAA,kBAAkB,sBA2G1B"}
@@ -0,0 +1,38 @@
1
+ import { InvokeOutput } from './toolShared';
2
+ import { Features } from '@aws/language-server-runtimes/server-interface/server';
3
+ export interface FsReadParams {
4
+ path: string;
5
+ readRange?: number[];
6
+ }
7
+ export declare class FsRead {
8
+ private readonly logging;
9
+ private readonly workspace;
10
+ constructor(features: Pick<Features, 'workspace' | 'logging'> & Partial<Features>);
11
+ invoke(params: FsReadParams): Promise<InvokeOutput>;
12
+ private readFile;
13
+ private handleFileRange;
14
+ private parseLineRange;
15
+ private enforceMaxSize;
16
+ private createOutput;
17
+ getSpec(): {
18
+ readonly name: "fsRead";
19
+ readonly description: "A tool for reading a file. \n* This tool returns the contents of a file, and the optional `readRange` determines what range of lines will be read from the specified file.";
20
+ readonly inputSchema: {
21
+ readonly type: "object";
22
+ readonly parameters: {
23
+ readonly path: {
24
+ readonly description: "Absolute path to a file, e.g. `/repo/file.py`.";
25
+ readonly type: "string";
26
+ };
27
+ readonly readRange: {
28
+ readonly description: "Optional parameter when reading files.\n* If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[startLine, -1]` shows all lines from `startLine` to the end of the file.";
29
+ readonly items: {
30
+ readonly type: "integer";
31
+ };
32
+ readonly type: "array";
33
+ };
34
+ };
35
+ readonly required: readonly ["path"];
36
+ };
37
+ };
38
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FsRead = void 0;
4
+ /*!
5
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ * SPDX-License-Identifier: Apache-2.0
7
+ */
8
+ const path_1 = require("@aws/lsp-core/out/util/path");
9
+ const toolShared_1 = require("./toolShared");
10
+ class FsRead {
11
+ logging;
12
+ workspace;
13
+ constructor(features) {
14
+ this.logging = features.logging;
15
+ this.workspace = features.workspace;
16
+ }
17
+ async invoke(params) {
18
+ const path = (0, path_1.sanitize)(params.path);
19
+ const fileContents = await this.readFile(path);
20
+ this.logging.info(`Read file: ${path}, size: ${fileContents.length}`);
21
+ return this.handleFileRange(params, fileContents);
22
+ }
23
+ async readFile(filePath) {
24
+ this.logging.info(`Reading file: ${filePath}`);
25
+ return await this.workspace.fs.readFile(filePath);
26
+ }
27
+ handleFileRange(params, fullText) {
28
+ if (!params.readRange || params.readRange.length === 0) {
29
+ this.logging.log('No range provided. returning entire file.');
30
+ return this.createOutput(this.enforceMaxSize(fullText));
31
+ }
32
+ const lines = fullText.split('\n');
33
+ const [start, end] = this.parseLineRange(lines.length, params.readRange);
34
+ if (start > end) {
35
+ this.logging.error(`Invalid range: ${params.readRange.join('-')}`);
36
+ return this.createOutput('');
37
+ }
38
+ this.logging.log(`Reading file: ${params.path}, lines ${start + 1}-${end + 1}`);
39
+ const slice = lines.slice(start, end + 1).join('\n');
40
+ return this.createOutput(this.enforceMaxSize(slice));
41
+ }
42
+ parseLineRange(lineCount, range) {
43
+ const startIdx = range[0];
44
+ let endIdx = range.length >= 2 ? range[1] : undefined;
45
+ if (endIdx === undefined) {
46
+ endIdx = -1;
47
+ }
48
+ const convert = (i) => {
49
+ return i < 0 ? lineCount + i : i - 1;
50
+ };
51
+ const finalStart = Math.max(0, Math.min(lineCount - 1, convert(startIdx)));
52
+ const finalEnd = Math.max(0, Math.min(lineCount - 1, convert(endIdx)));
53
+ return [finalStart, finalEnd];
54
+ }
55
+ enforceMaxSize(content) {
56
+ const byteCount = Buffer.byteLength(content, 'utf8');
57
+ if (byteCount > toolShared_1.maxToolResponseSize) {
58
+ throw new Error(`This tool only supports reading ${toolShared_1.maxToolResponseSize} bytes at a time.
59
+ You tried to read ${byteCount} bytes. Try executing with fewer lines specified.`);
60
+ }
61
+ return content;
62
+ }
63
+ createOutput(content) {
64
+ return {
65
+ output: {
66
+ kind: 'text',
67
+ content: content,
68
+ },
69
+ };
70
+ }
71
+ getSpec() {
72
+ return {
73
+ name: 'fsRead',
74
+ description: 'A tool for reading a file. \n* This tool returns the contents of a file, and the optional `readRange` determines what range of lines will be read from the specified file.',
75
+ inputSchema: {
76
+ type: 'object',
77
+ parameters: {
78
+ path: {
79
+ description: 'Absolute path to a file, e.g. `/repo/file.py`.',
80
+ type: 'string',
81
+ },
82
+ readRange: {
83
+ description: 'Optional parameter when reading files.\n* If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[startLine, -1]` shows all lines from `startLine` to the end of the file.',
84
+ items: {
85
+ type: 'integer',
86
+ },
87
+ type: 'array',
88
+ },
89
+ },
90
+ required: ['path'],
91
+ },
92
+ };
93
+ }
94
+ }
95
+ exports.FsRead = FsRead;
96
+ //# sourceMappingURL=fsRead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsRead.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/tools/fsRead.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,sDAAsD;AACtD,6CAAgE;AAUhE,MAAa,MAAM;IACE,OAAO,CAAqB;IAC5B,SAAS,CAAuB;IAEjD,YAAY,QAAqE;QAC7E,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;IACvC,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,MAAoB;QACpC,MAAM,IAAI,GAAG,IAAA,eAAQ,EAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,IAAI,WAAW,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;QACrE,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACrD,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,QAAgB;QACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAA;QAC9C,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACrD,CAAC;IAEO,eAAe,CAAC,MAAoB,EAAE,QAAgB;QAC1D,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,GAAG,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AE,OAAO;qBAChB;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACrB;SACK,CAAA;IACd,CAAC;CACJ;AArGD,wBAqGC"}
@@ -0,0 +1,73 @@
1
+ import { InvokeOutput } from './toolShared';
2
+ import { Features } from '@aws/language-server-runtimes/server-interface/server';
3
+ interface BaseParams {
4
+ path: string;
5
+ }
6
+ export interface CreateParams extends BaseParams {
7
+ command: 'create';
8
+ fileText?: string;
9
+ newStr?: string;
10
+ }
11
+ export interface StrReplaceParams extends BaseParams {
12
+ command: 'strReplace';
13
+ oldStr: string;
14
+ newStr: string;
15
+ }
16
+ export interface InsertParams extends BaseParams {
17
+ command: 'insert';
18
+ insertLine: number;
19
+ newStr: string;
20
+ }
21
+ export interface AppendParams extends BaseParams {
22
+ command: 'append';
23
+ newStr: string;
24
+ }
25
+ export type FsWriteParams = CreateParams | StrReplaceParams | InsertParams | AppendParams;
26
+ export declare class FsWrite {
27
+ private readonly logging;
28
+ private readonly workspace;
29
+ constructor(features: Pick<Features, 'workspace' | 'logging'> & Partial<Features>);
30
+ invoke(params: FsWriteParams): Promise<InvokeOutput>;
31
+ private handleCreate;
32
+ private handleStrReplace;
33
+ private handleInsert;
34
+ private handleAppend;
35
+ private getCreateCommandText;
36
+ private escapeRegExp;
37
+ getSpec(): {
38
+ readonly name: "fsWrite";
39
+ readonly description: "A tool for creating and editing a file.\n * The `create` command will override the file at `path` if it already exists as a file, and otherwise create a new file\n * The `append` command will add content to the end of an existing file, automatically adding a newline if the file does not end with one. The file must exist.\n Notes for using the `strReplace` command:\n * The `oldStr` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n * If the `oldStr` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `oldStr` to make it unique\n * The `newStr` parameter should contain the edited lines that should replace the `oldStr`. The `insert` command will insert `newStr` after `insertLine` and place it on its own line.";
40
+ readonly inputSchema: {
41
+ readonly type: "object";
42
+ readonly parameters: {
43
+ readonly command: {
44
+ readonly type: "string";
45
+ readonly enum: readonly ["create", "strReplace", "insert", "append"];
46
+ readonly description: "The commands to run. Allowed options are: `create`, `strReplace`, `insert`, `append`.";
47
+ };
48
+ readonly fileText: {
49
+ readonly description: "Required parameter of `create` command, with the content of the file to be created.";
50
+ readonly type: "string";
51
+ };
52
+ readonly insertLine: {
53
+ readonly description: "Required parameter of `insert` command. The `newStr` will be inserted AFTER the line `insertLine` of `path`.";
54
+ readonly type: "integer";
55
+ };
56
+ readonly newStr: {
57
+ readonly description: "Required parameter of `strReplace` command containing the new string. Required parameter of `insert` command containing the string to insert. Required parameter of `append` command containing the content to append to the file.";
58
+ readonly type: "string";
59
+ };
60
+ readonly oldStr: {
61
+ readonly description: "Required parameter of `strReplace` command containing the string in `path` to replace.";
62
+ readonly type: "string";
63
+ };
64
+ readonly path: {
65
+ readonly description: "Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.";
66
+ readonly type: "string";
67
+ };
68
+ };
69
+ readonly required: readonly ["command", "path"];
70
+ };
71
+ };
72
+ }
73
+ export {};
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FsWrite = void 0;
4
+ const path_1 = require("@aws/lsp-core/out/util/path");
5
+ class FsWrite {
6
+ logging;
7
+ workspace;
8
+ constructor(features) {
9
+ this.logging = features.logging;
10
+ this.workspace = features.workspace;
11
+ }
12
+ async invoke(params) {
13
+ const sanitizedPath = (0, path_1.sanitize)(params.path);
14
+ switch (params.command) {
15
+ case 'create':
16
+ await this.handleCreate(params, sanitizedPath);
17
+ break;
18
+ case 'strReplace':
19
+ await this.handleStrReplace(params, sanitizedPath);
20
+ break;
21
+ case 'insert':
22
+ await this.handleInsert(params, sanitizedPath);
23
+ break;
24
+ case 'append':
25
+ await this.handleAppend(params, sanitizedPath);
26
+ break;
27
+ }
28
+ return {
29
+ output: {
30
+ kind: 'text',
31
+ content: '',
32
+ },
33
+ };
34
+ }
35
+ async handleCreate(params, sanitizedPath) {
36
+ const content = this.getCreateCommandText(params);
37
+ await this.workspace.fs.writeFile(sanitizedPath, content);
38
+ }
39
+ async handleStrReplace(params, sanitizedPath) {
40
+ const fileContent = await this.workspace.fs.readFile(sanitizedPath);
41
+ const matches = [...fileContent.matchAll(new RegExp(this.escapeRegExp(params.oldStr), 'g'))];
42
+ if (matches.length === 0) {
43
+ throw new Error(`No occurrences of "${params.oldStr}" were found`);
44
+ }
45
+ if (matches.length > 1) {
46
+ throw new Error(`${matches.length} occurrences of oldStr were found when only 1 is expected`);
47
+ }
48
+ const newContent = fileContent.replace(params.oldStr, params.newStr);
49
+ await this.workspace.fs.writeFile(sanitizedPath, newContent);
50
+ }
51
+ async handleInsert(params, sanitizedPath) {
52
+ const fileContent = await this.workspace.fs.readFile(sanitizedPath);
53
+ const lines = fileContent.split('\n');
54
+ const numLines = lines.length;
55
+ const insertLine = Math.max(0, Math.min(params.insertLine, numLines));
56
+ let newContent;
57
+ if (insertLine === 0) {
58
+ newContent = params.newStr + '\n' + fileContent;
59
+ }
60
+ else {
61
+ newContent = [...lines.slice(0, insertLine), params.newStr, ...lines.slice(insertLine)].join('\n');
62
+ }
63
+ await this.workspace.fs.writeFile(sanitizedPath, newContent);
64
+ }
65
+ async handleAppend(params, sanitizedPath) {
66
+ const fileContent = await this.workspace.fs.readFile(sanitizedPath);
67
+ const needsNewline = fileContent.length !== 0 && !fileContent.endsWith('\n');
68
+ let contentToAppend = params.newStr;
69
+ if (needsNewline) {
70
+ contentToAppend = '\n' + contentToAppend;
71
+ }
72
+ const newContent = fileContent + contentToAppend;
73
+ await this.workspace.fs.writeFile(sanitizedPath, newContent);
74
+ }
75
+ getCreateCommandText(params) {
76
+ if (params.fileText) {
77
+ return params.fileText;
78
+ }
79
+ if (params.newStr) {
80
+ this.logging.warn('Required field `fileText` is missing, use the provided `newStr` instead');
81
+ return params.newStr;
82
+ }
83
+ this.logging.warn('No content provided for the create command');
84
+ return '';
85
+ }
86
+ escapeRegExp(string) {
87
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
88
+ }
89
+ getSpec() {
90
+ return {
91
+ name: 'fsWrite',
92
+ description: 'A tool for creating and editing a file.\n * The `create` command will override the file at `path` if it already exists as a file, and otherwise create a new file\n * The `append` command will add content to the end of an existing file, automatically adding a newline if the file does not end with one. The file must exist.\n Notes for using the `strReplace` command:\n * The `oldStr` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n * If the `oldStr` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `oldStr` to make it unique\n * The `newStr` parameter should contain the edited lines that should replace the `oldStr`. The `insert` command will insert `newStr` after `insertLine` and place it on its own line.',
93
+ inputSchema: {
94
+ type: 'object',
95
+ parameters: {
96
+ command: {
97
+ type: 'string',
98
+ enum: ['create', 'strReplace', 'insert', 'append'],
99
+ description: 'The commands to run. Allowed options are: `create`, `strReplace`, `insert`, `append`.',
100
+ },
101
+ fileText: {
102
+ description: 'Required parameter of `create` command, with the content of the file to be created.',
103
+ type: 'string',
104
+ },
105
+ insertLine: {
106
+ description: 'Required parameter of `insert` command. The `newStr` will be inserted AFTER the line `insertLine` of `path`.',
107
+ type: 'integer',
108
+ },
109
+ newStr: {
110
+ description: 'Required parameter of `strReplace` command containing the new string. Required parameter of `insert` command containing the string to insert. Required parameter of `append` command containing the content to append to the file.',
111
+ type: 'string',
112
+ },
113
+ oldStr: {
114
+ description: 'Required parameter of `strReplace` command containing the string in `path` to replace.',
115
+ type: 'string',
116
+ },
117
+ path: {
118
+ description: 'Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.',
119
+ type: 'string',
120
+ },
121
+ },
122
+ required: ['command', 'path'],
123
+ },
124
+ };
125
+ }
126
+ }
127
+ exports.FsWrite = FsWrite;
128
+ //# sourceMappingURL=fsWrite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsWrite.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/tools/fsWrite.ts"],"names":[],"mappings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,YAAY,CAAC,MAAc;QAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA;IACxD,CAAC;IAEM,OAAO;QACV,OAAO;YACH,IAAI,EAAE,SAAS;YACf,WAAW,EACP,20BAA20B;YAC/0B,WAAW,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC;wBAClD,WAAW,EACP,uFAAuF;qBAC9F;oBACD,QAAQ,EAAE;wBACN,WAAW,EACP,qFAAqF;wBACzF,IAAI,EAAE,QAAQ;qBACjB;oBACD,UAAU,EAAE;wBACR,WAAW,EACP,8GAA8G;wBAClH,IAAI,EAAE,SAAS;qBAClB;oBACD,MAAM,EAAE;wBACJ,WAAW,EACP,oOAAoO;wBACxO,IAAI,EAAE,QAAQ;qBACjB;oBACD,MAAM,EAAE;wBACJ,WAAW,EACP,wFAAwF;wBAC5F,IAAI,EAAE,QAAQ;qBACjB;oBACD,IAAI,EAAE;wBACF,WAAW,EAAE,sEAAsE;wBACnF,IAAI,EAAE,QAAQ;qBACjB;iBACJ;gBACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;aAChC;SACK,CAAA;IACd,CAAC;CACJ;AAlJD,0BAkJC"}
@@ -0,0 +1,2 @@
1
+ import { Server } from '@aws/language-server-runtimes/server-interface';
2
+ export declare const FsToolsServer: Server;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FsToolsServer = void 0;
4
+ const fsRead_1 = require("./fsRead");
5
+ const fsWrite_1 = require("./fsWrite");
6
+ const FsToolsServer = ({ workspace, logging, agent }) => {
7
+ const fsReadTool = new fsRead_1.FsRead({ workspace, logging });
8
+ const fsWriteTool = new fsWrite_1.FsWrite({ workspace, logging });
9
+ agent.addTool(fsReadTool.getSpec(), (input) => fsReadTool.invoke(input));
10
+ agent.addTool(fsWriteTool.getSpec(), (input) => fsWriteTool.invoke(input));
11
+ return () => { };
12
+ };
13
+ exports.FsToolsServer = FsToolsServer;
14
+ //# sourceMappingURL=toolServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolServer.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/tools/toolServer.ts"],"names":[],"mappings":";;;AACA,qCAA+C;AAC/C,uCAAkD;AAE3C,MAAM,aAAa,GAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IACnE,MAAM,UAAU,GAAG,IAAI,eAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;IACrD,MAAM,WAAW,GAAG,IAAI,iBAAO,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;IAEvD,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,KAAmB,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAEtF,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC,KAAoB,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAEzF,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACnB,CAAC,CAAA;AATY,QAAA,aAAa,iBASzB"}
@@ -0,0 +1,7 @@
1
+ export declare const maxToolResponseSize = 30720;
2
+ export interface InvokeOutput {
3
+ output: {
4
+ kind: 'text' | 'json';
5
+ content: string;
6
+ };
7
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maxToolResponseSize = void 0;
4
+ exports.maxToolResponseSize = 30720; // 30KB
5
+ //# sourceMappingURL=toolShared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolShared.js","sourceRoot":"","sources":["../../../../src/language-server/agenticChat/tools/toolShared.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,KAAK,CAAA,CAAC,OAAO"}
@@ -0,0 +1,59 @@
1
+ /*!
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { MynahIcons, Status } from '@aws/mynah-ui';
6
+ import { FollowUpTypes, NewFileInfo } from '../shared/types';
7
+ export declare const docChat = "docChat";
8
+ export declare const docScheme = "aws-doc";
9
+ export declare const featureName = "Amazon Q Doc Generation";
10
+ export declare function getFileSummaryPercentage(input: string): number;
11
+ export declare enum DocGenerationStep {
12
+ UPLOAD_TO_S3 = 0,
13
+ SUMMARIZING_FILES = 1,
14
+ GENERATING_ARTIFACTS = 2
15
+ }
16
+ export declare const docGenerationProgressMessage: (currentStep: DocGenerationStep, mode: Mode) => string;
17
+ export declare const docGenerationSuccessMessage: (mode: Mode) => string;
18
+ export declare const docRejectConfirmation = "Your changes have been discarded.";
19
+ export declare const FolderSelectorFollowUps: {
20
+ icon: MynahIcons;
21
+ pillText: string;
22
+ prompt: string;
23
+ status: Status;
24
+ type: FollowUpTypes;
25
+ }[];
26
+ export declare const CodeChangeFollowUps: {
27
+ pillText: string;
28
+ prompt: string;
29
+ type: FollowUpTypes;
30
+ icon: MynahIcons;
31
+ status: Status;
32
+ }[];
33
+ export declare const NewSessionFollowUps: {
34
+ pillText: string;
35
+ type: FollowUpTypes;
36
+ status: Status;
37
+ }[];
38
+ export declare const SynchronizeDocumentation: {
39
+ pillText: string;
40
+ prompt: string;
41
+ type: FollowUpTypes;
42
+ };
43
+ export declare const EditDocumentation: {
44
+ pillText: string;
45
+ prompt: string;
46
+ type: FollowUpTypes;
47
+ };
48
+ export declare enum Mode {
49
+ NONE = "None",
50
+ CREATE = "Create",
51
+ SYNC = "Sync",
52
+ EDIT = "Edit"
53
+ }
54
+ /**
55
+ *
56
+ * @param paths file paths
57
+ * @returns the path to a README.md, or undefined if none exist
58
+ */
59
+ export declare const findReadmePath: (paths?: NewFileInfo[]) => NewFileInfo | undefined;