@codebolt/agent 1.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -66
- package/dist/{agent.js → builderpattern/agent.js} +2 -2
- package/dist/{followupquestionbuilder.d.ts → builderpattern/followupquestionbuilder.d.ts} +1 -1
- package/dist/{followupquestionbuilder.js → builderpattern/followupquestionbuilder.js} +1 -1
- package/dist/{index.d.ts → builderpattern/index.d.ts} +3 -3
- package/dist/{llmoutputhandler.d.ts → builderpattern/llmoutputhandler.d.ts} +1 -1
- package/dist/{llmoutputhandler.js → builderpattern/llmoutputhandler.js} +7 -7
- package/dist/{promptbuilder.d.ts → builderpattern/promptbuilder.d.ts} +3 -3
- package/dist/{taskInstruction.d.ts → builderpattern/taskInstruction.d.ts} +2 -2
- package/dist/{usermessage.d.ts → builderpattern/usermessage.d.ts} +9 -4
- package/dist/composablepattern/agent.d.ts +169 -0
- package/dist/composablepattern/agent.js +598 -0
- package/dist/composablepattern/codebolt-storage.d.ts +67 -0
- package/dist/composablepattern/codebolt-storage.js +320 -0
- package/dist/composablepattern/document.d.ts +149 -0
- package/dist/composablepattern/document.js +372 -0
- package/dist/composablepattern/examples/codebolt-integration-example.d.ts +12 -0
- package/dist/composablepattern/examples/codebolt-integration-example.js +218 -0
- package/dist/composablepattern/examples/codebolt-storage-example.d.ts +40 -0
- package/dist/composablepattern/examples/codebolt-storage-example.js +223 -0
- package/dist/composablepattern/examples/custom-steps-example.d.ts +20 -0
- package/dist/composablepattern/examples/custom-steps-example.js +455 -0
- package/dist/composablepattern/examples/document-agent.d.ts +17 -0
- package/dist/composablepattern/examples/document-agent.js +107 -0
- package/dist/composablepattern/examples/simple-codebolt-integration.d.ts +8 -0
- package/dist/composablepattern/examples/simple-codebolt-integration.js +164 -0
- package/dist/composablepattern/examples/weather-agent.d.ts +18 -0
- package/dist/composablepattern/examples/weather-agent.js +86 -0
- package/dist/composablepattern/examples/workflow-example.d.ts +12 -0
- package/dist/composablepattern/examples/workflow-example.js +463 -0
- package/dist/composablepattern/index.d.ts +63 -0
- package/dist/composablepattern/index.js +115 -0
- package/dist/composablepattern/memory.d.ts +89 -0
- package/dist/composablepattern/memory.js +141 -0
- package/dist/composablepattern/tool.d.ts +84 -0
- package/dist/composablepattern/tool.js +260 -0
- package/dist/composablepattern/types.d.ts +194 -0
- package/dist/composablepattern/types.js +6 -0
- package/dist/composablepattern/user-context.d.ts +214 -0
- package/dist/composablepattern/user-context.js +275 -0
- package/dist/composablepattern/workflow.d.ts +388 -0
- package/dist/composablepattern/workflow.js +562 -0
- package/dist/local-tools/fileTools.d.ts +26 -0
- package/dist/local-tools/fileTools.js +162 -0
- package/dist/processor/agent/agentStep.d.ts +49 -0
- package/dist/processor/agent/agentStep.js +241 -0
- package/dist/processor/agent/toolExecutor.d.ts +19 -0
- package/dist/processor/agent/toolExecutor.js +90 -0
- package/dist/processor/index.d.ts +7 -0
- package/dist/processor/index.js +36 -0
- package/dist/processor/messageModifiers/baseMessageModifier.d.ts +20 -0
- package/dist/processor/messageModifiers/baseMessageModifier.js +55 -0
- package/dist/processor/processors/baseProcessor.d.ts +14 -0
- package/dist/processor/processors/baseProcessor.js +29 -0
- package/dist/processor/tools/baseTool.d.ts +10 -0
- package/dist/processor/tools/baseTool.js +20 -0
- package/dist/processor/tools/toolList.d.ts +9 -0
- package/dist/processor/tools/toolList.js +22 -0
- package/dist/processor/types/interfaces.d.ts +117 -0
- package/dist/processor/types/interfaces.js +2 -0
- 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/base/baseMessageModifier.d.ts +12 -0
- package/dist/processor-pieces/base/baseMessageModifier.js +15 -0
- package/dist/processor-pieces/base/basePostInferenceProcessor.d.ts +13 -0
- package/dist/processor-pieces/base/basePostInferenceProcessor.js +18 -0
- package/dist/processor-pieces/base/basePostToolCallProcessor.d.ts +15 -0
- package/dist/processor-pieces/base/basePostToolCallProcessor.js +25 -0
- package/dist/processor-pieces/base/basePreInferenceProcessor.d.ts +12 -0
- package/dist/processor-pieces/base/basePreInferenceProcessor.js +17 -0
- package/dist/processor-pieces/base/basePreToolCallProcessor.d.ts +18 -0
- package/dist/processor-pieces/base/basePreToolCallProcessor.js +66 -0
- package/dist/processor-pieces/base/index.d.ts +9 -0
- package/dist/processor-pieces/base/index.js +18 -0
- package/dist/processor-pieces/index.d.ts +1 -0
- package/dist/processor-pieces/index.js +59 -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 +31 -0
- package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +145 -0
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.d.ts +9 -0
- package/dist/processor-pieces/messageModifiers/advancedSystemInstructionMessageModifier.js +77 -0
- package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.d.ts +13 -0
- package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.js +68 -0
- package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.d.ts +25 -0
- package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.js +453 -0
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +7 -0
- package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +67 -0
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +9 -0
- package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +90 -0
- 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.d.ts +18 -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/chatHistoryMessageModifier.js +104 -0
- package/dist/processor-pieces/messageModifiers/chatRecordingModifier.d.ts +23 -0
- package/dist/processor-pieces/messageModifiers/chatRecordingModifier.js +173 -0
- package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.d.ts +14 -0
- package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.js +130 -0
- package/dist/processor-pieces/messageModifiers/directoryContextModifier.d.ts +36 -0
- package/dist/processor-pieces/messageModifiers/directoryContextModifier.js +418 -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/environmentContextModifier.d.ts +26 -0
- package/dist/processor-pieces/messageModifiers/environmentContextModifier.js +260 -0
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +13 -0
- package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +59 -0
- package/dist/processor-pieces/messageModifiers/ideContextModifier.d.ts +34 -0
- package/dist/processor-pieces/messageModifiers/ideContextModifier.js +157 -0
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +19 -0
- package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +221 -0
- package/dist/processor-pieces/messageModifiers/index.d.ts +11 -0
- package/dist/processor-pieces/messageModifiers/index.js +26 -0
- package/dist/processor-pieces/messageModifiers/memoryImportModifier.d.ts +15 -0
- package/dist/processor-pieces/messageModifiers/memoryImportModifier.js +129 -0
- 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/toolInjectionModifier.d.ts +20 -0
- package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +152 -0
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +38 -0
- package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +392 -0
- 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/postInferenceProcessors/loopDetectionModifier.d.ts +29 -0
- package/dist/processor-pieces/postInferenceProcessors/loopDetectionModifier.js +174 -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/postToolCallProcessors/index.d.ts +1 -0
- package/dist/processor-pieces/postToolCallProcessors/index.js +2 -0
- package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.d.ts +25 -0
- package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.js +225 -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/chatCompressionModifier.d.ts +35 -0
- package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.js +255 -0
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.d.ts +7 -0
- package/dist/processor-pieces/preInferenceProcessors/conversationCompaction.js +31 -0
- package/dist/processor-pieces/preInferenceProcessors/index.d.ts +1 -0
- package/dist/processor-pieces/preInferenceProcessors/index.js +2 -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/processor-pieces/pretoolCallProcessors/index.d.ts +1 -0
- package/dist/processor-pieces/pretoolCallProcessors/index.js +2 -0
- package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.d.ts +41 -0
- package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.js +197 -0
- package/dist/processor-pieces/processors/chatCompressionProcessor.d.ts +26 -0
- package/dist/processor-pieces/processors/chatCompressionProcessor.js +90 -0
- package/dist/processor-pieces/processors/chatRecordingProcessor.d.ts +81 -0
- package/dist/processor-pieces/processors/chatRecordingProcessor.js +329 -0
- package/dist/processor-pieces/processors/contextManagementProcessor.d.ts +40 -0
- package/dist/processor-pieces/processors/contextManagementProcessor.js +305 -0
- package/dist/processor-pieces/processors/loopDetectionProcessor.d.ts +30 -0
- package/dist/processor-pieces/processors/loopDetectionProcessor.js +137 -0
- package/dist/processor-pieces/processors/responseValidationProcessor.d.ts +30 -0
- package/dist/processor-pieces/processors/responseValidationProcessor.js +228 -0
- package/dist/processor-pieces/processors/telemetryProcessor.d.ts +99 -0
- package/dist/processor-pieces/processors/telemetryProcessor.js +311 -0
- package/dist/processor-pieces/processors/tokenManagementProcessor.d.ts +37 -0
- package/dist/processor-pieces/processors/tokenManagementProcessor.js +178 -0
- package/dist/processor-pieces/processors/toolExecutionProcessor.d.ts +43 -0
- package/dist/processor-pieces/processors/toolExecutionProcessor.js +207 -0
- package/dist/processor-pieces/tools/fileTools.d.ts +26 -0
- package/dist/processor-pieces/tools/fileTools.js +162 -0
- package/dist/processor-pieces/utils/messageModifierHelper.d.ts +4 -0
- package/dist/processor-pieces/utils/messageModifierHelper.js +58 -0
- package/dist/types/commonTypes.d.ts +4 -0
- package/dist/types/processorTypes.d.ts +67 -0
- package/dist/types/processorTypes.js +58 -0
- package/dist/unified/agent/agent.d.ts +17 -0
- package/dist/unified/agent/agent.js +79 -0
- package/dist/unified/agent/team.d.ts +2 -0
- package/dist/unified/agent/team.js +6 -0
- package/dist/unified/agent/tool.d.ts +99 -0
- package/dist/unified/agent/tool.js +440 -0
- package/dist/unified/agent/tools.d.ts +44 -0
- package/dist/unified/agent/tools.js +487 -0
- package/dist/unified/agent/workflow.d.ts +24 -0
- package/dist/unified/agent/workflow.js +275 -0
- package/dist/unified/agent/workflowControls.d.ts +11 -0
- package/dist/unified/agent/workflowControls.js +20 -0
- package/dist/unified/agent/workflowSteps.d.ts +63 -0
- package/dist/unified/agent/workflowSteps.js +284 -0
- package/dist/unified/base/agentStep.d.ts +32 -0
- package/dist/unified/base/agentStep.js +96 -0
- package/dist/unified/base/create/createInitialPromptGenerators.d.ts +5 -0
- package/dist/unified/base/create/createInitialPromptGenerators.js +17 -0
- package/dist/unified/base/index.d.ts +5 -0
- package/dist/unified/base/index.js +13 -0
- package/dist/unified/base/initialPromptGenerator.d.ts +48 -0
- package/dist/unified/base/initialPromptGenerator.js +118 -0
- package/dist/unified/base/responseExecutor.d.ts +36 -0
- package/dist/unified/base/responseExecutor.js +283 -0
- 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/index.d.ts +18 -0
- package/dist/unified/index.js +42 -0
- package/dist/unified/orchestrator/orchestrator.d.ts +260 -0
- package/dist/unified/orchestrator/orchestrator.js +519 -0
- package/dist/unified/team/team.d.ts +1 -0
- package/dist/unified/team/team.js +2 -0
- package/dist/unified/types/libTypes.d.ts +378 -0
- package/dist/unified/types/libTypes.js +6 -0
- package/dist/unified/types/types.d.ts +212 -0
- package/dist/unified/types/types.js +43 -0
- package/dist/unified/utils/utils.d.ts +40 -0
- package/dist/unified/utils/utils.js +219 -0
- package/package.json +35 -13
- /package/dist/{agent.d.ts → builderpattern/agent.d.ts} +0 -0
- /package/dist/{index.js → builderpattern/index.js} +0 -0
- /package/dist/{promptbuilder.js → builderpattern/promptbuilder.js} +0 -0
- /package/dist/{systemprompt.d.ts → builderpattern/systemprompt.d.ts} +0 -0
- /package/dist/{systemprompt.js → builderpattern/systemprompt.js} +0 -0
- /package/dist/{taskInstruction.js → builderpattern/taskInstruction.js} +0 -0
- /package/dist/{usermessage.js → builderpattern/usermessage.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
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.ChatCompressionProcessor = void 0;
|
|
7
|
+
const processor_1 = require("../../processor");
|
|
8
|
+
const codeboltjs_1 = __importDefault(require("@codebolt/codeboltjs"));
|
|
9
|
+
class ChatCompressionProcessor extends processor_1.BaseProcessor {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.compressionThreshold = options.compressionThreshold || 0.7;
|
|
13
|
+
this.compressionPreserveThreshold = options.compressionPreserveThreshold || 0.3;
|
|
14
|
+
this.tokenLimit = options.tokenLimit || 128000;
|
|
15
|
+
this.enableCompression = options.enableCompression !== false;
|
|
16
|
+
}
|
|
17
|
+
async processInput(input) {
|
|
18
|
+
try {
|
|
19
|
+
const { message, context } = input;
|
|
20
|
+
if (!this.enableCompression) {
|
|
21
|
+
return [this.createEvent('ChatCompressionDisabled', {
|
|
22
|
+
reason: 'Compression is disabled for this session'
|
|
23
|
+
})];
|
|
24
|
+
}
|
|
25
|
+
// Get chat history from CodeBolt
|
|
26
|
+
const chatHistory = await codeboltjs_1.default.chat.getChatHistory();
|
|
27
|
+
if (chatHistory.length === 0) {
|
|
28
|
+
return [this.createEvent('NoChatHistory', {
|
|
29
|
+
reason: 'No chat history available for compression'
|
|
30
|
+
})];
|
|
31
|
+
}
|
|
32
|
+
// Estimate token count (simple heuristic: 4 chars per token)
|
|
33
|
+
const estimatedTokens = this.estimateTokenCount(chatHistory);
|
|
34
|
+
const threshold = this.compressionThreshold * this.tokenLimit;
|
|
35
|
+
console.log(`[Compression] Estimated tokens: ${estimatedTokens}, threshold: ${threshold}`);
|
|
36
|
+
if (estimatedTokens < threshold) {
|
|
37
|
+
return [this.createEvent('ChatCompressionSkipped', {
|
|
38
|
+
estimatedTokens,
|
|
39
|
+
threshold,
|
|
40
|
+
reason: 'Below compression threshold'
|
|
41
|
+
})];
|
|
42
|
+
}
|
|
43
|
+
// Perform compression using CodeBolt's chatSummary
|
|
44
|
+
const compressionResult = await codeboltjs_1.default.chatSummary.summarizeAll();
|
|
45
|
+
if (compressionResult.success && compressionResult.data) {
|
|
46
|
+
const newTokenCount = this.estimateTokenCount(compressionResult.data);
|
|
47
|
+
const compressionInfo = {
|
|
48
|
+
originalTokenCount: estimatedTokens,
|
|
49
|
+
newTokenCount,
|
|
50
|
+
compressionRatio: newTokenCount / estimatedTokens,
|
|
51
|
+
threshold: this.compressionThreshold
|
|
52
|
+
};
|
|
53
|
+
// Send notification about compression
|
|
54
|
+
await codeboltjs_1.default.chat.sendNotificationEvent(`Chat compressed: ${estimatedTokens} → ${newTokenCount} tokens`, 'debug');
|
|
55
|
+
return [this.createEvent('ChatCompressed', compressionInfo)];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return [this.createEvent('ChatCompressionFailed', {
|
|
59
|
+
error: compressionResult.message || 'Unknown compression error',
|
|
60
|
+
originalTokenCount: estimatedTokens
|
|
61
|
+
})];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error('Error in ChatCompressionProcessor:', error);
|
|
66
|
+
return [this.createEvent('ChatCompressionError', {
|
|
67
|
+
error: error instanceof Error ? error.message : String(error)
|
|
68
|
+
})];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
estimateTokenCount(data) {
|
|
72
|
+
// Simple heuristic: 4 characters per token
|
|
73
|
+
const totalContent = JSON.stringify(data);
|
|
74
|
+
return Math.ceil(totalContent.length / 4);
|
|
75
|
+
}
|
|
76
|
+
// Public methods for external control
|
|
77
|
+
setCompressionThreshold(threshold) {
|
|
78
|
+
this.compressionThreshold = Math.max(0.1, Math.min(0.9, threshold));
|
|
79
|
+
}
|
|
80
|
+
setTokenLimit(limit) {
|
|
81
|
+
this.tokenLimit = Math.max(1000, limit);
|
|
82
|
+
}
|
|
83
|
+
enableCompressionForSession() {
|
|
84
|
+
this.enableCompression = true;
|
|
85
|
+
}
|
|
86
|
+
disableCompressionForSession() {
|
|
87
|
+
this.enableCompression = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ChatCompressionProcessor = ChatCompressionProcessor;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BaseProcessor, ProcessorInput, ProcessorOutput } from '../../processor';
|
|
2
|
+
export interface ChatRecordingProcessorOptions {
|
|
3
|
+
enableTokenTracking?: boolean;
|
|
4
|
+
exportFormat?: 'json' | 'txt' | 'csv';
|
|
5
|
+
outputDirectory?: string;
|
|
6
|
+
maxFileSize?: number;
|
|
7
|
+
enableCompression?: boolean;
|
|
8
|
+
includeMetadata?: boolean;
|
|
9
|
+
autoExport?: boolean;
|
|
10
|
+
exportInterval?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TokensSummary {
|
|
13
|
+
input: number;
|
|
14
|
+
output: number;
|
|
15
|
+
cached: number;
|
|
16
|
+
thoughts?: number;
|
|
17
|
+
tool?: number;
|
|
18
|
+
total: number;
|
|
19
|
+
}
|
|
20
|
+
export interface MessageRecord {
|
|
21
|
+
id: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
role: string;
|
|
24
|
+
content: string;
|
|
25
|
+
metadata?: Record<string, any>;
|
|
26
|
+
tokens?: TokensSummary;
|
|
27
|
+
toolCalls?: ToolCallRecord[];
|
|
28
|
+
}
|
|
29
|
+
export interface ToolCallRecord {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
args: Record<string, unknown>;
|
|
33
|
+
result?: any;
|
|
34
|
+
status: 'pending' | 'success' | 'error' | 'cancelled';
|
|
35
|
+
timestamp: string;
|
|
36
|
+
executionTime?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ConversationSession {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
startTime: string;
|
|
41
|
+
endTime?: string;
|
|
42
|
+
messages: MessageRecord[];
|
|
43
|
+
totalTokens: TokensSummary;
|
|
44
|
+
toolCallCount: number;
|
|
45
|
+
metadata: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
export declare class ChatRecordingProcessor extends BaseProcessor {
|
|
48
|
+
private readonly enableTokenTracking;
|
|
49
|
+
private readonly exportFormat;
|
|
50
|
+
private readonly outputDirectory;
|
|
51
|
+
private readonly maxFileSize;
|
|
52
|
+
private readonly enableCompression;
|
|
53
|
+
private readonly includeMetadata;
|
|
54
|
+
private readonly autoExport;
|
|
55
|
+
private readonly exportInterval;
|
|
56
|
+
private currentSession;
|
|
57
|
+
private messageCount;
|
|
58
|
+
private sessions;
|
|
59
|
+
constructor(options?: ChatRecordingProcessorOptions);
|
|
60
|
+
processInput(input: ProcessorInput): Promise<ProcessorOutput[]>;
|
|
61
|
+
private initializeSession;
|
|
62
|
+
private createMessageRecord;
|
|
63
|
+
private extractContent;
|
|
64
|
+
private extractToolCalls;
|
|
65
|
+
private estimateTokens;
|
|
66
|
+
private updateSessionTotals;
|
|
67
|
+
private generateSessionId;
|
|
68
|
+
private generateMessageId;
|
|
69
|
+
private generateToolCallId;
|
|
70
|
+
exportSession(session: ConversationSession): Promise<string>;
|
|
71
|
+
private ensureDirectoryExists;
|
|
72
|
+
private formatAsText;
|
|
73
|
+
private formatAsCSV;
|
|
74
|
+
finalizeSession(): Promise<string | null>;
|
|
75
|
+
getCurrentSession(): ConversationSession | null;
|
|
76
|
+
getSessionStats(): {
|
|
77
|
+
currentSessionMessages: number;
|
|
78
|
+
totalSessions: number;
|
|
79
|
+
totalMessages: number;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ChatRecordingProcessor = void 0;
|
|
37
|
+
const processor_1 = require("../../processor");
|
|
38
|
+
const fs = __importStar(require("fs/promises"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
class ChatRecordingProcessor extends processor_1.BaseProcessor {
|
|
41
|
+
constructor(options = {}) {
|
|
42
|
+
super();
|
|
43
|
+
// Session tracking
|
|
44
|
+
this.currentSession = null;
|
|
45
|
+
this.messageCount = 0;
|
|
46
|
+
this.sessions = [];
|
|
47
|
+
this.enableTokenTracking = options.enableTokenTracking !== false;
|
|
48
|
+
this.exportFormat = options.exportFormat || 'json';
|
|
49
|
+
this.outputDirectory = options.outputDirectory || './chat-recordings';
|
|
50
|
+
this.maxFileSize = options.maxFileSize || 10 * 1024 * 1024; // 10MB
|
|
51
|
+
this.enableCompression = options.enableCompression || false;
|
|
52
|
+
this.includeMetadata = options.includeMetadata !== false;
|
|
53
|
+
this.autoExport = options.autoExport || false;
|
|
54
|
+
this.exportInterval = options.exportInterval || 50;
|
|
55
|
+
}
|
|
56
|
+
async processInput(input) {
|
|
57
|
+
const { message, context } = input;
|
|
58
|
+
try {
|
|
59
|
+
// Initialize session if not exists
|
|
60
|
+
if (!this.currentSession) {
|
|
61
|
+
this.initializeSession(context);
|
|
62
|
+
}
|
|
63
|
+
// Record the message
|
|
64
|
+
const messageRecord = this.createMessageRecord(message, context);
|
|
65
|
+
this.currentSession.messages.push(messageRecord);
|
|
66
|
+
this.messageCount++;
|
|
67
|
+
// Update session totals
|
|
68
|
+
this.updateSessionTotals(messageRecord);
|
|
69
|
+
const results = [
|
|
70
|
+
this.createEvent('MessageRecorded', {
|
|
71
|
+
messageId: messageRecord.id,
|
|
72
|
+
sessionId: this.currentSession.sessionId,
|
|
73
|
+
messageCount: this.messageCount
|
|
74
|
+
})
|
|
75
|
+
];
|
|
76
|
+
// Auto-export if enabled and interval reached
|
|
77
|
+
if (this.autoExport && this.messageCount % this.exportInterval === 0) {
|
|
78
|
+
try {
|
|
79
|
+
const exportPath = await this.exportSession(this.currentSession);
|
|
80
|
+
results.push(this.createEvent('SessionExported', {
|
|
81
|
+
sessionId: this.currentSession.sessionId,
|
|
82
|
+
exportPath,
|
|
83
|
+
messageCount: this.currentSession.messages.length
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
catch (exportError) {
|
|
87
|
+
results.push(this.createEvent('ExportError', {
|
|
88
|
+
error: exportError instanceof Error ? exportError.message : String(exportError),
|
|
89
|
+
sessionId: this.currentSession.sessionId
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('[ChatRecording] Error recording message:', error);
|
|
97
|
+
const messageStr = String(message);
|
|
98
|
+
return [this.createEvent('RecordingError', {
|
|
99
|
+
error: error instanceof Error ? error.message : String(error),
|
|
100
|
+
messageContent: messageStr.slice(0, 100)
|
|
101
|
+
})];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
initializeSession(context) {
|
|
105
|
+
const sessionId = this.generateSessionId();
|
|
106
|
+
this.currentSession = {
|
|
107
|
+
sessionId,
|
|
108
|
+
startTime: new Date().toISOString(),
|
|
109
|
+
messages: [],
|
|
110
|
+
totalTokens: {
|
|
111
|
+
input: 0,
|
|
112
|
+
output: 0,
|
|
113
|
+
cached: 0,
|
|
114
|
+
total: 0
|
|
115
|
+
},
|
|
116
|
+
toolCallCount: 0,
|
|
117
|
+
metadata: {
|
|
118
|
+
llmConfig: (context === null || context === void 0 ? void 0 : context.llmconfig) || {},
|
|
119
|
+
userAgent: 'codebolt-agent',
|
|
120
|
+
version: '1.0.0',
|
|
121
|
+
...context === null || context === void 0 ? void 0 : context.sessionMetadata
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
createMessageRecord(message, context) {
|
|
126
|
+
const id = this.generateMessageId();
|
|
127
|
+
const timestamp = new Date().toISOString();
|
|
128
|
+
// Extract basic message info
|
|
129
|
+
let role = 'unknown';
|
|
130
|
+
let content = '';
|
|
131
|
+
let toolCalls = [];
|
|
132
|
+
if (message.messages && Array.isArray(message.messages) && message.messages.length > 0) {
|
|
133
|
+
const lastMessage = message.messages[message.messages.length - 1];
|
|
134
|
+
role = lastMessage.role || 'unknown';
|
|
135
|
+
content = this.extractContent(lastMessage.content);
|
|
136
|
+
if (lastMessage.tool_calls) {
|
|
137
|
+
toolCalls = this.extractToolCalls(lastMessage.tool_calls);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (typeof message === 'string') {
|
|
141
|
+
role = 'user';
|
|
142
|
+
content = message;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
content = JSON.stringify(message);
|
|
146
|
+
}
|
|
147
|
+
// Calculate tokens if enabled
|
|
148
|
+
let tokens;
|
|
149
|
+
if (this.enableTokenTracking) {
|
|
150
|
+
tokens = this.estimateTokens(content);
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
timestamp,
|
|
155
|
+
role,
|
|
156
|
+
content: content.slice(0, 10000), // Limit content length for storage
|
|
157
|
+
metadata: this.includeMetadata ? {
|
|
158
|
+
originalMessageLength: content.length,
|
|
159
|
+
hasToolCalls: toolCalls.length > 0,
|
|
160
|
+
contextKeys: context ? Object.keys(context) : [],
|
|
161
|
+
...message.metadata
|
|
162
|
+
} : undefined,
|
|
163
|
+
tokens,
|
|
164
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : undefined
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
extractContent(content) {
|
|
168
|
+
if (typeof content === 'string') {
|
|
169
|
+
return content;
|
|
170
|
+
}
|
|
171
|
+
if (Array.isArray(content)) {
|
|
172
|
+
return content
|
|
173
|
+
.map(part => {
|
|
174
|
+
if (typeof part === 'string')
|
|
175
|
+
return part;
|
|
176
|
+
if (part === null || part === void 0 ? void 0 : part.text)
|
|
177
|
+
return part.text;
|
|
178
|
+
if ((part === null || part === void 0 ? void 0 : part.type) === 'text')
|
|
179
|
+
return part.text || '';
|
|
180
|
+
return JSON.stringify(part);
|
|
181
|
+
})
|
|
182
|
+
.join(' ');
|
|
183
|
+
}
|
|
184
|
+
return JSON.stringify(content);
|
|
185
|
+
}
|
|
186
|
+
extractToolCalls(toolCalls) {
|
|
187
|
+
return toolCalls.map(tc => {
|
|
188
|
+
var _a, _b, _c;
|
|
189
|
+
return ({
|
|
190
|
+
id: tc.id || this.generateToolCallId(),
|
|
191
|
+
name: ((_a = tc.function) === null || _a === void 0 ? void 0 : _a.name) || 'unknown',
|
|
192
|
+
args: typeof ((_b = tc.function) === null || _b === void 0 ? void 0 : _b.arguments) === 'string'
|
|
193
|
+
? JSON.parse(tc.function.arguments)
|
|
194
|
+
: ((_c = tc.function) === null || _c === void 0 ? void 0 : _c.arguments) || {},
|
|
195
|
+
status: 'pending',
|
|
196
|
+
timestamp: new Date().toISOString()
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
estimateTokens(content) {
|
|
201
|
+
// Simple token estimation
|
|
202
|
+
const charCount = content.length;
|
|
203
|
+
const estimated = Math.ceil(charCount / 4);
|
|
204
|
+
return {
|
|
205
|
+
input: estimated,
|
|
206
|
+
output: 0,
|
|
207
|
+
cached: 0,
|
|
208
|
+
total: estimated
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
updateSessionTotals(messageRecord) {
|
|
212
|
+
if (!this.currentSession || !messageRecord.tokens)
|
|
213
|
+
return;
|
|
214
|
+
this.currentSession.totalTokens.input += messageRecord.tokens.input;
|
|
215
|
+
this.currentSession.totalTokens.output += messageRecord.tokens.output;
|
|
216
|
+
this.currentSession.totalTokens.cached += messageRecord.tokens.cached;
|
|
217
|
+
this.currentSession.totalTokens.total += messageRecord.tokens.total;
|
|
218
|
+
if (messageRecord.toolCalls) {
|
|
219
|
+
this.currentSession.toolCallCount += messageRecord.toolCalls.length;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
generateSessionId() {
|
|
223
|
+
return `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
224
|
+
}
|
|
225
|
+
generateMessageId() {
|
|
226
|
+
return `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
227
|
+
}
|
|
228
|
+
generateToolCallId() {
|
|
229
|
+
return `tool-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`;
|
|
230
|
+
}
|
|
231
|
+
async exportSession(session) {
|
|
232
|
+
// Ensure output directory exists
|
|
233
|
+
await this.ensureDirectoryExists();
|
|
234
|
+
const filename = `chat-session-${session.sessionId}-${Date.now()}.${this.exportFormat}`;
|
|
235
|
+
const filepath = path.join(this.outputDirectory, filename);
|
|
236
|
+
// Update end time
|
|
237
|
+
session.endTime = new Date().toISOString();
|
|
238
|
+
let content;
|
|
239
|
+
switch (this.exportFormat) {
|
|
240
|
+
case 'json':
|
|
241
|
+
content = JSON.stringify(session, null, 2);
|
|
242
|
+
break;
|
|
243
|
+
case 'txt':
|
|
244
|
+
content = this.formatAsText(session);
|
|
245
|
+
break;
|
|
246
|
+
case 'csv':
|
|
247
|
+
content = this.formatAsCSV(session);
|
|
248
|
+
break;
|
|
249
|
+
default:
|
|
250
|
+
content = JSON.stringify(session, null, 2);
|
|
251
|
+
}
|
|
252
|
+
await fs.writeFile(filepath, content, 'utf-8');
|
|
253
|
+
return filepath;
|
|
254
|
+
}
|
|
255
|
+
async ensureDirectoryExists() {
|
|
256
|
+
try {
|
|
257
|
+
await fs.access(this.outputDirectory);
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
await fs.mkdir(this.outputDirectory, { recursive: true });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
formatAsText(session) {
|
|
264
|
+
const lines = [];
|
|
265
|
+
lines.push(`Chat Session: ${session.sessionId}`);
|
|
266
|
+
lines.push(`Start Time: ${session.startTime}`);
|
|
267
|
+
lines.push(`End Time: ${session.endTime || 'Ongoing'}`);
|
|
268
|
+
lines.push(`Total Messages: ${session.messages.length}`);
|
|
269
|
+
lines.push(`Total Tokens: ${session.totalTokens.total}`);
|
|
270
|
+
lines.push(`Tool Calls: ${session.toolCallCount}`);
|
|
271
|
+
lines.push('---');
|
|
272
|
+
for (const message of session.messages) {
|
|
273
|
+
lines.push(`[${message.timestamp}] ${message.role.toUpperCase()}: ${message.content}`);
|
|
274
|
+
if (message.toolCalls) {
|
|
275
|
+
for (const tool of message.toolCalls) {
|
|
276
|
+
lines.push(` 🔧 ${tool.name}(${JSON.stringify(tool.args)})`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
lines.push('');
|
|
280
|
+
}
|
|
281
|
+
return lines.join('\n');
|
|
282
|
+
}
|
|
283
|
+
formatAsCSV(session) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
const headers = ['timestamp', 'role', 'content', 'tokens', 'tool_calls'];
|
|
286
|
+
const rows = [headers.join(',')];
|
|
287
|
+
for (const message of session.messages) {
|
|
288
|
+
const row = [
|
|
289
|
+
message.timestamp,
|
|
290
|
+
message.role,
|
|
291
|
+
`"${message.content.replace(/"/g, '""')}"`, // Escape quotes
|
|
292
|
+
((_a = message.tokens) === null || _a === void 0 ? void 0 : _a.total) || 0,
|
|
293
|
+
((_b = message.toolCalls) === null || _b === void 0 ? void 0 : _b.length) || 0
|
|
294
|
+
];
|
|
295
|
+
rows.push(row.join(','));
|
|
296
|
+
}
|
|
297
|
+
return rows.join('\n');
|
|
298
|
+
}
|
|
299
|
+
// Public methods for session management
|
|
300
|
+
async finalizeSession() {
|
|
301
|
+
if (!this.currentSession)
|
|
302
|
+
return null;
|
|
303
|
+
try {
|
|
304
|
+
const exportPath = await this.exportSession(this.currentSession);
|
|
305
|
+
this.sessions.push(this.currentSession);
|
|
306
|
+
this.currentSession = null;
|
|
307
|
+
this.messageCount = 0;
|
|
308
|
+
return exportPath;
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
console.error('[ChatRecording] Error finalizing session:', error);
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
getCurrentSession() {
|
|
316
|
+
return this.currentSession;
|
|
317
|
+
}
|
|
318
|
+
getSessionStats() {
|
|
319
|
+
var _a, _b;
|
|
320
|
+
const totalMessages = this.sessions.reduce((sum, session) => sum + session.messages.length, 0) +
|
|
321
|
+
(((_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.messages.length) || 0);
|
|
322
|
+
return {
|
|
323
|
+
currentSessionMessages: ((_b = this.currentSession) === null || _b === void 0 ? void 0 : _b.messages.length) || 0,
|
|
324
|
+
totalSessions: this.sessions.length + (this.currentSession ? 1 : 0),
|
|
325
|
+
totalMessages
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.ChatRecordingProcessor = ChatRecordingProcessor;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseProcessor, ProcessorInput, ProcessorOutput } from '../../processor';
|
|
2
|
+
export interface ContextInfo {
|
|
3
|
+
projectContext?: string;
|
|
4
|
+
ideContext?: any;
|
|
5
|
+
directoryContext?: string;
|
|
6
|
+
contextAdded: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ContextManagementProcessorOptions {
|
|
9
|
+
enableProjectContext?: boolean;
|
|
10
|
+
enableIdeContext?: boolean;
|
|
11
|
+
enableDirectoryContext?: boolean;
|
|
12
|
+
forceFullContext?: boolean;
|
|
13
|
+
contextThreshold?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class ContextManagementProcessor extends BaseProcessor {
|
|
16
|
+
private readonly enableProjectContext;
|
|
17
|
+
private readonly enableIdeContext;
|
|
18
|
+
private readonly enableDirectoryContext;
|
|
19
|
+
private readonly forceFullContext;
|
|
20
|
+
private readonly contextThreshold;
|
|
21
|
+
private lastSentIdeContext;
|
|
22
|
+
private contextAddedToHistory;
|
|
23
|
+
constructor(options?: ContextManagementProcessorOptions);
|
|
24
|
+
processInput(input: ProcessorInput): Promise<ProcessorOutput[]>;
|
|
25
|
+
private collectContext;
|
|
26
|
+
private getProjectContext;
|
|
27
|
+
private getIdeContext;
|
|
28
|
+
private getDirectoryContext;
|
|
29
|
+
private detectIdeType;
|
|
30
|
+
private getOpenFiles;
|
|
31
|
+
private getActiveFile;
|
|
32
|
+
private addContextToMessage;
|
|
33
|
+
resetContext(): void;
|
|
34
|
+
forceContextRefresh(): void;
|
|
35
|
+
setContextThreshold(threshold: number): void;
|
|
36
|
+
enableProjectContextForSession(): void;
|
|
37
|
+
disableProjectContextForSession(): void;
|
|
38
|
+
enableIdeContextForSession(): void;
|
|
39
|
+
disableIdeContextForSession(): void;
|
|
40
|
+
}
|