@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,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library types for the Unified Agent Framework
|
|
3
|
+
* Self-contained within the unified directory
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents a message in the conversation with roles and content.
|
|
7
|
+
*/
|
|
8
|
+
export interface Message {
|
|
9
|
+
/** The role of the message sender: user, assistant, tool, or system */
|
|
10
|
+
role: 'user' | 'assistant' | 'tool' | 'system';
|
|
11
|
+
/** The content of the message, can be an array of content blocks or a string */
|
|
12
|
+
content: unknown[] | string;
|
|
13
|
+
/** Optional ID for tool calls */
|
|
14
|
+
tool_call_id?: string;
|
|
15
|
+
/** Optional tool calls for assistant messages */
|
|
16
|
+
tool_calls?: ToolCall[];
|
|
17
|
+
/** Additional properties that might be present */
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents a tool call in OpenAI format
|
|
22
|
+
*/
|
|
23
|
+
export interface ToolCall {
|
|
24
|
+
/** Unique identifier for this tool call */
|
|
25
|
+
id: string;
|
|
26
|
+
/** The type of tool call */
|
|
27
|
+
type: 'function';
|
|
28
|
+
/** Function call details */
|
|
29
|
+
function: {
|
|
30
|
+
/** Name of the function to call */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Arguments for the function call as JSON string */
|
|
33
|
+
arguments: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Represents a tool definition in OpenAI format
|
|
38
|
+
*/
|
|
39
|
+
export interface Tool {
|
|
40
|
+
/** The type of tool */
|
|
41
|
+
type: 'function';
|
|
42
|
+
/** Function definition */
|
|
43
|
+
function: {
|
|
44
|
+
/** Name of the function */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Description of what the function does */
|
|
47
|
+
description?: string;
|
|
48
|
+
/** JSON schema for the function parameters */
|
|
49
|
+
parameters?: unknown;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* OpenAI-compatible message format for conversations
|
|
54
|
+
*/
|
|
55
|
+
export interface OpenAIMessage {
|
|
56
|
+
/** Role of the message sender */
|
|
57
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
58
|
+
/** Content of the message */
|
|
59
|
+
content: string | Array<{
|
|
60
|
+
type: string;
|
|
61
|
+
text: string;
|
|
62
|
+
}>;
|
|
63
|
+
/** Tool call ID for tool messages */
|
|
64
|
+
tool_call_id?: string;
|
|
65
|
+
/** Tool calls for assistant messages */
|
|
66
|
+
tool_calls?: Array<{
|
|
67
|
+
id: string;
|
|
68
|
+
type: 'function';
|
|
69
|
+
function: {
|
|
70
|
+
name: string;
|
|
71
|
+
arguments: string;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
/** Name for tool messages */
|
|
75
|
+
name?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* OpenAI-compatible tool format
|
|
79
|
+
*/
|
|
80
|
+
export interface OpenAITool {
|
|
81
|
+
type: 'function';
|
|
82
|
+
function: {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
parameters: {
|
|
86
|
+
type: 'object';
|
|
87
|
+
properties: Record<string, unknown>;
|
|
88
|
+
required?: string[];
|
|
89
|
+
additionalProperties?: boolean;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Tool result from execution
|
|
95
|
+
*/
|
|
96
|
+
export interface ToolResult {
|
|
97
|
+
/** Tool call ID that this result corresponds to */
|
|
98
|
+
toolCallId: string;
|
|
99
|
+
/** Name of the tool that was executed */
|
|
100
|
+
toolName: string;
|
|
101
|
+
/** Result of the tool execution */
|
|
102
|
+
result: string;
|
|
103
|
+
/** Whether the tool execution was successful */
|
|
104
|
+
success: boolean;
|
|
105
|
+
/** Error message if execution failed */
|
|
106
|
+
error?: string;
|
|
107
|
+
/** Execution metadata */
|
|
108
|
+
metadata?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* LLM inference request parameters
|
|
112
|
+
*/
|
|
113
|
+
export interface LLMInferenceParams {
|
|
114
|
+
/** Array of messages in the conversation */
|
|
115
|
+
messages: Message[];
|
|
116
|
+
/** Available tools for the model to use */
|
|
117
|
+
tools?: Tool[];
|
|
118
|
+
/** How the model should use tools */
|
|
119
|
+
tool_choice?: 'auto' | 'none' | 'required' | {
|
|
120
|
+
type: 'function';
|
|
121
|
+
function: {
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** The LLM role to determine which model to use */
|
|
126
|
+
llmrole: string;
|
|
127
|
+
/** Maximum number of tokens to generate */
|
|
128
|
+
max_tokens?: number;
|
|
129
|
+
/** Temperature for response generation */
|
|
130
|
+
temperature?: number;
|
|
131
|
+
/** Whether to stream the response */
|
|
132
|
+
stream?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* LLM response from inference
|
|
136
|
+
*/
|
|
137
|
+
export interface LLMResponse {
|
|
138
|
+
/** Generated content */
|
|
139
|
+
content?: string;
|
|
140
|
+
/** Tool calls if any */
|
|
141
|
+
tool_calls?: ToolCall[];
|
|
142
|
+
/** Finish reason */
|
|
143
|
+
finish_reason?: 'stop' | 'length' | 'tool_calls' | 'content_filter';
|
|
144
|
+
/** Usage statistics */
|
|
145
|
+
usage?: {
|
|
146
|
+
prompt_tokens: number;
|
|
147
|
+
completion_tokens: number;
|
|
148
|
+
total_tokens: number;
|
|
149
|
+
};
|
|
150
|
+
/** Additional metadata */
|
|
151
|
+
metadata?: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* CodeBolt API interface for agent operations
|
|
155
|
+
*/
|
|
156
|
+
export interface CodeboltAPI {
|
|
157
|
+
/** Chat operations */
|
|
158
|
+
chat: {
|
|
159
|
+
/** Send a message to the user */
|
|
160
|
+
sendMessage(message: string): Promise<void>;
|
|
161
|
+
/** Get conversation history */
|
|
162
|
+
getHistory(): Promise<OpenAIMessage[]>;
|
|
163
|
+
/** Clear conversation history */
|
|
164
|
+
clearHistory(): Promise<void>;
|
|
165
|
+
/** Summarize conversation */
|
|
166
|
+
summarizeConversation(messages: OpenAIMessage[], options?: {
|
|
167
|
+
maxLength?: number;
|
|
168
|
+
includeToolCalls?: boolean;
|
|
169
|
+
}): Promise<string>;
|
|
170
|
+
};
|
|
171
|
+
/** LLM operations */
|
|
172
|
+
llm: {
|
|
173
|
+
/** Generate LLM response */
|
|
174
|
+
inference(params: LLMInferenceParams): Promise<LLMResponse>;
|
|
175
|
+
/** Stream LLM response */
|
|
176
|
+
stream(params: LLMInferenceParams): AsyncIterable<LLMResponse>;
|
|
177
|
+
};
|
|
178
|
+
/** MCP (Micro-Component Platform) operations */
|
|
179
|
+
mcp: {
|
|
180
|
+
/** Execute an MCP tool */
|
|
181
|
+
executeTool(toolName: string, params: unknown): Promise<{
|
|
182
|
+
data: unknown;
|
|
183
|
+
}>;
|
|
184
|
+
/** List available MCP tools */
|
|
185
|
+
listTools(): Promise<string[]>;
|
|
186
|
+
/** Get tool schema */
|
|
187
|
+
getToolSchema(toolName: string): Promise<OpenAITool>;
|
|
188
|
+
};
|
|
189
|
+
/** File system operations */
|
|
190
|
+
fs: {
|
|
191
|
+
/** Read file content */
|
|
192
|
+
readFile(path: string): Promise<string>;
|
|
193
|
+
/** Write file content */
|
|
194
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
195
|
+
/** List directory contents */
|
|
196
|
+
listDir(path: string): Promise<string[]>;
|
|
197
|
+
/** Check if file exists */
|
|
198
|
+
exists(path: string): Promise<boolean>;
|
|
199
|
+
};
|
|
200
|
+
/** Agent operations */
|
|
201
|
+
agent?: {
|
|
202
|
+
/** Start a sub-agent */
|
|
203
|
+
startAgent(agentName: string, params: unknown): Promise<{
|
|
204
|
+
data: unknown;
|
|
205
|
+
}>;
|
|
206
|
+
/** List available agents */
|
|
207
|
+
listAgents(): Promise<string[]>;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* LLM configuration
|
|
212
|
+
*/
|
|
213
|
+
export interface LLMConfig {
|
|
214
|
+
/** LLM name/role identifier */
|
|
215
|
+
llmname?: string;
|
|
216
|
+
/** Model name */
|
|
217
|
+
model?: string;
|
|
218
|
+
/** Temperature for generation */
|
|
219
|
+
temperature?: number;
|
|
220
|
+
/** Maximum tokens */
|
|
221
|
+
maxTokens?: number;
|
|
222
|
+
/** API key */
|
|
223
|
+
apiKey?: string;
|
|
224
|
+
/** Base URL for API */
|
|
225
|
+
baseUrl?: string;
|
|
226
|
+
/** Additional configuration */
|
|
227
|
+
[key: string]: unknown;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Agent execution context
|
|
231
|
+
*/
|
|
232
|
+
export interface ExecutionContext {
|
|
233
|
+
/** Session identifier */
|
|
234
|
+
sessionId?: string;
|
|
235
|
+
/** User identifier */
|
|
236
|
+
userId?: string;
|
|
237
|
+
/** Conversation identifier */
|
|
238
|
+
conversationId?: string;
|
|
239
|
+
/** Request identifier */
|
|
240
|
+
requestId?: string;
|
|
241
|
+
/** Execution start time */
|
|
242
|
+
startTime: string;
|
|
243
|
+
/** Additional metadata */
|
|
244
|
+
metadata: Record<string, unknown>;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Agent execution result
|
|
248
|
+
*/
|
|
249
|
+
export interface AgentExecutionResult {
|
|
250
|
+
/** Whether execution completed successfully */
|
|
251
|
+
success: boolean;
|
|
252
|
+
/** Final response message */
|
|
253
|
+
response: string;
|
|
254
|
+
/** Complete conversation history */
|
|
255
|
+
conversationHistory: OpenAIMessage[];
|
|
256
|
+
/** Tool execution results */
|
|
257
|
+
toolResults: ToolResult[];
|
|
258
|
+
/** Number of iterations performed */
|
|
259
|
+
iterations: number;
|
|
260
|
+
/** Whether the agent completed its task */
|
|
261
|
+
completed: boolean;
|
|
262
|
+
/** Execution context */
|
|
263
|
+
context: Record<string, unknown>;
|
|
264
|
+
/** Error message if execution failed */
|
|
265
|
+
error?: string;
|
|
266
|
+
/** Execution metadata */
|
|
267
|
+
metadata?: Record<string, unknown>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Agent event types
|
|
271
|
+
*/
|
|
272
|
+
export type AgentEventType = 'AgentStarted' | 'AgentCompleted' | 'AgentError' | 'MessageProcessed' | 'ToolExecuted' | 'ConversationUpdated' | 'IterationCompleted';
|
|
273
|
+
/**
|
|
274
|
+
* Agent event data
|
|
275
|
+
*/
|
|
276
|
+
export interface AgentEvent {
|
|
277
|
+
type: AgentEventType;
|
|
278
|
+
timestamp: string;
|
|
279
|
+
data: Record<string, unknown>;
|
|
280
|
+
error?: string;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Event handler function
|
|
284
|
+
*/
|
|
285
|
+
export type AgentEventHandler = (event: AgentEvent) => void | Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Deep partial type for configuration objects
|
|
288
|
+
*/
|
|
289
|
+
export type DeepPartial<T> = {
|
|
290
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Function that can be sync or async
|
|
294
|
+
*/
|
|
295
|
+
export type MaybeAsync<T> = T | Promise<T>;
|
|
296
|
+
/**
|
|
297
|
+
* Callback function type
|
|
298
|
+
*/
|
|
299
|
+
export type Callback<T = unknown> = (data: T) => void | Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Error with context information
|
|
302
|
+
*/
|
|
303
|
+
export interface ContextualError extends Error {
|
|
304
|
+
context?: Record<string, unknown>;
|
|
305
|
+
code?: string;
|
|
306
|
+
statusCode?: number;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Validation result
|
|
310
|
+
*/
|
|
311
|
+
export interface ValidationResult {
|
|
312
|
+
/** Whether validation passed */
|
|
313
|
+
isValid: boolean;
|
|
314
|
+
/** Validation errors */
|
|
315
|
+
errors: string[];
|
|
316
|
+
/** Validation warnings */
|
|
317
|
+
warnings: string[];
|
|
318
|
+
/** Additional metadata */
|
|
319
|
+
metadata?: Record<string, unknown>;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Schema validation function
|
|
323
|
+
*/
|
|
324
|
+
export type SchemaValidator<T = unknown> = (data: unknown) => ValidationResult & {
|
|
325
|
+
data?: T;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Stream chunk for real-time responses
|
|
329
|
+
*/
|
|
330
|
+
export interface StreamChunk {
|
|
331
|
+
/** Type of chunk */
|
|
332
|
+
type: 'text' | 'tool_call' | 'tool_result' | 'error' | 'done';
|
|
333
|
+
/** Chunk content */
|
|
334
|
+
content: string;
|
|
335
|
+
/** Tool call information if applicable */
|
|
336
|
+
toolCall?: ToolCall;
|
|
337
|
+
/** Tool result if applicable */
|
|
338
|
+
toolResult?: ToolResult;
|
|
339
|
+
/** Error information if applicable */
|
|
340
|
+
error?: string;
|
|
341
|
+
/** Additional metadata */
|
|
342
|
+
metadata?: Record<string, unknown>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Stream callback function
|
|
346
|
+
*/
|
|
347
|
+
export type StreamCallback = (chunk: StreamChunk) => void | Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Memory storage interface
|
|
350
|
+
*/
|
|
351
|
+
export interface MemoryStorage {
|
|
352
|
+
/** Store data */
|
|
353
|
+
set(key: string, value: unknown): Promise<void>;
|
|
354
|
+
/** Retrieve data */
|
|
355
|
+
get(key: string): Promise<unknown>;
|
|
356
|
+
/** Delete data */
|
|
357
|
+
delete(key: string): Promise<void>;
|
|
358
|
+
/** List all keys */
|
|
359
|
+
keys(): Promise<string[]>;
|
|
360
|
+
/** Clear all data */
|
|
361
|
+
clear(): Promise<void>;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Conversation memory entry
|
|
365
|
+
*/
|
|
366
|
+
export interface ConversationMemory {
|
|
367
|
+
/** Conversation ID */
|
|
368
|
+
id: string;
|
|
369
|
+
/** Messages in the conversation */
|
|
370
|
+
messages: OpenAIMessage[];
|
|
371
|
+
/** Creation timestamp */
|
|
372
|
+
createdAt: string;
|
|
373
|
+
/** Last update timestamp */
|
|
374
|
+
updatedAt: string;
|
|
375
|
+
/** Additional metadata */
|
|
376
|
+
metadata: Record<string, unknown>;
|
|
377
|
+
}
|
|
378
|
+
export type { Message as LibMessage, ToolCall as LibToolCall, Tool as LibTool, OpenAIMessage as LibOpenAIMessage, OpenAITool as LibOpenAITool, ToolResult as LibToolResult, LLMInferenceParams as LibLLMInferenceParams, LLMResponse as LibLLMResponse, CodeboltAPI as LibCodeboltAPI, LLMConfig as LibLLMConfig, ExecutionContext as LibExecutionContext, AgentExecutionResult as LibAgentExecutionResult, AgentEvent as LibAgentEvent, AgentEventHandler as LibAgentEventHandler, StreamChunk as LibStreamChunk, StreamCallback as LibStreamCallback, MemoryStorage as LibMemoryStorage, ConversationMemory as LibConversationMemory };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Processor } from 'src/types/processorTypes';
|
|
2
|
+
import type { OpenAIMessage, OpenAITool, ToolResult, CodeboltAPI } from './libTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the unified agent
|
|
5
|
+
*/
|
|
6
|
+
export interface UnifiedAgentConfig {
|
|
7
|
+
/** Maximum iterations for agent loops */
|
|
8
|
+
maxIterations?: number;
|
|
9
|
+
/** Maximum conversation length before summarization */
|
|
10
|
+
maxConversationLength?: number;
|
|
11
|
+
/** LLM configuration */
|
|
12
|
+
llmConfig?: LLMConfig;
|
|
13
|
+
/** Codebolt API instance */
|
|
14
|
+
codebolt?: CodeboltAPI;
|
|
15
|
+
/** Enable logging */
|
|
16
|
+
enableLogging?: boolean;
|
|
17
|
+
/** Retry configuration */
|
|
18
|
+
retryConfig?: {
|
|
19
|
+
maxRetries?: number;
|
|
20
|
+
retryDelay?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* LLM configuration for the unified agent
|
|
25
|
+
*/
|
|
26
|
+
export interface LLMConfig {
|
|
27
|
+
llmname?: string;
|
|
28
|
+
model?: string;
|
|
29
|
+
temperature?: number;
|
|
30
|
+
maxTokens?: number;
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Output from unified message processing
|
|
36
|
+
*/
|
|
37
|
+
export interface UnifiedMessageOutput {
|
|
38
|
+
/** Processed messages ready for LLM */
|
|
39
|
+
messages: OpenAIMessage[];
|
|
40
|
+
/** Available tools */
|
|
41
|
+
tools: OpenAITool[];
|
|
42
|
+
/** Updated context */
|
|
43
|
+
context: Record<string, any>;
|
|
44
|
+
/** Tool choice strategy */
|
|
45
|
+
toolChoice: 'auto' | 'none' | 'required';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Input for unified agent step processing
|
|
49
|
+
*/
|
|
50
|
+
export interface UnifiedStepInput {
|
|
51
|
+
/** Processed messages */
|
|
52
|
+
messages: OpenAIMessage[];
|
|
53
|
+
/** Available tools */
|
|
54
|
+
tools: OpenAITool[];
|
|
55
|
+
/** Processing context */
|
|
56
|
+
context?: Record<string, any>;
|
|
57
|
+
/** Tool choice strategy */
|
|
58
|
+
toolChoice?: 'auto' | 'none' | 'required';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Output from unified agent step processing
|
|
62
|
+
*/
|
|
63
|
+
export interface UnifiedStepOutput {
|
|
64
|
+
/** LLM response */
|
|
65
|
+
llmResponse: any;
|
|
66
|
+
/** Whether processing is complete */
|
|
67
|
+
finished: boolean;
|
|
68
|
+
/** Tool calls detected */
|
|
69
|
+
toolCalls?: Array<{
|
|
70
|
+
tool: string;
|
|
71
|
+
parameters: any;
|
|
72
|
+
}>;
|
|
73
|
+
/** Updated context */
|
|
74
|
+
context: Record<string, any>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Input for unified response execution
|
|
78
|
+
*/
|
|
79
|
+
export interface UnifiedResponseInput {
|
|
80
|
+
/** LLM response to process */
|
|
81
|
+
llmResponse: any;
|
|
82
|
+
/** Previous conversation messages */
|
|
83
|
+
conversationHistory: OpenAIMessage[];
|
|
84
|
+
/** Available tools */
|
|
85
|
+
tools: OpenAITool[];
|
|
86
|
+
/** Processing context */
|
|
87
|
+
context?: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Output from unified response execution
|
|
91
|
+
*/
|
|
92
|
+
export interface UnifiedResponseOutput {
|
|
93
|
+
/** Tool execution results */
|
|
94
|
+
toolResults: ToolResult[];
|
|
95
|
+
/** Next user message (if any) */
|
|
96
|
+
nextUserMessage: OpenAIMessage | null;
|
|
97
|
+
/** Updated conversation history */
|
|
98
|
+
conversationHistory: OpenAIMessage[];
|
|
99
|
+
/** Whether task is completed */
|
|
100
|
+
completed: boolean;
|
|
101
|
+
/** Final response message */
|
|
102
|
+
finalMessage?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Complete agent execution input
|
|
106
|
+
*/
|
|
107
|
+
export interface UnifiedAgentInput {
|
|
108
|
+
/** User message or request */
|
|
109
|
+
userMessage: any;
|
|
110
|
+
/** Available tools */
|
|
111
|
+
tools?: OpenAITool[];
|
|
112
|
+
/** Processing context */
|
|
113
|
+
context?: Record<string, any>;
|
|
114
|
+
/** Previous conversation history */
|
|
115
|
+
conversationHistory?: OpenAIMessage[];
|
|
116
|
+
/** Maximum iterations for this execution */
|
|
117
|
+
maxIterations?: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Complete agent execution output
|
|
121
|
+
*/
|
|
122
|
+
export interface UnifiedAgentOutput {
|
|
123
|
+
/** Final response message */
|
|
124
|
+
response: string;
|
|
125
|
+
/** Tool execution results */
|
|
126
|
+
toolResults: ToolResult[];
|
|
127
|
+
/** Updated conversation history */
|
|
128
|
+
conversationHistory: OpenAIMessage[];
|
|
129
|
+
/** Final context state */
|
|
130
|
+
context: Record<string, any>;
|
|
131
|
+
/** Whether task was completed successfully */
|
|
132
|
+
completed: boolean;
|
|
133
|
+
/** Number of iterations used */
|
|
134
|
+
iterations: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Unified message modifier interface
|
|
138
|
+
*/
|
|
139
|
+
export interface UnifiedMessageModifier {
|
|
140
|
+
/** Process and modify input messages */
|
|
141
|
+
processMessage(input: any): Promise<UnifiedMessageOutput>;
|
|
142
|
+
/** Add a processor to the modifier */
|
|
143
|
+
addProcessor(processor: Processor): void;
|
|
144
|
+
/** Set context value */
|
|
145
|
+
setContext(key: string, value: any): void;
|
|
146
|
+
/** Get context value */
|
|
147
|
+
getContext(key: string): any;
|
|
148
|
+
/** Clear all context */
|
|
149
|
+
clearContext(): void;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Unified response executor interface
|
|
153
|
+
*/
|
|
154
|
+
export interface UnifiedResponseExecutor {
|
|
155
|
+
/** Execute response processing including tool execution */
|
|
156
|
+
executeResponse(input: UnifiedResponseInput): Promise<UnifiedResponseOutput>;
|
|
157
|
+
/** Execute tools from LLM response */
|
|
158
|
+
executeTools(llmResponse: any, tools: OpenAITool[], context?: Record<string, any>): Promise<ToolResult[]>;
|
|
159
|
+
/** Build follow-up conversation */
|
|
160
|
+
buildFollowUpConversation(conversationHistory: OpenAIMessage[], toolResults: ToolResult[], llmResponse: any): Promise<OpenAIMessage[]>;
|
|
161
|
+
/** Check if conversation needs summarization */
|
|
162
|
+
shouldSummarizeConversation(conversationHistory: OpenAIMessage[]): boolean;
|
|
163
|
+
/** Summarize conversation */
|
|
164
|
+
summarizeConversation(conversationHistory: OpenAIMessage[]): Promise<OpenAIMessage[]>;
|
|
165
|
+
/** Add a follow-up conversation processor */
|
|
166
|
+
addFollowUpConversationProcessor(processor: Processor): void;
|
|
167
|
+
/** Remove a follow-up conversation processor */
|
|
168
|
+
removeFollowUpConversationProcessor(processor: Processor): boolean;
|
|
169
|
+
/** Get all follow-up conversation processors */
|
|
170
|
+
getFollowUpConversationProcessors(): Processor[];
|
|
171
|
+
/** Clear all follow-up conversation processors */
|
|
172
|
+
clearFollowUpConversationProcessors(): void;
|
|
173
|
+
/** Add a pre-tool call processor */
|
|
174
|
+
addPreToolCallProcessor(processor: Processor): void;
|
|
175
|
+
/** Remove a pre-tool call processor */
|
|
176
|
+
removePreToolCallProcessor(processor: Processor): boolean;
|
|
177
|
+
/** Get all pre-tool call processors */
|
|
178
|
+
getPreToolCallProcessors(): Processor[];
|
|
179
|
+
/** Clear all pre-tool call processors */
|
|
180
|
+
clearPreToolCallProcessors(): void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Main unified agent interface
|
|
184
|
+
*/
|
|
185
|
+
export type UnifiedAgentEventType = 'message_processed' | 'step_started' | 'step_completed' | 'tool_call_detected' | 'tool_execution_started' | 'tool_execution_completed' | 'response_generated' | 'conversation_summarized' | 'agent_completed' | 'agent_error' | 'iteration_started' | 'iteration_completed';
|
|
186
|
+
export interface UnifiedAgentEvent {
|
|
187
|
+
type: UnifiedAgentEventType;
|
|
188
|
+
data?: any;
|
|
189
|
+
timestamp: string;
|
|
190
|
+
context?: Record<string, any>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Event handler for unified agent events
|
|
194
|
+
*/
|
|
195
|
+
export type UnifiedAgentEventHandler = (event: UnifiedAgentEvent) => void | Promise<void>;
|
|
196
|
+
export declare class UnifiedAgentError extends Error {
|
|
197
|
+
readonly code: string;
|
|
198
|
+
readonly context?: Record<string, any> | undefined;
|
|
199
|
+
constructor(message: string, code: string, context?: Record<string, any> | undefined);
|
|
200
|
+
}
|
|
201
|
+
export declare class UnifiedMessageProcessingError extends UnifiedAgentError {
|
|
202
|
+
constructor(message: string, context?: Record<string, any>);
|
|
203
|
+
}
|
|
204
|
+
export declare class UnifiedStepExecutionError extends UnifiedAgentError {
|
|
205
|
+
constructor(message: string, context?: Record<string, any>);
|
|
206
|
+
}
|
|
207
|
+
export declare class UnifiedResponseExecutionError extends UnifiedAgentError {
|
|
208
|
+
constructor(message: string, context?: Record<string, any>);
|
|
209
|
+
}
|
|
210
|
+
export declare class UnifiedToolExecutionError extends UnifiedAgentError {
|
|
211
|
+
constructor(message: string, context?: Record<string, any>);
|
|
212
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnifiedToolExecutionError = exports.UnifiedResponseExecutionError = exports.UnifiedStepExecutionError = exports.UnifiedMessageProcessingError = exports.UnifiedAgentError = void 0;
|
|
4
|
+
// ================================
|
|
5
|
+
// Error Types
|
|
6
|
+
// ================================
|
|
7
|
+
class UnifiedAgentError extends Error {
|
|
8
|
+
constructor(message, code, context) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.context = context;
|
|
12
|
+
this.name = 'UnifiedAgentError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.UnifiedAgentError = UnifiedAgentError;
|
|
16
|
+
class UnifiedMessageProcessingError extends UnifiedAgentError {
|
|
17
|
+
constructor(message, context) {
|
|
18
|
+
super(message, 'MESSAGE_PROCESSING_ERROR', context);
|
|
19
|
+
this.name = 'UnifiedMessageProcessingError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.UnifiedMessageProcessingError = UnifiedMessageProcessingError;
|
|
23
|
+
class UnifiedStepExecutionError extends UnifiedAgentError {
|
|
24
|
+
constructor(message, context) {
|
|
25
|
+
super(message, 'STEP_EXECUTION_ERROR', context);
|
|
26
|
+
this.name = 'UnifiedStepExecutionError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.UnifiedStepExecutionError = UnifiedStepExecutionError;
|
|
30
|
+
class UnifiedResponseExecutionError extends UnifiedAgentError {
|
|
31
|
+
constructor(message, context) {
|
|
32
|
+
super(message, 'RESPONSE_EXECUTION_ERROR', context);
|
|
33
|
+
this.name = 'UnifiedResponseExecutionError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.UnifiedResponseExecutionError = UnifiedResponseExecutionError;
|
|
37
|
+
class UnifiedToolExecutionError extends UnifiedAgentError {
|
|
38
|
+
constructor(message, context) {
|
|
39
|
+
super(message, 'TOOL_EXECUTION_ERROR', context);
|
|
40
|
+
this.name = 'UnifiedToolExecutionError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.UnifiedToolExecutionError = UnifiedToolExecutionError;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UnifiedAgentConfig } from '../types/types';
|
|
2
|
+
/**
|
|
3
|
+
* Advanced agent creation with full configuration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Utility to create a testing agent with minimal configuration
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Utility to validate agent configuration
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateAgentConfig(config: UnifiedAgentConfig): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: string[];
|
|
14
|
+
warnings: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Utility to create agent from environment variables
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Utility to benchmark agent performance
|
|
21
|
+
*/
|
|
22
|
+
export declare function benchmarkAgent(agent: any, testCases: Array<{
|
|
23
|
+
name: string;
|
|
24
|
+
input: any;
|
|
25
|
+
expectedOutput?: any;
|
|
26
|
+
}>): Promise<{
|
|
27
|
+
results: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
success: boolean;
|
|
30
|
+
duration: number;
|
|
31
|
+
output: any;
|
|
32
|
+
error?: string;
|
|
33
|
+
}>;
|
|
34
|
+
summary: {
|
|
35
|
+
totalTests: number;
|
|
36
|
+
passed: number;
|
|
37
|
+
failed: number;
|
|
38
|
+
averageDuration: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|