@codebolt/agent 1.2.1 → 2.2.3

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 (285) hide show
  1. package/README.md +157 -66
  2. package/dist/{agent.js → builderpattern/agent.js} +2 -2
  3. package/dist/{followupquestionbuilder.d.ts → builderpattern/followupquestionbuilder.d.ts} +1 -1
  4. package/dist/{followupquestionbuilder.js → builderpattern/followupquestionbuilder.js} +1 -1
  5. package/dist/{index.d.ts → builderpattern/index.d.ts} +3 -3
  6. package/dist/{llmoutputhandler.d.ts → builderpattern/llmoutputhandler.d.ts} +1 -1
  7. package/dist/{llmoutputhandler.js → builderpattern/llmoutputhandler.js} +7 -7
  8. package/dist/{promptbuilder.d.ts → builderpattern/promptbuilder.d.ts} +3 -3
  9. package/dist/{taskInstruction.d.ts → builderpattern/taskInstruction.d.ts} +2 -2
  10. package/dist/{usermessage.d.ts → builderpattern/usermessage.d.ts} +9 -4
  11. package/dist/composablepattern/agent.d.ts +169 -0
  12. package/dist/composablepattern/agent.js +598 -0
  13. package/dist/composablepattern/codebolt-storage.d.ts +67 -0
  14. package/dist/composablepattern/codebolt-storage.js +320 -0
  15. package/dist/composablepattern/document.d.ts +149 -0
  16. package/dist/composablepattern/document.js +372 -0
  17. package/dist/composablepattern/examples/codebolt-integration-example.d.ts +12 -0
  18. package/dist/composablepattern/examples/codebolt-integration-example.js +218 -0
  19. package/dist/composablepattern/examples/codebolt-storage-example.d.ts +40 -0
  20. package/dist/composablepattern/examples/codebolt-storage-example.js +223 -0
  21. package/dist/composablepattern/examples/custom-steps-example.d.ts +20 -0
  22. package/dist/composablepattern/examples/custom-steps-example.js +455 -0
  23. package/dist/composablepattern/examples/document-agent.d.ts +17 -0
  24. package/dist/composablepattern/examples/document-agent.js +107 -0
  25. package/dist/composablepattern/examples/simple-codebolt-integration.d.ts +8 -0
  26. package/dist/composablepattern/examples/simple-codebolt-integration.js +164 -0
  27. package/dist/composablepattern/examples/weather-agent.d.ts +18 -0
  28. package/dist/composablepattern/examples/weather-agent.js +86 -0
  29. package/dist/composablepattern/examples/workflow-example.d.ts +12 -0
  30. package/dist/composablepattern/examples/workflow-example.js +463 -0
  31. package/dist/composablepattern/index.d.ts +63 -0
  32. package/dist/composablepattern/index.js +115 -0
  33. package/dist/composablepattern/memory.d.ts +89 -0
  34. package/dist/composablepattern/memory.js +141 -0
  35. package/dist/composablepattern/tool.d.ts +84 -0
  36. package/dist/composablepattern/tool.js +260 -0
  37. package/dist/composablepattern/types.d.ts +194 -0
  38. package/dist/composablepattern/types.js +6 -0
  39. package/dist/composablepattern/user-context.d.ts +214 -0
  40. package/dist/composablepattern/user-context.js +275 -0
  41. package/dist/composablepattern/workflow.d.ts +388 -0
  42. package/dist/composablepattern/workflow.js +562 -0
  43. package/dist/local-tools/fileTools.d.ts +26 -0
  44. package/dist/local-tools/fileTools.js +162 -0
  45. package/dist/processor/agent/agentStep.d.ts +49 -0
  46. package/dist/processor/agent/agentStep.js +241 -0
  47. package/dist/processor/agent/toolExecutor.d.ts +19 -0
  48. package/dist/processor/agent/toolExecutor.js +90 -0
  49. package/dist/processor/index.d.ts +7 -0
  50. package/dist/processor/index.js +36 -0
  51. package/dist/processor/messageModifiers/baseMessageModifier.d.ts +20 -0
  52. package/dist/processor/messageModifiers/baseMessageModifier.js +55 -0
  53. package/dist/processor/processors/baseProcessor.d.ts +14 -0
  54. package/dist/processor/processors/baseProcessor.js +29 -0
  55. package/dist/processor/tools/baseTool.d.ts +10 -0
  56. package/dist/processor/tools/baseTool.js +20 -0
  57. package/dist/processor/tools/toolList.d.ts +9 -0
  58. package/dist/processor/tools/toolList.js +22 -0
  59. package/dist/processor/types/interfaces.d.ts +117 -0
  60. package/dist/processor/types/interfaces.js +2 -0
  61. package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.d.ts +13 -0
  62. package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.js +68 -0
  63. package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.d.ts +15 -0
  64. package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.js +212 -0
  65. package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.d.ts +19 -0
  66. package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.js +110 -0
  67. package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.d.ts +23 -0
  68. package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.js +173 -0
  69. package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.d.ts +14 -0
  70. package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.js +93 -0
  71. package/dist/processor-pieces/additionalModifiers/directoryContextModifier.d.ts +30 -0
  72. package/dist/processor-pieces/additionalModifiers/directoryContextModifier.js +330 -0
  73. package/dist/processor-pieces/additionalModifiers/environmentContextModifier.d.ts +26 -0
  74. package/dist/processor-pieces/additionalModifiers/environmentContextModifier.js +269 -0
  75. package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.d.ts +38 -0
  76. package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.js +217 -0
  77. package/dist/processor-pieces/additionalModifiers/ideContextModifier.d.ts +34 -0
  78. package/dist/processor-pieces/additionalModifiers/ideContextModifier.js +147 -0
  79. package/dist/processor-pieces/additionalModifiers/index.d.ts +12 -0
  80. package/dist/processor-pieces/additionalModifiers/index.js +28 -0
  81. package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.d.ts +29 -0
  82. package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.js +155 -0
  83. package/dist/processor-pieces/additionalModifiers/memoryImportModifier.d.ts +15 -0
  84. package/dist/processor-pieces/additionalModifiers/memoryImportModifier.js +129 -0
  85. package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.d.ts +25 -0
  86. package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.js +169 -0
  87. package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.d.ts +20 -0
  88. package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.js +152 -0
  89. package/dist/processor-pieces/base/baseMessageModifier.d.ts +12 -0
  90. package/dist/processor-pieces/base/baseMessageModifier.js +15 -0
  91. package/dist/processor-pieces/base/basePostInferenceProcessor.d.ts +13 -0
  92. package/dist/processor-pieces/base/basePostInferenceProcessor.js +18 -0
  93. package/dist/processor-pieces/base/basePostToolCallProcessor.d.ts +15 -0
  94. package/dist/processor-pieces/base/basePostToolCallProcessor.js +25 -0
  95. package/dist/processor-pieces/base/basePreInferenceProcessor.d.ts +12 -0
  96. package/dist/processor-pieces/base/basePreInferenceProcessor.js +17 -0
  97. package/dist/processor-pieces/base/basePreToolCallProcessor.d.ts +18 -0
  98. package/dist/processor-pieces/base/basePreToolCallProcessor.js +66 -0
  99. package/dist/processor-pieces/base/index.d.ts +9 -0
  100. package/dist/processor-pieces/base/index.js +18 -0
  101. package/dist/processor-pieces/index.d.ts +1 -0
  102. package/dist/processor-pieces/index.js +59 -0
  103. package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.d.ts +7 -0
  104. package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.js +93 -0
  105. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.d.ts +31 -0
  106. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +145 -0
  107. package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.d.ts +9 -0
  108. package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.js +77 -0
  109. package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.d.ts +13 -0
  110. package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.js +68 -0
  111. package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.d.ts +25 -0
  112. package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.js +453 -0
  113. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +7 -0
  114. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +67 -0
  115. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +9 -0
  116. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +90 -0
  117. package/dist/processor-pieces/messageModifiers/chatCompressionModifier.d.ts +19 -0
  118. package/dist/processor-pieces/messageModifiers/chatCompressionModifier.js +110 -0
  119. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.d.ts +18 -0
  120. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.d.ts +20 -0
  121. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.js +124 -0
  122. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.js +104 -0
  123. package/dist/processor-pieces/messageModifiers/chatRecordingModifier.d.ts +23 -0
  124. package/dist/processor-pieces/messageModifiers/chatRecordingModifier.js +173 -0
  125. package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.d.ts +14 -0
  126. package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.js +130 -0
  127. package/dist/processor-pieces/messageModifiers/directoryContextModifier.d.ts +36 -0
  128. package/dist/processor-pieces/messageModifiers/directoryContextModifier.js +418 -0
  129. package/dist/processor-pieces/messageModifiers/environmentContext.d.ts +41 -0
  130. package/dist/processor-pieces/messageModifiers/environmentContext.js +355 -0
  131. package/dist/processor-pieces/messageModifiers/environmentContextModifier.d.ts +26 -0
  132. package/dist/processor-pieces/messageModifiers/environmentContextModifier.js +260 -0
  133. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +13 -0
  134. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +59 -0
  135. package/dist/processor-pieces/messageModifiers/ideContextModifier.d.ts +34 -0
  136. package/dist/processor-pieces/messageModifiers/ideContextModifier.js +157 -0
  137. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +19 -0
  138. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +221 -0
  139. package/dist/processor-pieces/messageModifiers/index.d.ts +11 -0
  140. package/dist/processor-pieces/messageModifiers/index.js +26 -0
  141. package/dist/processor-pieces/messageModifiers/memoryImportModifier.d.ts +15 -0
  142. package/dist/processor-pieces/messageModifiers/memoryImportModifier.js +129 -0
  143. package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.d.ts +23 -0
  144. package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.js +207 -0
  145. package/dist/processor-pieces/messageModifiers/simpleMessageModifier.d.ts +7 -0
  146. package/dist/processor-pieces/messageModifiers/simpleMessageModifier.js +26 -0
  147. package/dist/processor-pieces/messageModifiers/toolInjectionModifier.d.ts +20 -0
  148. package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +152 -0
  149. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +38 -0
  150. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +392 -0
  151. package/dist/processor-pieces/postInference/llmOutputValidityProcessor.d.ts +1 -0
  152. package/dist/processor-pieces/postInference/llmOutputValidityProcessor.js +2 -0
  153. package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.d.ts +7 -0
  154. package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.js +24 -0
  155. package/dist/processor-pieces/postInferenceProcessors/loopDetectionModifier.d.ts +29 -0
  156. package/dist/processor-pieces/postInferenceProcessors/loopDetectionModifier.js +174 -0
  157. package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.d.ts +41 -0
  158. package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.js +197 -0
  159. package/dist/processor-pieces/postToolCall/chatCompressionProcessor.d.ts +26 -0
  160. package/dist/processor-pieces/postToolCall/chatCompressionProcessor.js +90 -0
  161. package/dist/processor-pieces/postToolCall/chatRecordingProcessor.d.ts +81 -0
  162. package/dist/processor-pieces/postToolCall/chatRecordingProcessor.js +329 -0
  163. package/dist/processor-pieces/postToolCall/contextManagementProcessor.d.ts +40 -0
  164. package/dist/processor-pieces/postToolCall/contextManagementProcessor.js +272 -0
  165. package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.d.ts +49 -0
  166. package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.js +291 -0
  167. package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.d.ts +49 -0
  168. package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.js +293 -0
  169. package/dist/processor-pieces/postToolCall/followUpConversationProcessor.d.ts +47 -0
  170. package/dist/processor-pieces/postToolCall/followUpConversationProcessor.js +249 -0
  171. package/dist/processor-pieces/postToolCall/loopDetectionProcessor.d.ts +30 -0
  172. package/dist/processor-pieces/postToolCall/loopDetectionProcessor.js +137 -0
  173. package/dist/processor-pieces/postToolCall/responseValidationProcessor.d.ts +30 -0
  174. package/dist/processor-pieces/postToolCall/responseValidationProcessor.js +228 -0
  175. package/dist/processor-pieces/postToolCall/telemetryProcessor.d.ts +99 -0
  176. package/dist/processor-pieces/postToolCall/telemetryProcessor.js +278 -0
  177. package/dist/processor-pieces/postToolCall/tokenManagementProcessor.d.ts +37 -0
  178. package/dist/processor-pieces/postToolCall/tokenManagementProcessor.js +178 -0
  179. package/dist/processor-pieces/postToolCall/toolExecutionProcessor.d.ts +43 -0
  180. package/dist/processor-pieces/postToolCall/toolExecutionProcessor.js +207 -0
  181. package/dist/processor-pieces/postToolCallProcessors/index.d.ts +1 -0
  182. package/dist/processor-pieces/postToolCallProcessors/index.js +2 -0
  183. package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.d.ts +25 -0
  184. package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.js +225 -0
  185. package/dist/processor-pieces/preInference/conversationCompactorProcessor.d.ts +52 -0
  186. package/dist/processor-pieces/preInference/conversationCompactorProcessor.js +264 -0
  187. package/dist/processor-pieces/preInference/conversationContinuityProcessor.d.ts +49 -0
  188. package/dist/processor-pieces/preInference/conversationContinuityProcessor.js +293 -0
  189. package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.d.ts +35 -0
  190. package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.js +255 -0
  191. package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.d.ts +7 -0
  192. package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.js +31 -0
  193. package/dist/processor-pieces/preInferenceProcessors/index.d.ts +1 -0
  194. package/dist/processor-pieces/preInferenceProcessors/index.js +2 -0
  195. package/dist/processor-pieces/preToolCall/index.d.ts +9 -0
  196. package/dist/processor-pieces/preToolCall/index.js +18 -0
  197. package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.d.ts +58 -0
  198. package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.js +444 -0
  199. package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.d.ts +44 -0
  200. package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.js +367 -0
  201. package/dist/processor-pieces/preToolCall/toolValidationProcessor.d.ts +58 -0
  202. package/dist/processor-pieces/preToolCall/toolValidationProcessor.js +391 -0
  203. package/dist/processor-pieces/pretoolCallProcessors/index.d.ts +1 -0
  204. package/dist/processor-pieces/pretoolCallProcessors/index.js +2 -0
  205. package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.d.ts +41 -0
  206. package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.js +197 -0
  207. package/dist/processor-pieces/processors/chatCompressionProcessor.d.ts +26 -0
  208. package/dist/processor-pieces/processors/chatCompressionProcessor.js +90 -0
  209. package/dist/processor-pieces/processors/chatRecordingProcessor.d.ts +81 -0
  210. package/dist/processor-pieces/processors/chatRecordingProcessor.js +329 -0
  211. package/dist/processor-pieces/processors/contextManagementProcessor.d.ts +40 -0
  212. package/dist/processor-pieces/processors/contextManagementProcessor.js +305 -0
  213. package/dist/processor-pieces/processors/loopDetectionProcessor.d.ts +30 -0
  214. package/dist/processor-pieces/processors/loopDetectionProcessor.js +137 -0
  215. package/dist/processor-pieces/processors/responseValidationProcessor.d.ts +30 -0
  216. package/dist/processor-pieces/processors/responseValidationProcessor.js +228 -0
  217. package/dist/processor-pieces/processors/telemetryProcessor.d.ts +99 -0
  218. package/dist/processor-pieces/processors/telemetryProcessor.js +311 -0
  219. package/dist/processor-pieces/processors/tokenManagementProcessor.d.ts +37 -0
  220. package/dist/processor-pieces/processors/tokenManagementProcessor.js +178 -0
  221. package/dist/processor-pieces/processors/toolExecutionProcessor.d.ts +43 -0
  222. package/dist/processor-pieces/processors/toolExecutionProcessor.js +207 -0
  223. package/dist/processor-pieces/tools/fileTools.d.ts +26 -0
  224. package/dist/processor-pieces/tools/fileTools.js +162 -0
  225. package/dist/processor-pieces/utils/messageModifierHelper.d.ts +4 -0
  226. package/dist/processor-pieces/utils/messageModifierHelper.js +58 -0
  227. package/dist/types/commonTypes.d.ts +4 -0
  228. package/dist/types/processorTypes.d.ts +67 -0
  229. package/dist/types/processorTypes.js +58 -0
  230. package/dist/unified/agent/agent.d.ts +17 -0
  231. package/dist/unified/agent/agent.js +79 -0
  232. package/dist/unified/agent/team.d.ts +2 -0
  233. package/dist/unified/agent/team.js +6 -0
  234. package/dist/unified/agent/tool.d.ts +99 -0
  235. package/dist/unified/agent/tool.js +440 -0
  236. package/dist/unified/agent/tools.d.ts +44 -0
  237. package/dist/unified/agent/tools.js +487 -0
  238. package/dist/unified/agent/workflow.d.ts +24 -0
  239. package/dist/unified/agent/workflow.js +275 -0
  240. package/dist/unified/agent/workflowControls.d.ts +11 -0
  241. package/dist/unified/agent/workflowControls.js +20 -0
  242. package/dist/unified/agent/workflowSteps.d.ts +63 -0
  243. package/dist/unified/agent/workflowSteps.js +284 -0
  244. package/dist/unified/base/agentStep.d.ts +32 -0
  245. package/dist/unified/base/agentStep.js +96 -0
  246. package/dist/unified/base/create/createInitialPromptGenerators.d.ts +5 -0
  247. package/dist/unified/base/create/createInitialPromptGenerators.js +17 -0
  248. package/dist/unified/base/index.d.ts +5 -0
  249. package/dist/unified/base/index.js +13 -0
  250. package/dist/unified/base/initialPromptGenerator.d.ts +48 -0
  251. package/dist/unified/base/initialPromptGenerator.js +118 -0
  252. package/dist/unified/base/responseExecutor.d.ts +36 -0
  253. package/dist/unified/base/responseExecutor.js +283 -0
  254. package/dist/unified/examples/agentExample.d.ts +46 -0
  255. package/dist/unified/examples/agentExample.js +464 -0
  256. package/dist/unified/examples/documentationPatternExample.d.ts +10 -0
  257. package/dist/unified/examples/documentationPatternExample.js +385 -0
  258. package/dist/unified/examples/followUpProcessorsExample.d.ts +45 -0
  259. package/dist/unified/examples/followUpProcessorsExample.js +311 -0
  260. package/dist/unified/examples/orchestratorExample.d.ts +16 -0
  261. package/dist/unified/examples/orchestratorExample.js +415 -0
  262. package/dist/unified/examples/preToolCallProcessorsExample.d.ts +36 -0
  263. package/dist/unified/examples/preToolCallProcessorsExample.js +458 -0
  264. package/dist/unified/examples/workflowExample.d.ts +12 -0
  265. package/dist/unified/examples/workflowExample.js +497 -0
  266. package/dist/unified/index.d.ts +18 -0
  267. package/dist/unified/index.js +42 -0
  268. package/dist/unified/orchestrator/orchestrator.d.ts +260 -0
  269. package/dist/unified/orchestrator/orchestrator.js +519 -0
  270. package/dist/unified/team/team.d.ts +1 -0
  271. package/dist/unified/team/team.js +2 -0
  272. package/dist/unified/types/libTypes.d.ts +378 -0
  273. package/dist/unified/types/libTypes.js +6 -0
  274. package/dist/unified/types/types.d.ts +212 -0
  275. package/dist/unified/types/types.js +43 -0
  276. package/dist/unified/utils/utils.d.ts +40 -0
  277. package/dist/unified/utils/utils.js +219 -0
  278. package/package.json +35 -13
  279. /package/dist/{agent.d.ts → builderpattern/agent.d.ts} +0 -0
  280. /package/dist/{index.js → builderpattern/index.js} +0 -0
  281. /package/dist/{promptbuilder.js → builderpattern/promptbuilder.js} +0 -0
  282. /package/dist/{systemprompt.d.ts → builderpattern/systemprompt.d.ts} +0 -0
  283. /package/dist/{systemprompt.js → builderpattern/systemprompt.js} +0 -0
  284. /package/dist/{taskInstruction.js → builderpattern/taskInstruction.js} +0 -0
  285. /package/dist/{usermessage.js → builderpattern/usermessage.js} +0 -0
@@ -0,0 +1,453 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AtFileProcessorModifier = void 0;
40
+ const base_1 = require("../base");
41
+ const fs = __importStar(require("node:fs/promises"));
42
+ const path = __importStar(require("node:path"));
43
+ const codeboltjs_1 = __importDefault(require("@codebolt/codeboltjs"));
44
+ const DEFAULT_FILE_FILTERING_OPTIONS = {
45
+ respectGitIgnore: true,
46
+ respectGeminiIgnore: true,
47
+ };
48
+ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
49
+ constructor(options = {}) {
50
+ super();
51
+ this.options = {
52
+ maxFileSize: options.maxFileSize || 1024 * 1024, // 1MB default
53
+ allowedExtensions: options.allowedExtensions || ['.ts', '.js', '.d.ts', '.json', '.md', '.txt', '.yml', '.yaml', '.xml', '.html', '.css', '.py', '.java', '.cpp', '.c', '.h'],
54
+ enableRecursiveSearch: options.enableRecursiveSearch !== false
55
+ };
56
+ }
57
+ async modify(originalRequest, createdMessage) {
58
+ try {
59
+ const mentionedFiles = originalRequest.mentionedFiles || [];
60
+ const mentionedFolders = originalRequest.mentionedFolders || [];
61
+ if (mentionedFiles.length === 0 && mentionedFolders.length === 0) {
62
+ return createdMessage;
63
+ }
64
+ // Process mentioned files and folders
65
+ const result = await this.processMentionedPaths(mentionedFiles, mentionedFolders);
66
+ if (!result.success) {
67
+ return createdMessage;
68
+ }
69
+ // Update the user message with processed content
70
+ const messages = [...createdMessage.message.messages];
71
+ const lastUserMessageIndex = this.findLastUserMessage(messages);
72
+ if (lastUserMessageIndex !== -1 && result.processedContent) {
73
+ const lastUserMessage = messages[lastUserMessageIndex];
74
+ // Convert string content to array format if needed
75
+ let currentContent;
76
+ if (Array.isArray(lastUserMessage.content)) {
77
+ currentContent = lastUserMessage.content;
78
+ }
79
+ else {
80
+ // Convert string content to array format
81
+ currentContent = [{ type: 'text', text: lastUserMessage.content }];
82
+ }
83
+ // Ensure processedContent is in array format
84
+ const newContent = Array.isArray(result.processedContent)
85
+ ? result.processedContent
86
+ : [{ type: 'text', text: result.processedContent }];
87
+ // Merge existing content with processed content
88
+ messages[lastUserMessageIndex] = {
89
+ ...lastUserMessage,
90
+ content: [...currentContent, ...newContent]
91
+ };
92
+ }
93
+ return {
94
+ message: {
95
+ ...createdMessage.message,
96
+ messages
97
+ },
98
+ metadata: {
99
+ ...createdMessage.metadata,
100
+ atFileProcessed: true,
101
+ processedFiles: mentionedFiles,
102
+ processedFolders: mentionedFolders,
103
+ filesRead: result.filesRead || []
104
+ }
105
+ };
106
+ }
107
+ catch (error) {
108
+ console.error('Error in AtFileProcessorModifier:', error);
109
+ return createdMessage;
110
+ }
111
+ }
112
+ async processMentionedPaths(mentionedFiles, mentionedFolders) {
113
+ const filesRead = [];
114
+ const contextParts = [];
115
+ // Get workspace directories
116
+ let workspaceDirectories = [];
117
+ try {
118
+ const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
119
+ workspaceDirectories = projectPath ? [projectPath] : [await this.getProjectPath()];
120
+ }
121
+ catch (error) {
122
+ workspaceDirectories = [await this.getProjectPath()];
123
+ }
124
+ // Process mentioned files using readManyFiles
125
+ if (mentionedFiles.length > 0) {
126
+ try {
127
+ const resolvedPaths = await Promise.all(mentionedFiles.map(async (filePath) => {
128
+ try {
129
+ await this.resolvePath(filePath, workspaceDirectories);
130
+ return filePath; // Keep original path for readManyFiles
131
+ }
132
+ catch (error) {
133
+ console.warn(`Could not resolve path: ${filePath}`);
134
+ return filePath; // Still try to read it
135
+ }
136
+ }));
137
+ const fileContents = await this.readManyFiles(resolvedPaths);
138
+ filesRead.push(...mentionedFiles);
139
+ if (fileContents.length > 0) {
140
+ contextParts.push(`\n--- Content from referenced files ---`);
141
+ for (const { path: filePath, content } of fileContents) {
142
+ contextParts.push(`\nContent from @${filePath}:\n`);
143
+ contextParts.push(content);
144
+ }
145
+ }
146
+ }
147
+ catch (error) {
148
+ console.error('Error reading mentioned files:', error);
149
+ // Fallback to individual file reading
150
+ contextParts.push(`\n--- Content from referenced files ---`);
151
+ for (const filePath of mentionedFiles) {
152
+ try {
153
+ const resolvedPath = await this.resolvePath(filePath, workspaceDirectories);
154
+ const content = await this.readFileContent(resolvedPath);
155
+ filesRead.push(filePath);
156
+ contextParts.push(`\nContent from @${filePath}:\n`);
157
+ contextParts.push(content);
158
+ }
159
+ catch (error) {
160
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
161
+ contextParts.push(`\nContent from @${filePath}:\n`);
162
+ contextParts.push(`[Error loading ${filePath}: ${errorMessage}]`);
163
+ }
164
+ }
165
+ }
166
+ }
167
+ // Process mentioned folders
168
+ if (mentionedFolders.length > 0) {
169
+ contextParts.push(`\n--- Folder Structures ---`);
170
+ for (const folderPath of mentionedFolders) {
171
+ try {
172
+ const resolvedPath = await this.resolvePath(folderPath, workspaceDirectories);
173
+ const structure = await this.getFolderStructure(resolvedPath);
174
+ filesRead.push(folderPath);
175
+ contextParts.push(`\nStructure of @${folderPath}:\n`);
176
+ contextParts.push(structure);
177
+ // Also read files within the folder
178
+ const filesInFolder = await this.getFilesInFolder(resolvedPath);
179
+ // console.log(`Found ${filesInFolder.length} files in ${folderPath}:`, filesInFolder.map(f => path.basename(f)));
180
+ if (filesInFolder.length > 0) {
181
+ contextParts.push(`\n--- Files in ${folderPath} ---`);
182
+ for (const filePath of filesInFolder) {
183
+ try {
184
+ // console.log(`Attempting to read file: ${filePath}`);
185
+ const content = await this.readFileContent(filePath);
186
+ const relativePath = path.relative(resolvedPath, filePath);
187
+ const displayPath = `${folderPath}/${relativePath}`;
188
+ contextParts.push(`\nContent from @${displayPath}:\n`);
189
+ contextParts.push(content);
190
+ // console.log(`Successfully read file: ${displayPath} (${content.length} chars)`);
191
+ }
192
+ catch (error) {
193
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
194
+ const relativePath = path.relative(resolvedPath, filePath);
195
+ const displayPath = `${folderPath}/${relativePath}`;
196
+ console.error(`Error reading file ${displayPath}:`, errorMessage);
197
+ contextParts.push(`\nContent from @${displayPath}:\n`);
198
+ contextParts.push(`[Error reading file: ${errorMessage}]`);
199
+ }
200
+ }
201
+ }
202
+ else {
203
+ console.log(`No files found in ${folderPath} (resolved to ${resolvedPath})`);
204
+ }
205
+ }
206
+ catch (error) {
207
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
208
+ contextParts.push(`\nStructure of @${folderPath}:\n`);
209
+ contextParts.push(`[Error reading folder ${folderPath}: ${errorMessage}]`);
210
+ }
211
+ }
212
+ }
213
+ return {
214
+ success: true,
215
+ processedContent: this.buildContentParts(contextParts),
216
+ filesRead
217
+ };
218
+ }
219
+ buildContentParts(contextParts) {
220
+ const contentParts = [];
221
+ for (const part of contextParts) {
222
+ contentParts.push({
223
+ type: 'text',
224
+ text: part
225
+ });
226
+ }
227
+ return contentParts;
228
+ }
229
+ async resolvePath(pathName, workspaceDirectories) {
230
+ // Try to resolve the path in workspace directories
231
+ for (const dir of workspaceDirectories) {
232
+ try {
233
+ const absolutePath = path.resolve(dir, pathName);
234
+ await fs.stat(absolutePath); // Check if path exists
235
+ return absolutePath;
236
+ }
237
+ catch (error) {
238
+ if (this.isNodeError(error) && error.code === 'ENOENT') {
239
+ if (this.options.enableRecursiveSearch) {
240
+ // Try glob search
241
+ const globResult = await this.globSearch(pathName, dir);
242
+ if (globResult) {
243
+ return path.resolve(dir, globResult);
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ // Fallback to original path
250
+ const projectPath = await this.getProjectPath();
251
+ return path.isAbsolute(pathName) ? pathName : path.resolve(projectPath, pathName);
252
+ }
253
+ async globSearch(pathName, dir) {
254
+ // Simple glob search implementation
255
+ try {
256
+ const pattern = `**/*${pathName}*`;
257
+ const matches = await this.findFiles(dir, pattern);
258
+ if (matches.length > 0) {
259
+ return path.relative(dir, matches[0]);
260
+ }
261
+ }
262
+ catch (error) {
263
+ console.error('Glob search error:', error);
264
+ }
265
+ return null;
266
+ }
267
+ async findFiles(dir, pattern) {
268
+ // Simplified file finding - in real implementation would use proper glob
269
+ const matches = [];
270
+ const searchTerm = pattern.replace(/\*\*/g, '').replace(/\*/g, '');
271
+ try {
272
+ const entries = await fs.readdir(dir, { withFileTypes: true });
273
+ for (const entry of entries) {
274
+ if (entry.name.includes(searchTerm)) {
275
+ matches.push(path.join(dir, entry.name));
276
+ }
277
+ if (entry.isDirectory() && !entry.name.startsWith('.')) {
278
+ const subMatches = await this.findFiles(path.join(dir, entry.name), pattern);
279
+ matches.push(...subMatches);
280
+ }
281
+ }
282
+ }
283
+ catch (error) {
284
+ // Ignore errors in subdirectories
285
+ }
286
+ return matches.slice(0, 10); // Limit results
287
+ }
288
+ async readManyFiles(pathSpecs) {
289
+ const results = [];
290
+ // Try to use read_many_files tool if available (like gemini-cli)
291
+ try {
292
+ // In a real implementation, this would use the actual tool registry
293
+ // For now, we'll simulate the tool behavior
294
+ const toolArgs = {
295
+ paths: pathSpecs,
296
+ useDefaultExcludes: true,
297
+ file_filtering_options: {
298
+ respect_git_ignore: DEFAULT_FILE_FILTERING_OPTIONS.respectGitIgnore,
299
+ respect_gemini_ignore: DEFAULT_FILE_FILTERING_OPTIONS.respectGeminiIgnore,
300
+ }
301
+ };
302
+ // Simulate read_many_files tool execution
303
+ for (const pathSpec of pathSpecs) {
304
+ try {
305
+ if (pathSpec.includes('**') || pathSpec.includes('*')) {
306
+ // Handle directory patterns
307
+ const basePath = pathSpec.replace('/**', '').replace('**', '');
308
+ const files = await this.findFiles(basePath, '**/*');
309
+ for (const filePath of files.slice(0, 20)) { // Limit files
310
+ try {
311
+ const content = await this.readFileContent(filePath);
312
+ const projectPath = await this.getProjectPath();
313
+ results.push({ path: path.relative(projectPath, filePath), content });
314
+ }
315
+ catch (error) {
316
+ results.push({ path: filePath, content: `[Error reading file: ${error}]` });
317
+ }
318
+ }
319
+ }
320
+ else {
321
+ // Handle single file
322
+ const projectPath = await this.getProjectPath();
323
+ const resolvedPath = path.isAbsolute(pathSpec) ? pathSpec : path.resolve(projectPath, pathSpec);
324
+ const content = await this.readFileContent(resolvedPath);
325
+ results.push({ path: pathSpec, content });
326
+ }
327
+ }
328
+ catch (error) {
329
+ results.push({ path: pathSpec, content: `[Error reading: ${error}]` });
330
+ }
331
+ }
332
+ }
333
+ catch (error) {
334
+ console.error('Error in readManyFiles:', error);
335
+ // Fallback to individual file reading
336
+ for (const pathSpec of pathSpecs) {
337
+ try {
338
+ const projectPath = await this.getProjectPath();
339
+ const resolvedPath = path.isAbsolute(pathSpec) ? pathSpec : path.resolve(projectPath, pathSpec);
340
+ const content = await this.readFileContent(resolvedPath);
341
+ results.push({ path: pathSpec, content });
342
+ }
343
+ catch (error) {
344
+ results.push({ path: pathSpec, content: `[Error reading: ${error}]` });
345
+ }
346
+ }
347
+ }
348
+ return results;
349
+ }
350
+ async readFileContent(filePath) {
351
+ // Check file size
352
+ const stats = await fs.stat(filePath);
353
+ if (stats.size > this.options.maxFileSize) {
354
+ throw new Error(`File too large: ${stats.size} bytes`);
355
+ }
356
+ // Check file extension
357
+ if (this.options.allowedExtensions.length > 0) {
358
+ const ext = path.extname(filePath).toLowerCase();
359
+ if (!this.options.allowedExtensions.includes(ext)) {
360
+ throw new Error(`File type not allowed: ${ext}`);
361
+ }
362
+ }
363
+ const content = await fs.readFile(filePath, 'utf-8');
364
+ return content;
365
+ }
366
+ async getFilesInFolder(folderPath) {
367
+ try {
368
+ const entries = await fs.readdir(folderPath, { withFileTypes: true });
369
+ const files = [];
370
+ for (const entry of entries) {
371
+ if (entry.isFile() && !entry.name.startsWith('.')) {
372
+ // Check file extension if allowed extensions are specified
373
+ if (this.options.allowedExtensions.length > 0) {
374
+ const ext = path.extname(entry.name).toLowerCase();
375
+ // console.log(`Checking file ${entry.name} with extension ${ext}. Allowed:`, this.options.allowedExtensions);
376
+ if (this.options.allowedExtensions.includes(ext)) {
377
+ files.push(path.join(folderPath, entry.name));
378
+ }
379
+ else {
380
+ // console.log(`File ${entry.name} extension ${ext} not in allowed list`);
381
+ }
382
+ }
383
+ else {
384
+ files.push(path.join(folderPath, entry.name));
385
+ }
386
+ }
387
+ }
388
+ // Limit number of files to avoid overwhelming output
389
+ return files.slice(0, 10);
390
+ }
391
+ catch (error) {
392
+ console.error('Error reading files in folder:', error);
393
+ return [];
394
+ }
395
+ }
396
+ async getFolderStructure(folderPath) {
397
+ // Check if folder exists and is readable
398
+ const stats = await fs.stat(folderPath);
399
+ if (!stats.isDirectory()) {
400
+ throw new Error(`${folderPath} is not a directory`);
401
+ }
402
+ // Read directory structure
403
+ const entries = await fs.readdir(folderPath, { withFileTypes: true });
404
+ const lines = [];
405
+ // Sort entries: directories first, then files
406
+ const sortedEntries = entries.sort((a, b) => {
407
+ if (a.isDirectory() && !b.isDirectory())
408
+ return -1;
409
+ if (!a.isDirectory() && b.isDirectory())
410
+ return 1;
411
+ return a.name.localeCompare(b.name);
412
+ });
413
+ for (const entry of sortedEntries.slice(0, 50)) { // Limit to 50 entries
414
+ if (entry.name.startsWith('.'))
415
+ continue; // Skip hidden files
416
+ if (entry.isDirectory()) {
417
+ lines.push(`${path.basename(folderPath)}/${entry.name}/`);
418
+ }
419
+ else {
420
+ const filePath = path.join(folderPath, entry.name);
421
+ const fileStats = await fs.stat(filePath);
422
+ const size = fileStats.size < 1024 ? `${fileStats.size}B` : `${Math.round(fileStats.size / 1024)}KB`;
423
+ lines.push(`${path.basename(folderPath)}/${entry.name} (${size})`);
424
+ }
425
+ }
426
+ if (entries.length > 50) {
427
+ lines.push(`... and ${entries.length - 50} more items`);
428
+ }
429
+ return lines.join('\n');
430
+ }
431
+ findLastUserMessage(messages) {
432
+ for (let i = messages.length - 1; i >= 0; i--) {
433
+ if (messages[i].role === 'user') {
434
+ return i;
435
+ }
436
+ }
437
+ return -1;
438
+ }
439
+ async getProjectPath() {
440
+ try {
441
+ const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
442
+ return projectPath || process.cwd();
443
+ }
444
+ catch (error) {
445
+ console.warn('Failed to get project path from codebolt.project.getProjectPath(), falling back to process.cwd()');
446
+ return process.cwd();
447
+ }
448
+ }
449
+ isNodeError(error) {
450
+ return error instanceof Error && 'code' in error;
451
+ }
452
+ }
453
+ exports.AtFileProcessorModifier = AtFileProcessorModifier;
@@ -0,0 +1,7 @@
1
+ import { ProcessedMessage } from "@codebolt/types/agent";
2
+ import { BaseMessageModifier } from "../base";
3
+ import { FlatUserMessage } from "@codebolt/types/sdk";
4
+ export declare class BaseContextMessageModifier extends BaseMessageModifier {
5
+ constructor();
6
+ modify(originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
7
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BaseContextMessageModifier = void 0;
7
+ const base_1 = require("../base");
8
+ const codeboltjs_1 = __importDefault(require("@codebolt/codeboltjs"));
9
+ const os_1 = __importDefault(require("os"));
10
+ class BaseContextMessageModifier extends base_1.BaseMessageModifier {
11
+ constructor() {
12
+ super();
13
+ }
14
+ async modify(originalRequest, createdMessage) {
15
+ const contextParts = [];
16
+ const now = new Date();
17
+ contextParts.push(`Current Date/Time: ${now.toISOString()}`);
18
+ const osInfo = {
19
+ platform: os_1.default.platform(),
20
+ arch: os_1.default.arch(),
21
+ version: os_1.default.version(),
22
+ hostname: os_1.default.hostname()
23
+ };
24
+ contextParts.push(`Operating System: ${JSON.stringify(osInfo, null, 2)}`);
25
+ try {
26
+ const { projectPath } = await codeboltjs_1.default.project.getProjectPath();
27
+ contextParts.push(`Working Directory: ${projectPath}`);
28
+ }
29
+ catch (error) {
30
+ contextParts.push(`Working Directory: ${process.cwd()}`);
31
+ }
32
+ if (contextParts.length > 0) {
33
+ const contextMessage = {
34
+ role: 'system',
35
+ content: contextParts.join('\n\n'),
36
+ };
37
+ // Create a copy of messages array
38
+ const messages = [...createdMessage.message.messages];
39
+ // Check if system message already exists in the messages array
40
+ const existingSystemMessageIndex = messages.findIndex(msg => msg.role == 'system');
41
+ if (existingSystemMessageIndex !== -1) {
42
+ // Append context to existing system message content
43
+ const existingContent = messages[existingSystemMessageIndex].content || '';
44
+ messages[existingSystemMessageIndex] = {
45
+ ...messages[existingSystemMessageIndex],
46
+ content: existingContent + '\n\n' + contextMessage.content
47
+ };
48
+ }
49
+ else {
50
+ // Add system message to the top of the array
51
+ messages.unshift(contextMessage);
52
+ }
53
+ // Return new ProcessedMessage object
54
+ return {
55
+ message: {
56
+ ...createdMessage.message,
57
+ messages
58
+ },
59
+ metadata: {
60
+ ...createdMessage.metadata
61
+ }
62
+ };
63
+ }
64
+ return createdMessage;
65
+ }
66
+ }
67
+ exports.BaseContextMessageModifier = BaseContextMessageModifier;
@@ -0,0 +1,9 @@
1
+ import { ProcessedMessage } from "@codebolt/types/agent";
2
+ import { BaseMessageModifier } from "../base";
3
+ import { FlatUserMessage } from "@codebolt/types/sdk";
4
+ export declare class BaseSystemInstructionMessageModifier extends BaseMessageModifier {
5
+ private readonly systemInstruction;
6
+ constructor(systemInstruction?: string);
7
+ modify(originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
8
+ private getCoreSystemPrompt;
9
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSystemInstructionMessageModifier = void 0;
4
+ const base_1 = require("../base");
5
+ class BaseSystemInstructionMessageModifier extends base_1.BaseMessageModifier {
6
+ constructor(systemInstruction) {
7
+ super();
8
+ this.systemInstruction = systemInstruction || this.getCoreSystemPrompt();
9
+ }
10
+ async modify(originalRequest, createdMessage) {
11
+ try {
12
+ // Create system instruction message
13
+ const systemMessage = {
14
+ role: 'system',
15
+ content: this.systemInstruction
16
+ };
17
+ // Get existing messages
18
+ const messages = [...(createdMessage.message.messages || [])];
19
+ // Check if system message already exists
20
+ const existingSystemIndex = messages.findIndex(msg => msg.role === 'system');
21
+ if (existingSystemIndex !== -1) {
22
+ // Update existing system message
23
+ messages[existingSystemIndex] = systemMessage;
24
+ }
25
+ else {
26
+ // Add system message to first position
27
+ messages.unshift(systemMessage);
28
+ }
29
+ // Return new ProcessedMessage object
30
+ return {
31
+ message: {
32
+ ...createdMessage.message,
33
+ messages
34
+ },
35
+ metadata: {
36
+ ...createdMessage.metadata
37
+ }
38
+ };
39
+ }
40
+ catch (error) {
41
+ console.error('Error in BaseSystemInstructionMessageModifier:', error);
42
+ throw error;
43
+ }
44
+ }
45
+ getCoreSystemPrompt() {
46
+ // Default system prompt similar to gemini-cli but simplified for CodeBolt context
47
+ const basePrompt = `
48
+ You are an interactive AI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
49
+
50
+ # Core Mandates
51
+
52
+ - **Conventions:** Rigorously adhere to existing project conventions when reading or modifying code. Analyze surrounding code, tests, and configuration first.
53
+ - **Libraries/Frameworks:** NEVER assume a library/framework is available or appropriate. Verify its established usage within the project before employing it.
54
+ - **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
55
+ - **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
56
+ - **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done.
57
+ - **Proactiveness:** Fulfill the user's request thoroughly, including reasonable, directly implied follow-up actions.
58
+ - **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user.
59
+ - **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
60
+
61
+ # Primary Workflows
62
+
63
+ ## Software Engineering Tasks
64
+ When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
65
+ 1. **Understand:** Think about the user's request and the relevant codebase context. Use search tools extensively to understand file structures, existing code patterns, and conventions.
66
+ 2. **Plan:** Build a coherent and grounded plan for how you intend to resolve the user's task. Share a concise yet clear plan with the user if it would help.
67
+ 3. **Implement:** Use the available tools to act on the plan, strictly adhering to the project's established conventions.
68
+ 4. **Verify:** If applicable and feasible, verify the changes using the project's testing procedures and build/lint commands.
69
+
70
+ # Operational Guidelines
71
+
72
+ ## Tone and Style
73
+ - **Concise & Direct:** Adopt a professional, direct, and concise tone.
74
+ - **Minimal Output:** Aim for fewer than 3 lines of text output per response whenever practical.
75
+ - **Clarity over Brevity:** While conciseness is key, prioritize clarity for essential explanations.
76
+ - **No Chitchat:** Avoid conversational filler. Get straight to the action or answer.
77
+ - **Formatting:** Use GitHub-flavored Markdown.
78
+
79
+ ## Security and Safety Rules
80
+ - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
81
+ - **File Operations:** Always use absolute paths when referring to files with tools.
82
+
83
+ # Final Reminder
84
+ Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions.
85
+ Do not ask for more information than necessary. Use the tools provided to accomplish the user's request efficiently and effectively. When you've completed your task, you must use the attempt_completion tool to present the result to the user. The user may provide feedback, which you can use to make improvements and try again.
86
+ `.trim();
87
+ return basePrompt;
88
+ }
89
+ }
90
+ exports.BaseSystemInstructionMessageModifier = BaseSystemInstructionMessageModifier;
@@ -0,0 +1,19 @@
1
+ import { ProcessedMessage } from "@codebolt/types/agent";
2
+ import { BaseMessageModifier } from "../base";
3
+ import { FlatUserMessage } from "@codebolt/types/sdk";
4
+ export interface ChatCompressionOptions {
5
+ tokenThreshold?: number;
6
+ compressionRatio?: number;
7
+ preserveRecentMessages?: number;
8
+ enableCompression?: boolean;
9
+ }
10
+ export declare class ChatCompressionModifier extends BaseMessageModifier {
11
+ private readonly options;
12
+ private hasFailedCompressionAttempt;
13
+ constructor(options?: ChatCompressionOptions);
14
+ modify(originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<ProcessedMessage>;
15
+ private shouldCompressChat;
16
+ private compressMessages;
17
+ private createConversationSummary;
18
+ resetCompressionState(): void;
19
+ }