agentic-qe 2.0.0 → 2.1.1

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 (144) hide show
  1. package/.claude/agents/qx-partner.md +17 -4
  2. package/.claude/skills/accessibility-testing/SKILL.md +144 -692
  3. package/.claude/skills/agentic-quality-engineering/SKILL.md +176 -529
  4. package/.claude/skills/api-testing-patterns/SKILL.md +180 -560
  5. package/.claude/skills/brutal-honesty-review/SKILL.md +113 -603
  6. package/.claude/skills/bug-reporting-excellence/SKILL.md +116 -517
  7. package/.claude/skills/chaos-engineering-resilience/SKILL.md +127 -72
  8. package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +209 -404
  9. package/.claude/skills/code-review-quality/SKILL.md +158 -608
  10. package/.claude/skills/compatibility-testing/SKILL.md +148 -38
  11. package/.claude/skills/compliance-testing/SKILL.md +132 -63
  12. package/.claude/skills/consultancy-practices/SKILL.md +114 -446
  13. package/.claude/skills/context-driven-testing/SKILL.md +117 -381
  14. package/.claude/skills/contract-testing/SKILL.md +176 -141
  15. package/.claude/skills/database-testing/SKILL.md +137 -130
  16. package/.claude/skills/exploratory-testing-advanced/SKILL.md +160 -629
  17. package/.claude/skills/holistic-testing-pact/SKILL.md +140 -188
  18. package/.claude/skills/localization-testing/SKILL.md +145 -33
  19. package/.claude/skills/mobile-testing/SKILL.md +132 -448
  20. package/.claude/skills/mutation-testing/SKILL.md +147 -41
  21. package/.claude/skills/performance-testing/SKILL.md +200 -546
  22. package/.claude/skills/quality-metrics/SKILL.md +164 -519
  23. package/.claude/skills/refactoring-patterns/SKILL.md +132 -699
  24. package/.claude/skills/regression-testing/SKILL.md +120 -926
  25. package/.claude/skills/risk-based-testing/SKILL.md +157 -660
  26. package/.claude/skills/security-testing/SKILL.md +199 -538
  27. package/.claude/skills/sherlock-review/SKILL.md +163 -699
  28. package/.claude/skills/shift-left-testing/SKILL.md +161 -465
  29. package/.claude/skills/shift-right-testing/SKILL.md +161 -519
  30. package/.claude/skills/six-thinking-hats/SKILL.md +175 -1110
  31. package/.claude/skills/skills-manifest.json +71 -20
  32. package/.claude/skills/tdd-london-chicago/SKILL.md +131 -448
  33. package/.claude/skills/technical-writing/SKILL.md +103 -154
  34. package/.claude/skills/test-automation-strategy/SKILL.md +166 -772
  35. package/.claude/skills/test-data-management/SKILL.md +126 -910
  36. package/.claude/skills/test-design-techniques/SKILL.md +179 -89
  37. package/.claude/skills/test-environment-management/SKILL.md +136 -91
  38. package/.claude/skills/test-reporting-analytics/SKILL.md +169 -92
  39. package/.claude/skills/testability-scoring/SKILL.md +172 -538
  40. package/.claude/skills/testability-scoring/scripts/generate-html-report.js +0 -0
  41. package/.claude/skills/visual-testing-advanced/SKILL.md +155 -78
  42. package/.claude/skills/xp-practices/SKILL.md +151 -587
  43. package/CHANGELOG.md +86 -0
  44. package/README.md +23 -16
  45. package/dist/agents/QXPartnerAgent.d.ts +47 -1
  46. package/dist/agents/QXPartnerAgent.d.ts.map +1 -1
  47. package/dist/agents/QXPartnerAgent.js +2086 -125
  48. package/dist/agents/QXPartnerAgent.js.map +1 -1
  49. package/dist/agents/lifecycle/AgentLifecycleManager.d.ts.map +1 -1
  50. package/dist/agents/lifecycle/AgentLifecycleManager.js +34 -31
  51. package/dist/agents/lifecycle/AgentLifecycleManager.js.map +1 -1
  52. package/dist/cli/commands/init-claude-md-template.d.ts.map +1 -1
  53. package/dist/cli/commands/init-claude-md-template.js +14 -0
  54. package/dist/cli/commands/init-claude-md-template.js.map +1 -1
  55. package/dist/core/SwarmCoordinator.d.ts +180 -0
  56. package/dist/core/SwarmCoordinator.d.ts.map +1 -0
  57. package/dist/core/SwarmCoordinator.js +473 -0
  58. package/dist/core/SwarmCoordinator.js.map +1 -0
  59. package/dist/core/memory/ReflexionMemoryAdapter.d.ts +109 -0
  60. package/dist/core/memory/ReflexionMemoryAdapter.d.ts.map +1 -0
  61. package/dist/core/memory/ReflexionMemoryAdapter.js +306 -0
  62. package/dist/core/memory/ReflexionMemoryAdapter.js.map +1 -0
  63. package/dist/core/memory/RuVectorPatternStore.d.ts +28 -0
  64. package/dist/core/memory/RuVectorPatternStore.d.ts.map +1 -1
  65. package/dist/core/memory/RuVectorPatternStore.js +70 -0
  66. package/dist/core/memory/RuVectorPatternStore.js.map +1 -1
  67. package/dist/core/memory/SparseVectorSearch.d.ts +55 -0
  68. package/dist/core/memory/SparseVectorSearch.d.ts.map +1 -0
  69. package/dist/core/memory/SparseVectorSearch.js +130 -0
  70. package/dist/core/memory/SparseVectorSearch.js.map +1 -0
  71. package/dist/core/memory/TieredCompression.d.ts +81 -0
  72. package/dist/core/memory/TieredCompression.d.ts.map +1 -0
  73. package/dist/core/memory/TieredCompression.js +270 -0
  74. package/dist/core/memory/TieredCompression.js.map +1 -0
  75. package/dist/core/memory/index.d.ts +6 -0
  76. package/dist/core/memory/index.d.ts.map +1 -1
  77. package/dist/core/memory/index.js +29 -1
  78. package/dist/core/memory/index.js.map +1 -1
  79. package/dist/core/metrics/MetricsAggregator.d.ts +228 -0
  80. package/dist/core/metrics/MetricsAggregator.d.ts.map +1 -0
  81. package/dist/core/metrics/MetricsAggregator.js +482 -0
  82. package/dist/core/metrics/MetricsAggregator.js.map +1 -0
  83. package/dist/core/metrics/index.d.ts +5 -0
  84. package/dist/core/metrics/index.d.ts.map +1 -0
  85. package/dist/core/metrics/index.js +11 -0
  86. package/dist/core/metrics/index.js.map +1 -0
  87. package/dist/core/optimization/SwarmOptimizer.d.ts +5 -0
  88. package/dist/core/optimization/SwarmOptimizer.d.ts.map +1 -1
  89. package/dist/core/optimization/SwarmOptimizer.js +17 -0
  90. package/dist/core/optimization/SwarmOptimizer.js.map +1 -1
  91. package/dist/core/orchestration/AdaptiveScheduler.d.ts +190 -0
  92. package/dist/core/orchestration/AdaptiveScheduler.d.ts.map +1 -0
  93. package/dist/core/orchestration/AdaptiveScheduler.js +460 -0
  94. package/dist/core/orchestration/AdaptiveScheduler.js.map +1 -0
  95. package/dist/core/orchestration/WorkflowOrchestrator.d.ts +13 -0
  96. package/dist/core/orchestration/WorkflowOrchestrator.d.ts.map +1 -1
  97. package/dist/core/orchestration/WorkflowOrchestrator.js +32 -0
  98. package/dist/core/orchestration/WorkflowOrchestrator.js.map +1 -1
  99. package/dist/core/recovery/CircuitBreaker.d.ts +176 -0
  100. package/dist/core/recovery/CircuitBreaker.d.ts.map +1 -0
  101. package/dist/core/recovery/CircuitBreaker.js +382 -0
  102. package/dist/core/recovery/CircuitBreaker.js.map +1 -0
  103. package/dist/core/recovery/RecoveryOrchestrator.d.ts +186 -0
  104. package/dist/core/recovery/RecoveryOrchestrator.d.ts.map +1 -0
  105. package/dist/core/recovery/RecoveryOrchestrator.js +476 -0
  106. package/dist/core/recovery/RecoveryOrchestrator.js.map +1 -0
  107. package/dist/core/recovery/RetryStrategy.d.ts +127 -0
  108. package/dist/core/recovery/RetryStrategy.d.ts.map +1 -0
  109. package/dist/core/recovery/RetryStrategy.js +314 -0
  110. package/dist/core/recovery/RetryStrategy.js.map +1 -0
  111. package/dist/core/recovery/index.d.ts +8 -0
  112. package/dist/core/recovery/index.d.ts.map +1 -0
  113. package/dist/core/recovery/index.js +27 -0
  114. package/dist/core/recovery/index.js.map +1 -0
  115. package/dist/core/skills/DependencyResolver.d.ts +99 -0
  116. package/dist/core/skills/DependencyResolver.d.ts.map +1 -0
  117. package/dist/core/skills/DependencyResolver.js +260 -0
  118. package/dist/core/skills/DependencyResolver.js.map +1 -0
  119. package/dist/core/skills/ManifestGenerator.d.ts +114 -0
  120. package/dist/core/skills/ManifestGenerator.d.ts.map +1 -0
  121. package/dist/core/skills/ManifestGenerator.js +449 -0
  122. package/dist/core/skills/ManifestGenerator.js.map +1 -0
  123. package/dist/core/skills/index.d.ts +9 -0
  124. package/dist/core/skills/index.d.ts.map +1 -0
  125. package/dist/core/skills/index.js +24 -0
  126. package/dist/core/skills/index.js.map +1 -0
  127. package/dist/mcp/handlers/chaos/chaos-inject-failure.d.ts +5 -0
  128. package/dist/mcp/handlers/chaos/chaos-inject-failure.d.ts.map +1 -1
  129. package/dist/mcp/handlers/chaos/chaos-inject-failure.js +36 -2
  130. package/dist/mcp/handlers/chaos/chaos-inject-failure.js.map +1 -1
  131. package/dist/mcp/handlers/chaos/chaos-inject-latency.d.ts +5 -0
  132. package/dist/mcp/handlers/chaos/chaos-inject-latency.d.ts.map +1 -1
  133. package/dist/mcp/handlers/chaos/chaos-inject-latency.js +36 -2
  134. package/dist/mcp/handlers/chaos/chaos-inject-latency.js.map +1 -1
  135. package/dist/mcp/server.d.ts +9 -9
  136. package/dist/mcp/server.d.ts.map +1 -1
  137. package/dist/mcp/server.js +1 -2
  138. package/dist/mcp/server.js.map +1 -1
  139. package/dist/types/qx.d.ts +113 -7
  140. package/dist/types/qx.d.ts.map +1 -1
  141. package/dist/types/qx.js.map +1 -1
  142. package/dist/visualization/api/RestEndpoints.js +1 -1
  143. package/dist/visualization/api/RestEndpoints.js.map +1 -1
  144. package/package.json +15 -54
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CircuitBreaker.js","sourceRoot":"","sources":["../../../src/core/recovery/CircuitBreaker.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAubH,4DAOC;AAKD,gEAKC;AAtcD,mCAAsC;AAEtC;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AA8CD;;GAEG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YACkB,WAAmB,EACnB,KAAmB;QAEnC,KAAK,CAAC,oBAAoB,WAAW,QAAQ,KAAK,EAAE,CAAC,CAAC;QAHtC,gBAAW,GAAX,WAAW,CAAQ;QACnB,UAAK,GAAL,KAAK,CAAc;QAGnC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AARD,0DAQC;AAED;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
+ * Coordinates error recovery across transport, memory, and orchestration systems
4
+ */
5
+ import { EventEmitter } from 'events';
6
+ import { CircuitState } from './CircuitBreaker.js';
7
+ import { RetryConfig } from './RetryStrategy.js';
8
+ /**
9
+ * Recovery strategy types
10
+ */
11
+ export type RecoveryStrategyType = 'retry' | 'fallback' | 'circuit-break' | 'rollback' | 'graceful-degradation' | 'escalate';
12
+ /**
13
+ * Component types that can be recovered
14
+ */
15
+ export type RecoverableComponent = 'transport' | 'memory' | 'orchestration' | 'agent' | 'workflow' | 'database';
16
+ /**
17
+ * Health status
18
+ */
19
+ export type HealthStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';
20
+ /**
21
+ * Recovery action result
22
+ */
23
+ export interface RecoveryActionResult {
24
+ success: boolean;
25
+ strategy: RecoveryStrategyType;
26
+ component: RecoverableComponent;
27
+ action: string;
28
+ duration: number;
29
+ error?: string;
30
+ metadata?: Record<string, any>;
31
+ }
32
+ /**
33
+ * Component health info
34
+ */
35
+ export interface ComponentHealth {
36
+ component: RecoverableComponent;
37
+ status: HealthStatus;
38
+ lastCheck: Date;
39
+ errorRate: number;
40
+ latencyP95: number;
41
+ circuitState?: CircuitState;
42
+ details?: Record<string, any>;
43
+ }
44
+ /**
45
+ * Recovery policy configuration
46
+ */
47
+ export interface RecoveryPolicy {
48
+ /** Maximum recovery attempts per minute */
49
+ maxRecoveryRate: number;
50
+ /** Time to wait between recovery attempts */
51
+ cooldownPeriod: number;
52
+ /** When to escalate to manual intervention */
53
+ escalationThreshold: number;
54
+ /** Strategies in order of preference */
55
+ strategyOrder: RecoveryStrategyType[];
56
+ /** Component-specific overrides */
57
+ componentOverrides?: Partial<Record<RecoverableComponent, Partial<RecoveryPolicy>>>;
58
+ }
59
+ /**
60
+ * Recovery event
61
+ */
62
+ export interface RecoveryEvent {
63
+ timestamp: Date;
64
+ component: RecoverableComponent;
65
+ strategy: RecoveryStrategyType;
66
+ success: boolean;
67
+ error?: string;
68
+ duration: number;
69
+ }
70
+ /**
71
+ * Fallback handler type
72
+ */
73
+ export type FallbackHandler<T> = () => Promise<T>;
74
+ /**
75
+ * Health check function type
76
+ */
77
+ export type HealthChecker = (component: RecoverableComponent) => Promise<ComponentHealth>;
78
+ /**
79
+ * Recovery Orchestrator Implementation
80
+ */
81
+ export declare class RecoveryOrchestrator extends EventEmitter {
82
+ private circuitBreakerManager;
83
+ private retryStrategies;
84
+ private fallbackHandlers;
85
+ private healthCheckers;
86
+ private recoveryHistory;
87
+ private componentHealth;
88
+ private policy;
89
+ private recoveryInProgress;
90
+ private lastRecoveryAttempts;
91
+ constructor(policy?: Partial<RecoveryPolicy>);
92
+ /**
93
+ * Execute operation with full recovery support
94
+ */
95
+ executeWithRecovery<T>(component: RecoverableComponent, operationId: string, operation: () => Promise<T>, options?: {
96
+ fallback?: FallbackHandler<T>;
97
+ retryConfig?: Partial<RetryConfig>;
98
+ bypassCircuitBreaker?: boolean;
99
+ }): Promise<T>;
100
+ /**
101
+ * Attempt automatic recovery for a component
102
+ */
103
+ attemptRecovery(component: RecoverableComponent, error: Error): Promise<RecoveryActionResult>;
104
+ /**
105
+ * Register fallback handler
106
+ */
107
+ registerFallback<T>(component: RecoverableComponent, operationId: string, handler: FallbackHandler<T>): void;
108
+ /**
109
+ * Register health checker
110
+ */
111
+ registerHealthChecker(component: RecoverableComponent, checker: HealthChecker): void;
112
+ /**
113
+ * Check health of all components
114
+ */
115
+ checkHealth(): Promise<Map<RecoverableComponent, ComponentHealth>>;
116
+ /**
117
+ * Get component health
118
+ */
119
+ getComponentHealth(component: RecoverableComponent): ComponentHealth | undefined;
120
+ /**
121
+ * Get recovery history
122
+ */
123
+ getRecoveryHistory(limit?: number): RecoveryEvent[];
124
+ /**
125
+ * Get recovery statistics
126
+ */
127
+ getStats(): {
128
+ totalRecoveries: number;
129
+ successfulRecoveries: number;
130
+ failedRecoveries: number;
131
+ successRate: number;
132
+ byComponent: Record<string, {
133
+ total: number;
134
+ successful: number;
135
+ }>;
136
+ byStrategy: Record<string, {
137
+ total: number;
138
+ successful: number;
139
+ }>;
140
+ };
141
+ /**
142
+ * Reset circuit breakers for a component
143
+ */
144
+ resetCircuitBreakers(component?: RecoverableComponent): void;
145
+ /**
146
+ * Initialize default retry strategies per component
147
+ */
148
+ private initializeDefaultStrategies;
149
+ /**
150
+ * Get retry strategy for component
151
+ */
152
+ private getRetryStrategy;
153
+ /**
154
+ * Get policy for component
155
+ */
156
+ private getComponentPolicy;
157
+ /**
158
+ * Execute a specific recovery strategy
159
+ */
160
+ private executeRecoveryStrategy;
161
+ /**
162
+ * Check if recovery can be attempted (rate limiting)
163
+ */
164
+ private canAttemptRecovery;
165
+ /**
166
+ * Record recovery attempt for rate limiting
167
+ */
168
+ private recordRecoveryAttempt;
169
+ /**
170
+ * Record recovery event
171
+ */
172
+ private recordRecoveryEvent;
173
+ /**
174
+ * Cleanup resources
175
+ */
176
+ destroy(): void;
177
+ }
178
+ /**
179
+ * Get default recovery orchestrator
180
+ */
181
+ export declare function getRecoveryOrchestrator(policy?: Partial<RecoveryPolicy>): RecoveryOrchestrator;
182
+ /**
183
+ * Reset default orchestrator (for testing)
184
+ */
185
+ export declare function resetRecoveryOrchestrator(): void;
186
+ //# sourceMappingURL=RecoveryOrchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecoveryOrchestrator.d.ts","sourceRoot":"","sources":["../../../src/core/recovery/RecoveryOrchestrator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAyC,YAAY,EAA4B,MAAM,qBAAqB,CAAC;AACpH,OAAO,EAA8B,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,OAAO,GACP,UAAU,GACV,eAAe,GACf,UAAU,GACV,sBAAsB,GACtB,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,WA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uBAAuB,CACrC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC/B,oBAAoB,CAKtB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAKhD"}
@@ -0,0 +1,476 @@
1
+ "use strict";
2
+ /**
3
+ * Recovery Orchestrator
4
+ * Coordinates error recovery across transport, memory, and orchestration systems
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.RecoveryOrchestrator = void 0;
8
+ exports.getRecoveryOrchestrator = getRecoveryOrchestrator;
9
+ exports.resetRecoveryOrchestrator = resetRecoveryOrchestrator;
10
+ const events_1 = require("events");
11
+ const CircuitBreaker_js_1 = require("./CircuitBreaker.js");
12
+ const RetryStrategy_js_1 = require("./RetryStrategy.js");
13
+ /**
14
+ * Recovery Orchestrator Implementation
15
+ */
16
+ class RecoveryOrchestrator extends events_1.EventEmitter {
17
+ constructor(policy) {
18
+ super();
19
+ this.retryStrategies = new Map();
20
+ this.fallbackHandlers = new Map();
21
+ this.healthCheckers = new Map();
22
+ this.recoveryHistory = [];
23
+ this.componentHealth = new Map();
24
+ this.recoveryInProgress = new Set();
25
+ this.lastRecoveryAttempts = new Map();
26
+ this.policy = {
27
+ maxRecoveryRate: 10,
28
+ cooldownPeriod: 5000,
29
+ escalationThreshold: 5,
30
+ strategyOrder: ['retry', 'fallback', 'circuit-break', 'graceful-degradation', 'rollback', 'escalate'],
31
+ ...policy,
32
+ };
33
+ this.circuitBreakerManager = (0, CircuitBreaker_js_1.getCircuitBreakerManager)();
34
+ this.initializeDefaultStrategies();
35
+ }
36
+ /**
37
+ * Execute operation with full recovery support
38
+ */
39
+ async executeWithRecovery(component, operationId, operation, options) {
40
+ const circuitName = `${component}:${operationId}`;
41
+ const breaker = this.circuitBreakerManager.getBreaker(circuitName);
42
+ // Check if circuit breaker allows execution
43
+ if (!options?.bypassCircuitBreaker && breaker.getState() === CircuitBreaker_js_1.CircuitState.OPEN) {
44
+ // Try fallback if available
45
+ const fallbackKey = `${component}:${operationId}`;
46
+ const fallback = options?.fallback || this.fallbackHandlers.get(fallbackKey);
47
+ if (fallback) {
48
+ this.emit('fallback-used', { component, operationId, reason: 'circuit-open' });
49
+ return fallback();
50
+ }
51
+ throw new Error(`Circuit breaker is OPEN for ${circuitName} and no fallback available`);
52
+ }
53
+ // Execute with retry and circuit breaker
54
+ const retryStrategy = this.getRetryStrategy(component, options?.retryConfig);
55
+ try {
56
+ const result = await retryStrategy.execute(async () => {
57
+ return breaker.execute(operation);
58
+ });
59
+ if (result.success) {
60
+ return result.result;
61
+ }
62
+ // Retry exhausted, try fallback
63
+ const fallbackKey = `${component}:${operationId}`;
64
+ const fallback = options?.fallback || this.fallbackHandlers.get(fallbackKey);
65
+ if (fallback) {
66
+ this.emit('fallback-used', {
67
+ component,
68
+ operationId,
69
+ reason: 'retry-exhausted',
70
+ attempts: result.attempts
71
+ });
72
+ return fallback();
73
+ }
74
+ throw result.error || new Error('Operation failed after all retries');
75
+ }
76
+ catch (error) {
77
+ // Record recovery event
78
+ this.recordRecoveryEvent({
79
+ timestamp: new Date(),
80
+ component,
81
+ strategy: 'retry',
82
+ success: false,
83
+ error: error instanceof Error ? error.message : String(error),
84
+ duration: 0,
85
+ });
86
+ throw error;
87
+ }
88
+ }
89
+ /**
90
+ * Attempt automatic recovery for a component
91
+ */
92
+ async attemptRecovery(component, error) {
93
+ const recoveryKey = `${component}:recovery`;
94
+ // Check if recovery is already in progress
95
+ if (this.recoveryInProgress.has(recoveryKey)) {
96
+ return {
97
+ success: false,
98
+ strategy: 'retry',
99
+ component,
100
+ action: 'skipped',
101
+ duration: 0,
102
+ error: 'Recovery already in progress',
103
+ };
104
+ }
105
+ // Check recovery rate limit
106
+ if (!this.canAttemptRecovery(component)) {
107
+ return {
108
+ success: false,
109
+ strategy: 'escalate',
110
+ component,
111
+ action: 'rate-limited',
112
+ duration: 0,
113
+ error: 'Recovery rate limit exceeded',
114
+ };
115
+ }
116
+ this.recoveryInProgress.add(recoveryKey);
117
+ const startTime = Date.now();
118
+ try {
119
+ // Get policy for component
120
+ const policy = this.getComponentPolicy(component);
121
+ // Try strategies in order
122
+ for (const strategy of policy.strategyOrder) {
123
+ const result = await this.executeRecoveryStrategy(component, strategy, error);
124
+ if (result.success) {
125
+ this.recordRecoveryEvent({
126
+ timestamp: new Date(),
127
+ component,
128
+ strategy,
129
+ success: true,
130
+ duration: Date.now() - startTime,
131
+ });
132
+ this.emit('recovery-success', { component, strategy, duration: result.duration });
133
+ return result;
134
+ }
135
+ }
136
+ // All strategies failed
137
+ const result = {
138
+ success: false,
139
+ strategy: 'escalate',
140
+ component,
141
+ action: 'all-strategies-failed',
142
+ duration: Date.now() - startTime,
143
+ error: 'All recovery strategies failed',
144
+ };
145
+ this.emit('recovery-failed', { component, error: error.message });
146
+ return result;
147
+ }
148
+ finally {
149
+ this.recoveryInProgress.delete(recoveryKey);
150
+ this.recordRecoveryAttempt(component);
151
+ }
152
+ }
153
+ /**
154
+ * Register fallback handler
155
+ */
156
+ registerFallback(component, operationId, handler) {
157
+ this.fallbackHandlers.set(`${component}:${operationId}`, handler);
158
+ }
159
+ /**
160
+ * Register health checker
161
+ */
162
+ registerHealthChecker(component, checker) {
163
+ this.healthCheckers.set(component, checker);
164
+ }
165
+ /**
166
+ * Check health of all components
167
+ */
168
+ async checkHealth() {
169
+ const components = [
170
+ 'transport', 'memory', 'orchestration', 'agent', 'workflow', 'database'
171
+ ];
172
+ for (const component of components) {
173
+ const checker = this.healthCheckers.get(component);
174
+ if (checker) {
175
+ try {
176
+ const health = await checker(component);
177
+ this.componentHealth.set(component, health);
178
+ }
179
+ catch (error) {
180
+ this.componentHealth.set(component, {
181
+ component,
182
+ status: 'unknown',
183
+ lastCheck: new Date(),
184
+ errorRate: 1,
185
+ latencyP95: 0,
186
+ details: { error: error instanceof Error ? error.message : String(error) },
187
+ });
188
+ }
189
+ }
190
+ }
191
+ return new Map(this.componentHealth);
192
+ }
193
+ /**
194
+ * Get component health
195
+ */
196
+ getComponentHealth(component) {
197
+ return this.componentHealth.get(component);
198
+ }
199
+ /**
200
+ * Get recovery history
201
+ */
202
+ getRecoveryHistory(limit) {
203
+ const history = [...this.recoveryHistory].reverse();
204
+ return limit ? history.slice(0, limit) : history;
205
+ }
206
+ /**
207
+ * Get recovery statistics
208
+ */
209
+ getStats() {
210
+ const total = this.recoveryHistory.length;
211
+ const successful = this.recoveryHistory.filter(e => e.success).length;
212
+ const byComponent = {};
213
+ const byStrategy = {};
214
+ for (const event of this.recoveryHistory) {
215
+ // By component
216
+ if (!byComponent[event.component]) {
217
+ byComponent[event.component] = { total: 0, successful: 0 };
218
+ }
219
+ byComponent[event.component].total++;
220
+ if (event.success)
221
+ byComponent[event.component].successful++;
222
+ // By strategy
223
+ if (!byStrategy[event.strategy]) {
224
+ byStrategy[event.strategy] = { total: 0, successful: 0 };
225
+ }
226
+ byStrategy[event.strategy].total++;
227
+ if (event.success)
228
+ byStrategy[event.strategy].successful++;
229
+ }
230
+ return {
231
+ totalRecoveries: total,
232
+ successfulRecoveries: successful,
233
+ failedRecoveries: total - successful,
234
+ successRate: total > 0 ? successful / total : 0,
235
+ byComponent,
236
+ byStrategy,
237
+ };
238
+ }
239
+ /**
240
+ * Reset circuit breakers for a component
241
+ */
242
+ resetCircuitBreakers(component) {
243
+ if (component) {
244
+ const metrics = this.circuitBreakerManager.getAllMetrics();
245
+ for (const [name] of metrics) {
246
+ if (name.startsWith(component)) {
247
+ this.circuitBreakerManager.getBreaker(name).reset();
248
+ }
249
+ }
250
+ }
251
+ else {
252
+ this.circuitBreakerManager.resetAll();
253
+ }
254
+ }
255
+ /**
256
+ * Initialize default retry strategies per component
257
+ */
258
+ initializeDefaultStrategies() {
259
+ this.retryStrategies.set('transport', new RetryStrategy_js_1.RetryStrategy({
260
+ maxAttempts: 4,
261
+ initialDelay: 1000,
262
+ backoffType: 'exponential',
263
+ retryableErrors: ['ECONNRESET', 'ETIMEDOUT', 'ECONNREFUSED'],
264
+ }));
265
+ this.retryStrategies.set('memory', new RetryStrategy_js_1.RetryStrategy({
266
+ maxAttempts: 3,
267
+ initialDelay: 500,
268
+ backoffType: 'exponential',
269
+ retryableErrors: ['SQLITE_BUSY', 'SQLITE_LOCKED'],
270
+ }));
271
+ this.retryStrategies.set('database', new RetryStrategy_js_1.RetryStrategy({
272
+ maxAttempts: 3,
273
+ initialDelay: 500,
274
+ backoffType: 'exponential',
275
+ retryableErrors: ['SQLITE_BUSY', 'connection', 'timeout'],
276
+ }));
277
+ this.retryStrategies.set('orchestration', new RetryStrategy_js_1.RetryStrategy({
278
+ maxAttempts: 2,
279
+ initialDelay: 2000,
280
+ backoffType: 'linear',
281
+ }));
282
+ this.retryStrategies.set('agent', new RetryStrategy_js_1.RetryStrategy({
283
+ maxAttempts: 2,
284
+ initialDelay: 1000,
285
+ backoffType: 'constant',
286
+ }));
287
+ this.retryStrategies.set('workflow', new RetryStrategy_js_1.RetryStrategy({
288
+ maxAttempts: 3,
289
+ initialDelay: 1000,
290
+ backoffType: 'exponential',
291
+ }));
292
+ }
293
+ /**
294
+ * Get retry strategy for component
295
+ */
296
+ getRetryStrategy(component, overrides) {
297
+ const baseStrategy = this.retryStrategies.get(component);
298
+ if (overrides && baseStrategy) {
299
+ return new RetryStrategy_js_1.RetryStrategy({
300
+ ...baseStrategy.getConfig(),
301
+ ...overrides,
302
+ });
303
+ }
304
+ return baseStrategy || new RetryStrategy_js_1.RetryStrategy();
305
+ }
306
+ /**
307
+ * Get policy for component
308
+ */
309
+ getComponentPolicy(component) {
310
+ const override = this.policy.componentOverrides?.[component];
311
+ if (override) {
312
+ return { ...this.policy, ...override };
313
+ }
314
+ return this.policy;
315
+ }
316
+ /**
317
+ * Execute a specific recovery strategy
318
+ */
319
+ async executeRecoveryStrategy(component, strategy, error) {
320
+ const startTime = Date.now();
321
+ try {
322
+ switch (strategy) {
323
+ case 'retry':
324
+ // Already handled by executeWithRecovery
325
+ return {
326
+ success: false,
327
+ strategy,
328
+ component,
329
+ action: 'no-op',
330
+ duration: 0,
331
+ };
332
+ case 'fallback':
333
+ const fallback = this.fallbackHandlers.get(`${component}:default`);
334
+ if (fallback) {
335
+ await fallback();
336
+ return {
337
+ success: true,
338
+ strategy,
339
+ component,
340
+ action: 'fallback-executed',
341
+ duration: Date.now() - startTime,
342
+ };
343
+ }
344
+ return {
345
+ success: false,
346
+ strategy,
347
+ component,
348
+ action: 'no-fallback-available',
349
+ duration: 0,
350
+ };
351
+ case 'circuit-break':
352
+ // Reset circuit breakers for component
353
+ this.resetCircuitBreakers(component);
354
+ return {
355
+ success: true,
356
+ strategy,
357
+ component,
358
+ action: 'circuits-reset',
359
+ duration: Date.now() - startTime,
360
+ };
361
+ case 'graceful-degradation':
362
+ this.emit('degradation-mode', { component, reason: error.message });
363
+ return {
364
+ success: true,
365
+ strategy,
366
+ component,
367
+ action: 'degradation-activated',
368
+ duration: Date.now() - startTime,
369
+ };
370
+ case 'rollback':
371
+ this.emit('rollback-requested', { component, error: error.message });
372
+ return {
373
+ success: false, // Rollback is async, can't confirm success
374
+ strategy,
375
+ component,
376
+ action: 'rollback-requested',
377
+ duration: Date.now() - startTime,
378
+ };
379
+ case 'escalate':
380
+ this.emit('escalation', { component, error: error.message });
381
+ return {
382
+ success: false,
383
+ strategy,
384
+ component,
385
+ action: 'escalated',
386
+ duration: Date.now() - startTime,
387
+ metadata: { requiresManualIntervention: true },
388
+ };
389
+ default:
390
+ return {
391
+ success: false,
392
+ strategy,
393
+ component,
394
+ action: 'unknown-strategy',
395
+ duration: 0,
396
+ };
397
+ }
398
+ }
399
+ catch (strategyError) {
400
+ return {
401
+ success: false,
402
+ strategy,
403
+ component,
404
+ action: 'strategy-failed',
405
+ duration: Date.now() - startTime,
406
+ error: strategyError instanceof Error ? strategyError.message : String(strategyError),
407
+ };
408
+ }
409
+ }
410
+ /**
411
+ * Check if recovery can be attempted (rate limiting)
412
+ */
413
+ canAttemptRecovery(component) {
414
+ const key = `${component}:recovery`;
415
+ const attempts = this.lastRecoveryAttempts.get(key) || [];
416
+ const now = Date.now();
417
+ const oneMinuteAgo = now - 60000;
418
+ // Filter to last minute
419
+ const recentAttempts = attempts.filter(t => t > oneMinuteAgo);
420
+ this.lastRecoveryAttempts.set(key, recentAttempts);
421
+ return recentAttempts.length < this.policy.maxRecoveryRate;
422
+ }
423
+ /**
424
+ * Record recovery attempt for rate limiting
425
+ */
426
+ recordRecoveryAttempt(component) {
427
+ const key = `${component}:recovery`;
428
+ const attempts = this.lastRecoveryAttempts.get(key) || [];
429
+ attempts.push(Date.now());
430
+ this.lastRecoveryAttempts.set(key, attempts);
431
+ }
432
+ /**
433
+ * Record recovery event
434
+ */
435
+ recordRecoveryEvent(event) {
436
+ this.recoveryHistory.push(event);
437
+ // Keep only last 1000 events
438
+ if (this.recoveryHistory.length > 1000) {
439
+ this.recoveryHistory = this.recoveryHistory.slice(-1000);
440
+ }
441
+ }
442
+ /**
443
+ * Cleanup resources
444
+ */
445
+ destroy() {
446
+ this.removeAllListeners();
447
+ this.recoveryHistory = [];
448
+ this.componentHealth.clear();
449
+ this.fallbackHandlers.clear();
450
+ this.healthCheckers.clear();
451
+ }
452
+ }
453
+ exports.RecoveryOrchestrator = RecoveryOrchestrator;
454
+ /**
455
+ * Default recovery orchestrator instance
456
+ */
457
+ let defaultOrchestrator = null;
458
+ /**
459
+ * Get default recovery orchestrator
460
+ */
461
+ function getRecoveryOrchestrator(policy) {
462
+ if (!defaultOrchestrator) {
463
+ defaultOrchestrator = new RecoveryOrchestrator(policy);
464
+ }
465
+ return defaultOrchestrator;
466
+ }
467
+ /**
468
+ * Reset default orchestrator (for testing)
469
+ */
470
+ function resetRecoveryOrchestrator() {
471
+ if (defaultOrchestrator) {
472
+ defaultOrchestrator.destroy();
473
+ defaultOrchestrator = null;
474
+ }
475
+ }
476
+ //# sourceMappingURL=RecoveryOrchestrator.js.map