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.
Files changed (346) hide show
  1. package/config/security-deployment.json +54 -0
  2. package/dist/bin/adapters/node/index.js +33 -0
  3. package/dist/bin/adapters/types.js +1 -0
  4. package/dist/bin/alpha-zero/agentWrapper.js +165 -0
  5. package/dist/bin/alpha-zero/codeEvaluator.js +272 -0
  6. package/dist/bin/alpha-zero/competitiveRunner.js +219 -0
  7. package/dist/bin/alpha-zero/index.js +98 -0
  8. package/dist/bin/alpha-zero/introspection.js +298 -0
  9. package/dist/bin/alpha-zero/metricsTracker.js +207 -0
  10. package/dist/bin/alpha-zero/security/core.js +269 -0
  11. package/dist/bin/alpha-zero/security/google.js +308 -0
  12. package/dist/bin/alpha-zero/security/googleLoader.js +40 -0
  13. package/dist/bin/alpha-zero/security/index.js +31 -0
  14. package/dist/bin/alpha-zero/security/simulation.js +274 -0
  15. package/dist/bin/alpha-zero/selfModification.js +231 -0
  16. package/dist/bin/alpha-zero/types.js +30 -0
  17. package/dist/bin/bin/erosolar-optimized.js +205 -0
  18. package/dist/bin/capabilities/agentSpawningCapability.js +116 -0
  19. package/dist/bin/capabilities/bashCapability.js +22 -0
  20. package/dist/bin/capabilities/cloudCapability.js +36 -0
  21. package/dist/bin/capabilities/codeAnalysisCapability.js +22 -0
  22. package/dist/bin/capabilities/codeQualityCapability.js +23 -0
  23. package/dist/bin/capabilities/dependencySecurityCapability.js +22 -0
  24. package/dist/bin/capabilities/devCapability.js +22 -0
  25. package/dist/bin/capabilities/editCapability.js +28 -0
  26. package/dist/bin/capabilities/emailCapability.js +20 -0
  27. package/dist/bin/capabilities/enhancedGitCapability.js +221 -0
  28. package/dist/bin/capabilities/filesystemCapability.js +22 -0
  29. package/dist/bin/capabilities/globCapability.js +28 -0
  30. package/dist/bin/capabilities/interactionCapability.js +20 -0
  31. package/dist/bin/capabilities/learnCapability.js +22 -0
  32. package/dist/bin/capabilities/mcpCapability.js +20 -0
  33. package/dist/bin/capabilities/notebookCapability.js +28 -0
  34. package/dist/bin/capabilities/planningCapability.js +27 -0
  35. package/dist/bin/capabilities/refactoringCapability.js +23 -0
  36. package/dist/bin/capabilities/repoChecksCapability.js +22 -0
  37. package/dist/bin/capabilities/searchCapability.js +22 -0
  38. package/dist/bin/capabilities/skillCapability.js +76 -0
  39. package/dist/bin/capabilities/taskManagementCapability.js +20 -0
  40. package/dist/bin/capabilities/testingCapability.js +23 -0
  41. package/dist/bin/capabilities/toolManifest.js +159 -0
  42. package/dist/bin/capabilities/toolRegistry.js +114 -0
  43. package/dist/bin/capabilities/webCapability.js +20 -0
  44. package/dist/bin/config.js +139 -0
  45. package/dist/bin/contracts/v1/agent.js +7 -0
  46. package/dist/bin/contracts/v1/agentProfileManifest.js +8 -0
  47. package/dist/bin/contracts/v1/agentRules.js +9 -0
  48. package/dist/bin/contracts/v1/toolAccess.js +8 -0
  49. package/dist/bin/core/agent.js +362 -0
  50. package/dist/bin/core/agentProfileManifest.js +187 -0
  51. package/dist/bin/core/agentProfiles.js +34 -0
  52. package/dist/bin/core/agentRulebook.js +135 -0
  53. package/dist/bin/core/agentSchemaLoader.js +233 -0
  54. package/dist/bin/core/contextManager.js +412 -0
  55. package/dist/bin/core/contextWindow.js +122 -0
  56. package/dist/bin/core/customCommands.js +80 -0
  57. package/dist/bin/core/errors/apiKeyErrors.js +114 -0
  58. package/dist/bin/core/errors/errorTypes.js +340 -0
  59. package/dist/bin/core/errors/safetyValidator.js +304 -0
  60. package/dist/bin/core/errors.js +32 -0
  61. package/dist/bin/core/modelDiscovery.js +755 -0
  62. package/dist/bin/core/preferences.js +224 -0
  63. package/dist/bin/core/schemaValidator.js +92 -0
  64. package/dist/bin/core/secretStore.js +199 -0
  65. package/dist/bin/core/sessionStore.js +187 -0
  66. package/dist/bin/core/toolRuntime.js +290 -0
  67. package/dist/bin/core/types.js +1 -0
  68. package/dist/bin/erosolar-optimized.d.ts +12 -0
  69. package/dist/bin/erosolar-optimized.d.ts.map +1 -0
  70. package/dist/bin/erosolar-optimized.js +239 -0
  71. package/dist/bin/erosolar-optimized.js.map +1 -0
  72. package/dist/bin/erosolar.js +14 -0
  73. package/dist/bin/erosolar.js.map +1 -1
  74. package/dist/bin/headless/headlessApp.js +172 -0
  75. package/dist/bin/mcp/config.js +202 -0
  76. package/dist/bin/mcp/stdioClient.js +172 -0
  77. package/dist/bin/mcp/toolBridge.js +104 -0
  78. package/dist/bin/mcp/types.js +1 -0
  79. package/dist/bin/plugins/index.js +113 -0
  80. package/dist/bin/plugins/providers/anthropic/index.js +25 -0
  81. package/dist/bin/plugins/providers/deepseek/index.js +24 -0
  82. package/dist/bin/plugins/providers/google/index.js +26 -0
  83. package/dist/bin/plugins/providers/index.js +19 -0
  84. package/dist/bin/plugins/providers/ollama/index.js +59 -0
  85. package/dist/bin/plugins/providers/openai/index.js +26 -0
  86. package/dist/bin/plugins/providers/xai/index.js +24 -0
  87. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +8 -0
  88. package/dist/bin/plugins/tools/bash/localBashPlugin.js +13 -0
  89. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +13 -0
  90. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +13 -0
  91. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +13 -0
  92. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +13 -0
  93. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +11 -0
  94. package/dist/bin/plugins/tools/development/devPlugin.js +13 -0
  95. package/dist/bin/plugins/tools/edit/editPlugin.js +14 -0
  96. package/dist/bin/plugins/tools/email/emailPlugin.js +11 -0
  97. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +8 -0
  98. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +13 -0
  99. package/dist/bin/plugins/tools/glob/globPlugin.js +14 -0
  100. package/dist/bin/plugins/tools/index.js +2 -0
  101. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +11 -0
  102. package/dist/bin/plugins/tools/learn/learnPlugin.js +13 -0
  103. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +8 -0
  104. package/dist/bin/plugins/tools/nodeDefaults.js +56 -0
  105. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +14 -0
  106. package/dist/bin/plugins/tools/planning/planningPlugin.js +14 -0
  107. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +11 -0
  108. package/dist/bin/plugins/tools/registry.js +57 -0
  109. package/dist/bin/plugins/tools/search/localSearchPlugin.js +13 -0
  110. package/dist/bin/plugins/tools/skills/skillPlugin.js +8 -0
  111. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +11 -0
  112. package/dist/bin/plugins/tools/testing/testingPlugin.js +11 -0
  113. package/dist/bin/plugins/tools/web/webPlugin.js +11 -0
  114. package/dist/bin/providers/anthropicProvider.js +329 -0
  115. package/dist/bin/providers/googleProvider.js +203 -0
  116. package/dist/bin/providers/openaiChatCompletionsProvider.js +208 -0
  117. package/dist/bin/providers/openaiResponsesProvider.js +249 -0
  118. package/dist/bin/providers/providerFactory.js +24 -0
  119. package/dist/bin/runtime/agentController.js +321 -0
  120. package/dist/bin/runtime/agentHost.js +153 -0
  121. package/dist/bin/runtime/agentSession.js +195 -0
  122. package/dist/bin/runtime/node.js +10 -0
  123. package/dist/bin/runtime/universal.js +28 -0
  124. package/dist/bin/shell/bracketedPasteManager.js +350 -0
  125. package/dist/bin/shell/fileChangeTracker.js +65 -0
  126. package/dist/bin/shell/interactiveShell.js +2908 -0
  127. package/dist/bin/shell/liveStatus.js +78 -0
  128. package/dist/bin/shell/shellApp.js +290 -0
  129. package/dist/bin/shell/systemPrompt.js +60 -0
  130. package/dist/bin/shell/updateManager.js +108 -0
  131. package/dist/bin/skills/skillRepository.js +236 -0
  132. package/dist/bin/skills/types.js +1 -0
  133. package/dist/bin/subagents/taskRunner.js +269 -0
  134. package/dist/bin/tools/backgroundBashTools.js +211 -0
  135. package/dist/bin/tools/bashTools.js +159 -0
  136. package/dist/bin/tools/cloudTools.js +864 -0
  137. package/dist/bin/tools/codeAnalysisTools.js +641 -0
  138. package/dist/bin/tools/codeQualityTools.js +294 -0
  139. package/dist/bin/tools/dependencyTools.js +282 -0
  140. package/dist/bin/tools/devTools.js +238 -0
  141. package/dist/bin/tools/diffUtils.js +137 -0
  142. package/dist/bin/tools/editTools.js +134 -0
  143. package/dist/bin/tools/emailTools.js +448 -0
  144. package/dist/bin/tools/fileTools.js +282 -0
  145. package/dist/bin/tools/globTools.js +173 -0
  146. package/dist/bin/tools/grepTools.js +332 -0
  147. package/dist/bin/tools/interactionTools.js +170 -0
  148. package/dist/bin/tools/learnTools.js +1818 -0
  149. package/dist/bin/tools/notebookEditTools.js +196 -0
  150. package/dist/bin/tools/planningTools.js +46 -0
  151. package/dist/bin/tools/refactoringTools.js +293 -0
  152. package/dist/bin/tools/repoChecksTools.js +160 -0
  153. package/dist/bin/tools/searchTools.js +206 -0
  154. package/dist/bin/tools/skillTools.js +177 -0
  155. package/dist/bin/tools/taskManagementTools.js +156 -0
  156. package/dist/bin/tools/testingTools.js +232 -0
  157. package/dist/bin/tools/webTools.js +480 -0
  158. package/dist/bin/ui/ShellUIAdapter.js +459 -0
  159. package/dist/bin/ui/UnifiedUIController.js +183 -0
  160. package/dist/bin/ui/animation/AnimationScheduler.js +430 -0
  161. package/dist/bin/ui/codeHighlighter.js +854 -0
  162. package/dist/bin/ui/designSystem.js +121 -0
  163. package/dist/bin/ui/display.js +1222 -0
  164. package/dist/bin/ui/interrupts/InterruptManager.js +437 -0
  165. package/dist/bin/ui/layout.js +139 -0
  166. package/dist/bin/ui/orchestration/StatusOrchestrator.js +403 -0
  167. package/dist/bin/ui/outputMode.js +38 -0
  168. package/dist/bin/ui/persistentPrompt.js +183 -0
  169. package/dist/bin/ui/richText.js +338 -0
  170. package/dist/bin/ui/shortcutsHelp.js +87 -0
  171. package/dist/bin/ui/telemetry/UITelemetry.js +443 -0
  172. package/dist/bin/ui/textHighlighter.js +210 -0
  173. package/dist/bin/ui/theme.js +116 -0
  174. package/dist/bin/ui/toolDisplay.js +423 -0
  175. package/dist/bin/ui/toolDisplayAdapter.js +357 -0
  176. package/dist/bin/workspace.js +106 -0
  177. package/dist/bin/workspace.validator.js +213 -0
  178. package/dist/capabilities/cloudCapability.d.ts +13 -0
  179. package/dist/capabilities/cloudCapability.d.ts.map +1 -0
  180. package/dist/capabilities/cloudCapability.js +38 -0
  181. package/dist/capabilities/cloudCapability.js.map +1 -0
  182. package/dist/capabilities/index.d.ts +1 -0
  183. package/dist/capabilities/index.d.ts.map +1 -1
  184. package/dist/capabilities/index.js +1 -0
  185. package/dist/capabilities/index.js.map +1 -1
  186. package/dist/capabilities/offensiveSecurityCapability.d.ts +26 -0
  187. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +1 -0
  188. package/dist/capabilities/offensiveSecurityCapability.js +58 -0
  189. package/dist/capabilities/offensiveSecurityCapability.js.map +1 -0
  190. package/dist/capabilities/realSecurityCapability.d.ts +26 -0
  191. package/dist/capabilities/realSecurityCapability.d.ts.map +1 -0
  192. package/dist/capabilities/realSecurityCapability.js +53 -0
  193. package/dist/capabilities/realSecurityCapability.js.map +1 -0
  194. package/dist/capabilities/securityCapability.d.ts +32 -0
  195. package/dist/capabilities/securityCapability.d.ts.map +1 -0
  196. package/dist/capabilities/securityCapability.js +57 -0
  197. package/dist/capabilities/securityCapability.js.map +1 -0
  198. package/dist/capabilities/ultimateSecurityCapability.d.ts +42 -0
  199. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +1 -0
  200. package/dist/capabilities/ultimateSecurityCapability.js +96 -0
  201. package/dist/capabilities/ultimateSecurityCapability.js.map +1 -0
  202. package/dist/core/LazyLoader.d.ts +129 -0
  203. package/dist/core/LazyLoader.d.ts.map +1 -0
  204. package/dist/core/LazyLoader.js +240 -0
  205. package/dist/core/LazyLoader.js.map +1 -0
  206. package/dist/core/intelligenceTools.d.ts +19 -0
  207. package/dist/core/intelligenceTools.d.ts.map +1 -0
  208. package/dist/core/intelligenceTools.js +453 -0
  209. package/dist/core/intelligenceTools.js.map +1 -0
  210. package/dist/core/operationalTools.d.ts +19 -0
  211. package/dist/core/operationalTools.d.ts.map +1 -0
  212. package/dist/core/operationalTools.js +467 -0
  213. package/dist/core/operationalTools.js.map +1 -0
  214. package/dist/offensive/core/offensive-engine.d.ts +171 -0
  215. package/dist/offensive/core/offensive-engine.d.ts.map +1 -0
  216. package/dist/offensive/core/offensive-engine.js +345 -0
  217. package/dist/offensive/core/offensive-engine.js.map +1 -0
  218. package/dist/offensive/core/offensive-integration.d.ts +129 -0
  219. package/dist/offensive/core/offensive-integration.d.ts.map +1 -0
  220. package/dist/offensive/core/offensive-integration.js +364 -0
  221. package/dist/offensive/core/offensive-integration.js.map +1 -0
  222. package/dist/offensive/core/offensive-tools.d.ts +55 -0
  223. package/dist/offensive/core/offensive-tools.d.ts.map +1 -0
  224. package/dist/offensive/core/offensive-tools.js +438 -0
  225. package/dist/offensive/core/offensive-tools.js.map +1 -0
  226. package/dist/offensive/offensive-cli.d.ts +48 -0
  227. package/dist/offensive/offensive-cli.d.ts.map +1 -0
  228. package/dist/offensive/offensive-cli.js +233 -0
  229. package/dist/offensive/offensive-cli.js.map +1 -0
  230. package/dist/plugins/index.d.ts +1 -1
  231. package/dist/plugins/index.d.ts.map +1 -1
  232. package/dist/plugins/index.js +2 -0
  233. package/dist/plugins/index.js.map +1 -1
  234. package/dist/plugins/tools/cloud/cloudPlugin.d.ts +3 -0
  235. package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +1 -0
  236. package/dist/plugins/tools/cloud/cloudPlugin.js +14 -0
  237. package/dist/plugins/tools/cloud/cloudPlugin.js.map +1 -0
  238. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  239. package/dist/plugins/tools/nodeDefaults.js +2 -0
  240. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  241. package/dist/security/advanced-persistence-research.d.ts +92 -0
  242. package/dist/security/advanced-persistence-research.d.ts.map +1 -0
  243. package/dist/security/advanced-persistence-research.js +195 -0
  244. package/dist/security/advanced-persistence-research.js.map +1 -0
  245. package/dist/security/apt-simulation-cli.d.ts +57 -0
  246. package/dist/security/apt-simulation-cli.d.ts.map +1 -0
  247. package/dist/security/apt-simulation-cli.js +278 -0
  248. package/dist/security/apt-simulation-cli.js.map +1 -0
  249. package/dist/security/apt-simulation-engine-complete.d.ts +97 -0
  250. package/dist/security/apt-simulation-engine-complete.d.ts.map +1 -0
  251. package/dist/security/apt-simulation-engine-complete.js +441 -0
  252. package/dist/security/apt-simulation-engine-complete.js.map +1 -0
  253. package/dist/security/apt-simulation-engine.d.ts +97 -0
  254. package/dist/security/apt-simulation-engine.d.ts.map +1 -0
  255. package/dist/security/apt-simulation-engine.js +441 -0
  256. package/dist/security/apt-simulation-engine.js.map +1 -0
  257. package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
  258. package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
  259. package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
  260. package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
  261. package/dist/security/authorization/securityAuthorization.d.ts +88 -0
  262. package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
  263. package/dist/security/authorization/securityAuthorization.js +172 -0
  264. package/dist/security/authorization/securityAuthorization.js.map +1 -0
  265. package/dist/security/authorization.d.ts +45 -0
  266. package/dist/security/authorization.d.ts.map +1 -0
  267. package/dist/security/authorization.js +128 -0
  268. package/dist/security/authorization.js.map +1 -0
  269. package/dist/security/comprehensive-security-research.d.ts +84 -0
  270. package/dist/security/comprehensive-security-research.d.ts.map +1 -0
  271. package/dist/security/comprehensive-security-research.js +211 -0
  272. package/dist/security/comprehensive-security-research.js.map +1 -0
  273. package/dist/security/offensive/exploitationEngine.d.ts +54 -0
  274. package/dist/security/offensive/exploitationEngine.d.ts.map +1 -0
  275. package/dist/security/offensive/exploitationEngine.js +263 -0
  276. package/dist/security/offensive/exploitationEngine.js.map +1 -0
  277. package/dist/security/persistence-analyzer.d.ts +56 -0
  278. package/dist/security/persistence-analyzer.d.ts.map +1 -0
  279. package/dist/security/persistence-analyzer.js +187 -0
  280. package/dist/security/persistence-analyzer.js.map +1 -0
  281. package/dist/security/persistence-cli.d.ts +36 -0
  282. package/dist/security/persistence-cli.d.ts.map +1 -0
  283. package/dist/security/persistence-cli.js +160 -0
  284. package/dist/security/persistence-cli.js.map +1 -0
  285. package/dist/security/persistence-research.d.ts +100 -0
  286. package/dist/security/persistence-research.d.ts.map +1 -0
  287. package/dist/security/persistence-research.js +372 -0
  288. package/dist/security/persistence-research.js.map +1 -0
  289. package/dist/security/real/networkExploitation.d.ts +92 -0
  290. package/dist/security/real/networkExploitation.d.ts.map +1 -0
  291. package/dist/security/real/networkExploitation.js +316 -0
  292. package/dist/security/real/networkExploitation.js.map +1 -0
  293. package/dist/security/real/persistenceImplementation.d.ts +62 -0
  294. package/dist/security/real/persistenceImplementation.d.ts.map +1 -0
  295. package/dist/security/real/persistenceImplementation.js +323 -0
  296. package/dist/security/real/persistenceImplementation.js.map +1 -0
  297. package/dist/security/real/vulnerabilityScanner.d.ts +73 -0
  298. package/dist/security/real/vulnerabilityScanner.d.ts.map +1 -0
  299. package/dist/security/real/vulnerabilityScanner.js +341 -0
  300. package/dist/security/real/vulnerabilityScanner.js.map +1 -0
  301. package/dist/security/research/persistenceResearch.d.ts +97 -0
  302. package/dist/security/research/persistenceResearch.d.ts.map +1 -0
  303. package/dist/security/research/persistenceResearch.js +282 -0
  304. package/dist/security/research/persistenceResearch.js.map +1 -0
  305. package/dist/security/security-testing-framework.d.ts +120 -0
  306. package/dist/security/security-testing-framework.d.ts.map +1 -0
  307. package/dist/security/security-testing-framework.js +372 -0
  308. package/dist/security/security-testing-framework.js.map +1 -0
  309. package/dist/security/simulation/attackSimulation.d.ts +93 -0
  310. package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
  311. package/dist/security/simulation/attackSimulation.js +341 -0
  312. package/dist/security/simulation/attackSimulation.js.map +1 -0
  313. package/dist/shell/bracketedPasteManager.d.ts +76 -0
  314. package/dist/shell/bracketedPasteManager.d.ts.map +1 -1
  315. package/dist/shell/bracketedPasteManager.js +267 -9
  316. package/dist/shell/bracketedPasteManager.js.map +1 -1
  317. package/dist/shell/interactiveShell.d.ts +34 -1
  318. package/dist/shell/interactiveShell.d.ts.map +1 -1
  319. package/dist/shell/interactiveShell.js +304 -24
  320. package/dist/shell/interactiveShell.js.map +1 -1
  321. package/dist/shell/taskCompletionDetector.d.ts +101 -0
  322. package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
  323. package/dist/shell/taskCompletionDetector.js +343 -0
  324. package/dist/shell/taskCompletionDetector.js.map +1 -0
  325. package/dist/tools/cloudTools.d.ts +57 -0
  326. package/dist/tools/cloudTools.d.ts.map +1 -0
  327. package/dist/tools/cloudTools.js +865 -0
  328. package/dist/tools/cloudTools.js.map +1 -0
  329. package/dist/tools/enhancedSecurityTools.d.ts +19 -0
  330. package/dist/tools/enhancedSecurityTools.d.ts.map +1 -0
  331. package/dist/tools/enhancedSecurityTools.js +215 -0
  332. package/dist/tools/enhancedSecurityTools.js.map +1 -0
  333. package/dist/tools/offensiveSecurityTools.d.ts +16 -0
  334. package/dist/tools/offensiveSecurityTools.d.ts.map +1 -0
  335. package/dist/tools/offensiveSecurityTools.js +285 -0
  336. package/dist/tools/offensiveSecurityTools.js.map +1 -0
  337. package/dist/tools/realSecurityTools.d.ts +18 -0
  338. package/dist/tools/realSecurityTools.d.ts.map +1 -0
  339. package/dist/tools/realSecurityTools.js +468 -0
  340. package/dist/tools/realSecurityTools.js.map +1 -0
  341. package/dist/tools/securityTools.d.ts +20 -0
  342. package/dist/tools/securityTools.d.ts.map +1 -0
  343. package/dist/tools/securityTools.js +449 -0
  344. package/dist/tools/securityTools.js.map +1 -0
  345. package/package.json +27 -12
  346. package/scripts/deploy-security-capabilities.js +178 -0
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Alpha Zero 2 - Competitive Agent Runner
3
+ *
4
+ * Runs competitive comparisons between two AI agents.
5
+ *
6
+ * Principal Investigator: Bo Shang
7
+ * Framework: erosolar-cli
8
+ */
9
+ import { extractCodeBlocks, evaluateCodeQuality, calculateRewardScore } from './codeEvaluator.js';
10
+ /**
11
+ * Run competitive comparisons between two agents.
12
+ */
13
+ export class CompetitiveAgentRunner {
14
+ constructor(agent1, agent2) {
15
+ this.roundResults = [];
16
+ this.agent1 = agent1;
17
+ this.agent2 = agent2;
18
+ }
19
+ /**
20
+ * Run both agents on the same prompt and compare results.
21
+ */
22
+ async runComparison(prompt, evaluateCode = true) {
23
+ const startTime = Date.now();
24
+ // Run both agents concurrently
25
+ const [result1, result2] = await Promise.allSettled([
26
+ this.runAgent(this.agent1, prompt, evaluateCode),
27
+ this.runAgent(this.agent2, prompt, evaluateCode),
28
+ ]);
29
+ const agent1Result = result1.status === 'fulfilled'
30
+ ? result1.value
31
+ : { response: '', error: String(result1.reason), score: 0, timeMs: 0 };
32
+ const agent2Result = result2.status === 'fulfilled'
33
+ ? result2.value
34
+ : { response: '', error: String(result2.reason), score: 0, timeMs: 0 };
35
+ const totalTimeMs = Date.now() - startTime;
36
+ // Determine winner
37
+ let winner;
38
+ if (agent1Result.score > agent2Result.score) {
39
+ winner = this.agent1.getAgentId();
40
+ }
41
+ else if (agent2Result.score > agent1Result.score) {
42
+ winner = this.agent2.getAgentId();
43
+ }
44
+ else {
45
+ winner = 'tie';
46
+ }
47
+ const result = {
48
+ prompt: prompt.slice(0, 100),
49
+ agent1: {
50
+ id: this.agent1.getAgentId(),
51
+ score: agent1Result.score,
52
+ responseLength: agent1Result.response.length,
53
+ timeMs: agent1Result.timeMs,
54
+ error: agent1Result.error,
55
+ },
56
+ agent2: {
57
+ id: this.agent2.getAgentId(),
58
+ score: agent2Result.score,
59
+ responseLength: agent2Result.response.length,
60
+ timeMs: agent2Result.timeMs,
61
+ error: agent2Result.error,
62
+ },
63
+ winner,
64
+ totalTimeMs,
65
+ };
66
+ this.roundResults.push(result);
67
+ return result;
68
+ }
69
+ /**
70
+ * Run a single agent and return results.
71
+ */
72
+ async runAgent(agent, prompt, evaluateCode) {
73
+ const startTime = Date.now();
74
+ try {
75
+ const response = await agent.send(prompt);
76
+ const timeMs = Date.now() - startTime;
77
+ // Calculate score
78
+ let score = 50; // Base score
79
+ if (evaluateCode && response.includes('```')) {
80
+ const codeBlocks = extractCodeBlocks(response);
81
+ if (codeBlocks.length > 0) {
82
+ const metrics = evaluateCodeQuality(codeBlocks[0]);
83
+ score = calculateRewardScore(metrics);
84
+ }
85
+ }
86
+ return { response, score, timeMs };
87
+ }
88
+ catch (error) {
89
+ return {
90
+ response: '',
91
+ score: 0,
92
+ timeMs: Date.now() - startTime,
93
+ error: error instanceof Error ? error.message : String(error),
94
+ };
95
+ }
96
+ }
97
+ /**
98
+ * Get current competition standings.
99
+ */
100
+ getStandings() {
101
+ const agent1Wins = this.roundResults.filter((r) => r.winner === this.agent1.getAgentId()).length;
102
+ const agent2Wins = this.roundResults.filter((r) => r.winner === this.agent2.getAgentId()).length;
103
+ const ties = this.roundResults.filter((r) => r.winner === 'tie').length;
104
+ const total = this.roundResults.length;
105
+ return {
106
+ totalRounds: total,
107
+ agent1: {
108
+ id: this.agent1.getAgentId(),
109
+ wins: agent1Wins,
110
+ winRate: total > 0 ? agent1Wins / total : 0,
111
+ },
112
+ agent2: {
113
+ id: this.agent2.getAgentId(),
114
+ wins: agent2Wins,
115
+ winRate: total > 0 ? agent2Wins / total : 0,
116
+ },
117
+ ties,
118
+ };
119
+ }
120
+ /**
121
+ * Get all round results.
122
+ */
123
+ getRoundResults() {
124
+ return [...this.roundResults];
125
+ }
126
+ /**
127
+ * Reset competition history.
128
+ */
129
+ reset() {
130
+ this.roundResults.length = 0;
131
+ }
132
+ }
133
+ /**
134
+ * Tournament runner for multi-round competitions.
135
+ */
136
+ export class TournamentRunner {
137
+ constructor(agent1, agent2) {
138
+ this.status = 'pending';
139
+ this.currentResult = null;
140
+ this.agent1 = agent1;
141
+ this.agent2 = agent2;
142
+ }
143
+ /**
144
+ * Run a tournament with the given configuration.
145
+ */
146
+ async run(config, callbacks) {
147
+ this.status = 'running';
148
+ const startTime = new Date();
149
+ const runner = new CompetitiveAgentRunner(this.agent1, this.agent2);
150
+ const rounds = [];
151
+ try {
152
+ for (let i = 0; i < config.rounds; i++) {
153
+ const prompt = config.prompts[i % config.prompts.length];
154
+ callbacks?.onRoundStart?.(i + 1, prompt);
155
+ const result = await runner.runComparison(prompt, config.evaluateCode);
156
+ rounds.push(result);
157
+ callbacks?.onRoundComplete?.(i + 1, result);
158
+ }
159
+ const endTime = new Date();
160
+ const totalDurationMs = endTime.getTime() - startTime.getTime();
161
+ const result = {
162
+ tournamentId: config.tournamentId,
163
+ config,
164
+ rounds,
165
+ standings: runner.getStandings(),
166
+ startTime: startTime.toISOString(),
167
+ endTime: endTime.toISOString(),
168
+ totalDurationMs,
169
+ };
170
+ this.currentResult = result;
171
+ this.status = 'completed';
172
+ callbacks?.onTournamentComplete?.(result);
173
+ return result;
174
+ }
175
+ catch (error) {
176
+ this.status = 'failed';
177
+ const err = error instanceof Error ? error : new Error(String(error));
178
+ callbacks?.onError?.(err);
179
+ throw err;
180
+ }
181
+ }
182
+ /**
183
+ * Get current tournament status.
184
+ */
185
+ getStatus() {
186
+ return this.status;
187
+ }
188
+ /**
189
+ * Get the tournament result (if completed).
190
+ */
191
+ getResult() {
192
+ return this.currentResult;
193
+ }
194
+ }
195
+ /**
196
+ * Generate a summary of tournament results.
197
+ */
198
+ export function formatTournamentSummary(result) {
199
+ const lines = [
200
+ `Tournament: ${result.tournamentId}`,
201
+ '='.repeat(50),
202
+ '',
203
+ 'Final Standings:',
204
+ ` ${result.standings.agent1.id}: ${result.standings.agent1.wins} wins (${(result.standings.agent1.winRate * 100).toFixed(1)}%)`,
205
+ ` ${result.standings.agent2.id}: ${result.standings.agent2.wins} wins (${(result.standings.agent2.winRate * 100).toFixed(1)}%)`,
206
+ ` Ties: ${result.standings.ties}`,
207
+ '',
208
+ `Total Rounds: ${result.standings.totalRounds}`,
209
+ `Duration: ${(result.totalDurationMs / 1000).toFixed(2)}s`,
210
+ '',
211
+ 'Round Results:',
212
+ ];
213
+ for (let i = 0; i < result.rounds.length; i++) {
214
+ const round = result.rounds[i];
215
+ lines.push(` Round ${i + 1}: ${round.winner === 'tie' ? 'Tie' : `${round.winner} wins`} ` +
216
+ `(${round.agent1.score.toFixed(1)} vs ${round.agent2.score.toFixed(1)})`);
217
+ }
218
+ return lines.join('\n');
219
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Alpha Zero 2 - Multi-Agent Competitive RL Framework
3
+ *
4
+ * A competitive reinforcement learning framework where two autonomous erosolar-cli
5
+ * agents compete on code optimization tasks while recursively improving their own
6
+ * implementations.
7
+ *
8
+ * Principal Investigator: Bo Shang
9
+ * Framework: erosolar-cli
10
+ * Status: Active Development
11
+ *
12
+ * Core Innovations:
13
+ * - Recursive Self-Modification Engine: Agents modify their own tool source code
14
+ * - Competitive Multi-Agent Framework: Tournament system with parallel execution
15
+ * - Version-Controlled Self-Improvement: SHA-256 checkpoints with automatic rollback
16
+ * - AST-Based Code Quality Metrics: Comprehensive evaluation across 10+ dimensions
17
+ *
18
+ * Structure:
19
+ * - Core: Types, metrics tracking, code evaluation
20
+ * - Self-Modification: Version-controlled code self-improvement
21
+ * - Introspection: Runtime analysis and self-awareness
22
+ * - Competitive: Multi-agent tournament framework
23
+ * - Security: Optional security research module (lazy loaded)
24
+ *
25
+ * Tech Stack (erosolar-cli):
26
+ * - Python: typer, rich, prompt-toolkit, pydantic, aiohttp, tiktoken
27
+ * - TypeScript: chalk, ora, gradient-string, boxen, nanospinner
28
+ * - AI Providers: anthropic, openai, google-generativeai
29
+ * - Testing: pytest, pytest-asyncio, mypy, ruff, eslint
30
+ *
31
+ * Research Contributions:
32
+ * - Demonstrated practical recursive self-improvement in autonomous agents
33
+ * - Proved competitive dynamics accelerate capability development
34
+ * - Established version control patterns for safe code self-modification
35
+ * - Created comprehensive metrics for evaluating code generation quality
36
+ *
37
+ * Citation:
38
+ * @software{alpha_zero_2,
39
+ * title={Alpha Zero 2: Recursive Self-Improvement in Competitive Multi-Agent Systems},
40
+ * author={Bo Shang},
41
+ * year={2024},
42
+ * framework={erosolar-cli},
43
+ * url={https://github.com/ErosolarAI/erosolar-by-bo}
44
+ * }
45
+ */
46
+ export { ALPHA_ZERO_2_METADATA } from './types.js';
47
+ // Metrics Tracker
48
+ export { MetricsTracker, createDefaultMetrics } from './metricsTracker.js';
49
+ // Code Evaluator
50
+ export { extractCodeBlocks, evaluateCodeQuality, calculateRewardScore, } from './codeEvaluator.js';
51
+ // Agent Wrapper
52
+ export { AlphaZeroAgentWrapper } from './agentWrapper.js';
53
+ // Competitive Runner
54
+ export { CompetitiveAgentRunner, TournamentRunner, formatTournamentSummary, } from './competitiveRunner.js';
55
+ // Self-Modification Engine
56
+ export { SelfModificationEngine, createSelfModificationEngine, } from './selfModification.js';
57
+ // Introspection Engine
58
+ export { IntrospectionEngine, createIntrospectionEngine, } from './introspection.js';
59
+ // Security Module (optional, lazy loaded)
60
+ export { isGoogleEnabled, getGoogleModule } from './security/googleLoader.js';
61
+ export * from './security/index.js';
62
+ /**
63
+ * Version information
64
+ */
65
+ export const ALPHA_ZERO_VERSION = '1.0.0';
66
+ export const ALPHA_ZERO_AUTHOR = 'Bo Shang';
67
+ export const ALPHA_ZERO_FRAMEWORK = 'erosolar-cli';
68
+ /**
69
+ * Check if security research module is available
70
+ */
71
+ let _securityModule = null;
72
+ export function isSecurityEnabled() {
73
+ if (_securityModule !== null) {
74
+ return true;
75
+ }
76
+ try {
77
+ // Module exists, can be loaded
78
+ return true;
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }
84
+ /**
85
+ * Get security module (lazy load)
86
+ */
87
+ export async function getSecurityModule() {
88
+ if (_securityModule === null) {
89
+ try {
90
+ _securityModule = await import('./security/index.js');
91
+ }
92
+ catch (error) {
93
+ throw new Error('Security research module not available. ' +
94
+ 'Ensure security modules are built and available.');
95
+ }
96
+ }
97
+ return _securityModule;
98
+ }
@@ -0,0 +1,298 @@
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
+ }