@codebolt/agent 2.2.2 → 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.
- 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 +6 -1
- package/dist/composablepattern/document.js +2 -35
- package/dist/local-tools/fileTools.d.ts +26 -0
- package/dist/local-tools/fileTools.js +162 -0
- package/dist/processor/types/interfaces.d.ts +44 -21
- package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.d.ts +13 -0
- package/dist/processor-pieces/additionalModifiers/argumentProcessorModifier.js +68 -0
- package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.d.ts +15 -0
- package/dist/processor-pieces/additionalModifiers/atFileProcessorModifier.js +212 -0
- package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.d.ts +19 -0
- package/dist/processor-pieces/additionalModifiers/chatCompressionModifier.js +110 -0
- package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.d.ts +23 -0
- package/dist/processor-pieces/additionalModifiers/chatRecordingModifier.js +173 -0
- package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.d.ts +14 -0
- package/dist/processor-pieces/additionalModifiers/coreSystemPromptModifier.js +93 -0
- package/dist/processor-pieces/additionalModifiers/directoryContextModifier.d.ts +30 -0
- package/dist/processor-pieces/additionalModifiers/directoryContextModifier.js +330 -0
- package/dist/processor-pieces/additionalModifiers/environmentContextModifier.d.ts +26 -0
- package/dist/processor-pieces/additionalModifiers/environmentContextModifier.js +269 -0
- package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.d.ts +38 -0
- package/dist/processor-pieces/additionalModifiers/fallbackHandlerModifier.js +217 -0
- package/dist/processor-pieces/additionalModifiers/ideContextModifier.d.ts +34 -0
- package/dist/processor-pieces/additionalModifiers/ideContextModifier.js +147 -0
- package/dist/processor-pieces/additionalModifiers/index.d.ts +12 -0
- package/dist/processor-pieces/additionalModifiers/index.js +28 -0
- package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.d.ts +29 -0
- package/dist/processor-pieces/additionalModifiers/loopDetectionModifier.js +155 -0
- package/dist/processor-pieces/additionalModifiers/memoryImportModifier.d.ts +15 -0
- package/dist/processor-pieces/additionalModifiers/memoryImportModifier.js +129 -0
- package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.d.ts +25 -0
- package/dist/processor-pieces/additionalModifiers/shellProcessorModifier.js +169 -0
- package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.d.ts +20 -0
- package/dist/processor-pieces/additionalModifiers/toolInjectionModifier.js +152 -0
- package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.d.ts +7 -0
- package/dist/processor-pieces/messageModifiers/addCurrentDirectoryRootFilesModifier.js +93 -0
- package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.d.ts +14 -5
- package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +41 -40
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.d.ts +9 -0
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.js +77 -0
- package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.js +5 -5
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +5 -13
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +50 -58
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +6 -8
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +66 -22
- package/dist/processor-pieces/messageModifiers/chatCompressionModifier.d.ts +19 -0
- package/dist/processor-pieces/messageModifiers/chatCompressionModifier.js +110 -0
- package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.d.ts +20 -0
- package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.example.js +124 -0
- package/dist/processor-pieces/messageModifiers/environmentContext.d.ts +41 -0
- package/dist/processor-pieces/messageModifiers/environmentContext.js +355 -0
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +3 -2
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +1 -2
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +3 -2
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +1 -2
- package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.d.ts +23 -0
- package/dist/processor-pieces/messageModifiers/mentionedFilesModifier.js +207 -0
- package/dist/processor-pieces/messageModifiers/simpleMessageModifier.d.ts +7 -0
- package/dist/processor-pieces/messageModifiers/simpleMessageModifier.js +26 -0
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +18 -2
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +291 -93
- package/dist/processor-pieces/postInference/llmOutputValidityProcessor.d.ts +1 -0
- package/dist/processor-pieces/postInference/llmOutputValidityProcessor.js +2 -0
- package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.d.ts +7 -0
- package/dist/processor-pieces/postInferenceProcessors/checkForNoToolCall.js +24 -0
- package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.d.ts +41 -0
- package/dist/processor-pieces/postToolCall/advancedLoopDetectionProcessor.js +197 -0
- package/dist/processor-pieces/postToolCall/chatCompressionProcessor.d.ts +26 -0
- package/dist/processor-pieces/postToolCall/chatCompressionProcessor.js +90 -0
- package/dist/processor-pieces/postToolCall/chatRecordingProcessor.d.ts +81 -0
- package/dist/processor-pieces/postToolCall/chatRecordingProcessor.js +329 -0
- package/dist/processor-pieces/postToolCall/contextManagementProcessor.d.ts +40 -0
- package/dist/processor-pieces/postToolCall/contextManagementProcessor.js +272 -0
- package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.d.ts +49 -0
- package/dist/processor-pieces/postToolCall/conversationCompactorProcessor.js +291 -0
- package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.d.ts +49 -0
- package/dist/processor-pieces/postToolCall/conversationContinuityProcessor.js +293 -0
- package/dist/processor-pieces/postToolCall/followUpConversationProcessor.d.ts +47 -0
- package/dist/processor-pieces/postToolCall/followUpConversationProcessor.js +249 -0
- package/dist/processor-pieces/postToolCall/loopDetectionProcessor.d.ts +30 -0
- package/dist/processor-pieces/postToolCall/loopDetectionProcessor.js +137 -0
- package/dist/processor-pieces/postToolCall/responseValidationProcessor.d.ts +30 -0
- package/dist/processor-pieces/postToolCall/responseValidationProcessor.js +228 -0
- package/dist/processor-pieces/postToolCall/telemetryProcessor.d.ts +99 -0
- package/dist/processor-pieces/postToolCall/telemetryProcessor.js +278 -0
- package/dist/processor-pieces/postToolCall/tokenManagementProcessor.d.ts +37 -0
- package/dist/processor-pieces/postToolCall/tokenManagementProcessor.js +178 -0
- package/dist/processor-pieces/postToolCall/toolExecutionProcessor.d.ts +43 -0
- package/dist/processor-pieces/postToolCall/toolExecutionProcessor.js +207 -0
- package/dist/processor-pieces/preInference/conversationCompactorProcessor.d.ts +52 -0
- package/dist/processor-pieces/preInference/conversationCompactorProcessor.js +264 -0
- package/dist/processor-pieces/preInference/conversationContinuityProcessor.d.ts +49 -0
- package/dist/processor-pieces/preInference/conversationContinuityProcessor.js +293 -0
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.d.ts +7 -0
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.js +31 -0
- package/dist/processor-pieces/preToolCall/index.d.ts +9 -0
- package/dist/processor-pieces/preToolCall/index.js +18 -0
- package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.d.ts +58 -0
- package/dist/processor-pieces/preToolCall/localToolInterceptorProcessor.js +444 -0
- package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.d.ts +44 -0
- package/dist/processor-pieces/preToolCall/toolParameterModifierProcessor.js +367 -0
- package/dist/processor-pieces/preToolCall/toolValidationProcessor.d.ts +58 -0
- package/dist/processor-pieces/preToolCall/toolValidationProcessor.js +391 -0
- package/dist/unified/agent/agent.js +2 -2
- package/dist/unified/agent/tool.d.ts +99 -0
- package/dist/unified/agent/tool.js +440 -0
- package/dist/unified/base/initialPromptGenerator.js +5 -5
- package/dist/unified/base/responseExecutor.js +6 -6
- package/dist/unified/examples/agentExample.d.ts +46 -0
- package/dist/unified/examples/agentExample.js +464 -0
- package/dist/unified/examples/documentationPatternExample.d.ts +10 -0
- package/dist/unified/examples/documentationPatternExample.js +385 -0
- package/dist/unified/examples/followUpProcessorsExample.d.ts +45 -0
- package/dist/unified/examples/followUpProcessorsExample.js +311 -0
- package/dist/unified/examples/orchestratorExample.d.ts +16 -0
- package/dist/unified/examples/orchestratorExample.js +415 -0
- package/dist/unified/examples/preToolCallProcessorsExample.d.ts +36 -0
- package/dist/unified/examples/preToolCallProcessorsExample.js +458 -0
- package/dist/unified/examples/workflowExample.d.ts +12 -0
- package/dist/unified/examples/workflowExample.js +497 -0
- package/dist/unified/orchestrator/orchestrator.d.ts +260 -0
- package/dist/unified/orchestrator/orchestrator.js +519 -0
- package/package.json +15 -15
- package/dist/agent.d.ts +0 -86
- package/dist/agent.js +0 -324
- package/dist/followupquestionbuilder.d.ts +0 -75
- package/dist/followupquestionbuilder.js +0 -197
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -23
- package/dist/llmoutputhandler.d.ts +0 -102
- package/dist/llmoutputhandler.js +0 -452
- package/dist/promptbuilder.d.ts +0 -382
- package/dist/promptbuilder.js +0 -805
- package/dist/systemprompt.d.ts +0 -20
- package/dist/systemprompt.js +0 -48
- package/dist/taskInstruction.d.ts +0 -37
- package/dist/taskInstruction.js +0 -57
- package/dist/usermessage.d.ts +0 -70
- package/dist/usermessage.js +0 -123
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConversationCompactorProcessor = void 0;
|
|
7
|
+
const processor_1 = require("../../processor");
|
|
8
|
+
const codeboltjs_1 = __importDefault(require("@codebolt/codeboltjs"));
|
|
9
|
+
const { chatSummary } = codeboltjs_1.default;
|
|
10
|
+
/**
|
|
11
|
+
* Processor that compacts long conversations to keep them within manageable limits
|
|
12
|
+
* while preserving important context and recent interactions.
|
|
13
|
+
*/
|
|
14
|
+
class ConversationCompactorProcessor extends processor_1.BaseProcessor {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
super(options);
|
|
17
|
+
this.maxConversationLength = options.maxConversationLength || 50;
|
|
18
|
+
this.compactionThreshold = options.compactionThreshold || 0.8; // Compact when 80% of max length
|
|
19
|
+
this.preserveRecentMessages = options.preserveRecentMessages || 10;
|
|
20
|
+
this.preserveSystemMessages = options.preserveSystemMessages !== false;
|
|
21
|
+
this.preserveToolMessages = options.preserveToolMessages !== false;
|
|
22
|
+
this.enableSummarization = options.enableSummarization !== false;
|
|
23
|
+
this.enableSmartRemoval = options.enableSmartRemoval !== false;
|
|
24
|
+
this.compressionRatio = options.compressionRatio || 0.6; // Target 60% of original size
|
|
25
|
+
}
|
|
26
|
+
async processInput(input) {
|
|
27
|
+
try {
|
|
28
|
+
const { message, context } = input;
|
|
29
|
+
const conversationLength = message.messages.length;
|
|
30
|
+
const threshold = Math.floor(this.maxConversationLength * this.compactionThreshold);
|
|
31
|
+
// Check if compaction is needed
|
|
32
|
+
if (conversationLength <= threshold) {
|
|
33
|
+
return [this.createEvent('ConversationCompactionSkipped', {
|
|
34
|
+
conversationLength,
|
|
35
|
+
threshold,
|
|
36
|
+
reason: 'Below compaction threshold'
|
|
37
|
+
})];
|
|
38
|
+
}
|
|
39
|
+
// Perform compaction
|
|
40
|
+
const compactedMessage = await this.compactConversation(message, context);
|
|
41
|
+
const compactionInfo = this.calculateCompactionInfo(message, compactedMessage);
|
|
42
|
+
return [
|
|
43
|
+
this.createEvent('ConversationCompacted', compactionInfo),
|
|
44
|
+
this.createEvent('ConversationProcessed', compactedMessage)
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Error in ConversationCompactorProcessor:', error);
|
|
49
|
+
return [this.createEvent('ConversationCompactionError', {
|
|
50
|
+
error: error instanceof Error ? error.message : String(error),
|
|
51
|
+
originalLength: input.message.messages.length
|
|
52
|
+
})];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async compactConversation(message, context) {
|
|
56
|
+
const messages = [...message.messages];
|
|
57
|
+
let compactionMethod = 'truncation';
|
|
58
|
+
// Try smart removal first if enabled
|
|
59
|
+
if (this.enableSmartRemoval) {
|
|
60
|
+
const smartCompacted = await this.performSmartRemoval(messages);
|
|
61
|
+
if (smartCompacted.length <= this.maxConversationLength) {
|
|
62
|
+
compactionMethod = 'smart_removal';
|
|
63
|
+
return {
|
|
64
|
+
...message,
|
|
65
|
+
messages: smartCompacted,
|
|
66
|
+
metadata: {
|
|
67
|
+
...message.metadata,
|
|
68
|
+
compacted: true,
|
|
69
|
+
compactionMethod,
|
|
70
|
+
originalLength: messages.length,
|
|
71
|
+
compactedLength: smartCompacted.length
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Try summarization if enabled and we have chat summary service
|
|
77
|
+
if (this.enableSummarization) {
|
|
78
|
+
try {
|
|
79
|
+
const summarized = await this.performSummarization(messages);
|
|
80
|
+
if (summarized.length <= this.maxConversationLength) {
|
|
81
|
+
compactionMethod = 'summarization';
|
|
82
|
+
return {
|
|
83
|
+
...message,
|
|
84
|
+
messages: summarized,
|
|
85
|
+
metadata: {
|
|
86
|
+
...message.metadata,
|
|
87
|
+
compacted: true,
|
|
88
|
+
compactionMethod,
|
|
89
|
+
originalLength: messages.length,
|
|
90
|
+
compactedLength: summarized.length
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.warn('Summarization failed, falling back to truncation:', error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Fall back to truncation
|
|
100
|
+
const truncated = this.performTruncation(messages);
|
|
101
|
+
return {
|
|
102
|
+
...message,
|
|
103
|
+
messages: truncated,
|
|
104
|
+
metadata: {
|
|
105
|
+
...message.metadata,
|
|
106
|
+
compacted: true,
|
|
107
|
+
compactionMethod,
|
|
108
|
+
originalLength: messages.length,
|
|
109
|
+
compactedLength: truncated.length
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async performSmartRemoval(messages) {
|
|
114
|
+
const result = [];
|
|
115
|
+
const messagesToAnalyze = [...messages];
|
|
116
|
+
// Always preserve system messages if enabled
|
|
117
|
+
if (this.preserveSystemMessages) {
|
|
118
|
+
const systemMessages = messagesToAnalyze.filter(m => m.role === 'system');
|
|
119
|
+
result.push(...systemMessages);
|
|
120
|
+
messagesToAnalyze.splice(0, messagesToAnalyze.length, ...messagesToAnalyze.filter(m => m.role !== 'system'));
|
|
121
|
+
}
|
|
122
|
+
// Always preserve recent messages
|
|
123
|
+
const recentMessages = messagesToAnalyze.slice(-this.preserveRecentMessages);
|
|
124
|
+
const olderMessages = messagesToAnalyze.slice(0, -this.preserveRecentMessages);
|
|
125
|
+
// Analyze older messages for importance
|
|
126
|
+
const importantOlderMessages = this.selectImportantMessages(olderMessages);
|
|
127
|
+
// Preserve tool messages if enabled
|
|
128
|
+
let toolMessages = [];
|
|
129
|
+
if (this.preserveToolMessages) {
|
|
130
|
+
toolMessages = olderMessages.filter(m => m.role === 'tool');
|
|
131
|
+
}
|
|
132
|
+
// Combine all preserved messages
|
|
133
|
+
const preservedMessages = [
|
|
134
|
+
...importantOlderMessages,
|
|
135
|
+
...toolMessages,
|
|
136
|
+
...recentMessages
|
|
137
|
+
];
|
|
138
|
+
// Remove duplicates while preserving order
|
|
139
|
+
const seen = new Set();
|
|
140
|
+
const uniqueMessages = preservedMessages.filter(msg => {
|
|
141
|
+
const key = `${msg.role}-${JSON.stringify(msg.content)}-${msg.tool_call_id || ''}`;
|
|
142
|
+
if (seen.has(key))
|
|
143
|
+
return false;
|
|
144
|
+
seen.add(key);
|
|
145
|
+
return true;
|
|
146
|
+
});
|
|
147
|
+
result.push(...uniqueMessages);
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
selectImportantMessages(messages) {
|
|
151
|
+
// Score messages based on importance criteria
|
|
152
|
+
const scoredMessages = messages.map(msg => ({
|
|
153
|
+
message: msg,
|
|
154
|
+
score: this.calculateMessageImportance(msg)
|
|
155
|
+
}));
|
|
156
|
+
// Sort by score (highest first)
|
|
157
|
+
scoredMessages.sort((a, b) => b.score - a.score);
|
|
158
|
+
// Select top messages up to compression ratio
|
|
159
|
+
const targetCount = Math.floor(messages.length * this.compressionRatio);
|
|
160
|
+
return scoredMessages.slice(0, targetCount).map(sm => sm.message);
|
|
161
|
+
}
|
|
162
|
+
calculateMessageImportance(message) {
|
|
163
|
+
let score = 0;
|
|
164
|
+
// Base score by role
|
|
165
|
+
switch (message.role) {
|
|
166
|
+
case 'system':
|
|
167
|
+
score += 10;
|
|
168
|
+
break;
|
|
169
|
+
case 'tool':
|
|
170
|
+
score += 8;
|
|
171
|
+
break;
|
|
172
|
+
case 'assistant':
|
|
173
|
+
score += 5;
|
|
174
|
+
break;
|
|
175
|
+
case 'user':
|
|
176
|
+
score += 3;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
// Content-based scoring
|
|
180
|
+
const content = typeof message.content === 'string'
|
|
181
|
+
? message.content
|
|
182
|
+
: JSON.stringify(message.content);
|
|
183
|
+
// Longer messages might be more important
|
|
184
|
+
score += Math.min(content.length / 100, 5);
|
|
185
|
+
// Messages with tool calls are important
|
|
186
|
+
if (message.tool_calls && message.tool_calls.length > 0) {
|
|
187
|
+
score += 7;
|
|
188
|
+
}
|
|
189
|
+
// Messages with specific keywords are important
|
|
190
|
+
const importantKeywords = [
|
|
191
|
+
'error', 'warning', 'critical', 'important', 'required',
|
|
192
|
+
'configuration', 'setup', 'install', 'deploy', 'build'
|
|
193
|
+
];
|
|
194
|
+
const lowerContent = content.toLowerCase();
|
|
195
|
+
importantKeywords.forEach(keyword => {
|
|
196
|
+
if (lowerContent.includes(keyword)) {
|
|
197
|
+
score += 2;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return score;
|
|
201
|
+
}
|
|
202
|
+
async performSummarization(messages) {
|
|
203
|
+
try {
|
|
204
|
+
// Preserve system messages and recent messages
|
|
205
|
+
const systemMessages = this.preserveSystemMessages
|
|
206
|
+
? messages.filter(m => m.role === 'system')
|
|
207
|
+
: [];
|
|
208
|
+
const recentMessages = messages.slice(-this.preserveRecentMessages);
|
|
209
|
+
const messagesToSummarize = messages.slice(0, -this.preserveRecentMessages)
|
|
210
|
+
.filter(m => !this.preserveSystemMessages || m.role !== 'system');
|
|
211
|
+
if (messagesToSummarize.length === 0) {
|
|
212
|
+
return [...systemMessages, ...recentMessages];
|
|
213
|
+
}
|
|
214
|
+
// Convert to format expected by chatSummary
|
|
215
|
+
const formattedMessages = messagesToSummarize.map(msg => ({
|
|
216
|
+
role: msg.role,
|
|
217
|
+
content: typeof msg.content === 'string' ? msg.content :
|
|
218
|
+
Array.isArray(msg.content) ? msg.content.map(c => c.text).join(' ') :
|
|
219
|
+
JSON.stringify(msg.content)
|
|
220
|
+
}));
|
|
221
|
+
// Use chat summary service
|
|
222
|
+
const targetLength = Math.floor(this.maxConversationLength * this.compressionRatio);
|
|
223
|
+
const summaryResponse = await chatSummary.summarize(formattedMessages, targetLength);
|
|
224
|
+
if (summaryResponse && (summaryResponse.payload || summaryResponse.summary)) {
|
|
225
|
+
const summaryText = summaryResponse.payload || summaryResponse.summary;
|
|
226
|
+
const summaryMessage = {
|
|
227
|
+
role: 'system',
|
|
228
|
+
content: `Previous conversation summary: ${summaryText}`,
|
|
229
|
+
name: 'conversation-summary'
|
|
230
|
+
};
|
|
231
|
+
return [
|
|
232
|
+
...systemMessages,
|
|
233
|
+
summaryMessage,
|
|
234
|
+
...recentMessages
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
// If summarization fails, fall back to truncation
|
|
238
|
+
return this.performTruncation(messages);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
console.warn('Summarization failed:', error);
|
|
242
|
+
return this.performTruncation(messages);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
performTruncation(messages) {
|
|
246
|
+
// Simple truncation: keep system messages + recent messages
|
|
247
|
+
const systemMessages = this.preserveSystemMessages
|
|
248
|
+
? messages.filter(m => m.role === 'system')
|
|
249
|
+
: [];
|
|
250
|
+
const nonSystemMessages = messages.filter(m => !this.preserveSystemMessages || m.role !== 'system');
|
|
251
|
+
const availableSlots = this.maxConversationLength - systemMessages.length;
|
|
252
|
+
const recentMessages = nonSystemMessages.slice(-Math.max(availableSlots, this.preserveRecentMessages));
|
|
253
|
+
return [...systemMessages, ...recentMessages];
|
|
254
|
+
}
|
|
255
|
+
calculateCompactionInfo(original, compacted) {
|
|
256
|
+
var _a;
|
|
257
|
+
const originalCount = original.messages.length;
|
|
258
|
+
const compactedCount = compacted.messages.length;
|
|
259
|
+
return {
|
|
260
|
+
originalMessageCount: originalCount,
|
|
261
|
+
compactedMessageCount: compactedCount,
|
|
262
|
+
compressionRatio: compactedCount / originalCount,
|
|
263
|
+
compactionMethod: ((_a = compacted.metadata) === null || _a === void 0 ? void 0 : _a.compactionMethod) || 'truncation',
|
|
264
|
+
preservedMessages: compactedCount,
|
|
265
|
+
removedMessages: originalCount - compactedCount
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
// Public methods for configuration
|
|
269
|
+
setMaxConversationLength(length) {
|
|
270
|
+
this.maxConversationLength = Math.max(10, length);
|
|
271
|
+
}
|
|
272
|
+
setCompressionRatio(ratio) {
|
|
273
|
+
this.compressionRatio = Math.max(0.1, Math.min(0.9, ratio));
|
|
274
|
+
}
|
|
275
|
+
setPreserveRecentMessages(count) {
|
|
276
|
+
this.preserveRecentMessages = Math.max(1, count);
|
|
277
|
+
}
|
|
278
|
+
enableSummarizationForSession() {
|
|
279
|
+
this.enableSummarization = true;
|
|
280
|
+
}
|
|
281
|
+
disableSummarizationForSession() {
|
|
282
|
+
this.enableSummarization = false;
|
|
283
|
+
}
|
|
284
|
+
enableSmartRemovalForSession() {
|
|
285
|
+
this.enableSmartRemoval = true;
|
|
286
|
+
}
|
|
287
|
+
disableSmartRemovalForSession() {
|
|
288
|
+
this.enableSmartRemoval = false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
exports.ConversationCompactorProcessor = ConversationCompactorProcessor;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseProcessor, ProcessorInput, ProcessorOutput } from '../../processor';
|
|
2
|
+
export interface ConversationContinuityInfo {
|
|
3
|
+
contextLinksAdded: number;
|
|
4
|
+
referenceResolutionsAdded: number;
|
|
5
|
+
continuityEnhanced: boolean;
|
|
6
|
+
missingContextDetected: boolean;
|
|
7
|
+
conversationGapsFound: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ConversationContinuityProcessorOptions {
|
|
10
|
+
enableContextLinking?: boolean;
|
|
11
|
+
enableReferenceResolution?: boolean;
|
|
12
|
+
enableGapDetection?: boolean;
|
|
13
|
+
maxContextLinks?: number;
|
|
14
|
+
contextLookbackWindow?: number;
|
|
15
|
+
enableProactiveContext?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Processor that maintains conversation continuity by linking related messages,
|
|
19
|
+
* resolving references, and detecting context gaps in follow-up conversations.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConversationContinuityProcessor extends BaseProcessor {
|
|
22
|
+
private readonly enableContextLinking;
|
|
23
|
+
private readonly enableReferenceResolution;
|
|
24
|
+
private readonly enableGapDetection;
|
|
25
|
+
private readonly maxContextLinks;
|
|
26
|
+
private readonly contextLookbackWindow;
|
|
27
|
+
private readonly enableProactiveContext;
|
|
28
|
+
constructor(options?: ConversationContinuityProcessorOptions);
|
|
29
|
+
processInput(input: ProcessorInput): Promise<ProcessorOutput[]>;
|
|
30
|
+
private enhanceConversationContinuity;
|
|
31
|
+
private addContextLinks;
|
|
32
|
+
private findReferencingMessages;
|
|
33
|
+
private generateContextLinkMessage;
|
|
34
|
+
private resolveReferences;
|
|
35
|
+
private resolveMessageReferences;
|
|
36
|
+
private detectAndFillGaps;
|
|
37
|
+
private detectConversationGaps;
|
|
38
|
+
private generateGapFillerMessage;
|
|
39
|
+
private addProactiveContext;
|
|
40
|
+
private calculateContinuityInfo;
|
|
41
|
+
setContextLookbackWindow(window: number): void;
|
|
42
|
+
setMaxContextLinks(max: number): void;
|
|
43
|
+
enableContextLinkingForSession(): void;
|
|
44
|
+
disableContextLinkingForSession(): void;
|
|
45
|
+
enableReferenceResolutionForSession(): void;
|
|
46
|
+
disableReferenceResolutionForSession(): void;
|
|
47
|
+
enableGapDetectionForSession(): void;
|
|
48
|
+
disableGapDetectionForSession(): void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationContinuityProcessor = void 0;
|
|
4
|
+
const processor_1 = require("../../processor");
|
|
5
|
+
/**
|
|
6
|
+
* Processor that maintains conversation continuity by linking related messages,
|
|
7
|
+
* resolving references, and detecting context gaps in follow-up conversations.
|
|
8
|
+
*/
|
|
9
|
+
class ConversationContinuityProcessor extends processor_1.BaseProcessor {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.enableContextLinking = options.enableContextLinking !== false;
|
|
13
|
+
this.enableReferenceResolution = options.enableReferenceResolution !== false;
|
|
14
|
+
this.enableGapDetection = options.enableGapDetection !== false;
|
|
15
|
+
this.maxContextLinks = options.maxContextLinks || 5;
|
|
16
|
+
this.contextLookbackWindow = options.contextLookbackWindow || 20;
|
|
17
|
+
this.enableProactiveContext = options.enableProactiveContext !== false;
|
|
18
|
+
}
|
|
19
|
+
async processInput(input) {
|
|
20
|
+
try {
|
|
21
|
+
const { message, context } = input;
|
|
22
|
+
// Only process follow-up conversations
|
|
23
|
+
if (!(context === null || context === void 0 ? void 0 : context.followUpProcessing)) {
|
|
24
|
+
return [this.createEvent('ContinuityProcessingSkipped', {
|
|
25
|
+
reason: 'Not a follow-up conversation processing context'
|
|
26
|
+
})];
|
|
27
|
+
}
|
|
28
|
+
const enhancedMessage = await this.enhanceConversationContinuity(message, context);
|
|
29
|
+
const continuityInfo = this.calculateContinuityInfo(message, enhancedMessage, context);
|
|
30
|
+
return [
|
|
31
|
+
this.createEvent('ConversationContinuityProcessed', continuityInfo),
|
|
32
|
+
this.createEvent('ConversationProcessed', enhancedMessage)
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Error in ConversationContinuityProcessor:', error);
|
|
37
|
+
return [this.createEvent('ConversationContinuityError', {
|
|
38
|
+
error: error instanceof Error ? error.message : String(error),
|
|
39
|
+
originalLength: input.message.messages.length
|
|
40
|
+
})];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async enhanceConversationContinuity(message, context) {
|
|
44
|
+
let enhancedMessages = [...message.messages];
|
|
45
|
+
let enhancementsAdded = 0;
|
|
46
|
+
// Add context links if enabled
|
|
47
|
+
if (this.enableContextLinking) {
|
|
48
|
+
const contextLinks = this.addContextLinks(enhancedMessages, context);
|
|
49
|
+
enhancedMessages.push(...contextLinks);
|
|
50
|
+
enhancementsAdded += contextLinks.length;
|
|
51
|
+
}
|
|
52
|
+
// Resolve references if enabled
|
|
53
|
+
if (this.enableReferenceResolution) {
|
|
54
|
+
enhancedMessages = this.resolveReferences(enhancedMessages, context);
|
|
55
|
+
}
|
|
56
|
+
// Detect and fill conversation gaps if enabled
|
|
57
|
+
if (this.enableGapDetection) {
|
|
58
|
+
const gapFillers = this.detectAndFillGaps(enhancedMessages, context);
|
|
59
|
+
enhancedMessages.push(...gapFillers);
|
|
60
|
+
enhancementsAdded += gapFillers.length;
|
|
61
|
+
}
|
|
62
|
+
// Add proactive context if enabled
|
|
63
|
+
if (this.enableProactiveContext) {
|
|
64
|
+
const proactiveContext = this.addProactiveContext(enhancedMessages, context);
|
|
65
|
+
enhancedMessages.push(...proactiveContext);
|
|
66
|
+
enhancementsAdded += proactiveContext.length;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...message,
|
|
70
|
+
messages: enhancedMessages,
|
|
71
|
+
metadata: {
|
|
72
|
+
...message.metadata,
|
|
73
|
+
continuityEnhanced: true,
|
|
74
|
+
enhancementsAdded,
|
|
75
|
+
timestamp: new Date().toISOString()
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
addContextLinks(messages, context) {
|
|
80
|
+
const contextLinks = [];
|
|
81
|
+
const recentMessages = messages.slice(-this.contextLookbackWindow);
|
|
82
|
+
// Find messages that reference previous interactions
|
|
83
|
+
const referencingMessages = this.findReferencingMessages(recentMessages);
|
|
84
|
+
if (referencingMessages.length > 0) {
|
|
85
|
+
const linkMessage = {
|
|
86
|
+
role: 'system',
|
|
87
|
+
content: this.generateContextLinkMessage(referencingMessages, context),
|
|
88
|
+
name: 'context-link'
|
|
89
|
+
};
|
|
90
|
+
contextLinks.push(linkMessage);
|
|
91
|
+
}
|
|
92
|
+
return contextLinks.slice(0, this.maxContextLinks);
|
|
93
|
+
}
|
|
94
|
+
findReferencingMessages(messages) {
|
|
95
|
+
const referencePatterns = [
|
|
96
|
+
/\b(this|that|it|they|them)\b/i,
|
|
97
|
+
/\b(the (above|previous|last|earlier))\b/i,
|
|
98
|
+
/\b(as (mentioned|discussed|shown))\b/i,
|
|
99
|
+
/\b(from (before|earlier))\b/i,
|
|
100
|
+
/\b(the (file|code|result|output))\b/i
|
|
101
|
+
];
|
|
102
|
+
return messages.filter(message => {
|
|
103
|
+
const content = typeof message.content === 'string'
|
|
104
|
+
? message.content
|
|
105
|
+
: JSON.stringify(message.content);
|
|
106
|
+
return referencePatterns.some(pattern => pattern.test(content));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
generateContextLinkMessage(referencingMessages, context) {
|
|
110
|
+
const messageCount = referencingMessages.length;
|
|
111
|
+
const toolResults = context.toolResults || [];
|
|
112
|
+
let linkMessage = `**Context Links:** Found ${messageCount} message${messageCount > 1 ? 's' : ''} with references to previous interactions.`;
|
|
113
|
+
if (toolResults.length > 0) {
|
|
114
|
+
linkMessage += ` Recent tool executions: ${toolResults.length} tool${toolResults.length > 1 ? 's' : ''} executed.`;
|
|
115
|
+
}
|
|
116
|
+
if (context.originalHistory && context.originalHistory.length > 0) {
|
|
117
|
+
linkMessage += ` Conversation history: ${context.originalHistory.length} previous messages available for reference.`;
|
|
118
|
+
}
|
|
119
|
+
return linkMessage;
|
|
120
|
+
}
|
|
121
|
+
resolveReferences(messages, context) {
|
|
122
|
+
return messages.map(message => {
|
|
123
|
+
if (message.role === 'system' || message.name === 'reference-resolution') {
|
|
124
|
+
return message;
|
|
125
|
+
}
|
|
126
|
+
const resolvedContent = this.resolveMessageReferences(message.content, context);
|
|
127
|
+
if (resolvedContent !== message.content) {
|
|
128
|
+
return {
|
|
129
|
+
...message,
|
|
130
|
+
content: resolvedContent,
|
|
131
|
+
name: message.name || 'reference-resolved'
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return message;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
resolveMessageReferences(content, context) {
|
|
138
|
+
if (typeof content !== 'string') {
|
|
139
|
+
return content;
|
|
140
|
+
}
|
|
141
|
+
let resolvedContent = content;
|
|
142
|
+
const toolResults = context.toolResults || [];
|
|
143
|
+
// Resolve "the file" references
|
|
144
|
+
if (/\bthe file\b/i.test(resolvedContent) && toolResults.length > 0) {
|
|
145
|
+
const fileOperations = toolResults.filter((result) => result.tool_call_id && result.tool_call_id.includes('file'));
|
|
146
|
+
if (fileOperations.length === 1) {
|
|
147
|
+
resolvedContent = resolvedContent.replace(/\bthe file\b/gi, `the file (from recent tool execution)`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Resolve "the result" references
|
|
151
|
+
if (/\bthe result\b/i.test(resolvedContent) && toolResults.length > 0) {
|
|
152
|
+
resolvedContent = resolvedContent.replace(/\bthe result\b/gi, `the result (from ${toolResults.length} recent tool execution${toolResults.length > 1 ? 's' : ''})`);
|
|
153
|
+
}
|
|
154
|
+
// Resolve "it" references in context of tool operations
|
|
155
|
+
if (/\bit\b/i.test(resolvedContent) && toolResults.length === 1) {
|
|
156
|
+
const toolResult = toolResults[0];
|
|
157
|
+
if (toolResult.tool_call_id) {
|
|
158
|
+
resolvedContent = resolvedContent.replace(/\bit\b/gi, `it (referring to the tool execution result)`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return resolvedContent;
|
|
162
|
+
}
|
|
163
|
+
detectAndFillGaps(messages, context) {
|
|
164
|
+
const gapFillers = [];
|
|
165
|
+
const gaps = this.detectConversationGaps(messages, context);
|
|
166
|
+
gaps.forEach(gap => {
|
|
167
|
+
const fillerMessage = {
|
|
168
|
+
role: 'system',
|
|
169
|
+
content: this.generateGapFillerMessage(gap, context),
|
|
170
|
+
name: 'gap-filler'
|
|
171
|
+
};
|
|
172
|
+
gapFillers.push(fillerMessage);
|
|
173
|
+
});
|
|
174
|
+
return gapFillers;
|
|
175
|
+
}
|
|
176
|
+
detectConversationGaps(messages, context) {
|
|
177
|
+
const gaps = [];
|
|
178
|
+
const toolResults = context.toolResults || [];
|
|
179
|
+
// Gap: Tool results without explanation
|
|
180
|
+
const unexplainedToolResults = toolResults.filter((result) => {
|
|
181
|
+
const hasExplanation = messages.some(msg => msg.role === 'assistant' &&
|
|
182
|
+
typeof msg.content === 'string' &&
|
|
183
|
+
msg.content.includes('result'));
|
|
184
|
+
return !hasExplanation;
|
|
185
|
+
});
|
|
186
|
+
if (unexplainedToolResults.length > 0) {
|
|
187
|
+
gaps.push({
|
|
188
|
+
type: 'unexplained-tool-results',
|
|
189
|
+
description: `${unexplainedToolResults.length} tool result(s) without explanation`,
|
|
190
|
+
severity: 'medium'
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// Gap: Missing context for references
|
|
194
|
+
const unresolvedReferences = messages.filter(msg => {
|
|
195
|
+
const content = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content);
|
|
196
|
+
return /\b(this|that|it)\b/i.test(content) && msg.role === 'user';
|
|
197
|
+
});
|
|
198
|
+
if (unresolvedReferences.length > 2) {
|
|
199
|
+
gaps.push({
|
|
200
|
+
type: 'unresolved-references',
|
|
201
|
+
description: `${unresolvedReferences.length} messages with unclear references`,
|
|
202
|
+
severity: 'low'
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
// Gap: Long silence after tool execution
|
|
206
|
+
const lastToolIndex = messages.findLastIndex(msg => msg.role === 'tool');
|
|
207
|
+
const lastAssistantIndex = messages.findLastIndex(msg => msg.role === 'assistant');
|
|
208
|
+
if (lastToolIndex > lastAssistantIndex && lastToolIndex < messages.length - 1) {
|
|
209
|
+
gaps.push({
|
|
210
|
+
type: 'missing-tool-response',
|
|
211
|
+
description: 'Tool execution without assistant response',
|
|
212
|
+
severity: 'high'
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return gaps;
|
|
216
|
+
}
|
|
217
|
+
generateGapFillerMessage(gap, context) {
|
|
218
|
+
switch (gap.type) {
|
|
219
|
+
case 'unexplained-tool-results':
|
|
220
|
+
return `**Context Note:** There are tool execution results that may need explanation or analysis. Consider reviewing the tool outputs and their implications.`;
|
|
221
|
+
case 'unresolved-references':
|
|
222
|
+
return `**Context Note:** Some messages contain references that might be unclear. Consider providing more specific context when referring to previous interactions.`;
|
|
223
|
+
case 'missing-tool-response':
|
|
224
|
+
return `**Context Note:** Recent tool execution completed but may need assistant analysis or response to continue the conversation effectively.`;
|
|
225
|
+
default:
|
|
226
|
+
return `**Context Note:** Potential conversation gap detected: ${gap.description}`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
addProactiveContext(messages, context) {
|
|
230
|
+
const proactiveMessages = [];
|
|
231
|
+
const toolResults = context.toolResults || [];
|
|
232
|
+
const conversationLength = messages.length;
|
|
233
|
+
// Add proactive context for complex tool interactions
|
|
234
|
+
if (toolResults.length > 3) {
|
|
235
|
+
proactiveMessages.push({
|
|
236
|
+
role: 'system',
|
|
237
|
+
content: `**Proactive Context:** Multiple tools have been executed (${toolResults.length} total). This suggests a complex task that may benefit from step-by-step progress tracking.`,
|
|
238
|
+
name: 'proactive-context'
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// Add proactive context for long conversations
|
|
242
|
+
if (conversationLength > 25) {
|
|
243
|
+
proactiveMessages.push({
|
|
244
|
+
role: 'system',
|
|
245
|
+
content: `**Proactive Context:** This is an extended conversation (${conversationLength} messages). Consider summarizing progress or breaking down remaining objectives.`,
|
|
246
|
+
name: 'proactive-context'
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return proactiveMessages.slice(0, 2); // Limit proactive messages
|
|
250
|
+
}
|
|
251
|
+
calculateContinuityInfo(original, enhanced, context) {
|
|
252
|
+
const originalCount = original.messages.length;
|
|
253
|
+
const enhancedCount = enhanced.messages.length;
|
|
254
|
+
const addedMessages = enhancedCount - originalCount;
|
|
255
|
+
// Count different types of enhancements
|
|
256
|
+
const contextLinks = enhanced.messages.filter(m => m.name === 'context-link').length;
|
|
257
|
+
const referenceResolutions = enhanced.messages.filter(m => m.name === 'reference-resolved').length;
|
|
258
|
+
const gapFillers = enhanced.messages.filter(m => m.name === 'gap-filler').length;
|
|
259
|
+
return {
|
|
260
|
+
contextLinksAdded: contextLinks,
|
|
261
|
+
referenceResolutionsAdded: referenceResolutions,
|
|
262
|
+
continuityEnhanced: addedMessages > 0,
|
|
263
|
+
missingContextDetected: gapFillers > 0,
|
|
264
|
+
conversationGapsFound: gapFillers
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
// Public methods for configuration
|
|
268
|
+
setContextLookbackWindow(window) {
|
|
269
|
+
this.contextLookbackWindow = Math.max(5, Math.min(50, window));
|
|
270
|
+
}
|
|
271
|
+
setMaxContextLinks(max) {
|
|
272
|
+
this.maxContextLinks = Math.max(1, Math.min(10, max));
|
|
273
|
+
}
|
|
274
|
+
enableContextLinkingForSession() {
|
|
275
|
+
this.enableContextLinking = true;
|
|
276
|
+
}
|
|
277
|
+
disableContextLinkingForSession() {
|
|
278
|
+
this.enableContextLinking = false;
|
|
279
|
+
}
|
|
280
|
+
enableReferenceResolutionForSession() {
|
|
281
|
+
this.enableReferenceResolution = true;
|
|
282
|
+
}
|
|
283
|
+
disableReferenceResolutionForSession() {
|
|
284
|
+
this.enableReferenceResolution = false;
|
|
285
|
+
}
|
|
286
|
+
enableGapDetectionForSession() {
|
|
287
|
+
this.enableGapDetection = true;
|
|
288
|
+
}
|
|
289
|
+
disableGapDetectionForSession() {
|
|
290
|
+
this.enableGapDetection = false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.ConversationContinuityProcessor = ConversationContinuityProcessor;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseProcessor, ProcessorInput, ProcessorOutput } from '../../processor';
|
|
2
|
+
export interface FollowUpConversationInfo {
|
|
3
|
+
toolResultsProcessed: number;
|
|
4
|
+
followUpMessagesAdded: number;
|
|
5
|
+
conversationEnhanced: boolean;
|
|
6
|
+
processingMethod: 'automatic' | 'guided' | 'minimal';
|
|
7
|
+
}
|
|
8
|
+
export interface FollowUpConversationProcessorOptions {
|
|
9
|
+
addFollowUpPrompts?: boolean;
|
|
10
|
+
enhanceToolResults?: boolean;
|
|
11
|
+
addContextualHints?: boolean;
|
|
12
|
+
processingMode?: 'automatic' | 'guided' | 'minimal';
|
|
13
|
+
maxFollowUpMessages?: number;
|
|
14
|
+
enableToolResultEnhancement?: boolean;
|
|
15
|
+
enableConversationGuidance?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Processor that enhances follow-up conversations by adding contextual information,
|
|
19
|
+
* improving tool result presentation, and providing guidance for continued interaction.
|
|
20
|
+
*/
|
|
21
|
+
export declare class FollowUpConversationProcessor extends BaseProcessor {
|
|
22
|
+
private readonly addFollowUpPrompts;
|
|
23
|
+
private readonly enhanceToolResults;
|
|
24
|
+
private readonly addContextualHints;
|
|
25
|
+
private readonly processingMode;
|
|
26
|
+
private readonly maxFollowUpMessages;
|
|
27
|
+
private readonly enableToolResultEnhancement;
|
|
28
|
+
private readonly enableConversationGuidance;
|
|
29
|
+
constructor(options?: FollowUpConversationProcessorOptions);
|
|
30
|
+
processInput(input: ProcessorInput): Promise<ProcessorOutput[]>;
|
|
31
|
+
private enhanceFollowUpConversation;
|
|
32
|
+
private enhanceToolResultMessages;
|
|
33
|
+
private enhanceToolResultContent;
|
|
34
|
+
private generateFollowUpPrompts;
|
|
35
|
+
private generateGuidedPrompts;
|
|
36
|
+
private generateAutomaticPrompts;
|
|
37
|
+
private generateContextualHints;
|
|
38
|
+
private calculateProcessingInfo;
|
|
39
|
+
setProcessingMode(mode: 'automatic' | 'guided' | 'minimal'): void;
|
|
40
|
+
setMaxFollowUpMessages(count: number): void;
|
|
41
|
+
enableFollowUpPromptsForSession(): void;
|
|
42
|
+
disableFollowUpPromptsForSession(): void;
|
|
43
|
+
enableToolResultEnhancementForSession(): void;
|
|
44
|
+
disableToolResultEnhancementForSession(): void;
|
|
45
|
+
enableConversationGuidanceForSession(): void;
|
|
46
|
+
disableConversationGuidanceForSession(): void;
|
|
47
|
+
}
|