agentic-qe 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/.claude/agents/qe-code-complexity.md +291 -0
  2. package/.claude/settings.json +2 -2
  3. package/CHANGELOG.md +37 -0
  4. package/README.md +27 -2
  5. package/dist/agents/BaseAgent.d.ts +6 -2
  6. package/dist/agents/BaseAgent.d.ts.map +1 -1
  7. package/dist/agents/BaseAgent.js +62 -51
  8. package/dist/agents/BaseAgent.js.map +1 -1
  9. package/dist/agents/CodeComplexityAnalyzerAgent.d.ts +139 -0
  10. package/dist/agents/CodeComplexityAnalyzerAgent.d.ts.map +1 -0
  11. package/dist/agents/CodeComplexityAnalyzerAgent.js +403 -0
  12. package/dist/agents/CodeComplexityAnalyzerAgent.js.map +1 -0
  13. package/dist/agents/FleetCommanderAgent.js +2 -2
  14. package/dist/agents/FleetCommanderAgent.js.map +1 -1
  15. package/dist/agents/QualityGateAgent.d.ts +5 -5
  16. package/dist/agents/QualityGateAgent.d.ts.map +1 -1
  17. package/dist/agents/QualityGateAgent.js +33 -19
  18. package/dist/agents/QualityGateAgent.js.map +1 -1
  19. package/dist/agents/TestDataArchitectAgent.d.ts +9 -0
  20. package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -1
  21. package/dist/agents/TestDataArchitectAgent.js +96 -2
  22. package/dist/agents/TestDataArchitectAgent.js.map +1 -1
  23. package/dist/agents/TestGeneratorAgent.d.ts +23 -1
  24. package/dist/agents/TestGeneratorAgent.d.ts.map +1 -1
  25. package/dist/agents/TestGeneratorAgent.js +279 -54
  26. package/dist/agents/TestGeneratorAgent.js.map +1 -1
  27. package/dist/agents/coordination/AgentCoordinator.d.ts +98 -0
  28. package/dist/agents/coordination/AgentCoordinator.d.ts.map +1 -0
  29. package/dist/agents/coordination/AgentCoordinator.js +196 -0
  30. package/dist/agents/coordination/AgentCoordinator.js.map +1 -0
  31. package/dist/agents/lifecycle/AgentLifecycleManager.d.ts +107 -0
  32. package/dist/agents/lifecycle/AgentLifecycleManager.d.ts.map +1 -0
  33. package/dist/agents/lifecycle/AgentLifecycleManager.js +220 -0
  34. package/dist/agents/lifecycle/AgentLifecycleManager.js.map +1 -0
  35. package/dist/agents/memory/AgentMemoryService.d.ts +173 -0
  36. package/dist/agents/memory/AgentMemoryService.d.ts.map +1 -0
  37. package/dist/agents/memory/AgentMemoryService.js +297 -0
  38. package/dist/agents/memory/AgentMemoryService.js.map +1 -0
  39. package/dist/cli/commands/init.d.ts.map +1 -1
  40. package/dist/cli/commands/init.js +45 -3
  41. package/dist/cli/commands/init.js.map +1 -1
  42. package/dist/cli/commands/skills/index.d.ts +4 -0
  43. package/dist/cli/commands/skills/index.d.ts.map +1 -1
  44. package/dist/cli/commands/skills/index.js +8 -2
  45. package/dist/cli/commands/skills/index.js.map +1 -1
  46. package/dist/core/memory/SwarmMemoryManager.d.ts +2 -1
  47. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -1
  48. package/dist/core/memory/SwarmMemoryManager.js +4 -1
  49. package/dist/core/memory/SwarmMemoryManager.js.map +1 -1
  50. package/dist/core/memory/dao/AccessControlDAO.d.ts +66 -0
  51. package/dist/core/memory/dao/AccessControlDAO.d.ts.map +1 -0
  52. package/dist/core/memory/dao/AccessControlDAO.js +140 -0
  53. package/dist/core/memory/dao/AccessControlDAO.js.map +1 -0
  54. package/dist/core/memory/dao/BaseDAO.d.ts +34 -0
  55. package/dist/core/memory/dao/BaseDAO.d.ts.map +1 -0
  56. package/dist/core/memory/dao/BaseDAO.js +34 -0
  57. package/dist/core/memory/dao/BaseDAO.js.map +1 -0
  58. package/dist/core/memory/dao/BlackboardDAO.d.ts +90 -0
  59. package/dist/core/memory/dao/BlackboardDAO.d.ts.map +1 -0
  60. package/dist/core/memory/dao/BlackboardDAO.js +223 -0
  61. package/dist/core/memory/dao/BlackboardDAO.js.map +1 -0
  62. package/dist/core/memory/dao/EventDAO.d.ts +83 -0
  63. package/dist/core/memory/dao/EventDAO.d.ts.map +1 -0
  64. package/dist/core/memory/dao/EventDAO.js +177 -0
  65. package/dist/core/memory/dao/EventDAO.js.map +1 -0
  66. package/dist/core/memory/dao/MemoryEntryDAO.d.ts +57 -0
  67. package/dist/core/memory/dao/MemoryEntryDAO.d.ts.map +1 -0
  68. package/dist/core/memory/dao/MemoryEntryDAO.js +159 -0
  69. package/dist/core/memory/dao/MemoryEntryDAO.js.map +1 -0
  70. package/dist/core/memory/dao/WorkflowDAO.d.ts +85 -0
  71. package/dist/core/memory/dao/WorkflowDAO.d.ts.map +1 -0
  72. package/dist/core/memory/dao/WorkflowDAO.js +182 -0
  73. package/dist/core/memory/dao/WorkflowDAO.js.map +1 -0
  74. package/dist/core/memory/services/AccessControlService.d.ts +123 -0
  75. package/dist/core/memory/services/AccessControlService.d.ts.map +1 -0
  76. package/dist/core/memory/services/AccessControlService.js +249 -0
  77. package/dist/core/memory/services/AccessControlService.js.map +1 -0
  78. package/dist/core/memory/services/MemoryStoreService.d.ts +69 -0
  79. package/dist/core/memory/services/MemoryStoreService.d.ts.map +1 -0
  80. package/dist/core/memory/services/MemoryStoreService.js +214 -0
  81. package/dist/core/memory/services/MemoryStoreService.js.map +1 -0
  82. package/dist/mcp/handlers/base-handler.d.ts.map +1 -1
  83. package/dist/mcp/handlers/base-handler.js +4 -1
  84. package/dist/mcp/handlers/base-handler.js.map +1 -1
  85. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts +11 -1
  86. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts.map +1 -1
  87. package/dist/mcp/handlers/prediction/regression-risk-analyze.js +63 -8
  88. package/dist/mcp/handlers/prediction/regression-risk-analyze.js.map +1 -1
  89. package/dist/mcp/handlers/quality-analyze.d.ts +7 -1
  90. package/dist/mcp/handlers/quality-analyze.d.ts.map +1 -1
  91. package/dist/mcp/handlers/quality-analyze.js +18 -1
  92. package/dist/mcp/handlers/quality-analyze.js.map +1 -1
  93. package/dist/mcp/handlers/test-generate.d.ts.map +1 -1
  94. package/dist/mcp/handlers/test-generate.js +24 -8
  95. package/dist/mcp/handlers/test-generate.js.map +1 -1
  96. package/dist/mcp/services/AgentRegistry.d.ts +5 -0
  97. package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
  98. package/dist/mcp/services/AgentRegistry.js +19 -0
  99. package/dist/mcp/services/AgentRegistry.js.map +1 -1
  100. package/dist/utils/__mocks__/Database.d.ts +64 -0
  101. package/dist/utils/__mocks__/Database.d.ts.map +1 -0
  102. package/dist/utils/__mocks__/Database.js +134 -0
  103. package/dist/utils/__mocks__/Database.js.map +1 -0
  104. package/package.json +5 -1
@@ -0,0 +1,291 @@
1
+ ---
2
+ name: qe-code-complexity
3
+ version: 1.0.0
4
+ description: Educational code complexity analyzer demonstrating the Agentic QE Fleet architecture
5
+ tags: [quality-engineering, complexity-analysis, refactoring, learning-example]
6
+ capabilities: [complexity-analysis, refactoring-recommendations, pattern-detection]
7
+ type: quality-analyzer
8
+ ---
9
+
10
+ # QE Code Complexity Analyzer
11
+
12
+ ## Overview
13
+
14
+ The Code Complexity Analyzer is an **educational agent** that demonstrates the complete Agentic QE Fleet architecture. It analyzes code complexity metrics and provides AI-powered refactoring recommendations.
15
+
16
+ **Purpose**: Learning tool to understand how agents work in the AQE fleet.
17
+
18
+ ## Capabilities
19
+
20
+ ### 1. Complexity Analysis
21
+ - **Cyclomatic Complexity**: Measures decision point density
22
+ - **Cognitive Complexity**: Accounts for nesting and control flow
23
+ - **File Size Analysis**: Identifies overly large files
24
+ - **Function Metrics**: Tracks function count and average complexity
25
+
26
+ ### 2. Refactoring Recommendations
27
+ - AI-powered suggestions based on detected patterns
28
+ - Severity-based prioritization (low, medium, high, critical)
29
+ - Specific actionable advice (e.g., "Extract Method", "Reduce Nesting")
30
+
31
+ ### 3. Quality Scoring
32
+ - Holistic quality score (0-100)
33
+ - Issue-based deductions
34
+ - Helps prioritize refactoring efforts
35
+
36
+ ## Key Learning Concepts
37
+
38
+ ### BaseAgent Pattern
39
+ ```typescript
40
+ // All agents extend BaseAgent
41
+ export class CodeComplexityAnalyzerAgent extends BaseAgent {
42
+ // Define capabilities in constructor
43
+ constructor(config: CodeComplexityConfig) {
44
+ super({
45
+ ...config,
46
+ type: QEAgentType.QUALITY_ANALYZER,
47
+ capabilities: [/* ... */]
48
+ });
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### Lifecycle Hooks
54
+ ```typescript
55
+ // Pre-task: Load context before work
56
+ protected async onPreTask(data: { assignment: any }): Promise<void> {
57
+ const history = await this.memoryStore.retrieve('aqe/complexity/.../history');
58
+ // Use historical data to improve analysis
59
+ }
60
+
61
+ // Post-task: Store results and coordinate
62
+ protected async onPostTask(data: PostTaskData): Promise<void> {
63
+ await this.memoryStore.store('aqe/complexity/.../results', data.result);
64
+ this.eventBus.emit('complexity:analysis:completed', { ... });
65
+ }
66
+
67
+ // Error handling: Learn from failures
68
+ protected async onTaskError(data: { assignment: any; error: Error }): Promise<void> {
69
+ await this.memoryStore.store('aqe/complexity/.../errors/...', { ... });
70
+ }
71
+ ```
72
+
73
+ ### Memory System
74
+ ```typescript
75
+ // Store results for other agents
76
+ await this.memoryStore.store(
77
+ 'aqe/complexity/${agentId}/latest-result',
78
+ result,
79
+ 86400 // 24 hour TTL
80
+ );
81
+
82
+ // Retrieve for coordination
83
+ const previous = await this.memoryStore.retrieve(
84
+ 'aqe/complexity/${agentId}/history'
85
+ );
86
+ ```
87
+
88
+ ### Event-Driven Architecture
89
+ ```typescript
90
+ // Emit events for coordination
91
+ this.eventBus.emit('complexity:analysis:completed', {
92
+ agentId: this.agentId,
93
+ result: analysisResult,
94
+ timestamp: new Date()
95
+ });
96
+
97
+ // Other agents can subscribe
98
+ eventBus.on('complexity:analysis:completed', (event) => {
99
+ // Test generator could prioritize complex code
100
+ // Coverage analyzer could focus on complex functions
101
+ });
102
+ ```
103
+
104
+ ## Usage Examples
105
+
106
+ ### From Claude Code CLI
107
+
108
+ ```bash
109
+ # Analyze a single file
110
+ claude "Use qe-code-complexity to analyze src/services/order-processor.ts"
111
+
112
+ # Analyze multiple files
113
+ claude "Run complexity analysis on all files in src/services/"
114
+
115
+ # Get refactoring recommendations
116
+ claude "Analyze src/utils/validator.ts and suggest refactorings"
117
+ ```
118
+
119
+ ### Via TypeScript
120
+
121
+ ```typescript
122
+ import { CodeComplexityAnalyzerAgent } from './agents/CodeComplexityAnalyzerAgent';
123
+
124
+ // Initialize agent
125
+ const agent = new CodeComplexityAnalyzerAgent({
126
+ type: QEAgentType.QUALITY_ANALYZER,
127
+ capabilities: [],
128
+ context: { /* ... */ },
129
+ memoryStore,
130
+ eventBus,
131
+ thresholds: {
132
+ cyclomaticComplexity: 10,
133
+ cognitiveComplexity: 15,
134
+ linesOfCode: 300
135
+ },
136
+ enableRecommendations: true
137
+ });
138
+
139
+ await agent.initialize();
140
+
141
+ // Analyze code
142
+ const result = await agent.analyzeComplexity({
143
+ files: [{
144
+ path: 'complex.ts',
145
+ content: sourceCode,
146
+ language: 'typescript'
147
+ }]
148
+ });
149
+
150
+ console.log('Quality Score:', result.score);
151
+ console.log('Issues:', result.issues);
152
+ console.log('Recommendations:', result.recommendations);
153
+ ```
154
+
155
+ ## Configuration
156
+
157
+ ### Thresholds
158
+
159
+ Customize complexity thresholds:
160
+
161
+ ```typescript
162
+ {
163
+ thresholds: {
164
+ cyclomaticComplexity: 10, // Default: 10
165
+ cognitiveComplexity: 15, // Default: 15
166
+ linesOfCode: 300 // Default: 300
167
+ }
168
+ }
169
+ ```
170
+
171
+ ### Features
172
+
173
+ ```typescript
174
+ {
175
+ enableRecommendations: true, // Default: true
176
+ enableLearning: true // Default: false (demo uses false)
177
+ }
178
+ ```
179
+
180
+ ## Integration with Other Agents
181
+
182
+ ### Test Generator
183
+ The test-generator agent can use complexity analysis to:
184
+ - Prioritize complex functions for testing
185
+ - Generate more comprehensive tests for high-complexity code
186
+ - Focus on edge cases in nested logic
187
+
188
+ ```typescript
189
+ eventBus.on('complexity:analysis:completed', async (event) => {
190
+ if (event.result.issues.some(i => i.severity === 'critical')) {
191
+ // Test generator: Create extra tests for critical complexity
192
+ await testGeneratorAgent.generateTests({
193
+ focusAreas: event.result.issues
194
+ .filter(i => i.severity === 'critical')
195
+ .map(i => i.file)
196
+ });
197
+ }
198
+ });
199
+ ```
200
+
201
+ ### Coverage Analyzer
202
+ The coverage-analyzer can use complexity data to:
203
+ - Ensure high-complexity code has high coverage
204
+ - Identify risk areas (high complexity + low coverage)
205
+
206
+ ### Quality Gate
207
+ The quality-gate can use complexity metrics as criteria:
208
+ - Fail builds with critical complexity issues
209
+ - Track complexity trends over time
210
+ - Prevent complexity regressions
211
+
212
+ ## Example Output
213
+
214
+ ```
215
+ Quality Score: 65/100
216
+
217
+ ⚠️ Issues Detected:
218
+ 1. [HIGH] cyclomatic
219
+ Current: 23, Threshold: 10
220
+ Consider breaking down complex logic into smaller functions
221
+
222
+ 2. [MEDIUM] cognitive
223
+ Current: 18, Threshold: 15
224
+ Reduce nesting levels and simplify control flow
225
+
226
+ 💡 Recommendations:
227
+ 1. Apply Extract Method refactoring to reduce cyclomatic complexity
228
+ 2. Use early returns to reduce nesting levels
229
+ 3. Extract nested loops into separate methods
230
+ ```
231
+
232
+ ## Learning Objectives
233
+
234
+ By studying this agent, you'll learn:
235
+
236
+ 1. ✅ **BaseAgent Pattern**: How to extend and customize agents
237
+ 2. ✅ **Lifecycle Hooks**: Pre-task, post-task, and error handling
238
+ 3. ✅ **Memory System**: Storing and retrieving agent data
239
+ 4. ✅ **Event System**: Coordinating multiple agents
240
+ 5. ✅ **Testing Patterns**: Comprehensive test coverage
241
+ 6. ✅ **Agent Coordination**: How agents work together
242
+
243
+ ## Running the Example
244
+
245
+ ```bash
246
+ # Run the demo
247
+ npx ts-node examples/complexity-analysis/demo.ts
248
+
249
+ # Run tests
250
+ npm test tests/agents/CodeComplexityAnalyzerAgent.test.ts
251
+ ```
252
+
253
+ ## Architecture Insights
254
+
255
+ ### Memory Namespace
256
+ - `aqe/complexity/${agentId}/current-request` - Active analysis request
257
+ - `aqe/complexity/${agentId}/latest-result` - Most recent result
258
+ - `aqe/complexity/${agentId}/history` - Historical analyses (last 100)
259
+ - `aqe/complexity/${agentId}/errors/*` - Error tracking
260
+
261
+ ### Events Emitted
262
+ - `complexity:analysis:completed` - When analysis finishes successfully
263
+ - `complexity:analysis:stored` - When results are persisted
264
+
265
+ ### Capabilities Provided
266
+ - `complexity-analysis` - Core analysis functionality
267
+ - `refactoring-recommendations` - AI-powered suggestions
268
+ - `pattern-detection` - Complex code pattern recognition
269
+
270
+ ## Next Steps
271
+
272
+ After understanding this agent, explore:
273
+ - **TestGeneratorAgent**: See how it generates tests
274
+ - **CoverageAnalyzerAgent**: Learn about O(log n) gap detection
275
+ - **FleetManager**: Understand multi-agent coordination
276
+ - **LearningEngine**: Discover how agents improve over time
277
+
278
+ ## Resources
279
+
280
+ - **Source Code**: `src/agents/CodeComplexityAnalyzerAgent.ts`
281
+ - **Tests**: `tests/agents/CodeComplexityAnalyzerAgent.test.ts`
282
+ - **Demo**: `examples/complexity-analysis/demo.ts`
283
+ - **BaseAgent**: `src/agents/BaseAgent.ts`
284
+
285
+ ---
286
+
287
+ **Educational Agent**: This agent is designed for learning. For production complexity analysis, consider:
288
+ - ESLint with complexity rules
289
+ - SonarQube
290
+ - CodeClimate
291
+ - Commercial static analysis tools
@@ -145,9 +145,9 @@
145
145
  ]
146
146
  },
147
147
  "includeCoAuthoredBy": true,
148
- "enabledMcpjsonServers": ["claude-flow", "ruv-swarm"],
148
+ "enabledMcpjsonServers": ["claude-flow", "ruv-swarm", "agentic-qe"],
149
149
  "statusLine": {
150
150
  "type": "command",
151
- "command": ".claude/statusline-agentdb.sh"
151
+ "command": ".claude/statusline-command.sh"
152
152
  }
153
153
  }
package/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ All notable changes to the Agentic QE project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.6] - 2025-10-30
9
+
10
+ ### 🔒 Security & UX Improvements
11
+
12
+ #### Security Fixes
13
+ - **eval() Removal**: Replaced unsafe `eval()` in TestDataArchitectAgent with safe expression evaluator
14
+ - Supports comparison operators (===, !==, ==, !=, >=, <=, >, <)
15
+ - Supports logical operators (&&, ||)
16
+ - Eliminates arbitrary code execution vulnerability
17
+ - File: `src/agents/TestDataArchitectAgent.ts`
18
+
19
+ #### UX Enhancements
20
+ - **CLAUDE.md Append Strategy**: User-friendly placement of AQE instructions
21
+ - Interactive mode: Prompts user to choose prepend or append
22
+ - `--yes` mode: Defaults to append (less disruptive)
23
+ - Clear visual separator (---) between sections
24
+ - Backup existing CLAUDE.md automatically
25
+ - File: `src/cli/commands/init.ts`
26
+
27
+ - **CLI Skills Count Fix**: Accurate display of installed skills
28
+ - Dynamic counting instead of hardcoded values
29
+ - Now shows correct "34/34" instead of "8/17"
30
+ - Future-proof (auto-updates when skills added)
31
+ - File: `src/cli/commands/skills/index.ts`
32
+
33
+ #### Additional Improvements
34
+ - **CodeComplexityAnalyzerAgent**: Cherry-picked from PR #22 with full integration
35
+ - **TypeScript Compilation**: All errors resolved (0 compilation errors)
36
+ - **Documentation**: Comprehensive fix reports and verification
37
+
38
+ ### Testing
39
+ - ✅ TypeScript compilation: 0 errors
40
+ - ✅ All three fixes verified and working
41
+ - ✅ Backward compatible changes only
42
+
43
+ ---
44
+
8
45
  ## [1.3.5] - 2025-10-27
9
46
 
10
47
  ### ✨ Features Complete - Production Ready Release
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
8
8
  [![Node.js](https://img.shields.io/badge/Node.js-20+-green.svg)](https://nodejs.org/)
9
9
 
10
- **Version 1.3.5** | [Changelog](CHANGELOG.md) | [Issues](https://github.com/proffesor-for-testing/agentic-qe/issues) | [Discussions](https://github.com/proffesor-for-testing/agentic-qe/discussions)
10
+ **Version 1.3.6** | [Changelog](CHANGELOG.md) | [Issues](https://github.com/proffesor-for-testing/agentic-qe/issues) | [Discussions](https://github.com/proffesor-for-testing/agentic-qe/discussions)
11
11
 
12
12
  > Enterprise-grade test automation with AI learning, comprehensive skills library (34 QE skills), and 85.7% cost savings through intelligent model routing.
13
13
 
@@ -30,7 +30,7 @@ cd your-project
30
30
  aqe init
31
31
 
32
32
  # Add MCP server to Claude Code (optional)
33
- claude mcp add agentic-qe npx -y agentic-qe mcp:start
33
+ claude mcp add agentic-qe npx aqe-mcp
34
34
 
35
35
  # Verify connection
36
36
  claude mcp list
@@ -501,6 +501,31 @@ Model Usage:
501
501
 
502
502
  ## 📝 Recent Changes
503
503
 
504
+ ### v1.3.6 (2025-10-30)
505
+ **Stability & Educational Release**
506
+
507
+ - ✅ **Fixed 16 critical TypeScript compilation errors** blocking production builds
508
+ - ✅ **Integrated CodeComplexityAnalyzerAgent** (educational example from PR #22 by @mondweep)
509
+ - ✅ **Zero functional regressions** - all core functionality tested and stable
510
+ - ✅ **Build stability improvements** - TypeScript compilation passing with 0 errors
511
+ - ✅ **BaseAgent property encapsulation** - proper lifecycle manager integration
512
+ - ✅ **Clean cherry-pick** from PR #22 with zero conflicts
513
+
514
+ **Technical Improvements**:
515
+ - BaseAgent property access patterns now use lifecycle manager accessors
516
+ - AccessControlDAO interface mapping corrected (`resourceId`, `owner` properties)
517
+ - Permission enum usage standardized (READ, WRITE, DELETE, SHARE)
518
+ - AgentLifecycleManager and AgentCoordinator properly integrated
519
+
520
+ **New Capabilities**:
521
+ - 📊 Code complexity analysis agent (cyclomatic & cognitive complexity)
522
+ - 🎯 Quality scoring system (0-100 scale)
523
+ - 🤖 AI-powered refactoring recommendations
524
+ - 📚 Complete BaseAgent pattern demonstration
525
+ - 📖 463-line architecture guide for learning
526
+
527
+ **Contributors**: @mondweep (CodeComplexityAnalyzerAgent), AQE Development Team
528
+
504
529
  ### v1.3.5 (2025-10-27) - Learning System Complete & Critical Policies
505
530
 
506
531
  **Phase 2 Features Complete:**
@@ -10,6 +10,9 @@ import { PerformanceTracker } from '../learning/PerformanceTracker';
10
10
  import { LearningEngine } from '../learning/LearningEngine';
11
11
  import { LearningConfig, StrategyRecommendation } from '../learning/types';
12
12
  import { AgentDBManager, AgentDBConfig } from '../core/memory/AgentDBManager';
13
+ import { AgentLifecycleManager } from './lifecycle/AgentLifecycleManager';
14
+ import { AgentCoordinator } from './coordination/AgentCoordinator';
15
+ import { AgentMemoryService } from './memory/AgentMemoryService';
13
16
  export interface BaseAgentConfig {
14
17
  id?: string;
15
18
  type: AgentType;
@@ -28,12 +31,10 @@ export interface BaseAgentConfig {
28
31
  }
29
32
  export declare abstract class BaseAgent extends EventEmitter {
30
33
  protected readonly agentId: AgentId;
31
- protected status: AgentStatus;
32
34
  protected readonly capabilities: Map<string, AgentCapability>;
33
35
  protected readonly context: AgentContext;
34
36
  protected readonly memoryStore: MemoryStore;
35
37
  protected readonly eventBus: EventEmitter;
36
- protected readonly eventHandlers: Map<string, EventHandler[]>;
37
38
  protected currentTask?: TaskAssignment;
38
39
  protected hookManager: VerificationHookManager;
39
40
  protected performanceTracker?: PerformanceTracker;
@@ -49,6 +50,9 @@ export declare abstract class BaseAgent extends EventEmitter {
49
50
  lastActivity: Date;
50
51
  };
51
52
  private taskStartTime?;
53
+ protected readonly lifecycleManager: AgentLifecycleManager;
54
+ protected readonly coordinator: AgentCoordinator;
55
+ protected readonly memoryService: AgentMemoryService;
52
56
  constructor(config: BaseAgentConfig);
53
57
  /**
54
58
  * Initialize the agent - must be called after construction
@@ -1 +1 @@
1
- {"version":3,"file":"BaseAgent.d.ts","sourceRoot":"","sources":["../../src/agents/BaseAgent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,OAAO,EACP,WAAW,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GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1E,iBAAiB,IAAI,SAAS,EAAE,CAAC;IACjC,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,EAAE,CAAC;CACrD;AAED,8BAAsB,gBAAiB,YAAW,YAAY;IAC5D,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IAClF,QAAQ,CAAC,iBAAiB,IAAI,SAAS,EAAE;IACzC,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe,EAAE;CAC7D"}
@@ -15,11 +15,12 @@ const PerformanceTracker_1 = require("../learning/PerformanceTracker");
15
15
  const SwarmMemoryManager_1 = require("../core/memory/SwarmMemoryManager");
16
16
  const LearningEngine_1 = require("../learning/LearningEngine");
17
17
  const AgentDBManager_1 = require("../core/memory/AgentDBManager");
18
+ const AgentLifecycleManager_1 = require("./lifecycle/AgentLifecycleManager");
19
+ const AgentCoordinator_1 = require("./coordination/AgentCoordinator");
20
+ const AgentMemoryService_1 = require("./memory/AgentMemoryService");
18
21
  class BaseAgent extends events_1.EventEmitter {
19
22
  constructor(config) {
20
23
  super();
21
- this.status = types_1.AgentStatus.INITIALIZING;
22
- this.eventHandlers = new Map();
23
24
  this.performanceMetrics = {
24
25
  tasksCompleted: 0,
25
26
  averageExecutionTime: 0,
@@ -58,6 +59,17 @@ class BaseAgent extends events_1.EventEmitter {
58
59
  // Provides runtime validation and clear error messages for incompatible implementations
59
60
  const memoryAdapter = new MemoryStoreAdapter_1.MemoryStoreAdapter(this.memoryStore);
60
61
  this.hookManager = new hooks_1.VerificationHookManager(memoryAdapter);
62
+ // Initialize integrated service classes
63
+ this.lifecycleManager = new AgentLifecycleManager_1.AgentLifecycleManager(this.agentId);
64
+ this.coordinator = new AgentCoordinator_1.AgentCoordinator({
65
+ agentId: this.agentId,
66
+ eventBus: this.eventBus,
67
+ memoryStore: this.memoryStore
68
+ });
69
+ this.memoryService = new AgentMemoryService_1.AgentMemoryService({
70
+ agentId: this.agentId,
71
+ memoryStore: this.memoryStore
72
+ });
61
73
  this.setupEventHandlers();
62
74
  this.setupLifecycleHooks();
63
75
  }
@@ -69,36 +81,43 @@ class BaseAgent extends events_1.EventEmitter {
69
81
  */
70
82
  async initialize() {
71
83
  try {
72
- this.status = types_1.AgentStatus.INITIALIZING;
73
- // Execute pre-initialization hooks
74
- await this.executeHook('pre-initialization');
75
- // Load agent knowledge and state
76
- await this.loadKnowledge();
77
- await this.restoreState();
78
- // Initialize PerformanceTracker if learning is enabled
79
- if (this.enableLearning && this.memoryStore instanceof SwarmMemoryManager_1.SwarmMemoryManager) {
80
- this.performanceTracker = new PerformanceTracker_1.PerformanceTracker(this.agentId.id, this.memoryStore);
81
- await this.performanceTracker.initialize();
82
- // Initialize learning engine for Q-learning
83
- this.learningEngine = new LearningEngine_1.LearningEngine(this.agentId.id, this.memoryStore, this.learningConfig);
84
- await this.learningEngine.initialize();
85
- }
86
- // Initialize AgentDB if configured
87
- if (this.agentDBConfig) {
88
- await this.initializeAgentDB(this.agentDBConfig);
89
- }
90
- // Initialize agent-specific components
91
- await this.initializeComponents();
92
- // Execute post-initialization hooks
93
- await this.executeHook('post-initialization');
94
- this.status = types_1.AgentStatus.ACTIVE;
95
- this.emitEvent('agent.initialized', { agentId: this.agentId });
96
- // Report initialization to coordination system
97
- await this.reportStatus('initialized');
84
+ // Delegate lifecycle initialization to lifecycleManager
85
+ await this.lifecycleManager.initialize({
86
+ onPreInitialization: async () => {
87
+ await this.executeHook('pre-initialization');
88
+ },
89
+ onPostInitialization: async () => {
90
+ // Load agent knowledge and state
91
+ await this.loadKnowledge();
92
+ const savedState = await this.memoryService.restoreState();
93
+ if (savedState && savedState.performanceMetrics) {
94
+ this.performanceMetrics = { ...this.performanceMetrics, ...savedState.performanceMetrics };
95
+ }
96
+ // Initialize PerformanceTracker if learning is enabled
97
+ if (this.enableLearning && this.memoryStore instanceof SwarmMemoryManager_1.SwarmMemoryManager) {
98
+ this.performanceTracker = new PerformanceTracker_1.PerformanceTracker(this.agentId.id, this.memoryStore);
99
+ await this.performanceTracker.initialize();
100
+ // Initialize learning engine for Q-learning
101
+ this.learningEngine = new LearningEngine_1.LearningEngine(this.agentId.id, this.memoryStore, this.learningConfig);
102
+ await this.learningEngine.initialize();
103
+ }
104
+ // Initialize AgentDB if configured
105
+ if (this.agentDBConfig) {
106
+ await this.initializeAgentDB(this.agentDBConfig);
107
+ }
108
+ // Initialize agent-specific components
109
+ await this.initializeComponents();
110
+ // Execute post-initialization hooks
111
+ await this.executeHook('post-initialization');
112
+ this.coordinator.emitEvent('agent.initialized', { agentId: this.agentId });
113
+ // Report initialization to coordination system
114
+ await this.coordinator.reportStatus('initialized', this.performanceMetrics);
115
+ }
116
+ });
98
117
  }
99
118
  catch (error) {
100
- this.status = types_1.AgentStatus.ERROR;
101
- this.emitEvent('agent.error', { agentId: this.agentId, error });
119
+ this.lifecycleManager.markError(`Initialization failed: ${error}`);
120
+ this.coordinator.emitEvent('agent.error', { agentId: this.agentId, error });
102
121
  throw error;
103
122
  }
104
123
  }
@@ -111,13 +130,13 @@ class BaseAgent extends events_1.EventEmitter {
111
130
  // Validate task assignment
112
131
  this.validateTaskAssignment(assignment);
113
132
  this.currentTask = assignment;
114
- this.status = types_1.AgentStatus.ACTIVE;
133
+ this.lifecycleManager.markActive();
115
134
  // Execute pre-task hooks with verification
116
135
  const preTaskData = { assignment };
117
136
  await this.onPreTask(preTaskData);
118
137
  await this.executeHook('pre-task', preTaskData);
119
138
  // Broadcast task start
120
- await this.broadcastMessage('task-start', assignment);
139
+ await this.coordinator.broadcastMessage('task-start', assignment);
121
140
  // Execute the actual task
122
141
  const result = await this.performTask(assignment.task);
123
142
  // Execute post-task hooks with validation
@@ -127,15 +146,15 @@ class BaseAgent extends events_1.EventEmitter {
127
146
  // Update performance metrics
128
147
  this.updatePerformanceMetrics(startTime, true);
129
148
  // Store task completion in memory
130
- await this.storeTaskResult(assignment.id, result);
149
+ await this.memoryService.storeTaskResult(assignment.id, result);
131
150
  this.currentTask = undefined;
132
- this.status = types_1.AgentStatus.IDLE;
151
+ this.lifecycleManager.markIdle();
133
152
  return result;
134
153
  }
135
154
  catch (error) {
136
155
  this.updatePerformanceMetrics(startTime, false);
137
156
  this.currentTask = undefined;
138
- this.status = types_1.AgentStatus.ERROR;
157
+ this.lifecycleManager.markError(`Task execution failed: ${error}`);
139
158
  // Execute error hooks
140
159
  const errorData = {
141
160
  assignment,
@@ -151,7 +170,7 @@ class BaseAgent extends events_1.EventEmitter {
151
170
  */
152
171
  async terminate() {
153
172
  try {
154
- this.status = types_1.AgentStatus.TERMINATING;
173
+ this.lifecycleManager.setStatus(types_1.AgentStatus.TERMINATING);
155
174
  // Execute pre-termination hooks
156
175
  await this.executeHook('pre-termination');
157
176
  // Close AgentDB if enabled
@@ -163,22 +182,17 @@ class BaseAgent extends events_1.EventEmitter {
163
182
  await this.saveState();
164
183
  // Clean up agent-specific resources
165
184
  await this.cleanup();
166
- // Remove all event handlers from EventBus
167
- for (const [eventType, handlers] of this.eventHandlers.entries()) {
168
- for (const handler of handlers) {
169
- this.eventBus.off(eventType, handler.handler);
170
- }
171
- }
172
- this.eventHandlers.clear();
185
+ // Remove all event handlers from EventBus using coordinator
186
+ this.coordinator.clearAllHandlers();
173
187
  // Execute post-termination hooks
174
188
  await this.executeHook('post-termination');
175
- this.status = types_1.AgentStatus.TERMINATED;
189
+ this.lifecycleManager.setStatus(types_1.AgentStatus.TERMINATED);
176
190
  this.emitEvent('agent.terminated', { agentId: this.agentId });
177
191
  // Remove all listeners from this agent (EventEmitter)
178
192
  this.removeAllListeners();
179
193
  }
180
194
  catch (error) {
181
- this.status = types_1.AgentStatus.ERROR;
195
+ this.lifecycleManager.setStatus(types_1.AgentStatus.ERROR);
182
196
  throw error;
183
197
  }
184
198
  }
@@ -188,7 +202,7 @@ class BaseAgent extends events_1.EventEmitter {
188
202
  getStatus() {
189
203
  return {
190
204
  agentId: this.agentId,
191
- status: this.status,
205
+ status: this.lifecycleManager.getStatus(),
192
206
  currentTask: this.currentTask?.id,
193
207
  capabilities: Array.from(this.capabilities.keys()),
194
208
  performanceMetrics: { ...this.performanceMetrics }
@@ -325,10 +339,7 @@ class BaseAgent extends events_1.EventEmitter {
325
339
  * Register an event handler
326
340
  */
327
341
  registerEventHandler(handler) {
328
- const handlers = this.eventHandlers.get(handler.eventType) || [];
329
- handlers.push(handler);
330
- this.eventHandlers.set(handler.eventType, handlers);
331
- this.eventBus.on(handler.eventType, handler.handler);
342
+ this.coordinator.registerEventHandler(handler);
332
343
  }
333
344
  /**
334
345
  * Emit an event
@@ -763,7 +774,7 @@ class BaseAgent extends events_1.EventEmitter {
763
774
  setupLifecycleHooks() {
764
775
  // Setup default lifecycle behavior
765
776
  this.on('error', (error) => {
766
- this.status = types_1.AgentStatus.ERROR;
777
+ this.lifecycleManager.setStatus(types_1.AgentStatus.ERROR);
767
778
  this.emitEvent('agent.error', { agentId: this.agentId, error });
768
779
  });
769
780
  }