snow-flow 2.0.5 → 2.0.7

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 (52) hide show
  1. package/dist/config/snow-flow-config.d.ts +1492 -0
  2. package/dist/config/snow-flow-config.js +938 -0
  3. package/dist/coordination/coordination-engine.d.ts +41 -0
  4. package/dist/coordination/coordination-engine.js +324 -0
  5. package/dist/coordination/coordination.test.d.ts +6 -0
  6. package/dist/coordination/example.d.ts +31 -0
  7. package/dist/coordination/example.js +394 -0
  8. package/dist/coordination/execution-patterns.d.ts +43 -0
  9. package/dist/coordination/execution-patterns.js +507 -0
  10. package/dist/coordination/factory.d.ts +94 -0
  11. package/dist/coordination/factory.js +433 -0
  12. package/dist/coordination/index.d.ts +71 -0
  13. package/dist/coordination/index.js +135 -0
  14. package/dist/coordination/progress-monitor.d.ts +71 -0
  15. package/dist/coordination/progress-monitor.js +505 -0
  16. package/dist/coordination/quality-gates.d.ts +124 -0
  17. package/dist/coordination/quality-gates.js +577 -0
  18. package/dist/coordination/shared-memory.d.ts +39 -0
  19. package/dist/coordination/shared-memory.js +289 -0
  20. package/dist/coordination/task-dependencies.d.ts +50 -0
  21. package/dist/coordination/task-dependencies.js +407 -0
  22. package/dist/coordination/team-coordinator.d.ts +59 -0
  23. package/dist/coordination/team-coordinator.js +550 -0
  24. package/dist/coordination/types.d.ts +152 -0
  25. package/dist/coordination/types.js +3 -0
  26. package/dist/memory/memory-system.d.ts +1 -0
  27. package/dist/memory/memory-system.js +21 -2
  28. package/memory/claude-flow-data.json +5 -0
  29. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
  30. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
  31. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
  32. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
  33. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
  34. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
  35. package/memory/sessions/README.md +32 -0
  36. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
  37. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
  38. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
  39. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
  40. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
  41. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
  42. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
  43. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
  44. package/package.json +1 -1
  45. package/reports/swarm-auto-centralized-1752649029776.json +13 -0
  46. package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
  47. package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
  48. package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
  49. package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
  50. package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
  51. package/intelligent-mcp.db-shm +0 -0
  52. package/intelligent-mcp.db-wal +0 -0
@@ -0,0 +1,71 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { ProgressStatus, ProgressListener, BaseTeam } from './types';
3
+ import { TaskDependencyGraph } from './task-dependencies';
4
+ export declare class ProgressMonitor extends EventEmitter {
5
+ private listeners;
6
+ private monitoringActive;
7
+ private monitoringInterval?;
8
+ private agentHealthInterval?;
9
+ private memoryMonitorInterval?;
10
+ private progressHistory;
11
+ private agentMetrics;
12
+ private bottleneckDetector;
13
+ private performanceAnalyzer;
14
+ constructor();
15
+ startMonitoring(team: BaseTeam, taskGraph: TaskDependencyGraph): Promise<void>;
16
+ stopMonitoring(): Promise<void>;
17
+ private monitorTaskProgress;
18
+ private monitorAgentHealth;
19
+ private monitorSharedMemory;
20
+ private monitorPerformance;
21
+ private detectBottlenecks;
22
+ private getProgressStatus;
23
+ private checkAgentHealth;
24
+ private performAgentHealthCheck;
25
+ private updateAgentMetrics;
26
+ private estimateCompletion;
27
+ private determineCurrentPhase;
28
+ private gatherMetrics;
29
+ private analyzeTrends;
30
+ private calculateProgressRate;
31
+ private calculateErrorRate;
32
+ addListener(listener: ProgressListener): void;
33
+ removeListener(listener: ProgressListener): void;
34
+ private notifyListeners;
35
+ getDetailedReport(): Promise<DetailedProgressReport>;
36
+ private generateTrendSummary;
37
+ private describeTrend;
38
+ private generateRecommendations;
39
+ }
40
+ interface AgentMetrics {
41
+ totalChecks: number;
42
+ healthyChecks: number;
43
+ averageResponseTime: number;
44
+ lastSeen: Date;
45
+ errors: {
46
+ timestamp: Date;
47
+ error: string;
48
+ }[];
49
+ }
50
+ interface OverallPerformanceMetrics {
51
+ averageEfficiency: number;
52
+ averageThroughput: number;
53
+ bestEfficiency: number;
54
+ worstEfficiency: number;
55
+ trend: 'improving' | 'declining' | 'stable' | 'unknown';
56
+ }
57
+ interface DetailedProgressReport {
58
+ overview: ProgressStatus | null;
59
+ agentMetrics: Record<string, AgentMetrics>;
60
+ performanceMetrics: OverallPerformanceMetrics;
61
+ trends: TrendSummary;
62
+ recommendations: string[];
63
+ }
64
+ interface TrendSummary {
65
+ direction: 'improving' | 'declining' | 'stable' | 'unknown';
66
+ confidence: number;
67
+ description: string;
68
+ progressRate?: number;
69
+ }
70
+ export {};
71
+ //# sourceMappingURL=progress-monitor.d.ts.map
@@ -0,0 +1,505 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProgressMonitor = void 0;
4
+ const eventemitter3_1 = require("eventemitter3");
5
+ const logger_1 = require("../utils/logger");
6
+ class ProgressMonitor extends eventemitter3_1.EventEmitter {
7
+ constructor() {
8
+ super();
9
+ this.listeners = new Set();
10
+ this.monitoringActive = false;
11
+ this.progressHistory = [];
12
+ this.agentMetrics = new Map();
13
+ this.bottleneckDetector = new BottleneckDetector();
14
+ this.performanceAnalyzer = new PerformanceAnalyzer();
15
+ logger_1.logger.info('📊 Progress Monitor initialized');
16
+ }
17
+ async startMonitoring(team, taskGraph) {
18
+ if (this.monitoringActive) {
19
+ logger_1.logger.warn('⚠️ Progress monitoring already active');
20
+ return;
21
+ }
22
+ this.monitoringActive = true;
23
+ logger_1.logger.info('📊 Starting comprehensive team progress monitoring');
24
+ // Start different monitoring aspects
25
+ await Promise.all([
26
+ this.monitorTaskProgress(taskGraph),
27
+ this.monitorAgentHealth(team),
28
+ this.monitorSharedMemory(),
29
+ this.monitorPerformance(taskGraph),
30
+ this.detectBottlenecks(taskGraph)
31
+ ]);
32
+ this.emit('monitoring:started', {
33
+ teamSize: team.agents.size,
34
+ totalTasks: taskGraph.getTotalTasks()
35
+ });
36
+ }
37
+ async stopMonitoring() {
38
+ this.monitoringActive = false;
39
+ if (this.monitoringInterval) {
40
+ clearInterval(this.monitoringInterval);
41
+ }
42
+ if (this.agentHealthInterval) {
43
+ clearInterval(this.agentHealthInterval);
44
+ }
45
+ if (this.memoryMonitorInterval) {
46
+ clearInterval(this.memoryMonitorInterval);
47
+ }
48
+ logger_1.logger.info('🛑 Progress monitoring stopped');
49
+ this.emit('monitoring:stopped');
50
+ }
51
+ async monitorTaskProgress(taskGraph) {
52
+ this.monitoringInterval = setInterval(async () => {
53
+ try {
54
+ const status = await this.getProgressStatus(taskGraph);
55
+ // Store progress snapshot
56
+ this.progressHistory.push({
57
+ timestamp: new Date(),
58
+ status,
59
+ metrics: await this.gatherMetrics(taskGraph)
60
+ });
61
+ // Keep only last 100 snapshots
62
+ if (this.progressHistory.length > 100) {
63
+ this.progressHistory = this.progressHistory.slice(-100);
64
+ }
65
+ // Notify listeners
66
+ this.notifyListeners('task_progress', status);
67
+ // Check for completion
68
+ if (status.completed) {
69
+ await this.stopMonitoring();
70
+ this.emit('monitoring:completed', status);
71
+ }
72
+ // Analyze trends
73
+ await this.analyzeTrends();
74
+ }
75
+ catch (error) {
76
+ logger_1.logger.error('❌ Task progress monitoring error', { error: error.message });
77
+ }
78
+ }, 1000); // Check every second
79
+ }
80
+ async monitorAgentHealth(team) {
81
+ this.agentHealthInterval = setInterval(async () => {
82
+ try {
83
+ const healthReport = await this.checkAgentHealth(team);
84
+ // Update agent metrics
85
+ for (const [agentId, health] of Object.entries(healthReport.agents)) {
86
+ this.updateAgentMetrics(agentId, health);
87
+ }
88
+ this.notifyListeners('agent_health', healthReport);
89
+ // Check for unhealthy agents
90
+ const unhealthyAgents = Object.entries(healthReport.agents)
91
+ .filter(([, health]) => health.status === 'error' || health.responseTime > 30000);
92
+ if (unhealthyAgents.length > 0) {
93
+ this.emit('agents:unhealthy', { agents: unhealthyAgents });
94
+ logger_1.logger.warn('⚠️ Unhealthy agents detected', {
95
+ count: unhealthyAgents.length,
96
+ agents: unhealthyAgents.map(([id]) => id)
97
+ });
98
+ }
99
+ }
100
+ catch (error) {
101
+ logger_1.logger.error('❌ Agent health monitoring error', { error: error.message });
102
+ }
103
+ }, 5000); // Check every 5 seconds
104
+ }
105
+ async monitorSharedMemory() {
106
+ this.memoryMonitorInterval = setInterval(async () => {
107
+ try {
108
+ // This would integrate with the SharedMemoryManager
109
+ // For now, we'll simulate memory monitoring
110
+ const memoryStats = {
111
+ usage: Math.random() * 100,
112
+ operations: Math.floor(Math.random() * 50),
113
+ conflicts: Math.floor(Math.random() * 3)
114
+ };
115
+ this.notifyListeners('memory_stats', memoryStats);
116
+ // Check for memory issues
117
+ if (memoryStats.usage > 90) {
118
+ this.emit('memory:high_usage', memoryStats);
119
+ logger_1.logger.warn('⚠️ High memory usage detected', memoryStats);
120
+ }
121
+ if (memoryStats.conflicts > 5) {
122
+ this.emit('memory:conflicts', memoryStats);
123
+ logger_1.logger.warn('⚠️ Memory conflicts detected', memoryStats);
124
+ }
125
+ }
126
+ catch (error) {
127
+ logger_1.logger.error('❌ Memory monitoring error', { error: error.message });
128
+ }
129
+ }, 3000); // Check every 3 seconds
130
+ }
131
+ async monitorPerformance(taskGraph) {
132
+ const performanceCheck = async () => {
133
+ try {
134
+ const performance = await this.performanceAnalyzer.analyze(taskGraph);
135
+ this.notifyListeners('performance_metrics', performance);
136
+ // Check for performance degradation
137
+ if (performance.efficiency < 0.5) {
138
+ this.emit('performance:degradation', performance);
139
+ logger_1.logger.warn('⚠️ Performance degradation detected', performance);
140
+ }
141
+ }
142
+ catch (error) {
143
+ logger_1.logger.error('❌ Performance monitoring error', { error: error.message });
144
+ }
145
+ };
146
+ // Run performance check every 10 seconds
147
+ setInterval(performanceCheck, 10000);
148
+ }
149
+ async detectBottlenecks(taskGraph) {
150
+ const bottleneckCheck = async () => {
151
+ try {
152
+ const bottlenecks = await this.bottleneckDetector.detect(taskGraph);
153
+ if (bottlenecks.length > 0) {
154
+ this.notifyListeners('bottlenecks_detected', bottlenecks);
155
+ this.emit('bottlenecks:detected', { bottlenecks });
156
+ logger_1.logger.warn('🚧 Bottlenecks detected', {
157
+ count: bottlenecks.length,
158
+ types: bottlenecks.map(b => b.type)
159
+ });
160
+ }
161
+ }
162
+ catch (error) {
163
+ logger_1.logger.error('❌ Bottleneck detection error', { error: error.message });
164
+ }
165
+ };
166
+ // Run bottleneck detection every 15 seconds
167
+ setInterval(bottleneckCheck, 15000);
168
+ }
169
+ async getProgressStatus(taskGraph) {
170
+ const totalTasks = taskGraph.getTotalTasks();
171
+ const completedTasks = taskGraph.getCompletedTasks();
172
+ const failedTasks = taskGraph.getFailedTasks();
173
+ const inProgressTasks = taskGraph.getInProgressTasks();
174
+ const percentage = totalTasks > 0 ? Math.round((completedTasks.length / totalTasks) * 100) : 0;
175
+ const estimatedCompletion = this.estimateCompletion(taskGraph);
176
+ const currentPhase = this.determineCurrentPhase(taskGraph);
177
+ const bottlenecks = await this.bottleneckDetector.detect(taskGraph);
178
+ return {
179
+ total: totalTasks,
180
+ completed: completedTasks.length,
181
+ failed: failedTasks.length,
182
+ inProgress: inProgressTasks.length,
183
+ percentage,
184
+ estimated_completion: estimatedCompletion,
185
+ currentPhase,
186
+ bottlenecks: bottlenecks.map(b => b.description)
187
+ };
188
+ }
189
+ async checkAgentHealth(team) {
190
+ const agents = {};
191
+ let overallHealth = 'healthy';
192
+ for (const [agentId, agent] of team.agents) {
193
+ try {
194
+ const startTime = Date.now();
195
+ // Simulate health check (in real implementation, this would ping the agent)
196
+ const healthCheckResult = await this.performAgentHealthCheck(agent);
197
+ const responseTime = Date.now() - startTime;
198
+ agents[agentId] = {
199
+ status: healthCheckResult.status,
200
+ responseTime,
201
+ lastActivity: agent.lastActivity,
202
+ currentTask: healthCheckResult.currentTask,
203
+ memoryUsage: healthCheckResult.memoryUsage,
204
+ errorCount: healthCheckResult.errorCount
205
+ };
206
+ if (healthCheckResult.status === 'error') {
207
+ overallHealth = 'degraded';
208
+ }
209
+ }
210
+ catch (error) {
211
+ agents[agentId] = {
212
+ status: 'error',
213
+ responseTime: 0,
214
+ lastActivity: agent.lastActivity,
215
+ error: error.message
216
+ };
217
+ overallHealth = 'degraded';
218
+ }
219
+ }
220
+ return {
221
+ overall: overallHealth,
222
+ agents,
223
+ timestamp: new Date()
224
+ };
225
+ }
226
+ async performAgentHealthCheck(agent) {
227
+ // Simulate agent health check
228
+ // In real implementation, this would communicate with the actual agent
229
+ const isHealthy = Math.random() > 0.1; // 90% healthy
230
+ return {
231
+ status: isHealthy ? 'idle' : 'error',
232
+ currentTask: isHealthy ? null : 'stuck_task',
233
+ memoryUsage: Math.random() * 100,
234
+ errorCount: isHealthy ? 0 : Math.floor(Math.random() * 5)
235
+ };
236
+ }
237
+ updateAgentMetrics(agentId, health) {
238
+ const existing = this.agentMetrics.get(agentId) || {
239
+ totalChecks: 0,
240
+ healthyChecks: 0,
241
+ averageResponseTime: 0,
242
+ lastSeen: new Date(),
243
+ errors: []
244
+ };
245
+ existing.totalChecks++;
246
+ if (health.status !== 'error') {
247
+ existing.healthyChecks++;
248
+ }
249
+ if (health.responseTime) {
250
+ existing.averageResponseTime =
251
+ (existing.averageResponseTime * (existing.totalChecks - 1) + health.responseTime) / existing.totalChecks;
252
+ }
253
+ existing.lastSeen = new Date();
254
+ if (health.error) {
255
+ existing.errors.push({
256
+ timestamp: new Date(),
257
+ error: health.error
258
+ });
259
+ // Keep only last 10 errors
260
+ if (existing.errors.length > 10) {
261
+ existing.errors = existing.errors.slice(-10);
262
+ }
263
+ }
264
+ this.agentMetrics.set(agentId, existing);
265
+ }
266
+ estimateCompletion(taskGraph) {
267
+ const inProgressTasks = taskGraph.getInProgressTasks();
268
+ const pendingTasks = taskGraph.getPendingTasks();
269
+ if (inProgressTasks.length === 0 && pendingTasks.length === 0) {
270
+ return new Date(); // Already completed
271
+ }
272
+ // Calculate average task duration from completed tasks
273
+ const completedTasks = taskGraph.getCompletedTasks();
274
+ const averageDuration = completedTasks.length > 0
275
+ ? completedTasks.reduce((sum, task) => {
276
+ const duration = task.endTime && task.startTime
277
+ ? task.endTime.getTime() - task.startTime.getTime()
278
+ : 60000;
279
+ return sum + duration;
280
+ }, 0) / completedTasks.length
281
+ : 60000; // Default 1 minute
282
+ // Estimate remaining time
283
+ const estimatedRemainingTime = (inProgressTasks.length + pendingTasks.length) * averageDuration;
284
+ return new Date(Date.now() + estimatedRemainingTime);
285
+ }
286
+ determineCurrentPhase(taskGraph) {
287
+ const totalTasks = taskGraph.getTotalTasks();
288
+ const completedTasks = taskGraph.getCompletedTasks().length;
289
+ const percentage = totalTasks > 0 ? (completedTasks / totalTasks) * 100 : 0;
290
+ if (percentage < 25)
291
+ return 'Initialization';
292
+ if (percentage < 50)
293
+ return 'Development';
294
+ if (percentage < 75)
295
+ return 'Integration';
296
+ if (percentage < 90)
297
+ return 'Testing';
298
+ if (percentage < 100)
299
+ return 'Finalization';
300
+ return 'Completed';
301
+ }
302
+ async gatherMetrics(taskGraph) {
303
+ return {
304
+ taskMetrics: await taskGraph.getExecutionStats(),
305
+ agentMetrics: Object.fromEntries(this.agentMetrics),
306
+ systemMetrics: {
307
+ timestamp: new Date(),
308
+ monitoringDuration: this.progressHistory.length * 1000 // milliseconds
309
+ }
310
+ };
311
+ }
312
+ async analyzeTrends() {
313
+ if (this.progressHistory.length < 10)
314
+ return; // Need enough data
315
+ const recent = this.progressHistory.slice(-10);
316
+ const progressRate = this.calculateProgressRate(recent);
317
+ const errorRate = this.calculateErrorRate(recent);
318
+ // Emit trend analysis
319
+ this.notifyListeners('trend_analysis', {
320
+ progressRate,
321
+ errorRate,
322
+ trend: progressRate > 0 ? 'improving' : progressRate < 0 ? 'declining' : 'stable'
323
+ });
324
+ }
325
+ calculateProgressRate(snapshots) {
326
+ if (snapshots.length < 2)
327
+ return 0;
328
+ const first = snapshots[0];
329
+ const last = snapshots[snapshots.length - 1];
330
+ const timeDiff = last.timestamp.getTime() - first.timestamp.getTime();
331
+ const progressDiff = last.status.percentage - first.status.percentage;
332
+ return timeDiff > 0 ? progressDiff / (timeDiff / 1000) : 0; // Progress per second
333
+ }
334
+ calculateErrorRate(snapshots) {
335
+ if (snapshots.length < 2)
336
+ return 0;
337
+ const errors = snapshots.reduce((sum, snapshot) => sum + snapshot.status.failed, 0);
338
+ return errors / snapshots.length;
339
+ }
340
+ // Public API methods
341
+ addListener(listener) {
342
+ this.listeners.add(listener);
343
+ logger_1.logger.debug('👂 Progress listener added', { totalListeners: this.listeners.size });
344
+ }
345
+ removeListener(listener) {
346
+ this.listeners.delete(listener);
347
+ logger_1.logger.debug('👂 Progress listener removed', { totalListeners: this.listeners.size });
348
+ }
349
+ notifyListeners(event, data) {
350
+ this.listeners.forEach(listener => {
351
+ try {
352
+ listener.onProgress(event, data);
353
+ }
354
+ catch (error) {
355
+ logger_1.logger.error('❌ Progress listener error', { event, error: error.message });
356
+ }
357
+ });
358
+ }
359
+ async getDetailedReport() {
360
+ return {
361
+ overview: this.progressHistory.length > 0
362
+ ? this.progressHistory[this.progressHistory.length - 1].status
363
+ : null,
364
+ agentMetrics: Object.fromEntries(this.agentMetrics),
365
+ performanceMetrics: await this.performanceAnalyzer.getOverallMetrics(),
366
+ trends: this.generateTrendSummary(),
367
+ recommendations: this.generateRecommendations()
368
+ };
369
+ }
370
+ generateTrendSummary() {
371
+ if (this.progressHistory.length === 0) {
372
+ return { direction: 'unknown', confidence: 0, description: 'Insufficient data' };
373
+ }
374
+ const recent = this.progressHistory.slice(-20);
375
+ const progressRate = this.calculateProgressRate(recent);
376
+ return {
377
+ direction: progressRate > 0.1 ? 'improving' : progressRate < -0.1 ? 'declining' : 'stable',
378
+ confidence: Math.min(recent.length / 20, 1),
379
+ description: this.describeTrend(progressRate),
380
+ progressRate
381
+ };
382
+ }
383
+ describeTrend(rate) {
384
+ if (rate > 0.5)
385
+ return 'Excellent progress rate';
386
+ if (rate > 0.1)
387
+ return 'Good progress rate';
388
+ if (rate > -0.1)
389
+ return 'Stable progress';
390
+ if (rate > -0.5)
391
+ return 'Slow progress';
392
+ return 'Progress has stalled';
393
+ }
394
+ generateRecommendations() {
395
+ const recommendations = [];
396
+ // Analyze agent health
397
+ const unhealthyAgents = Array.from(this.agentMetrics.entries())
398
+ .filter(([, metrics]) => metrics.healthyChecks / metrics.totalChecks < 0.8);
399
+ if (unhealthyAgents.length > 0) {
400
+ recommendations.push(`Review ${unhealthyAgents.length} underperforming agent(s)`);
401
+ }
402
+ // Analyze progress rate
403
+ if (this.progressHistory.length > 10) {
404
+ const rate = this.calculateProgressRate(this.progressHistory.slice(-10));
405
+ if (rate < 0.1) {
406
+ recommendations.push('Consider increasing parallelism or reviewing task dependencies');
407
+ }
408
+ }
409
+ return recommendations;
410
+ }
411
+ }
412
+ exports.ProgressMonitor = ProgressMonitor;
413
+ // Supporting classes
414
+ class BottleneckDetector {
415
+ async detect(taskGraph) {
416
+ const bottlenecks = [];
417
+ // Detect long-running tasks
418
+ const inProgressTasks = taskGraph.getInProgressTasks();
419
+ const longRunningTasks = inProgressTasks.filter(task => {
420
+ const duration = task.startTime ? Date.now() - task.startTime.getTime() : 0;
421
+ return duration > 300000; // 5 minutes
422
+ });
423
+ for (const task of longRunningTasks) {
424
+ bottlenecks.push({
425
+ type: 'long_running_task',
426
+ taskId: task.id,
427
+ description: `Task ${task.id} has been running for over 5 minutes`,
428
+ severity: 'medium',
429
+ suggestion: 'Consider task timeout or agent health check'
430
+ });
431
+ }
432
+ // Detect dependency chains
433
+ const pendingTasks = taskGraph.getPendingTasks();
434
+ if (pendingTasks.length > inProgressTasks.length * 2) {
435
+ bottlenecks.push({
436
+ type: 'dependency_bottleneck',
437
+ description: 'Many tasks waiting for dependencies to complete',
438
+ severity: 'high',
439
+ suggestion: 'Review task dependencies and consider parallel execution'
440
+ });
441
+ }
442
+ return bottlenecks;
443
+ }
444
+ }
445
+ class PerformanceAnalyzer {
446
+ constructor() {
447
+ this.metrics = [];
448
+ }
449
+ async analyze(taskGraph) {
450
+ const stats = await taskGraph.getExecutionStats();
451
+ const efficiency = stats.totalTasks > 0
452
+ ? stats.completedTasks / stats.totalTasks
453
+ : 0;
454
+ const throughput = stats.averageExecutionTime > 0
455
+ ? 1000 / stats.averageExecutionTime
456
+ : 0;
457
+ const metrics = {
458
+ efficiency,
459
+ throughput,
460
+ averageTaskTime: stats.averageExecutionTime,
461
+ retryRate: stats.totalRetries / Math.max(stats.totalTasks, 1),
462
+ timestamp: new Date()
463
+ };
464
+ this.metrics.push(metrics);
465
+ if (this.metrics.length > 100) {
466
+ this.metrics = this.metrics.slice(-100);
467
+ }
468
+ return metrics;
469
+ }
470
+ async getOverallMetrics() {
471
+ if (this.metrics.length === 0) {
472
+ return {
473
+ averageEfficiency: 0,
474
+ averageThroughput: 0,
475
+ bestEfficiency: 0,
476
+ worstEfficiency: 0,
477
+ trend: 'unknown'
478
+ };
479
+ }
480
+ const efficiencies = this.metrics.map(m => m.efficiency);
481
+ const throughputs = this.metrics.map(m => m.throughput);
482
+ return {
483
+ averageEfficiency: efficiencies.reduce((sum, e) => sum + e, 0) / efficiencies.length,
484
+ averageThroughput: throughputs.reduce((sum, t) => sum + t, 0) / throughputs.length,
485
+ bestEfficiency: Math.max(...efficiencies),
486
+ worstEfficiency: Math.min(...efficiencies),
487
+ trend: this.calculateTrend()
488
+ };
489
+ }
490
+ calculateTrend() {
491
+ if (this.metrics.length < 10)
492
+ return 'unknown';
493
+ const recent = this.metrics.slice(-5);
494
+ const older = this.metrics.slice(-10, -5);
495
+ const recentAvg = recent.reduce((sum, m) => sum + m.efficiency, 0) / recent.length;
496
+ const olderAvg = older.reduce((sum, m) => sum + m.efficiency, 0) / older.length;
497
+ const diff = recentAvg - olderAvg;
498
+ if (diff > 0.05)
499
+ return 'improving';
500
+ if (diff < -0.05)
501
+ return 'declining';
502
+ return 'stable';
503
+ }
504
+ }
505
+ //# sourceMappingURL=progress-monitor.js.map
@@ -0,0 +1,124 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { QualityGate, ValidationResult, QualityGateResult } from './types';
3
+ export declare class QualityGateManager extends EventEmitter {
4
+ private gates;
5
+ private gateResults;
6
+ private config;
7
+ constructor(config?: Partial<QualityGateConfig>);
8
+ addGate(taskId: string, gate: QualityGate): void;
9
+ validateTask(taskId: string, result: any): Promise<QualityGateResult>;
10
+ private executeGateWithTimeout;
11
+ private calculateOverallScore;
12
+ private createPassingResult;
13
+ getGateStatistics(taskId?: string): Promise<GateStatistics>;
14
+ createCodeQualityGate(options?: CodeQualityOptions): QualityGate;
15
+ createSecurityGate(options?: SecurityGateOptions): QualityGate;
16
+ createPerformanceGate(options?: PerformanceGateOptions): QualityGate;
17
+ createServiceNowGate(options?: ServiceNowGateOptions): QualityGate;
18
+ createBusinessLogicGate(options?: BusinessLogicGateOptions): QualityGate;
19
+ }
20
+ export declare class CodeQualityGate implements QualityGate {
21
+ name: string;
22
+ blocking: boolean;
23
+ private options;
24
+ constructor(options?: CodeQualityOptions);
25
+ validate(result: any): Promise<ValidationResult>;
26
+ private hasDocumentation;
27
+ private generateCodeSuggestions;
28
+ }
29
+ export declare class SecurityGate implements QualityGate {
30
+ name: string;
31
+ blocking: boolean;
32
+ private options;
33
+ constructor(options?: SecurityGateOptions);
34
+ validate(result: any): Promise<ValidationResult>;
35
+ private hasSQLInjectionRisk;
36
+ private hasXSSRisk;
37
+ private hasHardcodedSecrets;
38
+ private hasProperAuthentication;
39
+ private hasProperPermissions;
40
+ private generateSecuritySuggestions;
41
+ }
42
+ export declare class PerformanceGate implements QualityGate {
43
+ name: string;
44
+ blocking: boolean;
45
+ private options;
46
+ constructor(options?: PerformanceGateOptions);
47
+ validate(result: any): Promise<ValidationResult>;
48
+ private generatePerformanceSuggestions;
49
+ }
50
+ export declare class ServiceNowGate implements QualityGate {
51
+ name: string;
52
+ blocking: boolean;
53
+ private options;
54
+ constructor(options?: ServiceNowGateOptions);
55
+ validate(result: any): Promise<ValidationResult>;
56
+ private hasValidScope;
57
+ private hasValidUpdateSet;
58
+ private hasValidNaming;
59
+ private hasValidDependencies;
60
+ private generateServiceNowSuggestions;
61
+ }
62
+ export declare class BusinessLogicGate implements QualityGate {
63
+ name: string;
64
+ blocking: boolean;
65
+ private options;
66
+ constructor(options?: BusinessLogicGateOptions);
67
+ validate(result: any): Promise<ValidationResult>;
68
+ private meetsBusinessRequirements;
69
+ private hasExpectedOutputs;
70
+ private hasProperErrorHandling;
71
+ }
72
+ interface QualityGateConfig {
73
+ enableBlocking: boolean;
74
+ enableScoring: boolean;
75
+ minPassingScore: number;
76
+ enableMetrics: boolean;
77
+ timeoutMs: number;
78
+ }
79
+ interface CodeQualityOptions {
80
+ maxComplexity?: number;
81
+ minCoverage?: number;
82
+ maxLines?: number;
83
+ requireDocumentation?: boolean;
84
+ checkNaming?: boolean;
85
+ blocking?: boolean;
86
+ }
87
+ interface SecurityGateOptions {
88
+ checkInjection?: boolean;
89
+ checkXSS?: boolean;
90
+ checkAuth?: boolean;
91
+ checkSecrets?: boolean;
92
+ checkPermissions?: boolean;
93
+ }
94
+ interface PerformanceGateOptions {
95
+ maxResponseTime?: number;
96
+ maxMemoryUsage?: number;
97
+ minThroughput?: number;
98
+ blocking?: boolean;
99
+ }
100
+ interface ServiceNowGateOptions {
101
+ checkScope?: boolean;
102
+ checkUpdateSet?: boolean;
103
+ checkNaming?: boolean;
104
+ checkDependencies?: boolean;
105
+ blocking?: boolean;
106
+ }
107
+ interface BusinessLogicGateOptions {
108
+ checkRequirements?: boolean;
109
+ checkOutputs?: boolean;
110
+ checkErrorHandling?: boolean;
111
+ blocking?: boolean;
112
+ }
113
+ interface GateStatistics {
114
+ totalExecutions: number;
115
+ passRate: number;
116
+ averageScore: number;
117
+ averageExecutionTime: number;
118
+ mostCommonFailures: {
119
+ error: string;
120
+ count: number;
121
+ }[];
122
+ }
123
+ export {};
124
+ //# sourceMappingURL=quality-gates.d.ts.map