agentic-qe 1.9.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/qe-api-contract-validator.md +95 -1336
- package/.claude/agents/qe-chaos-engineer.md +152 -1211
- package/.claude/agents/qe-code-complexity.md +144 -707
- package/.claude/agents/qe-coverage-analyzer.md +147 -743
- package/.claude/agents/qe-deployment-readiness.md +143 -1496
- package/.claude/agents/qe-flaky-test-hunter.md +132 -1529
- package/.claude/agents/qe-fleet-commander.md +12 -12
- package/.claude/agents/qe-performance-tester.md +150 -886
- package/.claude/agents/qe-production-intelligence.md +155 -1396
- package/.claude/agents/qe-quality-analyzer.md +6 -6
- package/.claude/agents/qe-quality-gate.md +151 -648
- package/.claude/agents/qe-regression-risk-analyzer.md +132 -1150
- package/.claude/agents/qe-requirements-validator.md +149 -932
- package/.claude/agents/qe-security-scanner.md +157 -797
- package/.claude/agents/qe-test-data-architect.md +96 -1365
- package/.claude/agents/qe-test-executor.md +8 -8
- package/.claude/agents/qe-test-generator.md +145 -1540
- package/.claude/agents/qe-visual-tester.md +153 -1257
- package/.claude/agents/qx-partner.md +248 -0
- package/.claude/agents/subagents/qe-code-reviewer.md +40 -136
- package/.claude/agents/subagents/qe-coverage-gap-analyzer.md +40 -480
- package/.claude/agents/subagents/qe-data-generator.md +41 -125
- package/.claude/agents/subagents/qe-flaky-investigator.md +55 -411
- package/.claude/agents/subagents/qe-integration-tester.md +53 -141
- package/.claude/agents/subagents/qe-performance-validator.md +54 -130
- package/.claude/agents/subagents/qe-security-auditor.md +56 -114
- package/.claude/agents/subagents/qe-test-data-architect-sub.md +57 -548
- package/.claude/agents/subagents/qe-test-implementer.md +58 -551
- package/.claude/agents/subagents/qe-test-refactorer.md +65 -722
- package/.claude/agents/subagents/qe-test-writer.md +63 -726
- package/.claude/skills/accessibility-testing/SKILL.md +144 -692
- package/.claude/skills/agentic-quality-engineering/SKILL.md +176 -529
- package/.claude/skills/api-testing-patterns/SKILL.md +180 -560
- package/.claude/skills/brutal-honesty-review/SKILL.md +113 -603
- package/.claude/skills/bug-reporting-excellence/SKILL.md +116 -517
- package/.claude/skills/chaos-engineering-resilience/SKILL.md +127 -72
- package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +209 -404
- package/.claude/skills/code-review-quality/SKILL.md +158 -608
- package/.claude/skills/compatibility-testing/SKILL.md +148 -38
- package/.claude/skills/compliance-testing/SKILL.md +132 -63
- package/.claude/skills/consultancy-practices/SKILL.md +114 -446
- package/.claude/skills/context-driven-testing/SKILL.md +117 -381
- package/.claude/skills/contract-testing/SKILL.md +176 -141
- package/.claude/skills/database-testing/SKILL.md +137 -130
- package/.claude/skills/exploratory-testing-advanced/SKILL.md +160 -629
- package/.claude/skills/holistic-testing-pact/SKILL.md +140 -188
- package/.claude/skills/localization-testing/SKILL.md +145 -33
- package/.claude/skills/mobile-testing/SKILL.md +132 -448
- package/.claude/skills/mutation-testing/SKILL.md +147 -41
- package/.claude/skills/performance-testing/SKILL.md +200 -546
- package/.claude/skills/quality-metrics/SKILL.md +164 -519
- package/.claude/skills/refactoring-patterns/SKILL.md +132 -699
- package/.claude/skills/regression-testing/SKILL.md +120 -926
- package/.claude/skills/risk-based-testing/SKILL.md +157 -660
- package/.claude/skills/security-testing/SKILL.md +199 -538
- package/.claude/skills/sherlock-review/SKILL.md +163 -699
- package/.claude/skills/shift-left-testing/SKILL.md +161 -465
- package/.claude/skills/shift-right-testing/SKILL.md +161 -519
- package/.claude/skills/six-thinking-hats/SKILL.md +175 -1110
- package/.claude/skills/skills-manifest.json +683 -0
- package/.claude/skills/tdd-london-chicago/SKILL.md +131 -448
- package/.claude/skills/technical-writing/SKILL.md +103 -154
- package/.claude/skills/test-automation-strategy/SKILL.md +166 -772
- package/.claude/skills/test-data-management/SKILL.md +126 -910
- package/.claude/skills/test-design-techniques/SKILL.md +179 -89
- package/.claude/skills/test-environment-management/SKILL.md +136 -91
- package/.claude/skills/test-reporting-analytics/SKILL.md +169 -92
- package/.claude/skills/testability-scoring/README.md +71 -0
- package/.claude/skills/testability-scoring/SKILL.md +245 -0
- package/.claude/skills/testability-scoring/resources/templates/config.template.js +84 -0
- package/.claude/skills/testability-scoring/resources/templates/testability-scoring.spec.template.js +532 -0
- package/.claude/skills/testability-scoring/scripts/generate-html-report.js +1007 -0
- package/.claude/skills/testability-scoring/scripts/run-assessment.sh +70 -0
- package/.claude/skills/visual-testing-advanced/SKILL.md +155 -78
- package/.claude/skills/xp-practices/SKILL.md +151 -587
- package/CHANGELOG.md +110 -0
- package/README.md +55 -21
- package/dist/agents/QXPartnerAgent.d.ts +146 -0
- package/dist/agents/QXPartnerAgent.d.ts.map +1 -0
- package/dist/agents/QXPartnerAgent.js +1831 -0
- package/dist/agents/QXPartnerAgent.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +82 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/lifecycle/AgentLifecycleManager.d.ts.map +1 -1
- package/dist/agents/lifecycle/AgentLifecycleManager.js +34 -31
- package/dist/agents/lifecycle/AgentLifecycleManager.js.map +1 -1
- package/dist/cli/commands/debug/agent.d.ts.map +1 -1
- package/dist/cli/commands/debug/agent.js +19 -6
- package/dist/cli/commands/debug/agent.js.map +1 -1
- package/dist/cli/commands/debug/health-check.js +20 -7
- package/dist/cli/commands/debug/health-check.js.map +1 -1
- package/dist/cli/commands/init-claude-md-template.d.ts +1 -0
- package/dist/cli/commands/init-claude-md-template.d.ts.map +1 -1
- package/dist/cli/commands/init-claude-md-template.js +18 -3
- package/dist/cli/commands/init-claude-md-template.js.map +1 -1
- package/dist/cli/commands/workflow/cancel.d.ts.map +1 -1
- package/dist/cli/commands/workflow/cancel.js +4 -3
- package/dist/cli/commands/workflow/cancel.js.map +1 -1
- package/dist/cli/commands/workflow/list.d.ts.map +1 -1
- package/dist/cli/commands/workflow/list.js +4 -3
- package/dist/cli/commands/workflow/list.js.map +1 -1
- package/dist/cli/commands/workflow/pause.d.ts.map +1 -1
- package/dist/cli/commands/workflow/pause.js +4 -3
- package/dist/cli/commands/workflow/pause.js.map +1 -1
- package/dist/cli/init/claude-config.d.ts.map +1 -1
- package/dist/cli/init/claude-config.js +3 -8
- package/dist/cli/init/claude-config.js.map +1 -1
- package/dist/cli/init/claude-md.d.ts.map +1 -1
- package/dist/cli/init/claude-md.js +44 -2
- package/dist/cli/init/claude-md.js.map +1 -1
- package/dist/cli/init/database-init.js +1 -1
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/index.js +13 -6
- package/dist/cli/init/index.js.map +1 -1
- package/dist/cli/init/skills.d.ts.map +1 -1
- package/dist/cli/init/skills.js +2 -1
- package/dist/cli/init/skills.js.map +1 -1
- package/dist/core/SwarmCoordinator.d.ts +180 -0
- package/dist/core/SwarmCoordinator.d.ts.map +1 -0
- package/dist/core/SwarmCoordinator.js +473 -0
- package/dist/core/SwarmCoordinator.js.map +1 -0
- package/dist/core/memory/AgentDBIntegration.d.ts +24 -6
- package/dist/core/memory/AgentDBIntegration.d.ts.map +1 -1
- package/dist/core/memory/AgentDBIntegration.js +66 -10
- package/dist/core/memory/AgentDBIntegration.js.map +1 -1
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts +341 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts.map +1 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.js +986 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.js.map +1 -0
- package/dist/core/memory/index.d.ts +5 -0
- package/dist/core/memory/index.d.ts.map +1 -1
- package/dist/core/memory/index.js +23 -1
- package/dist/core/memory/index.js.map +1 -1
- package/dist/core/metrics/MetricsAggregator.d.ts +228 -0
- package/dist/core/metrics/MetricsAggregator.d.ts.map +1 -0
- package/dist/core/metrics/MetricsAggregator.js +482 -0
- package/dist/core/metrics/MetricsAggregator.js.map +1 -0
- package/dist/core/metrics/index.d.ts +5 -0
- package/dist/core/metrics/index.d.ts.map +1 -0
- package/dist/core/metrics/index.js +11 -0
- package/dist/core/metrics/index.js.map +1 -0
- package/dist/core/optimization/SwarmOptimizer.d.ts +190 -0
- package/dist/core/optimization/SwarmOptimizer.d.ts.map +1 -0
- package/dist/core/optimization/SwarmOptimizer.js +648 -0
- package/dist/core/optimization/SwarmOptimizer.js.map +1 -0
- package/dist/core/optimization/index.d.ts +9 -0
- package/dist/core/optimization/index.d.ts.map +1 -0
- package/dist/core/optimization/index.js +25 -0
- package/dist/core/optimization/index.js.map +1 -0
- package/dist/core/optimization/types.d.ts +53 -0
- package/dist/core/optimization/types.d.ts.map +1 -0
- package/dist/core/optimization/types.js +6 -0
- package/dist/core/optimization/types.js.map +1 -0
- package/dist/core/orchestration/AdaptiveScheduler.d.ts +190 -0
- package/dist/core/orchestration/AdaptiveScheduler.d.ts.map +1 -0
- package/dist/core/orchestration/AdaptiveScheduler.js +460 -0
- package/dist/core/orchestration/AdaptiveScheduler.js.map +1 -0
- package/dist/core/orchestration/PriorityQueue.d.ts +54 -0
- package/dist/core/orchestration/PriorityQueue.d.ts.map +1 -0
- package/dist/core/orchestration/PriorityQueue.js +122 -0
- package/dist/core/orchestration/PriorityQueue.js.map +1 -0
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts +189 -0
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts.map +1 -0
- package/dist/core/orchestration/WorkflowOrchestrator.js +845 -0
- package/dist/core/orchestration/WorkflowOrchestrator.js.map +1 -0
- package/dist/core/orchestration/index.d.ts +7 -0
- package/dist/core/orchestration/index.d.ts.map +1 -0
- package/dist/core/orchestration/index.js +11 -0
- package/dist/core/orchestration/index.js.map +1 -0
- package/dist/core/orchestration/types.d.ts +96 -0
- package/dist/core/orchestration/types.d.ts.map +1 -0
- package/dist/core/orchestration/types.js +6 -0
- package/dist/core/orchestration/types.js.map +1 -0
- package/dist/core/recovery/CircuitBreaker.d.ts +176 -0
- package/dist/core/recovery/CircuitBreaker.d.ts.map +1 -0
- package/dist/core/recovery/CircuitBreaker.js +382 -0
- package/dist/core/recovery/CircuitBreaker.js.map +1 -0
- package/dist/core/recovery/RecoveryOrchestrator.d.ts +186 -0
- package/dist/core/recovery/RecoveryOrchestrator.d.ts.map +1 -0
- package/dist/core/recovery/RecoveryOrchestrator.js +476 -0
- package/dist/core/recovery/RecoveryOrchestrator.js.map +1 -0
- package/dist/core/recovery/RetryStrategy.d.ts +127 -0
- package/dist/core/recovery/RetryStrategy.d.ts.map +1 -0
- package/dist/core/recovery/RetryStrategy.js +314 -0
- package/dist/core/recovery/RetryStrategy.js.map +1 -0
- package/dist/core/recovery/index.d.ts +8 -0
- package/dist/core/recovery/index.d.ts.map +1 -0
- package/dist/core/recovery/index.js +27 -0
- package/dist/core/recovery/index.js.map +1 -0
- package/dist/core/skills/DependencyResolver.d.ts +99 -0
- package/dist/core/skills/DependencyResolver.d.ts.map +1 -0
- package/dist/core/skills/DependencyResolver.js +260 -0
- package/dist/core/skills/DependencyResolver.js.map +1 -0
- package/dist/core/skills/DynamicSkillLoader.d.ts +96 -0
- package/dist/core/skills/DynamicSkillLoader.d.ts.map +1 -0
- package/dist/core/skills/DynamicSkillLoader.js +353 -0
- package/dist/core/skills/DynamicSkillLoader.js.map +1 -0
- package/dist/core/skills/ManifestGenerator.d.ts +114 -0
- package/dist/core/skills/ManifestGenerator.d.ts.map +1 -0
- package/dist/core/skills/ManifestGenerator.js +449 -0
- package/dist/core/skills/ManifestGenerator.js.map +1 -0
- package/dist/core/skills/index.d.ts +9 -0
- package/dist/core/skills/index.d.ts.map +1 -0
- package/dist/core/skills/index.js +24 -0
- package/dist/core/skills/index.js.map +1 -0
- package/dist/core/skills/types.d.ts +118 -0
- package/dist/core/skills/types.d.ts.map +1 -0
- package/dist/core/skills/types.js +7 -0
- package/dist/core/skills/types.js.map +1 -0
- package/dist/core/transport/QUICTransport.d.ts +320 -0
- package/dist/core/transport/QUICTransport.d.ts.map +1 -0
- package/dist/core/transport/QUICTransport.js +711 -0
- package/dist/core/transport/QUICTransport.js.map +1 -0
- package/dist/core/transport/index.d.ts +40 -0
- package/dist/core/transport/index.d.ts.map +1 -0
- package/dist/core/transport/index.js +46 -0
- package/dist/core/transport/index.js.map +1 -0
- package/dist/core/transport/quic-loader.d.ts +123 -0
- package/dist/core/transport/quic-loader.d.ts.map +1 -0
- package/dist/core/transport/quic-loader.js +293 -0
- package/dist/core/transport/quic-loader.js.map +1 -0
- package/dist/core/transport/quic.d.ts +154 -0
- package/dist/core/transport/quic.d.ts.map +1 -0
- package/dist/core/transport/quic.js +214 -0
- package/dist/core/transport/quic.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -9
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +1 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
- package/dist/mcp/services/AgentRegistry.js +4 -1
- package/dist/mcp/services/AgentRegistry.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/qx.d.ts +429 -0
- package/dist/types/qx.d.ts.map +1 -0
- package/dist/types/qx.js +71 -0
- package/dist/types/qx.js.map +1 -0
- package/dist/visualization/api/RestEndpoints.js +2 -2
- package/dist/visualization/api/RestEndpoints.js.map +1 -1
- package/dist/visualization/api/WebSocketServer.d.ts +44 -0
- package/dist/visualization/api/WebSocketServer.d.ts.map +1 -1
- package/dist/visualization/api/WebSocketServer.js +144 -23
- package/dist/visualization/api/WebSocketServer.js.map +1 -1
- package/dist/visualization/core/DataTransformer.d.ts +10 -0
- package/dist/visualization/core/DataTransformer.d.ts.map +1 -1
- package/dist/visualization/core/DataTransformer.js +60 -5
- package/dist/visualization/core/DataTransformer.js.map +1 -1
- package/dist/visualization/emit-event.d.ts +75 -0
- package/dist/visualization/emit-event.d.ts.map +1 -0
- package/dist/visualization/emit-event.js +213 -0
- package/dist/visualization/emit-event.js.map +1 -0
- package/dist/visualization/index.d.ts +1 -0
- package/dist/visualization/index.d.ts.map +1 -1
- package/dist/visualization/index.js +7 -1
- package/dist/visualization/index.js.map +1 -1
- package/docs/reference/skills.md +63 -1
- package/package.json +16 -58
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryOrchestrator.js","sourceRoot":"","sources":["../../../src/core/recovery/RecoveryOrchestrator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8nBH,0DAOC;AAKD,8DAKC;AA7oBD,mCAAsC;AACtC,2DAAoH;AACpH,yDAA6E;AA6F7E;;GAEG;AACH,MAAa,oBAAqB,SAAQ,qBAAY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AAI,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF;AAhhBD,oDAghBC;AAED;;GAEG;AACH,IAAI,mBAAmB,GAAgC,IAAI,CAAC;AAE5D;;GAEG;AACH,SAAgB,uBAAuB,CACrC,MAAgC;IAEhC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,mBAAmB,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB;IACvC,IAAI,mBAAmB,EAAE,CAAC;QACxB,mBAAmB,CAAC,OAAO,EAAE,CAAC;QAC9B,mBAAmB,GAAG,IAAI,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry Strategy with Multiple Backoff Algorithms
|
|
3
|
+
* Provides configurable retry logic for transient failures
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Backoff strategy types
|
|
7
|
+
*/
|
|
8
|
+
export type BackoffType = 'exponential' | 'linear' | 'constant' | 'fibonacci' | 'decorrelated-jitter';
|
|
9
|
+
/**
|
|
10
|
+
* Retry configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface RetryConfig {
|
|
13
|
+
/** Maximum number of retry attempts */
|
|
14
|
+
maxAttempts: number;
|
|
15
|
+
/** Initial delay in milliseconds */
|
|
16
|
+
initialDelay: number;
|
|
17
|
+
/** Maximum delay in milliseconds */
|
|
18
|
+
maxDelay: number;
|
|
19
|
+
/** Backoff strategy */
|
|
20
|
+
backoffType: BackoffType;
|
|
21
|
+
/** Multiplier for exponential backoff */
|
|
22
|
+
multiplier: number;
|
|
23
|
+
/** Add randomization to delays */
|
|
24
|
+
jitter: boolean;
|
|
25
|
+
/** Jitter factor (0-1) */
|
|
26
|
+
jitterFactor: number;
|
|
27
|
+
/** Errors that should trigger retry */
|
|
28
|
+
retryableErrors?: string[];
|
|
29
|
+
/** Errors that should NOT trigger retry */
|
|
30
|
+
nonRetryableErrors?: string[];
|
|
31
|
+
/** Custom function to determine if error is retryable */
|
|
32
|
+
isRetryable?: (error: Error) => boolean;
|
|
33
|
+
/** Callback on each retry attempt */
|
|
34
|
+
onRetry?: (attempt: number, error: Error, delay: number) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retry result with metadata
|
|
38
|
+
*/
|
|
39
|
+
export interface RetryResult<T> {
|
|
40
|
+
success: boolean;
|
|
41
|
+
result?: T;
|
|
42
|
+
error?: Error;
|
|
43
|
+
attempts: number;
|
|
44
|
+
totalDelay: number;
|
|
45
|
+
retryHistory: {
|
|
46
|
+
attempt: number;
|
|
47
|
+
delay: number;
|
|
48
|
+
error: string;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Retry context for tracking state
|
|
53
|
+
*/
|
|
54
|
+
export interface RetryContext {
|
|
55
|
+
attempt: number;
|
|
56
|
+
totalAttempts: number;
|
|
57
|
+
lastDelay: number;
|
|
58
|
+
totalDelay: number;
|
|
59
|
+
startTime: number;
|
|
60
|
+
errors: Error[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retry Strategy Implementation
|
|
64
|
+
*/
|
|
65
|
+
export declare class RetryStrategy {
|
|
66
|
+
private config;
|
|
67
|
+
private fibonacciCache;
|
|
68
|
+
constructor(config?: Partial<RetryConfig>);
|
|
69
|
+
/**
|
|
70
|
+
* Execute operation with retry logic
|
|
71
|
+
*/
|
|
72
|
+
execute<T>(operation: () => Promise<T>): Promise<RetryResult<T>>;
|
|
73
|
+
/**
|
|
74
|
+
* Determine if error is retryable
|
|
75
|
+
*/
|
|
76
|
+
shouldRetry(error: Error, context: RetryContext): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate delay for next retry attempt
|
|
79
|
+
*/
|
|
80
|
+
calculateDelay(context: RetryContext): number;
|
|
81
|
+
/**
|
|
82
|
+
* Apply jitter to delay
|
|
83
|
+
*/
|
|
84
|
+
private applyJitter;
|
|
85
|
+
/**
|
|
86
|
+
* Get fibonacci number (cached for performance)
|
|
87
|
+
*/
|
|
88
|
+
private getFibonacci;
|
|
89
|
+
/**
|
|
90
|
+
* Random number between min and max
|
|
91
|
+
*/
|
|
92
|
+
private randomBetween;
|
|
93
|
+
/**
|
|
94
|
+
* Sleep for specified milliseconds
|
|
95
|
+
*/
|
|
96
|
+
private sleep;
|
|
97
|
+
/**
|
|
98
|
+
* Get current configuration
|
|
99
|
+
*/
|
|
100
|
+
getConfig(): RetryConfig;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Retry decorator for async functions
|
|
104
|
+
*/
|
|
105
|
+
export declare function withRetry<T>(operation: () => Promise<T>, config?: Partial<RetryConfig>): Promise<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Create a retryable wrapper for a function
|
|
108
|
+
*/
|
|
109
|
+
export declare function createRetryable<TArgs extends any[], TResult>(fn: (...args: TArgs) => Promise<TResult>, config?: Partial<RetryConfig>): (...args: TArgs) => Promise<RetryResult<TResult>>;
|
|
110
|
+
/**
|
|
111
|
+
* Predefined retry strategies for common use cases
|
|
112
|
+
*/
|
|
113
|
+
export declare const RetryStrategies: {
|
|
114
|
+
/** Fast retry for quick transient failures */
|
|
115
|
+
fast: RetryStrategy;
|
|
116
|
+
/** Standard retry for most operations */
|
|
117
|
+
standard: RetryStrategy;
|
|
118
|
+
/** Aggressive retry for critical operations */
|
|
119
|
+
aggressive: RetryStrategy;
|
|
120
|
+
/** Gentle retry for rate-limited APIs */
|
|
121
|
+
rateLimited: RetryStrategy;
|
|
122
|
+
/** Database retry for connection issues */
|
|
123
|
+
database: RetryStrategy;
|
|
124
|
+
/** Network retry for HTTP calls */
|
|
125
|
+
network: RetryStrategy;
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=RetryStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryStrategy.d.ts","sourceRoot":"","sources":["../../../src/core/recovery/RetryStrategy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,qBAAqB,CAAC;AAEtG;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,yDAAyD;IACzD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IACxC,qCAAqC;IACrC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KA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