@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.
- package/dist/agent.d.ts +86 -0
- package/dist/agent.js +324 -0
- package/dist/builderpattern/agent.js +2 -2
- package/dist/builderpattern/followupquestionbuilder.js +1 -1
- package/dist/builderpattern/llmoutputhandler.js +7 -7
- package/dist/builderpattern/usermessage.d.ts +1 -6
- package/dist/composablepattern/document.js +35 -2
- package/dist/followupquestionbuilder.d.ts +75 -0
- package/dist/followupquestionbuilder.js +197 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +23 -0
- package/dist/llmoutputhandler.d.ts +102 -0
- package/dist/llmoutputhandler.js +452 -0
- package/dist/processor/types/interfaces.d.ts +21 -44
- package/dist/processor-pieces/index.d.ts +3 -0
- package/dist/processor-pieces/index.js +3 -0
- package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.d.ts +5 -14
- package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +40 -41
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +13 -5
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +58 -50
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +8 -6
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +22 -66
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +2 -3
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +2 -1
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +2 -3
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +2 -1
- package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +4 -1
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +2 -18
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +93 -291
- package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.d.ts +18 -0
- package/dist/processor-pieces/postToolCallProcessors/conversationCompactorModifier.js +41 -0
- package/dist/processor-pieces/postToolCallProcessors/index.d.ts +2 -1
- package/dist/processor-pieces/postToolCallProcessors/index.js +5 -0
- package/dist/processor-pieces/preInferenceProcessors/index.d.ts +1 -1
- package/dist/processor-pieces/preInferenceProcessors/index.js +3 -0
- package/dist/processor-pieces/pretoolCallProcessors/index.d.ts +2 -1
- package/dist/processor-pieces/pretoolCallProcessors/index.js +5 -0
- package/dist/processor-pieces/pretoolCallProcessors/toolParameterModifier.d.ts +21 -0
- package/dist/processor-pieces/pretoolCallProcessors/toolParameterModifier.js +32 -0
- package/dist/processor-pieces/pretoolCallProcessors/toolValidationModifier.d.ts +16 -0
- package/dist/processor-pieces/pretoolCallProcessors/toolValidationModifier.js +37 -0
- package/dist/promptbuilder.d.ts +382 -0
- package/dist/promptbuilder.js +805 -0
- package/dist/systemprompt.d.ts +20 -0
- package/dist/systemprompt.js +48 -0
- package/dist/taskInstruction.d.ts +37 -0
- package/dist/taskInstruction.js +57 -0
- package/dist/unified/agent/agent.js +2 -2
- package/dist/unified/agent/codeboltAgent.d.ts +122 -0
- package/dist/unified/agent/codeboltAgent.js +210 -0
- package/dist/unified/base/initialPromptGenerator.js +18 -4
- package/dist/unified/base/responseExecutor.d.ts +3 -2
- package/dist/unified/base/responseExecutor.js +100 -56
- package/dist/unified/index.d.ts +4 -0
- package/dist/unified/index.js +12 -1
- package/dist/usermessage.d.ts +70 -0
- package/dist/usermessage.js +123 -0
- package/package.json +5 -5
- package/dist/local-tools/fileTools.d.ts +0 -26
- package/dist/local-tools/fileTools.js +0 -162
- package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.d.ts +0 -13
- package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.js +0 -68
- package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.d.ts +0 -15
- package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.js +0 -212
- package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.d.ts +0 -19
- package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.js +0 -110
- package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.d.ts +0 -23
- package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.js +0 -173
- package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.d.ts +0 -14
- package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.js +0 -93
- package/dist/processor-pieces/additionalModifiers/directoryContextModifier.d.ts +0 -30
- package/dist/processor-pieces/additionalModifiers/directoryContextModifier.js +0 -330
- package/dist/processor-pieces/additionalModifiers/environmentContextModifier.d.ts +0 -26
- package/dist/processor-pieces/additionalModifiers/environmentContextModifier.js +0 -269
- package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.d.ts +0 -38
- package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.js +0 -217
- package/dist/processor-pieces/additionalModifiers/ideContextModifier.d.ts +0 -34
- package/dist/processor-pieces/additionalModifiers/ideContextModifier.js +0 -147
- package/dist/processor-pieces/additionalModifiers/index.d.ts +0 -12
- package/dist/processor-pieces/additionalModifiers/index.js +0 -28
- package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.d.ts +0 -29
- package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.js +0 -155
- package/dist/processor-pieces/additionalModifiers/memoryImportModifier.d.ts +0 -15
- package/dist/processor-pieces/additionalModifiers/memoryImportModifier.js +0 -129
- package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.d.ts +0 -25
- package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.js +0 -169
- package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.d.ts +0 -20
- package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.js +0 -152
- package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.d.ts +0 -7
- package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.js +0 -93
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.d.ts +0 -9
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.js +0 -77
- package/dist/processor-pieces/messageModifiers/chatCompressionModifier.d.ts +0 -19
- package/dist/processor-pieces/messageModifiers/chatCompressionModifier.js +0 -110
- package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.d.ts +0 -20
- package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.js +0 -124
- package/dist/processor-pieces/messageModifiers/environmentContext.d.ts +0 -41
- package/dist/processor-pieces/messageModifiers/environmentContext.js +0 -355
- package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.d.ts +0 -23
- package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.js +0 -207
- package/dist/processor-pieces/messageModifiers/simpleMessageModifier.d.ts +0 -7
- package/dist/processor-pieces/messageModifiers/simpleMessageModifier.js +0 -26
- package/dist/processor-pieces/postInference/llmOutputValidityProcessor.d.ts +0 -1
- package/dist/processor-pieces/postInference/llmOutputValidityProcessor.js +0 -2
- package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.d.ts +0 -7
- package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.js +0 -24
- package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.d.ts +0 -41
- package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.js +0 -197
- package/dist/processor-pieces/postToolCall/chatCompressionProcessor.d.ts +0 -26
- package/dist/processor-pieces/postToolCall/chatCompressionProcessor.js +0 -90
- package/dist/processor-pieces/postToolCall/chatRecordingProcessor.d.ts +0 -81
- package/dist/processor-pieces/postToolCall/chatRecordingProcessor.js +0 -329
- package/dist/processor-pieces/postToolCall/contextManagementProcessor.d.ts +0 -40
- package/dist/processor-pieces/postToolCall/contextManagementProcessor.js +0 -272
- package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.d.ts +0 -49
- package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.js +0 -291
- package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.d.ts +0 -49
- package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.js +0 -293
- package/dist/processor-pieces/postToolCall/followUpConversationProcessor.d.ts +0 -47
- package/dist/processor-pieces/postToolCall/followUpConversationProcessor.js +0 -249
- package/dist/processor-pieces/postToolCall/loopDetectionProcessor.d.ts +0 -30
- package/dist/processor-pieces/postToolCall/loopDetectionProcessor.js +0 -137
- package/dist/processor-pieces/postToolCall/responseValidationProcessor.d.ts +0 -30
- package/dist/processor-pieces/postToolCall/responseValidationProcessor.js +0 -228
- package/dist/processor-pieces/postToolCall/telemetryProcessor.d.ts +0 -99
- package/dist/processor-pieces/postToolCall/telemetryProcessor.js +0 -278
- package/dist/processor-pieces/postToolCall/tokenManagementProcessor.d.ts +0 -37
- package/dist/processor-pieces/postToolCall/tokenManagementProcessor.js +0 -178
- package/dist/processor-pieces/postToolCall/toolExecutionProcessor.d.ts +0 -43
- package/dist/processor-pieces/postToolCall/toolExecutionProcessor.js +0 -207
- package/dist/processor-pieces/preInference/conversationCompactorProcessor.d.ts +0 -52
- package/dist/processor-pieces/preInference/conversationCompactorProcessor.js +0 -264
- package/dist/processor-pieces/preInference/conversationContinuityProcessor.d.ts +0 -49
- package/dist/processor-pieces/preInference/conversationContinuityProcessor.js +0 -293
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.d.ts +0 -7
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.js +0 -31
- package/dist/processor-pieces/preToolCall/index.d.ts +0 -9
- package/dist/processor-pieces/preToolCall/index.js +0 -18
- package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.d.ts +0 -58
- package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.js +0 -444
- package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.d.ts +0 -44
- package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.js +0 -367
- package/dist/processor-pieces/preToolCall/toolValidationProcessor.d.ts +0 -58
- package/dist/processor-pieces/preToolCall/toolValidationProcessor.js +0 -391
- package/dist/unified/agent/tool.d.ts +0 -99
- package/dist/unified/agent/tool.js +0 -440
- package/dist/unified/examples/agentExample.d.ts +0 -46
- package/dist/unified/examples/agentExample.js +0 -464
- package/dist/unified/examples/documentationPatternExample.d.ts +0 -10
- package/dist/unified/examples/documentationPatternExample.js +0 -385
- package/dist/unified/examples/followUpProcessorsExample.d.ts +0 -45
- package/dist/unified/examples/followUpProcessorsExample.js +0 -311
- package/dist/unified/examples/orchestratorExample.d.ts +0 -16
- package/dist/unified/examples/orchestratorExample.js +0 -415
- package/dist/unified/examples/preToolCallProcessorsExample.d.ts +0 -36
- package/dist/unified/examples/preToolCallProcessorsExample.js +0 -458
- package/dist/unified/examples/workflowExample.d.ts +0 -12
- package/dist/unified/examples/workflowExample.js +0 -497
- package/dist/unified/orchestrator/orchestrator.d.ts +0 -260
- package/dist/unified/orchestrator/orchestrator.js +0 -519
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Example demonstrating how to use follow-up conversation processors
|
|
4
|
-
* with the Unified Agent Framework
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.CustomMetricsProcessor = void 0;
|
|
8
|
-
exports.basicFollowUpProcessorExample = basicFollowUpProcessorExample;
|
|
9
|
-
exports.advancedFollowUpProcessorExample = advancedFollowUpProcessorExample;
|
|
10
|
-
exports.dynamicProcessorManagementExample = dynamicProcessorManagementExample;
|
|
11
|
-
exports.processorEventMonitoringExample = processorEventMonitoringExample;
|
|
12
|
-
exports.customProcessorExample = customProcessorExample;
|
|
13
|
-
const index_1 = require("../index");
|
|
14
|
-
const processors_1 = require("../processors");
|
|
15
|
-
/**
|
|
16
|
-
* Example 1: Basic Follow-Up Processor Usage
|
|
17
|
-
*/
|
|
18
|
-
async function basicFollowUpProcessorExample(codebolt, tools) {
|
|
19
|
-
// Create processors
|
|
20
|
-
const compactorProcessor = new processors_1.ConversationCompactorProcessor({
|
|
21
|
-
maxConversationLength: 30,
|
|
22
|
-
enableSummarization: true,
|
|
23
|
-
enableSmartRemoval: true,
|
|
24
|
-
preserveRecentMessages: 8
|
|
25
|
-
});
|
|
26
|
-
const followUpProcessor = new processors_1.FollowUpConversationProcessor({
|
|
27
|
-
processingMode: 'guided',
|
|
28
|
-
enableToolResultEnhancement: true,
|
|
29
|
-
addFollowUpPrompts: true
|
|
30
|
-
});
|
|
31
|
-
// Create response executor with processors
|
|
32
|
-
const responseExecutor = (0, index_1.createUnifiedResponseExecutor)({
|
|
33
|
-
codebolt,
|
|
34
|
-
maxConversationLength: 50,
|
|
35
|
-
followUpConversationProcessors: [
|
|
36
|
-
compactorProcessor,
|
|
37
|
-
followUpProcessor
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
// Create unified agent
|
|
41
|
-
const agent = (0, index_1.createUnifiedAgent)({
|
|
42
|
-
codebolt,
|
|
43
|
-
maxIterations: 10,
|
|
44
|
-
enableLogging: true
|
|
45
|
-
});
|
|
46
|
-
// Set the enhanced response executor
|
|
47
|
-
agent.setResponseExecutor(responseExecutor);
|
|
48
|
-
// Execute agent with a complex task
|
|
49
|
-
const result = await agent.loop({
|
|
50
|
-
userMessage: "Please read the package.json file, analyze its dependencies, and suggest optimizations",
|
|
51
|
-
tools,
|
|
52
|
-
maxIterations: 15
|
|
53
|
-
});
|
|
54
|
-
console.log('Agent completed with enhanced follow-up processing:', result.response);
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Example 2: Advanced Processor Configuration
|
|
59
|
-
*/
|
|
60
|
-
async function advancedFollowUpProcessorExample(codebolt, tools) {
|
|
61
|
-
// Create conversation compactor with custom settings
|
|
62
|
-
const compactorProcessor = new processors_1.ConversationCompactorProcessor({
|
|
63
|
-
maxConversationLength: 40,
|
|
64
|
-
compactionThreshold: 0.75, // Compact when 75% full
|
|
65
|
-
preserveRecentMessages: 12,
|
|
66
|
-
preserveSystemMessages: true,
|
|
67
|
-
preserveToolMessages: true,
|
|
68
|
-
enableSummarization: true,
|
|
69
|
-
enableSmartRemoval: true,
|
|
70
|
-
compressionRatio: 0.5 // Target 50% compression
|
|
71
|
-
});
|
|
72
|
-
// Create follow-up processor with automatic mode
|
|
73
|
-
const followUpProcessor = new processors_1.FollowUpConversationProcessor({
|
|
74
|
-
processingMode: 'automatic',
|
|
75
|
-
enableToolResultEnhancement: true,
|
|
76
|
-
addFollowUpPrompts: true,
|
|
77
|
-
addContextualHints: true,
|
|
78
|
-
maxFollowUpMessages: 2
|
|
79
|
-
});
|
|
80
|
-
// Create continuity processor
|
|
81
|
-
const continuityProcessor = new processors_1.ConversationContinuityProcessor({
|
|
82
|
-
enableContextLinking: true,
|
|
83
|
-
enableReferenceResolution: true,
|
|
84
|
-
enableGapDetection: true,
|
|
85
|
-
maxContextLinks: 3,
|
|
86
|
-
contextLookbackWindow: 15,
|
|
87
|
-
enableProactiveContext: true
|
|
88
|
-
});
|
|
89
|
-
// Create response executor with all processors
|
|
90
|
-
const responseExecutor = (0, index_1.createUnifiedResponseExecutor)({
|
|
91
|
-
codebolt,
|
|
92
|
-
maxConversationLength: 60,
|
|
93
|
-
enableLogging: true,
|
|
94
|
-
followUpConversationProcessors: [
|
|
95
|
-
compactorProcessor,
|
|
96
|
-
followUpProcessor,
|
|
97
|
-
continuityProcessor
|
|
98
|
-
]
|
|
99
|
-
});
|
|
100
|
-
// Create agent configuration
|
|
101
|
-
const agentConfig = {
|
|
102
|
-
codebolt,
|
|
103
|
-
maxIterations: 20,
|
|
104
|
-
maxConversationLength: 60,
|
|
105
|
-
enableLogging: true,
|
|
106
|
-
llmConfig: {
|
|
107
|
-
llmname: 'gpt-4',
|
|
108
|
-
temperature: 0.7,
|
|
109
|
-
maxTokens: 2000
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
const agent = (0, index_1.createUnifiedAgent)(agentConfig);
|
|
113
|
-
agent.setResponseExecutor(responseExecutor);
|
|
114
|
-
// Add event listeners to monitor processor activity
|
|
115
|
-
agent.addEventListener('response_generated', (event) => {
|
|
116
|
-
console.log('Response generated with processor enhancements:', event.data);
|
|
117
|
-
});
|
|
118
|
-
agent.addEventListener('tool_execution_completed', (event) => {
|
|
119
|
-
console.log('Tool execution completed, processors will enhance follow-up:', event.data);
|
|
120
|
-
});
|
|
121
|
-
// Execute a multi-step task
|
|
122
|
-
const result = await agent.loop({
|
|
123
|
-
userMessage: "Help me set up a new React project with TypeScript, configure ESLint and Prettier, and create a basic component structure",
|
|
124
|
-
tools,
|
|
125
|
-
maxIterations: 25
|
|
126
|
-
});
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Example 3: Dynamic Processor Management
|
|
131
|
-
*/
|
|
132
|
-
async function dynamicProcessorManagementExample(codebolt, tools) {
|
|
133
|
-
// Create response executor without initial processors
|
|
134
|
-
const responseExecutor = (0, index_1.createUnifiedResponseExecutor)({
|
|
135
|
-
codebolt,
|
|
136
|
-
maxConversationLength: 50,
|
|
137
|
-
enableLogging: true
|
|
138
|
-
});
|
|
139
|
-
const agent = (0, index_1.createUnifiedAgent)({ codebolt });
|
|
140
|
-
agent.setResponseExecutor(responseExecutor);
|
|
141
|
-
// Start with basic processing
|
|
142
|
-
console.log('Starting with no processors...');
|
|
143
|
-
let result = await agent.step({
|
|
144
|
-
userMessage: "List the files in the current directory",
|
|
145
|
-
tools
|
|
146
|
-
});
|
|
147
|
-
// Add compactor processor when conversation gets longer
|
|
148
|
-
console.log('Adding compactor processor...');
|
|
149
|
-
const compactorProcessor = new processors_1.ConversationCompactorProcessor({
|
|
150
|
-
maxConversationLength: 20,
|
|
151
|
-
enableSummarization: true
|
|
152
|
-
});
|
|
153
|
-
responseExecutor.addFollowUpConversationProcessor(compactorProcessor);
|
|
154
|
-
result = await agent.step({
|
|
155
|
-
userMessage: "Now read the README.md file and summarize it",
|
|
156
|
-
tools,
|
|
157
|
-
conversationHistory: result.conversationHistory
|
|
158
|
-
});
|
|
159
|
-
// Add follow-up processor for better guidance
|
|
160
|
-
console.log('Adding follow-up processor...');
|
|
161
|
-
const followUpProcessor = new processors_1.FollowUpConversationProcessor({
|
|
162
|
-
processingMode: 'guided',
|
|
163
|
-
enableToolResultEnhancement: true
|
|
164
|
-
});
|
|
165
|
-
responseExecutor.addFollowUpConversationProcessor(followUpProcessor);
|
|
166
|
-
result = await agent.step({
|
|
167
|
-
userMessage: "Based on the README, what are the next steps I should take?",
|
|
168
|
-
tools,
|
|
169
|
-
conversationHistory: result.conversationHistory
|
|
170
|
-
});
|
|
171
|
-
// Remove processors if needed
|
|
172
|
-
console.log('Removing compactor processor...');
|
|
173
|
-
responseExecutor.removeFollowUpConversationProcessor(compactorProcessor);
|
|
174
|
-
// Check active processors
|
|
175
|
-
const activeProcessors = responseExecutor.getFollowUpConversationProcessors();
|
|
176
|
-
console.log(`Active processors: ${activeProcessors.length}`);
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Example 4: Processor Event Monitoring
|
|
181
|
-
*/
|
|
182
|
-
async function processorEventMonitoringExample(codebolt, tools) {
|
|
183
|
-
// Create processors with logging
|
|
184
|
-
const compactorProcessor = new processors_1.ConversationCompactorProcessor({
|
|
185
|
-
maxConversationLength: 25,
|
|
186
|
-
enableSummarization: true,
|
|
187
|
-
enableSmartRemoval: true
|
|
188
|
-
});
|
|
189
|
-
const followUpProcessor = new processors_1.FollowUpConversationProcessor({
|
|
190
|
-
processingMode: 'automatic',
|
|
191
|
-
enableToolResultEnhancement: true,
|
|
192
|
-
addFollowUpPrompts: true
|
|
193
|
-
});
|
|
194
|
-
// Monitor processor events by extending the processors
|
|
195
|
-
class MonitoredCompactorProcessor extends processors_1.ConversationCompactorProcessor {
|
|
196
|
-
async processInput(input) {
|
|
197
|
-
console.log('🔄 Compactor processor starting...');
|
|
198
|
-
const results = await super.processInput(input);
|
|
199
|
-
results.forEach(result => {
|
|
200
|
-
switch (result.type) {
|
|
201
|
-
case 'ConversationCompacted':
|
|
202
|
-
console.log('✂️ Conversation compacted:', result.value);
|
|
203
|
-
break;
|
|
204
|
-
case 'ConversationCompactionSkipped':
|
|
205
|
-
console.log('⏭️ Compaction skipped:', result.value.reason);
|
|
206
|
-
break;
|
|
207
|
-
case 'ConversationCompactionError':
|
|
208
|
-
console.log('❌ Compaction error:', result.value.error);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
return results;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
class MonitoredFollowUpProcessor extends processors_1.FollowUpConversationProcessor {
|
|
216
|
-
async processInput(input) {
|
|
217
|
-
console.log('💬 Follow-up processor starting...');
|
|
218
|
-
const results = await super.processInput(input);
|
|
219
|
-
results.forEach(result => {
|
|
220
|
-
switch (result.type) {
|
|
221
|
-
case 'FollowUpConversationProcessed':
|
|
222
|
-
console.log('🎯 Follow-up processed:', result.value);
|
|
223
|
-
break;
|
|
224
|
-
case 'FollowUpProcessingSkipped':
|
|
225
|
-
console.log('⏭️ Follow-up processing skipped:', result.value.reason);
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
return results;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// Create response executor with monitored processors
|
|
233
|
-
const responseExecutor = (0, index_1.createUnifiedResponseExecutor)({
|
|
234
|
-
codebolt,
|
|
235
|
-
maxConversationLength: 40,
|
|
236
|
-
enableLogging: true,
|
|
237
|
-
followUpConversationProcessors: [
|
|
238
|
-
new MonitoredCompactorProcessor(),
|
|
239
|
-
new MonitoredFollowUpProcessor()
|
|
240
|
-
]
|
|
241
|
-
});
|
|
242
|
-
const agent = (0, index_1.createUnifiedAgent)({ codebolt, enableLogging: true });
|
|
243
|
-
agent.setResponseExecutor(responseExecutor);
|
|
244
|
-
// Execute with monitoring
|
|
245
|
-
const result = await agent.loop({
|
|
246
|
-
userMessage: "Help me debug this JavaScript code and fix any issues you find",
|
|
247
|
-
tools,
|
|
248
|
-
maxIterations: 15
|
|
249
|
-
});
|
|
250
|
-
return result;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Example 5: Custom Processor Creation
|
|
254
|
-
*/
|
|
255
|
-
class CustomMetricsProcessor extends processors_1.ConversationCompactorProcessor {
|
|
256
|
-
constructor() {
|
|
257
|
-
super(...arguments);
|
|
258
|
-
this.metricsCollected = [];
|
|
259
|
-
}
|
|
260
|
-
async processInput(input) {
|
|
261
|
-
var _a, _b;
|
|
262
|
-
const startTime = Date.now();
|
|
263
|
-
const results = await super.processInput(input);
|
|
264
|
-
const processingTime = Date.now() - startTime;
|
|
265
|
-
// Collect metrics
|
|
266
|
-
this.metricsCollected.push({
|
|
267
|
-
timestamp: new Date().toISOString(),
|
|
268
|
-
messageCount: input.message.messages.length,
|
|
269
|
-
toolCount: ((_b = (_a = input.context) === null || _a === void 0 ? void 0 : _a.toolResults) === null || _b === void 0 ? void 0 : _b.length) || 0,
|
|
270
|
-
processingTime
|
|
271
|
-
});
|
|
272
|
-
// Add metrics event
|
|
273
|
-
results.push(this.createEvent('MetricsCollected', {
|
|
274
|
-
totalProcessingTime: processingTime,
|
|
275
|
-
averageProcessingTime: this.getAverageProcessingTime(),
|
|
276
|
-
totalInteractions: this.metricsCollected.length
|
|
277
|
-
}));
|
|
278
|
-
return results;
|
|
279
|
-
}
|
|
280
|
-
getAverageProcessingTime() {
|
|
281
|
-
if (this.metricsCollected.length === 0)
|
|
282
|
-
return 0;
|
|
283
|
-
const total = this.metricsCollected.reduce((sum, metric) => sum + metric.processingTime, 0);
|
|
284
|
-
return total / this.metricsCollected.length;
|
|
285
|
-
}
|
|
286
|
-
getMetrics() {
|
|
287
|
-
return [...this.metricsCollected];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
exports.CustomMetricsProcessor = CustomMetricsProcessor;
|
|
291
|
-
async function customProcessorExample(codebolt, tools) {
|
|
292
|
-
const customProcessor = new CustomMetricsProcessor({
|
|
293
|
-
maxConversationLength: 30,
|
|
294
|
-
enableSummarization: true
|
|
295
|
-
});
|
|
296
|
-
const responseExecutor = (0, index_1.createUnifiedResponseExecutor)({
|
|
297
|
-
codebolt,
|
|
298
|
-
followUpConversationProcessors: [customProcessor]
|
|
299
|
-
});
|
|
300
|
-
const agent = (0, index_1.createUnifiedAgent)({ codebolt });
|
|
301
|
-
agent.setResponseExecutor(responseExecutor);
|
|
302
|
-
const result = await agent.loop({
|
|
303
|
-
userMessage: "Analyze the performance of this application and suggest improvements",
|
|
304
|
-
tools,
|
|
305
|
-
maxIterations: 10
|
|
306
|
-
});
|
|
307
|
-
// Get collected metrics
|
|
308
|
-
const metrics = customProcessor.getMetrics();
|
|
309
|
-
console.log('Collected metrics:', metrics);
|
|
310
|
-
return { result, metrics };
|
|
311
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orchestrator Pattern Example for Unified Agent Framework
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates how to create and use an orchestrator that can
|
|
5
|
-
* dynamically coordinate agents, workflows, and tools based on the pattern
|
|
6
|
-
* described in the documentation.
|
|
7
|
-
*/
|
|
8
|
-
declare function orchestratorPatternExample(): Promise<{
|
|
9
|
-
result1: import("../index").OrchestratorResult;
|
|
10
|
-
result2: import("../index").OrchestratorResult;
|
|
11
|
-
result3: import("../index").OrchestratorResult;
|
|
12
|
-
}>;
|
|
13
|
-
declare function dynamicResourceSelectionExample(): Promise<import("../index").OrchestratorResult[]>;
|
|
14
|
-
declare function orchestratorAsToolExample(): Promise<any>;
|
|
15
|
-
export declare function runOrchestratorExamples(): Promise<void>;
|
|
16
|
-
export { orchestratorPatternExample, dynamicResourceSelectionExample, orchestratorAsToolExample };
|