erosolar-cli 1.5.3 → 1.5.5

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 (385) hide show
  1. package/config/security-deployment.json +54 -0
  2. package/dist/active-stack-security.d.ts +110 -0
  3. package/dist/active-stack-security.js +313 -0
  4. package/dist/active-stack-security.js.map +1 -0
  5. package/dist/advanced-targeting.d.ts +113 -0
  6. package/dist/advanced-targeting.js +252 -0
  7. package/dist/advanced-targeting.js.map +1 -0
  8. package/dist/bin/adapters/node/index.js +33 -0
  9. package/dist/bin/adapters/types.js +1 -0
  10. package/dist/bin/alpha-zero/agentWrapper.js +165 -0
  11. package/dist/bin/alpha-zero/codeEvaluator.js +272 -0
  12. package/dist/bin/alpha-zero/competitiveRunner.js +219 -0
  13. package/dist/bin/alpha-zero/index.js +98 -0
  14. package/dist/bin/alpha-zero/introspection.js +298 -0
  15. package/dist/bin/alpha-zero/metricsTracker.js +207 -0
  16. package/dist/bin/alpha-zero/security/core.js +269 -0
  17. package/dist/bin/alpha-zero/security/google.js +308 -0
  18. package/dist/bin/alpha-zero/security/googleLoader.js +40 -0
  19. package/dist/bin/alpha-zero/security/index.js +31 -0
  20. package/dist/bin/alpha-zero/security/simulation.js +274 -0
  21. package/dist/bin/alpha-zero/selfModification.js +231 -0
  22. package/dist/bin/alpha-zero/types.js +30 -0
  23. package/dist/bin/bin/erosolar-optimized.js +205 -0
  24. package/dist/bin/capabilities/agentSpawningCapability.js +116 -0
  25. package/dist/bin/capabilities/bashCapability.js +22 -0
  26. package/dist/bin/capabilities/cloudCapability.js +36 -0
  27. package/dist/bin/capabilities/codeAnalysisCapability.js +22 -0
  28. package/dist/bin/capabilities/codeQualityCapability.js +23 -0
  29. package/dist/bin/capabilities/dependencySecurityCapability.js +22 -0
  30. package/dist/bin/capabilities/devCapability.js +22 -0
  31. package/dist/bin/capabilities/editCapability.js +28 -0
  32. package/dist/bin/capabilities/emailCapability.js +20 -0
  33. package/dist/bin/capabilities/enhancedGitCapability.js +221 -0
  34. package/dist/bin/capabilities/filesystemCapability.js +22 -0
  35. package/dist/bin/capabilities/globCapability.js +28 -0
  36. package/dist/bin/capabilities/interactionCapability.js +20 -0
  37. package/dist/bin/capabilities/learnCapability.js +22 -0
  38. package/dist/bin/capabilities/mcpCapability.js +20 -0
  39. package/dist/bin/capabilities/notebookCapability.js +28 -0
  40. package/dist/bin/capabilities/planningCapability.js +27 -0
  41. package/dist/bin/capabilities/refactoringCapability.js +23 -0
  42. package/dist/bin/capabilities/repoChecksCapability.js +22 -0
  43. package/dist/bin/capabilities/searchCapability.js +22 -0
  44. package/dist/bin/capabilities/skillCapability.js +76 -0
  45. package/dist/bin/capabilities/taskManagementCapability.js +20 -0
  46. package/dist/bin/capabilities/testingCapability.js +23 -0
  47. package/dist/bin/capabilities/toolManifest.js +159 -0
  48. package/dist/bin/capabilities/toolRegistry.js +114 -0
  49. package/dist/bin/capabilities/webCapability.js +20 -0
  50. package/dist/bin/config.js +139 -0
  51. package/dist/bin/contracts/v1/agent.js +7 -0
  52. package/dist/bin/contracts/v1/agentProfileManifest.js +8 -0
  53. package/dist/bin/contracts/v1/agentRules.js +9 -0
  54. package/dist/bin/contracts/v1/toolAccess.js +8 -0
  55. package/dist/bin/core/agent.js +362 -0
  56. package/dist/bin/core/agentProfileManifest.js +187 -0
  57. package/dist/bin/core/agentProfiles.js +34 -0
  58. package/dist/bin/core/agentRulebook.js +135 -0
  59. package/dist/bin/core/agentSchemaLoader.js +233 -0
  60. package/dist/bin/core/contextManager.js +412 -0
  61. package/dist/bin/core/contextWindow.js +122 -0
  62. package/dist/bin/core/customCommands.js +80 -0
  63. package/dist/bin/core/errors/apiKeyErrors.js +114 -0
  64. package/dist/bin/core/errors/errorTypes.js +340 -0
  65. package/dist/bin/core/errors/safetyValidator.js +304 -0
  66. package/dist/bin/core/errors.js +32 -0
  67. package/dist/bin/core/modelDiscovery.js +755 -0
  68. package/dist/bin/core/preferences.js +224 -0
  69. package/dist/bin/core/schemaValidator.js +92 -0
  70. package/dist/bin/core/secretStore.js +199 -0
  71. package/dist/bin/core/sessionStore.js +187 -0
  72. package/dist/bin/core/toolRuntime.js +290 -0
  73. package/dist/bin/core/types.js +1 -0
  74. package/dist/bin/erosolar-optimized.d.ts +12 -0
  75. package/dist/bin/erosolar-optimized.d.ts.map +1 -0
  76. package/dist/bin/erosolar-optimized.js +239 -0
  77. package/dist/bin/erosolar-optimized.js.map +1 -0
  78. package/dist/bin/erosolar.js +14 -0
  79. package/dist/bin/erosolar.js.map +1 -1
  80. package/dist/bin/headless/headlessApp.js +172 -0
  81. package/dist/bin/mcp/config.js +202 -0
  82. package/dist/bin/mcp/stdioClient.js +172 -0
  83. package/dist/bin/mcp/toolBridge.js +104 -0
  84. package/dist/bin/mcp/types.js +1 -0
  85. package/dist/bin/plugins/index.js +113 -0
  86. package/dist/bin/plugins/providers/anthropic/index.js +25 -0
  87. package/dist/bin/plugins/providers/deepseek/index.js +24 -0
  88. package/dist/bin/plugins/providers/google/index.js +26 -0
  89. package/dist/bin/plugins/providers/index.js +19 -0
  90. package/dist/bin/plugins/providers/ollama/index.js +59 -0
  91. package/dist/bin/plugins/providers/openai/index.js +26 -0
  92. package/dist/bin/plugins/providers/xai/index.js +24 -0
  93. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +8 -0
  94. package/dist/bin/plugins/tools/bash/localBashPlugin.js +13 -0
  95. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +13 -0
  96. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +13 -0
  97. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +13 -0
  98. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +13 -0
  99. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +11 -0
  100. package/dist/bin/plugins/tools/development/devPlugin.js +13 -0
  101. package/dist/bin/plugins/tools/edit/editPlugin.js +14 -0
  102. package/dist/bin/plugins/tools/email/emailPlugin.js +11 -0
  103. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +8 -0
  104. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +13 -0
  105. package/dist/bin/plugins/tools/glob/globPlugin.js +14 -0
  106. package/dist/bin/plugins/tools/index.js +2 -0
  107. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +11 -0
  108. package/dist/bin/plugins/tools/learn/learnPlugin.js +13 -0
  109. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +8 -0
  110. package/dist/bin/plugins/tools/nodeDefaults.js +56 -0
  111. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +14 -0
  112. package/dist/bin/plugins/tools/planning/planningPlugin.js +14 -0
  113. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +11 -0
  114. package/dist/bin/plugins/tools/registry.js +57 -0
  115. package/dist/bin/plugins/tools/search/localSearchPlugin.js +13 -0
  116. package/dist/bin/plugins/tools/skills/skillPlugin.js +8 -0
  117. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +11 -0
  118. package/dist/bin/plugins/tools/testing/testingPlugin.js +11 -0
  119. package/dist/bin/plugins/tools/web/webPlugin.js +11 -0
  120. package/dist/bin/providers/anthropicProvider.js +329 -0
  121. package/dist/bin/providers/googleProvider.js +203 -0
  122. package/dist/bin/providers/openaiChatCompletionsProvider.js +208 -0
  123. package/dist/bin/providers/openaiResponsesProvider.js +249 -0
  124. package/dist/bin/providers/providerFactory.js +24 -0
  125. package/dist/bin/runtime/agentController.js +321 -0
  126. package/dist/bin/runtime/agentHost.js +153 -0
  127. package/dist/bin/runtime/agentSession.js +195 -0
  128. package/dist/bin/runtime/node.js +10 -0
  129. package/dist/bin/runtime/universal.js +28 -0
  130. package/dist/bin/shell/bracketedPasteManager.js +350 -0
  131. package/dist/bin/shell/fileChangeTracker.js +65 -0
  132. package/dist/bin/shell/interactiveShell.js +2908 -0
  133. package/dist/bin/shell/liveStatus.js +78 -0
  134. package/dist/bin/shell/shellApp.js +290 -0
  135. package/dist/bin/shell/systemPrompt.js +60 -0
  136. package/dist/bin/shell/updateManager.js +108 -0
  137. package/dist/bin/skills/skillRepository.js +236 -0
  138. package/dist/bin/skills/types.js +1 -0
  139. package/dist/bin/subagents/taskRunner.js +269 -0
  140. package/dist/bin/tools/backgroundBashTools.js +211 -0
  141. package/dist/bin/tools/bashTools.js +159 -0
  142. package/dist/bin/tools/cloudTools.js +864 -0
  143. package/dist/bin/tools/codeAnalysisTools.js +641 -0
  144. package/dist/bin/tools/codeQualityTools.js +294 -0
  145. package/dist/bin/tools/dependencyTools.js +282 -0
  146. package/dist/bin/tools/devTools.js +238 -0
  147. package/dist/bin/tools/diffUtils.js +137 -0
  148. package/dist/bin/tools/editTools.js +134 -0
  149. package/dist/bin/tools/emailTools.js +448 -0
  150. package/dist/bin/tools/fileTools.js +282 -0
  151. package/dist/bin/tools/globTools.js +173 -0
  152. package/dist/bin/tools/grepTools.js +332 -0
  153. package/dist/bin/tools/interactionTools.js +170 -0
  154. package/dist/bin/tools/learnTools.js +1818 -0
  155. package/dist/bin/tools/notebookEditTools.js +196 -0
  156. package/dist/bin/tools/planningTools.js +46 -0
  157. package/dist/bin/tools/refactoringTools.js +293 -0
  158. package/dist/bin/tools/repoChecksTools.js +160 -0
  159. package/dist/bin/tools/searchTools.js +206 -0
  160. package/dist/bin/tools/skillTools.js +177 -0
  161. package/dist/bin/tools/taskManagementTools.js +156 -0
  162. package/dist/bin/tools/testingTools.js +232 -0
  163. package/dist/bin/tools/webTools.js +480 -0
  164. package/dist/bin/ui/ShellUIAdapter.js +459 -0
  165. package/dist/bin/ui/UnifiedUIController.js +183 -0
  166. package/dist/bin/ui/animation/AnimationScheduler.js +430 -0
  167. package/dist/bin/ui/codeHighlighter.js +854 -0
  168. package/dist/bin/ui/designSystem.js +121 -0
  169. package/dist/bin/ui/display.js +1222 -0
  170. package/dist/bin/ui/interrupts/InterruptManager.js +437 -0
  171. package/dist/bin/ui/layout.js +139 -0
  172. package/dist/bin/ui/orchestration/StatusOrchestrator.js +403 -0
  173. package/dist/bin/ui/outputMode.js +38 -0
  174. package/dist/bin/ui/persistentPrompt.js +183 -0
  175. package/dist/bin/ui/richText.js +338 -0
  176. package/dist/bin/ui/shortcutsHelp.js +87 -0
  177. package/dist/bin/ui/telemetry/UITelemetry.js +443 -0
  178. package/dist/bin/ui/textHighlighter.js +210 -0
  179. package/dist/bin/ui/theme.js +116 -0
  180. package/dist/bin/ui/toolDisplay.js +423 -0
  181. package/dist/bin/ui/toolDisplayAdapter.js +357 -0
  182. package/dist/bin/workspace.js +106 -0
  183. package/dist/bin/workspace.validator.js +213 -0
  184. package/dist/capabilities/offensiveSecurityCapability.d.ts +26 -0
  185. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +1 -0
  186. package/dist/capabilities/offensiveSecurityCapability.js +58 -0
  187. package/dist/capabilities/offensiveSecurityCapability.js.map +1 -0
  188. package/dist/capabilities/realSecurityCapability.d.ts +26 -0
  189. package/dist/capabilities/realSecurityCapability.d.ts.map +1 -0
  190. package/dist/capabilities/realSecurityCapability.js +53 -0
  191. package/dist/capabilities/realSecurityCapability.js.map +1 -0
  192. package/dist/capabilities/securityCapability.d.ts +32 -0
  193. package/dist/capabilities/securityCapability.d.ts.map +1 -0
  194. package/dist/capabilities/securityCapability.js +57 -0
  195. package/dist/capabilities/securityCapability.js.map +1 -0
  196. package/dist/capabilities/ultimateSecurityCapability.d.ts +42 -0
  197. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +1 -0
  198. package/dist/capabilities/ultimateSecurityCapability.js +96 -0
  199. package/dist/capabilities/ultimateSecurityCapability.js.map +1 -0
  200. package/dist/core/LazyLoader.d.ts +129 -0
  201. package/dist/core/LazyLoader.d.ts.map +1 -0
  202. package/dist/core/LazyLoader.js +240 -0
  203. package/dist/core/LazyLoader.js.map +1 -0
  204. package/dist/core/agent.d.ts.map +1 -1
  205. package/dist/core/agent.js +78 -8
  206. package/dist/core/agent.js.map +1 -1
  207. package/dist/core/contextManager.d.ts.map +1 -1
  208. package/dist/core/contextManager.js +117 -16
  209. package/dist/core/contextManager.js.map +1 -1
  210. package/dist/core/intelligenceTools.d.ts +19 -0
  211. package/dist/core/intelligenceTools.d.ts.map +1 -0
  212. package/dist/core/intelligenceTools.js +453 -0
  213. package/dist/core/intelligenceTools.js.map +1 -0
  214. package/dist/core/operationalTools.d.ts +19 -0
  215. package/dist/core/operationalTools.d.ts.map +1 -0
  216. package/dist/core/operationalTools.js +467 -0
  217. package/dist/core/operationalTools.js.map +1 -0
  218. package/dist/intelligence/codeIntelligence.d.ts.map +1 -1
  219. package/dist/intelligence/codeIntelligence.js +12 -0
  220. package/dist/intelligence/codeIntelligence.js.map +1 -1
  221. package/dist/offensive/core/offensive-engine.d.ts +171 -0
  222. package/dist/offensive/core/offensive-engine.d.ts.map +1 -0
  223. package/dist/offensive/core/offensive-engine.js +345 -0
  224. package/dist/offensive/core/offensive-engine.js.map +1 -0
  225. package/dist/offensive/core/offensive-integration.d.ts +129 -0
  226. package/dist/offensive/core/offensive-integration.d.ts.map +1 -0
  227. package/dist/offensive/core/offensive-integration.js +364 -0
  228. package/dist/offensive/core/offensive-integration.js.map +1 -0
  229. package/dist/offensive/core/offensive-tools.d.ts +55 -0
  230. package/dist/offensive/core/offensive-tools.d.ts.map +1 -0
  231. package/dist/offensive/core/offensive-tools.js +438 -0
  232. package/dist/offensive/core/offensive-tools.js.map +1 -0
  233. package/dist/offensive/offensive-cli.d.ts +48 -0
  234. package/dist/offensive/offensive-cli.d.ts.map +1 -0
  235. package/dist/offensive/offensive-cli.js +233 -0
  236. package/dist/offensive/offensive-cli.js.map +1 -0
  237. package/dist/plugins/index.d.ts +1 -1
  238. package/dist/plugins/index.d.ts.map +1 -1
  239. package/dist/plugins/index.js +2 -0
  240. package/dist/plugins/index.js.map +1 -1
  241. package/dist/security/active-stack-security.d.ts +112 -0
  242. package/dist/security/active-stack-security.d.ts.map +1 -0
  243. package/dist/security/active-stack-security.js +296 -0
  244. package/dist/security/active-stack-security.js.map +1 -0
  245. package/dist/security/advanced-persistence-research.d.ts +92 -0
  246. package/dist/security/advanced-persistence-research.d.ts.map +1 -0
  247. package/dist/security/advanced-persistence-research.js +195 -0
  248. package/dist/security/advanced-persistence-research.js.map +1 -0
  249. package/dist/security/advanced-targeting.d.ts +119 -0
  250. package/dist/security/advanced-targeting.d.ts.map +1 -0
  251. package/dist/security/advanced-targeting.js +233 -0
  252. package/dist/security/advanced-targeting.js.map +1 -0
  253. package/dist/security/apt-simulation-cli.d.ts +57 -0
  254. package/dist/security/apt-simulation-cli.d.ts.map +1 -0
  255. package/dist/security/apt-simulation-cli.js +278 -0
  256. package/dist/security/apt-simulation-cli.js.map +1 -0
  257. package/dist/security/apt-simulation-engine-complete.d.ts +97 -0
  258. package/dist/security/apt-simulation-engine-complete.d.ts.map +1 -0
  259. package/dist/security/apt-simulation-engine-complete.js +441 -0
  260. package/dist/security/apt-simulation-engine-complete.js.map +1 -0
  261. package/dist/security/apt-simulation-engine.d.ts +97 -0
  262. package/dist/security/apt-simulation-engine.d.ts.map +1 -0
  263. package/dist/security/apt-simulation-engine.js +441 -0
  264. package/dist/security/apt-simulation-engine.js.map +1 -0
  265. package/dist/security/assessment/vulnerabilityAssessment.d.ts +104 -0
  266. package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +1 -0
  267. package/dist/security/assessment/vulnerabilityAssessment.js +315 -0
  268. package/dist/security/assessment/vulnerabilityAssessment.js.map +1 -0
  269. package/dist/security/authorization/securityAuthorization.d.ts +88 -0
  270. package/dist/security/authorization/securityAuthorization.d.ts.map +1 -0
  271. package/dist/security/authorization/securityAuthorization.js +172 -0
  272. package/dist/security/authorization/securityAuthorization.js.map +1 -0
  273. package/dist/security/authorization.d.ts +45 -0
  274. package/dist/security/authorization.d.ts.map +1 -0
  275. package/dist/security/authorization.js +128 -0
  276. package/dist/security/authorization.js.map +1 -0
  277. package/dist/security/comprehensive-security-research.d.ts +84 -0
  278. package/dist/security/comprehensive-security-research.d.ts.map +1 -0
  279. package/dist/security/comprehensive-security-research.js +211 -0
  280. package/dist/security/comprehensive-security-research.js.map +1 -0
  281. package/dist/security/comprehensive-targeting.d.ts +85 -0
  282. package/dist/security/comprehensive-targeting.d.ts.map +1 -0
  283. package/dist/security/comprehensive-targeting.js +438 -0
  284. package/dist/security/comprehensive-targeting.js.map +1 -0
  285. package/dist/security/global-security-integration.d.ts +91 -0
  286. package/dist/security/global-security-integration.d.ts.map +1 -0
  287. package/dist/security/global-security-integration.js +218 -0
  288. package/dist/security/global-security-integration.js.map +1 -0
  289. package/dist/security/index.d.ts +38 -0
  290. package/dist/security/index.d.ts.map +1 -0
  291. package/dist/security/index.js +47 -0
  292. package/dist/security/index.js.map +1 -0
  293. package/dist/security/offensive/exploitationEngine.d.ts +54 -0
  294. package/dist/security/offensive/exploitationEngine.d.ts.map +1 -0
  295. package/dist/security/offensive/exploitationEngine.js +263 -0
  296. package/dist/security/offensive/exploitationEngine.js.map +1 -0
  297. package/dist/security/persistence-cli.d.ts +36 -0
  298. package/dist/security/persistence-cli.d.ts.map +1 -0
  299. package/dist/security/persistence-cli.js +160 -0
  300. package/dist/security/persistence-cli.js.map +1 -0
  301. package/dist/security/persistence-research.d.ts +11 -0
  302. package/dist/security/persistence-research.d.ts.map +1 -1
  303. package/dist/security/persistence-research.js +11 -0
  304. package/dist/security/persistence-research.js.map +1 -1
  305. package/dist/security/real/networkExploitation.d.ts +92 -0
  306. package/dist/security/real/networkExploitation.d.ts.map +1 -0
  307. package/dist/security/real/networkExploitation.js +316 -0
  308. package/dist/security/real/networkExploitation.js.map +1 -0
  309. package/dist/security/real/persistenceImplementation.d.ts +62 -0
  310. package/dist/security/real/persistenceImplementation.d.ts.map +1 -0
  311. package/dist/security/real/persistenceImplementation.js +323 -0
  312. package/dist/security/real/persistenceImplementation.js.map +1 -0
  313. package/dist/security/real/vulnerabilityScanner.d.ts +73 -0
  314. package/dist/security/real/vulnerabilityScanner.d.ts.map +1 -0
  315. package/dist/security/real/vulnerabilityScanner.js +341 -0
  316. package/dist/security/real/vulnerabilityScanner.js.map +1 -0
  317. package/dist/security/research/persistenceResearch.d.ts +97 -0
  318. package/dist/security/research/persistenceResearch.d.ts.map +1 -0
  319. package/dist/security/research/persistenceResearch.js +282 -0
  320. package/dist/security/research/persistenceResearch.js.map +1 -0
  321. package/dist/security/security-integration.d.ts +74 -0
  322. package/dist/security/security-integration.d.ts.map +1 -0
  323. package/dist/security/security-integration.js +137 -0
  324. package/dist/security/security-integration.js.map +1 -0
  325. package/dist/security/security-testing-framework.d.ts +120 -0
  326. package/dist/security/security-testing-framework.d.ts.map +1 -0
  327. package/dist/security/security-testing-framework.js +372 -0
  328. package/dist/security/security-testing-framework.js.map +1 -0
  329. package/dist/security/simulation/attackSimulation.d.ts +93 -0
  330. package/dist/security/simulation/attackSimulation.d.ts.map +1 -0
  331. package/dist/security/simulation/attackSimulation.js +341 -0
  332. package/dist/security/simulation/attackSimulation.js.map +1 -0
  333. package/dist/security/strategic-operations.d.ts +100 -0
  334. package/dist/security/strategic-operations.d.ts.map +1 -0
  335. package/dist/security/strategic-operations.js +276 -0
  336. package/dist/security/strategic-operations.js.map +1 -0
  337. package/dist/security/tool-security-wrapper.d.ts +58 -0
  338. package/dist/security/tool-security-wrapper.d.ts.map +1 -0
  339. package/dist/security/tool-security-wrapper.js +156 -0
  340. package/dist/security/tool-security-wrapper.js.map +1 -0
  341. package/dist/shell/bracketedPasteManager.d.ts +33 -0
  342. package/dist/shell/bracketedPasteManager.d.ts.map +1 -1
  343. package/dist/shell/bracketedPasteManager.js +101 -0
  344. package/dist/shell/bracketedPasteManager.js.map +1 -1
  345. package/dist/shell/interactiveShell.d.ts +22 -1
  346. package/dist/shell/interactiveShell.d.ts.map +1 -1
  347. package/dist/shell/interactiveShell.js +257 -24
  348. package/dist/shell/interactiveShell.js.map +1 -1
  349. package/dist/shell/taskCompletionDetector.d.ts +101 -0
  350. package/dist/shell/taskCompletionDetector.d.ts.map +1 -0
  351. package/dist/shell/taskCompletionDetector.js +343 -0
  352. package/dist/shell/taskCompletionDetector.js.map +1 -0
  353. package/dist/tools/cloudTools.d.ts +11 -0
  354. package/dist/tools/cloudTools.d.ts.map +1 -1
  355. package/dist/tools/cloudTools.js +11 -0
  356. package/dist/tools/cloudTools.js.map +1 -1
  357. package/dist/tools/codeAnalysisTools.d.ts.map +1 -1
  358. package/dist/tools/codeAnalysisTools.js +23 -1
  359. package/dist/tools/codeAnalysisTools.js.map +1 -1
  360. package/dist/tools/enhancedSecurityTools.d.ts +19 -0
  361. package/dist/tools/enhancedSecurityTools.d.ts.map +1 -0
  362. package/dist/tools/enhancedSecurityTools.js +215 -0
  363. package/dist/tools/enhancedSecurityTools.js.map +1 -0
  364. package/dist/tools/fileTools.d.ts.map +1 -1
  365. package/dist/tools/fileTools.js +7 -0
  366. package/dist/tools/fileTools.js.map +1 -1
  367. package/dist/tools/grepTools.d.ts.map +1 -1
  368. package/dist/tools/grepTools.js +6 -0
  369. package/dist/tools/grepTools.js.map +1 -1
  370. package/dist/tools/offensiveSecurityTools.d.ts +16 -0
  371. package/dist/tools/offensiveSecurityTools.d.ts.map +1 -0
  372. package/dist/tools/offensiveSecurityTools.js +285 -0
  373. package/dist/tools/offensiveSecurityTools.js.map +1 -0
  374. package/dist/tools/realSecurityTools.d.ts +18 -0
  375. package/dist/tools/realSecurityTools.d.ts.map +1 -0
  376. package/dist/tools/realSecurityTools.js +468 -0
  377. package/dist/tools/realSecurityTools.js.map +1 -0
  378. package/dist/tools/securityTools.d.ts +20 -0
  379. package/dist/tools/securityTools.d.ts.map +1 -0
  380. package/dist/tools/securityTools.js +449 -0
  381. package/dist/tools/securityTools.js.map +1 -0
  382. package/dist/tools/webTools.js +9 -0
  383. package/dist/tools/webTools.js.map +1 -1
  384. package/package.json +26 -11
  385. package/scripts/deploy-security-capabilities.js +178 -0
@@ -0,0 +1,172 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { readFileSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import readline from 'node:readline';
6
+ import { exit, stdin, stdout } from 'node:process';
7
+ import { hasAgentProfile, listAgentProfiles } from '../core/agentProfiles.js';
8
+ import { createAgentController } from '../runtime/agentController.js';
9
+ import { resolveWorkspaceCaptureOptions, buildWorkspaceContext } from '../workspace.js';
10
+ export async function runHeadlessApp(options) {
11
+ const parsed = parseHeadlessArgs(options.argv);
12
+ const profile = resolveProfile(parsed.profile);
13
+ const sessionId = parsed.sessionId ?? randomUUID();
14
+ const workingDir = process.cwd();
15
+ const workspaceOptions = resolveWorkspaceCaptureOptions(process.env);
16
+ const workspaceContext = buildWorkspaceContext(workingDir, workspaceOptions);
17
+ const controller = await createAgentController({
18
+ profile,
19
+ workingDir,
20
+ workspaceContext,
21
+ env: process.env,
22
+ });
23
+ const manifest = controller.getCapabilities();
24
+ emitEvent({
25
+ type: 'session',
26
+ sessionId,
27
+ profile,
28
+ manifest,
29
+ workingDir,
30
+ workspaceContext,
31
+ version: readPackageVersion(),
32
+ });
33
+ const queue = [];
34
+ let processing = false;
35
+ let stdinClosed = !parsed.watchStdIn;
36
+ const enqueuePrompt = (prompt) => {
37
+ const content = prompt.trim();
38
+ if (!content) {
39
+ return;
40
+ }
41
+ queue.push({ id: randomUUID(), prompt: content });
42
+ void processQueue();
43
+ };
44
+ const processQueue = async () => {
45
+ if (processing) {
46
+ return;
47
+ }
48
+ processing = true;
49
+ while (queue.length) {
50
+ const next = queue.shift();
51
+ await handlePrompt(next).catch((error) => {
52
+ emitEvent({
53
+ type: 'error',
54
+ sessionId,
55
+ profile,
56
+ runId: next.id,
57
+ message: error instanceof Error ? error.message : String(error),
58
+ });
59
+ });
60
+ }
61
+ processing = false;
62
+ if (stdinClosed) {
63
+ exit(0);
64
+ }
65
+ };
66
+ const handlePrompt = async (work) => {
67
+ emitEvent({ type: 'user-input', sessionId, profile, runId: work.id, content: work.prompt });
68
+ for await (const event of controller.send(work.prompt)) {
69
+ emitEvent({ type: 'agent-event', sessionId, profile, runId: work.id, event });
70
+ }
71
+ emitEvent({ type: 'run-complete', sessionId, profile, runId: work.id });
72
+ };
73
+ if (parsed.initialPrompt) {
74
+ enqueuePrompt(parsed.initialPrompt);
75
+ }
76
+ if (parsed.watchStdIn) {
77
+ const rl = readline.createInterface({ input: stdin, terminal: false });
78
+ rl.on('line', (line) => {
79
+ enqueuePrompt(line);
80
+ });
81
+ rl.on('close', () => {
82
+ stdinClosed = true;
83
+ if (!processing) {
84
+ exit(0);
85
+ }
86
+ });
87
+ // Keep stdin open to receive input
88
+ stdin.resume();
89
+ }
90
+ else if (!parsed.initialPrompt) {
91
+ // Nothing to do in headless mode without stdin or an initial prompt
92
+ emitEvent({
93
+ type: 'error',
94
+ sessionId,
95
+ profile,
96
+ message: 'Headless mode requires stdin or a prompt argument.',
97
+ });
98
+ exit(1);
99
+ }
100
+ // Note: stdin.resume() is now only called when watchStdIn is true
101
+ }
102
+ function parseHeadlessArgs(argv) {
103
+ let profile;
104
+ let sessionId;
105
+ let watchStdIn = true;
106
+ const promptTokens = [];
107
+ for (let index = 0; index < argv.length; index += 1) {
108
+ const token = argv[index];
109
+ if (!token) {
110
+ continue;
111
+ }
112
+ if (token === '--json') {
113
+ continue;
114
+ }
115
+ if (token === '--profile' || token === '-p') {
116
+ profile = argv[index + 1];
117
+ index += 1;
118
+ continue;
119
+ }
120
+ if (token.startsWith('--profile=')) {
121
+ profile = token.slice('--profile='.length);
122
+ continue;
123
+ }
124
+ if (token === '--session-id') {
125
+ sessionId = argv[index + 1];
126
+ index += 1;
127
+ continue;
128
+ }
129
+ if (token.startsWith('--session-id=')) {
130
+ sessionId = token.slice('--session-id='.length);
131
+ continue;
132
+ }
133
+ if (token === '--no-stdin') {
134
+ watchStdIn = false;
135
+ continue;
136
+ }
137
+ promptTokens.push(token);
138
+ }
139
+ return {
140
+ profile,
141
+ sessionId,
142
+ watchStdIn,
143
+ initialPrompt: promptTokens.length ? promptTokens.join(' ').trim() : null,
144
+ };
145
+ }
146
+ function resolveProfile(candidate) {
147
+ const envOverride = process.env['EROSOLAR_PROFILE']?.trim();
148
+ const desired = candidate?.trim() || envOverride || 'erosolar-code';
149
+ if (hasAgentProfile(desired)) {
150
+ return desired;
151
+ }
152
+ const lower = desired.toLowerCase();
153
+ const match = listAgentProfiles().find((entry) => entry.name.toLowerCase() === lower);
154
+ if (match) {
155
+ return match.name;
156
+ }
157
+ throw new Error(`Unknown profile "${candidate ?? desired}".`);
158
+ }
159
+ function emitEvent(event) {
160
+ stdout.write(`${JSON.stringify(event)}\n`);
161
+ }
162
+ function readPackageVersion() {
163
+ try {
164
+ const filePath = fileURLToPath(import.meta.url);
165
+ const packagePath = resolve(dirname(filePath), '../../package.json');
166
+ const payload = JSON.parse(readFileSync(packagePath, 'utf8'));
167
+ return typeof payload.version === 'string' ? payload.version : '0.0.0';
168
+ }
169
+ catch {
170
+ return '0.0.0';
171
+ }
172
+ }
@@ -0,0 +1,202 @@
1
+ import { readFile, readdir, stat } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import { join, resolve } from 'node:path';
4
+ const DEFAULT_FILES = ['.mcp.json', join('.erosolar', 'mcp.json')];
5
+ const DEFAULT_DIRECTORIES = [join('.erosolar', 'mcp.d')];
6
+ export async function loadMcpServers(options) {
7
+ const candidates = await discoverConfigFiles(options);
8
+ if (!candidates.length) {
9
+ return [];
10
+ }
11
+ const normalized = new Map();
12
+ for (const file of candidates) {
13
+ try {
14
+ const definitions = await parseConfigFile(file);
15
+ for (const definition of definitions) {
16
+ if (definition.disabled) {
17
+ normalized.delete(definition.id ?? '');
18
+ continue;
19
+ }
20
+ const entry = normalizeServerDefinition(definition, file, options);
21
+ if (entry) {
22
+ normalized.set(entry.id, entry);
23
+ }
24
+ }
25
+ }
26
+ catch {
27
+ // Ignore malformed files but continue loading others.
28
+ }
29
+ }
30
+ return Array.from(normalized.values());
31
+ }
32
+ async function discoverConfigFiles(options) {
33
+ const files = new Set();
34
+ const home = homedir();
35
+ const envOverride = options.env['EROSOLAR_MCP_CONFIG'];
36
+ if (envOverride) {
37
+ for (const path of envOverride.split(/[:,;]/)) {
38
+ const trimmed = path.trim();
39
+ if (trimmed) {
40
+ files.add(resolve(trimmed));
41
+ }
42
+ }
43
+ }
44
+ const searchRoots = [options.workingDir, home];
45
+ for (const root of searchRoots) {
46
+ for (const name of DEFAULT_FILES) {
47
+ const candidate = resolve(root, name);
48
+ if (await fileExists(candidate)) {
49
+ files.add(candidate);
50
+ }
51
+ }
52
+ for (const dirName of DEFAULT_DIRECTORIES) {
53
+ const directory = resolve(root, dirName);
54
+ const entries = await readDirectoryJsonFiles(directory);
55
+ for (const entry of entries) {
56
+ files.add(entry);
57
+ }
58
+ }
59
+ }
60
+ return Array.from(files);
61
+ }
62
+ async function readDirectoryJsonFiles(directory) {
63
+ try {
64
+ const stats = await stat(directory);
65
+ if (!stats.isDirectory()) {
66
+ return [];
67
+ }
68
+ const entries = await readdir(directory);
69
+ return entries
70
+ .filter((name) => name.endsWith('.json'))
71
+ .map((name) => resolve(directory, name));
72
+ }
73
+ catch {
74
+ return [];
75
+ }
76
+ }
77
+ async function parseConfigFile(path) {
78
+ const content = await readFile(path, 'utf8');
79
+ const trimmed = content.trim();
80
+ if (!trimmed) {
81
+ return [];
82
+ }
83
+ const parsed = JSON.parse(trimmed);
84
+ if (Array.isArray(parsed)) {
85
+ return parsed.filter((entry) => Boolean(entry && typeof entry === 'object'));
86
+ }
87
+ if (parsed && typeof parsed === 'object') {
88
+ const result = [];
89
+ for (const [id, value] of Object.entries(parsed)) {
90
+ if (value && typeof value === 'object') {
91
+ result.push({ ...value, id });
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ return [];
97
+ }
98
+ function normalizeServerDefinition(raw, source, options) {
99
+ const type = normalizeTransport(raw.type);
100
+ if (!type) {
101
+ return null;
102
+ }
103
+ const id = sanitizeId(raw.id ?? '');
104
+ if (!id) {
105
+ return null;
106
+ }
107
+ if (type === 'stdio') {
108
+ const command = expandTemplate(raw.command ?? '', options, source);
109
+ if (!command) {
110
+ return null;
111
+ }
112
+ const args = Array.isArray(raw.args)
113
+ ? raw.args.map((value) => expandTemplate(String(value ?? ''), options, source)).filter(Boolean)
114
+ : [];
115
+ const env = normalizeEnv(raw.env, options, source);
116
+ const cwd = raw.cwd ? expandTemplate(raw.cwd, options, source) : undefined;
117
+ return {
118
+ id,
119
+ type,
120
+ command,
121
+ args,
122
+ cwd,
123
+ env,
124
+ description: raw.description,
125
+ source,
126
+ };
127
+ }
128
+ return null;
129
+ }
130
+ function normalizeTransport(value) {
131
+ if (!value) {
132
+ return 'stdio';
133
+ }
134
+ const normalized = value.trim().toLowerCase();
135
+ if (normalized === 'stdio') {
136
+ return 'stdio';
137
+ }
138
+ return null;
139
+ }
140
+ function normalizeEnv(env, options, source) {
141
+ if (!env) {
142
+ return {};
143
+ }
144
+ const record = {};
145
+ for (const [key, value] of Object.entries(env)) {
146
+ if (typeof value !== 'string') {
147
+ continue;
148
+ }
149
+ const expanded = expandTemplate(value, options, source);
150
+ if (expanded) {
151
+ record[key] = expanded;
152
+ }
153
+ }
154
+ return record;
155
+ }
156
+ function expandTemplate(value, options, file) {
157
+ if (!value) {
158
+ return '';
159
+ }
160
+ const workspace = resolve(options.workingDir);
161
+ const erosolarHome = join(homedir(), '.erosolar');
162
+ const replacements = {
163
+ WORKSPACE_ROOT: workspace,
164
+ PROJECT_DIR: workspace,
165
+ CLAUDE_PROJECT_DIR: workspace,
166
+ EROSOLAR_HOME: erosolarHome,
167
+ HOME: homedir(),
168
+ MCP_CONFIG_DIR: resolve(file, '..'),
169
+ };
170
+ return value.replace(/\$\{([^}]+)\}/g, (_match, token) => {
171
+ const key = token.trim();
172
+ if (Object.prototype.hasOwnProperty.call(replacements, key)) {
173
+ const replacementKey = key;
174
+ return replacements[replacementKey];
175
+ }
176
+ const envValue = options.env[key];
177
+ if (typeof envValue === 'string' && envValue.trim()) {
178
+ return envValue.trim();
179
+ }
180
+ if (typeof process.env[key] === 'string' && process.env[key].trim()) {
181
+ return process.env[key].trim();
182
+ }
183
+ return '';
184
+ });
185
+ }
186
+ async function fileExists(path) {
187
+ try {
188
+ const stats = await stat(path);
189
+ return stats.isFile();
190
+ }
191
+ catch {
192
+ return false;
193
+ }
194
+ }
195
+ function sanitizeId(value) {
196
+ return value
197
+ .trim()
198
+ .replace(/[^a-zA-Z0-9_-]/g, '-')
199
+ .replace(/-+/g, '-')
200
+ .replace(/^-+|-+$/g, '')
201
+ .toLowerCase();
202
+ }
@@ -0,0 +1,172 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { once } from 'node:events';
3
+ export class McpStdioClient {
4
+ constructor(config, workingDir) {
5
+ this.pending = new Map();
6
+ this.buffer = Buffer.alloc(0);
7
+ this.nextId = 1;
8
+ this.disposed = false;
9
+ this.stderrLog = [];
10
+ this.id = config.id;
11
+ this.description = config.description;
12
+ this.process = spawn(config.command, config.args, {
13
+ cwd: config.cwd ?? workingDir,
14
+ env: { ...process.env, ...config.env },
15
+ stdio: ['pipe', 'pipe', 'pipe'],
16
+ });
17
+ this.process.stdout.on('data', (chunk) => this.handleStdout(chunk));
18
+ this.process.stderr.on('data', (chunk) => this.handleStderr(chunk));
19
+ this.process.on('exit', (code, signal) => {
20
+ if (!this.disposed) {
21
+ const message = signal
22
+ ? `MCP server "${this.id}" exited via signal ${signal}.`
23
+ : `MCP server "${this.id}" exited with code ${code}.`;
24
+ this.rejectAll(new Error(message));
25
+ }
26
+ });
27
+ this.ready = this.initialize();
28
+ }
29
+ async listTools() {
30
+ await this.ready;
31
+ const response = (await this.sendRequest('tools/list', {}));
32
+ return response?.tools ?? [];
33
+ }
34
+ async callTool(toolName, args) {
35
+ await this.ready;
36
+ const response = (await this.sendRequest('tools/call', {
37
+ name: toolName,
38
+ arguments: args ?? {},
39
+ }));
40
+ return response;
41
+ }
42
+ async dispose() {
43
+ if (this.disposed) {
44
+ return;
45
+ }
46
+ this.disposed = true;
47
+ this.rejectAll(new Error(`MCP server "${this.id}" disposed.`));
48
+ this.process.kill();
49
+ await once(this.process, 'close').catch(() => { });
50
+ }
51
+ async initialize() {
52
+ await this.sendRequest('initialize', {
53
+ protocolVersion: '2024-11-05',
54
+ capabilities: {
55
+ tools: {
56
+ listChanged: true,
57
+ },
58
+ },
59
+ clientInfo: {
60
+ name: 'Erosolar CLI',
61
+ version: process.env['EROSOLAR_VERSION'] ?? 'dev',
62
+ },
63
+ });
64
+ await this.sendNotification('notifications/initialized', {});
65
+ }
66
+ async sendRequest(method, params) {
67
+ if (this.disposed) {
68
+ throw new Error(`MCP server "${this.id}" is not running.`);
69
+ }
70
+ const id = this.nextId++;
71
+ const payload = {
72
+ jsonrpc: '2.0',
73
+ id,
74
+ method,
75
+ params,
76
+ };
77
+ const serialized = JSON.stringify(payload);
78
+ this.process.stdin.write(`Content-Length: ${Buffer.byteLength(serialized, 'utf8')}\r\n\r\n${serialized}`);
79
+ return await new Promise((resolve, reject) => {
80
+ const timer = setTimeout(() => {
81
+ if (this.pending.has(id)) {
82
+ this.pending.delete(id);
83
+ reject(new Error(`Timed out waiting for "${method}" from MCP server "${this.id}".`));
84
+ }
85
+ }, 60000);
86
+ this.pending.set(id, { resolve, reject, method, timer });
87
+ });
88
+ }
89
+ async sendNotification(method, params) {
90
+ if (this.disposed) {
91
+ return;
92
+ }
93
+ const payload = {
94
+ jsonrpc: '2.0',
95
+ method,
96
+ params,
97
+ };
98
+ const serialized = JSON.stringify(payload);
99
+ this.process.stdin.write(`Content-Length: ${Buffer.byteLength(serialized, 'utf8')}\r\n\r\n${serialized}`);
100
+ }
101
+ handleStdout(chunk) {
102
+ this.buffer = Buffer.concat([this.buffer, chunk]);
103
+ while (true) {
104
+ let headerIndex = this.buffer.indexOf('\r\n\r\n');
105
+ let delimiterLength = 4;
106
+ if (headerIndex === -1) {
107
+ headerIndex = this.buffer.indexOf('\n\n');
108
+ delimiterLength = 2;
109
+ }
110
+ if (headerIndex === -1) {
111
+ break;
112
+ }
113
+ const header = this.buffer.slice(0, headerIndex).toString('utf8');
114
+ const lengthMatch = header.match(/Content-Length:\s*(\d+)/i);
115
+ if (!lengthMatch) {
116
+ this.buffer = this.buffer.slice(headerIndex + 4);
117
+ continue;
118
+ }
119
+ const bodyLength = Number(lengthMatch[1]);
120
+ const totalLength = headerIndex + delimiterLength + bodyLength;
121
+ if (this.buffer.length < totalLength) {
122
+ break;
123
+ }
124
+ const body = this.buffer.slice(headerIndex + delimiterLength, totalLength).toString('utf8');
125
+ this.buffer = this.buffer.slice(totalLength);
126
+ this.handleMessage(body);
127
+ }
128
+ }
129
+ handleStderr(chunk) {
130
+ const text = chunk.toString('utf8').trim();
131
+ if (!text) {
132
+ return;
133
+ }
134
+ this.stderrLog.push(text);
135
+ if (this.stderrLog.length > 5) {
136
+ this.stderrLog.shift();
137
+ }
138
+ }
139
+ handleMessage(payload) {
140
+ try {
141
+ const message = JSON.parse(payload);
142
+ if (typeof message.id === 'number' && this.pending.has(message.id)) {
143
+ const pending = this.pending.get(message.id);
144
+ this.pending.delete(message.id);
145
+ clearTimeout(pending.timer);
146
+ if (message.error) {
147
+ const errorMessage = message.error.message || `MCP server "${this.id}" returned an error.`;
148
+ const details = this.stderrLog.length ? `\n${this.stderrLog.join('\n')}` : '';
149
+ pending.reject(new Error(`${errorMessage}${details}`));
150
+ }
151
+ else {
152
+ pending.resolve(message.result);
153
+ }
154
+ return;
155
+ }
156
+ if (message.method === 'notifications/tools/list_changed') {
157
+ // Tool list changed notification; callers can refresh by calling listTools again.
158
+ return;
159
+ }
160
+ }
161
+ catch {
162
+ // Ignore malformed messages.
163
+ }
164
+ }
165
+ rejectAll(error) {
166
+ for (const pending of this.pending.values()) {
167
+ clearTimeout(pending.timer);
168
+ pending.reject(error);
169
+ }
170
+ this.pending.clear();
171
+ }
172
+ }
@@ -0,0 +1,104 @@
1
+ import { loadMcpServers } from './config.js';
2
+ import { McpStdioClient } from './stdioClient.js';
3
+ export class McpToolBridge {
4
+ constructor(context) {
5
+ this.servers = [];
6
+ this.context = context;
7
+ }
8
+ async initialize() {
9
+ const configs = await loadMcpServers({
10
+ workingDir: this.context.workingDir,
11
+ env: this.context.env,
12
+ });
13
+ if (!configs.length) {
14
+ return [];
15
+ }
16
+ const suites = [];
17
+ for (const config of configs) {
18
+ try {
19
+ const client = new McpStdioClient(config, this.context.workingDir);
20
+ const tools = await client.listTools();
21
+ if (!tools.length) {
22
+ await client.dispose();
23
+ continue;
24
+ }
25
+ this.servers.push({ config, client, tools });
26
+ suites.push({
27
+ id: `mcp.${config.id}`,
28
+ description: `MCP server at ${config.description ?? config.command}`,
29
+ tools: tools.map((tool) => this.buildToolDefinition(config.id, client, tool)),
30
+ });
31
+ }
32
+ catch (error) {
33
+ // eslint-disable-next-line no-console
34
+ console.warn(`Failed to load MCP server "${config.id}" (${config.source}): ${error instanceof Error ? error.message : String(error)}`);
35
+ }
36
+ }
37
+ return suites;
38
+ }
39
+ async dispose() {
40
+ await Promise.allSettled(this.servers.map((entry) => entry.client.dispose()));
41
+ this.servers = [];
42
+ }
43
+ buildToolDefinition(serverId, client, tool) {
44
+ const name = buildToolName(serverId, tool.name);
45
+ const description = tool.description
46
+ ? `[${serverId}] ${tool.description}`
47
+ : `MCP tool "${tool.name}" from ${serverId}`;
48
+ return {
49
+ name,
50
+ description,
51
+ parameters: normalizeSchema(tool.inputSchema),
52
+ handler: async (args) => {
53
+ const response = await client.callTool(tool.name, args);
54
+ return formatToolResponse(response);
55
+ },
56
+ };
57
+ }
58
+ }
59
+ function buildToolName(serverId, toolName) {
60
+ const safeServer = serverId.replace(/[^a-z0-9_-]/gi, '_');
61
+ const safeTool = toolName.replace(/[^a-z0-9_-]/gi, '_');
62
+ return `mcp__${safeServer}__${safeTool}`;
63
+ }
64
+ function normalizeSchema(schema) {
65
+ if (schema && typeof schema === 'object') {
66
+ return schema;
67
+ }
68
+ return {
69
+ type: 'object',
70
+ additionalProperties: true,
71
+ properties: {},
72
+ };
73
+ }
74
+ function formatToolResponse(result) {
75
+ const blocks = Array.isArray(result?.content) ? result.content : [];
76
+ if (!blocks.length) {
77
+ return 'MCP tool completed without returning content.';
78
+ }
79
+ return blocks.map(formatContentBlock).join('\n\n');
80
+ }
81
+ function formatContentBlock(block) {
82
+ switch (block.type) {
83
+ case 'text':
84
+ return getStringField(block, 'text') ?? '';
85
+ case 'markdown':
86
+ return getStringField(block, 'markdown') ?? '';
87
+ case 'json': {
88
+ const jsonValue = block['json'];
89
+ return jsonValue !== undefined ? JSON.stringify(jsonValue, null, 2) : '';
90
+ }
91
+ case 'resource': {
92
+ const uri = getStringField(block, 'uri') ?? '(unknown uri)';
93
+ const description = getStringField(block, 'description');
94
+ return `Resource: ${uri}${description ? `\n${description}` : ''}`;
95
+ }
96
+ default:
97
+ return JSON.stringify(block, null, 2);
98
+ }
99
+ }
100
+ function getStringField(block, key) {
101
+ const record = block;
102
+ const value = record[key];
103
+ return typeof value === 'string' ? value : null;
104
+ }
@@ -0,0 +1 @@
1
+ export {};