@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,372 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Document handling for Composable Agent Pattern
4
+ * @description Provides document processing, chunking, and embedding capabilities
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.MDocument = void 0;
8
+ /**
9
+ * Document processing and management class
10
+ */
11
+ class MDocument {
12
+ constructor(content, type = 'text', metadata = {}) {
13
+ this.content = content;
14
+ this.type = type;
15
+ this.metadata = {
16
+ ...metadata,
17
+ createdAt: new Date().toISOString(),
18
+ wordCount: this.countWords(content),
19
+ charCount: content.length
20
+ };
21
+ }
22
+ /**
23
+ * Create MDocument from plain text
24
+ *
25
+ * @param text - Plain text content
26
+ * @param metadata - Optional metadata
27
+ * @returns MDocument instance
28
+ */
29
+ static fromText(text, metadata) {
30
+ return new MDocument(text, 'text', metadata);
31
+ }
32
+ /**
33
+ * Create MDocument from markdown
34
+ *
35
+ * @param markdown - Markdown content
36
+ * @param metadata - Optional metadata
37
+ * @returns MDocument instance
38
+ */
39
+ static fromMarkdown(markdown, metadata) {
40
+ return new MDocument(markdown, 'markdown', metadata);
41
+ }
42
+ /**
43
+ * Create MDocument from JSON
44
+ *
45
+ * @param json - JSON object or string
46
+ * @param metadata - Optional metadata
47
+ * @returns MDocument instance
48
+ */
49
+ static fromJSON(json, metadata) {
50
+ const content = typeof json === 'string' ? json : JSON.stringify(json, null, 2);
51
+ return new MDocument(content, 'json', metadata);
52
+ }
53
+ /**
54
+ * Create MDocument from file path
55
+ *
56
+ * @param filePath - Path to the file
57
+ * @param metadata - Optional metadata
58
+ * @returns Promise<MDocument> instance
59
+ */
60
+ static async fromFile(filePath, metadata) {
61
+ const fs = await import('fs/promises');
62
+ const path = await import('path');
63
+ const content = await fs.readFile(filePath, 'utf-8');
64
+ const extension = path.extname(filePath).toLowerCase();
65
+ let type = 'text';
66
+ if (extension === '.md')
67
+ type = 'markdown';
68
+ else if (extension === '.json')
69
+ type = 'json';
70
+ else if (extension === '.xml')
71
+ type = 'xml';
72
+ const fileMetadata = {
73
+ ...metadata,
74
+ filePath,
75
+ fileName: path.basename(filePath),
76
+ fileExtension: extension
77
+ };
78
+ return new MDocument(content, type, fileMetadata);
79
+ }
80
+ /**
81
+ * Get document content
82
+ */
83
+ getContent() {
84
+ return this.content;
85
+ }
86
+ /**
87
+ * Get document type
88
+ */
89
+ getType() {
90
+ return this.type;
91
+ }
92
+ /**
93
+ * Get document metadata
94
+ */
95
+ getMetadata() {
96
+ return { ...this.metadata };
97
+ }
98
+ /**
99
+ * Update document metadata
100
+ *
101
+ * @param metadata - Metadata to merge
102
+ */
103
+ updateMetadata(metadata) {
104
+ this.metadata = {
105
+ ...this.metadata,
106
+ ...metadata,
107
+ updatedAt: new Date().toISOString()
108
+ };
109
+ }
110
+ /**
111
+ * Chunk the document into smaller pieces
112
+ *
113
+ * @param options - Chunking options
114
+ * @returns Array of text chunks
115
+ */
116
+ chunk(options = {}) {
117
+ const { size = 1000, overlap = 100, strategy = 'paragraph' } = options;
118
+ let chunks;
119
+ switch (strategy) {
120
+ case 'sentence':
121
+ chunks = this.chunkBySentence(size, overlap);
122
+ break;
123
+ case 'paragraph':
124
+ chunks = this.chunkByParagraph(size, overlap);
125
+ break;
126
+ case 'semantic':
127
+ chunks = this.chunkSemantic(size, overlap);
128
+ break;
129
+ case 'fixed':
130
+ default:
131
+ chunks = this.chunkFixed(size, overlap);
132
+ break;
133
+ }
134
+ this.chunks = chunks;
135
+ this.updateMetadata({
136
+ chunkCount: chunks.length,
137
+ chunkStrategy: strategy,
138
+ chunkSize: size,
139
+ chunkOverlap: overlap
140
+ });
141
+ return chunks;
142
+ }
143
+ /**
144
+ * Get existing chunks or create them if they don't exist
145
+ */
146
+ getChunks() {
147
+ if (!this.chunks) {
148
+ return this.chunk();
149
+ }
150
+ return this.chunks;
151
+ }
152
+ /**
153
+ * Set embeddings for the document or its chunks
154
+ *
155
+ * @param embeddings - Array of embedding vectors
156
+ */
157
+ setEmbeddings(embeddings) {
158
+ var _a;
159
+ this.embeddings = embeddings;
160
+ this.updateMetadata({
161
+ hasEmbeddings: true,
162
+ embeddingCount: embeddings.length,
163
+ embeddingDimension: ((_a = embeddings[0]) === null || _a === void 0 ? void 0 : _a.length) || 0
164
+ });
165
+ }
166
+ /**
167
+ * Get embeddings
168
+ */
169
+ getEmbeddings() {
170
+ return this.embeddings;
171
+ }
172
+ /**
173
+ * Convert to processed document format
174
+ */
175
+ toProcessedDocument() {
176
+ return {
177
+ content: this.content,
178
+ chunks: this.chunks,
179
+ metadata: this.metadata,
180
+ embeddings: this.embeddings
181
+ };
182
+ }
183
+ /**
184
+ * Convert to plain object
185
+ */
186
+ toJSON() {
187
+ return {
188
+ content: this.content,
189
+ type: this.type,
190
+ metadata: this.metadata,
191
+ chunks: this.chunks,
192
+ embeddings: this.embeddings
193
+ };
194
+ }
195
+ /**
196
+ * Create MDocument from processed document
197
+ *
198
+ * @param processed - Processed document data
199
+ * @returns MDocument instance
200
+ */
201
+ static fromProcessedDocument(processed) {
202
+ const doc = new MDocument(processed.content, processed.metadata.type || 'text', processed.metadata);
203
+ if (processed.chunks) {
204
+ doc.chunks = processed.chunks;
205
+ }
206
+ if (processed.embeddings) {
207
+ doc.embeddings = processed.embeddings;
208
+ }
209
+ return doc;
210
+ }
211
+ /**
212
+ * Extract text content based on document type
213
+ */
214
+ extractText() {
215
+ switch (this.type) {
216
+ case 'markdown':
217
+ return this.extractMarkdownText();
218
+ case 'json':
219
+ return this.extractJSONText();
220
+ case 'xml':
221
+ return this.extractXMLText();
222
+ default:
223
+ return this.content;
224
+ }
225
+ }
226
+ /**
227
+ * Count words in content
228
+ */
229
+ countWords(content) {
230
+ return content.trim().split(/\s+/).filter(word => word.length > 0).length;
231
+ }
232
+ /**
233
+ * Fixed-size chunking with overlap
234
+ */
235
+ chunkFixed(size, overlap) {
236
+ const chunks = [];
237
+ let start = 0;
238
+ while (start < this.content.length) {
239
+ const end = Math.min(start + size, this.content.length);
240
+ chunks.push(this.content.slice(start, end));
241
+ if (end === this.content.length)
242
+ break;
243
+ start = end - overlap;
244
+ }
245
+ return chunks;
246
+ }
247
+ /**
248
+ * Sentence-based chunking
249
+ */
250
+ chunkBySentence(size, overlap) {
251
+ const sentences = this.content.split(/[.!?]+/).filter(s => s.trim().length > 0);
252
+ const chunks = [];
253
+ let currentChunk = '';
254
+ let currentSize = 0;
255
+ for (const sentence of sentences) {
256
+ const sentenceSize = sentence.length;
257
+ if (currentSize + sentenceSize > size && currentChunk) {
258
+ chunks.push(currentChunk.trim());
259
+ // Handle overlap by keeping some sentences
260
+ if (overlap > 0) {
261
+ const overlapSentences = currentChunk.split(/[.!?]+/).slice(-Math.ceil(overlap / 100));
262
+ currentChunk = overlapSentences.join('. ') + '. ';
263
+ currentSize = currentChunk.length;
264
+ }
265
+ else {
266
+ currentChunk = '';
267
+ currentSize = 0;
268
+ }
269
+ }
270
+ currentChunk += sentence + '. ';
271
+ currentSize += sentenceSize;
272
+ }
273
+ if (currentChunk.trim()) {
274
+ chunks.push(currentChunk.trim());
275
+ }
276
+ return chunks;
277
+ }
278
+ /**
279
+ * Paragraph-based chunking
280
+ */
281
+ chunkByParagraph(size, overlap) {
282
+ const paragraphs = this.content.split(/\n\s*\n/).filter(p => p.trim().length > 0);
283
+ const chunks = [];
284
+ let currentChunk = '';
285
+ let currentSize = 0;
286
+ for (const paragraph of paragraphs) {
287
+ const paragraphSize = paragraph.length;
288
+ if (currentSize + paragraphSize > size && currentChunk) {
289
+ chunks.push(currentChunk.trim());
290
+ // Handle overlap
291
+ if (overlap > 0) {
292
+ const words = currentChunk.split(/\s+/);
293
+ const overlapWords = words.slice(-overlap);
294
+ currentChunk = overlapWords.join(' ') + ' ';
295
+ currentSize = currentChunk.length;
296
+ }
297
+ else {
298
+ currentChunk = '';
299
+ currentSize = 0;
300
+ }
301
+ }
302
+ currentChunk += paragraph + '\n\n';
303
+ currentSize += paragraphSize;
304
+ }
305
+ if (currentChunk.trim()) {
306
+ chunks.push(currentChunk.trim());
307
+ }
308
+ return chunks;
309
+ }
310
+ /**
311
+ * Semantic chunking (basic implementation)
312
+ */
313
+ chunkSemantic(size, overlap) {
314
+ // For now, fall back to paragraph chunking
315
+ // In a full implementation, this would use NLP techniques
316
+ return this.chunkByParagraph(size, overlap);
317
+ }
318
+ /**
319
+ * Extract text from markdown
320
+ */
321
+ extractMarkdownText() {
322
+ // Simple markdown text extraction
323
+ return this.content
324
+ .replace(/^#+\s+/gm, '') // Remove headers
325
+ .replace(/\*\*(.*?)\*\*/g, '$1') // Remove bold
326
+ .replace(/\*(.*?)\*/g, '$1') // Remove italic
327
+ .replace(/`(.*?)`/g, '$1') // Remove inline code
328
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Remove links
329
+ .replace(/```[\s\S]*?```/g, '') // Remove code blocks
330
+ .trim();
331
+ }
332
+ /**
333
+ * Extract text from JSON
334
+ */
335
+ extractJSONText() {
336
+ try {
337
+ const obj = JSON.parse(this.content);
338
+ return this.extractTextFromObject(obj);
339
+ }
340
+ catch {
341
+ return this.content;
342
+ }
343
+ }
344
+ /**
345
+ * Extract text from XML
346
+ */
347
+ extractXMLText() {
348
+ // Simple XML text extraction
349
+ return this.content.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
350
+ }
351
+ /**
352
+ * Recursively extract text from object
353
+ */
354
+ extractTextFromObject(obj) {
355
+ if (typeof obj === 'string')
356
+ return obj;
357
+ if (typeof obj === 'number')
358
+ return obj.toString();
359
+ if (typeof obj === 'boolean')
360
+ return obj.toString();
361
+ if (obj === null || obj === undefined)
362
+ return '';
363
+ if (Array.isArray(obj)) {
364
+ return obj.map(item => this.extractTextFromObject(item)).join(' ');
365
+ }
366
+ if (typeof obj === 'object') {
367
+ return Object.values(obj).map(value => this.extractTextFromObject(value)).join(' ');
368
+ }
369
+ return '';
370
+ }
371
+ }
372
+ exports.MDocument = MDocument;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @fileoverview CodeBolt Integration Example
3
+ * @description Example showing how to use ComposableAgent within CodeBolt's onMessage system
4
+ */
5
+ import { ComposableAgent } from '../index';
6
+ declare const myAgent: ComposableAgent;
7
+ declare const flexibleAgent: ComposableAgent;
8
+ declare const researchAgent: ComposableAgent;
9
+ declare const writingAgent: ComposableAgent;
10
+ declare const workflowAgent: ComposableAgent;
11
+ declare const complexWorkflow: import("../workflow").Workflow;
12
+ export { myAgent, flexibleAgent, researchAgent, writingAgent, workflowAgent, complexWorkflow };
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview CodeBolt Integration Example
4
+ * @description Example showing how to use ComposableAgent within CodeBolt's onMessage system
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.complexWorkflow = exports.workflowAgent = exports.writingAgent = exports.researchAgent = exports.flexibleAgent = exports.myAgent = void 0;
8
+ const index_1 = require("../index");
9
+ // This would typically be in a separate file, e.g., agent.js
10
+ const codebolt = require('@codebolt/codeboltjs');
11
+ // Create your tools
12
+ const weatherTool = (0, index_1.createTool)({
13
+ id: 'get-weather',
14
+ description: 'Get current weather for a location',
15
+ inputSchema: index_1.z.object({
16
+ location: index_1.z.string().describe('City name'),
17
+ }),
18
+ outputSchema: index_1.z.object({
19
+ temperature: index_1.z.number(),
20
+ conditions: index_1.z.string(),
21
+ location: index_1.z.string(),
22
+ }),
23
+ execute: async ({ context }) => {
24
+ // Mock weather data
25
+ return {
26
+ temperature: 22,
27
+ conditions: 'Sunny',
28
+ location: context.location
29
+ };
30
+ },
31
+ });
32
+ // Create your composable agent
33
+ const myAgent = new index_1.ComposableAgent({
34
+ name: 'Weather Assistant',
35
+ instructions: `
36
+ You are a helpful weather assistant.
37
+ Use the weather tool to get current weather information.
38
+ Be friendly and provide helpful responses.
39
+ `,
40
+ model: 'weathermodel', // References configuration in codeboltagents.yaml
41
+ tools: { weatherTool },
42
+ processing: {
43
+ // Configure what to process automatically
44
+ processMentionedMCPs: true, // Auto-add mentioned MCPs as tools
45
+ processRemixPrompt: true, // Use remix prompt to enhance instructions
46
+ processMentionedFiles: true, // Include mentioned file contents
47
+ processMentionedAgents: true // Add mentioned agents as sub-agents
48
+ }
49
+ });
50
+ exports.myAgent = myAgent;
51
+ // CodeBolt integration - this is how you'd use it in your agent
52
+ codebolt.onMessage(async (reqMessage) => {
53
+ try {
54
+ console.log('Received message:', reqMessage);
55
+ // Save the user message globally so the agent can access it
56
+ (0, index_1.saveUserMessage)(reqMessage, {
57
+ // You can override the auto-detection here if needed
58
+ processMentionedMCPs: true,
59
+ processRemixPrompt: true,
60
+ processMentionedFiles: false, // Don't process files for this agent
61
+ processMentionedAgents: true
62
+ });
63
+ // Now simply run the agent - it will automatically use the saved user context
64
+ const result = await myAgent.run();
65
+ if (result.success) {
66
+ return result.message;
67
+ }
68
+ else {
69
+ console.error('Agent failed:', result.error);
70
+ return 'Sorry, I encountered an error processing your request.';
71
+ }
72
+ }
73
+ catch (error) {
74
+ console.error('Error in agent execution:', error);
75
+ return 'Sorry, something went wrong.';
76
+ }
77
+ });
78
+ // ================================
79
+ // Alternative Example: Manual Configuration per Message
80
+ // ================================
81
+ const flexibleAgent = new index_1.ComposableAgent({
82
+ name: 'Flexible Assistant',
83
+ instructions: 'I am a flexible assistant that adapts based on user context.',
84
+ model: 'gpt-4o-mini', // References configuration in codeboltagents.yaml
85
+ tools: { weatherTool }
86
+ // No processing config - will use global user config
87
+ });
88
+ exports.flexibleAgent = flexibleAgent;
89
+ codebolt.onMessage(async (reqMessage) => {
90
+ var _a, _b;
91
+ try {
92
+ // Analyze the message to determine what to process
93
+ const shouldProcessMCPs = ((_a = reqMessage.mentionedMCPs) === null || _a === void 0 ? void 0 : _a.length) > 0;
94
+ const shouldProcessFiles = (_b = reqMessage.mentionedFiles) === null || _b === void 0 ? void 0 : _b.some((file) => file.endsWith('.json') || file.endsWith('.yaml'));
95
+ // Save with custom configuration
96
+ (0, index_1.saveUserMessage)(reqMessage, {
97
+ processMentionedMCPs: shouldProcessMCPs,
98
+ processRemixPrompt: true,
99
+ processMentionedFiles: shouldProcessFiles,
100
+ processMentionedAgents: false // Don't use sub-agents for this example
101
+ });
102
+ // Run the agent
103
+ const result = await flexibleAgent.run();
104
+ return result.success ? result.message : 'Error occurred';
105
+ }
106
+ catch (error) {
107
+ console.error('Error:', error);
108
+ return 'Error processing request';
109
+ }
110
+ });
111
+ // ================================
112
+ // Example: Multiple Agents with Shared Context
113
+ // ================================
114
+ const researchAgent = new index_1.ComposableAgent({
115
+ name: 'Research Agent',
116
+ instructions: 'Research and gather information on topics.',
117
+ model: 'gpt-4o-mini', // References configuration in codeboltagents.yaml
118
+ processing: { processMentionedFiles: true } // This agent processes files
119
+ });
120
+ exports.researchAgent = researchAgent;
121
+ const writingAgent = new index_1.ComposableAgent({
122
+ name: 'Writing Agent',
123
+ instructions: 'Write content based on research and requirements.',
124
+ model: 'gpt-4o-mini', // References configuration in codeboltagents.yaml
125
+ processing: { processRemixPrompt: true } // This agent uses remix prompts
126
+ });
127
+ exports.writingAgent = writingAgent;
128
+ codebolt.onMessage(async (reqMessage) => {
129
+ try {
130
+ // Save user message once for all agents to use
131
+ (0, index_1.saveUserMessage)(reqMessage);
132
+ let result;
133
+ // Determine which agent to use based on message content
134
+ if (reqMessage.userMessage.toLowerCase().includes('research')) {
135
+ result = await researchAgent.run();
136
+ }
137
+ else if (reqMessage.userMessage.toLowerCase().includes('write')) {
138
+ result = await writingAgent.run();
139
+ }
140
+ else {
141
+ // Use the default agent
142
+ result = await myAgent.run();
143
+ }
144
+ return result.success ? result.message : 'Error occurred';
145
+ }
146
+ catch (error) {
147
+ console.error('Error:', error);
148
+ return 'Error processing request';
149
+ }
150
+ });
151
+ // ================================
152
+ // Example: Workflow with Global Context
153
+ // ================================
154
+ const index_2 = require("../index");
155
+ const workflowAgent = new index_1.ComposableAgent({
156
+ name: 'Workflow Agent',
157
+ instructions: 'I coordinate complex multi-step tasks.',
158
+ model: 'gpt-4o-mini' // References configuration in codeboltagents.yaml
159
+ });
160
+ exports.workflowAgent = workflowAgent;
161
+ const complexWorkflow = (0, index_2.createWorkflow)({
162
+ name: 'Research and Write Workflow',
163
+ initialData: {}, // Will be populated from user context
164
+ steps: [
165
+ // Extract user context into workflow data
166
+ (0, index_2.createSimpleStep)({
167
+ id: 'setup-context',
168
+ name: 'Setup Workflow Context',
169
+ execute: () => {
170
+ const userMsg = (0, index_1.getUserMessage)();
171
+ const files = (0, index_1.getMentionedFiles)();
172
+ const mcps = (0, index_1.getMentionedMCPs)();
173
+ return {
174
+ userMessage: (userMsg === null || userMsg === void 0 ? void 0 : userMsg.userMessage) || '',
175
+ mentionedFiles: files,
176
+ mentionedMCPs: mcps,
177
+ setupComplete: true
178
+ };
179
+ }
180
+ }),
181
+ // Use agent step that automatically gets user context
182
+ (0, index_2.createAgentStep)({
183
+ id: 'research-step',
184
+ name: 'Research Phase',
185
+ agent: researchAgent,
186
+ messageTemplate: 'Research this topic: {{userMessage}}',
187
+ outputMapping: { 'researchData': 'agentResult.message' }
188
+ }),
189
+ (0, index_2.createAgentStep)({
190
+ id: 'writing-step',
191
+ name: 'Writing Phase',
192
+ agent: writingAgent,
193
+ messageTemplate: 'Write content based on: {{researchData}}',
194
+ outputMapping: { 'finalContent': 'agentResult.message' }
195
+ })
196
+ ]
197
+ });
198
+ exports.complexWorkflow = complexWorkflow;
199
+ codebolt.onMessage(async (reqMessage) => {
200
+ try {
201
+ // Save user message for all agents and workflow steps to use
202
+ (0, index_1.saveUserMessage)(reqMessage);
203
+ if (reqMessage.userMessage.includes('complex task')) {
204
+ // Use workflow for complex tasks
205
+ const workflowResult = await complexWorkflow.execute();
206
+ return workflowResult.success ? workflowResult.data.finalContent : 'Workflow failed';
207
+ }
208
+ else {
209
+ // Use simple agent for regular tasks
210
+ const result = await workflowAgent.run();
211
+ return result.success ? result.message : 'Agent failed';
212
+ }
213
+ }
214
+ catch (error) {
215
+ console.error('Error:', error);
216
+ return 'Error processing request';
217
+ }
218
+ });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview Example demonstrating CodeBolt backend storage for ComposableAgent
3
+ * @description Shows how to use CodeBolt's state and memory functions instead of SQLite
4
+ */
5
+ import { ComposableAgent } from '../index';
6
+ /**
7
+ * Example: Weather Agent with CodeBolt Agent State Storage
8
+ * Data is stored in CodeBolt's agent state backend
9
+ */
10
+ export declare const weatherAgentWithAgentStorage: ComposableAgent;
11
+ /**
12
+ * Example: Task Management Agent with CodeBolt Project State Storage
13
+ * Data is stored in CodeBolt's project state backend
14
+ */
15
+ export declare const taskAgentWithProjectStorage: ComposableAgent;
16
+ /**
17
+ * Example: Knowledge Agent with CodeBolt Memory Database Storage
18
+ * Data is stored in CodeBolt's in-memory database backend
19
+ */
20
+ export declare const knowledgeAgentWithDbStorage: ComposableAgent;
21
+ /**
22
+ * Example usage within CodeBolt onMessage
23
+ */
24
+ export declare function setupCodeBoltStorageExample(): void;
25
+ /**
26
+ * Example: Custom storage configuration
27
+ */
28
+ export declare function createCustomStorageAgent(): ComposableAgent;
29
+ /**
30
+ * Example: Multiple agents with different storage backends
31
+ */
32
+ export declare function setupMultiStorageAgents(): {
33
+ sessionAgent: ComposableAgent;
34
+ globalAgent: ComposableAgent;
35
+ cacheAgent: ComposableAgent;
36
+ };
37
+ /**
38
+ * Storage comparison and migration helper
39
+ */
40
+ export declare function storageComparison(): Promise<void>;