erosolar-cli 1.7.262 → 1.7.263
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/README.md +148 -22
- package/dist/alpha-zero/agentWrapper.d.ts +84 -0
- package/dist/alpha-zero/agentWrapper.d.ts.map +1 -0
- package/dist/alpha-zero/agentWrapper.js +171 -0
- package/dist/alpha-zero/agentWrapper.js.map +1 -0
- package/dist/alpha-zero/codeEvaluator.d.ts +25 -0
- package/dist/alpha-zero/codeEvaluator.d.ts.map +1 -0
- package/dist/alpha-zero/codeEvaluator.js +273 -0
- package/dist/alpha-zero/codeEvaluator.js.map +1 -0
- package/dist/alpha-zero/competitiveRunner.d.ts +66 -0
- package/dist/alpha-zero/competitiveRunner.d.ts.map +1 -0
- package/dist/alpha-zero/competitiveRunner.js +224 -0
- package/dist/alpha-zero/competitiveRunner.js.map +1 -0
- package/dist/alpha-zero/index.d.ts +67 -0
- package/dist/alpha-zero/index.d.ts.map +1 -0
- package/dist/alpha-zero/index.js +99 -0
- package/dist/alpha-zero/index.js.map +1 -0
- package/dist/alpha-zero/introspection.d.ts +128 -0
- package/dist/alpha-zero/introspection.d.ts.map +1 -0
- package/dist/alpha-zero/introspection.js +300 -0
- package/dist/alpha-zero/introspection.js.map +1 -0
- package/dist/alpha-zero/metricsTracker.d.ts +71 -0
- package/dist/alpha-zero/metricsTracker.d.ts.map +1 -0
- package/dist/{core → alpha-zero}/metricsTracker.js +5 -2
- package/dist/alpha-zero/metricsTracker.js.map +1 -0
- package/dist/alpha-zero/security/core.d.ts +125 -0
- package/dist/alpha-zero/security/core.d.ts.map +1 -0
- package/dist/alpha-zero/security/core.js +271 -0
- package/dist/alpha-zero/security/core.js.map +1 -0
- package/dist/alpha-zero/security/google.d.ts +125 -0
- package/dist/alpha-zero/security/google.d.ts.map +1 -0
- package/dist/alpha-zero/security/google.js +311 -0
- package/dist/alpha-zero/security/google.js.map +1 -0
- package/dist/alpha-zero/security/googleLoader.d.ts +17 -0
- package/dist/alpha-zero/security/googleLoader.d.ts.map +1 -0
- package/dist/alpha-zero/security/googleLoader.js +41 -0
- package/dist/alpha-zero/security/googleLoader.js.map +1 -0
- package/dist/alpha-zero/security/index.d.ts +29 -0
- package/dist/alpha-zero/security/index.d.ts.map +1 -0
- package/dist/alpha-zero/security/index.js +32 -0
- package/dist/alpha-zero/security/index.js.map +1 -0
- package/dist/alpha-zero/security/simulation.d.ts +124 -0
- package/dist/alpha-zero/security/simulation.d.ts.map +1 -0
- package/dist/alpha-zero/security/simulation.js +277 -0
- package/dist/alpha-zero/security/simulation.js.map +1 -0
- package/dist/alpha-zero/selfModification.d.ts +109 -0
- package/dist/alpha-zero/selfModification.d.ts.map +1 -0
- package/dist/alpha-zero/selfModification.js +233 -0
- package/dist/alpha-zero/selfModification.js.map +1 -0
- package/dist/alpha-zero/types.d.ts +170 -0
- package/dist/alpha-zero/types.d.ts.map +1 -0
- package/dist/alpha-zero/types.js +31 -0
- package/dist/alpha-zero/types.js.map +1 -0
- package/dist/capabilities/securityTestingCapability.d.ts +13 -0
- package/dist/capabilities/securityTestingCapability.d.ts.map +1 -0
- package/dist/capabilities/securityTestingCapability.js +25 -0
- package/dist/capabilities/securityTestingCapability.js.map +1 -0
- package/dist/contracts/agent-schemas.json +15 -0
- package/dist/contracts/tools.schema.json +9 -0
- package/dist/core/aiFlowOptimizer.d.ts +26 -0
- package/dist/core/aiFlowOptimizer.d.ts.map +1 -0
- package/dist/core/aiFlowOptimizer.js +31 -0
- package/dist/core/aiFlowOptimizer.js.map +1 -0
- package/dist/core/aiOptimizationEngine.d.ts +158 -0
- package/dist/core/aiOptimizationEngine.d.ts.map +1 -0
- package/dist/core/aiOptimizationEngine.js +428 -0
- package/dist/core/aiOptimizationEngine.js.map +1 -0
- package/dist/core/aiOptimizationIntegration.d.ts +93 -0
- package/dist/core/aiOptimizationIntegration.d.ts.map +1 -0
- package/dist/core/aiOptimizationIntegration.js +250 -0
- package/dist/core/aiOptimizationIntegration.js.map +1 -0
- package/dist/core/customCommands.d.ts +0 -1
- package/dist/core/customCommands.d.ts.map +1 -1
- package/dist/core/customCommands.js +0 -3
- package/dist/core/customCommands.js.map +1 -1
- package/dist/core/enhancedErrorRecovery.d.ts +100 -0
- package/dist/core/enhancedErrorRecovery.d.ts.map +1 -0
- package/dist/core/enhancedErrorRecovery.js +345 -0
- package/dist/core/enhancedErrorRecovery.js.map +1 -0
- package/dist/core/hooksSystem.d.ts +65 -0
- package/dist/core/hooksSystem.d.ts.map +1 -0
- package/dist/core/hooksSystem.js +273 -0
- package/dist/core/hooksSystem.js.map +1 -0
- package/dist/core/memorySystem.d.ts +48 -0
- package/dist/core/memorySystem.d.ts.map +1 -0
- package/dist/core/memorySystem.js +271 -0
- package/dist/core/memorySystem.js.map +1 -0
- package/dist/core/toolPreconditions.d.ts.map +1 -1
- package/dist/core/toolPreconditions.js +14 -0
- package/dist/core/toolPreconditions.js.map +1 -1
- package/dist/core/toolRuntime.d.ts.map +1 -1
- package/dist/core/toolRuntime.js +5 -0
- package/dist/core/toolRuntime.js.map +1 -1
- package/dist/core/toolValidation.d.ts.map +1 -1
- package/dist/core/toolValidation.js +3 -14
- package/dist/core/toolValidation.js.map +1 -1
- package/dist/core/unified/errors.d.ts +189 -0
- package/dist/core/unified/errors.d.ts.map +1 -0
- package/dist/core/unified/errors.js +497 -0
- package/dist/core/unified/errors.js.map +1 -0
- package/dist/core/unified/index.d.ts +19 -0
- package/dist/core/unified/index.d.ts.map +1 -0
- package/dist/core/unified/index.js +68 -0
- package/dist/core/unified/index.js.map +1 -0
- package/dist/core/unified/schema.d.ts +101 -0
- package/dist/core/unified/schema.d.ts.map +1 -0
- package/dist/core/unified/schema.js +350 -0
- package/dist/core/unified/schema.js.map +1 -0
- package/dist/core/unified/toolRuntime.d.ts +179 -0
- package/dist/core/unified/toolRuntime.d.ts.map +1 -0
- package/dist/core/unified/toolRuntime.js +517 -0
- package/dist/core/unified/toolRuntime.js.map +1 -0
- package/dist/core/unified/tools.d.ts +127 -0
- package/dist/core/unified/tools.d.ts.map +1 -0
- package/dist/core/unified/tools.js +1333 -0
- package/dist/core/unified/tools.js.map +1 -0
- package/dist/core/unified/types.d.ts +352 -0
- package/dist/core/unified/types.d.ts.map +1 -0
- package/dist/core/unified/types.js +12 -0
- package/dist/core/unified/types.js.map +1 -0
- package/dist/core/unified/version.d.ts +209 -0
- package/dist/core/unified/version.d.ts.map +1 -0
- package/dist/core/unified/version.js +454 -0
- package/dist/core/unified/version.js.map +1 -0
- package/dist/core/validationRunner.d.ts +3 -1
- package/dist/core/validationRunner.d.ts.map +1 -1
- package/dist/core/validationRunner.js.map +1 -1
- package/dist/mcp/sseClient.d.ts.map +1 -1
- package/dist/mcp/sseClient.js +18 -9
- package/dist/mcp/sseClient.js.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.d.ts +6 -0
- package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.js +10 -4
- package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +2 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/plugins/tools/security/securityPlugin.d.ts +3 -0
- package/dist/plugins/tools/security/securityPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/security/securityPlugin.js +12 -0
- package/dist/plugins/tools/security/securityPlugin.js.map +1 -0
- package/dist/security/active-stack-security.d.ts +112 -0
- package/dist/security/active-stack-security.d.ts.map +1 -0
- package/dist/security/active-stack-security.js +296 -0
- package/dist/security/active-stack-security.js.map +1 -0
- package/dist/security/advanced-persistence-research.d.ts +92 -0
- package/dist/security/advanced-persistence-research.d.ts.map +1 -0
- package/dist/security/advanced-persistence-research.js +195 -0
- package/dist/security/advanced-persistence-research.js.map +1 -0
- package/dist/security/advanced-targeting.d.ts +119 -0
- package/dist/security/advanced-targeting.d.ts.map +1 -0
- package/dist/security/advanced-targeting.js +233 -0
- package/dist/security/advanced-targeting.js.map +1 -0
- package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
- package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
- package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
- package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
- package/dist/security/authorization/securityAuthorization.d.ts +88 -0
- package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
- package/dist/security/authorization/securityAuthorization.js +172 -0
- package/dist/security/authorization/securityAuthorization.js.map +1 -0
- package/dist/security/comprehensive-targeting.d.ts +85 -0
- package/dist/security/comprehensive-targeting.d.ts.map +1 -0
- package/dist/security/comprehensive-targeting.js +438 -0
- package/dist/security/comprehensive-targeting.js.map +1 -0
- package/dist/security/global-security-integration.d.ts +91 -0
- package/dist/security/global-security-integration.d.ts.map +1 -0
- package/dist/security/global-security-integration.js +218 -0
- package/dist/security/global-security-integration.js.map +1 -0
- package/dist/security/index.d.ts +38 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +47 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/persistence-analyzer.d.ts +56 -0
- package/dist/security/persistence-analyzer.d.ts.map +1 -0
- package/dist/security/persistence-analyzer.js +187 -0
- package/dist/security/persistence-analyzer.js.map +1 -0
- package/dist/security/persistence-cli.d.ts +36 -0
- package/dist/security/persistence-cli.d.ts.map +1 -0
- package/dist/security/persistence-cli.js +160 -0
- package/dist/security/persistence-cli.js.map +1 -0
- package/dist/security/persistence-research.d.ts +92 -0
- package/dist/security/persistence-research.d.ts.map +1 -0
- package/dist/security/persistence-research.js +364 -0
- package/dist/security/persistence-research.js.map +1 -0
- package/dist/security/research/persistenceResearch.d.ts +97 -0
- package/dist/security/research/persistenceResearch.d.ts.map +1 -0
- package/dist/security/research/persistenceResearch.js +282 -0
- package/dist/security/research/persistenceResearch.js.map +1 -0
- package/dist/security/security-integration.d.ts +74 -0
- package/dist/security/security-integration.d.ts.map +1 -0
- package/dist/security/security-integration.js +137 -0
- package/dist/security/security-integration.js.map +1 -0
- package/dist/security/security-testing-framework.d.ts +112 -0
- package/dist/security/security-testing-framework.d.ts.map +1 -0
- package/dist/security/security-testing-framework.js +364 -0
- package/dist/security/security-testing-framework.js.map +1 -0
- package/dist/security/simulation/attackSimulation.d.ts +93 -0
- package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
- package/dist/security/simulation/attackSimulation.js +341 -0
- package/dist/security/simulation/attackSimulation.js.map +1 -0
- package/dist/security/strategic-operations.d.ts +100 -0
- package/dist/security/strategic-operations.d.ts.map +1 -0
- package/dist/security/strategic-operations.js +276 -0
- package/dist/security/strategic-operations.js.map +1 -0
- package/dist/security/tool-security-wrapper.d.ts +58 -0
- package/dist/security/tool-security-wrapper.d.ts.map +1 -0
- package/dist/security/tool-security-wrapper.js +156 -0
- package/dist/security/tool-security-wrapper.js.map +1 -0
- package/dist/shell/claudeCodeStreamHandler.d.ts +145 -0
- package/dist/shell/claudeCodeStreamHandler.d.ts.map +1 -0
- package/dist/shell/claudeCodeStreamHandler.js +322 -0
- package/dist/shell/claudeCodeStreamHandler.js.map +1 -0
- package/dist/shell/inputQueueManager.d.ts +144 -0
- package/dist/shell/inputQueueManager.d.ts.map +1 -0
- package/dist/shell/inputQueueManager.js +290 -0
- package/dist/shell/inputQueueManager.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +7 -11
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +153 -190
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/metricsTracker.d.ts +60 -0
- package/dist/shell/metricsTracker.d.ts.map +1 -0
- package/dist/shell/metricsTracker.js +119 -0
- package/dist/shell/metricsTracker.js.map +1 -0
- package/dist/shell/shellApp.d.ts +0 -2
- package/dist/shell/shellApp.d.ts.map +1 -1
- package/dist/shell/shellApp.js +0 -16
- package/dist/shell/shellApp.js.map +1 -1
- package/dist/shell/streamingOutputManager.d.ts +115 -0
- package/dist/shell/streamingOutputManager.d.ts.map +1 -0
- package/dist/shell/streamingOutputManager.js +225 -0
- package/dist/shell/streamingOutputManager.js.map +1 -0
- package/dist/shell/systemPrompt.d.ts.map +1 -1
- package/dist/shell/systemPrompt.js +4 -1
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/shell/terminalInput.d.ts +147 -68
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +689 -451
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +20 -20
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +29 -14
- package/dist/shell/terminalInputAdapter.js.map +1 -1
- package/dist/tools/securityTools.d.ts +22 -0
- package/dist/tools/securityTools.d.ts.map +1 -0
- package/dist/tools/securityTools.js +448 -0
- package/dist/tools/securityTools.js.map +1 -0
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +12 -13
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +0 -19
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +33 -131
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/persistentPrompt.d.ts +50 -0
- package/dist/ui/persistentPrompt.d.ts.map +1 -0
- package/dist/ui/persistentPrompt.js +92 -0
- package/dist/ui/persistentPrompt.js.map +1 -0
- package/dist/ui/terminalUISchema.d.ts +195 -0
- package/dist/ui/terminalUISchema.d.ts.map +1 -0
- package/dist/ui/terminalUISchema.js +113 -0
- package/dist/ui/terminalUISchema.js.map +1 -0
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +8 -6
- package/dist/ui/theme.js.map +1 -1
- package/dist/ui/toolDisplay.d.ts +158 -0
- package/dist/ui/toolDisplay.d.ts.map +1 -1
- package/dist/ui/toolDisplay.js +348 -0
- package/dist/ui/toolDisplay.js.map +1 -1
- package/dist/ui/unified/layout.d.ts +0 -1
- package/dist/ui/unified/layout.d.ts.map +1 -1
- package/dist/ui/unified/layout.js +25 -15
- package/dist/ui/unified/layout.js.map +1 -1
- package/package.json +1 -1
- package/scripts/deploy-security-capabilities.js +178 -0
- package/dist/core/hooks.d.ts +0 -113
- package/dist/core/hooks.d.ts.map +0 -1
- package/dist/core/hooks.js +0 -267
- package/dist/core/hooks.js.map +0 -1
- package/dist/core/metricsTracker.d.ts +0 -122
- package/dist/core/metricsTracker.d.ts.map +0 -1
- package/dist/core/metricsTracker.js.map +0 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Error Recovery System
|
|
3
|
+
*
|
|
4
|
+
* Provides intelligent error recovery with:
|
|
5
|
+
* - Multi-strategy error handling
|
|
6
|
+
* - Context-aware recovery actions
|
|
7
|
+
* - Progressive escalation
|
|
8
|
+
* - Learning from past recoveries
|
|
9
|
+
* - Integration with AI optimization engine
|
|
10
|
+
*
|
|
11
|
+
* @license MIT
|
|
12
|
+
* @author Bo Shang
|
|
13
|
+
*/
|
|
14
|
+
import { AIOptimizationEngine } from './aiOptimizationEngine.js';
|
|
15
|
+
export var RecoveryLevel;
|
|
16
|
+
(function (RecoveryLevel) {
|
|
17
|
+
RecoveryLevel["IMMEDIATE"] = "immediate";
|
|
18
|
+
RecoveryLevel["ASSISTED"] = "assisted";
|
|
19
|
+
RecoveryLevel["ESCALATED"] = "escalated";
|
|
20
|
+
RecoveryLevel["MANUAL"] = "manual"; // Full manual intervention required
|
|
21
|
+
})(RecoveryLevel || (RecoveryLevel = {}));
|
|
22
|
+
export class EnhancedErrorRecovery {
|
|
23
|
+
optimizationEngine;
|
|
24
|
+
recoveryHistory = [];
|
|
25
|
+
learnedPatterns = new Map();
|
|
26
|
+
constructor(options = {}) {
|
|
27
|
+
this.optimizationEngine = new AIOptimizationEngine(options);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Analyze error and generate comprehensive recovery plan
|
|
31
|
+
*/
|
|
32
|
+
analyzeError(context) {
|
|
33
|
+
const errorAnalysis = this.analyzeErrorType(context.error);
|
|
34
|
+
const recoveryLevel = this.determineRecoveryLevel(context, errorAnalysis);
|
|
35
|
+
const primaryAction = this.generatePrimaryRecoveryAction(context, errorAnalysis);
|
|
36
|
+
const alternativeActions = this.generateAlternativeActions(context, errorAnalysis);
|
|
37
|
+
const estimatedTime = this.estimateRecoveryTime(context, errorAnalysis);
|
|
38
|
+
const successProbability = this.calculateSuccessProbability(context, errorAnalysis);
|
|
39
|
+
const rollbackPlan = this.generateRollbackPlan(context);
|
|
40
|
+
const validationSteps = this.generateValidationSteps(context);
|
|
41
|
+
return {
|
|
42
|
+
level: recoveryLevel,
|
|
43
|
+
primaryAction,
|
|
44
|
+
alternativeActions,
|
|
45
|
+
estimatedTime,
|
|
46
|
+
successProbability,
|
|
47
|
+
rollbackPlan,
|
|
48
|
+
validationSteps
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Execute recovery plan with monitoring and learning
|
|
53
|
+
*/
|
|
54
|
+
async executeRecovery(plan, context) {
|
|
55
|
+
const startTime = Date.now();
|
|
56
|
+
let success = false;
|
|
57
|
+
let output = '';
|
|
58
|
+
let learnedPattern;
|
|
59
|
+
try {
|
|
60
|
+
// Execute primary action
|
|
61
|
+
if (plan.primaryAction.autoExecutable && !plan.primaryAction.requiresConfirmation) {
|
|
62
|
+
const result = await this.executeRecoveryAction(plan.primaryAction);
|
|
63
|
+
output = result.output;
|
|
64
|
+
success = result.success;
|
|
65
|
+
if (success) {
|
|
66
|
+
learnedPattern = this.extractPatternFromSuccess(context, plan.primaryAction);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Record recovery attempt
|
|
70
|
+
const recoveryAttempt = {
|
|
71
|
+
timestamp: new Date(),
|
|
72
|
+
error: context.error,
|
|
73
|
+
recoveryAction: plan.primaryAction.action,
|
|
74
|
+
success,
|
|
75
|
+
durationMs: Date.now() - startTime,
|
|
76
|
+
learnedPattern
|
|
77
|
+
};
|
|
78
|
+
this.recoveryHistory.push(recoveryAttempt);
|
|
79
|
+
if (learnedPattern) {
|
|
80
|
+
this.learnedPatterns.set(context.errorType, learnedPattern);
|
|
81
|
+
}
|
|
82
|
+
return { success, output, learnedPattern };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const recoveryAttempt = {
|
|
86
|
+
timestamp: new Date(),
|
|
87
|
+
error: context.error,
|
|
88
|
+
recoveryAction: plan.primaryAction.action,
|
|
89
|
+
success: false,
|
|
90
|
+
durationMs: Date.now() - startTime,
|
|
91
|
+
learnedPattern: `Failed recovery: ${error}`
|
|
92
|
+
};
|
|
93
|
+
this.recoveryHistory.push(recoveryAttempt);
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
output: `Recovery failed: ${error}`,
|
|
97
|
+
learnedPattern: `Avoid: ${plan.primaryAction.action} for ${context.errorType}`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get recovery statistics and insights
|
|
103
|
+
*/
|
|
104
|
+
getRecoveryInsights() {
|
|
105
|
+
const totalRecoveries = this.recoveryHistory.length;
|
|
106
|
+
const successfulRecoveries = this.recoveryHistory.filter(r => r.success).length;
|
|
107
|
+
const successRate = totalRecoveries > 0 ? successfulRecoveries / totalRecoveries : 0;
|
|
108
|
+
const averageRecoveryTime = totalRecoveries > 0
|
|
109
|
+
? this.recoveryHistory.reduce((sum, r) => sum + r.durationMs, 0) / totalRecoveries
|
|
110
|
+
: 0;
|
|
111
|
+
const errorCounts = new Map();
|
|
112
|
+
this.recoveryHistory.forEach(r => {
|
|
113
|
+
errorCounts.set(r.error, (errorCounts.get(r.error) || 0) + 1);
|
|
114
|
+
});
|
|
115
|
+
const mostCommonErrors = Array.from(errorCounts.entries())
|
|
116
|
+
.sort((a, b) => b[1] - a[1])
|
|
117
|
+
.slice(0, 5)
|
|
118
|
+
.map(([error]) => error);
|
|
119
|
+
const learnedPatterns = Array.from(this.learnedPatterns.entries())
|
|
120
|
+
.map(([errorType, pattern]) => `${errorType}: ${pattern}`);
|
|
121
|
+
return {
|
|
122
|
+
totalRecoveries,
|
|
123
|
+
successRate,
|
|
124
|
+
averageRecoveryTime,
|
|
125
|
+
mostCommonErrors,
|
|
126
|
+
learnedPatterns
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Private implementation methods
|
|
130
|
+
analyzeErrorType(error) {
|
|
131
|
+
const errorLower = error.toLowerCase();
|
|
132
|
+
// Error categorization
|
|
133
|
+
let category = 'unknown';
|
|
134
|
+
let severity = 'medium';
|
|
135
|
+
let autoFixable = false;
|
|
136
|
+
const patterns = [];
|
|
137
|
+
// TypeScript/compilation errors
|
|
138
|
+
if (errorLower.includes('ts') && errorLower.includes('error')) {
|
|
139
|
+
category = 'compilation';
|
|
140
|
+
severity = 'high';
|
|
141
|
+
autoFixable = true;
|
|
142
|
+
patterns.push('typescript_error');
|
|
143
|
+
}
|
|
144
|
+
// Test failures
|
|
145
|
+
if (errorLower.includes('fail') && errorLower.includes('test')) {
|
|
146
|
+
category = 'test';
|
|
147
|
+
severity = 'medium';
|
|
148
|
+
autoFixable = false;
|
|
149
|
+
patterns.push('test_failure');
|
|
150
|
+
}
|
|
151
|
+
// File not found
|
|
152
|
+
if (errorLower.includes('file not found') || errorLower.includes('enoent')) {
|
|
153
|
+
category = 'file';
|
|
154
|
+
severity = 'medium';
|
|
155
|
+
autoFixable = true;
|
|
156
|
+
patterns.push('file_not_found');
|
|
157
|
+
}
|
|
158
|
+
// Permission errors
|
|
159
|
+
if (errorLower.includes('permission') || errorLower.includes('eacces')) {
|
|
160
|
+
category = 'permission';
|
|
161
|
+
severity = 'high';
|
|
162
|
+
autoFixable = false;
|
|
163
|
+
patterns.push('permission_error');
|
|
164
|
+
}
|
|
165
|
+
// Network errors
|
|
166
|
+
if (errorLower.includes('network') || errorLower.includes('connection')) {
|
|
167
|
+
category = 'network';
|
|
168
|
+
severity = 'medium';
|
|
169
|
+
autoFixable = false;
|
|
170
|
+
patterns.push('network_error');
|
|
171
|
+
}
|
|
172
|
+
return { category, severity, autoFixable, patterns };
|
|
173
|
+
}
|
|
174
|
+
determineRecoveryLevel(context, errorAnalysis) {
|
|
175
|
+
// Check if we have learned patterns for this error
|
|
176
|
+
if (this.learnedPatterns.has(context.errorType) && errorAnalysis.autoFixable) {
|
|
177
|
+
return RecoveryLevel.IMMEDIATE;
|
|
178
|
+
}
|
|
179
|
+
// Check severity and auto-fixability
|
|
180
|
+
if (errorAnalysis.severity === 'low' && errorAnalysis.autoFixable) {
|
|
181
|
+
return RecoveryLevel.IMMEDIATE;
|
|
182
|
+
}
|
|
183
|
+
if (errorAnalysis.severity === 'medium' && errorAnalysis.autoFixable) {
|
|
184
|
+
return RecoveryLevel.ASSISTED;
|
|
185
|
+
}
|
|
186
|
+
if (errorAnalysis.severity === 'high' || errorAnalysis.severity === 'critical') {
|
|
187
|
+
return RecoveryLevel.ESCALATED;
|
|
188
|
+
}
|
|
189
|
+
// Check recovery history for similar errors
|
|
190
|
+
const similarRecoveries = this.recoveryHistory.filter(r => r.error.includes(context.errorType) && r.success);
|
|
191
|
+
if (similarRecoveries.length > 0) {
|
|
192
|
+
return RecoveryLevel.ASSISTED;
|
|
193
|
+
}
|
|
194
|
+
return RecoveryLevel.MANUAL;
|
|
195
|
+
}
|
|
196
|
+
generatePrimaryRecoveryAction(context, errorAnalysis) {
|
|
197
|
+
// Use learned patterns if available
|
|
198
|
+
const learnedPattern = this.learnedPatterns.get(context.errorType);
|
|
199
|
+
if (learnedPattern) {
|
|
200
|
+
return this.parseLearnedPattern(learnedPattern, context);
|
|
201
|
+
}
|
|
202
|
+
// Generate based on error category
|
|
203
|
+
switch (errorAnalysis.category) {
|
|
204
|
+
case 'compilation':
|
|
205
|
+
return {
|
|
206
|
+
action: 'Run TypeScript validation to get detailed errors',
|
|
207
|
+
tool: 'validate_typescript',
|
|
208
|
+
parameters: {},
|
|
209
|
+
description: 'Get comprehensive TypeScript error details',
|
|
210
|
+
confidence: 0.9,
|
|
211
|
+
autoExecutable: true,
|
|
212
|
+
requiresConfirmation: false
|
|
213
|
+
};
|
|
214
|
+
case 'test':
|
|
215
|
+
return {
|
|
216
|
+
action: 'Run tests with detailed output',
|
|
217
|
+
tool: 'run_tests',
|
|
218
|
+
parameters: {},
|
|
219
|
+
description: 'Get detailed test failure information',
|
|
220
|
+
confidence: 0.8,
|
|
221
|
+
autoExecutable: true,
|
|
222
|
+
requiresConfirmation: false
|
|
223
|
+
};
|
|
224
|
+
case 'file':
|
|
225
|
+
return {
|
|
226
|
+
action: 'Search for similar files',
|
|
227
|
+
tool: 'search_files',
|
|
228
|
+
parameters: { pattern: '**/*' },
|
|
229
|
+
description: 'Find available files to understand project structure',
|
|
230
|
+
confidence: 0.7,
|
|
231
|
+
autoExecutable: true,
|
|
232
|
+
requiresConfirmation: false
|
|
233
|
+
};
|
|
234
|
+
case 'permission':
|
|
235
|
+
return {
|
|
236
|
+
action: 'Check file permissions',
|
|
237
|
+
tool: 'execute_bash',
|
|
238
|
+
parameters: { command: 'ls -la' },
|
|
239
|
+
description: 'Check file permissions and ownership',
|
|
240
|
+
confidence: 0.6,
|
|
241
|
+
autoExecutable: true,
|
|
242
|
+
requiresConfirmation: true
|
|
243
|
+
};
|
|
244
|
+
default:
|
|
245
|
+
return {
|
|
246
|
+
action: 'Analyze current state',
|
|
247
|
+
tool: 'execute_bash',
|
|
248
|
+
parameters: { command: 'git status && npm run type-check' },
|
|
249
|
+
description: 'Get comprehensive system state information',
|
|
250
|
+
confidence: 0.5,
|
|
251
|
+
autoExecutable: true,
|
|
252
|
+
requiresConfirmation: false
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
generateAlternativeActions(context, errorAnalysis) {
|
|
257
|
+
const alternatives = [];
|
|
258
|
+
// Add rollback alternative for destructive operations
|
|
259
|
+
if (context.currentState.filesModified.length > 0) {
|
|
260
|
+
alternatives.push({
|
|
261
|
+
action: 'Rollback all changes',
|
|
262
|
+
tool: 'execute_bash',
|
|
263
|
+
parameters: { command: 'git reset --hard HEAD' },
|
|
264
|
+
description: 'Revert all changes to last known good state',
|
|
265
|
+
confidence: 1.0,
|
|
266
|
+
autoExecutable: true,
|
|
267
|
+
requiresConfirmation: true
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// Add validation alternative
|
|
271
|
+
alternatives.push({
|
|
272
|
+
action: 'Run comprehensive validation',
|
|
273
|
+
tool: 'validate_all_changes',
|
|
274
|
+
parameters: {},
|
|
275
|
+
description: 'Run full validation suite to identify all issues',
|
|
276
|
+
confidence: 0.8,
|
|
277
|
+
autoExecutable: true,
|
|
278
|
+
requiresConfirmation: false
|
|
279
|
+
});
|
|
280
|
+
return alternatives.slice(0, 3); // Return top 3 alternatives
|
|
281
|
+
}
|
|
282
|
+
estimateRecoveryTime(context, errorAnalysis) {
|
|
283
|
+
const baseTimes = {
|
|
284
|
+
compilation: 30,
|
|
285
|
+
test: 60,
|
|
286
|
+
file: 15,
|
|
287
|
+
permission: 45,
|
|
288
|
+
network: 120,
|
|
289
|
+
unknown: 30
|
|
290
|
+
};
|
|
291
|
+
return baseTimes[errorAnalysis.category];
|
|
292
|
+
}
|
|
293
|
+
calculateSuccessProbability(context, errorAnalysis) {
|
|
294
|
+
let probability = 0.5;
|
|
295
|
+
// Adjust based on error category
|
|
296
|
+
const categoryProbabilities = {
|
|
297
|
+
compilation: 0.8,
|
|
298
|
+
test: 0.6,
|
|
299
|
+
file: 0.9,
|
|
300
|
+
permission: 0.4,
|
|
301
|
+
network: 0.3,
|
|
302
|
+
unknown: 0.5
|
|
303
|
+
};
|
|
304
|
+
probability = categoryProbabilities[errorAnalysis.category];
|
|
305
|
+
// Adjust based on recovery history
|
|
306
|
+
const similarSuccesses = this.recoveryHistory.filter(r => r.error.includes(context.errorType) && r.success).length;
|
|
307
|
+
const similarFailures = this.recoveryHistory.filter(r => r.error.includes(context.errorType) && !r.success).length;
|
|
308
|
+
const totalSimilar = similarSuccesses + similarFailures;
|
|
309
|
+
if (totalSimilar > 0) {
|
|
310
|
+
const historicalProbability = similarSuccesses / totalSimilar;
|
|
311
|
+
probability = (probability + historicalProbability) / 2;
|
|
312
|
+
}
|
|
313
|
+
return probability;
|
|
314
|
+
}
|
|
315
|
+
generateRollbackPlan(context) {
|
|
316
|
+
const rollbackSteps = [];
|
|
317
|
+
if (context.currentState.filesModified.length > 0) {
|
|
318
|
+
rollbackSteps.push('git reset --hard HEAD');
|
|
319
|
+
rollbackSteps.push('Remove any untracked files if necessary');
|
|
320
|
+
}
|
|
321
|
+
return rollbackSteps;
|
|
322
|
+
}
|
|
323
|
+
generateValidationSteps(context) {
|
|
324
|
+
return [
|
|
325
|
+
'Verify error is resolved',
|
|
326
|
+
'Run TypeScript type checking',
|
|
327
|
+
'Run build process',
|
|
328
|
+
'Execute relevant tests',
|
|
329
|
+
'Confirm system is in stable state'
|
|
330
|
+
];
|
|
331
|
+
}
|
|
332
|
+
async executeRecoveryAction(action) {
|
|
333
|
+
// This would integrate with the actual tool execution system
|
|
334
|
+
// For now, return a mock implementation
|
|
335
|
+
return {
|
|
336
|
+
success: true,
|
|
337
|
+
output: `Executed: ${action.action}`
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
extractPatternFromSuccess(context, action) {
|
|
341
|
+
return `${context.errorType} -> ${action.action} (${action.tool})`;
|
|
342
|
+
}
|
|
343
|
+
parseLearnedPattern(pattern, context) { n; }
|
|
344
|
+
} // Simple pattern parsing - in practice this would be more sophisticated\n const parts = pattern.split(' -> ');\n if (parts.length === 2) {\n const [errorType, recovery] = parts;\n const [action, tool] = recovery.split(' (');\n \n return {\n action: action.trim(),\n tool: tool ? tool.replace(')', '') : undefined,\n parameters: {},\n description: `Learned recovery pattern for ${errorType}`,\n confidence: 0.9,\n autoExecutable: true,\n requiresConfirmation: false\n };\n }\n\n // Fallback to generic recovery\n return {\n action: 'Use learned recovery pattern',\n description: `Apply previously successful recovery for ${context.errorType}`,\n confidence: 0.8,\n autoExecutable: true,\n requiresConfirmation: false\n };\n }\n}
|
|
345
|
+
//# sourceMappingURL=enhancedErrorRecovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhancedErrorRecovery.js","sourceRoot":"","sources":["../../src/core/enhancedErrorRecovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,oBAAoB,EAA2C,MAAM,2BAA2B,CAAC;AAE1G,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;IACrB,wCAAuB,CAAA;IACvB,kCAAiB,CAAA,CAAW,oCAAoC;AAClE,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AA6CD,MAAM,OAAO,qBAAqB;IACf,kBAAkB,CAAuB;IACzC,eAAe,GAAsB,EAAE,CAAC;IACxC,eAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;IAElE,YAAY,UAAmC,EAAE;QAC/C,IAAI,CAAC,kBAAkB,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,OAAwB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3D,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAG,IAAI,CAAC,6BAA6B,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACjF,MAAM,kBAAkB,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACnF,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,aAAa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CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,oBAAoB,CAAC,OAAwB;QACnD,MAAM,aAAa,GAAa,EAAE,CAAC;QAEnC,IAAI,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,aAAa,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YAC5C,aAAa,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IAEO,uBAAuB,CAAC,OAAwB;QACtD,OAAO;YACL,0BAA0B;YAC1B,8BAA8B;YAC9B,mBAAmB;YACnB,wBAAwB;YACxB,mCAAmC;SACpC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,MAAsB;QACxD,6DAA6D;QAC7D,wCAAwC;QACxC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,aAAa,MAAM,CAAC,MAAM,EAAE;SACrC,CAAC;IACJ,CAAC;IAEO,yBAAyB,CAC/B,OAAwB,EACxB,MAAsB;QAEtB,OAAO,GAAG,OAAO,CAAC,SAAS,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC;IACrE,CAAC;IAEO,mBAAmB,CAAC,OAAe,EAAE,OAAwB,IAAoB,CAAC,CAAA,CAAk1B,CAAC,AAAn1B;CAAA,CAAI,80BAA80B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks System - Event-driven automation for tool execution
|
|
3
|
+
*
|
|
4
|
+
* Implements a Claude Code-style hooks system that runs shell commands
|
|
5
|
+
* in response to tool execution events:
|
|
6
|
+
*
|
|
7
|
+
* - beforeToolExecution: Runs before any tool starts
|
|
8
|
+
* - afterToolExecution: Runs after any tool completes
|
|
9
|
+
* - beforeFileEdit: Runs before a file is modified
|
|
10
|
+
* - afterFileEdit: Runs after a file is modified
|
|
11
|
+
* - beforeBashCommand: Runs before a bash command executes
|
|
12
|
+
* - afterBashCommand: Runs after a bash command completes
|
|
13
|
+
*
|
|
14
|
+
* Hooks are configured in EROSOLAR.md or settings.json
|
|
15
|
+
*/
|
|
16
|
+
export type HookTrigger = 'beforeToolExecution' | 'afterToolExecution' | 'beforeFileEdit' | 'afterFileEdit' | 'beforeBashCommand' | 'afterBashCommand';
|
|
17
|
+
export interface HookDefinition {
|
|
18
|
+
/** When to trigger the hook */
|
|
19
|
+
when: HookTrigger;
|
|
20
|
+
/** Condition to match (tool name, file pattern, or command pattern) */
|
|
21
|
+
if?: string;
|
|
22
|
+
/** Shell commands to execute */
|
|
23
|
+
then: string[];
|
|
24
|
+
/** Optional timeout in milliseconds */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface HookContext {
|
|
28
|
+
/** The tool or command being executed */
|
|
29
|
+
tool?: string;
|
|
30
|
+
/** File path if applicable */
|
|
31
|
+
file?: string;
|
|
32
|
+
/** Bash command if applicable */
|
|
33
|
+
command?: string;
|
|
34
|
+
/** Working directory */
|
|
35
|
+
workingDir: string;
|
|
36
|
+
/** Additional context data */
|
|
37
|
+
data?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export interface HookResult {
|
|
40
|
+
/** Whether the hook was triggered */
|
|
41
|
+
triggered: boolean;
|
|
42
|
+
/** Output from executed commands */
|
|
43
|
+
output: string[];
|
|
44
|
+
/** Any errors that occurred */
|
|
45
|
+
errors: string[];
|
|
46
|
+
/** Whether execution should be aborted */
|
|
47
|
+
abort: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load hooks from EROSOLAR.md or settings.json
|
|
51
|
+
*/
|
|
52
|
+
export declare function loadHooks(workingDir: string): HookDefinition[];
|
|
53
|
+
/**
|
|
54
|
+
* Run hooks for a specific trigger
|
|
55
|
+
*/
|
|
56
|
+
export declare function runHooks(trigger: HookTrigger, context: HookContext, hooks?: HookDefinition[]): Promise<HookResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Create a hooks runner bound to a specific working directory
|
|
59
|
+
*/
|
|
60
|
+
export declare function createHooksRunner(workingDir: string): {
|
|
61
|
+
runBefore: (trigger: HookTrigger, context: Omit<HookContext, 'workingDir'>) => Promise<HookResult>;
|
|
62
|
+
runAfter: (trigger: HookTrigger, context: Omit<HookContext, 'workingDir'>) => Promise<HookResult>;
|
|
63
|
+
reload: () => void;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=hooksSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooksSystem.d.ts","sourceRoot":"","sources":["../../src/core/hooksSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,MAAM,MAAM,WAAW,GACnB,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,GACf,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,IAAI,EAAE,WAAW,CAAC;IAClB,uEAAuE;IACvE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,oCAAoC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