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,211 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { buildError } from '../core/errors.js';
3
+ /**
4
+ * Background Bash Shell Manager
5
+ *
6
+ * Manages long-running background bash shells with output buffering.
7
+ */
8
+ class BackgroundShellManager {
9
+ constructor() {
10
+ this.shells = new Map();
11
+ this.nextId = 1;
12
+ }
13
+ createShell(command, workingDir) {
14
+ const shellId = `shell_${this.nextId++}`;
15
+ const shell = new BackgroundShell(shellId, command, workingDir);
16
+ this.shells.set(shellId, shell);
17
+ shell.start();
18
+ return shellId;
19
+ }
20
+ getShell(shellId) {
21
+ return this.shells.get(shellId);
22
+ }
23
+ killShell(shellId) {
24
+ const shell = this.shells.get(shellId);
25
+ if (shell) {
26
+ shell.kill();
27
+ this.shells.delete(shellId);
28
+ return true;
29
+ }
30
+ return false;
31
+ }
32
+ listShells() {
33
+ return Array.from(this.shells.keys());
34
+ }
35
+ }
36
+ class BackgroundShell {
37
+ constructor(id, command, _workingDir) {
38
+ this.id = id;
39
+ this.command = command;
40
+ this._workingDir = _workingDir;
41
+ this.outputBuffer = [];
42
+ this.errorBuffer = [];
43
+ this.lastReadPosition = 0;
44
+ this.isRunning = false;
45
+ }
46
+ start() {
47
+ this.process = spawn('bash', ['-c', this.command], {
48
+ cwd: this._workingDir,
49
+ stdio: ['ignore', 'pipe', 'pipe'],
50
+ });
51
+ this.isRunning = true;
52
+ this.process.stdout?.on('data', (data) => {
53
+ this.outputBuffer.push(data.toString());
54
+ });
55
+ this.process.stderr?.on('data', (data) => {
56
+ this.errorBuffer.push(data.toString());
57
+ });
58
+ this.process.on('exit', (code) => {
59
+ this.exitCode = code ?? 0;
60
+ this.isRunning = false;
61
+ });
62
+ }
63
+ getNewOutput(filter) {
64
+ const allOutput = this.outputBuffer.join('');
65
+ const newOutput = allOutput.substring(this.lastReadPosition);
66
+ this.lastReadPosition = allOutput.length;
67
+ const allError = this.errorBuffer.join('');
68
+ let stdout = newOutput;
69
+ if (filter) {
70
+ const lines = newOutput.split('\n');
71
+ const filtered = lines.filter(line => filter.test(line));
72
+ stdout = filtered.join('\n');
73
+ }
74
+ const status = this.isRunning
75
+ ? 'running'
76
+ : `exited with code ${this.exitCode}`;
77
+ return {
78
+ stdout,
79
+ stderr: allError,
80
+ status,
81
+ };
82
+ }
83
+ kill() {
84
+ if (this.process) {
85
+ this.process.kill('SIGTERM');
86
+ setTimeout(() => {
87
+ if (this.process && !this.process.killed) {
88
+ this.process.kill('SIGKILL');
89
+ }
90
+ }, 5000);
91
+ }
92
+ }
93
+ getStatus() {
94
+ return this.isRunning ? 'running' : `exited with code ${this.exitCode}`;
95
+ }
96
+ }
97
+ // Global manager instance
98
+ const shellManager = new BackgroundShellManager();
99
+ /**
100
+ * Creates background bash management tools
101
+ *
102
+ * Tools:
103
+ * - Bash (with run_in_background): Start background processes
104
+ * - BashOutput: Retrieve output from background shells
105
+ * - KillShell: Terminate background shells
106
+ *
107
+ * @param _workingDir - The working directory for commands (reserved for future use)
108
+ * @returns Array of tool definitions
109
+ */
110
+ export function createBackgroundBashTools(_workingDir) {
111
+ return [
112
+ {
113
+ name: 'BashOutput',
114
+ description: 'Retrieves output from a running or completed background bash shell. Always returns only new output since the last check.',
115
+ parameters: {
116
+ type: 'object',
117
+ properties: {
118
+ bash_id: {
119
+ type: 'string',
120
+ description: 'The ID of the background shell to retrieve output from',
121
+ },
122
+ filter: {
123
+ type: 'string',
124
+ description: 'Optional regular expression to filter the output lines. Only lines matching this regex will be included.',
125
+ },
126
+ },
127
+ required: ['bash_id'],
128
+ additionalProperties: false,
129
+ },
130
+ handler: async (args) => {
131
+ const bashId = args['bash_id'];
132
+ const filterStr = args['filter'];
133
+ if (typeof bashId !== 'string' || !bashId.trim()) {
134
+ return 'Error: bash_id must be a non-empty string.';
135
+ }
136
+ try {
137
+ const shell = shellManager.getShell(bashId);
138
+ if (!shell) {
139
+ const available = shellManager.listShells();
140
+ return `Error: Shell "${bashId}" not found.\n\nAvailable shells: ${available.length > 0 ? available.join(', ') : 'none'}`;
141
+ }
142
+ const filter = filterStr && typeof filterStr === 'string'
143
+ ? new RegExp(filterStr)
144
+ : undefined;
145
+ const { stdout, stderr, status } = shell.getNewOutput(filter);
146
+ const parts = [];
147
+ parts.push(`Shell: ${bashId}`);
148
+ parts.push(`Status: ${status}`);
149
+ if (stdout) {
150
+ parts.push('\n=== New Output ===');
151
+ parts.push(stdout);
152
+ }
153
+ if (stderr) {
154
+ parts.push('\n=== Errors ===');
155
+ parts.push(stderr);
156
+ }
157
+ if (!stdout && !stderr) {
158
+ parts.push('\n(No new output)');
159
+ }
160
+ return parts.join('\n');
161
+ }
162
+ catch (error) {
163
+ return buildError('retrieving shell output', error, { bash_id: bashId });
164
+ }
165
+ },
166
+ },
167
+ {
168
+ name: 'KillShell',
169
+ description: 'Kills a running background bash shell by its ID. Returns success or failure status.',
170
+ parameters: {
171
+ type: 'object',
172
+ properties: {
173
+ shell_id: {
174
+ type: 'string',
175
+ description: 'The ID of the background shell to kill',
176
+ },
177
+ },
178
+ required: ['shell_id'],
179
+ additionalProperties: false,
180
+ },
181
+ handler: async (args) => {
182
+ const shellId = args['shell_id'];
183
+ if (typeof shellId !== 'string' || !shellId.trim()) {
184
+ return 'Error: shell_id must be a non-empty string.';
185
+ }
186
+ try {
187
+ const success = shellManager.killShell(shellId);
188
+ if (success) {
189
+ return `✓ Shell "${shellId}" has been terminated.`;
190
+ }
191
+ else {
192
+ const available = shellManager.listShells();
193
+ return `Error: Shell "${shellId}" not found.\n\nAvailable shells: ${available.length > 0 ? available.join(', ') : 'none'}`;
194
+ }
195
+ }
196
+ catch (error) {
197
+ return buildError('killing shell', error, { shell_id: shellId });
198
+ }
199
+ },
200
+ },
201
+ ];
202
+ }
203
+ /**
204
+ * Start a background bash command
205
+ *
206
+ * This should be integrated into the main Bash tool with a run_in_background parameter.
207
+ * For now, it's exported as a helper function.
208
+ */
209
+ export function startBackgroundShell(command, workingDir) {
210
+ return shellManager.createShell(command, workingDir);
211
+ }
@@ -0,0 +1,159 @@
1
+ import { exec } from 'node:child_process';
2
+ import { mkdir } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { promisify } from 'node:util';
5
+ import { createBackgroundBashTools, startBackgroundShell } from './backgroundBashTools.js';
6
+ import { validateBashCommand, SmartFixer } from '../core/errors/safetyValidator.js';
7
+ import { toStructuredError } from '../core/errors/errorTypes.js';
8
+ const execAsync = promisify(exec);
9
+ const sandboxCache = new Map();
10
+ export function createBashTools(workingDir) {
11
+ const backgroundTools = createBackgroundBashTools(workingDir);
12
+ return [
13
+ {
14
+ name: 'execute_bash',
15
+ description: 'Execute a bash command in the working directory. Use run_in_background: true to run commands in the background and monitor with BashOutput.',
16
+ parameters: {
17
+ type: 'object',
18
+ properties: {
19
+ command: {
20
+ type: 'string',
21
+ description: 'The bash command to execute',
22
+ },
23
+ timeout: {
24
+ type: 'number',
25
+ description: 'Timeout in milliseconds (default: 30000). Not used when run_in_background is true.',
26
+ },
27
+ run_in_background: {
28
+ type: 'boolean',
29
+ description: 'Set to true to run this command in the background. Returns a shell ID that can be used with BashOutput to monitor output.',
30
+ },
31
+ },
32
+ required: ['command'],
33
+ },
34
+ handler: async (args) => {
35
+ const command = args['command'];
36
+ const timeout = args['timeout'] || 30000;
37
+ const runInBackground = args['run_in_background'] === true;
38
+ // Enhanced safety validation with structured errors
39
+ const validation = validateBashCommand(command);
40
+ if (!validation.valid) {
41
+ const structuredError = validation.error ? toStructuredError(validation.error) : null;
42
+ if (structuredError) {
43
+ // Return formatted error with suggestions
44
+ let errorMsg = structuredError.toDisplayString();
45
+ // Add auto-fix suggestion if available
46
+ if (validation.autoFix?.available) {
47
+ const { fixed, changes } = SmartFixer.fixDangerousCommand(command);
48
+ if (changes.length > 0) {
49
+ errorMsg += '\n\nAuto-fix available:';
50
+ for (const change of changes) {
51
+ errorMsg += `\n - ${change}`;
52
+ }
53
+ errorMsg += `\n\nFixed command: ${fixed}`;
54
+ }
55
+ }
56
+ return errorMsg;
57
+ }
58
+ return 'Error: Command validation failed';
59
+ }
60
+ // Log warnings if any
61
+ if (validation.warnings.length > 0) {
62
+ for (const warning of validation.warnings) {
63
+ console.warn(`[Bash Safety] ${warning}`);
64
+ }
65
+ }
66
+ // Handle background execution
67
+ if (runInBackground) {
68
+ const shellId = startBackgroundShell(command, workingDir);
69
+ return `Background shell started: ${shellId}\n\nUse BashOutput with bash_id="${shellId}" to monitor output.\nUse KillShell with shell_id="${shellId}" to terminate.`;
70
+ }
71
+ // Handle foreground execution
72
+ try {
73
+ const env = await buildSandboxEnv(workingDir);
74
+ const { stdout, stderr } = await execAsync(command, {
75
+ cwd: workingDir,
76
+ timeout,
77
+ maxBuffer: 1024 * 1024 * 10, // 10MB
78
+ env,
79
+ });
80
+ let result = '';
81
+ if (stdout)
82
+ result += `stdout:\n${stdout}\n`;
83
+ if (stderr)
84
+ result += `stderr:\n${stderr}\n`;
85
+ return result || 'Command executed successfully (no output)';
86
+ }
87
+ catch (error) {
88
+ if (error.killed) {
89
+ return `Error: Command timed out after ${timeout}ms`;
90
+ }
91
+ return `Error executing command: ${error.message}\nstderr: ${error.stderr || 'none'}`;
92
+ }
93
+ },
94
+ },
95
+ {
96
+ name: 'execute_bash_stream',
97
+ description: 'Execute a bash command and stream output (for long-running commands)',
98
+ parameters: {
99
+ type: 'object',
100
+ properties: {
101
+ command: {
102
+ type: 'string',
103
+ description: 'The bash command to execute',
104
+ },
105
+ },
106
+ required: ['command'],
107
+ },
108
+ handler: async (_args) => {
109
+ await buildSandboxEnv(workingDir);
110
+ return 'Stream execution not yet implemented - use execute_bash instead';
111
+ },
112
+ },
113
+ ...backgroundTools,
114
+ ];
115
+ }
116
+ export async function buildSandboxEnv(workingDir, options) {
117
+ const envPreference = process.env['EROSOLAR_PRESERVE_HOME'];
118
+ const preserveHome = envPreference === '1'
119
+ ? true
120
+ : envPreference === '0'
121
+ ? false
122
+ : Boolean(options?.preserveHome);
123
+ const paths = await ensureSandboxPaths(workingDir);
124
+ const env = {
125
+ ...process.env,
126
+ EROSOLAR_SANDBOX_ROOT: paths.root,
127
+ EROSOLAR_SANDBOX_HOME: paths.home,
128
+ EROSOLAR_SANDBOX_TMP: paths.tmp,
129
+ };
130
+ if (!preserveHome) {
131
+ env['HOME'] = paths.home;
132
+ }
133
+ env['XDG_CACHE_HOME'] = paths.cache;
134
+ env['XDG_CONFIG_HOME'] = paths.config;
135
+ env['XDG_DATA_HOME'] = paths.data;
136
+ env['TMPDIR'] = paths.tmp;
137
+ env['TMP'] = paths.tmp;
138
+ env['TEMP'] = paths.tmp;
139
+ return env;
140
+ }
141
+ async function ensureSandboxPaths(workingDir) {
142
+ const key = workingDir;
143
+ let pending = sandboxCache.get(key);
144
+ if (!pending) {
145
+ pending = createSandboxPaths(workingDir);
146
+ sandboxCache.set(key, pending);
147
+ }
148
+ return pending;
149
+ }
150
+ async function createSandboxPaths(workingDir) {
151
+ const root = join(workingDir, '.erosolar', 'shell-sandbox');
152
+ const home = join(root, 'home');
153
+ const cache = join(root, 'cache');
154
+ const config = join(root, 'config');
155
+ const data = join(root, 'data');
156
+ const tmp = join(root, 'tmp');
157
+ await Promise.all([home, cache, config, data, tmp].map((dir) => mkdir(dir, { recursive: true })));
158
+ return { root, home, cache, config, data, tmp };
159
+ }