erosolar-cli 1.7.356 → 1.7.358

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 (328) hide show
  1. package/README.md +24 -148
  2. package/dist/bin/erosolar.js +5 -21
  3. package/dist/bin/erosolar.js.map +1 -1
  4. package/dist/capabilities/agentSpawningCapability.d.ts.map +1 -1
  5. package/dist/capabilities/agentSpawningCapability.js +56 -31
  6. package/dist/capabilities/agentSpawningCapability.js.map +1 -1
  7. package/dist/contracts/agent-schemas.json +0 -15
  8. package/dist/contracts/tools.schema.json +0 -9
  9. package/dist/core/agent.d.ts +2 -2
  10. package/dist/core/agent.d.ts.map +1 -1
  11. package/dist/core/agent.js.map +1 -1
  12. package/dist/core/customCommands.d.ts +1 -0
  13. package/dist/core/customCommands.d.ts.map +1 -1
  14. package/dist/core/customCommands.js +3 -0
  15. package/dist/core/customCommands.js.map +1 -1
  16. package/dist/core/hooks.d.ts +113 -0
  17. package/dist/core/hooks.d.ts.map +1 -0
  18. package/dist/core/hooks.js +267 -0
  19. package/dist/core/hooks.js.map +1 -0
  20. package/dist/core/metricsTracker.d.ts +122 -0
  21. package/dist/core/metricsTracker.d.ts.map +1 -0
  22. package/dist/{alpha-zero → core}/metricsTracker.js +2 -5
  23. package/dist/core/metricsTracker.js.map +1 -0
  24. package/dist/core/securityAssessment.d.ts +91 -0
  25. package/dist/core/securityAssessment.d.ts.map +1 -0
  26. package/dist/core/securityAssessment.js +580 -0
  27. package/dist/core/securityAssessment.js.map +1 -0
  28. package/dist/core/sessionStore.d.ts +2 -0
  29. package/dist/core/sessionStore.d.ts.map +1 -1
  30. package/dist/core/sessionStore.js +1 -0
  31. package/dist/core/sessionStore.js.map +1 -1
  32. package/dist/core/toolPreconditions.d.ts.map +1 -1
  33. package/dist/core/toolPreconditions.js +0 -14
  34. package/dist/core/toolPreconditions.js.map +1 -1
  35. package/dist/core/toolRuntime.d.ts +22 -1
  36. package/dist/core/toolRuntime.d.ts.map +1 -1
  37. package/dist/core/toolRuntime.js +0 -5
  38. package/dist/core/toolRuntime.js.map +1 -1
  39. package/dist/core/toolValidation.d.ts.map +1 -1
  40. package/dist/core/toolValidation.js +14 -3
  41. package/dist/core/toolValidation.js.map +1 -1
  42. package/dist/core/validationRunner.d.ts +1 -3
  43. package/dist/core/validationRunner.d.ts.map +1 -1
  44. package/dist/core/validationRunner.js.map +1 -1
  45. package/dist/core/verification.d.ts +137 -0
  46. package/dist/core/verification.d.ts.map +1 -0
  47. package/dist/core/verification.js +323 -0
  48. package/dist/core/verification.js.map +1 -0
  49. package/dist/headless/headlessApp.d.ts.map +1 -1
  50. package/dist/headless/headlessApp.js +21 -0
  51. package/dist/headless/headlessApp.js.map +1 -1
  52. package/dist/mcp/sseClient.d.ts.map +1 -1
  53. package/dist/mcp/sseClient.js +9 -18
  54. package/dist/mcp/sseClient.js.map +1 -1
  55. package/dist/plugins/tools/build/buildPlugin.d.ts +0 -6
  56. package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
  57. package/dist/plugins/tools/build/buildPlugin.js +4 -10
  58. package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
  59. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  60. package/dist/plugins/tools/nodeDefaults.js +0 -2
  61. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  62. package/dist/runtime/agentSession.d.ts +2 -2
  63. package/dist/runtime/agentSession.d.ts.map +1 -1
  64. package/dist/runtime/agentSession.js +2 -2
  65. package/dist/runtime/agentSession.js.map +1 -1
  66. package/dist/shell/interactiveShell.d.ts +41 -7
  67. package/dist/shell/interactiveShell.d.ts.map +1 -1
  68. package/dist/shell/interactiveShell.js +399 -166
  69. package/dist/shell/interactiveShell.js.map +1 -1
  70. package/dist/shell/shellApp.d.ts +2 -0
  71. package/dist/shell/shellApp.d.ts.map +1 -1
  72. package/dist/shell/shellApp.js +82 -9
  73. package/dist/shell/shellApp.js.map +1 -1
  74. package/dist/shell/systemPrompt.d.ts.map +1 -1
  75. package/dist/shell/systemPrompt.js +1 -4
  76. package/dist/shell/systemPrompt.js.map +1 -1
  77. package/dist/shell/terminalInput.d.ts +250 -125
  78. package/dist/shell/terminalInput.d.ts.map +1 -1
  79. package/dist/shell/terminalInput.js +1061 -612
  80. package/dist/shell/terminalInput.js.map +1 -1
  81. package/dist/shell/terminalInputAdapter.d.ts +106 -24
  82. package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
  83. package/dist/shell/terminalInputAdapter.js +137 -30
  84. package/dist/shell/terminalInputAdapter.js.map +1 -1
  85. package/dist/subagents/agentConfig.d.ts +27 -0
  86. package/dist/subagents/agentConfig.d.ts.map +1 -0
  87. package/dist/subagents/agentConfig.js +89 -0
  88. package/dist/subagents/agentConfig.js.map +1 -0
  89. package/dist/subagents/agentRegistry.d.ts +33 -0
  90. package/dist/subagents/agentRegistry.d.ts.map +1 -0
  91. package/dist/subagents/agentRegistry.js +162 -0
  92. package/dist/subagents/agentRegistry.js.map +1 -0
  93. package/dist/subagents/taskRunner.d.ts +7 -1
  94. package/dist/subagents/taskRunner.d.ts.map +1 -1
  95. package/dist/subagents/taskRunner.js +200 -49
  96. package/dist/subagents/taskRunner.js.map +1 -1
  97. package/dist/ui/ShellUIAdapter.d.ts +7 -1
  98. package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
  99. package/dist/ui/ShellUIAdapter.js +42 -18
  100. package/dist/ui/ShellUIAdapter.js.map +1 -1
  101. package/dist/ui/display.d.ts +24 -45
  102. package/dist/ui/display.d.ts.map +1 -1
  103. package/dist/ui/display.js +148 -274
  104. package/dist/ui/display.js.map +1 -1
  105. package/dist/ui/theme.d.ts.map +1 -1
  106. package/dist/ui/theme.js +6 -8
  107. package/dist/ui/theme.js.map +1 -1
  108. package/dist/ui/toolDisplay.d.ts +0 -158
  109. package/dist/ui/toolDisplay.d.ts.map +1 -1
  110. package/dist/ui/toolDisplay.js +0 -348
  111. package/dist/ui/toolDisplay.js.map +1 -1
  112. package/dist/ui/unified/layout.d.ts +20 -0
  113. package/dist/ui/unified/layout.d.ts.map +1 -1
  114. package/dist/ui/unified/layout.js +105 -216
  115. package/dist/ui/unified/layout.js.map +1 -1
  116. package/dist/utils/frontmatter.d.ts +10 -0
  117. package/dist/utils/frontmatter.d.ts.map +1 -0
  118. package/dist/utils/frontmatter.js +78 -0
  119. package/dist/utils/frontmatter.js.map +1 -0
  120. package/package.json +4 -4
  121. package/dist/alpha-zero/agentWrapper.d.ts +0 -84
  122. package/dist/alpha-zero/agentWrapper.d.ts.map +0 -1
  123. package/dist/alpha-zero/agentWrapper.js +0 -171
  124. package/dist/alpha-zero/agentWrapper.js.map +0 -1
  125. package/dist/alpha-zero/codeEvaluator.d.ts +0 -25
  126. package/dist/alpha-zero/codeEvaluator.d.ts.map +0 -1
  127. package/dist/alpha-zero/codeEvaluator.js +0 -273
  128. package/dist/alpha-zero/codeEvaluator.js.map +0 -1
  129. package/dist/alpha-zero/competitiveRunner.d.ts +0 -66
  130. package/dist/alpha-zero/competitiveRunner.d.ts.map +0 -1
  131. package/dist/alpha-zero/competitiveRunner.js +0 -224
  132. package/dist/alpha-zero/competitiveRunner.js.map +0 -1
  133. package/dist/alpha-zero/index.d.ts +0 -67
  134. package/dist/alpha-zero/index.d.ts.map +0 -1
  135. package/dist/alpha-zero/index.js +0 -99
  136. package/dist/alpha-zero/index.js.map +0 -1
  137. package/dist/alpha-zero/introspection.d.ts +0 -128
  138. package/dist/alpha-zero/introspection.d.ts.map +0 -1
  139. package/dist/alpha-zero/introspection.js +0 -300
  140. package/dist/alpha-zero/introspection.js.map +0 -1
  141. package/dist/alpha-zero/metricsTracker.d.ts +0 -71
  142. package/dist/alpha-zero/metricsTracker.d.ts.map +0 -1
  143. package/dist/alpha-zero/metricsTracker.js.map +0 -1
  144. package/dist/alpha-zero/security/core.d.ts +0 -125
  145. package/dist/alpha-zero/security/core.d.ts.map +0 -1
  146. package/dist/alpha-zero/security/core.js +0 -271
  147. package/dist/alpha-zero/security/core.js.map +0 -1
  148. package/dist/alpha-zero/security/google.d.ts +0 -125
  149. package/dist/alpha-zero/security/google.d.ts.map +0 -1
  150. package/dist/alpha-zero/security/google.js +0 -311
  151. package/dist/alpha-zero/security/google.js.map +0 -1
  152. package/dist/alpha-zero/security/googleLoader.d.ts +0 -17
  153. package/dist/alpha-zero/security/googleLoader.d.ts.map +0 -1
  154. package/dist/alpha-zero/security/googleLoader.js +0 -41
  155. package/dist/alpha-zero/security/googleLoader.js.map +0 -1
  156. package/dist/alpha-zero/security/index.d.ts +0 -29
  157. package/dist/alpha-zero/security/index.d.ts.map +0 -1
  158. package/dist/alpha-zero/security/index.js +0 -32
  159. package/dist/alpha-zero/security/index.js.map +0 -1
  160. package/dist/alpha-zero/security/simulation.d.ts +0 -124
  161. package/dist/alpha-zero/security/simulation.d.ts.map +0 -1
  162. package/dist/alpha-zero/security/simulation.js +0 -277
  163. package/dist/alpha-zero/security/simulation.js.map +0 -1
  164. package/dist/alpha-zero/selfModification.d.ts +0 -109
  165. package/dist/alpha-zero/selfModification.d.ts.map +0 -1
  166. package/dist/alpha-zero/selfModification.js +0 -233
  167. package/dist/alpha-zero/selfModification.js.map +0 -1
  168. package/dist/alpha-zero/types.d.ts +0 -170
  169. package/dist/alpha-zero/types.d.ts.map +0 -1
  170. package/dist/alpha-zero/types.js +0 -31
  171. package/dist/alpha-zero/types.js.map +0 -1
  172. package/dist/capabilities/securityTestingCapability.d.ts +0 -13
  173. package/dist/capabilities/securityTestingCapability.d.ts.map +0 -1
  174. package/dist/capabilities/securityTestingCapability.js +0 -25
  175. package/dist/capabilities/securityTestingCapability.js.map +0 -1
  176. package/dist/core/aiFlowOptimizer.d.ts +0 -26
  177. package/dist/core/aiFlowOptimizer.d.ts.map +0 -1
  178. package/dist/core/aiFlowOptimizer.js +0 -31
  179. package/dist/core/aiFlowOptimizer.js.map +0 -1
  180. package/dist/core/aiOptimizationEngine.d.ts +0 -158
  181. package/dist/core/aiOptimizationEngine.d.ts.map +0 -1
  182. package/dist/core/aiOptimizationEngine.js +0 -428
  183. package/dist/core/aiOptimizationEngine.js.map +0 -1
  184. package/dist/core/aiOptimizationIntegration.d.ts +0 -93
  185. package/dist/core/aiOptimizationIntegration.d.ts.map +0 -1
  186. package/dist/core/aiOptimizationIntegration.js +0 -250
  187. package/dist/core/aiOptimizationIntegration.js.map +0 -1
  188. package/dist/core/enhancedErrorRecovery.d.ts +0 -100
  189. package/dist/core/enhancedErrorRecovery.d.ts.map +0 -1
  190. package/dist/core/enhancedErrorRecovery.js +0 -345
  191. package/dist/core/enhancedErrorRecovery.js.map +0 -1
  192. package/dist/core/hooksSystem.d.ts +0 -65
  193. package/dist/core/hooksSystem.d.ts.map +0 -1
  194. package/dist/core/hooksSystem.js +0 -273
  195. package/dist/core/hooksSystem.js.map +0 -1
  196. package/dist/core/memorySystem.d.ts +0 -48
  197. package/dist/core/memorySystem.d.ts.map +0 -1
  198. package/dist/core/memorySystem.js +0 -271
  199. package/dist/core/memorySystem.js.map +0 -1
  200. package/dist/core/unified/errors.d.ts +0 -189
  201. package/dist/core/unified/errors.d.ts.map +0 -1
  202. package/dist/core/unified/errors.js +0 -497
  203. package/dist/core/unified/errors.js.map +0 -1
  204. package/dist/core/unified/index.d.ts +0 -19
  205. package/dist/core/unified/index.d.ts.map +0 -1
  206. package/dist/core/unified/index.js +0 -68
  207. package/dist/core/unified/index.js.map +0 -1
  208. package/dist/core/unified/schema.d.ts +0 -101
  209. package/dist/core/unified/schema.d.ts.map +0 -1
  210. package/dist/core/unified/schema.js +0 -350
  211. package/dist/core/unified/schema.js.map +0 -1
  212. package/dist/core/unified/toolRuntime.d.ts +0 -179
  213. package/dist/core/unified/toolRuntime.d.ts.map +0 -1
  214. package/dist/core/unified/toolRuntime.js +0 -517
  215. package/dist/core/unified/toolRuntime.js.map +0 -1
  216. package/dist/core/unified/tools.d.ts +0 -127
  217. package/dist/core/unified/tools.d.ts.map +0 -1
  218. package/dist/core/unified/tools.js +0 -1333
  219. package/dist/core/unified/tools.js.map +0 -1
  220. package/dist/core/unified/types.d.ts +0 -352
  221. package/dist/core/unified/types.d.ts.map +0 -1
  222. package/dist/core/unified/types.js +0 -12
  223. package/dist/core/unified/types.js.map +0 -1
  224. package/dist/core/unified/version.d.ts +0 -209
  225. package/dist/core/unified/version.d.ts.map +0 -1
  226. package/dist/core/unified/version.js +0 -454
  227. package/dist/core/unified/version.js.map +0 -1
  228. package/dist/plugins/tools/security/securityPlugin.d.ts +0 -3
  229. package/dist/plugins/tools/security/securityPlugin.d.ts.map +0 -1
  230. package/dist/plugins/tools/security/securityPlugin.js +0 -12
  231. package/dist/plugins/tools/security/securityPlugin.js.map +0 -1
  232. package/dist/security/active-stack-security.d.ts +0 -112
  233. package/dist/security/active-stack-security.d.ts.map +0 -1
  234. package/dist/security/active-stack-security.js +0 -296
  235. package/dist/security/active-stack-security.js.map +0 -1
  236. package/dist/security/advanced-persistence-research.d.ts +0 -92
  237. package/dist/security/advanced-persistence-research.d.ts.map +0 -1
  238. package/dist/security/advanced-persistence-research.js +0 -195
  239. package/dist/security/advanced-persistence-research.js.map +0 -1
  240. package/dist/security/advanced-targeting.d.ts +0 -119
  241. package/dist/security/advanced-targeting.d.ts.map +0 -1
  242. package/dist/security/advanced-targeting.js +0 -233
  243. package/dist/security/advanced-targeting.js.map +0 -1
  244. package/dist/security/assessment/vulnerabilityAssessment.d.ts +0 -104
  245. package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +0 -1
  246. package/dist/security/assessment/vulnerabilityAssessment.js +0 -315
  247. package/dist/security/assessment/vulnerabilityAssessment.js.map +0 -1
  248. package/dist/security/authorization/securityAuthorization.d.ts +0 -88
  249. package/dist/security/authorization/securityAuthorization.d.ts.map +0 -1
  250. package/dist/security/authorization/securityAuthorization.js +0 -172
  251. package/dist/security/authorization/securityAuthorization.js.map +0 -1
  252. package/dist/security/comprehensive-targeting.d.ts +0 -85
  253. package/dist/security/comprehensive-targeting.d.ts.map +0 -1
  254. package/dist/security/comprehensive-targeting.js +0 -438
  255. package/dist/security/comprehensive-targeting.js.map +0 -1
  256. package/dist/security/global-security-integration.d.ts +0 -91
  257. package/dist/security/global-security-integration.d.ts.map +0 -1
  258. package/dist/security/global-security-integration.js +0 -218
  259. package/dist/security/global-security-integration.js.map +0 -1
  260. package/dist/security/index.d.ts +0 -38
  261. package/dist/security/index.d.ts.map +0 -1
  262. package/dist/security/index.js +0 -47
  263. package/dist/security/index.js.map +0 -1
  264. package/dist/security/persistence-analyzer.d.ts +0 -56
  265. package/dist/security/persistence-analyzer.d.ts.map +0 -1
  266. package/dist/security/persistence-analyzer.js +0 -187
  267. package/dist/security/persistence-analyzer.js.map +0 -1
  268. package/dist/security/persistence-cli.d.ts +0 -36
  269. package/dist/security/persistence-cli.d.ts.map +0 -1
  270. package/dist/security/persistence-cli.js +0 -160
  271. package/dist/security/persistence-cli.js.map +0 -1
  272. package/dist/security/persistence-research.d.ts +0 -92
  273. package/dist/security/persistence-research.d.ts.map +0 -1
  274. package/dist/security/persistence-research.js +0 -364
  275. package/dist/security/persistence-research.js.map +0 -1
  276. package/dist/security/research/persistenceResearch.d.ts +0 -97
  277. package/dist/security/research/persistenceResearch.d.ts.map +0 -1
  278. package/dist/security/research/persistenceResearch.js +0 -282
  279. package/dist/security/research/persistenceResearch.js.map +0 -1
  280. package/dist/security/security-integration.d.ts +0 -74
  281. package/dist/security/security-integration.d.ts.map +0 -1
  282. package/dist/security/security-integration.js +0 -137
  283. package/dist/security/security-integration.js.map +0 -1
  284. package/dist/security/security-testing-framework.d.ts +0 -112
  285. package/dist/security/security-testing-framework.d.ts.map +0 -1
  286. package/dist/security/security-testing-framework.js +0 -364
  287. package/dist/security/security-testing-framework.js.map +0 -1
  288. package/dist/security/simulation/attackSimulation.d.ts +0 -93
  289. package/dist/security/simulation/attackSimulation.d.ts.map +0 -1
  290. package/dist/security/simulation/attackSimulation.js +0 -341
  291. package/dist/security/simulation/attackSimulation.js.map +0 -1
  292. package/dist/security/strategic-operations.d.ts +0 -100
  293. package/dist/security/strategic-operations.d.ts.map +0 -1
  294. package/dist/security/strategic-operations.js +0 -276
  295. package/dist/security/strategic-operations.js.map +0 -1
  296. package/dist/security/tool-security-wrapper.d.ts +0 -58
  297. package/dist/security/tool-security-wrapper.d.ts.map +0 -1
  298. package/dist/security/tool-security-wrapper.js +0 -156
  299. package/dist/security/tool-security-wrapper.js.map +0 -1
  300. package/dist/shell/claudeCodeStreamHandler.d.ts +0 -145
  301. package/dist/shell/claudeCodeStreamHandler.d.ts.map +0 -1
  302. package/dist/shell/claudeCodeStreamHandler.js +0 -322
  303. package/dist/shell/claudeCodeStreamHandler.js.map +0 -1
  304. package/dist/shell/inputQueueManager.d.ts +0 -144
  305. package/dist/shell/inputQueueManager.d.ts.map +0 -1
  306. package/dist/shell/inputQueueManager.js +0 -290
  307. package/dist/shell/inputQueueManager.js.map +0 -1
  308. package/dist/shell/metricsTracker.d.ts +0 -60
  309. package/dist/shell/metricsTracker.d.ts.map +0 -1
  310. package/dist/shell/metricsTracker.js +0 -119
  311. package/dist/shell/metricsTracker.js.map +0 -1
  312. package/dist/shell/streamingOutputManager.d.ts +0 -115
  313. package/dist/shell/streamingOutputManager.d.ts.map +0 -1
  314. package/dist/shell/streamingOutputManager.js +0 -225
  315. package/dist/shell/streamingOutputManager.js.map +0 -1
  316. package/dist/tools/securityTools.d.ts +0 -22
  317. package/dist/tools/securityTools.d.ts.map +0 -1
  318. package/dist/tools/securityTools.js +0 -448
  319. package/dist/tools/securityTools.js.map +0 -1
  320. package/dist/ui/persistentPrompt.d.ts +0 -50
  321. package/dist/ui/persistentPrompt.d.ts.map +0 -1
  322. package/dist/ui/persistentPrompt.js +0 -92
  323. package/dist/ui/persistentPrompt.js.map +0 -1
  324. package/dist/ui/terminalUISchema.d.ts +0 -195
  325. package/dist/ui/terminalUISchema.d.ts.map +0 -1
  326. package/dist/ui/terminalUISchema.js +0 -113
  327. package/dist/ui/terminalUISchema.js.map +0 -1
  328. package/scripts/deploy-security-capabilities.js +0 -178
@@ -1,322 +0,0 @@
1
- /**
2
- * ClaudeCodeStreamHandler - Complete streaming I/O handler following Claude Code's approach
3
- *
4
- * This module combines StreamingOutputManager and InputQueueManager to provide
5
- * the complete Claude Code streaming experience:
6
- *
7
- * 1. Natural Output Flow
8
- * - Streaming output just writes to stdout normally
9
- * - Cursor stays where it is after each write
10
- * - Lines scroll up naturally as new content appears
11
- * - NO scroll regions, NO save/restore cursor during streaming
12
- *
13
- * 2. Readline Handles Input
14
- * - Uses Node.js readline module
15
- * - Input prompt naturally moves up as output streams above it
16
- * - User can type while streaming - input is queued in memory, not rendered
17
- *
18
- * 3. Queue-Based Approach
19
- * User types during streaming → Input stored in queue → Processed after streaming ends
20
- *
21
- * 4. The Key Insight
22
- * The cursor is NEVER moved during streaming. Output just appends at current position.
23
- * The "input at bottom" effect comes from:
24
- * - New output pushes older content (including the prompt) upward
25
- * - After streaming ends, a new prompt is shown at the bottom
26
- */
27
- import * as readline from 'node:readline';
28
- import { EventEmitter } from 'node:events';
29
- import { getStreamingOutputManager } from './streamingOutputManager.js';
30
- import { getInputQueueManager } from './inputQueueManager.js';
31
- import { writeLock } from '../ui/writeLock.js';
32
- /**
33
- * Coordinates streaming output and queued input for Claude Code style UX.
34
- */
35
- export class ClaudeCodeStreamHandler extends EventEmitter {
36
- outputManager;
37
- inputManager;
38
- writeStream;
39
- readStream;
40
- rl = null;
41
- keypressHandler = null;
42
- originalStdoutWrite = null;
43
- isOutputSuppressed = false;
44
- constructor(writeStream = process.stdout, readStream = process.stdin) {
45
- super();
46
- this.writeStream = writeStream;
47
- this.readStream = readStream;
48
- this.outputManager = getStreamingOutputManager();
49
- this.inputManager = getInputQueueManager();
50
- // Forward events
51
- this.inputManager.on('input-queued', (input) => {
52
- this.emit('input-queued', input);
53
- });
54
- }
55
- /**
56
- * Attach to an existing readline interface
57
- * Call this after creating your readline.Interface
58
- */
59
- attachToReadline(rl) {
60
- this.rl = rl;
61
- this.setupKeypressCapture();
62
- }
63
- /**
64
- * Set up keypress capturing for queued input during streaming
65
- */
66
- setupKeypressCapture() {
67
- if (!this.readStream || !this.readStream.isTTY) {
68
- return;
69
- }
70
- // Enable keypress events if not already enabled
71
- if (this.readStream.listenerCount('keypress') === 0 && this.rl) {
72
- readline.emitKeypressEvents(this.readStream, this.rl);
73
- }
74
- // Ensure raw mode for keypress events
75
- if (this.readStream.setRawMode && !this.readStream.isRaw) {
76
- this.readStream.setRawMode(true);
77
- }
78
- this.keypressHandler = (_str, key) => {
79
- // Only capture when streaming
80
- if (!this.outputManager.isStreaming() || !this.inputManager.isCapturing()) {
81
- return;
82
- }
83
- // Handle special keys
84
- if (key) {
85
- // Ctrl+C - interrupt
86
- if (key.ctrl && key.name === 'c') {
87
- this.inputManager.handleInterrupt();
88
- return;
89
- }
90
- // Enter - submit queued input
91
- if (key.name === 'return' || key.name === 'enter') {
92
- this.inputManager.handleSubmit();
93
- return;
94
- }
95
- // Backspace
96
- if (key.name === 'backspace') {
97
- this.inputManager.handleBackspace();
98
- return;
99
- }
100
- // Delete
101
- if (key.name === 'delete') {
102
- this.inputManager.handleDelete();
103
- return;
104
- }
105
- // Arrow keys
106
- if (key.name === 'left') {
107
- this.inputManager.handleCursorLeft();
108
- return;
109
- }
110
- if (key.name === 'right') {
111
- this.inputManager.handleCursorRight();
112
- return;
113
- }
114
- // Ignore other control sequences during capture
115
- if (key.ctrl || key.meta) {
116
- return;
117
- }
118
- }
119
- // Regular character input
120
- if (_str && _str.length > 0 && !key?.ctrl && !key?.meta) {
121
- this.inputManager.handleChar(_str);
122
- }
123
- };
124
- this.readStream.prependListener('keypress', this.keypressHandler);
125
- }
126
- /**
127
- * Begin streaming mode
128
- *
129
- * Claude Code approach:
130
- * - Start capturing input to queue
131
- * - Suppress readline echo (characters typed go to queue, not screen)
132
- * - Output flows naturally to stdout
133
- */
134
- startStreaming() {
135
- if (this.outputManager.isStreaming()) {
136
- return;
137
- }
138
- // Start both managers
139
- this.outputManager.startStream();
140
- this.inputManager.startCapturing();
141
- // Suppress readline's output so typed characters don't appear
142
- this.suppressReadlineOutput();
143
- this.emit('streaming-start');
144
- }
145
- /**
146
- * End streaming mode
147
- *
148
- * Claude Code approach:
149
- * - Stop capturing (any remaining buffer is preserved)
150
- * - Restore readline echo
151
- * - Return streaming statistics
152
- */
153
- endStreaming() {
154
- // Get remaining buffer before stopping capture
155
- const remainingBuffer = this.inputManager.stopCapturing();
156
- // If there's unsubmitted content in buffer, preserve it for next prompt
157
- if (remainingBuffer && remainingBuffer.trim()) {
158
- // The remaining buffer will be shown when readline prompts again
159
- // We could queue it, but leaving it as-is is more intuitive
160
- }
161
- // Restore readline output
162
- this.restoreReadlineOutput();
163
- // End output streaming
164
- const stats = this.outputManager.endStream();
165
- const result = {
166
- ...stats,
167
- queuedInputs: this.inputManager.getQueueLength(),
168
- };
169
- this.emit('streaming-end', stats);
170
- return result;
171
- }
172
- /**
173
- * Write content during streaming
174
- * Just writes naturally to stdout - no cursor manipulation
175
- */
176
- write(content) {
177
- this.outputManager.writeChunk(content);
178
- }
179
- /**
180
- * Write a complete line during streaming
181
- */
182
- writeLine(line = '') {
183
- this.outputManager.writeLine(line);
184
- }
185
- /**
186
- * Check if currently streaming
187
- */
188
- isStreaming() {
189
- return this.outputManager.isStreaming();
190
- }
191
- /**
192
- * Get current state
193
- */
194
- getState() {
195
- const outputStats = this.outputManager.getStats();
196
- return {
197
- isStreaming: this.outputManager.isStreaming(),
198
- queuedCount: this.inputManager.getQueueLength(),
199
- charsWritten: outputStats.chars,
200
- linesWritten: outputStats.lines,
201
- elapsedMs: outputStats.elapsed,
202
- };
203
- }
204
- /**
205
- * Check if there are queued inputs to process
206
- */
207
- hasQueuedInput() {
208
- return this.inputManager.hasQueuedInput();
209
- }
210
- /**
211
- * Get the next queued input
212
- */
213
- getNextQueuedInput() {
214
- return this.inputManager.dequeue();
215
- }
216
- /**
217
- * Get all queued inputs
218
- */
219
- getAllQueuedInputs() {
220
- return this.inputManager.getQueue();
221
- }
222
- /**
223
- * Clear all queued inputs
224
- */
225
- clearQueue() {
226
- this.inputManager.clearQueue();
227
- }
228
- /**
229
- * Get queue summary for display
230
- */
231
- getQueueSummary() {
232
- return this.inputManager.getQueueSummary();
233
- }
234
- /**
235
- * Suppress readline's output during streaming
236
- * Characters typed will be captured but not displayed
237
- */
238
- suppressReadlineOutput() {
239
- if (this.isOutputSuppressed) {
240
- return;
241
- }
242
- // Save original write function
243
- this.originalStdoutWrite = this.writeStream.write.bind(this.writeStream);
244
- // Replace with filtered version that suppresses readline echo
245
- const outputManager = this.outputManager;
246
- const originalWrite = this.originalStdoutWrite;
247
- this.writeStream.write = function (chunk, encodingOrCallback, callback) {
248
- const text = typeof chunk === 'string' ? chunk : chunk.toString();
249
- // During streaming, only allow output from the streaming manager
250
- // Suppress readline's echo of typed characters (single character writes)
251
- if (outputManager.isStreaming()) {
252
- // Allow newlines and multi-character writes (likely streaming content)
253
- if (text.length === 1 && !text.includes('\n') && !text.includes('\r')) {
254
- // Single character during streaming - likely user typing, suppress it
255
- if (typeof encodingOrCallback === 'function') {
256
- encodingOrCallback(null);
257
- return true;
258
- }
259
- if (callback) {
260
- callback(null);
261
- }
262
- return true;
263
- }
264
- }
265
- // Pass through everything else
266
- // If lock is already held, write directly - we're in a protected context
267
- // This prevents queuing issues where content gets delayed during streaming
268
- if (writeLock.isLocked()) {
269
- return originalWrite(chunk, encodingOrCallback, callback);
270
- }
271
- let result = true;
272
- writeLock.withLock(() => {
273
- result = originalWrite(chunk, encodingOrCallback, callback);
274
- }, 'claudeCodeStreamHandler.stdout');
275
- return result;
276
- };
277
- this.isOutputSuppressed = true;
278
- }
279
- /**
280
- * Restore readline's normal output
281
- */
282
- restoreReadlineOutput() {
283
- if (!this.isOutputSuppressed || !this.originalStdoutWrite) {
284
- return;
285
- }
286
- this.writeStream.write = this.originalStdoutWrite;
287
- this.originalStdoutWrite = null;
288
- this.isOutputSuppressed = false;
289
- }
290
- /**
291
- * Cleanup when done
292
- */
293
- dispose() {
294
- // Restore output if suppressed
295
- this.restoreReadlineOutput();
296
- // Remove keypress handler
297
- if (this.keypressHandler && this.readStream) {
298
- this.readStream.off('keypress', this.keypressHandler);
299
- this.keypressHandler = null;
300
- }
301
- // Clear queue
302
- this.inputManager.clearQueue();
303
- this.rl = null;
304
- }
305
- }
306
- /**
307
- * Singleton instance for global use
308
- */
309
- let globalInstance = null;
310
- export function getClaudeCodeStreamHandler() {
311
- if (!globalInstance) {
312
- globalInstance = new ClaudeCodeStreamHandler();
313
- }
314
- return globalInstance;
315
- }
316
- export function resetClaudeCodeStreamHandler() {
317
- if (globalInstance) {
318
- globalInstance.dispose();
319
- }
320
- globalInstance = null;
321
- }
322
- //# sourceMappingURL=claudeCodeStreamHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claudeCodeStreamHandler.js","sourceRoot":"","sources":["../../src/shell/claudeCodeStreamHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAA0B,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EAAqB,oBAAoB,EAAoB,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAiB/C;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,YAAY;IACtC,aAAa,CAAyB;IACtC,YAAY,CAAoB;IAChC,WAAW,CAAqB;IAChC,UAAU,CAAoB;IAEvC,EAAE,GAA8B,IAAI,CAAC;IACrC,eAAe,GAAsD,IAAI,CAAC;IAC1E,mBAAmB,GAAuC,IAAI,CAAC;IAC/D,kBAAkB,GAAG,KAAK,CAAC;IAEnC,YACE,cAAkC,OAAO,CAAC,MAAM,EAChD,aAAgC,OAAO,CAAC,KAAK;QAE7C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- * Key principles from Claude Code:
5
- * 1. Readline handles input - Uses Node.js readline module
6
- * 2. User can type while streaming - Input is queued in memory, not rendered
7
- * 3. Queue-based approach: User types → stored in queue → processed after streaming ends
8
- *
9
- * The key insight is that the cursor is never moved during streaming.
10
- * Input is captured "invisibly" while streaming, then processed when streaming ends.
11
- */
12
- import { EventEmitter } from 'node:events';
13
- export interface QueuedInput {
14
- id: string;
15
- text: string;
16
- timestamp: number;
17
- type: 'message' | 'command' | 'interrupt';
18
- }
19
- export interface InputQueueState {
20
- isCapturing: boolean;
21
- buffer: string;
22
- cursorPosition: number;
23
- queue: QueuedInput[];
24
- }
25
- export interface InputQueueEvents {
26
- 'input-queued': (input: QueuedInput) => void;
27
- 'input-processed': (input: QueuedInput) => void;
28
- 'queue-cleared': () => void;
29
- 'capture-start': () => void;
30
- 'capture-end': () => void;
31
- }
32
- /**
33
- * Manages input queuing during streaming output.
34
- *
35
- * When streaming is active:
36
- * - Captures keystrokes into a buffer
37
- * - On Enter, queues the input for later processing
38
- * - Provides methods to process queue after streaming ends
39
- */
40
- export declare class InputQueueManager extends EventEmitter {
41
- private state;
42
- private inputIdCounter;
43
- private readonly maxQueueSize;
44
- private readonly maxBufferLength;
45
- constructor(options?: {
46
- maxQueueSize?: number;
47
- maxBufferLength?: number;
48
- });
49
- /**
50
- * Start capturing input (during streaming)
51
- * Input will be buffered and queued, not immediately processed
52
- */
53
- startCapturing(): void;
54
- /**
55
- * Stop capturing input (after streaming ends)
56
- * Returns any remaining buffer content
57
- */
58
- stopCapturing(): string;
59
- /**
60
- * Check if currently capturing input
61
- */
62
- isCapturing(): boolean;
63
- /**
64
- * Handle a character input
65
- * During capturing, adds to buffer; otherwise ignored
66
- */
67
- handleChar(char: string): void;
68
- /**
69
- * Handle backspace
70
- */
71
- handleBackspace(): void;
72
- /**
73
- * Handle delete key
74
- */
75
- handleDelete(): void;
76
- /**
77
- * Handle cursor left
78
- */
79
- handleCursorLeft(): void;
80
- /**
81
- * Handle cursor right
82
- */
83
- handleCursorRight(): void;
84
- /**
85
- * Handle Enter - queue the current buffer
86
- * Returns the queued input or null if buffer was empty
87
- */
88
- handleSubmit(): QueuedInput | null;
89
- /**
90
- * Handle Ctrl+C during capture - queue an interrupt
91
- */
92
- handleInterrupt(): QueuedInput;
93
- /**
94
- * Get current buffer contents (for display purposes)
95
- */
96
- getBuffer(): string;
97
- /**
98
- * Get current cursor position
99
- */
100
- getCursorPosition(): number;
101
- /**
102
- * Get the number of queued inputs
103
- */
104
- getQueueLength(): number;
105
- /**
106
- * Check if there are queued inputs
107
- */
108
- hasQueuedInput(): boolean;
109
- /**
110
- * Get the next queued input without removing it
111
- */
112
- peekQueue(): QueuedInput | undefined;
113
- /**
114
- * Get and remove the next queued input
115
- */
116
- dequeue(): QueuedInput | undefined;
117
- /**
118
- * Get all queued inputs (copy)
119
- */
120
- getQueue(): QueuedInput[];
121
- /**
122
- * Clear all queued inputs
123
- */
124
- clearQueue(): void;
125
- /**
126
- * Clear the current buffer
127
- */
128
- clearBuffer(): void;
129
- /**
130
- * Set the buffer content directly (for paste handling)
131
- */
132
- setBuffer(content: string, cursorPos?: number): void;
133
- /**
134
- * Get queue summary for display
135
- */
136
- getQueueSummary(): string;
137
- /**
138
- * Get full state (for debugging)
139
- */
140
- getState(): InputQueueState;
141
- }
142
- export declare function getInputQueueManager(): InputQueueManager;
143
- export declare function resetInputQueueManager(): void;
144
- //# sourceMappingURL=inputQueueManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inputQueueManager.d.ts","sourceRoot":"","sources":["../../src/shell/inputQueueManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,WA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