erosolar-cli 2.1.249 → 2.1.253

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 (470) hide show
  1. package/agents/general.rules.json +10 -133
  2. package/agents/general.rules.json.bak +278 -0
  3. package/agents/general.rules.json.bak2 +306 -0
  4. package/dist/bin/erosolar.js +9 -5
  5. package/dist/bin/erosolar.js.map +1 -1
  6. package/dist/capabilities/bidirectionalAuditCapability.d.ts +26 -0
  7. package/dist/capabilities/bidirectionalAuditCapability.d.ts.map +1 -0
  8. package/dist/capabilities/bidirectionalAuditCapability.js +44 -0
  9. package/dist/capabilities/bidirectionalAuditCapability.js.map +1 -0
  10. package/dist/capabilities/globCapability.d.ts +3 -6
  11. package/dist/capabilities/globCapability.d.ts.map +1 -1
  12. package/dist/capabilities/globCapability.js +6 -10
  13. package/dist/capabilities/globCapability.js.map +1 -1
  14. package/dist/capabilities/index.d.ts +1 -18
  15. package/dist/capabilities/index.d.ts.map +1 -1
  16. package/dist/capabilities/index.js +1 -18
  17. package/dist/capabilities/index.js.map +1 -1
  18. package/dist/capabilities/orchestrationCapability.d.ts +2 -0
  19. package/dist/capabilities/orchestrationCapability.d.ts.map +1 -1
  20. package/dist/capabilities/orchestrationCapability.js +980 -2
  21. package/dist/capabilities/orchestrationCapability.js.map +1 -1
  22. package/dist/capabilities/searchCapability.d.ts +8 -2
  23. package/dist/capabilities/searchCapability.d.ts.map +1 -1
  24. package/dist/capabilities/searchCapability.js +11 -6
  25. package/dist/capabilities/searchCapability.js.map +1 -1
  26. package/dist/contracts/tools.schema.json +9 -133
  27. package/dist/core/aiErrorFixer.d.ts +1 -14
  28. package/dist/core/aiErrorFixer.d.ts.map +1 -1
  29. package/dist/core/aiErrorFixer.js +51 -239
  30. package/dist/core/aiErrorFixer.js.map +1 -1
  31. package/dist/core/alphaZeroEngine.d.ts +16 -256
  32. package/dist/core/alphaZeroEngine.d.ts.map +1 -1
  33. package/dist/core/alphaZeroEngine.js +22 -513
  34. package/dist/core/alphaZeroEngine.js.map +1 -1
  35. package/dist/core/completeAttackOrchestrator.d.ts +102 -0
  36. package/dist/core/completeAttackOrchestrator.d.ts.map +1 -0
  37. package/dist/core/completeAttackOrchestrator.js +293 -0
  38. package/dist/core/completeAttackOrchestrator.js.map +1 -0
  39. package/dist/core/defensiveSecurityToolkit.d.ts +373 -0
  40. package/dist/core/defensiveSecurityToolkit.d.ts.map +1 -0
  41. package/dist/core/defensiveSecurityToolkit.js +1304 -0
  42. package/dist/core/defensiveSecurityToolkit.js.map +1 -0
  43. package/dist/core/errors/errorTypes.d.ts +30 -57
  44. package/dist/core/errors/errorTypes.d.ts.map +1 -1
  45. package/dist/core/errors/errorTypes.js +51 -228
  46. package/dist/core/errors/errorTypes.js.map +1 -1
  47. package/dist/core/errors/safetyValidator.d.ts +19 -3
  48. package/dist/core/errors/safetyValidator.d.ts.map +1 -1
  49. package/dist/core/errors/safetyValidator.js +33 -71
  50. package/dist/core/errors/safetyValidator.js.map +1 -1
  51. package/dist/core/failureRecovery.d.ts +4 -100
  52. package/dist/core/failureRecovery.d.ts.map +1 -1
  53. package/dist/core/failureRecovery.js +16 -440
  54. package/dist/core/failureRecovery.js.map +1 -1
  55. package/dist/core/intelligentTargetResearcher.d.ts +142 -0
  56. package/dist/core/intelligentTargetResearcher.d.ts.map +1 -0
  57. package/dist/core/intelligentTargetResearcher.js +367 -0
  58. package/dist/core/intelligentTargetResearcher.js.map +1 -0
  59. package/dist/core/intelligentTestFlows.d.ts +26 -107
  60. package/dist/core/intelligentTestFlows.d.ts.map +1 -1
  61. package/dist/core/intelligentTestFlows.js +15 -659
  62. package/dist/core/intelligentTestFlows.js.map +1 -1
  63. package/dist/core/learningPersistence.d.ts +45 -132
  64. package/dist/core/learningPersistence.d.ts.map +1 -1
  65. package/dist/core/learningPersistence.js +32 -463
  66. package/dist/core/learningPersistence.js.map +1 -1
  67. package/dist/core/metricsTracker.d.ts +22 -139
  68. package/dist/core/metricsTracker.d.ts.map +1 -1
  69. package/dist/core/metricsTracker.js +51 -241
  70. package/dist/core/metricsTracker.js.map +1 -1
  71. package/dist/core/performanceMonitor.d.ts +15 -109
  72. package/dist/core/performanceMonitor.d.ts.map +1 -1
  73. package/dist/core/performanceMonitor.js +27 -184
  74. package/dist/core/performanceMonitor.js.map +1 -1
  75. package/dist/core/reliabilityPrompt.d.ts.map +1 -1
  76. package/dist/core/reliabilityPrompt.js +14 -0
  77. package/dist/core/reliabilityPrompt.js.map +1 -1
  78. package/dist/core/resultVerification.d.ts +6 -100
  79. package/dist/core/resultVerification.d.ts.map +1 -1
  80. package/dist/core/resultVerification.js +31 -400
  81. package/dist/core/resultVerification.js.map +1 -1
  82. package/dist/core/selfEvolution.d.ts +32 -126
  83. package/dist/core/selfEvolution.d.ts.map +1 -1
  84. package/dist/core/selfEvolution.js +24 -967
  85. package/dist/core/selfEvolution.js.map +1 -1
  86. package/dist/core/selfImprovement.d.ts +50 -109
  87. package/dist/core/selfImprovement.d.ts.map +1 -1
  88. package/dist/core/selfImprovement.js +14 -689
  89. package/dist/core/selfImprovement.js.map +1 -1
  90. package/dist/core/sourceCodeManager.d.ts +89 -0
  91. package/dist/core/sourceCodeManager.d.ts.map +1 -0
  92. package/dist/core/sourceCodeManager.js +332 -0
  93. package/dist/core/sourceCodeManager.js.map +1 -0
  94. package/dist/core/unifiedOrchestrator.d.ts +88 -0
  95. package/dist/core/unifiedOrchestrator.d.ts.map +1 -0
  96. package/dist/core/unifiedOrchestrator.js +284 -0
  97. package/dist/core/unifiedOrchestrator.js.map +1 -0
  98. package/dist/core/userDefenseOrchestrator.d.ts +202 -0
  99. package/dist/core/userDefenseOrchestrator.d.ts.map +1 -0
  100. package/dist/core/userDefenseOrchestrator.js +1006 -0
  101. package/dist/core/userDefenseOrchestrator.js.map +1 -0
  102. package/dist/plugins/index.d.ts +1 -1
  103. package/dist/plugins/index.d.ts.map +1 -1
  104. package/dist/plugins/index.js +36 -26
  105. package/dist/plugins/index.js.map +1 -1
  106. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.d.ts +8 -0
  107. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.d.ts.map +1 -0
  108. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.js +17 -0
  109. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.js.map +1 -0
  110. package/dist/plugins/tools/nodeDefaults.d.ts +14 -0
  111. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  112. package/dist/plugins/tools/nodeDefaults.js +17 -54
  113. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  114. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts +9 -0
  115. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts.map +1 -0
  116. package/dist/plugins/tools/orchestration/orchestrationPlugin.js +18 -0
  117. package/dist/plugins/tools/orchestration/orchestrationPlugin.js.map +1 -0
  118. package/dist/shell/interactiveShell.d.ts +97 -2
  119. package/dist/shell/interactiveShell.d.ts.map +1 -1
  120. package/dist/shell/interactiveShell.js +1001 -6
  121. package/dist/shell/interactiveShell.js.map +1 -1
  122. package/dist/tools/appleExposureTools.d.ts +108 -0
  123. package/dist/tools/appleExposureTools.d.ts.map +1 -0
  124. package/dist/tools/appleExposureTools.js +850 -0
  125. package/dist/tools/appleExposureTools.js.map +1 -0
  126. package/dist/tools/bidirectionalAuditTools.d.ts +104 -0
  127. package/dist/tools/bidirectionalAuditTools.d.ts.map +1 -0
  128. package/dist/tools/bidirectionalAuditTools.js +1280 -0
  129. package/dist/tools/bidirectionalAuditTools.js.map +1 -0
  130. package/dist/tools/defensiveSecurityTools.d.ts +152 -0
  131. package/dist/tools/defensiveSecurityTools.d.ts.map +1 -0
  132. package/dist/tools/defensiveSecurityTools.js +576 -0
  133. package/dist/tools/defensiveSecurityTools.js.map +1 -0
  134. package/dist/tools/forwardAttackChainTracer.d.ts +73 -0
  135. package/dist/tools/forwardAttackChainTracer.d.ts.map +1 -0
  136. package/dist/tools/forwardAttackChainTracer.js +604 -0
  137. package/dist/tools/forwardAttackChainTracer.js.map +1 -0
  138. package/dist/tools/localExplore.d.ts +12 -199
  139. package/dist/tools/localExplore.d.ts.map +1 -1
  140. package/dist/tools/localExplore.js +18 -1352
  141. package/dist/tools/localExplore.js.map +1 -1
  142. package/dist/tools/offensiveTransparencyTools.d.ts +188 -0
  143. package/dist/tools/offensiveTransparencyTools.d.ts.map +1 -0
  144. package/dist/tools/offensiveTransparencyTools.js +890 -0
  145. package/dist/tools/offensiveTransparencyTools.js.map +1 -0
  146. package/dist/tools/planningTools.d.ts +8 -17
  147. package/dist/tools/planningTools.d.ts.map +1 -1
  148. package/dist/tools/planningTools.js +31 -141
  149. package/dist/tools/planningTools.js.map +1 -1
  150. package/dist/tools/searchTools.d.ts +9 -0
  151. package/dist/tools/searchTools.d.ts.map +1 -1
  152. package/dist/tools/searchTools.js +305 -189
  153. package/dist/tools/searchTools.js.map +1 -1
  154. package/dist/tools/skillTools.d.ts +7 -5
  155. package/dist/tools/skillTools.d.ts.map +1 -1
  156. package/dist/tools/skillTools.js +13 -155
  157. package/dist/tools/skillTools.js.map +1 -1
  158. package/dist/tools/threatIntelligenceTools.d.ts +128 -0
  159. package/dist/tools/threatIntelligenceTools.d.ts.map +1 -0
  160. package/dist/tools/threatIntelligenceTools.js +712 -0
  161. package/dist/tools/threatIntelligenceTools.js.map +1 -0
  162. package/dist/ui/PromptController.d.ts +4 -0
  163. package/dist/ui/PromptController.d.ts.map +1 -1
  164. package/dist/ui/PromptController.js +32 -11
  165. package/dist/ui/PromptController.js.map +1 -1
  166. package/dist/ui/UnifiedUIRenderer.d.ts +20 -0
  167. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
  168. package/dist/ui/UnifiedUIRenderer.js +235 -28
  169. package/dist/ui/UnifiedUIRenderer.js.map +1 -1
  170. package/dist/ui/animatedStatus.d.ts +2 -0
  171. package/dist/ui/animatedStatus.d.ts.map +1 -1
  172. package/dist/ui/animatedStatus.js +36 -2
  173. package/dist/ui/animatedStatus.js.map +1 -1
  174. package/dist/ui/orchestration/StatusOrchestrator.d.ts +10 -0
  175. package/dist/ui/orchestration/StatusOrchestrator.d.ts.map +1 -1
  176. package/dist/ui/orchestration/StatusOrchestrator.js +36 -4
  177. package/dist/ui/orchestration/StatusOrchestrator.js.map +1 -1
  178. package/package.json +1 -1
  179. package/dist/capabilities/advancedTestGenerationCapability.d.ts +0 -17
  180. package/dist/capabilities/advancedTestGenerationCapability.d.ts.map +0 -1
  181. package/dist/capabilities/advancedTestGenerationCapability.js +0 -28
  182. package/dist/capabilities/advancedTestGenerationCapability.js.map +0 -1
  183. package/dist/capabilities/browserAutomationCapability.d.ts +0 -37
  184. package/dist/capabilities/browserAutomationCapability.d.ts.map +0 -1
  185. package/dist/capabilities/browserAutomationCapability.js +0 -49
  186. package/dist/capabilities/browserAutomationCapability.js.map +0 -1
  187. package/dist/capabilities/buildCapability.d.ts +0 -24
  188. package/dist/capabilities/buildCapability.d.ts.map +0 -1
  189. package/dist/capabilities/buildCapability.js +0 -25
  190. package/dist/capabilities/buildCapability.js.map +0 -1
  191. package/dist/capabilities/cloudCapability.d.ts +0 -13
  192. package/dist/capabilities/cloudCapability.d.ts.map +0 -1
  193. package/dist/capabilities/cloudCapability.js +0 -38
  194. package/dist/capabilities/cloudCapability.js.map +0 -1
  195. package/dist/capabilities/codeAnalysisCapability.d.ts +0 -13
  196. package/dist/capabilities/codeAnalysisCapability.d.ts.map +0 -1
  197. package/dist/capabilities/codeAnalysisCapability.js +0 -24
  198. package/dist/capabilities/codeAnalysisCapability.js.map +0 -1
  199. package/dist/capabilities/codeQualityCapability.d.ts +0 -13
  200. package/dist/capabilities/codeQualityCapability.d.ts.map +0 -1
  201. package/dist/capabilities/codeQualityCapability.js +0 -25
  202. package/dist/capabilities/codeQualityCapability.js.map +0 -1
  203. package/dist/capabilities/dependencySecurityCapability.d.ts +0 -13
  204. package/dist/capabilities/dependencySecurityCapability.d.ts.map +0 -1
  205. package/dist/capabilities/dependencySecurityCapability.js +0 -24
  206. package/dist/capabilities/dependencySecurityCapability.js.map +0 -1
  207. package/dist/capabilities/devCapability.d.ts +0 -13
  208. package/dist/capabilities/devCapability.d.ts.map +0 -1
  209. package/dist/capabilities/devCapability.js +0 -24
  210. package/dist/capabilities/devCapability.js.map +0 -1
  211. package/dist/capabilities/emailCapability.d.ts +0 -12
  212. package/dist/capabilities/emailCapability.d.ts.map +0 -1
  213. package/dist/capabilities/emailCapability.js +0 -22
  214. package/dist/capabilities/emailCapability.js.map +0 -1
  215. package/dist/capabilities/enhancedAnalysisCapability.d.ts +0 -13
  216. package/dist/capabilities/enhancedAnalysisCapability.d.ts.map +0 -1
  217. package/dist/capabilities/enhancedAnalysisCapability.js +0 -20
  218. package/dist/capabilities/enhancedAnalysisCapability.js.map +0 -1
  219. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts +0 -17
  220. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts.map +0 -1
  221. package/dist/capabilities/enhancedCodeIntelligenceCapability.js +0 -28
  222. package/dist/capabilities/enhancedCodeIntelligenceCapability.js.map +0 -1
  223. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts +0 -17
  224. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts.map +0 -1
  225. package/dist/capabilities/enhancedDevWorkflowCapability.js +0 -28
  226. package/dist/capabilities/enhancedDevWorkflowCapability.js.map +0 -1
  227. package/dist/capabilities/frontendTestingCapability.d.ts +0 -13
  228. package/dist/capabilities/frontendTestingCapability.d.ts.map +0 -1
  229. package/dist/capabilities/frontendTestingCapability.js +0 -28
  230. package/dist/capabilities/frontendTestingCapability.js.map +0 -1
  231. package/dist/capabilities/interactionCapability.d.ts +0 -12
  232. package/dist/capabilities/interactionCapability.d.ts.map +0 -1
  233. package/dist/capabilities/interactionCapability.js +0 -22
  234. package/dist/capabilities/interactionCapability.js.map +0 -1
  235. package/dist/capabilities/learnCapability.d.ts +0 -22
  236. package/dist/capabilities/learnCapability.d.ts.map +0 -1
  237. package/dist/capabilities/learnCapability.js +0 -37
  238. package/dist/capabilities/learnCapability.js.map +0 -1
  239. package/dist/capabilities/notebookCapability.d.ts +0 -17
  240. package/dist/capabilities/notebookCapability.d.ts.map +0 -1
  241. package/dist/capabilities/notebookCapability.js +0 -27
  242. package/dist/capabilities/notebookCapability.js.map +0 -1
  243. package/dist/capabilities/planningCapability.d.ts +0 -16
  244. package/dist/capabilities/planningCapability.d.ts.map +0 -1
  245. package/dist/capabilities/planningCapability.js +0 -26
  246. package/dist/capabilities/planningCapability.js.map +0 -1
  247. package/dist/capabilities/refactoringCapability.d.ts +0 -13
  248. package/dist/capabilities/refactoringCapability.d.ts.map +0 -1
  249. package/dist/capabilities/refactoringCapability.js +0 -25
  250. package/dist/capabilities/refactoringCapability.js.map +0 -1
  251. package/dist/capabilities/repoChecksCapability.d.ts +0 -10
  252. package/dist/capabilities/repoChecksCapability.d.ts.map +0 -1
  253. package/dist/capabilities/repoChecksCapability.js +0 -24
  254. package/dist/capabilities/repoChecksCapability.js.map +0 -1
  255. package/dist/capabilities/taskManagementCapability.d.ts +0 -12
  256. package/dist/capabilities/taskManagementCapability.d.ts.map +0 -1
  257. package/dist/capabilities/taskManagementCapability.js +0 -22
  258. package/dist/capabilities/taskManagementCapability.js.map +0 -1
  259. package/dist/capabilities/testingCapability.d.ts +0 -13
  260. package/dist/capabilities/testingCapability.d.ts.map +0 -1
  261. package/dist/capabilities/testingCapability.js +0 -25
  262. package/dist/capabilities/testingCapability.js.map +0 -1
  263. package/dist/capabilities/validationCapability.d.ts +0 -13
  264. package/dist/capabilities/validationCapability.d.ts.map +0 -1
  265. package/dist/capabilities/validationCapability.js +0 -24
  266. package/dist/capabilities/validationCapability.js.map +0 -1
  267. package/dist/capabilities/webCapability.d.ts +0 -12
  268. package/dist/capabilities/webCapability.d.ts.map +0 -1
  269. package/dist/capabilities/webCapability.js +0 -22
  270. package/dist/capabilities/webCapability.js.map +0 -1
  271. package/dist/core/deepBugAnalyzer.d.ts +0 -128
  272. package/dist/core/deepBugAnalyzer.d.ts.map +0 -1
  273. package/dist/core/deepBugAnalyzer.js +0 -406
  274. package/dist/core/deepBugAnalyzer.js.map +0 -1
  275. package/dist/core/hypothesisEngine.d.ts +0 -113
  276. package/dist/core/hypothesisEngine.d.ts.map +0 -1
  277. package/dist/core/hypothesisEngine.js +0 -264
  278. package/dist/core/hypothesisEngine.js.map +0 -1
  279. package/dist/core/productTestHarness.d.ts +0 -113
  280. package/dist/core/productTestHarness.d.ts.map +0 -1
  281. package/dist/core/productTestHarness.js +0 -351
  282. package/dist/core/productTestHarness.js.map +0 -1
  283. package/dist/core/validationRunner.d.ts +0 -106
  284. package/dist/core/validationRunner.d.ts.map +0 -1
  285. package/dist/core/validationRunner.js +0 -892
  286. package/dist/core/validationRunner.js.map +0 -1
  287. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts +0 -14
  288. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts.map +0 -1
  289. package/dist/plugins/tools/browser/browserAutomationPlugin.js +0 -26
  290. package/dist/plugins/tools/browser/browserAutomationPlugin.js.map +0 -1
  291. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts +0 -3
  292. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts.map +0 -1
  293. package/dist/plugins/tools/checks/localRepoChecksPlugin.js +0 -14
  294. package/dist/plugins/tools/checks/localRepoChecksPlugin.js.map +0 -1
  295. package/dist/plugins/tools/cloud/cloudPlugin.d.ts +0 -3
  296. package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +0 -1
  297. package/dist/plugins/tools/cloud/cloudPlugin.js +0 -14
  298. package/dist/plugins/tools/cloud/cloudPlugin.js.map +0 -1
  299. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts +0 -3
  300. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts.map +0 -1
  301. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -14
  302. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js.map +0 -1
  303. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts +0 -3
  304. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts.map +0 -1
  305. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js +0 -14
  306. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js.map +0 -1
  307. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts +0 -3
  308. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts.map +0 -1
  309. package/dist/plugins/tools/dependency/dependencyPlugin.js +0 -12
  310. package/dist/plugins/tools/dependency/dependencyPlugin.js.map +0 -1
  311. package/dist/plugins/tools/development/devPlugin.d.ts +0 -3
  312. package/dist/plugins/tools/development/devPlugin.d.ts.map +0 -1
  313. package/dist/plugins/tools/development/devPlugin.js +0 -14
  314. package/dist/plugins/tools/development/devPlugin.js.map +0 -1
  315. package/dist/plugins/tools/email/emailPlugin.d.ts +0 -3
  316. package/dist/plugins/tools/email/emailPlugin.d.ts.map +0 -1
  317. package/dist/plugins/tools/email/emailPlugin.js +0 -12
  318. package/dist/plugins/tools/email/emailPlugin.js.map +0 -1
  319. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts +0 -3
  320. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts.map +0 -1
  321. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js +0 -14
  322. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js.map +0 -1
  323. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts +0 -3
  324. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts.map +0 -1
  325. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js +0 -12
  326. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js.map +0 -1
  327. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts +0 -3
  328. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts.map +0 -1
  329. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js +0 -12
  330. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js.map +0 -1
  331. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts +0 -3
  332. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts.map +0 -1
  333. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js +0 -14
  334. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js.map +0 -1
  335. package/dist/plugins/tools/interaction/interactionPlugin.d.ts +0 -3
  336. package/dist/plugins/tools/interaction/interactionPlugin.d.ts.map +0 -1
  337. package/dist/plugins/tools/interaction/interactionPlugin.js +0 -12
  338. package/dist/plugins/tools/interaction/interactionPlugin.js.map +0 -1
  339. package/dist/plugins/tools/learn/learnPlugin.d.ts +0 -3
  340. package/dist/plugins/tools/learn/learnPlugin.d.ts.map +0 -1
  341. package/dist/plugins/tools/learn/learnPlugin.js +0 -14
  342. package/dist/plugins/tools/learn/learnPlugin.js.map +0 -1
  343. package/dist/plugins/tools/notebook/notebookPlugin.d.ts +0 -9
  344. package/dist/plugins/tools/notebook/notebookPlugin.d.ts.map +0 -1
  345. package/dist/plugins/tools/notebook/notebookPlugin.js +0 -15
  346. package/dist/plugins/tools/notebook/notebookPlugin.js.map +0 -1
  347. package/dist/plugins/tools/planning/planningPlugin.d.ts +0 -9
  348. package/dist/plugins/tools/planning/planningPlugin.d.ts.map +0 -1
  349. package/dist/plugins/tools/planning/planningPlugin.js +0 -15
  350. package/dist/plugins/tools/planning/planningPlugin.js.map +0 -1
  351. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts +0 -3
  352. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts.map +0 -1
  353. package/dist/plugins/tools/refactoring/refactoringPlugin.js +0 -12
  354. package/dist/plugins/tools/refactoring/refactoringPlugin.js.map +0 -1
  355. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts +0 -3
  356. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts.map +0 -1
  357. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js +0 -12
  358. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js.map +0 -1
  359. package/dist/plugins/tools/testing/testingPlugin.d.ts +0 -3
  360. package/dist/plugins/tools/testing/testingPlugin.d.ts.map +0 -1
  361. package/dist/plugins/tools/testing/testingPlugin.js +0 -12
  362. package/dist/plugins/tools/testing/testingPlugin.js.map +0 -1
  363. package/dist/plugins/tools/validation/validationPlugin.d.ts +0 -3
  364. package/dist/plugins/tools/validation/validationPlugin.d.ts.map +0 -1
  365. package/dist/plugins/tools/validation/validationPlugin.js +0 -14
  366. package/dist/plugins/tools/validation/validationPlugin.js.map +0 -1
  367. package/dist/plugins/tools/web/webPlugin.d.ts +0 -3
  368. package/dist/plugins/tools/web/webPlugin.d.ts.map +0 -1
  369. package/dist/plugins/tools/web/webPlugin.js +0 -12
  370. package/dist/plugins/tools/web/webPlugin.js.map +0 -1
  371. package/dist/tools/advancedTestGenerationTools.d.ts +0 -21
  372. package/dist/tools/advancedTestGenerationTools.d.ts.map +0 -1
  373. package/dist/tools/advancedTestGenerationTools.js +0 -304
  374. package/dist/tools/advancedTestGenerationTools.js.map +0 -1
  375. package/dist/tools/browserAutomationTools.d.ts +0 -23
  376. package/dist/tools/browserAutomationTools.d.ts.map +0 -1
  377. package/dist/tools/browserAutomationTools.js +0 -916
  378. package/dist/tools/browserAutomationTools.js.map +0 -1
  379. package/dist/tools/buildTools.d.ts +0 -9
  380. package/dist/tools/buildTools.d.ts.map +0 -1
  381. package/dist/tools/buildTools.js +0 -346
  382. package/dist/tools/buildTools.js.map +0 -1
  383. package/dist/tools/cloudTools.d.ts +0 -49
  384. package/dist/tools/cloudTools.d.ts.map +0 -1
  385. package/dist/tools/cloudTools.js +0 -1258
  386. package/dist/tools/cloudTools.js.map +0 -1
  387. package/dist/tools/codeAnalysisTools.d.ts +0 -74
  388. package/dist/tools/codeAnalysisTools.d.ts.map +0 -1
  389. package/dist/tools/codeAnalysisTools.js +0 -664
  390. package/dist/tools/codeAnalysisTools.js.map +0 -1
  391. package/dist/tools/codeGenerationTools.d.ts +0 -3
  392. package/dist/tools/codeGenerationTools.d.ts.map +0 -1
  393. package/dist/tools/codeGenerationTools.js +0 -439
  394. package/dist/tools/codeGenerationTools.js.map +0 -1
  395. package/dist/tools/codeQualityTools.d.ts +0 -3
  396. package/dist/tools/codeQualityTools.d.ts.map +0 -1
  397. package/dist/tools/codeQualityTools.js +0 -297
  398. package/dist/tools/codeQualityTools.js.map +0 -1
  399. package/dist/tools/dependencyTools.d.ts +0 -3
  400. package/dist/tools/dependencyTools.d.ts.map +0 -1
  401. package/dist/tools/dependencyTools.js +0 -284
  402. package/dist/tools/dependencyTools.js.map +0 -1
  403. package/dist/tools/devTools.d.ts +0 -10
  404. package/dist/tools/devTools.d.ts.map +0 -1
  405. package/dist/tools/devTools.js +0 -2126
  406. package/dist/tools/devTools.js.map +0 -1
  407. package/dist/tools/emailTools.d.ts +0 -21
  408. package/dist/tools/emailTools.d.ts.map +0 -1
  409. package/dist/tools/emailTools.js +0 -449
  410. package/dist/tools/emailTools.js.map +0 -1
  411. package/dist/tools/enhancedAnalysisTools.d.ts +0 -9
  412. package/dist/tools/enhancedAnalysisTools.d.ts.map +0 -1
  413. package/dist/tools/enhancedAnalysisTools.js +0 -370
  414. package/dist/tools/enhancedAnalysisTools.js.map +0 -1
  415. package/dist/tools/enhancedCodeIntelligenceTools.d.ts +0 -7
  416. package/dist/tools/enhancedCodeIntelligenceTools.d.ts.map +0 -1
  417. package/dist/tools/enhancedCodeIntelligenceTools.js +0 -540
  418. package/dist/tools/enhancedCodeIntelligenceTools.js.map +0 -1
  419. package/dist/tools/enhancedDevWorkflowTools.d.ts +0 -7
  420. package/dist/tools/enhancedDevWorkflowTools.d.ts.map +0 -1
  421. package/dist/tools/enhancedDevWorkflowTools.js +0 -432
  422. package/dist/tools/enhancedDevWorkflowTools.js.map +0 -1
  423. package/dist/tools/frontendTestingTools.d.ts +0 -35
  424. package/dist/tools/frontendTestingTools.d.ts.map +0 -1
  425. package/dist/tools/frontendTestingTools.js +0 -1258
  426. package/dist/tools/frontendTestingTools.js.map +0 -1
  427. package/dist/tools/globTools.d.ts +0 -15
  428. package/dist/tools/globTools.d.ts.map +0 -1
  429. package/dist/tools/globTools.js +0 -174
  430. package/dist/tools/globTools.js.map +0 -1
  431. package/dist/tools/grepTools.d.ts +0 -19
  432. package/dist/tools/grepTools.d.ts.map +0 -1
  433. package/dist/tools/grepTools.js +0 -411
  434. package/dist/tools/grepTools.js.map +0 -1
  435. package/dist/tools/interactionTools.d.ts +0 -6
  436. package/dist/tools/interactionTools.d.ts.map +0 -1
  437. package/dist/tools/interactionTools.js +0 -209
  438. package/dist/tools/interactionTools.js.map +0 -1
  439. package/dist/tools/learnTools.d.ts +0 -164
  440. package/dist/tools/learnTools.d.ts.map +0 -1
  441. package/dist/tools/learnTools.js +0 -2098
  442. package/dist/tools/learnTools.js.map +0 -1
  443. package/dist/tools/notebookEditTools.d.ts +0 -15
  444. package/dist/tools/notebookEditTools.d.ts.map +0 -1
  445. package/dist/tools/notebookEditTools.js +0 -197
  446. package/dist/tools/notebookEditTools.js.map +0 -1
  447. package/dist/tools/refactoringTools.d.ts +0 -3
  448. package/dist/tools/refactoringTools.d.ts.map +0 -1
  449. package/dist/tools/refactoringTools.js +0 -294
  450. package/dist/tools/refactoringTools.js.map +0 -1
  451. package/dist/tools/repoChecksTools.d.ts +0 -3
  452. package/dist/tools/repoChecksTools.d.ts.map +0 -1
  453. package/dist/tools/repoChecksTools.js +0 -276
  454. package/dist/tools/repoChecksTools.js.map +0 -1
  455. package/dist/tools/taskManagementTools.d.ts +0 -10
  456. package/dist/tools/taskManagementTools.d.ts.map +0 -1
  457. package/dist/tools/taskManagementTools.js +0 -133
  458. package/dist/tools/taskManagementTools.js.map +0 -1
  459. package/dist/tools/testingTools.d.ts +0 -3
  460. package/dist/tools/testingTools.d.ts.map +0 -1
  461. package/dist/tools/testingTools.js +0 -237
  462. package/dist/tools/testingTools.js.map +0 -1
  463. package/dist/tools/validationTools.d.ts +0 -7
  464. package/dist/tools/validationTools.d.ts.map +0 -1
  465. package/dist/tools/validationTools.js +0 -344
  466. package/dist/tools/validationTools.js.map +0 -1
  467. package/dist/tools/webTools.d.ts +0 -3
  468. package/dist/tools/webTools.d.ts.map +0 -1
  469. package/dist/tools/webTools.js +0 -502
  470. package/dist/tools/webTools.js.map +0 -1
@@ -82,6 +82,10 @@ export class UnifiedUIRenderer extends EventEmitter {
82
82
  funActivityPhrases = [
83
83
  'Thinking', 'Processing', 'Analyzing', 'Working', 'Preparing',
84
84
  ];
85
+ maxCuratedReasoningLines = 8;
86
+ maxCuratedReasoningChars = 1800;
87
+ thoughtDedupWindowMs = 15000;
88
+ lastCuratedThought = null;
85
89
  statusMeta = {};
86
90
  toggleState = {
87
91
  verificationEnabled: false,
@@ -90,6 +94,37 @@ export class UnifiedUIRenderer extends EventEmitter {
90
94
  dualRlEnabled: false,
91
95
  };
92
96
  // ------------ Helpers ------------
97
+ /** Ensure cursor is always within valid bounds for the current buffer */
98
+ clampCursor() {
99
+ this.cursor = Math.max(0, Math.min(this.cursor, this.buffer.length));
100
+ }
101
+ /** Safely append to paste buffer with size limit enforcement */
102
+ appendToPasteBuffer(buffer, text) {
103
+ if (this.pasteBufferOverflow)
104
+ return; // Already at limit
105
+ const current = buffer === 'paste' ? this.pasteBuffer : this.plainPasteBuffer;
106
+ const remaining = this.maxPasteBufferSize - current.length;
107
+ if (remaining <= 0) {
108
+ this.pasteBufferOverflow = true;
109
+ return;
110
+ }
111
+ const toAdd = text.length <= remaining ? text : text.slice(0, remaining);
112
+ if (buffer === 'paste') {
113
+ this.pasteBuffer += toAdd;
114
+ }
115
+ else {
116
+ this.plainPasteBuffer += toAdd;
117
+ }
118
+ if (toAdd.length < text.length) {
119
+ this.pasteBufferOverflow = true;
120
+ }
121
+ }
122
+ /** Strip ANSI escape sequences from text to prevent injection */
123
+ sanitizePasteContent(text) {
124
+ // Remove all ANSI escape sequences (CSI, OSC, etc.)
125
+ // eslint-disable-next-line no-control-regex
126
+ return text.replace(/\x1b\[[0-9;]*[A-Za-z]|\x1b\][^\x07]*\x07|\x1b[PX^_][^\x1b]*\x1b\\|\x1b./g, '');
127
+ }
93
128
  formatHotkey(combo) {
94
129
  if (!combo?.trim())
95
130
  return null;
@@ -106,6 +141,9 @@ export class UnifiedUIRenderer extends EventEmitter {
106
141
  plainPasteWindowMs = 60;
107
142
  plainPasteTriggerChars = 24;
108
143
  plainPasteEarlyNewlineChars = 2; // Guard for short first lines in plain paste mode
144
+ // Paste buffer limits to prevent memory exhaustion
145
+ maxPasteBufferSize = 10 * 1024 * 1024; // 10MB max paste size
146
+ pasteBufferOverflow = false; // Track if paste was truncated
109
147
  cursorVisibleColumn = 1;
110
148
  inBracketedPaste = false;
111
149
  pasteBuffer = '';
@@ -131,6 +169,12 @@ export class UnifiedUIRenderer extends EventEmitter {
131
169
  pendingRender = false;
132
170
  lastRenderTime = 0;
133
171
  renderThrottleMs = 16; // ~60fps max
172
+ renderThrottleTimer = null;
173
+ // Disposal state to prevent operations after cleanup
174
+ disposed = false;
175
+ // Bound event handlers for proper cleanup
176
+ boundResizeHandler = null;
177
+ boundKeypressHandler = null;
134
178
  inputCapture = null;
135
179
  constructor(output = process.stdout, input = process.stdin, _options) {
136
180
  super();
@@ -149,12 +193,14 @@ export class UnifiedUIRenderer extends EventEmitter {
149
193
  });
150
194
  this.rl.setPrompt('');
151
195
  this.updateTerminalSize();
152
- this.output.on('resize', () => {
153
- if (!this.plainMode) {
196
+ // Use bound handlers so we can remove them on cleanup
197
+ this.boundResizeHandler = () => {
198
+ if (!this.plainMode && !this.disposed) {
154
199
  this.updateTerminalSize();
155
200
  this.renderPrompt();
156
201
  }
157
- });
202
+ };
203
+ this.output.on('resize', this.boundResizeHandler);
158
204
  this.setupInputHandlers();
159
205
  }
160
206
  initialize() {
@@ -181,8 +227,15 @@ export class UnifiedUIRenderer extends EventEmitter {
181
227
  this.renderPrompt();
182
228
  }
183
229
  cleanup() {
230
+ // Mark as disposed first to prevent any pending operations
231
+ this.disposed = true;
184
232
  this.cancelInputCapture(new Error('Renderer disposed'));
185
233
  this.cancelPlainPasteCapture();
234
+ // Clear render throttle timer
235
+ if (this.renderThrottleTimer) {
236
+ clearTimeout(this.renderThrottleTimer);
237
+ this.renderThrottleTimer = null;
238
+ }
186
239
  // Stop any running animations
187
240
  if (this.spinnerInterval) {
188
241
  clearInterval(this.spinnerInterval);
@@ -198,6 +251,17 @@ export class UnifiedUIRenderer extends EventEmitter {
198
251
  }
199
252
  this.contextMeter.dispose();
200
253
  disposeAnimations();
254
+ // Remove event listeners to prevent memory leaks
255
+ if (this.boundResizeHandler) {
256
+ this.output.removeListener('resize', this.boundResizeHandler);
257
+ this.boundResizeHandler = null;
258
+ }
259
+ if (this.boundKeypressHandler) {
260
+ this.input.removeListener('keypress', this.boundKeypressHandler);
261
+ this.boundKeypressHandler = null;
262
+ }
263
+ // Remove all EventEmitter listeners from this instance
264
+ this.removeAllListeners();
201
265
  if (!this.interactive) {
202
266
  this.rl.close();
203
267
  return;
@@ -214,6 +278,8 @@ export class UnifiedUIRenderer extends EventEmitter {
214
278
  }
215
279
  this.rl.close();
216
280
  this.lastOverlay = null;
281
+ // Clear event queue
282
+ this.eventQueue = [];
217
283
  }
218
284
  suspendPromptRendering() {
219
285
  this.promptRenderingSuspended = true;
@@ -234,9 +300,13 @@ export class UnifiedUIRenderer extends EventEmitter {
234
300
  if (this.input.isTTY) {
235
301
  this.input.setRawMode(true);
236
302
  }
237
- this.input.on('keypress', (str, key) => {
238
- this.handleKeypress(str, key);
239
- });
303
+ // Use bound handler so we can remove it on cleanup
304
+ this.boundKeypressHandler = (str, key) => {
305
+ if (!this.disposed) {
306
+ this.handleKeypress(str, key);
307
+ }
308
+ };
309
+ this.input.on('keypress', this.boundKeypressHandler);
240
310
  }
241
311
  emitInputChange() {
242
312
  const payload = {
@@ -386,8 +456,16 @@ export class UnifiedUIRenderer extends EventEmitter {
386
456
  else if (this.historyIndex > 0) {
387
457
  this.historyIndex--;
388
458
  }
389
- this.buffer = this.history[this.historyIndex] ?? '';
459
+ // Validate index is within bounds before accessing
460
+ if (this.historyIndex >= 0 && this.historyIndex < this.history.length) {
461
+ this.buffer = this.history[this.historyIndex] ?? '';
462
+ }
463
+ else {
464
+ this.historyIndex = -1;
465
+ this.buffer = '';
466
+ }
390
467
  this.cursor = this.buffer.length;
468
+ this.inputRenderOffset = 0; // Reset render offset for new buffer
391
469
  this.updateSuggestions();
392
470
  this.renderPrompt();
393
471
  this.emitInputChange();
@@ -404,10 +482,16 @@ export class UnifiedUIRenderer extends EventEmitter {
404
482
  this.historyIndex = -1;
405
483
  this.buffer = '';
406
484
  }
407
- else {
485
+ else if (this.historyIndex >= 0) {
408
486
  this.buffer = this.history[this.historyIndex] ?? '';
409
487
  }
488
+ else {
489
+ // Safety: invalid state, reset
490
+ this.historyIndex = -1;
491
+ this.buffer = '';
492
+ }
410
493
  this.cursor = this.buffer.length;
494
+ this.inputRenderOffset = 0; // Reset render offset for new buffer
411
495
  this.updateSuggestions();
412
496
  this.renderPrompt();
413
497
  this.emitInputChange();
@@ -472,6 +556,7 @@ export class UnifiedUIRenderer extends EventEmitter {
472
556
  }
473
557
  if (sequence === '\x1b[200~') {
474
558
  this.inBracketedPaste = true;
559
+ this.pasteBufferOverflow = false; // Reset overflow flag for new paste
475
560
  // Consume any pending insert buffer to prevent leak
476
561
  const pending = this.consumePendingInsertForPaste();
477
562
  this.pasteBuffer = pending; // Include any chars that arrived before bracketed paste started
@@ -486,7 +571,7 @@ export class UnifiedUIRenderer extends EventEmitter {
486
571
  return true;
487
572
  }
488
573
  if (key?.name === 'return' || key?.name === 'enter') {
489
- this.pasteBuffer += '\n';
574
+ this.appendToPasteBuffer('paste', '\n');
490
575
  return true;
491
576
  }
492
577
  if (key?.name === 'backspace') {
@@ -494,11 +579,11 @@ export class UnifiedUIRenderer extends EventEmitter {
494
579
  return true;
495
580
  }
496
581
  if (typeof str === 'string' && str.length > 0) {
497
- this.pasteBuffer += str;
582
+ this.appendToPasteBuffer('paste', str);
498
583
  return true;
499
584
  }
500
585
  if (typeof sequence === 'string' && sequence.length > 0) {
501
- this.pasteBuffer += sequence;
586
+ this.appendToPasteBuffer('paste', sequence);
502
587
  return true;
503
588
  }
504
589
  return true;
@@ -506,11 +591,18 @@ export class UnifiedUIRenderer extends EventEmitter {
506
591
  commitPasteBuffer() {
507
592
  if (!this.inBracketedPaste)
508
593
  return;
509
- const content = this.pasteBuffer.replace(/\r\n?/g, '\n');
594
+ // Sanitize to remove any injected escape sequences, then normalize line endings
595
+ const sanitized = this.sanitizePasteContent(this.pasteBuffer);
596
+ const content = sanitized.replace(/\r\n?/g, '\n');
510
597
  if (content) {
511
598
  const lines = content.split('\n');
599
+ const wasTruncated = this.pasteBufferOverflow;
512
600
  if (lines.length > 1 || content.length > 200) {
513
- this.collapsedPaste = { text: content, lines: lines.length, chars: content.length };
601
+ this.collapsedPaste = {
602
+ text: content,
603
+ lines: lines.length,
604
+ chars: content.length + (wasTruncated ? '+' : 0), // Indicate truncation
605
+ };
514
606
  this.buffer = '';
515
607
  this.cursor = 0;
516
608
  this.updateSuggestions();
@@ -523,6 +615,7 @@ export class UnifiedUIRenderer extends EventEmitter {
523
615
  }
524
616
  this.inBracketedPaste = false;
525
617
  this.pasteBuffer = '';
618
+ this.pasteBufferOverflow = false;
526
619
  this.cancelPlainPasteCapture();
527
620
  }
528
621
  handlePlainPaste(str, key) {
@@ -562,6 +655,7 @@ export class UnifiedUIRenderer extends EventEmitter {
562
655
  let chunkAlreadyCaptured = false;
563
656
  if (!this.inPlainPaste) {
564
657
  this.inPlainPaste = true;
658
+ this.pasteBufferOverflow = false; // Reset overflow flag for new paste
565
659
  // Consume pending insert buffer first - this is the primary source now
566
660
  const pending = this.consumePendingInsertForPaste();
567
661
  const reclaimed = this.reclaimRecentPlainChunks();
@@ -575,9 +669,13 @@ export class UnifiedUIRenderer extends EventEmitter {
575
669
  if (removeCount > 0 && suffix === reclaimed.slice(-removeCount)) {
576
670
  this.buffer = this.buffer.slice(0, this.buffer.length - removeCount);
577
671
  this.cursor = Math.max(0, this.buffer.length);
672
+ this.clampCursor(); // Ensure cursor is valid
578
673
  }
579
674
  }
580
- this.plainPasteBuffer = combined;
675
+ this.plainPasteBuffer = combined.slice(0, this.maxPasteBufferSize);
676
+ if (combined.length > this.maxPasteBufferSize) {
677
+ this.pasteBufferOverflow = true;
678
+ }
581
679
  chunkAlreadyCaptured = combined.endsWith(chunk);
582
680
  }
583
681
  else {
@@ -585,7 +683,7 @@ export class UnifiedUIRenderer extends EventEmitter {
585
683
  }
586
684
  }
587
685
  if (!chunkAlreadyCaptured) {
588
- this.plainPasteBuffer += chunk;
686
+ this.appendToPasteBuffer('plainPaste', chunk);
589
687
  }
590
688
  this.schedulePlainPasteCommit();
591
689
  return true;
@@ -647,11 +745,15 @@ export class UnifiedUIRenderer extends EventEmitter {
647
745
  finalizePlainPaste() {
648
746
  if (!this.inPlainPaste)
649
747
  return;
650
- const content = this.plainPasteBuffer.replace(/\r\n?/g, '\n');
748
+ // Sanitize to remove any injected escape sequences, then normalize line endings
749
+ const sanitized = this.sanitizePasteContent(this.plainPasteBuffer);
750
+ const content = sanitized.replace(/\r\n?/g, '\n');
751
+ const wasTruncated = this.pasteBufferOverflow;
651
752
  this.inPlainPaste = false;
652
753
  this.plainPasteBuffer = '';
653
754
  this.plainRecentChunks = [];
654
755
  this.resetPlainPasteBurst();
756
+ this.pasteBufferOverflow = false;
655
757
  if (this.plainPasteTimer) {
656
758
  clearTimeout(this.plainPasteTimer);
657
759
  this.plainPasteTimer = null;
@@ -660,7 +762,11 @@ export class UnifiedUIRenderer extends EventEmitter {
660
762
  return;
661
763
  const lines = content.split('\n');
662
764
  if (lines.length > 1 || content.length > 200) {
663
- this.collapsedPaste = { text: content, lines: lines.length, chars: content.length };
765
+ this.collapsedPaste = {
766
+ text: content,
767
+ lines: lines.length,
768
+ chars: content.length + (wasTruncated ? '+' : 0),
769
+ };
664
770
  this.buffer = '';
665
771
  this.cursor = 0;
666
772
  this.updateSuggestions();
@@ -679,8 +785,11 @@ export class UnifiedUIRenderer extends EventEmitter {
679
785
  if (this.collapsedPaste) {
680
786
  this.expandCollapsedPaste();
681
787
  }
788
+ // Ensure cursor is valid before slicing
789
+ this.clampCursor();
682
790
  this.buffer = this.buffer.slice(0, this.cursor) + text + this.buffer.slice(this.cursor);
683
791
  this.cursor += text.length;
792
+ this.clampCursor(); // Ensure cursor remains valid after modification
684
793
  this.updateSuggestions();
685
794
  this.renderPrompt();
686
795
  this.emitInputChange();
@@ -797,11 +906,19 @@ export class UnifiedUIRenderer extends EventEmitter {
797
906
  }
798
907
  navigateSuggestions(direction) {
799
908
  if (!this.buffer.startsWith('/') || this.suggestions.length === 0) {
909
+ // Reset index if suggestions were cleared but index wasn't
910
+ if (this.suggestionIndex !== -1 && this.suggestions.length === 0) {
911
+ this.suggestionIndex = -1;
912
+ }
800
913
  return false;
801
914
  }
802
- const next = this.suggestionIndex + direction;
915
+ // Ensure current index is valid before computing next
916
+ const currentIndex = this.suggestionIndex >= 0 && this.suggestionIndex < this.suggestions.length
917
+ ? this.suggestionIndex
918
+ : -1;
919
+ const next = currentIndex + direction;
803
920
  const clamped = Math.max(0, Math.min(this.suggestions.length - 1, next));
804
- if (clamped === this.suggestionIndex) {
921
+ if (clamped === this.suggestionIndex && this.suggestionIndex >= 0) {
805
922
  return true;
806
923
  }
807
924
  this.suggestionIndex = clamped;
@@ -870,11 +987,11 @@ export class UnifiedUIRenderer extends EventEmitter {
870
987
  }
871
988
  }
872
989
  async processQueue() {
873
- if (this.isProcessingQueue)
990
+ if (this.isProcessingQueue || this.disposed)
874
991
  return;
875
992
  this.isProcessingQueue = true;
876
993
  try {
877
- while (this.eventQueue.length > 0) {
994
+ while (this.eventQueue.length > 0 && !this.disposed) {
878
995
  const event = this.eventQueue.shift();
879
996
  if (!event)
880
997
  continue;
@@ -884,9 +1001,14 @@ export class UnifiedUIRenderer extends EventEmitter {
884
1001
  }
885
1002
  catch (error) {
886
1003
  // Never allow a rendering failure to stall the event queue
1004
+ if (this.disposed)
1005
+ break; // Don't try to write after disposal
887
1006
  const message = error instanceof Error ? error.message : typeof error === 'string' ? error : 'Unknown renderer error';
888
1007
  this.output.write(`\n[renderer] ${message}\n`);
889
1008
  }
1009
+ // Check disposed before continuing
1010
+ if (this.disposed)
1011
+ break;
890
1012
  // For prompt events, ensure the overlay is rendered immediately
891
1013
  // This guarantees prompts are visible before async processing continues
892
1014
  if (event.type === 'prompt') {
@@ -902,7 +1024,7 @@ export class UnifiedUIRenderer extends EventEmitter {
902
1024
  }
903
1025
  // ALWAYS render prompt after queue completes to keep bottom UI persistent
904
1026
  // This ensures status/toggles stay pinned and responses are fully rendered
905
- if (this.output.isTTY) {
1027
+ if (this.output.isTTY && !this.disposed) {
906
1028
  this.allowPromptRender = true;
907
1029
  this.renderPrompt();
908
1030
  }
@@ -1032,9 +1154,18 @@ export class UnifiedUIRenderer extends EventEmitter {
1032
1154
  if (this.isGarbageOutput(event.content)) {
1033
1155
  return '';
1034
1156
  }
1035
- // Strip any existing bullet prefix (○ or ⏺) and use consistent wrapping
1036
- const cleanContent = event.content.replace(/^[○⏺]\s*/, '');
1037
- return this.formatThinkingBlock(cleanContent);
1157
+ const curated = this.curateReasoningContent(event.content);
1158
+ if (!curated || this.isGarbageOutput(curated)) {
1159
+ return '';
1160
+ }
1161
+ if (!this.shouldRenderThought(curated)) {
1162
+ return '';
1163
+ }
1164
+ this.lastCuratedThought = {
1165
+ text: curated.replace(/\s+/g, ' ').trim().toLowerCase(),
1166
+ at: Date.now(),
1167
+ };
1168
+ return this.formatThinkingBlock(curated);
1038
1169
  }
1039
1170
  case 'tool': {
1040
1171
  // Compact tool display: ⚡ToolName → result
@@ -1094,6 +1225,70 @@ export class UnifiedUIRenderer extends EventEmitter {
1094
1225
  }
1095
1226
  return false;
1096
1227
  }
1228
+ curateReasoningContent(content) {
1229
+ const normalized = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trim();
1230
+ if (!normalized)
1231
+ return null;
1232
+ const limited = normalized.length > this.maxCuratedReasoningChars
1233
+ ? normalized.slice(0, this.maxCuratedReasoningChars)
1234
+ : normalized;
1235
+ const segments = limited
1236
+ .split('\n')
1237
+ .flatMap(line => line.split(/(?<=[.?!])\s+/))
1238
+ .map(line => line.replace(/^[•*⏺○\-\u2022]+\s*/, '').trim())
1239
+ .filter(Boolean);
1240
+ if (segments.length === 0) {
1241
+ return null;
1242
+ }
1243
+ const seen = new Set();
1244
+ const deduped = [];
1245
+ for (const segment of segments) {
1246
+ const normalizedSegment = segment.replace(/\s+/g, ' ');
1247
+ const key = normalizedSegment.toLowerCase();
1248
+ if (seen.has(key)) {
1249
+ continue;
1250
+ }
1251
+ seen.add(key);
1252
+ deduped.push(normalizedSegment);
1253
+ if (deduped.length >= this.maxCuratedReasoningLines) {
1254
+ break;
1255
+ }
1256
+ }
1257
+ if (deduped.length === 0) {
1258
+ return null;
1259
+ }
1260
+ const structured = deduped.filter(line => this.looksStructuredThought(line));
1261
+ const selected = structured.length > 0 ? structured : deduped;
1262
+ const limitedSelection = selected.slice(0, this.maxCuratedReasoningLines);
1263
+ const bulleted = limitedSelection.map(line => this.ensureReasoningBullet(line));
1264
+ return bulleted.join('\n');
1265
+ }
1266
+ ensureReasoningBullet(line) {
1267
+ if (/^([•*⏺○\-]|\d+[.)])\s/.test(line)) {
1268
+ return line;
1269
+ }
1270
+ return `• ${line}`;
1271
+ }
1272
+ looksStructuredThought(line) {
1273
+ return (/^(\d+[.)]\s|step\s*\d+|plan\b|next\b|then\b|goal\b)/i.test(line) ||
1274
+ /^[-*•]\s/.test(line) ||
1275
+ line.includes('->') ||
1276
+ line.includes('→') ||
1277
+ line.includes(': '));
1278
+ }
1279
+ shouldRenderThought(content) {
1280
+ const normalized = content.replace(/\s+/g, ' ').trim().toLowerCase();
1281
+ if (!normalized) {
1282
+ return false;
1283
+ }
1284
+ const now = Date.now();
1285
+ if (this.lastCuratedThought && this.lastCuratedThought.text === normalized) {
1286
+ if (now - this.lastCuratedThought.at < this.thoughtDedupWindowMs) {
1287
+ return false;
1288
+ }
1289
+ }
1290
+ return true;
1291
+ }
1097
1292
  /**
1098
1293
  * Format text in Claude Code style: ⏺ prefix with wrapped continuation lines
1099
1294
  * Example:
@@ -1688,14 +1883,21 @@ export class UnifiedUIRenderer extends EventEmitter {
1688
1883
  }
1689
1884
  // ------------ Prompt rendering ------------
1690
1885
  renderPrompt() {
1886
+ // Don't render if disposed
1887
+ if (this.disposed)
1888
+ return;
1691
1889
  // Throttle renders to prevent excessive redraws during rapid input
1692
1890
  const now = Date.now();
1693
1891
  if (now - this.lastRenderTime < this.renderThrottleMs) {
1694
1892
  if (!this.pendingRender) {
1695
1893
  this.pendingRender = true;
1696
- setTimeout(() => {
1894
+ // Track the timer for cleanup
1895
+ this.renderThrottleTimer = setTimeout(() => {
1896
+ this.renderThrottleTimer = null;
1697
1897
  this.pendingRender = false;
1698
- this.renderPromptImmediate();
1898
+ if (!this.disposed) {
1899
+ this.renderPromptImmediate();
1900
+ }
1699
1901
  }, this.renderThrottleMs);
1700
1902
  }
1701
1903
  return;
@@ -1703,6 +1905,9 @@ export class UnifiedUIRenderer extends EventEmitter {
1703
1905
  this.renderPromptImmediate();
1704
1906
  }
1705
1907
  renderPromptImmediate() {
1908
+ // Don't render if disposed
1909
+ if (this.disposed)
1910
+ return;
1706
1911
  this.lastRenderTime = Date.now();
1707
1912
  if (!this.interactive) {
1708
1913
  this.isPromptActive = false;
@@ -2405,7 +2610,9 @@ export class UnifiedUIRenderer extends EventEmitter {
2405
2610
  }
2406
2611
  setBuffer(text, cursorPos) {
2407
2612
  this.buffer = text;
2408
- this.cursor = cursorPos ?? text.length;
2613
+ // Validate cursor position to prevent out-of-bounds issues
2614
+ const requestedCursor = cursorPos ?? text.length;
2615
+ this.cursor = Math.max(0, Math.min(requestedCursor, text.length));
2409
2616
  this.inputRenderOffset = 0;
2410
2617
  this.updateSuggestions();
2411
2618
  this.renderPrompt();