@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,464 @@
1
+ "use strict";
2
+ /**
3
+ * Examples demonstrating how to use the high-level Agent class
4
+ * with the Unified Agent Framework
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.basicAgentExample = basicAgentExample;
8
+ exports.customAgentExample = customAgentExample;
9
+ exports.localToolInterceptionExample = localToolInterceptionExample;
10
+ exports.dataProcessingAgentExample = dataProcessingAgentExample;
11
+ exports.dynamicAgentExample = dynamicAgentExample;
12
+ exports.runAllExamples = runAllExamples;
13
+ const zod_1 = require("zod");
14
+ const index_1 = require("../index");
15
+ const processors_1 = require("../processors");
16
+ /**
17
+ * Example 1: Basic Agent with Default Processors
18
+ */
19
+ async function basicAgentExample() {
20
+ // Create a simple calculator tool
21
+ const calculatorTool = (0, index_1.createTool)({
22
+ id: 'calculator',
23
+ name: 'Calculator',
24
+ description: 'Performs basic mathematical calculations',
25
+ inputSchema: zod_1.z.object({
26
+ expression: zod_1.z.string().describe('Mathematical expression to evaluate (e.g., "2 + 3 * 4")')
27
+ }),
28
+ outputSchema: zod_1.z.object({
29
+ result: zod_1.z.number(),
30
+ expression: zod_1.z.string()
31
+ }),
32
+ execute: async ({ input }) => {
33
+ // Simple expression evaluator (in production, use a proper math parser)
34
+ try {
35
+ // Remove any non-math characters for safety
36
+ const sanitized = input.expression.replace(/[^0-9+\-*/().\s]/g, '');
37
+ const result = eval(sanitized);
38
+ if (typeof result !== 'number' || !isFinite(result)) {
39
+ throw new Error('Invalid calculation result');
40
+ }
41
+ return {
42
+ result,
43
+ expression: input.expression
44
+ };
45
+ }
46
+ catch (error) {
47
+ throw new Error(`Calculation failed: ${error instanceof Error ? error.message : String(error)}`);
48
+ }
49
+ }
50
+ });
51
+ // Create agent with default processors
52
+ const agent = (0, index_1.createAgent)({
53
+ name: 'Math Assistant',
54
+ instructions: `You are a helpful math assistant. Use the calculator tool to perform calculations when needed.
55
+ Always show your work and explain the steps clearly.`,
56
+ model: 'gpt-4',
57
+ tools: [calculatorTool],
58
+ maxIterations: 5,
59
+ enableLogging: true,
60
+ defaultProcessors: true // This enables default processors
61
+ });
62
+ console.log('=== Basic Agent Example ===');
63
+ // Execute a simple calculation
64
+ const result1 = await agent.execute("What is 15 * 8 + 32?");
65
+ console.log('Result 1:', result1.message);
66
+ // Execute a more complex request
67
+ const result2 = await agent.execute("Calculate the area of a circle with radius 5, then add 10% to it");
68
+ console.log('Result 2:', result2.message);
69
+ return { result1, result2 };
70
+ }
71
+ /**
72
+ * Example 2: Agent with Custom Tools and Processors
73
+ */
74
+ async function customAgentExample() {
75
+ // Create multiple custom tools
76
+ const weatherTool = (0, index_1.createTool)({
77
+ id: 'get_weather',
78
+ name: 'Weather Tool',
79
+ description: 'Gets current weather information for a location',
80
+ inputSchema: zod_1.z.object({
81
+ location: zod_1.z.string().describe('City name or coordinates'),
82
+ units: zod_1.z.enum(['celsius', 'fahrenheit']).optional().describe('Temperature units')
83
+ }),
84
+ outputSchema: zod_1.z.object({
85
+ location: zod_1.z.string(),
86
+ temperature: zod_1.z.number(),
87
+ condition: zod_1.z.string(),
88
+ humidity: zod_1.z.number(),
89
+ windSpeed: zod_1.z.number()
90
+ }),
91
+ execute: async ({ input }) => {
92
+ // Mock weather data (in production, call a real weather API)
93
+ return {
94
+ location: input.location,
95
+ temperature: input.units === 'fahrenheit' ? 72 : 22,
96
+ condition: 'Partly cloudy',
97
+ humidity: 65,
98
+ windSpeed: 8
99
+ };
100
+ }
101
+ });
102
+ const textAnalysisTool = (0, index_1.createTextTool)({
103
+ id: 'analyze_text',
104
+ name: 'Text Analyzer',
105
+ description: 'Analyzes text for sentiment, keywords, and statistics',
106
+ execute: async (text) => {
107
+ const words = text.split(/\s+/).filter(word => word.length > 0);
108
+ const sentences = text.split(/[.!?]+/).filter(s => s.trim().length > 0);
109
+ // Simple sentiment analysis (mock)
110
+ const positiveWords = ['good', 'great', 'excellent', 'amazing', 'wonderful', 'fantastic'];
111
+ const negativeWords = ['bad', 'terrible', 'awful', 'horrible', 'disappointing'];
112
+ const positive = positiveWords.filter(word => text.toLowerCase().includes(word)).length;
113
+ const negative = negativeWords.filter(word => text.toLowerCase().includes(word)).length;
114
+ let sentiment = 'neutral';
115
+ if (positive > negative)
116
+ sentiment = 'positive';
117
+ else if (negative > positive)
118
+ sentiment = 'negative';
119
+ return `Text Analysis Results:
120
+ - Word count: ${words.length}
121
+ - Sentence count: ${sentences.length}
122
+ - Average words per sentence: ${(words.length / sentences.length).toFixed(1)}
123
+ - Sentiment: ${sentiment}
124
+ - Character count: ${text.length}`;
125
+ }
126
+ });
127
+ const fileOperationTool = (0, index_1.createFileTool)({
128
+ id: 'read_file',
129
+ name: 'File Reader',
130
+ description: 'Reads content from a file',
131
+ operation: 'read',
132
+ execute: async (params) => {
133
+ // Mock file reading (in production, use actual file system)
134
+ return `Mock file content from: ${params.filePath}`;
135
+ }
136
+ });
137
+ // Create custom processors
138
+ const customValidationProcessor = new processors_1.ToolValidationProcessor({
139
+ enableParameterValidation: true,
140
+ enableSecurityValidation: true,
141
+ strictMode: false,
142
+ allowedTools: ['get_weather', 'analyze_text', 'read_file'],
143
+ maxParameterSize: 1024 * 10, // 10KB
144
+ enableLogging: true
145
+ });
146
+ const customConversationProcessor = new processors_1.ConversationCompactorProcessor({
147
+ maxConversationLength: 20,
148
+ enableSummarization: true,
149
+ enableSmartRemoval: true,
150
+ enableLogging: true
151
+ });
152
+ // Create agent with custom tools and processors
153
+ const agent = (0, index_1.createAgent)({
154
+ name: 'Multi-Tool Assistant',
155
+ instructions: `You are a versatile assistant that can help with weather, text analysis, and file operations.
156
+ Always use the appropriate tools for each task and provide comprehensive responses.`,
157
+ model: 'gpt-4',
158
+ tools: [weatherTool, textAnalysisTool, fileOperationTool],
159
+ processors: {
160
+ preToolCall: [customValidationProcessor],
161
+ followUpConversation: [customConversationProcessor]
162
+ },
163
+ maxIterations: 8,
164
+ enableLogging: true,
165
+ defaultProcessors: true // Also include default processors
166
+ });
167
+ console.log('\n=== Custom Agent Example ===');
168
+ // Execute multiple tasks
169
+ const result1 = await agent.execute("What's the weather in New York and analyze the sentiment of this text: 'Today is a wonderful day!'");
170
+ console.log('Result 1:', result1.message);
171
+ const result2 = await agent.execute("Read the config.json file and tell me about its content");
172
+ console.log('Result 2:', result2.message);
173
+ return { result1, result2 };
174
+ }
175
+ /**
176
+ * Example 3: Agent with Local Tool Interception
177
+ */
178
+ async function localToolInterceptionExample() {
179
+ // Create local tools that will be intercepted
180
+ const localCalculatorTool = (0, index_1.createTool)({
181
+ id: 'local--advanced_calc',
182
+ name: 'Advanced Calculator',
183
+ description: 'Performs advanced mathematical calculations locally',
184
+ inputSchema: zod_1.z.object({
185
+ operation: zod_1.z.enum(['add', 'subtract', 'multiply', 'divide', 'power', 'sqrt']),
186
+ a: zod_1.z.number().describe('First number'),
187
+ b: zod_1.z.number().optional().describe('Second number (not needed for sqrt)')
188
+ }),
189
+ execute: async ({ input }) => {
190
+ const { operation, a, b } = input;
191
+ switch (operation) {
192
+ case 'add':
193
+ return { result: a + (b || 0), operation: `${a} + ${b}` };
194
+ case 'subtract':
195
+ return { result: a - (b || 0), operation: `${a} - ${b}` };
196
+ case 'multiply':
197
+ return { result: a * (b || 1), operation: `${a} * ${b}` };
198
+ case 'divide':
199
+ if (b === 0)
200
+ throw new Error('Division by zero');
201
+ return { result: a / (b || 1), operation: `${a} / ${b}` };
202
+ case 'power':
203
+ return { result: Math.pow(a, b || 2), operation: `${a} ^ ${b}` };
204
+ case 'sqrt':
205
+ return { result: Math.sqrt(a), operation: `√${a}` };
206
+ default:
207
+ throw new Error(`Unknown operation: ${operation}`);
208
+ }
209
+ }
210
+ });
211
+ // Create local tool interceptor
212
+ const localInterceptor = new processors_1.LocalToolInterceptorProcessor({
213
+ enableCustomToolHandling: true,
214
+ enableLogging: true
215
+ });
216
+ // Add the local calculator to the interceptor
217
+ localInterceptor.addLocalTool({
218
+ name: 'local--advanced_calc',
219
+ execute: async (params) => {
220
+ const { operation, a, b } = params;
221
+ console.log(`[Local Execution] Performing ${operation} with ${a} and ${b}`);
222
+ switch (operation) {
223
+ case 'add': return `Local calculation: ${a} + ${b} = ${a + b}`;
224
+ case 'subtract': return `Local calculation: ${a} - ${b} = ${a - b}`;
225
+ case 'multiply': return `Local calculation: ${a} * ${b} = ${a * b}`;
226
+ case 'divide':
227
+ if (b === 0)
228
+ throw new Error('Division by zero');
229
+ return `Local calculation: ${a} / ${b} = ${a / b}`;
230
+ case 'power': return `Local calculation: ${a} ^ ${b} = ${Math.pow(a, b)}`;
231
+ case 'sqrt': return `Local calculation: √${a} = ${Math.sqrt(a)}`;
232
+ default: throw new Error(`Unknown operation: ${operation}`);
233
+ }
234
+ }
235
+ });
236
+ // Create agent with local tool interception
237
+ const agent = (0, index_1.createAgent)({
238
+ name: 'Local Calculator Agent',
239
+ instructions: `You are a calculator assistant that performs mathematical operations.
240
+ Use the advanced_calc tool for calculations. The tool will be executed locally for better performance.`,
241
+ model: 'gpt-4',
242
+ tools: [localCalculatorTool],
243
+ processors: {
244
+ preToolCall: [localInterceptor]
245
+ },
246
+ maxIterations: 5,
247
+ enableLogging: true
248
+ });
249
+ console.log('\n=== Local Tool Interception Example ===');
250
+ const result1 = await agent.execute("Calculate 25 to the power of 3, then take the square root of the result");
251
+ console.log('Result 1:', result1.message);
252
+ const result2 = await agent.execute("Divide 144 by 12, then multiply by 5");
253
+ console.log('Result 2:', result2.message);
254
+ return { result1, result2 };
255
+ }
256
+ /**
257
+ * Example 4: Data Processing Agent with Validation and Transformation
258
+ */
259
+ async function dataProcessingAgentExample() {
260
+ // Create validation tool
261
+ const userValidationTool = (0, index_1.createValidationTool)({
262
+ id: 'validate_user',
263
+ name: 'User Validator',
264
+ description: 'Validates user data according to business rules',
265
+ schema: zod_1.z.object({
266
+ name: zod_1.z.string().min(2, 'Name must be at least 2 characters'),
267
+ email: zod_1.z.string().email('Invalid email format'),
268
+ age: zod_1.z.number().min(18, 'Must be at least 18 years old').max(120, 'Age seems unrealistic'),
269
+ role: zod_1.z.enum(['admin', 'user', 'moderator'])
270
+ }),
271
+ onValid: (data) => {
272
+ return {
273
+ ...data,
274
+ id: Math.random().toString(36).substr(2, 9),
275
+ createdAt: new Date().toISOString(),
276
+ status: 'active'
277
+ };
278
+ },
279
+ onInvalid: (errors) => {
280
+ return {
281
+ message: 'Validation failed',
282
+ errors,
283
+ suggestions: 'Please check the required fields and try again'
284
+ };
285
+ }
286
+ });
287
+ // Create transformation tool
288
+ const dataTransformTool = (0, index_1.createTransformTool)({
289
+ id: 'transform_data',
290
+ name: 'Data Transformer',
291
+ description: 'Transforms data between different formats',
292
+ inputSchema: zod_1.z.object({
293
+ data: zod_1.z.any(),
294
+ fromFormat: zod_1.z.enum(['json', 'csv', 'xml']),
295
+ toFormat: zod_1.z.enum(['json', 'csv', 'xml'])
296
+ }),
297
+ outputSchema: zod_1.z.object({
298
+ transformedData: zod_1.z.string(),
299
+ originalFormat: zod_1.z.string(),
300
+ targetFormat: zod_1.z.string()
301
+ }),
302
+ transform: async (input) => {
303
+ const { data, fromFormat, toFormat } = input;
304
+ // Mock transformation logic
305
+ let transformedData;
306
+ if (toFormat === 'json') {
307
+ transformedData = JSON.stringify(data, null, 2);
308
+ }
309
+ else if (toFormat === 'csv') {
310
+ if (Array.isArray(data) && data.length > 0) {
311
+ const headers = Object.keys(data[0]);
312
+ const csvData = [
313
+ headers.join(','),
314
+ ...data.map(row => headers.map(h => row[h] || '').join(','))
315
+ ];
316
+ transformedData = csvData.join('\n');
317
+ }
318
+ else {
319
+ transformedData = 'No data to transform to CSV';
320
+ }
321
+ }
322
+ else {
323
+ transformedData = `<data>${JSON.stringify(data)}</data>`;
324
+ }
325
+ return {
326
+ transformedData,
327
+ originalFormat: fromFormat,
328
+ targetFormat: toFormat
329
+ };
330
+ }
331
+ });
332
+ // Create HTTP tool for API interactions
333
+ const apiTool = (0, index_1.createHttpTool)({
334
+ id: 'api_request',
335
+ name: 'API Client',
336
+ description: 'Makes HTTP requests to external APIs',
337
+ method: 'GET',
338
+ defaultHeaders: {
339
+ 'User-Agent': 'DataProcessingAgent/1.0',
340
+ 'Accept': 'application/json'
341
+ },
342
+ execute: async ({ input }) => {
343
+ // Mock API response
344
+ return {
345
+ status: 200,
346
+ data: {
347
+ message: `API request to ${input.url} completed successfully`,
348
+ method: input.method || 'GET',
349
+ timestamp: new Date().toISOString()
350
+ },
351
+ headers: {
352
+ 'content-type': 'application/json'
353
+ }
354
+ };
355
+ }
356
+ });
357
+ // Create agent for data processing
358
+ const agent = (0, index_1.createAgent)({
359
+ name: 'Data Processing Agent',
360
+ instructions: `You are a data processing specialist. You can validate user data, transform between formats, and interact with APIs.
361
+ Always validate data before processing and provide clear feedback about any issues.`,
362
+ model: 'gpt-4',
363
+ tools: [userValidationTool, dataTransformTool, apiTool],
364
+ maxIterations: 6,
365
+ enableLogging: true,
366
+ defaultProcessors: true
367
+ });
368
+ console.log('\n=== Data Processing Agent Example ===');
369
+ // Test user validation
370
+ const userData = {
371
+ name: 'John Doe',
372
+ email: 'john@example.com',
373
+ age: 30,
374
+ role: 'user'
375
+ };
376
+ const result1 = await agent.execute(`Validate this user data: ${JSON.stringify(userData)}`);
377
+ console.log('Validation Result:', result1.message);
378
+ // Test data transformation
379
+ const sampleData = [
380
+ { id: 1, name: 'Alice', score: 95 },
381
+ { id: 2, name: 'Bob', score: 87 },
382
+ { id: 3, name: 'Charlie', score: 92 }
383
+ ];
384
+ const result2 = await agent.execute(`Transform this JSON data to CSV format: ${JSON.stringify(sampleData)}`);
385
+ console.log('Transformation Result:', result2.message);
386
+ return { result1, result2 };
387
+ }
388
+ /**
389
+ * Example 5: Dynamic Agent Configuration
390
+ */
391
+ async function dynamicAgentExample() {
392
+ // Start with basic agent
393
+ const agent = (0, index_1.createAgent)({
394
+ name: 'Dynamic Agent',
395
+ instructions: 'You are a flexible assistant that can be configured dynamically.',
396
+ model: 'gpt-4',
397
+ tools: [],
398
+ maxIterations: 5,
399
+ enableLogging: true
400
+ });
401
+ console.log('\n=== Dynamic Agent Example ===');
402
+ // Add tools dynamically
403
+ console.log('Adding calculator tool...');
404
+ const calcTool = (0, index_1.createTool)({
405
+ id: 'dynamic_calc',
406
+ name: 'Dynamic Calculator',
407
+ description: 'Calculator added dynamically',
408
+ inputSchema: zod_1.z.object({
409
+ expression: zod_1.z.string()
410
+ }),
411
+ execute: async ({ input }) => {
412
+ const result = eval(input.expression.replace(/[^0-9+\-*/().\s]/g, ''));
413
+ return `Calculation: ${input.expression} = ${result}`;
414
+ }
415
+ });
416
+ agent.addTool(calcTool);
417
+ const result1 = await agent.execute("Calculate 10 * 5 + 3");
418
+ console.log('With calculator:', result1.message);
419
+ // Add text tool dynamically
420
+ console.log('Adding text tool...');
421
+ const textTool = (0, index_1.createTextTool)({
422
+ id: 'text_processor',
423
+ name: 'Text Processor',
424
+ description: 'Processes text in various ways',
425
+ execute: async (text) => {
426
+ return `Processed text: "${text}" (${text.length} characters, ${text.split(' ').length} words)`;
427
+ }
428
+ });
429
+ agent.addTool(textTool);
430
+ const result2 = await agent.execute("Process this text: 'Hello, world! This is a test.'");
431
+ console.log('With text processor:', result2.message);
432
+ // Add processor dynamically
433
+ console.log('Adding validation processor...');
434
+ const validator = new processors_1.ToolValidationProcessor({
435
+ enableParameterValidation: true,
436
+ strictMode: true,
437
+ allowedTools: ['dynamic_calc', 'text_processor'],
438
+ enableLogging: true
439
+ });
440
+ agent.addProcessor('preToolCall', validator);
441
+ const result3 = await agent.execute("Calculate 20 / 4 and process the text 'Dynamic configuration works!'");
442
+ console.log('With validation:', result3.message);
443
+ // Show current tools
444
+ const tools = agent.getTools();
445
+ console.log('Current tools:', tools.map(t => t.id));
446
+ return { result1, result2, result3, tools };
447
+ }
448
+ /**
449
+ * Run all examples
450
+ */
451
+ async function runAllExamples() {
452
+ try {
453
+ console.log('🚀 Running Agent Examples...\n');
454
+ await basicAgentExample();
455
+ await customAgentExample();
456
+ await localToolInterceptionExample();
457
+ await dataProcessingAgentExample();
458
+ await dynamicAgentExample();
459
+ console.log('\n✅ All examples completed successfully!');
460
+ }
461
+ catch (error) {
462
+ console.error('❌ Error running examples:', error);
463
+ }
464
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Documentation Pattern Example
3
+ *
4
+ * This example implements the exact pattern described in the Orchestrator.md documentation
5
+ * showing how agents, workflows, and tools can be used as tools within an orchestrator.
6
+ */
7
+ export declare function documentationPatternExample(): Promise<import("../index").OrchestratorResult>;
8
+ export declare function nestedOrchestrationExample(): Promise<import("../index").OrchestratorResult>;
9
+ export declare function agentWorkflowToolAsToolsExample(): Promise<import("../index").OrchestratorResult[]>;
10
+ export declare function runDocumentationPatternExamples(): Promise<void>;