@codebolt/agent 5.0.2 → 5.0.6

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 (160) hide show
  1. package/dist/agent.d.ts +86 -0
  2. package/dist/agent.js +324 -0
  3. package/dist/builderpattern/agent.js +2 -2
  4. package/dist/builderpattern/followupquestionbuilder.js +1 -1
  5. package/dist/builderpattern/llmoutputhandler.js +7 -7
  6. package/dist/builderpattern/usermessage.d.ts +1 -6
  7. package/dist/composablepattern/document.js +35 -2
  8. package/dist/followupquestionbuilder.d.ts +75 -0
  9. package/dist/followupquestionbuilder.js +197 -0
  10. package/dist/index.d.ts +14 -0
  11. package/dist/index.js +23 -0
  12. package/dist/llmoutputhandler.d.ts +102 -0
  13. package/dist/llmoutputhandler.js +452 -0
  14. package/dist/processor/types/interfaces.d.ts +21 -44
  15. package/dist/processor-pieces/index.d.ts +3 -0
  16. package/dist/processor-pieces/index.js +3 -0
  17. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.d.ts +5 -14
  18. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +40 -41
  19. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +13 -5
  20. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +58 -50
  21. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +8 -6
  22. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +22 -66
  23. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +2 -3
  24. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +2 -1
  25. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +2 -3
  26. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +2 -1
  27. package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +4 -1
  28. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +2 -18
  29. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +93 -291
  30. package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.d.ts +18 -0
  31. package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.js +41 -0
  32. package/dist/processor-pieces/postToolCallProcessors/index.d.ts +2 -1
  33. package/dist/processor-pieces/postToolCallProcessors/index.js +5 -0
  34. package/dist/processor-pieces/preInferenceProcessors/index.d.ts +1 -1
  35. package/dist/processor-pieces/preInferenceProcessors/index.js +3 -0
  36. package/dist/processor-pieces/pretoolCallProcessors/index.d.ts +2 -1
  37. package/dist/processor-pieces/pretoolCallProcessors/index.js +5 -0
  38. package/dist/processor-pieces/pretoolCallProcessors/toolParameterModifier.d.ts +21 -0
  39. package/dist/processor-pieces/pretoolCallProcessors/toolParameterModifier.js +32 -0
  40. package/dist/processor-pieces/pretoolCallProcessors/toolValidationModifier.d.ts +16 -0
  41. package/dist/processor-pieces/pretoolCallProcessors/toolValidationModifier.js +37 -0
  42. package/dist/promptbuilder.d.ts +382 -0
  43. package/dist/promptbuilder.js +805 -0
  44. package/dist/systemprompt.d.ts +20 -0
  45. package/dist/systemprompt.js +48 -0
  46. package/dist/taskInstruction.d.ts +37 -0
  47. package/dist/taskInstruction.js +57 -0
  48. package/dist/unified/agent/agent.js +2 -2
  49. package/dist/unified/agent/codeboltAgent.d.ts +122 -0
  50. package/dist/unified/agent/codeboltAgent.js +210 -0
  51. package/dist/unified/base/initialPromptGenerator.js +18 -4
  52. package/dist/unified/base/responseExecutor.d.ts +3 -2
  53. package/dist/unified/base/responseExecutor.js +100 -56
  54. package/dist/unified/index.d.ts +4 -0
  55. package/dist/unified/index.js +12 -1
  56. package/dist/usermessage.d.ts +70 -0
  57. package/dist/usermessage.js +123 -0
  58. package/package.json +5 -5
  59. package/dist/local-tools/fileTools.d.ts +0 -26
  60. package/dist/local-tools/fileTools.js +0 -162
  61. package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.d.ts +0 -13
  62. package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.js +0 -68
  63. package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.d.ts +0 -15
  64. package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.js +0 -212
  65. package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.d.ts +0 -19
  66. package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.js +0 -110
  67. package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.d.ts +0 -23
  68. package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.js +0 -173
  69. package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.d.ts +0 -14
  70. package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.js +0 -93
  71. package/dist/processor-pieces/additionalModifiers/directoryContextModifier.d.ts +0 -30
  72. package/dist/processor-pieces/additionalModifiers/directoryContextModifier.js +0 -330
  73. package/dist/processor-pieces/additionalModifiers/environmentContextModifier.d.ts +0 -26
  74. package/dist/processor-pieces/additionalModifiers/environmentContextModifier.js +0 -269
  75. package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.d.ts +0 -38
  76. package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.js +0 -217
  77. package/dist/processor-pieces/additionalModifiers/ideContextModifier.d.ts +0 -34
  78. package/dist/processor-pieces/additionalModifiers/ideContextModifier.js +0 -147
  79. package/dist/processor-pieces/additionalModifiers/index.d.ts +0 -12
  80. package/dist/processor-pieces/additionalModifiers/index.js +0 -28
  81. package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.d.ts +0 -29
  82. package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.js +0 -155
  83. package/dist/processor-pieces/additionalModifiers/memoryImportModifier.d.ts +0 -15
  84. package/dist/processor-pieces/additionalModifiers/memoryImportModifier.js +0 -129
  85. package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.d.ts +0 -25
  86. package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.js +0 -169
  87. package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.d.ts +0 -20
  88. package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.js +0 -152
  89. package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.d.ts +0 -7
  90. package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.js +0 -93
  91. package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.d.ts +0 -9
  92. package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.js +0 -77
  93. package/dist/processor-pieces/messageModifiers/chatCompressionModifier.d.ts +0 -19
  94. package/dist/processor-pieces/messageModifiers/chatCompressionModifier.js +0 -110
  95. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.d.ts +0 -20
  96. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.js +0 -124
  97. package/dist/processor-pieces/messageModifiers/environmentContext.d.ts +0 -41
  98. package/dist/processor-pieces/messageModifiers/environmentContext.js +0 -355
  99. package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.d.ts +0 -23
  100. package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.js +0 -207
  101. package/dist/processor-pieces/messageModifiers/simpleMessageModifier.d.ts +0 -7
  102. package/dist/processor-pieces/messageModifiers/simpleMessageModifier.js +0 -26
  103. package/dist/processor-pieces/postInference/llmOutputValidityProcessor.d.ts +0 -1
  104. package/dist/processor-pieces/postInference/llmOutputValidityProcessor.js +0 -2
  105. package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.d.ts +0 -7
  106. package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.js +0 -24
  107. package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.d.ts +0 -41
  108. package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.js +0 -197
  109. package/dist/processor-pieces/postToolCall/chatCompressionProcessor.d.ts +0 -26
  110. package/dist/processor-pieces/postToolCall/chatCompressionProcessor.js +0 -90
  111. package/dist/processor-pieces/postToolCall/chatRecordingProcessor.d.ts +0 -81
  112. package/dist/processor-pieces/postToolCall/chatRecordingProcessor.js +0 -329
  113. package/dist/processor-pieces/postToolCall/contextManagementProcessor.d.ts +0 -40
  114. package/dist/processor-pieces/postToolCall/contextManagementProcessor.js +0 -272
  115. package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.d.ts +0 -49
  116. package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.js +0 -291
  117. package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.d.ts +0 -49
  118. package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.js +0 -293
  119. package/dist/processor-pieces/postToolCall/followUpConversationProcessor.d.ts +0 -47
  120. package/dist/processor-pieces/postToolCall/followUpConversationProcessor.js +0 -249
  121. package/dist/processor-pieces/postToolCall/loopDetectionProcessor.d.ts +0 -30
  122. package/dist/processor-pieces/postToolCall/loopDetectionProcessor.js +0 -137
  123. package/dist/processor-pieces/postToolCall/responseValidationProcessor.d.ts +0 -30
  124. package/dist/processor-pieces/postToolCall/responseValidationProcessor.js +0 -228
  125. package/dist/processor-pieces/postToolCall/telemetryProcessor.d.ts +0 -99
  126. package/dist/processor-pieces/postToolCall/telemetryProcessor.js +0 -278
  127. package/dist/processor-pieces/postToolCall/tokenManagementProcessor.d.ts +0 -37
  128. package/dist/processor-pieces/postToolCall/tokenManagementProcessor.js +0 -178
  129. package/dist/processor-pieces/postToolCall/toolExecutionProcessor.d.ts +0 -43
  130. package/dist/processor-pieces/postToolCall/toolExecutionProcessor.js +0 -207
  131. package/dist/processor-pieces/preInference/conversationCompactorProcessor.d.ts +0 -52
  132. package/dist/processor-pieces/preInference/conversationCompactorProcessor.js +0 -264
  133. package/dist/processor-pieces/preInference/conversationContinuityProcessor.d.ts +0 -49
  134. package/dist/processor-pieces/preInference/conversationContinuityProcessor.js +0 -293
  135. package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.d.ts +0 -7
  136. package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.js +0 -31
  137. package/dist/processor-pieces/preToolCall/index.d.ts +0 -9
  138. package/dist/processor-pieces/preToolCall/index.js +0 -18
  139. package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.d.ts +0 -58
  140. package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.js +0 -444
  141. package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.d.ts +0 -44
  142. package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.js +0 -367
  143. package/dist/processor-pieces/preToolCall/toolValidationProcessor.d.ts +0 -58
  144. package/dist/processor-pieces/preToolCall/toolValidationProcessor.js +0 -391
  145. package/dist/unified/agent/tool.d.ts +0 -99
  146. package/dist/unified/agent/tool.js +0 -440
  147. package/dist/unified/examples/agentExample.d.ts +0 -46
  148. package/dist/unified/examples/agentExample.js +0 -464
  149. package/dist/unified/examples/documentationPatternExample.d.ts +0 -10
  150. package/dist/unified/examples/documentationPatternExample.js +0 -385
  151. package/dist/unified/examples/followUpProcessorsExample.d.ts +0 -45
  152. package/dist/unified/examples/followUpProcessorsExample.js +0 -311
  153. package/dist/unified/examples/orchestratorExample.d.ts +0 -16
  154. package/dist/unified/examples/orchestratorExample.js +0 -415
  155. package/dist/unified/examples/preToolCallProcessorsExample.d.ts +0 -36
  156. package/dist/unified/examples/preToolCallProcessorsExample.js +0 -458
  157. package/dist/unified/examples/workflowExample.d.ts +0 -12
  158. package/dist/unified/examples/workflowExample.js +0 -497
  159. package/dist/unified/orchestrator/orchestrator.d.ts +0 -260
  160. package/dist/unified/orchestrator/orchestrator.js +0 -519
@@ -1,385 +0,0 @@
1
- "use strict";
2
- /**
3
- * Documentation Pattern Example
4
- *
5
- * This example implements the exact pattern described in the Orchestrator.md documentation
6
- * showing how agents, workflows, and tools can be used as tools within an orchestrator.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.documentationPatternExample = documentationPatternExample;
10
- exports.nestedOrchestrationExample = nestedOrchestrationExample;
11
- exports.agentWorkflowToolAsToolsExample = agentWorkflowToolAsToolsExample;
12
- exports.runDocumentationPatternExamples = runDocumentationPatternExamples;
13
- const zod_1 = require("zod");
14
- const index_1 = require("../index");
15
- // ================================
16
- // Documentation Pattern Implementation
17
- // ================================
18
- async function documentationPatternExample() {
19
- console.log('=== Documentation Pattern Example ===');
20
- console.log('Implementing the exact pattern from Orchestrator.md\n');
21
- // Create Agent 1 - Research and Text Synthesis
22
- const agent1 = (0, index_1.createAgent)({
23
- name: 'Research Agent',
24
- instructions: 'You are a research specialist focused on gathering information and synthesizing text.',
25
- description: 'Specializes in research and text synthesis',
26
- tools: [
27
- (0, index_1.createTool)({
28
- id: 'research-city-info',
29
- name: 'Research City Information',
30
- description: 'Research comprehensive information about a city',
31
- inputSchema: zod_1.z.object({
32
- city: zod_1.z.string(),
33
- aspects: zod_1.z.array(zod_1.z.string()).optional().default(['demographics', 'economy', 'culture'])
34
- }),
35
- execute: async ({ input }) => {
36
- // Simulate city research
37
- return {
38
- city: input.city,
39
- demographics: `${input.city} has a diverse population with various age groups and backgrounds.`,
40
- economy: `${input.city}'s economy is driven by multiple sectors including technology and services.`,
41
- culture: `${input.city} has a rich cultural heritage with numerous attractions and events.`,
42
- summary: `Comprehensive research completed for ${input.city} covering ${input.aspects.join(', ')}.`
43
- };
44
- }
45
- })
46
- ]
47
- });
48
- // Create Agent 2 - Text Processing and Enhancement
49
- const agent2 = (0, index_1.createAgent)({
50
- name: 'Text Processing Agent',
51
- instructions: 'You are a text processing specialist focused on enhancing and refining content.',
52
- description: 'Specializes in text processing and content enhancement',
53
- tools: [
54
- (0, index_1.createTool)({
55
- id: 'enhance-text',
56
- name: 'Text Enhancement Tool',
57
- description: 'Enhance and refine text content',
58
- inputSchema: zod_1.z.object({
59
- text: zod_1.z.string(),
60
- style: zod_1.z.enum(['formal', 'casual', 'academic']).optional().default('formal'),
61
- length: zod_1.z.enum(['short', 'medium', 'long']).optional().default('medium')
62
- }),
63
- execute: async ({ input }) => {
64
- // Simulate text enhancement
65
- return {
66
- originalText: input.text,
67
- enhancedText: `Enhanced ${input.style} version: ${input.text}`,
68
- improvements: ['Improved clarity', 'Better structure', 'Enhanced readability'],
69
- wordCount: input.length === 'short' ? 150 : input.length === 'medium' ? 300 : 500
70
- };
71
- }
72
- })
73
- ]
74
- });
75
- // Create Agent Step 1 - as shown in documentation
76
- const agentStep1 = (0, index_1.createAgentStep)({
77
- id: 'agent-step',
78
- name: 'Research and Text Synthesis Step',
79
- description: 'This step is used to do research and text synthesis.',
80
- agent: agent1,
81
- message: 'Research comprehensive information about {{city}} and synthesize the findings.',
82
- inputMapping: {
83
- city: 'city'
84
- },
85
- outputMapping: {
86
- researchResults: 'agentResult.response',
87
- cityData: 'agentResult.toolResults'
88
- }
89
- });
90
- // Create Agent Step 2 - as shown in documentation
91
- const agentStep2 = (0, index_1.createAgentStep)({
92
- id: 'agent-step-two',
93
- name: 'Text Processing Step',
94
- description: 'This step is used to process and enhance text.',
95
- agent: agent2,
96
- message: 'Process and enhance this text: {{text}}. Make it {{style}} and {{length}}.',
97
- inputMapping: {
98
- text: 'researchResults',
99
- style: 'textStyle',
100
- length: 'textLength'
101
- },
102
- outputMapping: {
103
- finalText: 'agentResult.response',
104
- enhancements: 'agentResult.toolResults'
105
- }
106
- });
107
- // Create Workflow 1 - as shown in documentation
108
- const workflow1Config = {
109
- name: 'Research and Processing Workflow',
110
- description: 'Sequential workflow for research and text processing',
111
- steps: [agentStep1, agentStep2],
112
- initialData: {
113
- city: 'San Francisco',
114
- textStyle: 'formal',
115
- textLength: 'medium'
116
- }
117
- };
118
- const workflow1 = (0, index_1.createWorkflow)(workflow1Config);
119
- // Add agents to workflow context
120
- workflow1.addAgent('agent1', agent1);
121
- workflow1.addAgent('agent2', agent2);
122
- // Create Orchestrator - as shown in documentation
123
- const orchestratorConfig = {
124
- name: 'Test Network',
125
- description: 'Test orchestrator network demonstrating the documentation pattern',
126
- instructions: `You are a test orchestrator that coordinates agents and workflows.
127
-
128
- Available Resources:
129
- - agent1: Research and text synthesis specialist
130
- - agent2: Text processing and enhancement specialist
131
- - workflow1: Complete research and processing pipeline
132
-
133
- Decision Logic:
134
- 1. For research tasks → use agent1 or workflow1
135
- 2. For text processing → use agent2 or workflow1
136
- 3. For complete research + processing → use workflow1
137
- 4. Always consider the most efficient resource for the task`,
138
- agents: {
139
- agent1,
140
- agent2
141
- },
142
- workflows: {
143
- workflow1
144
- },
145
- limits: {
146
- maxSteps: 10,
147
- maxExecutionTime: 300000 // 5 minutes
148
- },
149
- decisionConfig: {
150
- explainDecisions: true,
151
- confidenceThreshold: 0.7
152
- }
153
- };
154
- const orchestrator = (0, index_1.createOrchestrator)(orchestratorConfig);
155
- // Create Runtime Context - as shown in documentation
156
- const runtimeContext = (0, index_1.createRuntimeContext)({
157
- userId: 'test-user',
158
- customData: {
159
- preferences: {
160
- city: 'New York',
161
- outputStyle: 'formal',
162
- outputLength: 'long'
163
- }
164
- }
165
- });
166
- // Execute orchestrator loop - as shown in documentation
167
- console.log('Executing orchestrator loop...');
168
- const result = await orchestrator.loop('I need comprehensive research about New York City and then process that information into a formal, detailed report.', { runtimeContext });
169
- console.log('\nOrchestrator execution completed:');
170
- console.log('Success:', result.success);
171
- console.log('Total Steps:', result.executionSteps.length);
172
- console.log('Execution Time:', result.totalExecutionTime, 'ms');
173
- console.log('Resources Used:');
174
- console.log(' - Agents:', result.metrics.agentsExecuted);
175
- console.log(' - Workflows:', result.metrics.workflowsExecuted);
176
- console.log(' - Tools:', result.metrics.toolsExecuted);
177
- console.log('\nFinal Response:');
178
- console.log(result.response.substring(0, 300) + '...');
179
- // Demonstrate step-by-step execution details
180
- console.log('\n--- Execution Steps ---');
181
- result.executionSteps.forEach((step, index) => {
182
- console.log(`${index + 1}. ${step.stepType.toUpperCase()}: ${step.resourceName}`);
183
- console.log(` Success: ${step.success}`);
184
- console.log(` Time: ${step.executionTime}ms`);
185
- if (step.metadata.reasoning) {
186
- console.log(` Reasoning: ${step.metadata.reasoning}`);
187
- }
188
- console.log('');
189
- });
190
- return result;
191
- }
192
- // ================================
193
- // Advanced Pattern: Nested Orchestration
194
- // ================================
195
- async function nestedOrchestrationExample() {
196
- console.log('\n=== Nested Orchestration Example ===');
197
- console.log('Demonstrating orchestrators using other orchestrators as tools\n');
198
- // Create a specialized sub-orchestrator for content creation
199
- const contentOrchestrator = (0, index_1.createOrchestrator)({
200
- name: 'Content Creation Orchestrator',
201
- instructions: 'You specialize in content creation workflows.',
202
- agents: {
203
- writer: (0, index_1.createAgent)({
204
- name: 'Content Writer',
205
- instructions: 'You are a skilled content writer.'
206
- }),
207
- editor: (0, index_1.createAgent)({
208
- name: 'Content Editor',
209
- instructions: 'You are a meticulous content editor.'
210
- })
211
- },
212
- workflows: {}
213
- });
214
- // Create a tool that wraps the content orchestrator
215
- const contentOrchestrationTool = (0, index_1.createTool)({
216
- id: 'content-orchestrator-tool',
217
- name: 'Content Creation Orchestrator',
218
- description: 'Execute content creation using specialized orchestrator',
219
- inputSchema: zod_1.z.object({
220
- task: zod_1.z.string(),
221
- requirements: zod_1.z.array(zod_1.z.string()).optional()
222
- }),
223
- execute: async ({ input }) => {
224
- const result = await contentOrchestrator.loop(input.task);
225
- return {
226
- content: result.response,
227
- success: result.success,
228
- stepsExecuted: result.executionSteps.length,
229
- executionTime: result.totalExecutionTime
230
- };
231
- }
232
- });
233
- // Create main orchestrator that can use the content orchestrator as a tool
234
- const mainOrchestrator = (0, index_1.createOrchestrator)({
235
- name: 'Main Orchestrator',
236
- instructions: 'You coordinate high-level tasks and can delegate to specialized orchestrators.',
237
- agents: {
238
- coordinator: (0, index_1.createAgent)({
239
- name: 'Task Coordinator',
240
- instructions: 'You coordinate complex tasks across multiple systems.',
241
- tools: [contentOrchestrationTool]
242
- })
243
- },
244
- workflows: {},
245
- tools: {
246
- 'content-orchestrator': contentOrchestrationTool.toOpenAITool()
247
- }
248
- });
249
- // Test nested orchestration
250
- const result = await mainOrchestrator.loop('Create a comprehensive blog post about artificial intelligence trends, including research, writing, and editing phases.');
251
- console.log('Nested orchestration result:');
252
- console.log('Success:', result.success);
253
- console.log('Total Steps:', result.executionSteps.length);
254
- console.log('Response:', result.response.substring(0, 200) + '...');
255
- return result;
256
- }
257
- // ================================
258
- // Pattern: Agents, Workflows, and Tools as Tools
259
- // ================================
260
- async function agentWorkflowToolAsToolsExample() {
261
- console.log('\n=== Agents, Workflows, and Tools as Tools Example ===');
262
- console.log('Demonstrating how each resource type can be used as a tool\n');
263
- // 1. Agent as a Tool
264
- const researchAgent = (0, index_1.createAgent)({
265
- name: 'Research Specialist',
266
- instructions: 'You conduct thorough research on any topic.'
267
- });
268
- const agentAsTool = researchAgent.toTool();
269
- console.log('✓ Created agent as tool:', agentAsTool.name);
270
- // 2. Workflow as a Tool
271
- const analysisWorkflow = (0, index_1.createWorkflow)({
272
- name: 'Analysis Pipeline',
273
- description: 'Complete analysis workflow',
274
- steps: [
275
- (0, index_1.createAgentStep)({
276
- id: 'analyze',
277
- name: 'Analysis Step',
278
- agent: researchAgent,
279
- message: 'Analyze: {{topic}}'
280
- })
281
- ]
282
- });
283
- const workflowAsTool = (0, index_1.createTool)({
284
- id: 'analysis-workflow-tool',
285
- name: 'Analysis Workflow',
286
- description: 'Execute complete analysis workflow',
287
- inputSchema: zod_1.z.object({
288
- topic: zod_1.z.string(),
289
- depth: zod_1.z.enum(['basic', 'detailed']).optional().default('detailed')
290
- }),
291
- execute: async ({ input }) => {
292
- analysisWorkflow.updateContext({ topic: input.topic, depth: input.depth });
293
- const result = await analysisWorkflow.execute();
294
- return {
295
- analysisResult: result.data,
296
- success: result.success,
297
- executionTime: result.executionTime
298
- };
299
- }
300
- });
301
- console.log('✓ Created workflow as tool:', workflowAsTool.name);
302
- // 3. Regular Tool
303
- const calculatorTool = (0, index_1.createTool)({
304
- id: 'calculator',
305
- name: 'Calculator',
306
- description: 'Perform mathematical calculations',
307
- inputSchema: zod_1.z.object({
308
- expression: zod_1.z.string()
309
- }),
310
- execute: async ({ input }) => {
311
- // Simple calculation simulation
312
- return {
313
- expression: input.expression,
314
- result: `Calculated result for: ${input.expression}`,
315
- timestamp: new Date().toISOString()
316
- };
317
- }
318
- });
319
- console.log('✓ Created regular tool:', calculatorTool.name);
320
- // Create orchestrator that can use all three types as tools
321
- const multiToolOrchestrator = (0, index_1.createOrchestrator)({
322
- name: 'Multi-Tool Orchestrator',
323
- instructions: `You can use various types of tools:
324
-
325
- 1. Agent tools - for complex reasoning and conversation
326
- 2. Workflow tools - for structured multi-step processes
327
- 3. Regular tools - for specific functions
328
-
329
- Choose the appropriate tool type based on the task complexity and requirements.`,
330
- agents: {
331
- coordinator: (0, index_1.createAgent)({
332
- name: 'Tool Coordinator',
333
- instructions: 'You coordinate the use of different tool types.',
334
- tools: [agentAsTool, workflowAsTool, calculatorTool]
335
- })
336
- },
337
- workflows: {},
338
- tools: {
339
- 'agent-tool': researchAgent.toOpenAITool(),
340
- 'workflow-tool': workflowAsTool.toOpenAITool(),
341
- 'calculator-tool': calculatorTool.toOpenAITool()
342
- }
343
- });
344
- // Test using different tool types
345
- const testCases = [
346
- 'Research the latest developments in quantum computing', // Should use agent tool
347
- 'Perform a complete analysis of market trends in renewable energy', // Should use workflow tool
348
- 'Calculate the compound interest for $10,000 at 5% for 10 years' // Should use calculator tool
349
- ];
350
- const results = [];
351
- for (const [index, testCase] of testCases.entries()) {
352
- console.log(`\n--- Test Case ${index + 1}: ${testCase.substring(0, 40)}... ---`);
353
- const result = await multiToolOrchestrator.loop(testCase);
354
- console.log('Result:', {
355
- success: result.success,
356
- toolsUsed: result.metrics.toolsExecuted,
357
- agentsUsed: result.metrics.agentsExecuted,
358
- workflowsUsed: result.metrics.workflowsExecuted
359
- });
360
- results.push(result);
361
- }
362
- return results;
363
- }
364
- // ================================
365
- // Run All Documentation Pattern Examples
366
- // ================================
367
- async function runDocumentationPatternExamples() {
368
- try {
369
- console.log('🚀 Starting Documentation Pattern Examples...\n');
370
- await documentationPatternExample();
371
- await nestedOrchestrationExample();
372
- await agentWorkflowToolAsToolsExample();
373
- console.log('\n✅ All documentation pattern examples completed successfully!');
374
- console.log('\nKey Patterns Demonstrated:');
375
- console.log('1. ✓ Agent as a tool');
376
- console.log('2. ✓ Tool as a tool');
377
- console.log('3. ✓ Workflow as a tool');
378
- console.log('4. ✓ Orchestrator coordination');
379
- console.log('5. ✓ Dynamic resource selection');
380
- console.log('6. ✓ Nested orchestration');
381
- }
382
- catch (error) {
383
- console.error('❌ Documentation pattern example failed:', error);
384
- }
385
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Example demonstrating how to use follow-up conversation processors
3
- * with the Unified Agent Framework
4
- */
5
- import { ConversationCompactorProcessor } from '../processors';
6
- import type { CodeboltAPI, OpenAITool } from '../types/libTypes';
7
- /**
8
- * Example 1: Basic Follow-Up Processor Usage
9
- */
10
- export declare function basicFollowUpProcessorExample(codebolt: CodeboltAPI, tools: OpenAITool[]): Promise<any>;
11
- /**
12
- * Example 2: Advanced Processor Configuration
13
- */
14
- export declare function advancedFollowUpProcessorExample(codebolt: CodeboltAPI, tools: OpenAITool[]): Promise<any>;
15
- /**
16
- * Example 3: Dynamic Processor Management
17
- */
18
- export declare function dynamicProcessorManagementExample(codebolt: CodeboltAPI, tools: OpenAITool[]): Promise<any>;
19
- /**
20
- * Example 4: Processor Event Monitoring
21
- */
22
- export declare function processorEventMonitoringExample(codebolt: CodeboltAPI, tools: OpenAITool[]): Promise<any>;
23
- /**
24
- * Example 5: Custom Processor Creation
25
- */
26
- export declare class CustomMetricsProcessor extends ConversationCompactorProcessor {
27
- private metricsCollected;
28
- processInput(input: any): Promise<any[]>;
29
- private getAverageProcessingTime;
30
- getMetrics(): {
31
- timestamp: string;
32
- messageCount: number;
33
- toolCount: number;
34
- processingTime: number;
35
- }[];
36
- }
37
- export declare function customProcessorExample(codebolt: CodeboltAPI, tools: OpenAITool[]): Promise<{
38
- result: any;
39
- metrics: {
40
- timestamp: string;
41
- messageCount: number;
42
- toolCount: number;
43
- processingTime: number;
44
- }[];
45
- }>;