@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,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workflow = void 0;
4
+ const crypto_1 = require("crypto");
5
+ class Workflow {
6
+ constructor(config) {
7
+ this.context = {};
8
+ this.currentStepIndex = 0;
9
+ this.executionId = '';
10
+ this.startTime = 0;
11
+ this.stepResults = [];
12
+ this.config = config;
13
+ }
14
+ execute() {
15
+ this.executionId = (0, crypto_1.randomUUID)();
16
+ this.startTime = Date.now();
17
+ try {
18
+ // Validate input if schema exists
19
+ if (this.config.inputSchema) {
20
+ this.config.inputSchema.parse(this.context);
21
+ }
22
+ // Execute all steps synchronously (note: this is a limitation due to BaseWorkflow interface)
23
+ // In a real implementation, you might want to use async/await with proper error handling
24
+ const stepResults = this.executeSteps();
25
+ const executionTime = Date.now() - this.startTime;
26
+ const success = stepResults.every(result => result.success);
27
+ // Validate output if schema exists
28
+ if (this.config.outputSchema && success) {
29
+ this.config.outputSchema.parse(this.context);
30
+ }
31
+ return {
32
+ executionId: this.executionId,
33
+ success,
34
+ data: this.context,
35
+ stepResults,
36
+ executionTime,
37
+ error: success ? undefined : 'One or more steps failed'
38
+ };
39
+ }
40
+ catch (error) {
41
+ const executionTime = Date.now() - this.startTime;
42
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
43
+ return {
44
+ executionId: this.executionId,
45
+ success: false,
46
+ data: this.context,
47
+ stepResults: this.stepResults,
48
+ executionTime,
49
+ error: errorMessage
50
+ };
51
+ }
52
+ }
53
+ executeStep() {
54
+ if (this.currentStepIndex >= this.config.steps.length) {
55
+ throw new Error('No more steps to execute');
56
+ }
57
+ const step = this.config.steps[this.currentStepIndex];
58
+ try {
59
+ // Note: Since BaseWorkflow expects sync methods, we can't properly handle async step execution
60
+ // This is a design limitation that would need to be addressed in the BaseWorkflow interface
61
+ const result = {
62
+ stepId: step.id,
63
+ success: true,
64
+ result: null,
65
+ metaData: this.context
66
+ };
67
+ this.currentStepIndex++;
68
+ this.stepResults.push(result);
69
+ return result;
70
+ }
71
+ catch (error) {
72
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
73
+ this.currentStepIndex++;
74
+ const errorResult = {
75
+ stepId: step.id,
76
+ success: false,
77
+ result: null,
78
+ error: errorMessage
79
+ };
80
+ this.stepResults.push(errorResult);
81
+ return errorResult;
82
+ }
83
+ }
84
+ executeSteps() {
85
+ const allResults = [];
86
+ for (let i = 0; i < this.config.steps.length; i++) {
87
+ const step = this.config.steps[i];
88
+ try {
89
+ // Note: This is a synchronous implementation due to BaseWorkflow interface constraints
90
+ // In a real async implementation, you would await step.execute(this.context)
91
+ const result = {
92
+ stepId: step.id,
93
+ success: true,
94
+ result: `Step ${step.id} executed synchronously`,
95
+ metaData: this.context
96
+ };
97
+ allResults.push(result);
98
+ // Update context with successful result
99
+ if (result.success && result.result !== null) {
100
+ this.updateContext({
101
+ [`step_${result.stepId}`]: result.result,
102
+ ...result.metaData
103
+ });
104
+ }
105
+ }
106
+ catch (error) {
107
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
108
+ const errorResult = {
109
+ stepId: step.id,
110
+ success: false,
111
+ result: null,
112
+ error: errorMessage
113
+ };
114
+ allResults.push(errorResult);
115
+ // Break on error (can be made configurable)
116
+ break;
117
+ }
118
+ }
119
+ this.stepResults = allResults;
120
+ return allResults;
121
+ }
122
+ getContext() {
123
+ return { ...this.context };
124
+ }
125
+ updateContext(newContext) {
126
+ this.context = { ...this.context, ...newContext };
127
+ }
128
+ // Additional utility methods for better workflow management
129
+ reset() {
130
+ this.context = {};
131
+ this.currentStepIndex = 0;
132
+ this.executionId = '';
133
+ this.startTime = 0;
134
+ this.stepResults = [];
135
+ }
136
+ getCurrentStepIndex() {
137
+ return this.currentStepIndex;
138
+ }
139
+ getTotalSteps() {
140
+ return this.config.steps.length;
141
+ }
142
+ getExecutionId() {
143
+ return this.executionId;
144
+ }
145
+ setInitialContext(context) {
146
+ this.context = { ...context };
147
+ }
148
+ getStepResults() {
149
+ return [...this.stepResults];
150
+ }
151
+ // Async versions of the methods for proper workflow execution
152
+ // These can be used when the BaseWorkflow interface is updated to support async
153
+ async executeAsync() {
154
+ this.executionId = (0, crypto_1.randomUUID)();
155
+ this.startTime = Date.now();
156
+ try {
157
+ // Validate input if schema exists
158
+ if (this.config.inputSchema) {
159
+ this.config.inputSchema.parse(this.context);
160
+ }
161
+ // Execute all steps asynchronously
162
+ const stepResults = await this.executeStepsAsync();
163
+ const executionTime = Date.now() - this.startTime;
164
+ const success = stepResults.every(result => result.success);
165
+ // Validate output if schema exists
166
+ if (this.config.outputSchema && success) {
167
+ this.config.outputSchema.parse(this.context);
168
+ }
169
+ return {
170
+ executionId: this.executionId,
171
+ success,
172
+ data: this.context,
173
+ stepResults,
174
+ executionTime,
175
+ error: success ? undefined : 'One or more steps failed'
176
+ };
177
+ }
178
+ catch (error) {
179
+ const executionTime = Date.now() - this.startTime;
180
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
181
+ return {
182
+ executionId: this.executionId,
183
+ success: false,
184
+ data: this.context,
185
+ stepResults: this.stepResults,
186
+ executionTime,
187
+ error: errorMessage
188
+ };
189
+ }
190
+ }
191
+ async executeStepAsync() {
192
+ if (this.currentStepIndex >= this.config.steps.length) {
193
+ throw new Error('No more steps to execute');
194
+ }
195
+ const step = this.config.steps[this.currentStepIndex];
196
+ try {
197
+ const result = await step.execute(this.context);
198
+ // Handle different return types based on step type
199
+ if (Array.isArray(result)) {
200
+ // For parallel, condition, or loop steps that return multiple results
201
+ const lastResult = result[result.length - 1];
202
+ this.currentStepIndex++;
203
+ this.stepResults.push(...result);
204
+ return lastResult;
205
+ }
206
+ else {
207
+ // For single step execution
208
+ this.currentStepIndex++;
209
+ this.stepResults.push(result);
210
+ return result;
211
+ }
212
+ }
213
+ catch (error) {
214
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
215
+ this.currentStepIndex++;
216
+ const errorResult = {
217
+ stepId: step.id,
218
+ success: false,
219
+ result: null,
220
+ error: errorMessage
221
+ };
222
+ this.stepResults.push(errorResult);
223
+ return errorResult;
224
+ }
225
+ }
226
+ async executeStepsAsync() {
227
+ const allResults = [];
228
+ for (let i = 0; i < this.config.steps.length; i++) {
229
+ const step = this.config.steps[i];
230
+ try {
231
+ const result = await step.execute(this.context);
232
+ // Handle different return types based on step type
233
+ if (Array.isArray(result)) {
234
+ // For parallel, condition, or loop steps that return multiple results
235
+ allResults.push(...result);
236
+ // Update context with successful results
237
+ result.forEach(stepResult => {
238
+ if (stepResult.success && stepResult.result !== null) {
239
+ this.updateContext({
240
+ [`step_${stepResult.stepId}`]: stepResult.result,
241
+ ...stepResult.metaData
242
+ });
243
+ }
244
+ });
245
+ }
246
+ else {
247
+ // For single step execution
248
+ allResults.push(result);
249
+ // Update context with successful result
250
+ if (result.success && result.result !== null) {
251
+ this.updateContext({
252
+ [`step_${result.stepId}`]: result.result,
253
+ ...result.metaData
254
+ });
255
+ }
256
+ }
257
+ }
258
+ catch (error) {
259
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
260
+ const errorResult = {
261
+ stepId: step.id,
262
+ success: false,
263
+ result: null,
264
+ error: errorMessage
265
+ };
266
+ allResults.push(errorResult);
267
+ // Break on error (can be made configurable)
268
+ break;
269
+ }
270
+ }
271
+ this.stepResults = allResults;
272
+ return allResults;
273
+ }
274
+ }
275
+ exports.Workflow = Workflow;
@@ -0,0 +1,11 @@
1
+ export declare abstract class WorkflowControls {
2
+ constructor();
3
+ }
4
+ export declare class Parallel extends WorkflowControls {
5
+ }
6
+ export declare class Conditional extends WorkflowControls {
7
+ }
8
+ export declare class Step extends WorkflowControls {
9
+ }
10
+ export declare class Router extends WorkflowControls {
11
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = exports.Step = exports.Conditional = exports.Parallel = exports.WorkflowControls = void 0;
4
+ class WorkflowControls {
5
+ constructor() {
6
+ }
7
+ }
8
+ exports.WorkflowControls = WorkflowControls;
9
+ class Parallel extends WorkflowControls {
10
+ }
11
+ exports.Parallel = Parallel;
12
+ class Conditional extends WorkflowControls {
13
+ }
14
+ exports.Conditional = Conditional;
15
+ class Step extends WorkflowControls {
16
+ }
17
+ exports.Step = Step;
18
+ class Router extends WorkflowControls {
19
+ }
20
+ exports.Router = Router;
@@ -0,0 +1,63 @@
1
+ import { AgentInterface, BaseWorkFlowStep, StepConfig, StepType, ToolInterface, workflowContext, workflowStepOutput } from "@codebolt/types/agent";
2
+ import { ZodType } from "zod";
3
+ export declare class ParallelStep implements BaseWorkFlowStep {
4
+ id: string;
5
+ description: string;
6
+ type: StepType;
7
+ inputSchema?: ZodType<any, any, any>;
8
+ outputSchema?: ZodType<any, any, any>;
9
+ private steps;
10
+ constructor(config: StepConfig, steps: WorkFlowStep[]);
11
+ execute(context: any): Promise<workflowContext>;
12
+ }
13
+ export declare class ConditionStep implements BaseWorkFlowStep {
14
+ id: string;
15
+ description: string;
16
+ type: StepType;
17
+ inputSchema?: ZodType<any, any, any>;
18
+ outputSchema?: ZodType<any, any, any>;
19
+ private steps;
20
+ constructor(config: StepConfig, steps: WorkFlowStep[]);
21
+ execute(context: any): Promise<workflowContext>;
22
+ }
23
+ export declare class LoopStep implements BaseWorkFlowStep {
24
+ id: string;
25
+ description: string;
26
+ type: StepType;
27
+ inputSchema?: ZodType<any, any, any>;
28
+ outputSchema?: ZodType<any, any, any>;
29
+ private steps;
30
+ private maxIterations;
31
+ constructor(config: StepConfig, steps: WorkFlowStep[], maxIterations?: number);
32
+ execute(context: any): Promise<workflowContext>;
33
+ }
34
+ export declare class WorkFlowStep implements BaseWorkFlowStep {
35
+ id: string;
36
+ description: string;
37
+ type: StepType;
38
+ inputSchema?: ZodType<any, any, any>;
39
+ outputSchema?: ZodType<any, any, any>;
40
+ private config;
41
+ constructor(config: StepConfig);
42
+ execute(context: any): Promise<workflowStepOutput>;
43
+ }
44
+ export declare class AgentStep implements BaseWorkFlowStep {
45
+ private agent;
46
+ id: string;
47
+ description: string;
48
+ type: StepType;
49
+ inputSchema?: ZodType<any, any, any>;
50
+ outputSchema?: ZodType<any, any, any>;
51
+ constructor(config: StepConfig, agent: AgentInterface);
52
+ execute(context: any): Promise<workflowStepOutput>;
53
+ }
54
+ export declare class ToolStep implements BaseWorkFlowStep {
55
+ private tool;
56
+ id: string;
57
+ description: string;
58
+ type: StepType;
59
+ inputSchema?: ZodType<any, any, any>;
60
+ outputSchema?: ZodType<any, any, any>;
61
+ constructor(config: StepConfig, tool: ToolInterface);
62
+ execute(context: any): Promise<workflowStepOutput>;
63
+ }
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolStep = exports.AgentStep = exports.WorkFlowStep = exports.LoopStep = exports.ConditionStep = exports.ParallelStep = void 0;
4
+ class ParallelStep {
5
+ constructor(config, steps) {
6
+ this.steps = steps;
7
+ this.id = config.id;
8
+ this.description = config.description;
9
+ this.type = config.type;
10
+ this.inputSchema = config.inputSchema;
11
+ this.outputSchema = config.outputSchema;
12
+ }
13
+ async execute(context) {
14
+ try {
15
+ // Execute all steps in parallel using Promise.all
16
+ const stepPromises = this.steps.map((step, index) => step.execute(context).catch(error => ({
17
+ stepId: `${this.id}_step_${index}`,
18
+ success: false,
19
+ result: null,
20
+ error: error instanceof Error ? error.message : 'Unknown error occurred'
21
+ })));
22
+ const results = await Promise.all(stepPromises);
23
+ return results;
24
+ }
25
+ catch (error) {
26
+ // If Promise.all fails entirely, return error result
27
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
28
+ return [{
29
+ stepId: this.id,
30
+ success: false,
31
+ result: null,
32
+ error: `Failed to execute parallel steps: ${errorMessage}`
33
+ }];
34
+ }
35
+ }
36
+ }
37
+ exports.ParallelStep = ParallelStep;
38
+ class ConditionStep {
39
+ constructor(config, steps) {
40
+ this.steps = steps;
41
+ this.id = config.id;
42
+ this.description = config.description;
43
+ this.type = config.type;
44
+ this.inputSchema = config.inputSchema;
45
+ this.outputSchema = config.outputSchema;
46
+ }
47
+ async execute(context) {
48
+ try {
49
+ // For condition step, execute steps sequentially based on conditions
50
+ // This is a basic implementation - you may want to add condition logic
51
+ const results = [];
52
+ for (let i = 0; i < this.steps.length; i++) {
53
+ const step = this.steps[i];
54
+ try {
55
+ const result = await step.execute(context);
56
+ results.push(result);
57
+ // If step fails and it's a condition, you might want to break or continue
58
+ // This depends on your condition logic
59
+ if (!result.success) {
60
+ break; // Stop on first failure for condition step
61
+ }
62
+ }
63
+ catch (error) {
64
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
65
+ results.push({
66
+ stepId: `${this.id}_step_${i}`,
67
+ success: false,
68
+ result: null,
69
+ error: errorMessage
70
+ });
71
+ break; // Stop on error
72
+ }
73
+ }
74
+ return results;
75
+ }
76
+ catch (error) {
77
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
78
+ return [{
79
+ stepId: this.id,
80
+ success: false,
81
+ result: null,
82
+ error: `Failed to execute condition steps: ${errorMessage}`
83
+ }];
84
+ }
85
+ }
86
+ }
87
+ exports.ConditionStep = ConditionStep;
88
+ class LoopStep {
89
+ constructor(config, steps, maxIterations = 10) {
90
+ this.steps = steps;
91
+ this.id = config.id;
92
+ this.description = config.description;
93
+ this.type = config.type;
94
+ this.inputSchema = config.inputSchema;
95
+ this.outputSchema = config.outputSchema;
96
+ this.maxIterations = maxIterations;
97
+ }
98
+ async execute(context) {
99
+ try {
100
+ const allResults = [];
101
+ let iteration = 0;
102
+ let shouldContinue = true;
103
+ while (shouldContinue && iteration < this.maxIterations) {
104
+ const iterationResults = [];
105
+ // Execute all steps in this iteration
106
+ for (let i = 0; i < this.steps.length; i++) {
107
+ const step = this.steps[i];
108
+ try {
109
+ const result = await step.execute(context);
110
+ result.stepId = `${result.stepId}_loop_${iteration}`;
111
+ iterationResults.push(result);
112
+ // You can add loop exit conditions based on step results
113
+ // For example, stop if a specific condition is met
114
+ if (!result.success) {
115
+ shouldContinue = false;
116
+ break;
117
+ }
118
+ }
119
+ catch (error) {
120
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
121
+ iterationResults.push({
122
+ stepId: `${this.id}_step_${i}_loop_${iteration}`,
123
+ success: false,
124
+ result: null,
125
+ error: errorMessage
126
+ });
127
+ shouldContinue = false;
128
+ break;
129
+ }
130
+ }
131
+ allResults.push(...iterationResults);
132
+ iteration++;
133
+ // You can add custom loop continuation logic here
134
+ // For now, it continues until max iterations or failure
135
+ }
136
+ return allResults;
137
+ }
138
+ catch (error) {
139
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
140
+ return [{
141
+ stepId: this.id,
142
+ success: false,
143
+ result: null,
144
+ error: `Failed to execute loop steps: ${errorMessage}`
145
+ }];
146
+ }
147
+ }
148
+ }
149
+ exports.LoopStep = LoopStep;
150
+ class WorkFlowStep {
151
+ constructor(config) {
152
+ this.config = config;
153
+ this.id = config.id;
154
+ this.description = config.description;
155
+ this.type = config.type;
156
+ this.inputSchema = config.inputSchema;
157
+ this.outputSchema = config.outputSchema;
158
+ }
159
+ async execute(context) {
160
+ try {
161
+ const result = await this.config.execute(context);
162
+ return {
163
+ stepId: this.config.id,
164
+ success: true,
165
+ result: result,
166
+ metaData: context
167
+ };
168
+ }
169
+ catch (error) {
170
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
171
+ return {
172
+ stepId: this.config.id,
173
+ success: false,
174
+ result: null,
175
+ error: errorMessage
176
+ };
177
+ }
178
+ }
179
+ }
180
+ exports.WorkFlowStep = WorkFlowStep;
181
+ class AgentStep {
182
+ constructor(config, agent) {
183
+ this.agent = agent;
184
+ this.id = config.id;
185
+ this.description = config.description;
186
+ this.type = config.type;
187
+ this.inputSchema = config.inputSchema;
188
+ this.outputSchema = config.outputSchema;
189
+ }
190
+ async execute(context) {
191
+ let { result, success, error } = await this.agent.execute(context);
192
+ return {
193
+ stepId: this.id,
194
+ success: success,
195
+ result: result,
196
+ error: error
197
+ };
198
+ }
199
+ }
200
+ exports.AgentStep = AgentStep;
201
+ class ToolStep {
202
+ constructor(config, tool) {
203
+ this.id = config.id;
204
+ this.description = config.description;
205
+ this.type = config.type;
206
+ this.inputSchema = config.inputSchema;
207
+ this.outputSchema = config.outputSchema;
208
+ this.tool = tool;
209
+ }
210
+ async execute(context) {
211
+ try {
212
+ let { result, success, error } = await this.tool.execute({}, context);
213
+ return {
214
+ stepId: this.id,
215
+ success: success,
216
+ result: result,
217
+ error: error
218
+ };
219
+ }
220
+ catch (error) {
221
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
222
+ return {
223
+ stepId: this.id,
224
+ success: false,
225
+ result: null,
226
+ error: errorMessage
227
+ };
228
+ }
229
+ }
230
+ }
231
+ exports.ToolStep = ToolStep;
232
+ // export class parllelAgentStep implements BaseWorkFlowStep{
233
+ // private agents: AgentInterface[]
234
+ // private config: StepConfig
235
+ // constructor(config: StepConfig, agents: AgentInterface[]) {
236
+ // super(config)
237
+ // this.config = config
238
+ // this.agents = agents
239
+ // }
240
+ // async execute(context: any): Promise<workflowStepOutput> {
241
+ // try {
242
+ // // Execute all agents in parallel using Promise.all
243
+ // const agentPromises = this.agents.map((agent, index) =>
244
+ // agent.execute().then(result => ({
245
+ // agentIndex: index,
246
+ // ...result
247
+ // })).catch(error => ({
248
+ // agentIndex: index,
249
+ // success: false,
250
+ // result: null,
251
+ // error: error instanceof Error ? error.message : 'Unknown error occurred'
252
+ // }))
253
+ // );
254
+ // const results = await Promise.all(agentPromises);
255
+ // // Aggregate results
256
+ // const successfulResults = results.filter(result => result.success);
257
+ // const failedResults = results.filter(result => !result.success);
258
+ // const overallSuccess = failedResults.length === 0;
259
+ // return {
260
+ // stepId: this.id,
261
+ // success: overallSuccess,
262
+ // result: {
263
+ // totalAgents: this.agents.length,
264
+ // successfulAgents: successfulResults.length,
265
+ // failedAgents: failedResults.length,
266
+ // results: results,
267
+ // successfulResults: successfulResults.map(r => r.result),
268
+ // errors: failedResults.map(r => ({ agentIndex: r.agentIndex, error: r.error }))
269
+ // },
270
+ // error: failedResults.length > 0 ?
271
+ // `${failedResults.length} out of ${this.agents.length} agents failed` :
272
+ // undefined
273
+ // };
274
+ // } catch (error) {
275
+ // const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
276
+ // return {
277
+ // stepId: this.id,
278
+ // success: false,
279
+ // result: null,
280
+ // error: `Failed to execute parallel agents: ${errorMessage}`
281
+ // };
282
+ // }
283
+ // }
284
+ // }
@@ -0,0 +1,32 @@
1
+ import { PostInferenceProcessor, PreInferenceProcessor, AgentStepInterface, AgentStepOutput, ProcessedMessage } from '@codebolt/types/agent';
2
+ import { FlatUserMessage } from '@codebolt/types/sdk';
3
+ /**
4
+ * Unified agent step that handles LLM interaction and tool call analysis
5
+ */
6
+ export declare class AgentStep implements AgentStepInterface {
7
+ private preInferenceProcessors;
8
+ private postInferenceProcessors;
9
+ private llmRole;
10
+ constructor(options?: {
11
+ preInferenceProcessors?: PreInferenceProcessor[];
12
+ postInferenceProcessors?: PostInferenceProcessor[];
13
+ llmRole?: string;
14
+ });
15
+ /**
16
+ * Execute a single agent step
17
+ */
18
+ executeStep(originalRequest: FlatUserMessage, createdMessage: ProcessedMessage): Promise<AgentStepOutput>;
19
+ private generateResponse;
20
+ /**
21
+ * Update LLM configuration
22
+ */
23
+ setLLMConfig(config: string): void;
24
+ /**
25
+ * Get current LLM configuration
26
+ */
27
+ getLLMConfig(): string;
28
+ updatePreInferenceProcessors(processors: PreInferenceProcessor[]): void;
29
+ getPreInferenceProcessors(): PreInferenceProcessor[];
30
+ updatePostInferenceProcessors(processors: PostInferenceProcessor[]): void;
31
+ getPostInferenceProcessors(): PostInferenceProcessor[];
32
+ }