@codebolt/agent 1.1.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +157 -66
  2. package/dist/builderpattern/agent.d.ts +86 -0
  3. package/dist/builderpattern/agent.js +324 -0
  4. package/dist/builderpattern/followupquestionbuilder.d.ts +75 -0
  5. package/dist/builderpattern/followupquestionbuilder.js +197 -0
  6. package/dist/builderpattern/index.d.ts +14 -0
  7. package/dist/builderpattern/index.js +23 -0
  8. package/dist/builderpattern/llmoutputhandler.d.ts +102 -0
  9. package/dist/builderpattern/llmoutputhandler.js +452 -0
  10. package/dist/builderpattern/promptbuilder.d.ts +382 -0
  11. package/dist/builderpattern/promptbuilder.js +805 -0
  12. package/dist/builderpattern/systemprompt.d.ts +20 -0
  13. package/dist/builderpattern/systemprompt.js +48 -0
  14. package/dist/builderpattern/taskInstruction.d.ts +37 -0
  15. package/dist/builderpattern/taskInstruction.js +57 -0
  16. package/dist/builderpattern/usermessage.d.ts +70 -0
  17. package/dist/builderpattern/usermessage.js +123 -0
  18. package/dist/composablepattern/agent.d.ts +169 -0
  19. package/dist/composablepattern/agent.js +598 -0
  20. package/dist/composablepattern/codebolt-storage.d.ts +67 -0
  21. package/dist/composablepattern/codebolt-storage.js +320 -0
  22. package/dist/composablepattern/document.d.ts +149 -0
  23. package/dist/composablepattern/document.js +405 -0
  24. package/dist/composablepattern/examples/codebolt-integration-example.d.ts +12 -0
  25. package/dist/composablepattern/examples/codebolt-integration-example.js +218 -0
  26. package/dist/composablepattern/examples/codebolt-storage-example.d.ts +40 -0
  27. package/dist/composablepattern/examples/codebolt-storage-example.js +223 -0
  28. package/dist/composablepattern/examples/custom-steps-example.d.ts +20 -0
  29. package/dist/composablepattern/examples/custom-steps-example.js +455 -0
  30. package/dist/composablepattern/examples/document-agent.d.ts +17 -0
  31. package/dist/composablepattern/examples/document-agent.js +107 -0
  32. package/dist/composablepattern/examples/simple-codebolt-integration.d.ts +8 -0
  33. package/dist/composablepattern/examples/simple-codebolt-integration.js +164 -0
  34. package/dist/composablepattern/examples/weather-agent.d.ts +18 -0
  35. package/dist/composablepattern/examples/weather-agent.js +86 -0
  36. package/dist/composablepattern/examples/workflow-example.d.ts +12 -0
  37. package/dist/composablepattern/examples/workflow-example.js +463 -0
  38. package/dist/composablepattern/index.d.ts +63 -0
  39. package/dist/composablepattern/index.js +115 -0
  40. package/dist/composablepattern/memory.d.ts +89 -0
  41. package/dist/composablepattern/memory.js +141 -0
  42. package/dist/composablepattern/tool.d.ts +84 -0
  43. package/dist/composablepattern/tool.js +260 -0
  44. package/dist/composablepattern/types.d.ts +194 -0
  45. package/dist/composablepattern/types.js +6 -0
  46. package/dist/composablepattern/user-context.d.ts +214 -0
  47. package/dist/composablepattern/user-context.js +275 -0
  48. package/dist/composablepattern/workflow.d.ts +388 -0
  49. package/dist/composablepattern/workflow.js +562 -0
  50. package/dist/processor/agent/agentStep.d.ts +49 -0
  51. package/dist/processor/agent/agentStep.js +241 -0
  52. package/dist/processor/agent/toolExecutor.d.ts +19 -0
  53. package/dist/processor/agent/toolExecutor.js +90 -0
  54. package/dist/processor/index.d.ts +7 -0
  55. package/dist/processor/index.js +36 -0
  56. package/dist/processor/messageModifiers/baseMessageModifier.d.ts +20 -0
  57. package/dist/processor/messageModifiers/baseMessageModifier.js +55 -0
  58. package/dist/processor/processors/baseProcessor.d.ts +14 -0
  59. package/dist/processor/processors/baseProcessor.js +29 -0
  60. package/dist/processor/tools/baseTool.d.ts +10 -0
  61. package/dist/processor/tools/baseTool.js +20 -0
  62. package/dist/processor/tools/toolList.d.ts +9 -0
  63. package/dist/processor/tools/toolList.js +22 -0
  64. package/dist/processor/types/interfaces.d.ts +94 -0
  65. package/dist/processor/types/interfaces.js +2 -0
  66. package/dist/processor-pieces/base/baseMessageModifier.d.ts +12 -0
  67. package/dist/processor-pieces/base/baseMessageModifier.js +15 -0
  68. package/dist/processor-pieces/base/basePostInferenceProcessor.d.ts +13 -0
  69. package/dist/processor-pieces/base/basePostInferenceProcessor.js +18 -0
  70. package/dist/processor-pieces/base/basePostToolCallProcessor.d.ts +15 -0
  71. package/dist/processor-pieces/base/basePostToolCallProcessor.js +25 -0
  72. package/dist/processor-pieces/base/basePreInferenceProcessor.d.ts +12 -0
  73. package/dist/processor-pieces/base/basePreInferenceProcessor.js +17 -0
  74. package/dist/processor-pieces/base/basePreToolCallProcessor.d.ts +18 -0
  75. package/dist/processor-pieces/base/basePreToolCallProcessor.js +66 -0
  76. package/dist/processor-pieces/base/index.d.ts +9 -0
  77. package/dist/processor-pieces/base/index.js +18 -0
  78. package/dist/processor-pieces/index.d.ts +1 -0
  79. package/dist/processor-pieces/index.js +59 -0
  80. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.d.ts +22 -0
  81. package/dist/processor-pieces/messageModifiers/addToolsListMessageModifier.js +144 -0
  82. package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.d.ts +13 -0
  83. package/dist/processor-pieces/messageModifiers/argumentProcessorModifier.js +68 -0
  84. package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.d.ts +25 -0
  85. package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.js +453 -0
  86. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.d.ts +15 -0
  87. package/dist/processor-pieces/messageModifiers/baseContextMessageModifier.js +75 -0
  88. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.d.ts +11 -0
  89. package/dist/processor-pieces/messageModifiers/baseSystemInstructionMessageModifier.js +46 -0
  90. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.d.ts +18 -0
  91. package/dist/processor-pieces/messageModifiers/chatHistoryMessageModifier.js +104 -0
  92. package/dist/processor-pieces/messageModifiers/chatRecordingModifier.d.ts +23 -0
  93. package/dist/processor-pieces/messageModifiers/chatRecordingModifier.js +173 -0
  94. package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.d.ts +14 -0
  95. package/dist/processor-pieces/messageModifiers/coreSystemPromptModifier.js +130 -0
  96. package/dist/processor-pieces/messageModifiers/directoryContextModifier.d.ts +36 -0
  97. package/dist/processor-pieces/messageModifiers/directoryContextModifier.js +418 -0
  98. package/dist/processor-pieces/messageModifiers/environmentContextModifier.d.ts +26 -0
  99. package/dist/processor-pieces/messageModifiers/environmentContextModifier.js +260 -0
  100. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.d.ts +12 -0
  101. package/dist/processor-pieces/messageModifiers/handleUrlMessageModifier.js +60 -0
  102. package/dist/processor-pieces/messageModifiers/ideContextModifier.d.ts +34 -0
  103. package/dist/processor-pieces/messageModifiers/ideContextModifier.js +157 -0
  104. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.d.ts +18 -0
  105. package/dist/processor-pieces/messageModifiers/imageAttachmentMessageModifier.js +222 -0
  106. package/dist/processor-pieces/messageModifiers/index.d.ts +11 -0
  107. package/dist/processor-pieces/messageModifiers/index.js +26 -0
  108. package/dist/processor-pieces/messageModifiers/memoryImportModifier.d.ts +15 -0
  109. package/dist/processor-pieces/messageModifiers/memoryImportModifier.js +129 -0
  110. package/dist/processor-pieces/messageModifiers/toolInjectionModifier.d.ts +20 -0
  111. package/dist/processor-pieces/messageModifiers/toolInjectionModifier.js +152 -0
  112. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.d.ts +22 -0
  113. package/dist/processor-pieces/messageModifiers/workingDirectoryMessageModifier.js +194 -0
  114. package/dist/processor-pieces/postInferenceProcessors/loopDetectionModifier.d.ts +29 -0
  115. package/dist/processor-pieces/postInferenceProcessors/loopDetectionModifier.js +174 -0
  116. package/dist/processor-pieces/postToolCallProcessors/index.d.ts +1 -0
  117. package/dist/processor-pieces/postToolCallProcessors/index.js +2 -0
  118. package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.d.ts +25 -0
  119. package/dist/processor-pieces/postToolCallProcessors/shellProcessorModifier.js +225 -0
  120. package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.d.ts +35 -0
  121. package/dist/processor-pieces/preInferenceProcessors/chatCompressionModifier.js +255 -0
  122. package/dist/processor-pieces/preInferenceProcessors/index.d.ts +1 -0
  123. package/dist/processor-pieces/preInferenceProcessors/index.js +2 -0
  124. package/dist/processor-pieces/pretoolCallProcessors/index.d.ts +1 -0
  125. package/dist/processor-pieces/pretoolCallProcessors/index.js +2 -0
  126. package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.d.ts +41 -0
  127. package/dist/processor-pieces/processors/advancedLoopDetectionProcessor.js +197 -0
  128. package/dist/processor-pieces/processors/chatCompressionProcessor.d.ts +26 -0
  129. package/dist/processor-pieces/processors/chatCompressionProcessor.js +90 -0
  130. package/dist/processor-pieces/processors/chatRecordingProcessor.d.ts +81 -0
  131. package/dist/processor-pieces/processors/chatRecordingProcessor.js +329 -0
  132. package/dist/processor-pieces/processors/contextManagementProcessor.d.ts +40 -0
  133. package/dist/processor-pieces/processors/contextManagementProcessor.js +305 -0
  134. package/dist/processor-pieces/processors/loopDetectionProcessor.d.ts +30 -0
  135. package/dist/processor-pieces/processors/loopDetectionProcessor.js +137 -0
  136. package/dist/processor-pieces/processors/responseValidationProcessor.d.ts +30 -0
  137. package/dist/processor-pieces/processors/responseValidationProcessor.js +228 -0
  138. package/dist/processor-pieces/processors/telemetryProcessor.d.ts +99 -0
  139. package/dist/processor-pieces/processors/telemetryProcessor.js +311 -0
  140. package/dist/processor-pieces/processors/tokenManagementProcessor.d.ts +37 -0
  141. package/dist/processor-pieces/processors/tokenManagementProcessor.js +178 -0
  142. package/dist/processor-pieces/processors/toolExecutionProcessor.d.ts +43 -0
  143. package/dist/processor-pieces/processors/toolExecutionProcessor.js +207 -0
  144. package/dist/processor-pieces/tools/fileTools.d.ts +26 -0
  145. package/dist/processor-pieces/tools/fileTools.js +162 -0
  146. package/dist/processor-pieces/utils/messageModifierHelper.d.ts +4 -0
  147. package/dist/processor-pieces/utils/messageModifierHelper.js +58 -0
  148. package/dist/types/commonTypes.d.ts +4 -0
  149. package/dist/types/processorTypes.d.ts +67 -0
  150. package/dist/types/processorTypes.js +58 -0
  151. package/dist/unified/agent/agent.d.ts +17 -0
  152. package/dist/unified/agent/agent.js +79 -0
  153. package/dist/unified/agent/team.d.ts +2 -0
  154. package/dist/unified/agent/team.js +6 -0
  155. package/dist/unified/agent/tools.d.ts +44 -0
  156. package/dist/unified/agent/tools.js +487 -0
  157. package/dist/unified/agent/workflow.d.ts +24 -0
  158. package/dist/unified/agent/workflow.js +275 -0
  159. package/dist/unified/agent/workflowControls.d.ts +11 -0
  160. package/dist/unified/agent/workflowControls.js +20 -0
  161. package/dist/unified/agent/workflowSteps.d.ts +63 -0
  162. package/dist/unified/agent/workflowSteps.js +284 -0
  163. package/dist/unified/base/agentStep.d.ts +32 -0
  164. package/dist/unified/base/agentStep.js +96 -0
  165. package/dist/unified/base/create/createInitialPromptGenerators.d.ts +5 -0
  166. package/dist/unified/base/create/createInitialPromptGenerators.js +17 -0
  167. package/dist/unified/base/index.d.ts +5 -0
  168. package/dist/unified/base/index.js +13 -0
  169. package/dist/unified/base/initialPromptGenerator.d.ts +48 -0
  170. package/dist/unified/base/initialPromptGenerator.js +118 -0
  171. package/dist/unified/base/responseExecutor.d.ts +36 -0
  172. package/dist/unified/base/responseExecutor.js +283 -0
  173. package/dist/unified/index.d.ts +18 -0
  174. package/dist/unified/index.js +42 -0
  175. package/dist/unified/team/team.d.ts +1 -0
  176. package/dist/unified/team/team.js +2 -0
  177. package/dist/unified/types/libTypes.d.ts +378 -0
  178. package/dist/unified/types/libTypes.js +6 -0
  179. package/dist/unified/types/types.d.ts +212 -0
  180. package/dist/unified/types/types.js +43 -0
  181. package/dist/unified/utils/utils.d.ts +40 -0
  182. package/dist/unified/utils/utils.js +219 -0
  183. package/package.json +29 -7
package/README.md CHANGED
@@ -1,101 +1,177 @@
1
- # CodeBolt Agent Utils
1
+ # CodeBolt Agent Package
2
2
 
3
- A TypeScript library providing utilities for building and managing AI agents with CodeBolt. This package extracts the agent functionality from the main CodeBolt library into a focused, reusable package.
3
+ A comprehensive TypeScript framework for building and managing AI agents with CodeBolt. This package provides multiple architectural patterns and utilities to meet different development needs, from simple composable agents to complex multi-step workflows.
4
4
 
5
- ## Features
5
+ ## 🚀 Quick Start
6
6
 
7
- - **Agent Class**: Core agent functionality for managing conversations with LLMs
8
- - **Message Builders**: Utilities for building user messages, system prompts, and task instructions
9
- - **Prompt Management**: Advanced prompt building and management capabilities
10
- - **LLM Output Handling**: Processing and managing LLM responses and tool executions
11
- - **Follow-up Questions**: Generate contextual follow-up questions for conversations
7
+ ```typescript
8
+ import { ComposableAgent, createTool } from '@codebolt/agent/composable';
9
+ import { z } from 'zod';
10
+
11
+ // Create a simple weather tool
12
+ const weatherTool = createTool({
13
+ id: 'get-weather',
14
+ description: 'Get current weather for a location',
15
+ inputSchema: z.object({ location: z.string() }),
16
+ outputSchema: z.object({ temperature: z.number(), conditions: z.string() }),
17
+ execute: async ({ context }) => {
18
+ return await getWeatherAPI(context.location);
19
+ },
20
+ });
21
+
22
+ // Create and run agent
23
+ const agent = new ComposableAgent({
24
+ name: 'Weather Agent',
25
+ instructions: 'You are a helpful weather assistant.',
26
+ model: 'gpt-4o-mini',
27
+ tools: { weatherTool },
28
+ memory: createCodeBoltAgentMemory('weather_agent')
29
+ });
30
+
31
+ const result = await agent.execute('What is the weather in New York?');
32
+ ```
33
+
34
+ ## ✨ Key Features
35
+
36
+ - **Multiple Patterns**: Choose between Composable, Builder, and Processor patterns
37
+ - **Type Safety**: Full TypeScript support with Zod validation
38
+ - **Memory Management**: Persistent conversation storage with CodeBolt integration
39
+ - **Tool System**: Extensible tool framework with validation
40
+ - **Workflow Orchestration**: Multi-step agent processes with conditional logic
41
+ - **Model Agnostic**: Support for OpenAI, Anthropic, Ollama, and more
42
+ - **Stream Support**: Real-time streaming responses
12
43
 
13
- ## Installation
44
+ ## 📦 Installation
14
45
 
15
46
  ```bash
16
47
  npm install @codebolt/agent
17
48
  ```
18
49
 
19
- ## Usage
50
+ ## 📖 Documentation
20
51
 
21
- ### Basic Agent Setup
52
+ **📚 [View Complete Documentation](./DOCUMENTATION.md)** - Comprehensive guide with examples, API reference, and best practices
22
53
 
23
- ```typescript
24
- import { Agent, SystemPrompt, TaskInstruction } from '@codebolt/agent';
54
+ ### Quick Links
55
+ - [Architectural Patterns](./DOCUMENTATION.md#architectural-patterns) - Choose the right pattern for your use case
56
+ - [API Reference](./API_REFERENCE.md) - Complete API documentation
57
+ - [Examples](./EXAMPLES.md) - Real-world usage examples and tutorials
58
+ - [Best Practices](./DOCUMENTATION.md#best-practices) - Tips for optimal agent development
59
+ - [Migration Guide](./DOCUMENTATION.md#migration-guide) - Upgrading from previous versions
60
+
61
+ ## 🎯 Architecture Patterns
25
62
 
26
- // Create a system prompt
27
- const systemPrompt = new SystemPrompt();
28
- await systemPrompt.loadPrompt('./prompts/system.yaml');
63
+ ### Composable Pattern (Recommended)
64
+ **Best for**: Rapid prototyping, simple agents, beginners
29
65
 
30
- // Create a task instruction
31
- const taskInstruction = new TaskInstruction();
32
- await taskInstruction.loadInstruction('./tasks/coding-task.yaml');
66
+ ```typescript
67
+ import { ComposableAgent, createTool, createCodeBoltAgentMemory } from '@codebolt/agent/composable';
33
68
 
34
- // Initialize agent
35
- const agent = new Agent([], systemPrompt);
69
+ const agent = new ComposableAgent({
70
+ name: 'My Agent',
71
+ instructions: 'You are a helpful assistant.',
72
+ model: 'gpt-4o-mini',
73
+ tools: { myTool },
74
+ memory: createCodeBoltAgentMemory('agent_id')
75
+ });
36
76
 
37
- // Run the agent on a task
38
- const result = await agent.runAgent(taskInstruction);
77
+ const result = await agent.execute('Help me with this task');
39
78
  ```
40
79
 
41
- ### Building User Messages
80
+ ### Builder Pattern
81
+ **Best for**: Complex workflows, fine-grained control
42
82
 
43
83
  ```typescript
44
- import { UserMessage } from '@codebolt/agent-utils';
84
+ import { Agent, InitialPromptBuilder, LLMOutputHandler } from '@codebolt/agent/builder';
45
85
 
46
- const userMessage = new UserMessage();
47
- await userMessage.addMessage("Please help me with my code");
48
- await userMessage.addFileContent("./src/main.ts");
86
+ const promptBuilder = new InitialPromptBuilder(userMessage)
87
+ .addSystemInstructions("You are a coding assistant")
88
+ .addFile("./src/main.ts")
89
+ .addTaskDetails("Fix compilation errors");
90
+
91
+ const prompt = await promptBuilder.build();
92
+ const agent = new Agent(tools, systemPrompt);
93
+ const result = await agent.runAgent(prompt);
49
94
  ```
50
95
 
51
- ### Advanced Prompt Building
96
+ ### Processor Pattern
97
+ **Best for**: Advanced customization, specialized requirements
52
98
 
53
99
  ```typescript
54
- import { InitialPromptBuilder } from '@codebolt/agent';
55
-
56
- const promptBuilder = new InitialPromptBuilder("Fix the bug in my application");
57
- promptBuilder
58
- .addSystemInstructions("You are a helpful coding assistant")
59
- .addFile("./src/problematic-file.ts")
60
- .addTaskDetails("Find and fix the TypeScript compilation errors");
100
+ import { BaseProcessor, AgentStep } from '@codebolt/agent/processor';
61
101
 
62
- const prompt = await promptBuilder.build();
102
+ class CustomProcessor extends BaseProcessor {
103
+ async process(messages: any[]): Promise<any> {
104
+ return this.executeCustomFlow(messages);
105
+ }
106
+ }
63
107
  ```
64
108
 
65
- ### LLM Output Handling
109
+ ## 🛠️ Available Exports
110
+
111
+ ### Composable Pattern
112
+ ```typescript
113
+ import {
114
+ ComposableAgent, createTool, createWorkflow,
115
+ Memory, createCodeBoltAgentMemory, MDocument
116
+ } from '@codebolt/agent/composable';
117
+ ```
66
118
 
119
+ ### Builder Pattern
67
120
  ```typescript
68
- import { LLMOutputHandler } from '@codebolt/agent';
121
+ import {
122
+ Agent, InitialPromptBuilder, LLMOutputHandler,
123
+ SystemPrompt, TaskInstruction, UserMessage
124
+ } from '@codebolt/agent/builder';
125
+ ```
69
126
 
70
- const outputHandler = new LLMOutputHandler();
71
- const result = await outputHandler.processLLMResponse(llmResponse, tools);
127
+ ### Processor Pattern
128
+ ```typescript
129
+ import {
130
+ BaseProcessor, AgentStep, BaseTool,
131
+ ChatCompressionProcessor, LoopDetectionProcessor
132
+ } from '@codebolt/agent/processor';
72
133
  ```
73
134
 
74
- ## API Reference
135
+ ## 🏗️ Workflow System
75
136
 
76
- ### Classes
137
+ Create complex multi-agent workflows:
77
138
 
78
- - `Agent` - Core agent for managing LLM conversations and tool executions
79
- - `UserMessage` - Builder for user messages with file content support
80
- - `SystemPrompt` - Management of system prompts from YAML files
81
- - `TaskInstruction` - Handling of task instructions and metadata
82
- - `InitialPromptBuilder` - Fluent interface for building complex prompts
83
- - `FollowUpPromptBuilder` - Generate follow-up questions for conversations
84
- - `LLMOutputHandler` - Process LLM responses and handle tool executions
139
+ ```typescript
140
+ const workflow = createWorkflow({
141
+ name: 'Content Pipeline',
142
+ steps: [
143
+ createAgentStep({
144
+ id: 'research',
145
+ agent: researchAgent,
146
+ messageTemplate: 'Research: {{topic}}'
147
+ }),
148
+ createAgentStep({
149
+ id: 'write',
150
+ agent: writingAgent,
151
+ messageTemplate: 'Write article: {{researchData}}'
152
+ })
153
+ ]
154
+ });
155
+
156
+ const result = await workflow.execute({ topic: 'AI Ethics' });
157
+ ```
85
158
 
86
- ### Types
159
+ ## 🧠 Memory & Storage
87
160
 
88
- The package exports comprehensive TypeScript types for all interfaces, including:
89
- - `Message`, `ToolResult`, `ToolDetails`
90
- - `OpenAIMessage`, `OpenAITool`, `ConversationEntry`
91
- - `UserMessageContent`, `CodeboltAPI`
92
- - `MCPTool`, `InitialUserMessage`
161
+ Integrated with CodeBolt's storage system:
93
162
 
94
- ## Dependencies
163
+ ```typescript
164
+ // Agent-scoped persistent storage
165
+ const agentMemory = createCodeBoltAgentMemory('my_agent');
95
166
 
96
- This package depends on `@codebolt/codeboltjs` for core functionality like file system operations, LLM communication, and tool execution.
167
+ // Project-scoped storage
168
+ const projectMemory = createCodeBoltProjectMemory('project_agent');
97
169
 
98
- ## Development
170
+ // Fast access memory database
171
+ const dbMemory = createCodeBoltDbMemory('cache_agent');
172
+ ```
173
+
174
+ ## 🔧 Development
99
175
 
100
176
  ```bash
101
177
  # Install dependencies
@@ -104,17 +180,32 @@ npm install
104
180
  # Build the project
105
181
  npm run build
106
182
 
107
- # Run in development mode
183
+ # Development mode
108
184
  npm run dev
109
185
 
110
- # Clean build artifacts
111
- npm run clean
186
+ # Run tests
187
+ npm run test
188
+
189
+ # Lint code
190
+ npm run lint
112
191
  ```
113
192
 
114
- ## License
193
+ ## 📋 Pattern Comparison
194
+
195
+ | Pattern | Complexity | Use Case | Learning Curve |
196
+ |---------|------------|----------|----------------|
197
+ | **Composable** | Low | Rapid prototyping, simple agents | Low |
198
+ | **Builder** | Medium | Complex workflows, custom logic | Medium |
199
+ | **Processor** | High | Advanced customization | High |
200
+
201
+ ## 🤝 Contributing
202
+
203
+ See our [Contributing Guide](./DOCUMENTATION.md#contributing) for development setup, coding standards, and submission guidelines.
204
+
205
+ ## 📄 License
115
206
 
116
- MIT
207
+ MIT - See the main CodeBolt repository for details.
117
208
 
118
- ## Contributing
209
+ ---
119
210
 
120
- Please see the main CodeBolt repository for contribution guidelines.
211
+ **📚 [Complete Documentation](./DOCUMENTATION.md)** | **🐛 [Report Issues](https://github.com/codeboltai/codeboltjs/issues)** | **💬 [Join Community](https://discord.gg/codebolt)**
@@ -0,0 +1,86 @@
1
+ import { SystemPrompt } from "./systemprompt";
2
+ import { TaskInstruction } from "./taskInstruction";
3
+ /**
4
+ * Agent class that manages conversations with LLMs and tool executions.
5
+ * Handles the conversation flow, tool calls, and task completions.
6
+ */
7
+ declare class Agent {
8
+ /** Available tools for the agent to use */
9
+ private tools;
10
+ /** Full conversation history for API calls */
11
+ private apiConversationHistory;
12
+ /** Maximum number of conversation turns (0 means unlimited) */
13
+ private maxRun;
14
+ /** System prompt that provides instructions to the model */
15
+ private systemPrompt;
16
+ /** Messages from the user */
17
+ private userMessage;
18
+ /** The next user message to be added to the conversation */
19
+ private nextUserMessage;
20
+ /**
21
+ * Creates a new Agent instance.
22
+ *
23
+ * @param tools - The tools available to the agent
24
+ * @param systemPrompt - The system prompt providing instructions to the LLM
25
+ * @param maxRun - Maximum number of conversation turns (0 means unlimited)
26
+ */
27
+ constructor(tools: any | undefined, systemPrompt: SystemPrompt, maxRun?: number);
28
+ /**
29
+ * Runs the agent on a specific task until completion or max runs reached.
30
+ *
31
+ * @param task - The task instruction to be executed
32
+ * @param successCondition - Optional function to determine if the task is successful
33
+ * @returns Promise with success status, error (if any), and the last assistant message
34
+ */
35
+ run(task: TaskInstruction, successCondition?: () => boolean): Promise<{
36
+ success: boolean;
37
+ error: string | null;
38
+ message: string | null;
39
+ }>;
40
+ /**
41
+ * Attempts to make a request to the LLM with conversation history and tools.
42
+ *
43
+ * @param apiConversationHistory - The current conversation history
44
+ * @param tools - The tools available to the LLM
45
+ * @returns Promise with the LLM response
46
+ */
47
+ private attemptLlmRequest;
48
+ /**
49
+ * Executes a tool with given name and input.
50
+ *
51
+ * @param toolName - The name of the tool to execute
52
+ * @param toolInput - The input parameters for the tool
53
+ * @returns Promise with tuple [userRejected, result]
54
+ */
55
+ private executeTool;
56
+ /**
57
+ * Starts a sub-agent to handle a specific task.
58
+ *
59
+ * @param agentName - The name of the sub-agent to start
60
+ * @param params - Parameters for the sub-agent
61
+ * @returns Promise with tuple [userRejected, result]
62
+ */
63
+ private startSubAgent;
64
+ /**
65
+ * Extracts tool details from a tool call object.
66
+ *
67
+ * @param tool - The tool call object from the LLM response
68
+ * @returns ToolDetails object with name, input, and ID
69
+ */
70
+ private getToolDetail;
71
+ /**
72
+ * Creates a tool result object from the tool execution response.
73
+ *
74
+ * @param tool_call_id - The ID of the tool call
75
+ * @param content - The content returned by the tool
76
+ * @returns ToolResult object
77
+ */
78
+ private getToolResult;
79
+ /**
80
+ * Fallback method for API requests in case of failures.
81
+ *
82
+ * @throws Error API request fallback not implemented
83
+ */
84
+ private attemptApiRequest;
85
+ }
86
+ export { Agent };