erosolar-cli 1.5.2 → 1.5.4
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/config/security-deployment.json +54 -0
- package/dist/bin/adapters/node/index.js +33 -0
- package/dist/bin/adapters/types.js +1 -0
- package/dist/bin/alpha-zero/agentWrapper.js +165 -0
- package/dist/bin/alpha-zero/codeEvaluator.js +272 -0
- package/dist/bin/alpha-zero/competitiveRunner.js +219 -0
- package/dist/bin/alpha-zero/index.js +98 -0
- package/dist/bin/alpha-zero/introspection.js +298 -0
- package/dist/bin/alpha-zero/metricsTracker.js +207 -0
- package/dist/bin/alpha-zero/security/core.js +269 -0
- package/dist/bin/alpha-zero/security/google.js +308 -0
- package/dist/bin/alpha-zero/security/googleLoader.js +40 -0
- package/dist/bin/alpha-zero/security/index.js +31 -0
- package/dist/bin/alpha-zero/security/simulation.js +274 -0
- package/dist/bin/alpha-zero/selfModification.js +231 -0
- package/dist/bin/alpha-zero/types.js +30 -0
- package/dist/bin/bin/erosolar-optimized.js +205 -0
- package/dist/bin/capabilities/agentSpawningCapability.js +116 -0
- package/dist/bin/capabilities/bashCapability.js +22 -0
- package/dist/bin/capabilities/cloudCapability.js +36 -0
- package/dist/bin/capabilities/codeAnalysisCapability.js +22 -0
- package/dist/bin/capabilities/codeQualityCapability.js +23 -0
- package/dist/bin/capabilities/dependencySecurityCapability.js +22 -0
- package/dist/bin/capabilities/devCapability.js +22 -0
- package/dist/bin/capabilities/editCapability.js +28 -0
- package/dist/bin/capabilities/emailCapability.js +20 -0
- package/dist/bin/capabilities/enhancedGitCapability.js +221 -0
- package/dist/bin/capabilities/filesystemCapability.js +22 -0
- package/dist/bin/capabilities/globCapability.js +28 -0
- package/dist/bin/capabilities/interactionCapability.js +20 -0
- package/dist/bin/capabilities/learnCapability.js +22 -0
- package/dist/bin/capabilities/mcpCapability.js +20 -0
- package/dist/bin/capabilities/notebookCapability.js +28 -0
- package/dist/bin/capabilities/planningCapability.js +27 -0
- package/dist/bin/capabilities/refactoringCapability.js +23 -0
- package/dist/bin/capabilities/repoChecksCapability.js +22 -0
- package/dist/bin/capabilities/searchCapability.js +22 -0
- package/dist/bin/capabilities/skillCapability.js +76 -0
- package/dist/bin/capabilities/taskManagementCapability.js +20 -0
- package/dist/bin/capabilities/testingCapability.js +23 -0
- package/dist/bin/capabilities/toolManifest.js +159 -0
- package/dist/bin/capabilities/toolRegistry.js +114 -0
- package/dist/bin/capabilities/webCapability.js +20 -0
- package/dist/bin/config.js +139 -0
- package/dist/bin/contracts/v1/agent.js +7 -0
- package/dist/bin/contracts/v1/agentProfileManifest.js +8 -0
- package/dist/bin/contracts/v1/agentRules.js +9 -0
- package/dist/bin/contracts/v1/toolAccess.js +8 -0
- package/dist/bin/core/agent.js +362 -0
- package/dist/bin/core/agentProfileManifest.js +187 -0
- package/dist/bin/core/agentProfiles.js +34 -0
- package/dist/bin/core/agentRulebook.js +135 -0
- package/dist/bin/core/agentSchemaLoader.js +233 -0
- package/dist/bin/core/contextManager.js +412 -0
- package/dist/bin/core/contextWindow.js +122 -0
- package/dist/bin/core/customCommands.js +80 -0
- package/dist/bin/core/errors/apiKeyErrors.js +114 -0
- package/dist/bin/core/errors/errorTypes.js +340 -0
- package/dist/bin/core/errors/safetyValidator.js +304 -0
- package/dist/bin/core/errors.js +32 -0
- package/dist/bin/core/modelDiscovery.js +755 -0
- package/dist/bin/core/preferences.js +224 -0
- package/dist/bin/core/schemaValidator.js +92 -0
- package/dist/bin/core/secretStore.js +199 -0
- package/dist/bin/core/sessionStore.js +187 -0
- package/dist/bin/core/toolRuntime.js +290 -0
- package/dist/bin/core/types.js +1 -0
- package/dist/bin/erosolar-optimized.d.ts +12 -0
- package/dist/bin/erosolar-optimized.d.ts.map +1 -0
- package/dist/bin/erosolar-optimized.js +239 -0
- package/dist/bin/erosolar-optimized.js.map +1 -0
- package/dist/bin/erosolar.js +14 -0
- package/dist/bin/erosolar.js.map +1 -1
- package/dist/bin/headless/headlessApp.js +172 -0
- package/dist/bin/mcp/config.js +202 -0
- package/dist/bin/mcp/stdioClient.js +172 -0
- package/dist/bin/mcp/toolBridge.js +104 -0
- package/dist/bin/mcp/types.js +1 -0
- package/dist/bin/plugins/index.js +113 -0
- package/dist/bin/plugins/providers/anthropic/index.js +25 -0
- package/dist/bin/plugins/providers/deepseek/index.js +24 -0
- package/dist/bin/plugins/providers/google/index.js +26 -0
- package/dist/bin/plugins/providers/index.js +19 -0
- package/dist/bin/plugins/providers/ollama/index.js +59 -0
- package/dist/bin/plugins/providers/openai/index.js +26 -0
- package/dist/bin/plugins/providers/xai/index.js +24 -0
- package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +8 -0
- package/dist/bin/plugins/tools/bash/localBashPlugin.js +13 -0
- package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +13 -0
- package/dist/bin/plugins/tools/cloud/cloudPlugin.js +13 -0
- package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +13 -0
- package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +13 -0
- package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +11 -0
- package/dist/bin/plugins/tools/development/devPlugin.js +13 -0
- package/dist/bin/plugins/tools/edit/editPlugin.js +14 -0
- package/dist/bin/plugins/tools/email/emailPlugin.js +11 -0
- package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +8 -0
- package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +13 -0
- package/dist/bin/plugins/tools/glob/globPlugin.js +14 -0
- package/dist/bin/plugins/tools/index.js +2 -0
- package/dist/bin/plugins/tools/interaction/interactionPlugin.js +11 -0
- package/dist/bin/plugins/tools/learn/learnPlugin.js +13 -0
- package/dist/bin/plugins/tools/mcp/mcpPlugin.js +8 -0
- package/dist/bin/plugins/tools/nodeDefaults.js +56 -0
- package/dist/bin/plugins/tools/notebook/notebookPlugin.js +14 -0
- package/dist/bin/plugins/tools/planning/planningPlugin.js +14 -0
- package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +11 -0
- package/dist/bin/plugins/tools/registry.js +57 -0
- package/dist/bin/plugins/tools/search/localSearchPlugin.js +13 -0
- package/dist/bin/plugins/tools/skills/skillPlugin.js +8 -0
- package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +11 -0
- package/dist/bin/plugins/tools/testing/testingPlugin.js +11 -0
- package/dist/bin/plugins/tools/web/webPlugin.js +11 -0
- package/dist/bin/providers/anthropicProvider.js +329 -0
- package/dist/bin/providers/googleProvider.js +203 -0
- package/dist/bin/providers/openaiChatCompletionsProvider.js +208 -0
- package/dist/bin/providers/openaiResponsesProvider.js +249 -0
- package/dist/bin/providers/providerFactory.js +24 -0
- package/dist/bin/runtime/agentController.js +321 -0
- package/dist/bin/runtime/agentHost.js +153 -0
- package/dist/bin/runtime/agentSession.js +195 -0
- package/dist/bin/runtime/node.js +10 -0
- package/dist/bin/runtime/universal.js +28 -0
- package/dist/bin/shell/bracketedPasteManager.js +350 -0
- package/dist/bin/shell/fileChangeTracker.js +65 -0
- package/dist/bin/shell/interactiveShell.js +2908 -0
- package/dist/bin/shell/liveStatus.js +78 -0
- package/dist/bin/shell/shellApp.js +290 -0
- package/dist/bin/shell/systemPrompt.js +60 -0
- package/dist/bin/shell/updateManager.js +108 -0
- package/dist/bin/skills/skillRepository.js +236 -0
- package/dist/bin/skills/types.js +1 -0
- package/dist/bin/subagents/taskRunner.js +269 -0
- package/dist/bin/tools/backgroundBashTools.js +211 -0
- package/dist/bin/tools/bashTools.js +159 -0
- package/dist/bin/tools/cloudTools.js +864 -0
- package/dist/bin/tools/codeAnalysisTools.js +641 -0
- package/dist/bin/tools/codeQualityTools.js +294 -0
- package/dist/bin/tools/dependencyTools.js +282 -0
- package/dist/bin/tools/devTools.js +238 -0
- package/dist/bin/tools/diffUtils.js +137 -0
- package/dist/bin/tools/editTools.js +134 -0
- package/dist/bin/tools/emailTools.js +448 -0
- package/dist/bin/tools/fileTools.js +282 -0
- package/dist/bin/tools/globTools.js +173 -0
- package/dist/bin/tools/grepTools.js +332 -0
- package/dist/bin/tools/interactionTools.js +170 -0
- package/dist/bin/tools/learnTools.js +1818 -0
- package/dist/bin/tools/notebookEditTools.js +196 -0
- package/dist/bin/tools/planningTools.js +46 -0
- package/dist/bin/tools/refactoringTools.js +293 -0
- package/dist/bin/tools/repoChecksTools.js +160 -0
- package/dist/bin/tools/searchTools.js +206 -0
- package/dist/bin/tools/skillTools.js +177 -0
- package/dist/bin/tools/taskManagementTools.js +156 -0
- package/dist/bin/tools/testingTools.js +232 -0
- package/dist/bin/tools/webTools.js +480 -0
- package/dist/bin/ui/ShellUIAdapter.js +459 -0
- package/dist/bin/ui/UnifiedUIController.js +183 -0
- package/dist/bin/ui/animation/AnimationScheduler.js +430 -0
- package/dist/bin/ui/codeHighlighter.js +854 -0
- package/dist/bin/ui/designSystem.js +121 -0
- package/dist/bin/ui/display.js +1222 -0
- package/dist/bin/ui/interrupts/InterruptManager.js +437 -0
- package/dist/bin/ui/layout.js +139 -0
- package/dist/bin/ui/orchestration/StatusOrchestrator.js +403 -0
- package/dist/bin/ui/outputMode.js +38 -0
- package/dist/bin/ui/persistentPrompt.js +183 -0
- package/dist/bin/ui/richText.js +338 -0
- package/dist/bin/ui/shortcutsHelp.js +87 -0
- package/dist/bin/ui/telemetry/UITelemetry.js +443 -0
- package/dist/bin/ui/textHighlighter.js +210 -0
- package/dist/bin/ui/theme.js +116 -0
- package/dist/bin/ui/toolDisplay.js +423 -0
- package/dist/bin/ui/toolDisplayAdapter.js +357 -0
- package/dist/bin/workspace.js +106 -0
- package/dist/bin/workspace.validator.js +213 -0
- package/dist/capabilities/cloudCapability.d.ts +13 -0
- package/dist/capabilities/cloudCapability.d.ts.map +1 -0
- package/dist/capabilities/cloudCapability.js +38 -0
- package/dist/capabilities/cloudCapability.js.map +1 -0
- package/dist/capabilities/index.d.ts +1 -0
- package/dist/capabilities/index.d.ts.map +1 -1
- package/dist/capabilities/index.js +1 -0
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/offensiveSecurityCapability.d.ts +26 -0
- package/dist/capabilities/offensiveSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/offensiveSecurityCapability.js +58 -0
- package/dist/capabilities/offensiveSecurityCapability.js.map +1 -0
- package/dist/capabilities/realSecurityCapability.d.ts +26 -0
- package/dist/capabilities/realSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/realSecurityCapability.js +53 -0
- package/dist/capabilities/realSecurityCapability.js.map +1 -0
- package/dist/capabilities/securityCapability.d.ts +32 -0
- package/dist/capabilities/securityCapability.d.ts.map +1 -0
- package/dist/capabilities/securityCapability.js +57 -0
- package/dist/capabilities/securityCapability.js.map +1 -0
- package/dist/capabilities/ultimateSecurityCapability.d.ts +42 -0
- package/dist/capabilities/ultimateSecurityCapability.d.ts.map +1 -0
- package/dist/capabilities/ultimateSecurityCapability.js +96 -0
- package/dist/capabilities/ultimateSecurityCapability.js.map +1 -0
- package/dist/core/LazyLoader.d.ts +129 -0
- package/dist/core/LazyLoader.d.ts.map +1 -0
- package/dist/core/LazyLoader.js +240 -0
- package/dist/core/LazyLoader.js.map +1 -0
- package/dist/core/intelligenceTools.d.ts +19 -0
- package/dist/core/intelligenceTools.d.ts.map +1 -0
- package/dist/core/intelligenceTools.js +453 -0
- package/dist/core/intelligenceTools.js.map +1 -0
- package/dist/core/operationalTools.d.ts +19 -0
- package/dist/core/operationalTools.d.ts.map +1 -0
- package/dist/core/operationalTools.js +467 -0
- package/dist/core/operationalTools.js.map +1 -0
- package/dist/offensive/core/offensive-engine.d.ts +171 -0
- package/dist/offensive/core/offensive-engine.d.ts.map +1 -0
- package/dist/offensive/core/offensive-engine.js +345 -0
- package/dist/offensive/core/offensive-engine.js.map +1 -0
- package/dist/offensive/core/offensive-integration.d.ts +129 -0
- package/dist/offensive/core/offensive-integration.d.ts.map +1 -0
- package/dist/offensive/core/offensive-integration.js +364 -0
- package/dist/offensive/core/offensive-integration.js.map +1 -0
- package/dist/offensive/core/offensive-tools.d.ts +55 -0
- package/dist/offensive/core/offensive-tools.d.ts.map +1 -0
- package/dist/offensive/core/offensive-tools.js +438 -0
- package/dist/offensive/core/offensive-tools.js.map +1 -0
- package/dist/offensive/offensive-cli.d.ts +48 -0
- package/dist/offensive/offensive-cli.d.ts.map +1 -0
- package/dist/offensive/offensive-cli.js +233 -0
- package/dist/offensive/offensive-cli.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/tools/cloud/cloudPlugin.d.ts +3 -0
- package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/cloud/cloudPlugin.js +14 -0
- package/dist/plugins/tools/cloud/cloudPlugin.js.map +1 -0
- 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/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/apt-simulation-cli.d.ts +57 -0
- package/dist/security/apt-simulation-cli.d.ts.map +1 -0
- package/dist/security/apt-simulation-cli.js +278 -0
- package/dist/security/apt-simulation-cli.js.map +1 -0
- package/dist/security/apt-simulation-engine-complete.d.ts +97 -0
- package/dist/security/apt-simulation-engine-complete.d.ts.map +1 -0
- package/dist/security/apt-simulation-engine-complete.js +441 -0
- package/dist/security/apt-simulation-engine-complete.js.map +1 -0
- package/dist/security/apt-simulation-engine.d.ts +97 -0
- package/dist/security/apt-simulation-engine.d.ts.map +1 -0
- package/dist/security/apt-simulation-engine.js +441 -0
- package/dist/security/apt-simulation-engine.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/authorization.d.ts +45 -0
- package/dist/security/authorization.d.ts.map +1 -0
- package/dist/security/authorization.js +128 -0
- package/dist/security/authorization.js.map +1 -0
- package/dist/security/comprehensive-security-research.d.ts +84 -0
- package/dist/security/comprehensive-security-research.d.ts.map +1 -0
- package/dist/security/comprehensive-security-research.js +211 -0
- package/dist/security/comprehensive-security-research.js.map +1 -0
- package/dist/security/offensive/exploitationEngine.d.ts +54 -0
- package/dist/security/offensive/exploitationEngine.d.ts.map +1 -0
- package/dist/security/offensive/exploitationEngine.js +263 -0
- package/dist/security/offensive/exploitationEngine.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 +100 -0
- package/dist/security/persistence-research.d.ts.map +1 -0
- package/dist/security/persistence-research.js +372 -0
- package/dist/security/persistence-research.js.map +1 -0
- package/dist/security/real/networkExploitation.d.ts +92 -0
- package/dist/security/real/networkExploitation.d.ts.map +1 -0
- package/dist/security/real/networkExploitation.js +316 -0
- package/dist/security/real/networkExploitation.js.map +1 -0
- package/dist/security/real/persistenceImplementation.d.ts +62 -0
- package/dist/security/real/persistenceImplementation.d.ts.map +1 -0
- package/dist/security/real/persistenceImplementation.js +323 -0
- package/dist/security/real/persistenceImplementation.js.map +1 -0
- package/dist/security/real/vulnerabilityScanner.d.ts +73 -0
- package/dist/security/real/vulnerabilityScanner.d.ts.map +1 -0
- package/dist/security/real/vulnerabilityScanner.js +341 -0
- package/dist/security/real/vulnerabilityScanner.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-testing-framework.d.ts +120 -0
- package/dist/security/security-testing-framework.d.ts.map +1 -0
- package/dist/security/security-testing-framework.js +372 -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/shell/bracketedPasteManager.d.ts +76 -0
- package/dist/shell/bracketedPasteManager.d.ts.map +1 -1
- package/dist/shell/bracketedPasteManager.js +267 -9
- package/dist/shell/bracketedPasteManager.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +34 -1
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +304 -24
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/taskCompletionDetector.d.ts +101 -0
- package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
- package/dist/shell/taskCompletionDetector.js +343 -0
- package/dist/shell/taskCompletionDetector.js.map +1 -0
- package/dist/tools/cloudTools.d.ts +57 -0
- package/dist/tools/cloudTools.d.ts.map +1 -0
- package/dist/tools/cloudTools.js +865 -0
- package/dist/tools/cloudTools.js.map +1 -0
- package/dist/tools/enhancedSecurityTools.d.ts +19 -0
- package/dist/tools/enhancedSecurityTools.d.ts.map +1 -0
- package/dist/tools/enhancedSecurityTools.js +215 -0
- package/dist/tools/enhancedSecurityTools.js.map +1 -0
- package/dist/tools/offensiveSecurityTools.d.ts +16 -0
- package/dist/tools/offensiveSecurityTools.d.ts.map +1 -0
- package/dist/tools/offensiveSecurityTools.js +285 -0
- package/dist/tools/offensiveSecurityTools.js.map +1 -0
- package/dist/tools/realSecurityTools.d.ts +18 -0
- package/dist/tools/realSecurityTools.d.ts.map +1 -0
- package/dist/tools/realSecurityTools.js +468 -0
- package/dist/tools/realSecurityTools.js.map +1 -0
- package/dist/tools/securityTools.d.ts +20 -0
- package/dist/tools/securityTools.d.ts.map +1 -0
- package/dist/tools/securityTools.js +449 -0
- package/dist/tools/securityTools.js.map +1 -0
- package/package.json +27 -12
- package/scripts/deploy-security-capabilities.js +178 -0
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Security Research Framework
|
|
3
|
+
*
|
|
4
|
+
* Base authorization system and reconnaissance capabilities.
|
|
5
|
+
* All operations require explicit authorization.
|
|
6
|
+
*
|
|
7
|
+
* Principal Investigator: Bo Shang
|
|
8
|
+
* Framework: erosolar-cli
|
|
9
|
+
*/
|
|
10
|
+
import * as dns from 'dns/promises';
|
|
11
|
+
import * as net from 'net';
|
|
12
|
+
/**
|
|
13
|
+
* Scope of authorization for security testing
|
|
14
|
+
*/
|
|
15
|
+
export var AuthorizationScope;
|
|
16
|
+
(function (AuthorizationScope) {
|
|
17
|
+
AuthorizationScope["OWNED_SYSTEMS"] = "owned_systems";
|
|
18
|
+
AuthorizationScope["BUG_BOUNTY"] = "bug_bounty";
|
|
19
|
+
AuthorizationScope["PENTEST_ENGAGEMENT"] = "pentest_engagement";
|
|
20
|
+
AuthorizationScope["CTF_COMPETITION"] = "ctf_competition";
|
|
21
|
+
AuthorizationScope["RED_TEAM"] = "red_team";
|
|
22
|
+
AuthorizationScope["EDUCATIONAL"] = "educational";
|
|
23
|
+
})(AuthorizationScope || (AuthorizationScope = {}));
|
|
24
|
+
const DEFAULT_CONFIG = {
|
|
25
|
+
dataDir: '.security_research',
|
|
26
|
+
verbose: false,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Security Research Engine
|
|
30
|
+
*
|
|
31
|
+
* All operations require explicit authorization records.
|
|
32
|
+
*/
|
|
33
|
+
export class SecurityResearchEngine {
|
|
34
|
+
constructor(config = {}) {
|
|
35
|
+
this.authorization = null;
|
|
36
|
+
this.findings = [];
|
|
37
|
+
this.reconResults = [];
|
|
38
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set authorization for testing
|
|
42
|
+
*/
|
|
43
|
+
setAuthorization(authorization) {
|
|
44
|
+
this.authorization = authorization;
|
|
45
|
+
if (this.config.verbose) {
|
|
46
|
+
console.log(`[Authorization] Set for ${authorization.targetDomain}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if authorization is valid
|
|
51
|
+
*/
|
|
52
|
+
checkAuthorization(target) {
|
|
53
|
+
if (!this.authorization) {
|
|
54
|
+
throw new Error('No authorization record set.');
|
|
55
|
+
}
|
|
56
|
+
// Check expiration
|
|
57
|
+
if (this.authorization.expirationDate) {
|
|
58
|
+
const exp = new Date(this.authorization.expirationDate);
|
|
59
|
+
if (new Date() > exp) {
|
|
60
|
+
throw new Error('Authorization has expired.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Check scope
|
|
64
|
+
const inScope = this.authorization.targetDomain.includes(target) ||
|
|
65
|
+
target.endsWith(this.authorization.targetDomain);
|
|
66
|
+
const outOfScope = this.authorization.outOfScope.some(oos => target.includes(oos));
|
|
67
|
+
if (!inScope || outOfScope) {
|
|
68
|
+
throw new Error(`Target ${target} is not within authorized scope.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Perform passive reconnaissance
|
|
73
|
+
*/
|
|
74
|
+
async passiveRecon(target) {
|
|
75
|
+
this.checkAuthorization(target);
|
|
76
|
+
if (this.config.verbose) {
|
|
77
|
+
console.log(`[Recon] Starting passive recon on ${target}`);
|
|
78
|
+
}
|
|
79
|
+
const result = {
|
|
80
|
+
target,
|
|
81
|
+
timestamp: Date.now(),
|
|
82
|
+
dnsRecords: {},
|
|
83
|
+
openPorts: [],
|
|
84
|
+
sslInfo: {},
|
|
85
|
+
httpHeaders: {},
|
|
86
|
+
technologies: [],
|
|
87
|
+
subdomains: [],
|
|
88
|
+
potentialVectors: [],
|
|
89
|
+
};
|
|
90
|
+
// DNS lookup
|
|
91
|
+
try {
|
|
92
|
+
result.dnsRecords['A'] = await dns.resolve4(target);
|
|
93
|
+
}
|
|
94
|
+
catch { /* ignore */ }
|
|
95
|
+
try {
|
|
96
|
+
result.dnsRecords['MX'] = (await dns.resolveMx(target)).map(r => r.exchange);
|
|
97
|
+
}
|
|
98
|
+
catch { /* ignore */ }
|
|
99
|
+
try {
|
|
100
|
+
result.dnsRecords['TXT'] = await dns.resolveTxt(target).then(r => r.flat());
|
|
101
|
+
}
|
|
102
|
+
catch { /* ignore */ }
|
|
103
|
+
// Common subdomain patterns
|
|
104
|
+
const prefixes = ['www', 'mail', 'api', 'dev', 'staging', 'admin'];
|
|
105
|
+
result.subdomains = prefixes.map(p => `${p}.${target}`);
|
|
106
|
+
this.reconResults.push(result);
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Perform active reconnaissance (requires stronger authorization)
|
|
111
|
+
*/
|
|
112
|
+
async activeRecon(target, ports = [80, 443, 8080, 8443]) {
|
|
113
|
+
this.checkAuthorization(target);
|
|
114
|
+
// Active recon requires stronger authorization
|
|
115
|
+
const allowed = [
|
|
116
|
+
AuthorizationScope.OWNED_SYSTEMS,
|
|
117
|
+
AuthorizationScope.PENTEST_ENGAGEMENT,
|
|
118
|
+
AuthorizationScope.RED_TEAM,
|
|
119
|
+
AuthorizationScope.CTF_COMPETITION,
|
|
120
|
+
];
|
|
121
|
+
if (!allowed.includes(this.authorization.scope)) {
|
|
122
|
+
throw new Error('Active recon requires stronger authorization.');
|
|
123
|
+
}
|
|
124
|
+
const result = await this.passiveRecon(target);
|
|
125
|
+
// Port scan
|
|
126
|
+
result.openPorts = await this.scanPorts(target, ports);
|
|
127
|
+
// Identify vectors
|
|
128
|
+
result.potentialVectors = this.identifyVectors(result);
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Scan ports
|
|
133
|
+
*/
|
|
134
|
+
async scanPorts(host, ports) {
|
|
135
|
+
const checkPort = (port) => {
|
|
136
|
+
return new Promise(resolve => {
|
|
137
|
+
const socket = new net.Socket();
|
|
138
|
+
socket.setTimeout(2000);
|
|
139
|
+
socket.on('connect', () => {
|
|
140
|
+
socket.destroy();
|
|
141
|
+
resolve(true);
|
|
142
|
+
});
|
|
143
|
+
socket.on('error', () => {
|
|
144
|
+
socket.destroy();
|
|
145
|
+
resolve(false);
|
|
146
|
+
});
|
|
147
|
+
socket.on('timeout', () => {
|
|
148
|
+
socket.destroy();
|
|
149
|
+
resolve(false);
|
|
150
|
+
});
|
|
151
|
+
socket.connect(port, host);
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const results = await Promise.all(ports.map(async (port) => {
|
|
155
|
+
const isOpen = await checkPort(port);
|
|
156
|
+
return isOpen ? port : null;
|
|
157
|
+
}));
|
|
158
|
+
return results.filter((p) => p !== null);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Identify potential attack vectors
|
|
162
|
+
*/
|
|
163
|
+
identifyVectors(recon) {
|
|
164
|
+
const vectors = [];
|
|
165
|
+
// Missing security headers (would need HTTP request to determine)
|
|
166
|
+
// Placeholder for now
|
|
167
|
+
vectors.push('Check for missing security headers');
|
|
168
|
+
// Open ports analysis
|
|
169
|
+
if (recon.openPorts.includes(21)) {
|
|
170
|
+
vectors.push('FTP port open - check for anonymous access');
|
|
171
|
+
}
|
|
172
|
+
if (recon.openPorts.includes(22)) {
|
|
173
|
+
vectors.push('SSH port open - check for weak credentials');
|
|
174
|
+
}
|
|
175
|
+
return vectors;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Analyze for vulnerabilities
|
|
179
|
+
*/
|
|
180
|
+
analyzeForVulnerabilities(recon) {
|
|
181
|
+
this.checkAuthorization(recon.target);
|
|
182
|
+
const findings = [];
|
|
183
|
+
// Example: missing HSTS (would need actual HTTP response)
|
|
184
|
+
findings.push({
|
|
185
|
+
title: 'Missing HSTS Header (Verify Required)',
|
|
186
|
+
severity: 'medium',
|
|
187
|
+
category: 'config',
|
|
188
|
+
description: 'Verify HSTS header is present.',
|
|
189
|
+
evidence: 'Requires HTTP response analysis',
|
|
190
|
+
remediation: 'Add Strict-Transport-Security header',
|
|
191
|
+
cweId: 'CWE-319',
|
|
192
|
+
});
|
|
193
|
+
this.findings.push(...findings);
|
|
194
|
+
return findings;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generate report
|
|
198
|
+
*/
|
|
199
|
+
generateReport(format = 'text') {
|
|
200
|
+
if (format === 'json') {
|
|
201
|
+
return JSON.stringify({
|
|
202
|
+
generated: new Date().toISOString(),
|
|
203
|
+
authorization: this.authorization,
|
|
204
|
+
findings: this.findings,
|
|
205
|
+
reconResults: this.reconResults,
|
|
206
|
+
}, null, 2);
|
|
207
|
+
}
|
|
208
|
+
const lines = [
|
|
209
|
+
'='.repeat(60),
|
|
210
|
+
'SECURITY RESEARCH REPORT',
|
|
211
|
+
'='.repeat(60),
|
|
212
|
+
`Generated: ${new Date().toISOString()}`,
|
|
213
|
+
];
|
|
214
|
+
if (this.authorization) {
|
|
215
|
+
lines.push(`Target: ${this.authorization.targetDomain}`);
|
|
216
|
+
lines.push(`Scope: ${this.authorization.scope}`);
|
|
217
|
+
}
|
|
218
|
+
if (this.findings.length > 0) {
|
|
219
|
+
lines.push('', `Findings: ${this.findings.length}`);
|
|
220
|
+
for (const f of this.findings) {
|
|
221
|
+
lines.push(` [${f.severity.toUpperCase()}] ${f.title}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return lines.join('\n');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Create bug bounty authorization
|
|
229
|
+
*/
|
|
230
|
+
export function createBugBountyAuthorization(targetDomain, programName, scopeLimitations = [], outOfScope = []) {
|
|
231
|
+
return {
|
|
232
|
+
scope: AuthorizationScope.BUG_BOUNTY,
|
|
233
|
+
targetDomain,
|
|
234
|
+
authorizedBy: `Bug Bounty: ${programName}`,
|
|
235
|
+
authorizationDate: new Date().toISOString(),
|
|
236
|
+
scopeLimitations,
|
|
237
|
+
outOfScope,
|
|
238
|
+
notes: 'Testing authorized under bug bounty program terms',
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Create pentest authorization
|
|
243
|
+
*/
|
|
244
|
+
export function createPentestAuthorization(targetDomain, clientName, engagementId, expirationDate) {
|
|
245
|
+
return {
|
|
246
|
+
scope: AuthorizationScope.PENTEST_ENGAGEMENT,
|
|
247
|
+
targetDomain,
|
|
248
|
+
authorizedBy: `Client: ${clientName} (${engagementId})`,
|
|
249
|
+
authorizationDate: new Date().toISOString(),
|
|
250
|
+
expirationDate,
|
|
251
|
+
scopeLimitations: [],
|
|
252
|
+
outOfScope: [],
|
|
253
|
+
notes: 'Testing authorized under penetration testing agreement',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Create CTF authorization
|
|
258
|
+
*/
|
|
259
|
+
export function createCtfAuthorization(targetDomain, ctfName) {
|
|
260
|
+
return {
|
|
261
|
+
scope: AuthorizationScope.CTF_COMPETITION,
|
|
262
|
+
targetDomain,
|
|
263
|
+
authorizedBy: `CTF: ${ctfName}`,
|
|
264
|
+
authorizationDate: new Date().toISOString(),
|
|
265
|
+
scopeLimitations: [],
|
|
266
|
+
outOfScope: [],
|
|
267
|
+
notes: 'CTF competition testing',
|
|
268
|
+
};
|
|
269
|
+
}
|