openhorse 0.1.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 (587) hide show
  1. package/README.md +460 -0
  2. package/bin/openhorse +56 -0
  3. package/dist/agents/coder.d.ts +12 -0
  4. package/dist/agents/coder.d.ts.map +1 -0
  5. package/dist/agents/coder.js +48 -0
  6. package/dist/agents/coder.js.map +1 -0
  7. package/dist/agents/leader.d.ts +12 -0
  8. package/dist/agents/leader.d.ts.map +1 -0
  9. package/dist/agents/leader.js +49 -0
  10. package/dist/agents/leader.js.map +1 -0
  11. package/dist/agents/router.d.ts +59 -0
  12. package/dist/agents/router.d.ts.map +1 -0
  13. package/dist/agents/router.js +193 -0
  14. package/dist/agents/router.js.map +1 -0
  15. package/dist/cli-ink.d.ts +7 -0
  16. package/dist/cli-ink.d.ts.map +1 -0
  17. package/dist/cli-ink.js +135 -0
  18. package/dist/cli-ink.js.map +1 -0
  19. package/dist/cli.d.ts +7 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +638 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/commands/index.d.ts +12 -0
  24. package/dist/commands/index.d.ts.map +1 -0
  25. package/dist/commands/index.js +1095 -0
  26. package/dist/commands/index.js.map +1 -0
  27. package/dist/commands/parser.d.ts +26 -0
  28. package/dist/commands/parser.d.ts.map +1 -0
  29. package/dist/commands/parser.js +61 -0
  30. package/dist/commands/parser.js.map +1 -0
  31. package/dist/commands/types.d.ts +61 -0
  32. package/dist/commands/types.d.ts.map +1 -0
  33. package/dist/commands/types.js +32 -0
  34. package/dist/commands/types.js.map +1 -0
  35. package/dist/core/agent.d.ts +66 -0
  36. package/dist/core/agent.d.ts.map +1 -0
  37. package/dist/core/agent.js +55 -0
  38. package/dist/core/agent.js.map +1 -0
  39. package/dist/core/brain.d.ts +41 -0
  40. package/dist/core/brain.d.ts.map +1 -0
  41. package/dist/core/brain.js +92 -0
  42. package/dist/core/brain.js.map +1 -0
  43. package/dist/core/cost-tracker.d.ts +107 -0
  44. package/dist/core/cost-tracker.d.ts.map +1 -0
  45. package/dist/core/cost-tracker.js +199 -0
  46. package/dist/core/cost-tracker.js.map +1 -0
  47. package/dist/core/strategy-tracker.d.ts +61 -0
  48. package/dist/core/strategy-tracker.d.ts.map +1 -0
  49. package/dist/core/strategy-tracker.js +124 -0
  50. package/dist/core/strategy-tracker.js.map +1 -0
  51. package/dist/framework/index.d.ts +20 -0
  52. package/dist/framework/index.d.ts.map +1 -0
  53. package/dist/framework/index.js +29 -0
  54. package/dist/framework/index.js.map +1 -0
  55. package/dist/framework/prompt.d.ts +40 -0
  56. package/dist/framework/prompt.d.ts.map +1 -0
  57. package/dist/framework/prompt.js +112 -0
  58. package/dist/framework/prompt.js.map +1 -0
  59. package/dist/framework/query.d.ts +86 -0
  60. package/dist/framework/query.d.ts.map +1 -0
  61. package/dist/framework/query.js +177 -0
  62. package/dist/framework/query.js.map +1 -0
  63. package/dist/framework/store.d.ts +64 -0
  64. package/dist/framework/store.d.ts.map +1 -0
  65. package/dist/framework/store.js +78 -0
  66. package/dist/framework/store.js.map +1 -0
  67. package/dist/framework/tool-state.d.ts +22 -0
  68. package/dist/framework/tool-state.d.ts.map +1 -0
  69. package/dist/framework/tool-state.js +40 -0
  70. package/dist/framework/tool-state.js.map +1 -0
  71. package/dist/framework/tool.d.ts +88 -0
  72. package/dist/framework/tool.d.ts.map +1 -0
  73. package/dist/framework/tool.js +60 -0
  74. package/dist/framework/tool.js.map +1 -0
  75. package/dist/harness/harness.d.ts +96 -0
  76. package/dist/harness/harness.d.ts.map +1 -0
  77. package/dist/harness/harness.js +224 -0
  78. package/dist/harness/harness.js.map +1 -0
  79. package/dist/harness/safety.d.ts +89 -0
  80. package/dist/harness/safety.d.ts.map +1 -0
  81. package/dist/harness/safety.js +178 -0
  82. package/dist/harness/safety.js.map +1 -0
  83. package/dist/index.d.ts +30 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +57 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/init.d.ts +178 -0
  88. package/dist/init.d.ts.map +1 -0
  89. package/dist/init.js +473 -0
  90. package/dist/init.js.map +1 -0
  91. package/dist/ink/bidi.d.ts +16 -0
  92. package/dist/ink/bidi.d.ts.map +1 -0
  93. package/dist/ink/bidi.js +124 -0
  94. package/dist/ink/bidi.js.map +1 -0
  95. package/dist/ink/clearTerminal.d.ts +14 -0
  96. package/dist/ink/clearTerminal.d.ts.map +1 -0
  97. package/dist/ink/clearTerminal.js +63 -0
  98. package/dist/ink/clearTerminal.js.map +1 -0
  99. package/dist/ink/colorize.d.ts +17 -0
  100. package/dist/ink/colorize.d.ts.map +1 -0
  101. package/dist/ink/colorize.js +208 -0
  102. package/dist/ink/colorize.js.map +1 -0
  103. package/dist/ink/components/App.d.ts +73 -0
  104. package/dist/ink/components/App.d.ts.map +1 -0
  105. package/dist/ink/components/App.js +646 -0
  106. package/dist/ink/components/App.js.map +1 -0
  107. package/dist/ink/components/AppContext.d.ts +12 -0
  108. package/dist/ink/components/AppContext.d.ts.map +1 -0
  109. package/dist/ink/components/AppContext.js +14 -0
  110. package/dist/ink/components/AppContext.js.map +1 -0
  111. package/dist/ink/components/Box.d.ts +44 -0
  112. package/dist/ink/components/Box.d.ts.map +1 -0
  113. package/dist/ink/components/Box.js +191 -0
  114. package/dist/ink/components/Box.js.map +1 -0
  115. package/dist/ink/components/ClockContext.d.ts +9 -0
  116. package/dist/ink/components/ClockContext.d.ts.map +1 -0
  117. package/dist/ink/components/ClockContext.js +146 -0
  118. package/dist/ink/components/ClockContext.js.map +1 -0
  119. package/dist/ink/components/CursorDeclarationContext.d.ts +23 -0
  120. package/dist/ink/components/CursorDeclarationContext.d.ts.map +1 -0
  121. package/dist/ink/components/CursorDeclarationContext.js +6 -0
  122. package/dist/ink/components/CursorDeclarationContext.js.map +1 -0
  123. package/dist/ink/components/ErrorOverview.d.ts +6 -0
  124. package/dist/ink/components/ErrorOverview.d.ts.map +1 -0
  125. package/dist/ink/components/ErrorOverview.js +27 -0
  126. package/dist/ink/components/ErrorOverview.js.map +1 -0
  127. package/dist/ink/components/Newline.d.ts +13 -0
  128. package/dist/ink/components/Newline.d.ts.map +1 -0
  129. package/dist/ink/components/Newline.js +36 -0
  130. package/dist/ink/components/Newline.js.map +1 -0
  131. package/dist/ink/components/NoSelect.d.ts +20 -0
  132. package/dist/ink/components/NoSelect.d.ts.map +1 -0
  133. package/dist/ink/components/NoSelect.js +63 -0
  134. package/dist/ink/components/NoSelect.js.map +1 -0
  135. package/dist/ink/components/RawAnsi.d.ts +17 -0
  136. package/dist/ink/components/RawAnsi.d.ts.map +1 -0
  137. package/dist/ink/components/RawAnsi.js +52 -0
  138. package/dist/ink/components/RawAnsi.js.map +1 -0
  139. package/dist/ink/components/Spacer.d.ts +6 -0
  140. package/dist/ink/components/Spacer.d.ts.map +1 -0
  141. package/dist/ink/components/Spacer.js +26 -0
  142. package/dist/ink/components/Spacer.js.map +1 -0
  143. package/dist/ink/components/StdinContext.d.ts +28 -0
  144. package/dist/ink/components/StdinContext.d.ts.map +1 -0
  145. package/dist/ink/components/StdinContext.js +19 -0
  146. package/dist/ink/components/StdinContext.js.map +1 -0
  147. package/dist/ink/components/TerminalFocusContext.d.ts +10 -0
  148. package/dist/ink/components/TerminalFocusContext.d.ts.map +1 -0
  149. package/dist/ink/components/TerminalFocusContext.js +81 -0
  150. package/dist/ink/components/TerminalFocusContext.js.map +1 -0
  151. package/dist/ink/components/TerminalSizeContext.d.ts +6 -0
  152. package/dist/ink/components/TerminalSizeContext.d.ts.map +1 -0
  153. package/dist/ink/components/TerminalSizeContext.js +6 -0
  154. package/dist/ink/components/TerminalSizeContext.js.map +1 -0
  155. package/dist/ink/components/Text.d.ts +56 -0
  156. package/dist/ink/components/Text.d.ts.map +1 -0
  157. package/dist/ink/components/Text.js +201 -0
  158. package/dist/ink/components/Text.js.map +1 -0
  159. package/dist/ink/constants.d.ts +2 -0
  160. package/dist/ink/constants.d.ts.map +1 -0
  161. package/dist/ink/constants.js +6 -0
  162. package/dist/ink/constants.js.map +1 -0
  163. package/dist/ink/devtools.d.ts +3 -0
  164. package/dist/ink/devtools.d.ts.map +1 -0
  165. package/dist/ink/devtools.js +5 -0
  166. package/dist/ink/devtools.js.map +1 -0
  167. package/dist/ink/dom.d.ts +77 -0
  168. package/dist/ink/dom.d.ts.map +1 -0
  169. package/dist/ink/dom.js +322 -0
  170. package/dist/ink/dom.js.map +1 -0
  171. package/dist/ink/events/click-event.d.ts +32 -0
  172. package/dist/ink/events/click-event.d.ts.map +1 -0
  173. package/dist/ink/events/click-event.js +30 -0
  174. package/dist/ink/events/click-event.js.map +1 -0
  175. package/dist/ink/events/dispatcher.d.ts +41 -0
  176. package/dist/ink/events/dispatcher.d.ts.map +1 -0
  177. package/dist/ink/events/dispatcher.js +181 -0
  178. package/dist/ink/events/dispatcher.js.map +1 -0
  179. package/dist/ink/events/emitter.d.ts +6 -0
  180. package/dist/ink/events/emitter.d.ts.map +1 -0
  181. package/dist/ink/events/emitter.js +36 -0
  182. package/dist/ink/events/emitter.js.map +1 -0
  183. package/dist/ink/events/event-handlers.d.ts +47 -0
  184. package/dist/ink/events/event-handlers.d.ts.map +1 -0
  185. package/dist/ink/events/event-handlers.js +34 -0
  186. package/dist/ink/events/event-handlers.js.map +1 -0
  187. package/dist/ink/events/event.d.ts +6 -0
  188. package/dist/ink/events/event.d.ts.map +1 -0
  189. package/dist/ink/events/event.js +16 -0
  190. package/dist/ink/events/event.js.map +1 -0
  191. package/dist/ink/events/focus-event.d.ts +14 -0
  192. package/dist/ink/events/focus-event.d.ts.map +1 -0
  193. package/dist/ink/events/focus-event.js +20 -0
  194. package/dist/ink/events/focus-event.js.map +1 -0
  195. package/dist/ink/events/input-event.d.ts +31 -0
  196. package/dist/ink/events/input-event.d.ts.map +1 -0
  197. package/dist/ink/events/input-event.js +163 -0
  198. package/dist/ink/events/input-event.js.map +1 -0
  199. package/dist/ink/events/keyboard-event.d.ts +20 -0
  200. package/dist/ink/events/keyboard-event.d.ts.map +1 -0
  201. package/dist/ink/events/keyboard-event.js +44 -0
  202. package/dist/ink/events/keyboard-event.js.map +1 -0
  203. package/dist/ink/events/terminal-event.d.ts +55 -0
  204. package/dist/ink/events/terminal-event.d.ts.map +1 -0
  205. package/dist/ink/events/terminal-event.js +79 -0
  206. package/dist/ink/events/terminal-event.js.map +1 -0
  207. package/dist/ink/events/terminal-focus-event.d.ts +14 -0
  208. package/dist/ink/events/terminal-focus-event.d.ts.map +1 -0
  209. package/dist/ink/events/terminal-focus-event.js +19 -0
  210. package/dist/ink/events/terminal-focus-event.js.map +1 -0
  211. package/dist/ink/focus.d.ts +44 -0
  212. package/dist/ink/focus.d.ts.map +1 -0
  213. package/dist/ink/focus.js +164 -0
  214. package/dist/ink/focus.js.map +1 -0
  215. package/dist/ink/frame.d.ts +95 -0
  216. package/dist/ink/frame.d.ts.map +1 -0
  217. package/dist/ink/frame.js +35 -0
  218. package/dist/ink/frame.js.map +1 -0
  219. package/dist/ink/get-max-width.d.ts +18 -0
  220. package/dist/ink/get-max-width.d.ts.map +1 -0
  221. package/dist/ink/get-max-width.js +26 -0
  222. package/dist/ink/get-max-width.js.map +1 -0
  223. package/dist/ink/hit-test.d.ts +34 -0
  224. package/dist/ink/hit-test.d.ts.map +1 -0
  225. package/dist/ink/hit-test.js +119 -0
  226. package/dist/ink/hit-test.js.map +1 -0
  227. package/dist/ink/hooks/use-animation-frame.d.ts +27 -0
  228. package/dist/ink/hooks/use-animation-frame.d.ts.map +1 -0
  229. package/dist/ink/hooks/use-animation-frame.js +52 -0
  230. package/dist/ink/hooks/use-animation-frame.js.map +1 -0
  231. package/dist/ink/hooks/use-app.d.ts +6 -0
  232. package/dist/ink/hooks/use-app.d.ts.map +1 -0
  233. package/dist/ink/hooks/use-app.js +13 -0
  234. package/dist/ink/hooks/use-app.js.map +1 -0
  235. package/dist/ink/hooks/use-declared-cursor.d.ts +27 -0
  236. package/dist/ink/hooks/use-declared-cursor.d.ts.map +1 -0
  237. package/dist/ink/hooks/use-declared-cursor.js +67 -0
  238. package/dist/ink/hooks/use-declared-cursor.js.map +1 -0
  239. package/dist/ink/hooks/use-input.d.ts +38 -0
  240. package/dist/ink/hooks/use-input.d.ts.map +1 -0
  241. package/dist/ink/hooks/use-input.js +86 -0
  242. package/dist/ink/hooks/use-input.js.map +1 -0
  243. package/dist/ink/hooks/use-interval.d.ts +19 -0
  244. package/dist/ink/hooks/use-interval.d.ts.map +1 -0
  245. package/dist/ink/hooks/use-interval.js +59 -0
  246. package/dist/ink/hooks/use-interval.js.map +1 -0
  247. package/dist/ink/hooks/use-search-highlight.d.ts +31 -0
  248. package/dist/ink/hooks/use-search-highlight.d.ts.map +1 -0
  249. package/dist/ink/hooks/use-search-highlight.js +39 -0
  250. package/dist/ink/hooks/use-search-highlight.js.map +1 -0
  251. package/dist/ink/hooks/use-selection.d.ts +40 -0
  252. package/dist/ink/hooks/use-selection.d.ts.map +1 -0
  253. package/dist/ink/hooks/use-selection.js +68 -0
  254. package/dist/ink/hooks/use-selection.js.map +1 -0
  255. package/dist/ink/hooks/use-stdin.d.ts +6 -0
  256. package/dist/ink/hooks/use-stdin.d.ts.map +1 -0
  257. package/dist/ink/hooks/use-stdin.js +13 -0
  258. package/dist/ink/hooks/use-stdin.js.map +1 -0
  259. package/dist/ink/hooks/use-tab-status.d.ts +14 -0
  260. package/dist/ink/hooks/use-tab-status.d.ts.map +1 -0
  261. package/dist/ink/hooks/use-tab-status.js +61 -0
  262. package/dist/ink/hooks/use-tab-status.js.map +1 -0
  263. package/dist/ink/hooks/use-terminal-focus.d.ts +11 -0
  264. package/dist/ink/hooks/use-terminal-focus.d.ts.map +1 -0
  265. package/dist/ink/hooks/use-terminal-focus.js +22 -0
  266. package/dist/ink/hooks/use-terminal-focus.js.map +1 -0
  267. package/dist/ink/hooks/use-terminal-title.d.ts +13 -0
  268. package/dist/ink/hooks/use-terminal-title.d.ts.map +1 -0
  269. package/dist/ink/hooks/use-terminal-title.js +36 -0
  270. package/dist/ink/hooks/use-terminal-title.js.map +1 -0
  271. package/dist/ink/hooks/use-terminal-viewport.d.ts +30 -0
  272. package/dist/ink/hooks/use-terminal-viewport.d.ts.map +1 -0
  273. package/dist/ink/hooks/use-terminal-viewport.js +81 -0
  274. package/dist/ink/hooks/use-terminal-viewport.js.map +1 -0
  275. package/dist/ink/index.d.ts +54 -0
  276. package/dist/ink/index.d.ts.map +1 -0
  277. package/dist/ink/index.js +111 -0
  278. package/dist/ink/index.js.map +1 -0
  279. package/dist/ink/ink.d.ts +371 -0
  280. package/dist/ink/ink.d.ts.map +1 -0
  281. package/dist/ink/ink.js +1686 -0
  282. package/dist/ink/ink.js.map +1 -0
  283. package/dist/ink/instances.d.ts +4 -0
  284. package/dist/ink/instances.d.ts.map +1 -0
  285. package/dist/ink/instances.js +10 -0
  286. package/dist/ink/instances.js.map +1 -0
  287. package/dist/ink/line-width-cache.d.ts +2 -0
  288. package/dist/ink/line-width-cache.d.ts.map +1 -0
  289. package/dist/ink/line-width-cache.js +23 -0
  290. package/dist/ink/line-width-cache.js.map +1 -0
  291. package/dist/ink/log-update.d.ts +18 -0
  292. package/dist/ink/log-update.d.ts.map +1 -0
  293. package/dist/ink/log-update.js +637 -0
  294. package/dist/ink/log-update.js.map +1 -0
  295. package/dist/ink/measure-element.d.ts +17 -0
  296. package/dist/ink/measure-element.d.ts.map +1 -0
  297. package/dist/ink/measure-element.js +11 -0
  298. package/dist/ink/measure-element.js.map +1 -0
  299. package/dist/ink/measure-text.d.ts +7 -0
  300. package/dist/ink/measure-text.d.ts.map +1 -0
  301. package/dist/ink/measure-text.js +38 -0
  302. package/dist/ink/measure-text.js.map +1 -0
  303. package/dist/ink/node-cache.d.ts +21 -0
  304. package/dist/ink/node-cache.d.ts.map +1 -0
  305. package/dist/ink/node-cache.js +36 -0
  306. package/dist/ink/node-cache.js.map +1 -0
  307. package/dist/ink/optimizer.d.ts +16 -0
  308. package/dist/ink/optimizer.d.ts.map +1 -0
  309. package/dist/ink/optimizer.js +85 -0
  310. package/dist/ink/optimizer.js.map +1 -0
  311. package/dist/ink/output.d.ts +120 -0
  312. package/dist/ink/output.d.ts.map +1 -0
  313. package/dist/ink/output.js +559 -0
  314. package/dist/ink/output.js.map +1 -0
  315. package/dist/ink/parse-keypress.d.ts +112 -0
  316. package/dist/ink/parse-keypress.d.ts.map +1 -0
  317. package/dist/ink/parse-keypress.js +719 -0
  318. package/dist/ink/parse-keypress.js.map +1 -0
  319. package/dist/ink/parse-keypress.test.d.ts +2 -0
  320. package/dist/ink/parse-keypress.test.d.ts.map +1 -0
  321. package/dist/ink/parse-keypress.test.js +37 -0
  322. package/dist/ink/parse-keypress.test.js.map +1 -0
  323. package/dist/ink/reconciler.d.ts +12 -0
  324. package/dist/ink/reconciler.d.ts.map +1 -0
  325. package/dist/ink/reconciler.js +456 -0
  326. package/dist/ink/reconciler.js.map +1 -0
  327. package/dist/ink/render-border.d.ts +25 -0
  328. package/dist/ink/render-border.d.ts.map +1 -0
  329. package/dist/ink/render-border.js +141 -0
  330. package/dist/ink/render-border.js.map +1 -0
  331. package/dist/ink/render-node-to-output.d.ts +46 -0
  332. package/dist/ink/render-node-to-output.d.ts.map +1 -0
  333. package/dist/ink/render-node-to-output.js +1257 -0
  334. package/dist/ink/render-node-to-output.js.map +1 -0
  335. package/dist/ink/render-to-screen.d.ts +47 -0
  336. package/dist/ink/render-to-screen.d.ts.map +1 -0
  337. package/dist/ink/render-to-screen.js +213 -0
  338. package/dist/ink/render-to-screen.js.map +1 -0
  339. package/dist/ink/renderer.d.ts +15 -0
  340. package/dist/ink/renderer.d.ts.map +1 -0
  341. package/dist/ink/renderer.js +169 -0
  342. package/dist/ink/renderer.js.map +1 -0
  343. package/dist/ink/root.d.ts +75 -0
  344. package/dist/ink/root.d.ts.map +1 -0
  345. package/dist/ink/root.js +89 -0
  346. package/dist/ink/root.js.map +1 -0
  347. package/dist/ink/screen.d.ts +270 -0
  348. package/dist/ink/screen.d.ts.map +1 -0
  349. package/dist/ink/screen.js +1194 -0
  350. package/dist/ink/screen.js.map +1 -0
  351. package/dist/ink/searchHighlight.d.ts +21 -0
  352. package/dist/ink/searchHighlight.d.ts.map +1 -0
  353. package/dist/ink/searchHighlight.js +82 -0
  354. package/dist/ink/searchHighlight.js.map +1 -0
  355. package/dist/ink/selection.d.ts +230 -0
  356. package/dist/ink/selection.d.ts.map +1 -0
  357. package/dist/ink/selection.js +814 -0
  358. package/dist/ink/selection.js.map +1 -0
  359. package/dist/ink/squash-text-nodes.d.ts +23 -0
  360. package/dist/ink/squash-text-nodes.d.ts.map +1 -0
  361. package/dist/ink/squash-text-nodes.js +60 -0
  362. package/dist/ink/squash-text-nodes.js.map +1 -0
  363. package/dist/ink/stringWidth.d.ts +2 -0
  364. package/dist/ink/stringWidth.d.ts.map +1 -0
  365. package/dist/ink/stringWidth.js +207 -0
  366. package/dist/ink/stringWidth.js.map +1 -0
  367. package/dist/ink/styles.d.ts +307 -0
  368. package/dist/ink/styles.d.ts.map +1 -0
  369. package/dist/ink/styles.js +302 -0
  370. package/dist/ink/styles.js.map +1 -0
  371. package/dist/ink/supports-hyperlinks.d.ts +14 -0
  372. package/dist/ink/supports-hyperlinks.d.ts.map +1 -0
  373. package/dist/ink/supports-hyperlinks.js +48 -0
  374. package/dist/ink/supports-hyperlinks.js.map +1 -0
  375. package/dist/ink/tabstops.d.ts +2 -0
  376. package/dist/ink/tabstops.d.ts.map +1 -0
  377. package/dist/ink/tabstops.js +43 -0
  378. package/dist/ink/tabstops.js.map +1 -0
  379. package/dist/ink/terminal-focus-state.d.ts +7 -0
  380. package/dist/ink/terminal-focus-state.d.ts.map +1 -0
  381. package/dist/ink/terminal-focus-state.js +43 -0
  382. package/dist/ink/terminal-focus-state.js.map +1 -0
  383. package/dist/ink/terminal-querier.d.ts +130 -0
  384. package/dist/ink/terminal-querier.d.ts.map +1 -0
  385. package/dist/ink/terminal-querier.js +184 -0
  386. package/dist/ink/terminal-querier.js.map +1 -0
  387. package/dist/ink/terminal.d.ts +56 -0
  388. package/dist/ink/terminal.d.ts.map +1 -0
  389. package/dist/ink/terminal.js +249 -0
  390. package/dist/ink/terminal.js.map +1 -0
  391. package/dist/ink/termio/csi.d.ts +166 -0
  392. package/dist/ink/termio/csi.d.ts.map +1 -0
  393. package/dist/ink/termio/csi.js +285 -0
  394. package/dist/ink/termio/csi.js.map +1 -0
  395. package/dist/ink/termio/dec.d.ts +38 -0
  396. package/dist/ink/termio/dec.d.ts.map +1 -0
  397. package/dist/ink/termio/dec.js +59 -0
  398. package/dist/ink/termio/dec.js.map +1 -0
  399. package/dist/ink/termio.d.ts +25 -0
  400. package/dist/ink/termio.d.ts.map +1 -0
  401. package/dist/ink/termio.js +32 -0
  402. package/dist/ink/termio.js.map +1 -0
  403. package/dist/ink/useTerminalNotification.d.ts +27 -0
  404. package/dist/ink/useTerminalNotification.d.ts.map +1 -0
  405. package/dist/ink/useTerminalNotification.js +62 -0
  406. package/dist/ink/useTerminalNotification.js.map +1 -0
  407. package/dist/ink/warn.d.ts +2 -0
  408. package/dist/ink/warn.d.ts.map +1 -0
  409. package/dist/ink/warn.js +14 -0
  410. package/dist/ink/warn.js.map +1 -0
  411. package/dist/ink/widest-line.d.ts +2 -0
  412. package/dist/ink/widest-line.d.ts.map +1 -0
  413. package/dist/ink/widest-line.js +18 -0
  414. package/dist/ink/widest-line.js.map +1 -0
  415. package/dist/ink/wrap-text.d.ts +3 -0
  416. package/dist/ink/wrap-text.d.ts.map +1 -0
  417. package/dist/ink/wrap-text.js +61 -0
  418. package/dist/ink/wrap-text.js.map +1 -0
  419. package/dist/ink/wrapAnsi.d.ts +8 -0
  420. package/dist/ink/wrapAnsi.d.ts.map +1 -0
  421. package/dist/ink/wrapAnsi.js +13 -0
  422. package/dist/ink/wrapAnsi.js.map +1 -0
  423. package/dist/memory/embeddings.d.ts +33 -0
  424. package/dist/memory/embeddings.d.ts.map +1 -0
  425. package/dist/memory/embeddings.js +123 -0
  426. package/dist/memory/embeddings.js.map +1 -0
  427. package/dist/memory/index.d.ts +14 -0
  428. package/dist/memory/index.d.ts.map +1 -0
  429. package/dist/memory/index.js +31 -0
  430. package/dist/memory/index.js.map +1 -0
  431. package/dist/memory/prompts.d.ts +12 -0
  432. package/dist/memory/prompts.d.ts.map +1 -0
  433. package/dist/memory/prompts.js +117 -0
  434. package/dist/memory/prompts.js.map +1 -0
  435. package/dist/memory/semantic-search.d.ts +45 -0
  436. package/dist/memory/semantic-search.d.ts.map +1 -0
  437. package/dist/memory/semantic-search.js +112 -0
  438. package/dist/memory/semantic-search.js.map +1 -0
  439. package/dist/memory/storage.d.ts +79 -0
  440. package/dist/memory/storage.d.ts.map +1 -0
  441. package/dist/memory/storage.js +285 -0
  442. package/dist/memory/storage.js.map +1 -0
  443. package/dist/memory/store.d.ts +103 -0
  444. package/dist/memory/store.d.ts.map +1 -0
  445. package/dist/memory/store.js +226 -0
  446. package/dist/memory/store.js.map +1 -0
  447. package/dist/memory/types.d.ts +40 -0
  448. package/dist/memory/types.d.ts.map +1 -0
  449. package/dist/memory/types.js +71 -0
  450. package/dist/memory/types.js.map +1 -0
  451. package/dist/memory/validation.d.ts +28 -0
  452. package/dist/memory/validation.d.ts.map +1 -0
  453. package/dist/memory/validation.js +147 -0
  454. package/dist/memory/validation.js.map +1 -0
  455. package/dist/memory/vector-store.d.ts +49 -0
  456. package/dist/memory/vector-store.d.ts.map +1 -0
  457. package/dist/memory/vector-store.js +259 -0
  458. package/dist/memory/vector-store.js.map +1 -0
  459. package/dist/screens/REPL.d.ts +21 -0
  460. package/dist/screens/REPL.d.ts.map +1 -0
  461. package/dist/screens/REPL.js +139 -0
  462. package/dist/screens/REPL.js.map +1 -0
  463. package/dist/services/agent-runner.d.ts +68 -0
  464. package/dist/services/agent-runner.d.ts.map +1 -0
  465. package/dist/services/agent-runner.js +186 -0
  466. package/dist/services/agent-runner.js.map +1 -0
  467. package/dist/services/atomic-write.d.ts +12 -0
  468. package/dist/services/atomic-write.d.ts.map +1 -0
  469. package/dist/services/atomic-write.js +27 -0
  470. package/dist/services/atomic-write.js.map +1 -0
  471. package/dist/services/config-dir.d.ts +55 -0
  472. package/dist/services/config-dir.d.ts.map +1 -0
  473. package/dist/services/config-dir.js +136 -0
  474. package/dist/services/config-dir.js.map +1 -0
  475. package/dist/services/config.d.ts +54 -0
  476. package/dist/services/config.d.ts.map +1 -0
  477. package/dist/services/config.js +98 -0
  478. package/dist/services/config.js.map +1 -0
  479. package/dist/services/file-glob.d.ts +26 -0
  480. package/dist/services/file-glob.d.ts.map +1 -0
  481. package/dist/services/file-glob.js +134 -0
  482. package/dist/services/file-glob.js.map +1 -0
  483. package/dist/services/global-config.d.ts +109 -0
  484. package/dist/services/global-config.d.ts.map +1 -0
  485. package/dist/services/global-config.js +211 -0
  486. package/dist/services/global-config.js.map +1 -0
  487. package/dist/services/llm.d.ts +139 -0
  488. package/dist/services/llm.d.ts.map +1 -0
  489. package/dist/services/llm.js +376 -0
  490. package/dist/services/llm.js.map +1 -0
  491. package/dist/services/memory.d.ts +39 -0
  492. package/dist/services/memory.d.ts.map +1 -0
  493. package/dist/services/memory.js +88 -0
  494. package/dist/services/memory.js.map +1 -0
  495. package/dist/services/session-storage.d.ts +136 -0
  496. package/dist/services/session-storage.d.ts.map +1 -0
  497. package/dist/services/session-storage.js +304 -0
  498. package/dist/services/session-storage.js.map +1 -0
  499. package/dist/services/task-manager.d.ts +154 -0
  500. package/dist/services/task-manager.d.ts.map +1 -0
  501. package/dist/services/task-manager.js +288 -0
  502. package/dist/services/task-manager.js.map +1 -0
  503. package/dist/services/yaml-config.d.ts +57 -0
  504. package/dist/services/yaml-config.d.ts.map +1 -0
  505. package/dist/services/yaml-config.js +176 -0
  506. package/dist/services/yaml-config.js.map +1 -0
  507. package/dist/skills/discovery.d.ts +22 -0
  508. package/dist/skills/discovery.d.ts.map +1 -0
  509. package/dist/skills/discovery.js +75 -0
  510. package/dist/skills/discovery.js.map +1 -0
  511. package/dist/skills/index.d.ts +10 -0
  512. package/dist/skills/index.d.ts.map +1 -0
  513. package/dist/skills/index.js +26 -0
  514. package/dist/skills/index.js.map +1 -0
  515. package/dist/skills/loader.d.ts +48 -0
  516. package/dist/skills/loader.d.ts.map +1 -0
  517. package/dist/skills/loader.js +231 -0
  518. package/dist/skills/loader.js.map +1 -0
  519. package/dist/skills/registry.d.ts +37 -0
  520. package/dist/skills/registry.d.ts.map +1 -0
  521. package/dist/skills/registry.js +134 -0
  522. package/dist/skills/registry.js.map +1 -0
  523. package/dist/skills/types.d.ts +89 -0
  524. package/dist/skills/types.d.ts.map +1 -0
  525. package/dist/skills/types.js +24 -0
  526. package/dist/skills/types.js.map +1 -0
  527. package/dist/tools/bash_security.d.ts +64 -0
  528. package/dist/tools/bash_security.d.ts.map +1 -0
  529. package/dist/tools/bash_security.js +291 -0
  530. package/dist/tools/bash_security.js.map +1 -0
  531. package/dist/tools/index.d.ts +23 -0
  532. package/dist/tools/index.d.ts.map +1 -0
  533. package/dist/tools/index.js +965 -0
  534. package/dist/tools/index.js.map +1 -0
  535. package/dist/tools/mcp.d.ts +72 -0
  536. package/dist/tools/mcp.d.ts.map +1 -0
  537. package/dist/tools/mcp.js +422 -0
  538. package/dist/tools/mcp.js.map +1 -0
  539. package/dist/tools/plan.d.ts +18 -0
  540. package/dist/tools/plan.d.ts.map +1 -0
  541. package/dist/tools/plan.js +75 -0
  542. package/dist/tools/plan.js.map +1 -0
  543. package/dist/tools/todo.d.ts +18 -0
  544. package/dist/tools/todo.d.ts.map +1 -0
  545. package/dist/tools/todo.js +153 -0
  546. package/dist/tools/todo.js.map +1 -0
  547. package/dist/tools/web.d.ts +13 -0
  548. package/dist/tools/web.d.ts.map +1 -0
  549. package/dist/tools/web.js +377 -0
  550. package/dist/tools/web.js.map +1 -0
  551. package/dist/ui/box.d.ts +56 -0
  552. package/dist/ui/box.d.ts.map +1 -0
  553. package/dist/ui/box.js +241 -0
  554. package/dist/ui/box.js.map +1 -0
  555. package/dist/ui/command-panel.d.ts +55 -0
  556. package/dist/ui/command-panel.d.ts.map +1 -0
  557. package/dist/ui/command-panel.js +212 -0
  558. package/dist/ui/command-panel.js.map +1 -0
  559. package/dist/ui/file-completion.d.ts +62 -0
  560. package/dist/ui/file-completion.d.ts.map +1 -0
  561. package/dist/ui/file-completion.js +209 -0
  562. package/dist/ui/file-completion.js.map +1 -0
  563. package/dist/ui/markdown.d.ts +12 -0
  564. package/dist/ui/markdown.d.ts.map +1 -0
  565. package/dist/ui/markdown.js +215 -0
  566. package/dist/ui/markdown.js.map +1 -0
  567. package/dist/ui/multiline-input.d.ts +47 -0
  568. package/dist/ui/multiline-input.d.ts.map +1 -0
  569. package/dist/ui/multiline-input.js +94 -0
  570. package/dist/ui/multiline-input.js.map +1 -0
  571. package/dist/ui/status-bar.d.ts +33 -0
  572. package/dist/ui/status-bar.d.ts.map +1 -0
  573. package/dist/ui/status-bar.js +96 -0
  574. package/dist/ui/status-bar.js.map +1 -0
  575. package/dist/ui/stream-markdown.d.ts +35 -0
  576. package/dist/ui/stream-markdown.d.ts.map +1 -0
  577. package/dist/ui/stream-markdown.js +138 -0
  578. package/dist/ui/stream-markdown.js.map +1 -0
  579. package/dist/ui/suggestions.d.ts +35 -0
  580. package/dist/ui/suggestions.d.ts.map +1 -0
  581. package/dist/ui/suggestions.js +118 -0
  582. package/dist/ui/suggestions.js.map +1 -0
  583. package/dist/ui/tool-preview.d.ts +34 -0
  584. package/dist/ui/tool-preview.d.ts.map +1 -0
  585. package/dist/ui/tool-preview.js +128 -0
  586. package/dist/ui/tool-preview.js.map +1 -0
  587. package/package.json +93 -0
@@ -0,0 +1,646 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.handleMouseEvent = handleMouseEvent;
40
+ const react_1 = __importStar(require("react"));
41
+ const state_js_1 = require("../../bootstrap/state.js");
42
+ const earlyInput_js_1 = require("../../utils/earlyInput.js");
43
+ const envUtils_js_1 = require("../../utils/envUtils.js");
44
+ const fullscreen_js_1 = require("../../utils/fullscreen.js");
45
+ const debug_js_1 = require("../../utils/debug.js");
46
+ const log_js_1 = require("../../utils/log.js");
47
+ const emitter_js_1 = require("../events/emitter.js");
48
+ const input_event_js_1 = require("../events/input-event.js");
49
+ const terminal_focus_event_js_1 = require("../events/terminal-focus-event.js");
50
+ const parse_keypress_js_1 = require("../parse-keypress.js");
51
+ const reconciler_js_1 = __importDefault(require("../reconciler.js"));
52
+ const selection_js_1 = require("../selection.js");
53
+ const terminal_js_1 = require("../terminal.js");
54
+ const terminal_focus_state_js_1 = require("../terminal-focus-state.js");
55
+ const terminal_querier_js_1 = require("../terminal-querier.js");
56
+ const csi_js_1 = require("../termio/csi.js");
57
+ const dec_js_1 = require("../termio/dec.js");
58
+ const AppContext_js_1 = __importDefault(require("./AppContext.js"));
59
+ const ClockContext_js_1 = require("./ClockContext.js");
60
+ const CursorDeclarationContext_js_1 = __importDefault(require("./CursorDeclarationContext.js"));
61
+ const ErrorOverview_js_1 = __importDefault(require("./ErrorOverview.js"));
62
+ const StdinContext_js_1 = __importDefault(require("./StdinContext.js"));
63
+ const TerminalFocusContext_js_1 = require("./TerminalFocusContext.js");
64
+ const TerminalSizeContext_js_1 = require("./TerminalSizeContext.js");
65
+ // Platforms that support Unix-style process suspension (SIGSTOP/SIGCONT)
66
+ const SUPPORTS_SUSPEND = process.platform !== 'win32';
67
+ // After this many milliseconds of stdin silence, the next chunk triggers
68
+ // a terminal mode re-assert (mouse tracking). Catches tmux detach→attach,
69
+ // ssh reconnect, and laptop wake — the terminal resets DEC private modes
70
+ // but no signal reaches us. 5s is well above normal inter-keystroke gaps
71
+ // but short enough that the first scroll after reattach works.
72
+ const STDIN_RESUME_GAP_MS = 5000;
73
+ // Multi-click detection thresholds. 500ms is the macOS default; a small
74
+ // position tolerance allows for trackpad jitter between clicks.
75
+ const MULTI_CLICK_TIMEOUT_MS = 500;
76
+ const MULTI_CLICK_DISTANCE = 1;
77
+ // Root component for all Ink apps
78
+ // It renders stdin and stdout contexts, so that children can access them if needed
79
+ // It also handles Ctrl+C exiting and cursor visibility
80
+ class App extends react_1.PureComponent {
81
+ constructor() {
82
+ super(...arguments);
83
+ this.state = {
84
+ error: undefined
85
+ };
86
+ // Count how many components enabled raw mode to avoid disabling
87
+ // raw mode until all components don't need it anymore
88
+ this.rawModeEnabledCount = 0;
89
+ this.internal_eventEmitter = new emitter_js_1.EventEmitter();
90
+ this.keyParseState = parse_keypress_js_1.INITIAL_STATE;
91
+ // Timer for flushing incomplete escape sequences
92
+ this.incompleteEscapeTimer = null;
93
+ // Default to readable-mode stdin (legacy Ink behavior). The data-mode path
94
+ // is kept as an explicit opt-in because some terminals can enter a state
95
+ // where startup input appears frozen when data mode is the default.
96
+ this.stdinMode = process.env.OPENCLAUDE_USE_DATA_STDIN === '1' || process.env.OPENCLAUDE_USE_READABLE_STDIN === '0' ? 'data' : 'readable';
97
+ // Timeout durations for incomplete sequences (ms)
98
+ this.NORMAL_TIMEOUT = 50; // Short timeout for regular esc sequences
99
+ this.PASTE_TIMEOUT = 500; // Longer timeout for paste operations
100
+ // Terminal query/response dispatch. Responses arrive on stdin (parsed
101
+ // out by parse-keypress) and are routed to pending promise resolvers.
102
+ this.querier = new terminal_querier_js_1.TerminalQuerier(this.props.stdout);
103
+ // Multi-click tracking for double/triple-click text selection. A click
104
+ // within MULTI_CLICK_TIMEOUT_MS and MULTI_CLICK_DISTANCE of the previous
105
+ // click increments clickCount; otherwise it resets to 1.
106
+ this.lastClickTime = 0;
107
+ this.lastClickCol = -1;
108
+ this.lastClickRow = -1;
109
+ this.clickCount = 0;
110
+ // Deferred hyperlink-open timer — cancelled if a second click arrives
111
+ // within MULTI_CLICK_TIMEOUT_MS (so double-clicking a hyperlink selects
112
+ // the word without also opening the browser). DOM onClick dispatch is
113
+ // NOT deferred — it returns true from onClickAt and skips this timer.
114
+ this.pendingHyperlinkTimer = null;
115
+ // Last mode-1003 motion position. Terminals already dedupe to cell
116
+ // granularity but this also lets us skip dispatchHover entirely on
117
+ // repeat events (drag-then-release at same cell, etc.).
118
+ this.lastHoverCol = -1;
119
+ this.lastHoverRow = -1;
120
+ // Timestamp of last stdin chunk. Used to detect long gaps (tmux attach,
121
+ // ssh reconnect, laptop wake) and trigger terminal mode re-assert.
122
+ // Initialized to now so startup doesn't false-trigger.
123
+ this.lastStdinTime = Date.now();
124
+ this.handleSetRawMode = (isEnabled) => {
125
+ const { stdin } = this.props;
126
+ if (!this.isRawModeSupported()) {
127
+ if (stdin === process.stdin) {
128
+ throw new Error('Raw mode is not supported on the current process.stdin, which Ink uses as input stream by default.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
129
+ }
130
+ else {
131
+ throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
132
+ }
133
+ }
134
+ stdin.setEncoding('utf8');
135
+ if (isEnabled) {
136
+ // Ensure raw mode is enabled only once
137
+ if (this.rawModeEnabledCount === 0) {
138
+ // Stop early input capture right before we add our own readable handler.
139
+ // Both use the same stdin 'readable' + read() pattern, so they can't
140
+ // coexist -- our handler would drain stdin before Ink's can see it.
141
+ // The buffered text is preserved for REPL.tsx via consumeEarlyInput().
142
+ (0, earlyInput_js_1.stopCapturingEarlyInput)();
143
+ stdin.ref();
144
+ stdin.setRawMode(true);
145
+ if (this.stdinMode === 'data') {
146
+ stdin.addListener('data', this.handleDataChunk);
147
+ }
148
+ else {
149
+ stdin.addListener('readable', this.handleReadable);
150
+ }
151
+ stdin.resume();
152
+ // Enable bracketed paste mode
153
+ this.props.stdout.write(dec_js_1.EBP);
154
+ // Enable terminal focus reporting (DECSET 1004)
155
+ this.props.stdout.write(dec_js_1.EFE);
156
+ // Enable extended key reporting so ctrl+shift+<letter> is
157
+ // distinguishable from ctrl+<letter>. We write both the kitty stack
158
+ // push (CSI >1u) and xterm modifyOtherKeys level 2 (CSI >4;2m) —
159
+ // terminals honor whichever they implement (tmux only accepts the
160
+ // latter).
161
+ if ((0, terminal_js_1.supportsExtendedKeys)()) {
162
+ this.props.stdout.write(csi_js_1.ENABLE_KITTY_KEYBOARD);
163
+ this.props.stdout.write(csi_js_1.ENABLE_MODIFY_OTHER_KEYS);
164
+ }
165
+ // Probe terminal identity. XTVERSION survives SSH (query/reply goes
166
+ // through the pty), unlike TERM_PROGRAM. Used for wheel-scroll base
167
+ // detection when env vars are absent. Fire-and-forget: the DA1
168
+ // sentinel bounds the round-trip, and if the terminal ignores the
169
+ // query, flush() still resolves and name stays undefined.
170
+ // Deferred to next tick so it fires AFTER the current synchronous
171
+ // init sequence completes — avoids interleaving with alt-screen/mouse
172
+ // tracking enable writes that may happen in the same render cycle.
173
+ setImmediate(() => {
174
+ void Promise.all([this.querier.send((0, terminal_querier_js_1.xtversion)()), this.querier.flush()]).then(([r]) => {
175
+ if (r) {
176
+ (0, terminal_js_1.setXtversionName)(r.name);
177
+ (0, debug_js_1.logForDebugging)(`XTVERSION: terminal identified as "${r.name}"`);
178
+ }
179
+ else {
180
+ (0, debug_js_1.logForDebugging)('XTVERSION: no reply (terminal ignored query)');
181
+ }
182
+ });
183
+ });
184
+ }
185
+ this.rawModeEnabledCount++;
186
+ return;
187
+ }
188
+ // Disable raw mode only when no components left that are using it
189
+ if (--this.rawModeEnabledCount === 0) {
190
+ this.props.stdout.write(csi_js_1.DISABLE_MODIFY_OTHER_KEYS);
191
+ this.props.stdout.write(csi_js_1.DISABLE_KITTY_KEYBOARD);
192
+ // Disable terminal focus reporting (DECSET 1004)
193
+ this.props.stdout.write(dec_js_1.DFE);
194
+ // Disable bracketed paste mode
195
+ this.props.stdout.write(dec_js_1.DBP);
196
+ stdin.setRawMode(false);
197
+ stdin.removeListener('readable', this.handleReadable);
198
+ stdin.removeListener('data', this.handleDataChunk);
199
+ stdin.pause();
200
+ stdin.unref();
201
+ }
202
+ };
203
+ // Helper to flush incomplete escape sequences
204
+ this.flushIncomplete = () => {
205
+ // Clear the timer reference
206
+ this.incompleteEscapeTimer = null;
207
+ // Only proceed if we have incomplete sequences
208
+ if (!this.keyParseState.incomplete)
209
+ return;
210
+ // Fullscreen: if stdin has data waiting, it's almost certainly the
211
+ // continuation of the buffered sequence (e.g. `[<64;74;16M` after a
212
+ // lone ESC). Node's event loop runs the timers phase before the poll
213
+ // phase, so when a heavy render blocks the loop past 50ms, this timer
214
+ // fires before the queued readable event even though the bytes are
215
+ // already buffered. Re-arm instead of flushing: handleReadable will
216
+ // drain stdin next and clear this timer. Prevents both the spurious
217
+ // Escape key and the lost scroll event.
218
+ if (this.props.stdin.readableLength > 0) {
219
+ this.incompleteEscapeTimer = setTimeout(this.flushIncomplete, this.NORMAL_TIMEOUT);
220
+ return;
221
+ }
222
+ // Process incomplete as a flush operation (input=null)
223
+ // This reuses all existing parsing logic
224
+ this.processInput(null);
225
+ };
226
+ // Process input through the parser and handle the results
227
+ this.processInput = (input) => {
228
+ // Parse input using our state machine
229
+ const [keys, newState] = (0, parse_keypress_js_1.parseMultipleKeypresses)(this.keyParseState, input);
230
+ this.keyParseState = newState;
231
+ // Process ALL keys in a SINGLE discreteUpdates call to prevent
232
+ // "Maximum update depth exceeded" error when many keys arrive at once
233
+ // (e.g., from paste operations or holding keys rapidly).
234
+ // This batches all state updates from handleInput and all useInput
235
+ // listeners together within one high-priority update context.
236
+ if (keys.length > 0) {
237
+ reconciler_js_1.default.discreteUpdates(processKeysInBatch, this, keys, undefined, undefined);
238
+ }
239
+ // If we have incomplete escape sequences, set a timer to flush them
240
+ if (this.keyParseState.incomplete) {
241
+ // Cancel any existing timer first
242
+ if (this.incompleteEscapeTimer) {
243
+ clearTimeout(this.incompleteEscapeTimer);
244
+ }
245
+ this.incompleteEscapeTimer = setTimeout(this.flushIncomplete, this.keyParseState.mode === 'IN_PASTE' ? this.PASTE_TIMEOUT : this.NORMAL_TIMEOUT);
246
+ }
247
+ };
248
+ this.handleReadable = () => {
249
+ // Detect long stdin gaps (tmux attach, ssh reconnect, laptop wake).
250
+ // The terminal may have reset DEC private modes; re-assert mouse
251
+ // tracking. Checked before the read loop so one Date.now() covers
252
+ // all chunks in this readable event.
253
+ const now = Date.now();
254
+ if (now - this.lastStdinTime > STDIN_RESUME_GAP_MS) {
255
+ this.props.onStdinResume?.();
256
+ }
257
+ this.lastStdinTime = now;
258
+ try {
259
+ let chunk;
260
+ while ((chunk = this.props.stdin.read()) !== null) {
261
+ // Process the input chunk
262
+ this.processInput(chunk);
263
+ }
264
+ }
265
+ catch (error) {
266
+ // In Bun, an uncaught throw inside a stream 'readable' handler can
267
+ // permanently wedge the stream: data stays buffered and 'readable'
268
+ // never re-emits. Catching here ensures the stream stays healthy so
269
+ // subsequent keystrokes are still delivered.
270
+ (0, log_js_1.logError)(error);
271
+ // Re-attach the listener in case the exception detached it.
272
+ // Bun may remove the listener after an error; without this,
273
+ // the session freezes permanently (stdin reader dead, event loop alive).
274
+ const { stdin } = this.props;
275
+ if (this.rawModeEnabledCount > 0 && !stdin.listeners('readable').includes(this.handleReadable)) {
276
+ (0, debug_js_1.logForDebugging)('handleReadable: re-attaching stdin readable listener after error recovery', {
277
+ level: 'warn'
278
+ });
279
+ stdin.addListener('readable', this.handleReadable);
280
+ }
281
+ }
282
+ };
283
+ this.handleDataChunk = (chunk) => {
284
+ const now = Date.now();
285
+ if (now - this.lastStdinTime > STDIN_RESUME_GAP_MS) {
286
+ this.props.onStdinResume?.();
287
+ }
288
+ this.lastStdinTime = now;
289
+ try {
290
+ this.processInput(chunk);
291
+ }
292
+ catch (error) {
293
+ (0, log_js_1.logError)(error);
294
+ const { stdin } = this.props;
295
+ if (this.rawModeEnabledCount > 0 && !stdin.listeners('data').includes(this.handleDataChunk)) {
296
+ (0, debug_js_1.logForDebugging)('handleDataChunk: re-attaching stdin data listener after error recovery', {
297
+ level: 'warn'
298
+ });
299
+ stdin.addListener('data', this.handleDataChunk);
300
+ }
301
+ }
302
+ };
303
+ this.handleInput = (input) => {
304
+ // Exit on Ctrl+C
305
+ if (input === '\x03' && this.props.exitOnCtrlC) {
306
+ this.handleExit();
307
+ }
308
+ // Note: Ctrl+Z (suspend) is now handled in processKeysInBatch using the
309
+ // parsed key to support both raw (\x1a) and CSI u format from Kitty
310
+ // keyboard protocol terminals (Ghostty, iTerm2, kitty, WezTerm)
311
+ };
312
+ this.handleExit = (error) => {
313
+ if (this.isRawModeSupported()) {
314
+ this.handleSetRawMode(false);
315
+ }
316
+ this.props.onExit(error);
317
+ };
318
+ this.handleTerminalFocus = (isFocused) => {
319
+ // setTerminalFocused notifies subscribers: TerminalFocusProvider (context)
320
+ // and Clock (interval speed) — no App setState needed.
321
+ (0, terminal_focus_state_js_1.setTerminalFocused)(isFocused);
322
+ };
323
+ this.handleSuspend = () => {
324
+ if (!this.isRawModeSupported()) {
325
+ return;
326
+ }
327
+ // Store the exact raw mode count to restore it properly
328
+ const rawModeCountBeforeSuspend = this.rawModeEnabledCount;
329
+ // Completely disable raw mode before suspending
330
+ while (this.rawModeEnabledCount > 0) {
331
+ this.handleSetRawMode(false);
332
+ }
333
+ // Show cursor, disable focus reporting, and disable mouse tracking
334
+ // before suspending. DISABLE_MOUSE_TRACKING is a no-op if tracking
335
+ // wasn't enabled, so it's safe to emit unconditionally — without
336
+ // it, SGR mouse sequences would appear as garbled text at the
337
+ // shell prompt while suspended.
338
+ if (this.props.stdout.isTTY) {
339
+ this.props.stdout.write(dec_js_1.SHOW_CURSOR + dec_js_1.DFE + dec_js_1.DISABLE_MOUSE_TRACKING);
340
+ }
341
+ // Emit suspend event for Claude Code to handle. Mostly just has a notification
342
+ this.internal_eventEmitter.emit('suspend');
343
+ // Set up resume handler
344
+ const resumeHandler = () => {
345
+ // Restore raw mode to exact previous state
346
+ for (let i = 0; i < rawModeCountBeforeSuspend; i++) {
347
+ if (this.isRawModeSupported()) {
348
+ this.handleSetRawMode(true);
349
+ }
350
+ }
351
+ // Hide cursor (unless in accessibility mode) and re-enable focus reporting after resuming
352
+ if (this.props.stdout.isTTY) {
353
+ if (!(0, envUtils_js_1.isEnvTruthy)(process.env.CLAUDE_CODE_ACCESSIBILITY)) {
354
+ this.props.stdout.write(dec_js_1.HIDE_CURSOR);
355
+ }
356
+ // Re-enable focus reporting to restore terminal state
357
+ this.props.stdout.write(dec_js_1.EFE);
358
+ }
359
+ // Emit resume event for Claude Code to handle
360
+ this.internal_eventEmitter.emit('resume');
361
+ process.removeListener('SIGCONT', resumeHandler);
362
+ };
363
+ process.on('SIGCONT', resumeHandler);
364
+ process.kill(process.pid, 'SIGSTOP');
365
+ };
366
+ }
367
+ static getDerivedStateFromError(error) {
368
+ return {
369
+ error
370
+ };
371
+ }
372
+ // Determines if TTY is supported on the provided stdin
373
+ isRawModeSupported() {
374
+ return this.props.stdin.isTTY;
375
+ }
376
+ render() {
377
+ return <TerminalSizeContext_js_1.TerminalSizeContext.Provider value={{
378
+ columns: this.props.terminalColumns,
379
+ rows: this.props.terminalRows
380
+ }}>
381
+ <AppContext_js_1.default.Provider value={{
382
+ exit: this.handleExit
383
+ }}>
384
+ <StdinContext_js_1.default.Provider value={{
385
+ stdin: this.props.stdin,
386
+ setRawMode: this.handleSetRawMode,
387
+ isRawModeSupported: this.isRawModeSupported(),
388
+ internal_exitOnCtrlC: this.props.exitOnCtrlC,
389
+ internal_eventEmitter: this.internal_eventEmitter,
390
+ internal_querier: this.querier
391
+ }}>
392
+ <TerminalFocusContext_js_1.TerminalFocusProvider>
393
+ <ClockContext_js_1.ClockProvider>
394
+ <CursorDeclarationContext_js_1.default.Provider value={this.props.onCursorDeclaration ?? (() => { })}>
395
+ {this.state.error ? <ErrorOverview_js_1.default error={this.state.error}/> : this.props.children}
396
+ </CursorDeclarationContext_js_1.default.Provider>
397
+ </ClockContext_js_1.ClockProvider>
398
+ </TerminalFocusContext_js_1.TerminalFocusProvider>
399
+ </StdinContext_js_1.default.Provider>
400
+ </AppContext_js_1.default.Provider>
401
+ </TerminalSizeContext_js_1.TerminalSizeContext.Provider>;
402
+ }
403
+ componentDidMount() {
404
+ // In accessibility mode, keep the native cursor visible for screen magnifiers and other tools
405
+ if (this.props.stdout.isTTY && !(0, envUtils_js_1.isEnvTruthy)(process.env.CLAUDE_CODE_ACCESSIBILITY)) {
406
+ this.props.stdout.write(dec_js_1.HIDE_CURSOR);
407
+ }
408
+ }
409
+ componentWillUnmount() {
410
+ if (this.props.stdout.isTTY) {
411
+ this.props.stdout.write(dec_js_1.SHOW_CURSOR);
412
+ }
413
+ // Clear any pending timers
414
+ if (this.incompleteEscapeTimer) {
415
+ clearTimeout(this.incompleteEscapeTimer);
416
+ this.incompleteEscapeTimer = null;
417
+ }
418
+ if (this.pendingHyperlinkTimer) {
419
+ clearTimeout(this.pendingHyperlinkTimer);
420
+ this.pendingHyperlinkTimer = null;
421
+ }
422
+ // ignore calling setRawMode on an handle stdin it cannot be called
423
+ if (this.isRawModeSupported()) {
424
+ this.handleSetRawMode(false);
425
+ }
426
+ }
427
+ componentDidCatch(error) {
428
+ (0, log_js_1.logError)(error);
429
+ this.handleExit(error);
430
+ }
431
+ }
432
+ App.displayName = 'InternalApp';
433
+ exports.default = App;
434
+ // Helper to process all keys within a single discrete update context.
435
+ // discreteUpdates expects (fn, a, b, c, d) -> fn(a, b, c, d)
436
+ function processKeysInBatch(app, items, _unused1, _unused2) {
437
+ // Update interaction time for notification timeout tracking.
438
+ // This is called from the central input handler to avoid having multiple
439
+ // stdin listeners that can cause race conditions and dropped input.
440
+ // Terminal responses (kind: 'response') are automated, not user input.
441
+ // Mode-1003 no-button motion is also excluded — passive cursor drift is
442
+ // not engagement (would suppress idle notifications + defer housekeeping).
443
+ if (items.some(i => i.kind === 'key' || i.kind === 'mouse' && !((i.button & 0x20) !== 0 && (i.button & 0x03) === 3))) {
444
+ (0, state_js_1.updateLastInteractionTime)();
445
+ }
446
+ for (const item of items) {
447
+ // Terminal responses (DECRPM, DA1, OSC replies, etc.) are not user
448
+ // input — route them to the querier to resolve pending promises.
449
+ if (item.kind === 'response') {
450
+ app.querier.onResponse(item.response);
451
+ continue;
452
+ }
453
+ // Mouse click/drag events update selection state (fullscreen only).
454
+ // Terminal sends 1-indexed col/row; convert to 0-indexed for the
455
+ // screen buffer. Button bit 0x20 = drag (motion while button held).
456
+ if (item.kind === 'mouse') {
457
+ handleMouseEvent(app, item);
458
+ continue;
459
+ }
460
+ const sequence = item.sequence;
461
+ // Handle terminal focus events (DECSET 1004)
462
+ if (sequence === csi_js_1.FOCUS_IN) {
463
+ app.handleTerminalFocus(true);
464
+ const event = new terminal_focus_event_js_1.TerminalFocusEvent('terminalfocus');
465
+ app.internal_eventEmitter.emit('terminalfocus', event);
466
+ continue;
467
+ }
468
+ if (sequence === csi_js_1.FOCUS_OUT) {
469
+ app.handleTerminalFocus(false);
470
+ // Defensive: if we lost the release event (mouse released outside
471
+ // terminal window — some emulators drop it rather than capturing the
472
+ // pointer), focus-out is the next observable signal that the drag is
473
+ // over. Without this, drag-to-scroll's timer runs until the scroll
474
+ // boundary is hit.
475
+ if (app.props.selection.isDragging) {
476
+ (0, selection_js_1.finishSelection)(app.props.selection);
477
+ app.props.onSelectionChange();
478
+ }
479
+ const event = new terminal_focus_event_js_1.TerminalFocusEvent('terminalblur');
480
+ app.internal_eventEmitter.emit('terminalblur', event);
481
+ continue;
482
+ }
483
+ // Failsafe: if we receive input, the terminal must be focused
484
+ if (!(0, terminal_focus_state_js_1.getTerminalFocused)()) {
485
+ (0, terminal_focus_state_js_1.setTerminalFocused)(true);
486
+ }
487
+ // Handle Ctrl+Z (suspend) using parsed key to support both raw (\x1a) and
488
+ // CSI u format (\x1b[122;5u) from Kitty keyboard protocol terminals
489
+ if (item.name === 'z' && item.ctrl && SUPPORTS_SUSPEND) {
490
+ app.handleSuspend();
491
+ continue;
492
+ }
493
+ app.handleInput(sequence);
494
+ const event = new input_event_js_1.InputEvent(item);
495
+ app.internal_eventEmitter.emit('input', event);
496
+ // Also dispatch through the DOM tree so onKeyDown handlers fire.
497
+ app.props.dispatchKeyboardEvent(item);
498
+ }
499
+ }
500
+ /** Exported for testing. Mutates app.props.selection and click/hover state. */
501
+ function handleMouseEvent(app, m) {
502
+ // Allow disabling click handling while keeping wheel scroll (which goes
503
+ // through the keybinding system as 'wheelup'/'wheeldown', not here).
504
+ if ((0, fullscreen_js_1.isMouseClicksDisabled)())
505
+ return;
506
+ const sel = app.props.selection;
507
+ // Terminal coords are 1-indexed; screen buffer is 0-indexed
508
+ const col = m.col - 1;
509
+ const row = m.row - 1;
510
+ const baseButton = m.button & 0x03;
511
+ if (m.action === 'press') {
512
+ if ((m.button & 0x20) !== 0 && baseButton === 3) {
513
+ // Mode-1003 motion with no button held. Dispatch hover; skip the
514
+ // rest of this handler (no selection, no click-count side effects).
515
+ // Lost-release recovery: no-button motion while isDragging=true means
516
+ // the release happened outside the terminal window (iTerm2 doesn't
517
+ // capture the pointer past window bounds, so the SGR 'm' never
518
+ // arrives). Finish the selection here so copy-on-select fires. The
519
+ // FOCUS_OUT handler covers the "switched apps" case but not "released
520
+ // past the edge, came back" — and tmux drops focus events unless
521
+ // `focus-events on` is set, so this is the more reliable signal.
522
+ if (sel.isDragging) {
523
+ (0, selection_js_1.finishSelection)(sel);
524
+ app.props.onSelectionChange();
525
+ }
526
+ if (col === app.lastHoverCol && row === app.lastHoverRow)
527
+ return;
528
+ app.lastHoverCol = col;
529
+ app.lastHoverRow = row;
530
+ app.props.onHoverAt(col, row);
531
+ return;
532
+ }
533
+ if (baseButton !== 0) {
534
+ // Non-left press breaks the multi-click chain.
535
+ app.clickCount = 0;
536
+ return;
537
+ }
538
+ if ((m.button & 0x20) !== 0) {
539
+ // Drag motion: mode-aware extension (char/word/line). onSelectionDrag
540
+ // calls notifySelectionChange internally — no extra onSelectionChange.
541
+ app.props.onSelectionDrag(col, row);
542
+ return;
543
+ }
544
+ // Lost-release fallback for mode-1002-only terminals: a fresh press
545
+ // while isDragging=true means the previous release was dropped (cursor
546
+ // left the window). Finish that selection so copy-on-select fires
547
+ // before startSelection/onMultiClick clobbers it. Mode-1003 terminals
548
+ // hit the no-button-motion recovery above instead, so this is rare.
549
+ if (sel.isDragging) {
550
+ (0, selection_js_1.finishSelection)(sel);
551
+ app.props.onSelectionChange();
552
+ }
553
+ // Fresh left press. Detect multi-click HERE (not on release) so the
554
+ // word/line highlight appears immediately and a subsequent drag can
555
+ // extend by word/line like native macOS. Previously detected on
556
+ // release, which meant (a) visible latency before the word highlights
557
+ // and (b) double-click+drag fell through to char-mode selection.
558
+ const now = Date.now();
559
+ const nearLast = now - app.lastClickTime < MULTI_CLICK_TIMEOUT_MS && Math.abs(col - app.lastClickCol) <= MULTI_CLICK_DISTANCE && Math.abs(row - app.lastClickRow) <= MULTI_CLICK_DISTANCE;
560
+ app.clickCount = nearLast ? app.clickCount + 1 : 1;
561
+ app.lastClickTime = now;
562
+ app.lastClickCol = col;
563
+ app.lastClickRow = row;
564
+ if (app.clickCount >= 2) {
565
+ // Cancel any pending hyperlink-open from the first click — this is
566
+ // a double-click, not a single-click on a link.
567
+ if (app.pendingHyperlinkTimer) {
568
+ clearTimeout(app.pendingHyperlinkTimer);
569
+ app.pendingHyperlinkTimer = null;
570
+ }
571
+ // Cap at 3 (line select) for quadruple+ clicks.
572
+ const count = app.clickCount === 2 ? 2 : 3;
573
+ app.props.onMultiClick(col, row, count);
574
+ return;
575
+ }
576
+ (0, selection_js_1.startSelection)(sel, col, row);
577
+ // SGR bit 0x08 = alt (xterm.js wires altKey here, not metaKey — see
578
+ // comment at the hyperlink-open guard below). On macOS xterm.js,
579
+ // receiving alt means macOptionClickForcesSelection is OFF (otherwise
580
+ // xterm.js would have consumed the event for native selection).
581
+ sel.lastPressHadAlt = (m.button & 0x08) !== 0;
582
+ app.props.onSelectionChange();
583
+ return;
584
+ }
585
+ // Release: end the drag even for non-zero button codes. Some terminals
586
+ // encode release with the motion bit or button=3 "no button" (carried
587
+ // over from pre-SGR X10 encoding) — filtering those would orphan
588
+ // isDragging=true and leave drag-to-scroll's timer running until the
589
+ // scroll boundary. Only act on non-left releases when we ARE dragging
590
+ // (so an unrelated middle/right click-release doesn't touch selection).
591
+ if (baseButton !== 0) {
592
+ if (!sel.isDragging)
593
+ return;
594
+ (0, selection_js_1.finishSelection)(sel);
595
+ app.props.onSelectionChange();
596
+ return;
597
+ }
598
+ (0, selection_js_1.finishSelection)(sel);
599
+ // NOTE: unlike the old release-based detection we do NOT reset clickCount
600
+ // on release-after-drag. This aligns with NSEvent.clickCount semantics:
601
+ // an intervening drag doesn't break the click chain. Practical upside:
602
+ // trackpad jitter during an intended double-click (press→wobble→release
603
+ // →press) now correctly resolves to word-select instead of breaking to a
604
+ // fresh single click. The nearLast window (500ms, 1 cell) bounds the
605
+ // effect — a deliberate drag past that just starts a fresh chain.
606
+ // A press+release with no drag in char mode is a click: anchor set,
607
+ // focus null → hasSelection false. In word/line mode the press already
608
+ // set anchor+focus (hasSelection true), so release just keeps the
609
+ // highlight. The anchor check guards against an orphaned release (no
610
+ // prior press — e.g. button was held when mouse tracking was enabled).
611
+ if (!(0, selection_js_1.hasSelection)(sel) && sel.anchor) {
612
+ // Single click: dispatch DOM click immediately (cursor repositioning
613
+ // etc. are latency-sensitive). If no DOM handler consumed it, defer
614
+ // the hyperlink check so a second click can cancel it.
615
+ if (!app.props.onClickAt(col, row)) {
616
+ // Resolve the hyperlink URL synchronously while the screen buffer
617
+ // still reflects what the user clicked — deferring only the
618
+ // browser-open so double-click can cancel it.
619
+ const url = app.props.getHyperlinkAt(col, row);
620
+ // xterm.js (VS Code, Cursor, Windsurf, etc.) has its own OSC 8 link
621
+ // handler that fires on Cmd+click *without consuming the mouse event*
622
+ // (Linkifier._handleMouseUp calls link.activate() but never
623
+ // preventDefault/stopPropagation). The click is also forwarded to the
624
+ // pty as SGR, so both VS Code's terminalLinkManager AND our handler
625
+ // here would open the URL — twice. We can't filter on Cmd: xterm.js
626
+ // drops metaKey before SGR encoding (ICoreMouseEvent has no meta
627
+ // field; the SGR bit we call 'meta' is wired to alt). Let xterm.js
628
+ // own link-opening; Cmd+click is the native UX there anyway.
629
+ // TERM_PROGRAM is the sync fast-path; isXtermJs() is the XTVERSION
630
+ // probe result (catches SSH + non-VS Code embedders like Hyper).
631
+ if (url && process.env.TERM_PROGRAM !== 'vscode' && !(0, terminal_js_1.isXtermJs)()) {
632
+ // Clear any prior pending timer — clicking a second link
633
+ // supersedes the first (only the latest click opens).
634
+ if (app.pendingHyperlinkTimer) {
635
+ clearTimeout(app.pendingHyperlinkTimer);
636
+ }
637
+ app.pendingHyperlinkTimer = setTimeout((app, url) => {
638
+ app.pendingHyperlinkTimer = null;
639
+ app.props.onOpenHyperlink(url);
640
+ }, MULTI_CLICK_TIMEOUT_MS, app, url);
641
+ }
642
+ }
643
+ }
644
+ app.props.onSelectionChange();
645
+ }
646
+ //# sourceMappingURL=App.js.map