erosolar-cli 1.7.55 → 1.7.57
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/dist/shell/unifiedInputProcessor.d.ts +15 -12
- package/dist/shell/unifiedInputProcessor.d.ts.map +1 -1
- package/dist/shell/unifiedInputProcessor.js +45 -72
- package/dist/shell/unifiedInputProcessor.js.map +1 -1
- package/package.json +4 -4
- package/dist/active-stack-security.d.ts +0 -110
- package/dist/active-stack-security.js +0 -313
- package/dist/active-stack-security.js.map +0 -1
- package/dist/advanced-targeting.d.ts +0 -113
- package/dist/advanced-targeting.js +0 -252
- package/dist/advanced-targeting.js.map +0 -1
- package/dist/bin/adapters/node/index.js +0 -33
- package/dist/bin/adapters/types.js +0 -1
- package/dist/bin/alpha-zero/agentWrapper.js +0 -165
- package/dist/bin/alpha-zero/codeEvaluator.js +0 -272
- package/dist/bin/alpha-zero/competitiveRunner.js +0 -219
- package/dist/bin/alpha-zero/index.js +0 -98
- package/dist/bin/alpha-zero/introspection.js +0 -298
- package/dist/bin/alpha-zero/metricsTracker.js +0 -207
- package/dist/bin/alpha-zero/security/core.js +0 -269
- package/dist/bin/alpha-zero/security/google.js +0 -308
- package/dist/bin/alpha-zero/security/googleLoader.js +0 -40
- package/dist/bin/alpha-zero/security/index.js +0 -31
- package/dist/bin/alpha-zero/security/simulation.js +0 -274
- package/dist/bin/alpha-zero/selfModification.js +0 -231
- package/dist/bin/alpha-zero/types.js +0 -30
- package/dist/bin/bin/erosolar-optimized.js +0 -205
- package/dist/bin/capabilities/agentSpawningCapability.js +0 -116
- package/dist/bin/capabilities/bashCapability.js +0 -22
- package/dist/bin/capabilities/cloudCapability.js +0 -36
- package/dist/bin/capabilities/codeAnalysisCapability.js +0 -22
- package/dist/bin/capabilities/codeQualityCapability.js +0 -23
- package/dist/bin/capabilities/dependencySecurityCapability.js +0 -22
- package/dist/bin/capabilities/devCapability.js +0 -22
- package/dist/bin/capabilities/editCapability.js +0 -28
- package/dist/bin/capabilities/emailCapability.js +0 -20
- package/dist/bin/capabilities/enhancedGitCapability.js +0 -221
- package/dist/bin/capabilities/filesystemCapability.js +0 -22
- package/dist/bin/capabilities/globCapability.js +0 -28
- package/dist/bin/capabilities/interactionCapability.js +0 -20
- package/dist/bin/capabilities/learnCapability.js +0 -22
- package/dist/bin/capabilities/mcpCapability.js +0 -20
- package/dist/bin/capabilities/notebookCapability.js +0 -28
- package/dist/bin/capabilities/planningCapability.js +0 -27
- package/dist/bin/capabilities/refactoringCapability.js +0 -23
- package/dist/bin/capabilities/repoChecksCapability.js +0 -22
- package/dist/bin/capabilities/searchCapability.js +0 -22
- package/dist/bin/capabilities/skillCapability.js +0 -76
- package/dist/bin/capabilities/taskManagementCapability.js +0 -20
- package/dist/bin/capabilities/testingCapability.js +0 -23
- package/dist/bin/capabilities/toolManifest.js +0 -159
- package/dist/bin/capabilities/toolRegistry.js +0 -114
- package/dist/bin/capabilities/webCapability.js +0 -20
- package/dist/bin/config.js +0 -139
- package/dist/bin/contracts/v1/agent.js +0 -7
- package/dist/bin/contracts/v1/agentProfileManifest.js +0 -8
- package/dist/bin/contracts/v1/agentRules.js +0 -9
- package/dist/bin/contracts/v1/toolAccess.js +0 -8
- package/dist/bin/erosolar-optimized.d.ts +0 -12
- package/dist/bin/erosolar-optimized.d.ts.map +0 -1
- package/dist/bin/erosolar-optimized.js +0 -239
- package/dist/bin/erosolar-optimized.js.map +0 -1
- package/dist/bin/headless/headlessApp.js +0 -172
- package/dist/bin/mcp/config.js +0 -202
- package/dist/bin/mcp/stdioClient.js +0 -172
- package/dist/bin/mcp/toolBridge.js +0 -104
- package/dist/bin/mcp/types.js +0 -1
- package/dist/bin/plugins/index.js +0 -113
- package/dist/bin/plugins/providers/anthropic/index.js +0 -25
- package/dist/bin/plugins/providers/deepseek/index.js +0 -24
- package/dist/bin/plugins/providers/google/index.js +0 -26
- package/dist/bin/plugins/providers/index.js +0 -19
- package/dist/bin/plugins/providers/ollama/index.js +0 -59
- package/dist/bin/plugins/providers/openai/index.js +0 -26
- package/dist/bin/plugins/providers/xai/index.js +0 -24
- package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +0 -8
- package/dist/bin/plugins/tools/bash/localBashPlugin.js +0 -13
- package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +0 -13
- package/dist/bin/plugins/tools/cloud/cloudPlugin.js +0 -13
- package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -13
- package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +0 -13
- package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +0 -11
- package/dist/bin/plugins/tools/development/devPlugin.js +0 -13
- package/dist/bin/plugins/tools/edit/editPlugin.js +0 -14
- package/dist/bin/plugins/tools/email/emailPlugin.js +0 -11
- package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +0 -8
- package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +0 -13
- package/dist/bin/plugins/tools/glob/globPlugin.js +0 -14
- package/dist/bin/plugins/tools/index.js +0 -2
- package/dist/bin/plugins/tools/interaction/interactionPlugin.js +0 -11
- package/dist/bin/plugins/tools/learn/learnPlugin.js +0 -13
- package/dist/bin/plugins/tools/mcp/mcpPlugin.js +0 -8
- package/dist/bin/plugins/tools/nodeDefaults.js +0 -56
- package/dist/bin/plugins/tools/notebook/notebookPlugin.js +0 -14
- package/dist/bin/plugins/tools/planning/planningPlugin.js +0 -14
- package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +0 -11
- package/dist/bin/plugins/tools/registry.js +0 -57
- package/dist/bin/plugins/tools/search/localSearchPlugin.js +0 -13
- package/dist/bin/plugins/tools/skills/skillPlugin.js +0 -8
- package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +0 -11
- package/dist/bin/plugins/tools/testing/testingPlugin.js +0 -11
- package/dist/bin/plugins/tools/web/webPlugin.js +0 -11
- package/dist/bin/providers/anthropicProvider.js +0 -329
- package/dist/bin/providers/googleProvider.js +0 -203
- package/dist/bin/providers/openaiChatCompletionsProvider.js +0 -208
- package/dist/bin/providers/openaiResponsesProvider.js +0 -249
- package/dist/bin/providers/providerFactory.js +0 -24
- package/dist/bin/runtime/agentController.js +0 -321
- package/dist/bin/runtime/agentHost.js +0 -153
- package/dist/bin/runtime/agentSession.js +0 -195
- package/dist/bin/runtime/node.js +0 -10
- package/dist/bin/runtime/universal.js +0 -28
- package/dist/bin/skills/skillRepository.js +0 -236
- package/dist/bin/skills/types.js +0 -1
- package/dist/bin/subagents/taskRunner.js +0 -269
- package/dist/bin/tools/backgroundBashTools.js +0 -211
- package/dist/bin/tools/bashTools.js +0 -159
- package/dist/bin/tools/cloudTools.js +0 -864
- package/dist/bin/tools/codeAnalysisTools.js +0 -641
- package/dist/bin/tools/codeQualityTools.js +0 -294
- package/dist/bin/tools/dependencyTools.js +0 -282
- package/dist/bin/tools/devTools.js +0 -238
- package/dist/bin/tools/diffUtils.js +0 -137
- package/dist/bin/tools/editTools.js +0 -134
- package/dist/bin/tools/emailTools.js +0 -448
- package/dist/bin/tools/fileTools.js +0 -282
- package/dist/bin/tools/globTools.js +0 -173
- package/dist/bin/tools/grepTools.js +0 -332
- package/dist/bin/tools/interactionTools.js +0 -170
- package/dist/bin/tools/learnTools.js +0 -1818
- package/dist/bin/tools/notebookEditTools.js +0 -196
- package/dist/bin/tools/planningTools.js +0 -46
- package/dist/bin/tools/refactoringTools.js +0 -293
- package/dist/bin/tools/repoChecksTools.js +0 -160
- package/dist/bin/tools/searchTools.js +0 -206
- package/dist/bin/tools/skillTools.js +0 -177
- package/dist/bin/tools/taskManagementTools.js +0 -156
- package/dist/bin/tools/testingTools.js +0 -232
- package/dist/bin/tools/webTools.js +0 -480
- package/dist/bin/workspace.js +0 -106
- package/dist/bin/workspace.validator.js +0 -213
- package/dist/capabilities/offensiveSecurityCapability.d.ts +0 -26
- package/dist/capabilities/offensiveSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/offensiveSecurityCapability.js +0 -58
- package/dist/capabilities/offensiveSecurityCapability.js.map +0 -1
- package/dist/capabilities/realSecurityCapability.d.ts +0 -26
- package/dist/capabilities/realSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/realSecurityCapability.js +0 -53
- package/dist/capabilities/realSecurityCapability.js.map +0 -1
- package/dist/capabilities/securityCapability.d.ts +0 -32
- package/dist/capabilities/securityCapability.d.ts.map +0 -1
- package/dist/capabilities/securityCapability.js +0 -57
- package/dist/capabilities/securityCapability.js.map +0 -1
- package/dist/capabilities/ultimateSecurityCapability.d.ts +0 -42
- package/dist/capabilities/ultimateSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/ultimateSecurityCapability.js +0 -96
- package/dist/capabilities/ultimateSecurityCapability.js.map +0 -1
- package/dist/core/designThoughtCheck.d.ts +0 -196
- package/dist/core/designThoughtCheck.d.ts.map +0 -1
- package/dist/core/designThoughtCheck.js +0 -287
- package/dist/core/designThoughtCheck.js.map +0 -1
- package/dist/core/designThoughtCheckEngine.d.ts +0 -58
- package/dist/core/designThoughtCheckEngine.d.ts.map +0 -1
- package/dist/core/designThoughtCheckEngine.js +0 -358
- package/dist/core/designThoughtCheckEngine.js.map +0 -1
- package/dist/core/designThoughtCheckIntegration.d.ts +0 -103
- package/dist/core/designThoughtCheckIntegration.d.ts.map +0 -1
- package/dist/core/designThoughtCheckIntegration.js +0 -207
- package/dist/core/designThoughtCheckIntegration.js.map +0 -1
- package/dist/core/intelligenceTools.d.ts +0 -19
- package/dist/core/intelligenceTools.d.ts.map +0 -1
- package/dist/core/intelligenceTools.js +0 -453
- package/dist/core/intelligenceTools.js.map +0 -1
- package/dist/core/operationalTools.d.ts +0 -19
- package/dist/core/operationalTools.d.ts.map +0 -1
- package/dist/core/operationalTools.js +0 -467
- package/dist/core/operationalTools.js.map +0 -1
- package/dist/offensive/core/offensive-engine.d.ts +0 -171
- package/dist/offensive/core/offensive-engine.d.ts.map +0 -1
- package/dist/offensive/core/offensive-engine.js +0 -345
- package/dist/offensive/core/offensive-engine.js.map +0 -1
- package/dist/offensive/core/offensive-integration.d.ts +0 -129
- package/dist/offensive/core/offensive-integration.d.ts.map +0 -1
- package/dist/offensive/core/offensive-integration.js +0 -364
- package/dist/offensive/core/offensive-integration.js.map +0 -1
- package/dist/offensive/core/offensive-tools.d.ts +0 -55
- package/dist/offensive/core/offensive-tools.d.ts.map +0 -1
- package/dist/offensive/core/offensive-tools.js +0 -438
- package/dist/offensive/core/offensive-tools.js.map +0 -1
- package/dist/offensive/offensive-cli.d.ts +0 -48
- package/dist/offensive/offensive-cli.d.ts.map +0 -1
- package/dist/offensive/offensive-cli.js +0 -233
- package/dist/offensive/offensive-cli.js.map +0 -1
- package/dist/security/apt-simulation-cli.d.ts +0 -57
- package/dist/security/apt-simulation-cli.d.ts.map +0 -1
- package/dist/security/apt-simulation-cli.js +0 -278
- package/dist/security/apt-simulation-cli.js.map +0 -1
- package/dist/security/apt-simulation-engine-complete.d.ts +0 -97
- package/dist/security/apt-simulation-engine-complete.d.ts.map +0 -1
- package/dist/security/apt-simulation-engine-complete.js +0 -441
- package/dist/security/apt-simulation-engine-complete.js.map +0 -1
- package/dist/security/apt-simulation-engine.d.ts +0 -97
- package/dist/security/apt-simulation-engine.d.ts.map +0 -1
- package/dist/security/apt-simulation-engine.js +0 -441
- package/dist/security/apt-simulation-engine.js.map +0 -1
- package/dist/security/authorization.d.ts +0 -45
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -128
- package/dist/security/authorization.js.map +0 -1
- package/dist/security/comprehensive-security-research.d.ts +0 -84
- package/dist/security/comprehensive-security-research.d.ts.map +0 -1
- package/dist/security/comprehensive-security-research.js +0 -211
- package/dist/security/comprehensive-security-research.js.map +0 -1
- package/dist/security/offensive/exploitationEngine.d.ts +0 -54
- package/dist/security/offensive/exploitationEngine.d.ts.map +0 -1
- package/dist/security/offensive/exploitationEngine.js +0 -263
- package/dist/security/offensive/exploitationEngine.js.map +0 -1
- package/dist/security/real/networkExploitation.d.ts +0 -92
- package/dist/security/real/networkExploitation.d.ts.map +0 -1
- package/dist/security/real/networkExploitation.js +0 -316
- package/dist/security/real/networkExploitation.js.map +0 -1
- package/dist/security/real/persistenceImplementation.d.ts +0 -62
- package/dist/security/real/persistenceImplementation.d.ts.map +0 -1
- package/dist/security/real/persistenceImplementation.js +0 -323
- package/dist/security/real/persistenceImplementation.js.map +0 -1
- package/dist/security/real/vulnerabilityScanner.d.ts +0 -73
- package/dist/security/real/vulnerabilityScanner.d.ts.map +0 -1
- package/dist/security/real/vulnerabilityScanner.js +0 -341
- package/dist/security/real/vulnerabilityScanner.js.map +0 -1
- package/dist/shell/capturePastePatch.d.ts +0 -9
- package/dist/shell/capturePastePatch.d.ts.map +0 -1
- package/dist/shell/capturePastePatch.js +0 -98
- package/dist/shell/capturePastePatch.js.map +0 -1
- package/dist/shell/enhancedInteractiveShell.d.ts +0 -90
- package/dist/shell/enhancedInteractiveShell.d.ts.map +0 -1
- package/dist/shell/enhancedInteractiveShell.js +0 -248
- package/dist/shell/enhancedInteractiveShell.js.map +0 -1
- package/dist/shell/inputProcessor.d.ts +0 -56
- package/dist/shell/inputProcessor.d.ts.map +0 -1
- package/dist/shell/inputProcessor.js +0 -172
- package/dist/shell/inputProcessor.js.map +0 -1
- package/dist/shell/interactiveShell-patch.d.ts +0 -27
- package/dist/shell/interactiveShell-patch.d.ts.map +0 -1
- package/dist/shell/interactiveShell-patch.js +0 -38
- package/dist/shell/interactiveShell-patch.js.map +0 -1
- package/dist/shell/interactiveShell-robust.d.ts +0 -26
- package/dist/shell/interactiveShell-robust.d.ts.map +0 -1
- package/dist/shell/interactiveShell-robust.js +0 -34
- package/dist/shell/interactiveShell-robust.js.map +0 -1
- package/dist/shell/multiLinePasteManager.d.ts +0 -106
- package/dist/shell/multiLinePasteManager.d.ts.map +0 -1
- package/dist/shell/multiLinePasteManager.js +0 -308
- package/dist/shell/multiLinePasteManager.js.map +0 -1
- package/dist/shell/processInputBlockPatch.d.ts +0 -8
- package/dist/shell/processInputBlockPatch.d.ts.map +0 -1
- package/dist/shell/processInputBlockPatch.js +0 -133
- package/dist/shell/processInputBlockPatch.js.map +0 -1
- package/dist/tools/enhancedSecurityTools.d.ts +0 -19
- package/dist/tools/enhancedSecurityTools.d.ts.map +0 -1
- package/dist/tools/enhancedSecurityTools.js +0 -215
- package/dist/tools/enhancedSecurityTools.js.map +0 -1
- package/dist/tools/offensiveSecurityTools.d.ts +0 -16
- package/dist/tools/offensiveSecurityTools.d.ts.map +0 -1
- package/dist/tools/offensiveSecurityTools.js +0 -285
- package/dist/tools/offensiveSecurityTools.js.map +0 -1
- package/dist/tools/realSecurityTools.d.ts +0 -18
- package/dist/tools/realSecurityTools.d.ts.map +0 -1
- package/dist/tools/realSecurityTools.js +0 -468
- package/dist/tools/realSecurityTools.js.map +0 -1
- package/dist/tools/securityTools.d.ts +0 -20
- package/dist/tools/securityTools.d.ts.map +0 -1
- package/dist/tools/securityTools.js +0 -449
- package/dist/tools/securityTools.js.map +0 -1
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Introspection Engine for Alpha Zero 2
|
|
3
|
-
*
|
|
4
|
-
* Provides runtime analysis and self-awareness capabilities for agents.
|
|
5
|
-
* Tracks execution patterns and suggests improvements.
|
|
6
|
-
*
|
|
7
|
-
* Principal Investigator: Bo Shang
|
|
8
|
-
* Framework: erosolar-cli
|
|
9
|
-
*/
|
|
10
|
-
const DEFAULT_CONFIG = {
|
|
11
|
-
maxTraces: 1000,
|
|
12
|
-
enableProfiling: true,
|
|
13
|
-
suggestionThreshold: 0.3,
|
|
14
|
-
verbose: false,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Introspection Engine
|
|
18
|
-
*
|
|
19
|
-
* Provides self-awareness and analysis capabilities for agents.
|
|
20
|
-
*/
|
|
21
|
-
export class IntrospectionEngine {
|
|
22
|
-
constructor(config = {}) {
|
|
23
|
-
this.profiles = new Map();
|
|
24
|
-
this.codeAnalyses = new Map();
|
|
25
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Record an execution trace
|
|
29
|
-
*/
|
|
30
|
-
recordExecution(toolId, trace) {
|
|
31
|
-
const profile = this.getOrCreateProfile(toolId);
|
|
32
|
-
const fullTrace = {
|
|
33
|
-
...trace,
|
|
34
|
-
timestamp: Date.now(),
|
|
35
|
-
};
|
|
36
|
-
profile.traces.push(fullTrace);
|
|
37
|
-
profile.executionCount++;
|
|
38
|
-
profile.lastExecution = Date.now();
|
|
39
|
-
// Update averages
|
|
40
|
-
const totalTime = profile.traces.reduce((sum, t) => sum + (t.durationMs || 0), 0);
|
|
41
|
-
profile.averageExecutionTimeMs = totalTime / profile.executionCount;
|
|
42
|
-
// Update success rate
|
|
43
|
-
const successes = profile.traces.filter(t => t.success).length;
|
|
44
|
-
profile.successRate = successes / profile.executionCount;
|
|
45
|
-
// Trim old traces
|
|
46
|
-
if (profile.traces.length > this.config.maxTraces) {
|
|
47
|
-
profile.traces = profile.traces.slice(-this.config.maxTraces);
|
|
48
|
-
}
|
|
49
|
-
if (this.config.verbose) {
|
|
50
|
-
console.log(`[Introspection] Recorded execution for ${toolId}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Get performance profile for a tool
|
|
55
|
-
*/
|
|
56
|
-
getProfile(toolId) {
|
|
57
|
-
return this.profiles.get(toolId) || null;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get all performance profiles
|
|
61
|
-
*/
|
|
62
|
-
getAllProfiles() {
|
|
63
|
-
return Array.from(this.profiles.values());
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Analyze code and return analysis result
|
|
67
|
-
*/
|
|
68
|
-
analyzeCode(filePath, code) {
|
|
69
|
-
const lines = code.split('\n');
|
|
70
|
-
const analysis = {
|
|
71
|
-
filePath,
|
|
72
|
-
lineCount: lines.length,
|
|
73
|
-
functionCount: this.countFunctions(code),
|
|
74
|
-
cyclomaticComplexity: this.calculateComplexity(code),
|
|
75
|
-
hasDocstrings: this.hasDocstrings(code),
|
|
76
|
-
hasTypeAnnotations: this.hasTypeAnnotations(code),
|
|
77
|
-
imports: this.extractImports(code),
|
|
78
|
-
exports: this.extractExports(code),
|
|
79
|
-
issues: this.findIssues(code),
|
|
80
|
-
};
|
|
81
|
-
this.codeAnalyses.set(filePath, analysis);
|
|
82
|
-
return analysis;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Generate improvement suggestions based on execution history
|
|
86
|
-
*/
|
|
87
|
-
generateSuggestions(toolId) {
|
|
88
|
-
const profile = this.profiles.get(toolId);
|
|
89
|
-
if (!profile)
|
|
90
|
-
return [];
|
|
91
|
-
const suggestions = [];
|
|
92
|
-
// Check success rate
|
|
93
|
-
if (profile.successRate < this.config.suggestionThreshold) {
|
|
94
|
-
suggestions.push({
|
|
95
|
-
category: 'error-handling',
|
|
96
|
-
severity: 'high',
|
|
97
|
-
message: `Tool ${toolId} has low success rate (${(profile.successRate * 100).toFixed(1)}%)`,
|
|
98
|
-
suggestedAction: 'Add error handling and input validation',
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
// Check execution time
|
|
102
|
-
if (profile.averageExecutionTimeMs > 5000) {
|
|
103
|
-
suggestions.push({
|
|
104
|
-
category: 'performance',
|
|
105
|
-
severity: 'medium',
|
|
106
|
-
message: `Tool ${toolId} has high average execution time (${profile.averageExecutionTimeMs.toFixed(0)}ms)`,
|
|
107
|
-
suggestedAction: 'Consider caching, async operations, or algorithmic improvements',
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
// Check error patterns
|
|
111
|
-
const recentErrors = profile.traces
|
|
112
|
-
.filter(t => !t.success && t.timestamp > Date.now() - 3600000)
|
|
113
|
-
.map(t => t.error);
|
|
114
|
-
if (recentErrors.length > 5) {
|
|
115
|
-
const errorTypes = Array.from(new Set(recentErrors));
|
|
116
|
-
suggestions.push({
|
|
117
|
-
category: 'quality',
|
|
118
|
-
severity: 'high',
|
|
119
|
-
message: `Tool ${toolId} has ${recentErrors.length} recent errors`,
|
|
120
|
-
suggestedAction: `Address error types: ${errorTypes.slice(0, 3).join(', ')}`,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return suggestions;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get aggregated metrics across all tools
|
|
127
|
-
*/
|
|
128
|
-
getAggregatedMetrics() {
|
|
129
|
-
const profiles = this.getAllProfiles();
|
|
130
|
-
if (profiles.length === 0) {
|
|
131
|
-
return {
|
|
132
|
-
totalExecutions: 0,
|
|
133
|
-
averageSuccessRate: 0,
|
|
134
|
-
averageExecutionTime: 0,
|
|
135
|
-
toolCount: 0,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
const totalExecutions = profiles.reduce((sum, p) => sum + p.executionCount, 0);
|
|
139
|
-
const avgSuccessRate = profiles.reduce((sum, p) => sum + p.successRate, 0) / profiles.length;
|
|
140
|
-
const avgTime = profiles.reduce((sum, p) => sum + p.averageExecutionTimeMs, 0) / profiles.length;
|
|
141
|
-
return {
|
|
142
|
-
totalExecutions,
|
|
143
|
-
averageSuccessRate: avgSuccessRate,
|
|
144
|
-
averageExecutionTime: avgTime,
|
|
145
|
-
toolCount: profiles.length,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Identify bottlenecks in execution
|
|
150
|
-
*/
|
|
151
|
-
identifyBottlenecks() {
|
|
152
|
-
const bottlenecks = [];
|
|
153
|
-
for (const profile of Array.from(this.profiles.values())) {
|
|
154
|
-
// Slow tools
|
|
155
|
-
if (profile.averageExecutionTimeMs > 10000) {
|
|
156
|
-
bottlenecks.push({
|
|
157
|
-
toolId: profile.toolId,
|
|
158
|
-
issue: 'Very slow execution',
|
|
159
|
-
severity: 0.8,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else if (profile.averageExecutionTimeMs > 5000) {
|
|
163
|
-
bottlenecks.push({
|
|
164
|
-
toolId: profile.toolId,
|
|
165
|
-
issue: 'Slow execution',
|
|
166
|
-
severity: 0.5,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
// Unreliable tools
|
|
170
|
-
if (profile.successRate < 0.5) {
|
|
171
|
-
bottlenecks.push({
|
|
172
|
-
toolId: profile.toolId,
|
|
173
|
-
issue: 'High failure rate',
|
|
174
|
-
severity: 0.9,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
else if (profile.successRate < 0.8) {
|
|
178
|
-
bottlenecks.push({
|
|
179
|
-
toolId: profile.toolId,
|
|
180
|
-
issue: 'Moderate failure rate',
|
|
181
|
-
severity: 0.6,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Sort by severity
|
|
186
|
-
return bottlenecks.sort((a, b) => b.severity - a.severity);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Clear all recorded data
|
|
190
|
-
*/
|
|
191
|
-
clear() {
|
|
192
|
-
this.profiles.clear();
|
|
193
|
-
this.codeAnalyses.clear();
|
|
194
|
-
}
|
|
195
|
-
// Private helper methods
|
|
196
|
-
getOrCreateProfile(toolId) {
|
|
197
|
-
let profile = this.profiles.get(toolId);
|
|
198
|
-
if (!profile) {
|
|
199
|
-
profile = {
|
|
200
|
-
toolId,
|
|
201
|
-
executionCount: 0,
|
|
202
|
-
averageExecutionTimeMs: 0,
|
|
203
|
-
successRate: 1,
|
|
204
|
-
errorCount: 0,
|
|
205
|
-
traces: [],
|
|
206
|
-
};
|
|
207
|
-
this.profiles.set(toolId, profile);
|
|
208
|
-
}
|
|
209
|
-
return profile;
|
|
210
|
-
}
|
|
211
|
-
countFunctions(code) {
|
|
212
|
-
const functionPatterns = [
|
|
213
|
-
/function\s+\w+/g,
|
|
214
|
-
/\w+\s*=\s*(?:async\s+)?function/g,
|
|
215
|
-
/(?:async\s+)?(?:\w+|\(\w*\))\s*=>/g,
|
|
216
|
-
/\w+\s*\([^)]*\)\s*\{/g,
|
|
217
|
-
];
|
|
218
|
-
let count = 0;
|
|
219
|
-
for (const pattern of functionPatterns) {
|
|
220
|
-
const matches = code.match(pattern);
|
|
221
|
-
if (matches)
|
|
222
|
-
count += matches.length;
|
|
223
|
-
}
|
|
224
|
-
return count;
|
|
225
|
-
}
|
|
226
|
-
calculateComplexity(code) {
|
|
227
|
-
// Simple cyclomatic complexity approximation
|
|
228
|
-
const controlFlowKeywords = [
|
|
229
|
-
'if', 'else', 'for', 'while', 'switch', 'case',
|
|
230
|
-
'try', 'catch', '&&', '\\|\\|', '\\?',
|
|
231
|
-
];
|
|
232
|
-
let complexity = 1;
|
|
233
|
-
for (const keyword of controlFlowKeywords) {
|
|
234
|
-
const regex = new RegExp(`\\b${keyword}\\b`, 'g');
|
|
235
|
-
const matches = code.match(regex);
|
|
236
|
-
if (matches)
|
|
237
|
-
complexity += matches.length;
|
|
238
|
-
}
|
|
239
|
-
return complexity;
|
|
240
|
-
}
|
|
241
|
-
hasDocstrings(code) {
|
|
242
|
-
return code.includes('/**') || code.includes('///') || code.includes('/*');
|
|
243
|
-
}
|
|
244
|
-
hasTypeAnnotations(code) {
|
|
245
|
-
return (code.includes(': string') ||
|
|
246
|
-
code.includes(': number') ||
|
|
247
|
-
code.includes(': boolean') ||
|
|
248
|
-
code.includes(': void') ||
|
|
249
|
-
code.includes('<') && code.includes('>'));
|
|
250
|
-
}
|
|
251
|
-
extractImports(code) {
|
|
252
|
-
const importRegex = /import\s+.*?from\s+['"]([^'"]+)['"]/g;
|
|
253
|
-
const imports = [];
|
|
254
|
-
let match;
|
|
255
|
-
while ((match = importRegex.exec(code)) !== null) {
|
|
256
|
-
if (match[1])
|
|
257
|
-
imports.push(match[1]);
|
|
258
|
-
}
|
|
259
|
-
return imports;
|
|
260
|
-
}
|
|
261
|
-
extractExports(code) {
|
|
262
|
-
const exportRegex = /export\s+(?:const|function|class|type|interface)\s+(\w+)/g;
|
|
263
|
-
const exports = [];
|
|
264
|
-
let match;
|
|
265
|
-
while ((match = exportRegex.exec(code)) !== null) {
|
|
266
|
-
if (match[1])
|
|
267
|
-
exports.push(match[1]);
|
|
268
|
-
}
|
|
269
|
-
return exports;
|
|
270
|
-
}
|
|
271
|
-
findIssues(code) {
|
|
272
|
-
const issues = [];
|
|
273
|
-
// Check for console.log in production code
|
|
274
|
-
if (code.includes('console.log')) {
|
|
275
|
-
issues.push('Contains console.log statements');
|
|
276
|
-
}
|
|
277
|
-
// Check for TODO/FIXME comments
|
|
278
|
-
if (code.includes('TODO') || code.includes('FIXME')) {
|
|
279
|
-
issues.push('Contains TODO/FIXME comments');
|
|
280
|
-
}
|
|
281
|
-
// Check for any type
|
|
282
|
-
if (code.includes(': any')) {
|
|
283
|
-
issues.push('Uses any type');
|
|
284
|
-
}
|
|
285
|
-
// Check for very long lines
|
|
286
|
-
const longLines = code.split('\n').filter(line => line.length > 120);
|
|
287
|
-
if (longLines.length > 0) {
|
|
288
|
-
issues.push(`Has ${longLines.length} lines over 120 characters`);
|
|
289
|
-
}
|
|
290
|
-
return issues;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Create a default introspection engine
|
|
295
|
-
*/
|
|
296
|
-
export function createIntrospectionEngine(config) {
|
|
297
|
-
return new IntrospectionEngine(config);
|
|
298
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alpha Zero 2 - Metrics Tracker
|
|
3
|
-
*
|
|
4
|
-
* Performance metrics tracking for agent sessions.
|
|
5
|
-
*
|
|
6
|
-
* Principal Investigator: Bo Shang
|
|
7
|
-
* Framework: erosolar-cli
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Creates default performance metrics.
|
|
11
|
-
*/
|
|
12
|
-
export function createDefaultMetrics(sessionId) {
|
|
13
|
-
return {
|
|
14
|
-
sessionId,
|
|
15
|
-
totalMessages: 0,
|
|
16
|
-
totalToolCalls: 0,
|
|
17
|
-
totalTokensUsed: 0,
|
|
18
|
-
totalTimeMs: 0,
|
|
19
|
-
successfulToolCalls: 0,
|
|
20
|
-
failedToolCalls: 0,
|
|
21
|
-
codeBlocksGenerated: 0,
|
|
22
|
-
avgResponseTimeMs: 0,
|
|
23
|
-
avgCodeQuality: 0,
|
|
24
|
-
avgAlgorithmEfficiency: 0,
|
|
25
|
-
avgErrorHandling: 0,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Tracks performance metrics for an agent session.
|
|
30
|
-
*/
|
|
31
|
-
export class MetricsTracker {
|
|
32
|
-
constructor(sessionId) {
|
|
33
|
-
this.responseTimes = [];
|
|
34
|
-
this.codeQualityScores = [];
|
|
35
|
-
this.efficiencyScores = [];
|
|
36
|
-
this.errorHandlingScores = [];
|
|
37
|
-
this.traces = [];
|
|
38
|
-
this.metrics = createDefaultMetrics(sessionId);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Record a message exchange.
|
|
42
|
-
*/
|
|
43
|
-
recordMessage(elapsedMs, usage) {
|
|
44
|
-
this.metrics.totalMessages += 1;
|
|
45
|
-
this.metrics.totalTimeMs += elapsedMs;
|
|
46
|
-
this.responseTimes.push(elapsedMs);
|
|
47
|
-
if (usage) {
|
|
48
|
-
const tokens = usage.totalTokens ?? (usage.inputTokens ?? 0) + (usage.outputTokens ?? 0);
|
|
49
|
-
this.metrics.totalTokensUsed += tokens;
|
|
50
|
-
}
|
|
51
|
-
this.updateAverages();
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Record a tool call.
|
|
55
|
-
*/
|
|
56
|
-
recordToolCall(success) {
|
|
57
|
-
this.metrics.totalToolCalls += 1;
|
|
58
|
-
if (success) {
|
|
59
|
-
this.metrics.successfulToolCalls += 1;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.metrics.failedToolCalls += 1;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Record code generation.
|
|
67
|
-
*/
|
|
68
|
-
recordCodeGeneration(codeBlockCount) {
|
|
69
|
-
this.metrics.codeBlocksGenerated += codeBlockCount;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Record code quality evaluation.
|
|
73
|
-
*/
|
|
74
|
-
recordCodeQuality(quality) {
|
|
75
|
-
this.codeQualityScores.push(quality.codeQualityScore);
|
|
76
|
-
this.efficiencyScores.push(quality.algorithmEfficiency);
|
|
77
|
-
this.errorHandlingScores.push(quality.errorHandlingScore);
|
|
78
|
-
this.updateAverages();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Add an execution trace.
|
|
82
|
-
*/
|
|
83
|
-
addTrace(trace) {
|
|
84
|
-
this.traces.push(trace);
|
|
85
|
-
// Keep only the last 100 traces
|
|
86
|
-
if (this.traces.length > 100) {
|
|
87
|
-
this.traces.shift();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Update running averages.
|
|
92
|
-
*/
|
|
93
|
-
updateAverages() {
|
|
94
|
-
if (this.responseTimes.length > 0) {
|
|
95
|
-
this.metrics.avgResponseTimeMs =
|
|
96
|
-
this.responseTimes.reduce((a, b) => a + b, 0) / this.responseTimes.length;
|
|
97
|
-
}
|
|
98
|
-
if (this.codeQualityScores.length > 0) {
|
|
99
|
-
this.metrics.avgCodeQuality =
|
|
100
|
-
this.codeQualityScores.reduce((a, b) => a + b, 0) / this.codeQualityScores.length;
|
|
101
|
-
}
|
|
102
|
-
if (this.efficiencyScores.length > 0) {
|
|
103
|
-
this.metrics.avgAlgorithmEfficiency =
|
|
104
|
-
this.efficiencyScores.reduce((a, b) => a + b, 0) / this.efficiencyScores.length;
|
|
105
|
-
}
|
|
106
|
-
if (this.errorHandlingScores.length > 0) {
|
|
107
|
-
this.metrics.avgErrorHandling =
|
|
108
|
-
this.errorHandlingScores.reduce((a, b) => a + b, 0) / this.errorHandlingScores.length;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get current metrics.
|
|
113
|
-
*/
|
|
114
|
-
getMetrics() {
|
|
115
|
-
return { ...this.metrics };
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Get execution traces.
|
|
119
|
-
*/
|
|
120
|
-
getTraces() {
|
|
121
|
-
return [...this.traces];
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Get human-readable performance summary.
|
|
125
|
-
*/
|
|
126
|
-
getPerformanceSummary() {
|
|
127
|
-
const m = this.metrics;
|
|
128
|
-
const lines = [
|
|
129
|
-
`Agent Performance Summary: ${m.sessionId}`,
|
|
130
|
-
'='.repeat(50),
|
|
131
|
-
`Messages: ${m.totalMessages}`,
|
|
132
|
-
`Total Time: ${(m.totalTimeMs / 1000).toFixed(2)}s`,
|
|
133
|
-
`Avg Response: ${m.avgResponseTimeMs.toFixed(0)}ms`,
|
|
134
|
-
`Code Blocks: ${m.codeBlocksGenerated}`,
|
|
135
|
-
`Tokens Used: ${m.totalTokensUsed.toLocaleString()}`,
|
|
136
|
-
'',
|
|
137
|
-
'Tool Usage:',
|
|
138
|
-
` Total Calls: ${m.totalToolCalls}`,
|
|
139
|
-
` Success Rate: ${m.totalToolCalls > 0 ? ((m.successfulToolCalls / m.totalToolCalls) * 100).toFixed(1) : 0}%`,
|
|
140
|
-
'',
|
|
141
|
-
'Code Quality Metrics:',
|
|
142
|
-
` Quality Score: ${(m.avgCodeQuality * 100).toFixed(1)}/100`,
|
|
143
|
-
` Algorithm Efficiency: ${(m.avgAlgorithmEfficiency * 100).toFixed(1)}/100`,
|
|
144
|
-
` Error Handling: ${(m.avgErrorHandling * 100).toFixed(1)}/100`,
|
|
145
|
-
];
|
|
146
|
-
return lines.join('\n');
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Get improvement suggestions based on metrics.
|
|
150
|
-
*/
|
|
151
|
-
getImprovementSuggestions() {
|
|
152
|
-
const suggestions = [];
|
|
153
|
-
const m = this.metrics;
|
|
154
|
-
if (m.avgResponseTimeMs > 5000) {
|
|
155
|
-
suggestions.push({
|
|
156
|
-
category: 'performance',
|
|
157
|
-
severity: 'high',
|
|
158
|
-
message: 'Response time is high - consider optimizing prompts or using a faster model',
|
|
159
|
-
suggestedAction: 'Review prompt complexity and consider caching common operations',
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (m.avgCodeQuality < 0.5 && m.codeBlocksGenerated > 0) {
|
|
163
|
-
suggestions.push({
|
|
164
|
-
category: 'quality',
|
|
165
|
-
severity: 'medium',
|
|
166
|
-
message: 'Code quality is below average - enhance system prompt with coding best practices',
|
|
167
|
-
suggestedAction: 'Add explicit code style guidelines to the system prompt',
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (m.avgAlgorithmEfficiency < 0.5 && m.codeBlocksGenerated > 0) {
|
|
171
|
-
suggestions.push({
|
|
172
|
-
category: 'efficiency',
|
|
173
|
-
severity: 'medium',
|
|
174
|
-
message: 'Algorithm efficiency is low - add guidance for efficient data structures',
|
|
175
|
-
suggestedAction: 'Include examples of optimal algorithm patterns in prompts',
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
if (m.avgErrorHandling < 0.3 && m.codeBlocksGenerated > 0) {
|
|
179
|
-
suggestions.push({
|
|
180
|
-
category: 'error-handling',
|
|
181
|
-
severity: 'high',
|
|
182
|
-
message: 'Error handling is weak - instruct agent to include try/catch blocks',
|
|
183
|
-
suggestedAction: 'Require explicit error handling in generated code',
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
if (m.totalToolCalls > 0 && m.failedToolCalls / m.totalToolCalls > 0.2) {
|
|
187
|
-
suggestions.push({
|
|
188
|
-
category: 'performance',
|
|
189
|
-
severity: 'medium',
|
|
190
|
-
message: `Tool failure rate is ${((m.failedToolCalls / m.totalToolCalls) * 100).toFixed(1)}%`,
|
|
191
|
-
suggestedAction: 'Review failed tool calls and improve error recovery',
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
return suggestions;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Reset all metrics.
|
|
198
|
-
*/
|
|
199
|
-
reset() {
|
|
200
|
-
this.metrics = createDefaultMetrics(this.metrics.sessionId);
|
|
201
|
-
this.responseTimes = [];
|
|
202
|
-
this.codeQualityScores = [];
|
|
203
|
-
this.efficiencyScores = [];
|
|
204
|
-
this.errorHandlingScores = [];
|
|
205
|
-
this.traces = [];
|
|
206
|
-
}
|
|
207
|
-
}
|