4runr-os 2.1.4 → 2.1.6

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 (566) hide show
  1. package/dist/index.js +16 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/tui_mk1/kernel.d.ts.map +1 -1
  4. package/dist/tui_mk1/kernel.js +107 -4
  5. package/dist/tui_mk1/kernel.js.map +1 -1
  6. package/dist/tui_mk1/layout/layoutEngine.d.ts +38 -19
  7. package/dist/tui_mk1/layout/layoutEngine.d.ts.map +1 -1
  8. package/dist/tui_mk1/layout/layoutEngine.js +521 -228
  9. package/dist/tui_mk1/layout/layoutEngine.js.map +1 -1
  10. package/dist/tui_mk1/log.d.ts +23 -0
  11. package/dist/tui_mk1/log.d.ts.map +1 -0
  12. package/dist/tui_mk1/log.js +125 -0
  13. package/dist/tui_mk1/log.js.map +1 -0
  14. package/dist/tui_mk1/logger.d.ts.map +1 -1
  15. package/dist/tui_mk1/logger.js +20 -10
  16. package/dist/tui_mk1/logger.js.map +1 -1
  17. package/dist/tui_mk1/mk1App.d.ts +13 -18
  18. package/dist/tui_mk1/mk1App.d.ts.map +1 -1
  19. package/dist/tui_mk1/mk1App.js +334 -157
  20. package/dist/tui_mk1/mk1App.js.map +1 -1
  21. package/dist/tui_mk1/resizeController.d.ts.map +1 -1
  22. package/dist/tui_mk1/resizeController.js +15 -1
  23. package/dist/tui_mk1/resizeController.js.map +1 -1
  24. package/dist/tui_mk1/stdoutGuard.d.ts.map +1 -1
  25. package/dist/tui_mk1/stdoutGuard.js +7 -0
  26. package/dist/tui_mk1/stdoutGuard.js.map +1 -1
  27. package/dist/tui_mk1/terminalRestore.d.ts.map +1 -1
  28. package/dist/tui_mk1/terminalRestore.js +19 -1
  29. package/dist/tui_mk1/terminalRestore.js.map +1 -1
  30. package/dist/tui_mk1/ui/offenderScanner.d.ts +31 -0
  31. package/dist/tui_mk1/ui/offenderScanner.d.ts.map +1 -0
  32. package/dist/tui_mk1/ui/offenderScanner.js +80 -0
  33. package/dist/tui_mk1/ui/offenderScanner.js.map +1 -0
  34. package/dist/tui_mk1/ui/safe.d.ts +9 -0
  35. package/dist/tui_mk1/ui/safe.d.ts.map +1 -0
  36. package/dist/tui_mk1/ui/safe.js +29 -0
  37. package/dist/tui_mk1/ui/safe.js.map +1 -0
  38. package/dist/tui_mk1/ui/safeText.d.ts +22 -0
  39. package/dist/tui_mk1/ui/safeText.d.ts.map +1 -0
  40. package/dist/tui_mk1/ui/safeText.js +50 -0
  41. package/dist/tui_mk1/ui/safeText.js.map +1 -0
  42. package/dist/tui_mk1/ui/uiBuilder.d.ts +44 -0
  43. package/dist/tui_mk1/ui/uiBuilder.d.ts.map +1 -0
  44. package/dist/tui_mk1/ui/uiBuilder.js +467 -0
  45. package/dist/tui_mk1/ui/uiBuilder.js.map +1 -0
  46. package/dist/tui_mk1/viewport/safeViewport.d.ts +10 -1
  47. package/dist/tui_mk1/viewport/safeViewport.d.ts.map +1 -1
  48. package/dist/tui_mk1/viewport/safeViewport.js +47 -15
  49. package/dist/tui_mk1/viewport/safeViewport.js.map +1 -1
  50. package/dist/tui_mk2/kernel.d.ts +28 -0
  51. package/dist/tui_mk2/kernel.d.ts.map +1 -0
  52. package/dist/tui_mk2/kernel.js +138 -0
  53. package/dist/tui_mk2/kernel.js.map +1 -0
  54. package/dist/tui_mk2/mk2App.d.ts +33 -0
  55. package/dist/tui_mk2/mk2App.d.ts.map +1 -0
  56. package/dist/tui_mk2/mk2App.js +135 -0
  57. package/dist/tui_mk2/mk2App.js.map +1 -0
  58. package/package.json +8 -7
  59. package/dist/tui_mk1/ui/panels/createSection.d.ts +0 -18
  60. package/dist/tui_mk1/ui/panels/createSection.d.ts.map +0 -1
  61. package/dist/tui_mk1/ui/panels/createSection.js +0 -42
  62. package/dist/tui_mk1/ui/panels/createSection.js.map +0 -1
  63. package/dist/tui_mk1/ui/panels.d.ts +0 -23
  64. package/dist/tui_mk1/ui/panels.d.ts.map +0 -1
  65. package/dist/tui_mk1/ui/panels.js +0 -108
  66. package/dist/tui_mk1/ui/panels.js.map +0 -1
  67. package/dist/tui_mk1/ui/render/sectionRenderer.d.ts +0 -21
  68. package/dist/tui_mk1/ui/render/sectionRenderer.d.ts.map +0 -1
  69. package/dist/tui_mk1/ui/render/sectionRenderer.js +0 -32
  70. package/dist/tui_mk1/ui/render/sectionRenderer.js.map +0 -1
  71. package/dist/tui_mk1/ui/widgetManager.d.ts +0 -58
  72. package/dist/tui_mk1/ui/widgetManager.d.ts.map +0 -1
  73. package/dist/tui_mk1/ui/widgetManager.js +0 -197
  74. package/dist/tui_mk1/ui/widgetManager.js.map +0 -1
  75. package/dist/ui/boot/sequence.d.ts +0 -10
  76. package/dist/ui/boot/sequence.d.ts.map +0 -1
  77. package/dist/ui/boot/sequence.js +0 -171
  78. package/dist/ui/boot/sequence.js.map +0 -1
  79. package/dist/ui/constraints/layoutSpec.d.ts +0 -47
  80. package/dist/ui/constraints/layoutSpec.d.ts.map +0 -1
  81. package/dist/ui/constraints/layoutSpec.js +0 -60
  82. package/dist/ui/constraints/layoutSpec.js.map +0 -1
  83. package/dist/ui/constraints/unknownHandling.d.ts +0 -29
  84. package/dist/ui/constraints/unknownHandling.d.ts.map +0 -1
  85. package/dist/ui/constraints/unknownHandling.js +0 -60
  86. package/dist/ui/constraints/unknownHandling.js.map +0 -1
  87. package/dist/ui/drilldowns/feed.d.ts +0 -11
  88. package/dist/ui/drilldowns/feed.d.ts.map +0 -1
  89. package/dist/ui/drilldowns/feed.js +0 -68
  90. package/dist/ui/drilldowns/feed.js.map +0 -1
  91. package/dist/ui/drilldowns/index.d.ts +0 -7
  92. package/dist/ui/drilldowns/index.d.ts.map +0 -1
  93. package/dist/ui/drilldowns/index.js +0 -8
  94. package/dist/ui/drilldowns/index.js.map +0 -1
  95. package/dist/ui/drilldowns/posture.d.ts +0 -11
  96. package/dist/ui/drilldowns/posture.d.ts.map +0 -1
  97. package/dist/ui/drilldowns/posture.js +0 -74
  98. package/dist/ui/drilldowns/posture.js.map +0 -1
  99. package/dist/ui/intelligence-posture-view.d.ts +0 -22
  100. package/dist/ui/intelligence-posture-view.d.ts.map +0 -1
  101. package/dist/ui/intelligence-posture-view.js +0 -169
  102. package/dist/ui/intelligence-posture-view.js.map +0 -1
  103. package/dist/ui/navigation/keymaps.d.ts +0 -26
  104. package/dist/ui/navigation/keymaps.d.ts.map +0 -1
  105. package/dist/ui/navigation/keymaps.js +0 -135
  106. package/dist/ui/navigation/keymaps.js.map +0 -1
  107. package/dist/ui/navigation/palette.d.ts +0 -10
  108. package/dist/ui/navigation/palette.d.ts.map +0 -1
  109. package/dist/ui/navigation/palette.js +0 -133
  110. package/dist/ui/navigation/palette.js.map +0 -1
  111. package/dist/ui/navigation/state.d.ts +0 -47
  112. package/dist/ui/navigation/state.d.ts.map +0 -1
  113. package/dist/ui/navigation/state.js +0 -84
  114. package/dist/ui/navigation/state.js.map +0 -1
  115. package/dist/ui/navigation/types.d.ts +0 -38
  116. package/dist/ui/navigation/types.d.ts.map +0 -1
  117. package/dist/ui/navigation/types.js +0 -36
  118. package/dist/ui/navigation/types.js.map +0 -1
  119. package/dist/ui/panels/active-assets.d.ts +0 -12
  120. package/dist/ui/panels/active-assets.d.ts.map +0 -1
  121. package/dist/ui/panels/active-assets.js +0 -83
  122. package/dist/ui/panels/active-assets.js.map +0 -1
  123. package/dist/ui/panels/capability-flags.d.ts +0 -12
  124. package/dist/ui/panels/capability-flags.d.ts.map +0 -1
  125. package/dist/ui/panels/capability-flags.js +0 -59
  126. package/dist/ui/panels/capability-flags.js.map +0 -1
  127. package/dist/ui/panels/command-surface.d.ts +0 -12
  128. package/dist/ui/panels/command-surface.d.ts.map +0 -1
  129. package/dist/ui/panels/command-surface.js +0 -55
  130. package/dist/ui/panels/command-surface.js.map +0 -1
  131. package/dist/ui/panels/network-origin.d.ts +0 -12
  132. package/dist/ui/panels/network-origin.d.ts.map +0 -1
  133. package/dist/ui/panels/network-origin.js +0 -79
  134. package/dist/ui/panels/network-origin.js.map +0 -1
  135. package/dist/ui/panels/operations-feed.d.ts +0 -12
  136. package/dist/ui/panels/operations-feed.d.ts.map +0 -1
  137. package/dist/ui/panels/operations-feed.js +0 -90
  138. package/dist/ui/panels/operations-feed.js.map +0 -1
  139. package/dist/ui/panels/posture.d.ts +0 -12
  140. package/dist/ui/panels/posture.d.ts.map +0 -1
  141. package/dist/ui/panels/posture.js +0 -84
  142. package/dist/ui/panels/posture.js.map +0 -1
  143. package/dist/ui/panels/resources.d.ts +0 -11
  144. package/dist/ui/panels/resources.d.ts.map +0 -1
  145. package/dist/ui/panels/resources.js +0 -88
  146. package/dist/ui/panels/resources.js.map +0 -1
  147. package/dist/ui/primitives/Panel.d.ts +0 -25
  148. package/dist/ui/primitives/Panel.d.ts.map +0 -1
  149. package/dist/ui/primitives/Panel.js +0 -59
  150. package/dist/ui/primitives/Panel.js.map +0 -1
  151. package/dist/ui/rendering/metricRenderer.d.ts +0 -24
  152. package/dist/ui/rendering/metricRenderer.d.ts.map +0 -1
  153. package/dist/ui/rendering/metricRenderer.js +0 -86
  154. package/dist/ui/rendering/metricRenderer.js.map +0 -1
  155. package/dist/ui/runtime/hub.d.ts +0 -12
  156. package/dist/ui/runtime/hub.d.ts.map +0 -1
  157. package/dist/ui/runtime/hub.js +0 -486
  158. package/dist/ui/runtime/hub.js.map +0 -1
  159. package/dist/ui/runtime/hubValidation.d.ts +0 -23
  160. package/dist/ui/runtime/hubValidation.d.ts.map +0 -1
  161. package/dist/ui/runtime/hubValidation.js +0 -90
  162. package/dist/ui/runtime/hubValidation.js.map +0 -1
  163. package/dist/ui/runtime/index.d.ts +0 -29
  164. package/dist/ui/runtime/index.d.ts.map +0 -1
  165. package/dist/ui/runtime/index.js +0 -297
  166. package/dist/ui/runtime/index.js.map +0 -1
  167. package/dist/ui/runtime/no-tui.d.ts +0 -12
  168. package/dist/ui/runtime/no-tui.d.ts.map +0 -1
  169. package/dist/ui/runtime/no-tui.js +0 -77
  170. package/dist/ui/runtime/no-tui.js.map +0 -1
  171. package/dist/ui/runtime/state-builder.d.ts +0 -13
  172. package/dist/ui/runtime/state-builder.d.ts.map +0 -1
  173. package/dist/ui/runtime/state-builder.js +0 -114
  174. package/dist/ui/runtime/state-builder.js.map +0 -1
  175. package/dist/ui/runtime/terminalSizeCheck.d.ts +0 -10
  176. package/dist/ui/runtime/terminalSizeCheck.d.ts.map +0 -1
  177. package/dist/ui/runtime/terminalSizeCheck.js +0 -51
  178. package/dist/ui/runtime/terminalSizeCheck.js.map +0 -1
  179. package/dist/ui/runtime/tuiLogGate.d.ts +0 -22
  180. package/dist/ui/runtime/tuiLogGate.d.ts.map +0 -1
  181. package/dist/ui/runtime/tuiLogGate.js +0 -68
  182. package/dist/ui/runtime/tuiLogGate.js.map +0 -1
  183. package/dist/ui/state/types.d.ts +0 -72
  184. package/dist/ui/state/types.d.ts.map +0 -1
  185. package/dist/ui/state/types.js +0 -6
  186. package/dist/ui/state/types.js.map +0 -1
  187. package/dist/ui/theme/borders.d.ts +0 -20
  188. package/dist/ui/theme/borders.d.ts.map +0 -1
  189. package/dist/ui/theme/borders.js +0 -55
  190. package/dist/ui/theme/borders.js.map +0 -1
  191. package/dist/ui/theme/tokens.d.ts +0 -28
  192. package/dist/ui/theme/tokens.d.ts.map +0 -1
  193. package/dist/ui/theme/tokens.js +0 -50
  194. package/dist/ui/theme/tokens.js.map +0 -1
  195. package/dist/ui/theme/typography.d.ts +0 -14
  196. package/dist/ui/theme/typography.d.ts.map +0 -1
  197. package/dist/ui/theme/typography.js +0 -30
  198. package/dist/ui/theme/typography.js.map +0 -1
  199. package/dist/ui/v3/collectors/assets.collector.d.ts +0 -20
  200. package/dist/ui/v3/collectors/assets.collector.d.ts.map +0 -1
  201. package/dist/ui/v3/collectors/assets.collector.js +0 -80
  202. package/dist/ui/v3/collectors/assets.collector.js.map +0 -1
  203. package/dist/ui/v3/collectors/capabilities.collector.d.ts +0 -18
  204. package/dist/ui/v3/collectors/capabilities.collector.d.ts.map +0 -1
  205. package/dist/ui/v3/collectors/capabilities.collector.js +0 -113
  206. package/dist/ui/v3/collectors/capabilities.collector.js.map +0 -1
  207. package/dist/ui/v3/collectors/network.collector.d.ts +0 -18
  208. package/dist/ui/v3/collectors/network.collector.d.ts.map +0 -1
  209. package/dist/ui/v3/collectors/network.collector.js +0 -37
  210. package/dist/ui/v3/collectors/network.collector.js.map +0 -1
  211. package/dist/ui/v3/collectors/posture.derive.d.ts +0 -24
  212. package/dist/ui/v3/collectors/posture.derive.d.ts.map +0 -1
  213. package/dist/ui/v3/collectors/posture.derive.js +0 -57
  214. package/dist/ui/v3/collectors/posture.derive.js.map +0 -1
  215. package/dist/ui/v3/collectors/resources.d.ts +0 -23
  216. package/dist/ui/v3/collectors/resources.d.ts.map +0 -1
  217. package/dist/ui/v3/collectors/resources.js +0 -136
  218. package/dist/ui/v3/collectors/resources.js.map +0 -1
  219. package/dist/ui/v3/commands/commandEngine.d.ts +0 -77
  220. package/dist/ui/v3/commands/commandEngine.d.ts.map +0 -1
  221. package/dist/ui/v3/commands/commandEngine.js +0 -3289
  222. package/dist/ui/v3/commands/commandEngine.js.map +0 -1
  223. package/dist/ui/v3/commands/commandResult.d.ts +0 -25
  224. package/dist/ui/v3/commands/commandResult.d.ts.map +0 -1
  225. package/dist/ui/v3/commands/commandResult.js +0 -19
  226. package/dist/ui/v3/commands/commandResult.js.map +0 -1
  227. package/dist/ui/v3/commands/diagnose.d.ts +0 -17
  228. package/dist/ui/v3/commands/diagnose.d.ts.map +0 -1
  229. package/dist/ui/v3/commands/diagnose.js +0 -62
  230. package/dist/ui/v3/commands/diagnose.js.map +0 -1
  231. package/dist/ui/v3/commands/errorClassifier.d.ts +0 -23
  232. package/dist/ui/v3/commands/errorClassifier.d.ts.map +0 -1
  233. package/dist/ui/v3/commands/errorClassifier.js +0 -63
  234. package/dist/ui/v3/commands/errorClassifier.js.map +0 -1
  235. package/dist/ui/v3/commands/parser.d.ts +0 -14
  236. package/dist/ui/v3/commands/parser.d.ts.map +0 -1
  237. package/dist/ui/v3/commands/parser.js +0 -29
  238. package/dist/ui/v3/commands/parser.js.map +0 -1
  239. package/dist/ui/v3/commands/router.d.ts +0 -13
  240. package/dist/ui/v3/commands/router.d.ts.map +0 -1
  241. package/dist/ui/v3/commands/router.js +0 -150
  242. package/dist/ui/v3/commands/router.js.map +0 -1
  243. package/dist/ui/v3/config/gateway.d.ts +0 -40
  244. package/dist/ui/v3/config/gateway.d.ts.map +0 -1
  245. package/dist/ui/v3/config/gateway.js +0 -113
  246. package/dist/ui/v3/config/gateway.js.map +0 -1
  247. package/dist/ui/v3/core/event.d.ts +0 -19
  248. package/dist/ui/v3/core/event.d.ts.map +0 -1
  249. package/dist/ui/v3/core/event.js +0 -7
  250. package/dist/ui/v3/core/event.js.map +0 -1
  251. package/dist/ui/v3/core/eventBus.d.ts +0 -39
  252. package/dist/ui/v3/core/eventBus.d.ts.map +0 -1
  253. package/dist/ui/v3/core/eventBus.js +0 -79
  254. package/dist/ui/v3/core/eventBus.js.map +0 -1
  255. package/dist/ui/v3/core/feedStore.d.ts +0 -34
  256. package/dist/ui/v3/core/feedStore.d.ts.map +0 -1
  257. package/dist/ui/v3/core/feedStore.js +0 -46
  258. package/dist/ui/v3/core/feedStore.js.map +0 -1
  259. package/dist/ui/v3/core/logger.d.ts +0 -40
  260. package/dist/ui/v3/core/logger.d.ts.map +0 -1
  261. package/dist/ui/v3/core/logger.js +0 -191
  262. package/dist/ui/v3/core/logger.js.map +0 -1
  263. package/dist/ui/v3/core/opEvent.d.ts +0 -15
  264. package/dist/ui/v3/core/opEvent.d.ts.map +0 -1
  265. package/dist/ui/v3/core/opEvent.js +0 -7
  266. package/dist/ui/v3/core/opEvent.js.map +0 -1
  267. package/dist/ui/v3/index.d.ts +0 -8
  268. package/dist/ui/v3/index.d.ts.map +0 -1
  269. package/dist/ui/v3/index.js +0 -51
  270. package/dist/ui/v3/index.js.map +0 -1
  271. package/dist/ui/v3/runtime/moduleConfig.d.ts +0 -21
  272. package/dist/ui/v3/runtime/moduleConfig.d.ts.map +0 -1
  273. package/dist/ui/v3/runtime/moduleConfig.js +0 -41
  274. package/dist/ui/v3/runtime/moduleConfig.js.map +0 -1
  275. package/dist/ui/v3/section0/index.d.ts +0 -22
  276. package/dist/ui/v3/section0/index.d.ts.map +0 -1
  277. package/dist/ui/v3/section0/index.js +0 -88
  278. package/dist/ui/v3/section0/index.js.map +0 -1
  279. package/dist/ui/v3/section0/runtime/createScreen.d.ts +0 -27
  280. package/dist/ui/v3/section0/runtime/createScreen.d.ts.map +0 -1
  281. package/dist/ui/v3/section0/runtime/createScreen.js +0 -55
  282. package/dist/ui/v3/section0/runtime/createScreen.js.map +0 -1
  283. package/dist/ui/v3/section0/runtime/lifecycle.d.ts +0 -53
  284. package/dist/ui/v3/section0/runtime/lifecycle.d.ts.map +0 -1
  285. package/dist/ui/v3/section0/runtime/lifecycle.js +0 -172
  286. package/dist/ui/v3/section0/runtime/lifecycle.js.map +0 -1
  287. package/dist/ui/v3/section1/index.d.ts +0 -19
  288. package/dist/ui/v3/section1/index.d.ts.map +0 -1
  289. package/dist/ui/v3/section1/index.js +0 -413
  290. package/dist/ui/v3/section1/index.js.map +0 -1
  291. package/dist/ui/v3/section1/runtime/commandLine.d.ts +0 -49
  292. package/dist/ui/v3/section1/runtime/commandLine.d.ts.map +0 -1
  293. package/dist/ui/v3/section1/runtime/commandLine.js +0 -183
  294. package/dist/ui/v3/section1/runtime/commandLine.js.map +0 -1
  295. package/dist/ui/v3/section1/runtime/focusLock.d.ts +0 -24
  296. package/dist/ui/v3/section1/runtime/focusLock.d.ts.map +0 -1
  297. package/dist/ui/v3/section1/runtime/focusLock.js +0 -44
  298. package/dist/ui/v3/section1/runtime/focusLock.js.map +0 -1
  299. package/dist/ui/v3/state/assertUiState.d.ts +0 -27
  300. package/dist/ui/v3/state/assertUiState.d.ts.map +0 -1
  301. package/dist/ui/v3/state/assertUiState.js +0 -89
  302. package/dist/ui/v3/state/assertUiState.js.map +0 -1
  303. package/dist/ui/v3/state/capabilitiesStore.d.ts +0 -54
  304. package/dist/ui/v3/state/capabilitiesStore.d.ts.map +0 -1
  305. package/dist/ui/v3/state/capabilitiesStore.js +0 -76
  306. package/dist/ui/v3/state/capabilitiesStore.js.map +0 -1
  307. package/dist/ui/v3/state/defaultState.d.ts +0 -19
  308. package/dist/ui/v3/state/defaultState.d.ts.map +0 -1
  309. package/dist/ui/v3/state/defaultState.js +0 -28
  310. package/dist/ui/v3/state/defaultState.js.map +0 -1
  311. package/dist/ui/v3/state/gatewayConnectionStore.d.ts +0 -72
  312. package/dist/ui/v3/state/gatewayConnectionStore.d.ts.map +0 -1
  313. package/dist/ui/v3/state/gatewayConnectionStore.js +0 -108
  314. package/dist/ui/v3/state/gatewayConnectionStore.js.map +0 -1
  315. package/dist/ui/v3/state/initializePostureState.d.ts +0 -23
  316. package/dist/ui/v3/state/initializePostureState.d.ts.map +0 -1
  317. package/dist/ui/v3/state/initializePostureState.js +0 -41
  318. package/dist/ui/v3/state/initializePostureState.js.map +0 -1
  319. package/dist/ui/v3/state/panelStore.d.ts +0 -80
  320. package/dist/ui/v3/state/panelStore.d.ts.map +0 -1
  321. package/dist/ui/v3/state/panelStore.js +0 -131
  322. package/dist/ui/v3/state/panelStore.js.map +0 -1
  323. package/dist/ui/v3/state/resourcesData.d.ts +0 -15
  324. package/dist/ui/v3/state/resourcesData.d.ts.map +0 -1
  325. package/dist/ui/v3/state/resourcesData.js +0 -7
  326. package/dist/ui/v3/state/resourcesData.js.map +0 -1
  327. package/dist/ui/v3/state/uiState.d.ts +0 -22
  328. package/dist/ui/v3/state/uiState.d.ts.map +0 -1
  329. package/dist/ui/v3/state/uiState.js +0 -13
  330. package/dist/ui/v3/state/uiState.js.map +0 -1
  331. package/dist/ui/v3/state/uiStateBuilder.d.ts +0 -32
  332. package/dist/ui/v3/state/uiStateBuilder.d.ts.map +0 -1
  333. package/dist/ui/v3/state/uiStateBuilder.js +0 -73
  334. package/dist/ui/v3/state/uiStateBuilder.js.map +0 -1
  335. package/dist/ui/v3/state/uiStateTypes.d.ts +0 -59
  336. package/dist/ui/v3/state/uiStateTypes.d.ts.map +0 -1
  337. package/dist/ui/v3/state/uiStateTypes.js +0 -8
  338. package/dist/ui/v3/state/uiStateTypes.js.map +0 -1
  339. package/dist/ui/v3/state/value.d.ts +0 -80
  340. package/dist/ui/v3/state/value.d.ts.map +0 -1
  341. package/dist/ui/v3/state/value.js +0 -96
  342. package/dist/ui/v3/state/value.js.map +0 -1
  343. package/dist/ui/v3/tui/geometry.d.ts +0 -83
  344. package/dist/ui/v3/tui/geometry.d.ts.map +0 -1
  345. package/dist/ui/v3/tui/geometry.js +0 -201
  346. package/dist/ui/v3/tui/geometry.js.map +0 -1
  347. package/dist/ui/v3/tui/startTui.d.ts +0 -37
  348. package/dist/ui/v3/tui/startTui.d.ts.map +0 -1
  349. package/dist/ui/v3/tui/startTui.js +0 -61
  350. package/dist/ui/v3/tui/startTui.js.map +0 -1
  351. package/dist/ui/v3/tui/terminalMode.d.ts +0 -31
  352. package/dist/ui/v3/tui/terminalMode.d.ts.map +0 -1
  353. package/dist/ui/v3/tui/terminalMode.js +0 -76
  354. package/dist/ui/v3/tui/terminalMode.js.map +0 -1
  355. package/dist/ui/v3/ui/debugUtils.d.ts +0 -67
  356. package/dist/ui/v3/ui/debugUtils.d.ts.map +0 -1
  357. package/dist/ui/v3/ui/debugUtils.js +0 -238
  358. package/dist/ui/v3/ui/debugUtils.js.map +0 -1
  359. package/dist/ui/v3/ui/focus.d.ts +0 -28
  360. package/dist/ui/v3/ui/focus.d.ts.map +0 -1
  361. package/dist/ui/v3/ui/focus.js +0 -38
  362. package/dist/ui/v3/ui/focus.js.map +0 -1
  363. package/dist/ui/v3/ui/layout/hubLayout.d.ts +0 -43
  364. package/dist/ui/v3/ui/layout/hubLayout.d.ts.map +0 -1
  365. package/dist/ui/v3/ui/layout/hubLayout.js +0 -170
  366. package/dist/ui/v3/ui/layout/hubLayout.js.map +0 -1
  367. package/dist/ui/v3/ui/layout/phase1Layout.d.ts +0 -63
  368. package/dist/ui/v3/ui/layout/phase1Layout.d.ts.map +0 -1
  369. package/dist/ui/v3/ui/layout/phase1Layout.js +0 -274
  370. package/dist/ui/v3/ui/layout/phase1Layout.js.map +0 -1
  371. package/dist/ui/v3/ui/layout/phase1Layout.test.d.ts +0 -5
  372. package/dist/ui/v3/ui/layout/phase1Layout.test.d.ts.map +0 -1
  373. package/dist/ui/v3/ui/layout/phase1Layout.test.js +0 -120
  374. package/dist/ui/v3/ui/layout/phase1Layout.test.js.map +0 -1
  375. package/dist/ui/v3/ui/minimalRuntime.d.ts +0 -14
  376. package/dist/ui/v3/ui/minimalRuntime.d.ts.map +0 -1
  377. package/dist/ui/v3/ui/minimalRuntime.js +0 -111
  378. package/dist/ui/v3/ui/minimalRuntime.js.map +0 -1
  379. package/dist/ui/v3/ui/panels/AssetsPanel.d.ts +0 -17
  380. package/dist/ui/v3/ui/panels/AssetsPanel.d.ts.map +0 -1
  381. package/dist/ui/v3/ui/panels/AssetsPanel.js +0 -53
  382. package/dist/ui/v3/ui/panels/AssetsPanel.js.map +0 -1
  383. package/dist/ui/v3/ui/panels/CapabilitiesPanel.d.ts +0 -20
  384. package/dist/ui/v3/ui/panels/CapabilitiesPanel.d.ts.map +0 -1
  385. package/dist/ui/v3/ui/panels/CapabilitiesPanel.js +0 -67
  386. package/dist/ui/v3/ui/panels/CapabilitiesPanel.js.map +0 -1
  387. package/dist/ui/v3/ui/panels/NetworkPanel.d.ts +0 -31
  388. package/dist/ui/v3/ui/panels/NetworkPanel.d.ts.map +0 -1
  389. package/dist/ui/v3/ui/panels/NetworkPanel.js +0 -153
  390. package/dist/ui/v3/ui/panels/NetworkPanel.js.map +0 -1
  391. package/dist/ui/v3/ui/panels/PosturePanel.d.ts +0 -16
  392. package/dist/ui/v3/ui/panels/PosturePanel.d.ts.map +0 -1
  393. package/dist/ui/v3/ui/panels/PosturePanel.js +0 -60
  394. package/dist/ui/v3/ui/panels/PosturePanel.js.map +0 -1
  395. package/dist/ui/v3/ui/panels/ResourcesPanel.d.ts +0 -20
  396. package/dist/ui/v3/ui/panels/ResourcesPanel.d.ts.map +0 -1
  397. package/dist/ui/v3/ui/panels/ResourcesPanel.js +0 -66
  398. package/dist/ui/v3/ui/panels/ResourcesPanel.js.map +0 -1
  399. package/dist/ui/v3/ui/phase1Runtime.d.ts +0 -29
  400. package/dist/ui/v3/ui/phase1Runtime.d.ts.map +0 -1
  401. package/dist/ui/v3/ui/phase1Runtime.js +0 -1648
  402. package/dist/ui/v3/ui/phase1Runtime.js.map +0 -1
  403. package/dist/ui/v3/ui/phase1RuntimeClean.d.ts +0 -34
  404. package/dist/ui/v3/ui/phase1RuntimeClean.d.ts.map +0 -1
  405. package/dist/ui/v3/ui/phase1RuntimeClean.js +0 -1841
  406. package/dist/ui/v3/ui/phase1RuntimeClean.js.map +0 -1
  407. package/dist/ui/v3/ui/primitives/Panel.d.ts +0 -39
  408. package/dist/ui/v3/ui/primitives/Panel.d.ts.map +0 -1
  409. package/dist/ui/v3/ui/primitives/Panel.js +0 -105
  410. package/dist/ui/v3/ui/primitives/Panel.js.map +0 -1
  411. package/dist/ui/v3/ui/theme.d.ts +0 -37
  412. package/dist/ui/v3/ui/theme.d.ts.map +0 -1
  413. package/dist/ui/v3/ui/theme.js +0 -40
  414. package/dist/ui/v3/ui/theme.js.map +0 -1
  415. package/dist/ui/v3/ui/uiRuntime.d.ts +0 -40
  416. package/dist/ui/v3/ui/uiRuntime.d.ts.map +0 -1
  417. package/dist/ui/v3/ui/uiRuntime.js +0 -60
  418. package/dist/ui/v3/ui/uiRuntime.js.map +0 -1
  419. package/dist/ui/v3/ui/widgets/CommandLine.d.ts +0 -26
  420. package/dist/ui/v3/ui/widgets/CommandLine.d.ts.map +0 -1
  421. package/dist/ui/v3/ui/widgets/CommandLine.js +0 -67
  422. package/dist/ui/v3/ui/widgets/CommandLine.js.map +0 -1
  423. package/dist/ui/v3/v1Adapters/agents.d.ts +0 -72
  424. package/dist/ui/v3/v1Adapters/agents.d.ts.map +0 -1
  425. package/dist/ui/v3/v1Adapters/agents.js +0 -182
  426. package/dist/ui/v3/v1Adapters/agents.js.map +0 -1
  427. package/dist/ui/v3/v1Adapters/config.d.ts +0 -67
  428. package/dist/ui/v3/v1Adapters/config.d.ts.map +0 -1
  429. package/dist/ui/v3/v1Adapters/config.js +0 -78
  430. package/dist/ui/v3/v1Adapters/config.js.map +0 -1
  431. package/dist/ui/v3/v1Adapters/connect.d.ts +0 -77
  432. package/dist/ui/v3/v1Adapters/connect.d.ts.map +0 -1
  433. package/dist/ui/v3/v1Adapters/connect.js +0 -576
  434. package/dist/ui/v3/v1Adapters/connect.js.map +0 -1
  435. package/dist/ui/v3/v1Adapters/httpDebug.d.ts +0 -19
  436. package/dist/ui/v3/v1Adapters/httpDebug.d.ts.map +0 -1
  437. package/dist/ui/v3/v1Adapters/httpDebug.js +0 -60
  438. package/dist/ui/v3/v1Adapters/httpDebug.js.map +0 -1
  439. package/dist/ui/v3/v1Adapters/runs.d.ts +0 -77
  440. package/dist/ui/v3/v1Adapters/runs.d.ts.map +0 -1
  441. package/dist/ui/v3/v1Adapters/runs.js +0 -339
  442. package/dist/ui/v3/v1Adapters/runs.js.map +0 -1
  443. package/dist/ui/v4/engine/renderFrame.d.ts +0 -47
  444. package/dist/ui/v4/engine/renderFrame.d.ts.map +0 -1
  445. package/dist/ui/v4/engine/renderFrame.js +0 -653
  446. package/dist/ui/v4/engine/renderFrame.js.map +0 -1
  447. package/dist/ui/v4/engine/resizeController.d.ts +0 -48
  448. package/dist/ui/v4/engine/resizeController.d.ts.map +0 -1
  449. package/dist/ui/v4/engine/resizeController.js +0 -285
  450. package/dist/ui/v4/engine/resizeController.js.map +0 -1
  451. package/dist/ui/v4/engine/safeViewport.d.ts +0 -47
  452. package/dist/ui/v4/engine/safeViewport.d.ts.map +0 -1
  453. package/dist/ui/v4/engine/safeViewport.js +0 -123
  454. package/dist/ui/v4/engine/safeViewport.js.map +0 -1
  455. package/dist/ui/v4/engine/terminalProfile.d.ts +0 -56
  456. package/dist/ui/v4/engine/terminalProfile.d.ts.map +0 -1
  457. package/dist/ui/v4/engine/terminalProfile.js +0 -115
  458. package/dist/ui/v4/engine/terminalProfile.js.map +0 -1
  459. package/dist/ui/v4/index.d.ts +0 -28
  460. package/dist/ui/v4/index.d.ts.map +0 -1
  461. package/dist/ui/v4/index.js +0 -993
  462. package/dist/ui/v4/index.js.map +0 -1
  463. package/dist/ui/v4/layout/layoutEngine.d.ts +0 -62
  464. package/dist/ui/v4/layout/layoutEngine.d.ts.map +0 -1
  465. package/dist/ui/v4/layout/layoutEngine.js +0 -294
  466. package/dist/ui/v4/layout/layoutEngine.js.map +0 -1
  467. package/dist/ui/v4/runtime/keepAlive.d.ts +0 -21
  468. package/dist/ui/v4/runtime/keepAlive.d.ts.map +0 -1
  469. package/dist/ui/v4/runtime/keepAlive.js +0 -149
  470. package/dist/ui/v4/runtime/keepAlive.js.map +0 -1
  471. package/dist/ui/v4/runtime/logger.d.ts +0 -35
  472. package/dist/ui/v4/runtime/logger.d.ts.map +0 -1
  473. package/dist/ui/v4/runtime/logger.js +0 -109
  474. package/dist/ui/v4/runtime/logger.js.map +0 -1
  475. package/dist/ui/v5/debug/assertNoOverflow.d.ts +0 -28
  476. package/dist/ui/v5/debug/assertNoOverflow.d.ts.map +0 -1
  477. package/dist/ui/v5/debug/assertNoOverflow.js +0 -63
  478. package/dist/ui/v5/debug/assertNoOverflow.js.map +0 -1
  479. package/dist/ui/v5/debug/debugCommands.d.ts +0 -20
  480. package/dist/ui/v5/debug/debugCommands.d.ts.map +0 -1
  481. package/dist/ui/v5/debug/debugCommands.js +0 -461
  482. package/dist/ui/v5/debug/debugCommands.js.map +0 -1
  483. package/dist/ui/v5/debugCommands.d.ts +0 -20
  484. package/dist/ui/v5/debugCommands.d.ts.map +0 -1
  485. package/dist/ui/v5/debugCommands.js +0 -81
  486. package/dist/ui/v5/debugCommands.js.map +0 -1
  487. package/dist/ui/v5/guardrails/stdoutGuard.d.ts +0 -23
  488. package/dist/ui/v5/guardrails/stdoutGuard.d.ts.map +0 -1
  489. package/dist/ui/v5/guardrails/stdoutGuard.js +0 -94
  490. package/dist/ui/v5/guardrails/stdoutGuard.js.map +0 -1
  491. package/dist/ui/v5/guardrails/terminalRestore.d.ts +0 -17
  492. package/dist/ui/v5/guardrails/terminalRestore.d.ts.map +0 -1
  493. package/dist/ui/v5/guardrails/terminalRestore.js +0 -47
  494. package/dist/ui/v5/guardrails/terminalRestore.js.map +0 -1
  495. package/dist/ui/v5/index.d.ts +0 -30
  496. package/dist/ui/v5/index.d.ts.map +0 -1
  497. package/dist/ui/v5/index.js +0 -243
  498. package/dist/ui/v5/index.js.map +0 -1
  499. package/dist/ui/v5/kernel/kernel.d.ts +0 -81
  500. package/dist/ui/v5/kernel/kernel.d.ts.map +0 -1
  501. package/dist/ui/v5/kernel/kernel.js +0 -339
  502. package/dist/ui/v5/kernel/kernel.js.map +0 -1
  503. package/dist/ui/v5/kernel.d.ts +0 -75
  504. package/dist/ui/v5/kernel.d.ts.map +0 -1
  505. package/dist/ui/v5/kernel.js +0 -289
  506. package/dist/ui/v5/kernel.js.map +0 -1
  507. package/dist/ui/v5/layout/clampRect.d.ts +0 -28
  508. package/dist/ui/v5/layout/clampRect.d.ts.map +0 -1
  509. package/dist/ui/v5/layout/clampRect.js +0 -45
  510. package/dist/ui/v5/layout/clampRect.js.map +0 -1
  511. package/dist/ui/v5/layout/layoutEngine.d.ts +0 -16
  512. package/dist/ui/v5/layout/layoutEngine.d.ts.map +0 -1
  513. package/dist/ui/v5/layout/layoutEngine.js +0 -99
  514. package/dist/ui/v5/layout/layoutEngine.js.map +0 -1
  515. package/dist/ui/v5/renderGate.d.ts +0 -19
  516. package/dist/ui/v5/renderGate.d.ts.map +0 -1
  517. package/dist/ui/v5/renderGate.js +0 -36
  518. package/dist/ui/v5/renderGate.js.map +0 -1
  519. package/dist/ui/v5/resize/resizeController.d.ts +0 -62
  520. package/dist/ui/v5/resize/resizeController.d.ts.map +0 -1
  521. package/dist/ui/v5/resize/resizeController.js +0 -141
  522. package/dist/ui/v5/resize/resizeController.js.map +0 -1
  523. package/dist/ui/v5/resizeController.d.ts +0 -55
  524. package/dist/ui/v5/resizeController.d.ts.map +0 -1
  525. package/dist/ui/v5/resizeController.js +0 -124
  526. package/dist/ui/v5/resizeController.js.map +0 -1
  527. package/dist/ui/v5/runtime/keepAlive.d.ts +0 -37
  528. package/dist/ui/v5/runtime/keepAlive.d.ts.map +0 -1
  529. package/dist/ui/v5/runtime/keepAlive.js +0 -122
  530. package/dist/ui/v5/runtime/keepAlive.js.map +0 -1
  531. package/dist/ui/v5/runtime/restoreTerminal.d.ts +0 -34
  532. package/dist/ui/v5/runtime/restoreTerminal.d.ts.map +0 -1
  533. package/dist/ui/v5/runtime/restoreTerminal.js +0 -100
  534. package/dist/ui/v5/runtime/restoreTerminal.js.map +0 -1
  535. package/dist/ui/v5/runtime/stdoutGuard.d.ts +0 -42
  536. package/dist/ui/v5/runtime/stdoutGuard.d.ts.map +0 -1
  537. package/dist/ui/v5/runtime/stdoutGuard.js +0 -156
  538. package/dist/ui/v5/runtime/stdoutGuard.js.map +0 -1
  539. package/dist/ui/v5/viewport/getViewport.d.ts +0 -23
  540. package/dist/ui/v5/viewport/getViewport.d.ts.map +0 -1
  541. package/dist/ui/v5/viewport/getViewport.js +0 -117
  542. package/dist/ui/v5/viewport/getViewport.js.map +0 -1
  543. package/dist/ui/v5/viewport.d.ts +0 -41
  544. package/dist/ui/v5/viewport.d.ts.map +0 -1
  545. package/dist/ui/v5/viewport.js +0 -90
  546. package/dist/ui/v5/viewport.js.map +0 -1
  547. package/dist/ui/widgets/flagRow.d.ts +0 -25
  548. package/dist/ui/widgets/flagRow.d.ts.map +0 -1
  549. package/dist/ui/widgets/flagRow.js +0 -57
  550. package/dist/ui/widgets/flagRow.js.map +0 -1
  551. package/dist/ui/widgets/index.d.ts +0 -9
  552. package/dist/ui/widgets/index.d.ts.map +0 -1
  553. package/dist/ui/widgets/index.js +0 -9
  554. package/dist/ui/widgets/index.js.map +0 -1
  555. package/dist/ui/widgets/meter.d.ts +0 -18
  556. package/dist/ui/widgets/meter.d.ts.map +0 -1
  557. package/dist/ui/widgets/meter.js +0 -38
  558. package/dist/ui/widgets/meter.js.map +0 -1
  559. package/dist/ui/widgets/miniMap.d.ts +0 -26
  560. package/dist/ui/widgets/miniMap.d.ts.map +0 -1
  561. package/dist/ui/widgets/miniMap.js +0 -94
  562. package/dist/ui/widgets/miniMap.js.map +0 -1
  563. package/dist/ui/widgets/sparkline.d.ts +0 -17
  564. package/dist/ui/widgets/sparkline.d.ts.map +0 -1
  565. package/dist/ui/widgets/sparkline.js +0 -65
  566. package/dist/ui/widgets/sparkline.js.map +0 -1
@@ -1,993 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 4Runr Terminal UI V4 - Main Entry
4
- *
5
- * ⚠️ FROZEN STATUS ⚠️
6
- *
7
- * This version is FROZEN due to display issues.
8
- * Development has moved to V5.
9
- *
10
- * DO NOT MODIFY THIS CODE.
11
- *
12
- * Phase 2: Bulletproof Layout + Resize System
13
- *
14
- * Boot with: TUI_V4=1 (NOT RECOMMENDED)
15
- *
16
- * See FROZEN.md for details.
17
- */
18
- import blessed from 'neo-blessed';
19
- import { eventBus } from '../../core/eventBus.js';
20
- import { commandRegistry } from '../../core/commandRegistry.js';
21
- import { executeCommandLine } from '../../core/commandExecutor.js';
22
- import { handleSizeCommandWithScreen } from '../../core/commands/size.js';
23
- import { computeLayout, validateLayoutInvariant } from './layout/layoutEngine.js';
24
- import { initResizeController, destroyResizeController, getResizeStats, getTerminalSize } from './engine/resizeController.js';
25
- import { getSafeViewport } from './engine/safeViewport.js';
26
- import { renderFrame } from './engine/renderFrame.js';
27
- import { getTerminalProfile } from './engine/terminalProfile.js';
28
- import { attachTuiRuntime } from './runtime/keepAlive.js';
29
- import { tuiDebug, tuiError } from './runtime/logger.js';
30
- /**
31
- * Contract C: Stdout is owned by the TUI (no logs)
32
- *
33
- * Rule: once the screen is created:
34
- * - no console.log
35
- * - no raw process.stdout.write
36
- * - all debug goes to stderr or a file
37
- * - all user output goes through Operations feed only
38
- *
39
- * Code-level guard: monkey-patch console.log to redirect to stderr
40
- */
41
- let screenCreated = false;
42
- const originalConsoleLog = console.log;
43
- const originalStdoutWrite = process.stdout.write.bind(process.stdout);
44
- // Contract C: Guard console.log once screen is created
45
- function guardStdout() {
46
- if (!screenCreated)
47
- return;
48
- // Redirect console.log to stderr (safe)
49
- console.log = (...args) => {
50
- const msg = args.map(a => String(a)).join(' ');
51
- tuiError('BLOCKED console.log:', msg);
52
- // Also write to stderr safely
53
- try {
54
- process.stderr.write(`[V4 BLOCKED console.log] ${msg}\n`);
55
- }
56
- catch {
57
- // Ignore
58
- }
59
- };
60
- // Guard process.stdout.write (already wrapped, but ensure it stays wrapped)
61
- }
62
- // Contract C: Guard process.stdout.write
63
- function setupStdoutGuard(screen) {
64
- screenCreated = true;
65
- // Wrap stdout.write to detect/prevent long lines
66
- process.stdout.write = function (chunk, encoding, callback) {
67
- // Get current safeCols (dynamic, handles resize)
68
- const viewport = getSafeViewport(screen);
69
- const safeCols = viewport.cols;
70
- const str = typeof chunk === 'string' ? chunk : chunk.toString();
71
- const lines = str.split('\n');
72
- // Check for lines longer than safeCols
73
- for (const line of lines) {
74
- if (line.length > safeCols - 5) { // -5 for safety margin
75
- // Log warning to eventBus instead of printing (prevents overflow)
76
- eventBus.emit({
77
- id: `stdout-overflow-${Date.now()}`,
78
- tag: 'WARN',
79
- level: 'WARN',
80
- msg: `⚠️ stdout line truncated (${line.length} > ${safeCols - 5}): ${line.substring(0, 50)}...`,
81
- ts: Date.now(),
82
- });
83
- const truncated = line.substring(0, safeCols - 5);
84
- return originalStdoutWrite(truncated + '\n', encoding, callback);
85
- }
86
- }
87
- return originalStdoutWrite(chunk, encoding, callback);
88
- };
89
- // Enable console.log guard
90
- guardStdout();
91
- }
92
- /**
93
- * Contract C: Debug helper - uses tuiDebug (stderr/file, gated by TUI_DEBUG=1)
94
- * UI owns stdout. Logs go to stderr or file. No exceptions.
95
- */
96
- const dbg = tuiDebug; // Use the centralized logger
97
- const tuiLog = tuiDebug; // Backward compatibility
98
- /**
99
- * V4 TUI State
100
- */
101
- class V4TUI {
102
- screen;
103
- widgets = null; // Public for eventBus subscription
104
- currentLayout = null;
105
- commandInputValue = '';
106
- layoutOverlayEnabled = false;
107
- overlayBox = null;
108
- terminalProfile = null;
109
- constructor(screen) {
110
- this.screen = screen;
111
- }
112
- /**
113
- * Set terminal profile (called during initialization)
114
- */
115
- setTerminalProfile(profile) {
116
- this.terminalProfile = profile;
117
- }
118
- /**
119
- * Get terminal profile
120
- */
121
- getTerminalProfile() {
122
- return this.terminalProfile;
123
- }
124
- /**
125
- * Initialize V4 TUI
126
- */
127
- async init() {
128
- // Rule 1: Get safe viewport (always cols - 1)
129
- const viewport = getSafeViewport(this.screen);
130
- // Compute initial layout using safe viewport
131
- this.currentLayout = computeLayout(viewport);
132
- // A) Log to stderr only (never stdout)
133
- const { mode, columns } = this.currentLayout;
134
- const leftRight = columns.left.left + columns.left.width + 2;
135
- const centerRight = columns.center.left + columns.center.width + 2;
136
- const rightRight = columns.right.left + columns.right.width + 1;
137
- dbg('Layout:', `mode=${mode}, safeCols=${viewport.cols}`);
138
- dbg('Right edges:', `left=${leftRight}, center=${centerRight}, right=${rightRight}, safeCols=${viewport.cols}`);
139
- if (leftRight > viewport.cols || centerRight > viewport.cols || rightRight > viewport.cols) {
140
- dbg('ERROR: Some panel exceeds safeCols!');
141
- }
142
- // Initial render (includes watermark as part of widgets)
143
- // A) Render Guard: catch errors on boot
144
- // Use ASCII borders if in safe mode to prevent symbol corruption
145
- const useAsciiBorders = this.terminalProfile?.isSafeMode || false;
146
- try {
147
- this.widgets = renderFrame(this.screen, this.currentLayout, null, this.commandInputValue, true, useAsciiBorders);
148
- }
149
- catch (error) {
150
- // Step 1: Render failed on boot - use tuiError (always goes to stderr)
151
- const errorMsg = error instanceof Error ? error.message : String(error);
152
- tuiError('BOOT ERROR:', errorMsg);
153
- tuiError('Viewport:', `${viewport.cols}x${viewport.rows}`);
154
- tuiError('Press Ctrl+C to exit');
155
- // Also try to show on screen if possible
156
- const program = this.screen.program;
157
- if (program && typeof program.write === 'function') {
158
- try {
159
- program.write('\r\n\x1b[31m[V4 BOOT ERROR]\x1b[0m\r\n');
160
- program.write(`Error: ${errorMsg}\r\n`);
161
- program.write(`Viewport: ${viewport.cols}x${viewport.rows}\r\n`);
162
- program.write(`Press Ctrl+C to exit\r\n`);
163
- program.flush();
164
- }
165
- catch {
166
- // Ignore if screen write fails
167
- }
168
- }
169
- throw error;
170
- }
171
- // Setup resize controller
172
- initResizeController(this.screen, async (newSize) => {
173
- await this.handleResize(newSize);
174
- });
175
- // Setup input handling
176
- this.setupInputHandling();
177
- // Setup overlay toggle command
178
- this.setupCommands();
179
- // CRITICAL: Ensure screen is rendered after all setup
180
- // Force a full render cycle to make widgets visible
181
- // Don't render multiple times - it can cause black screens in CloudShell
182
- this.screen.render();
183
- }
184
- /**
185
- * Contract E: Handle resize (atomic, no mutation storms)
186
- *
187
- * Rule: on resize commit:
188
- * 1. debounce (handled by resizeController)
189
- * 2. destroy widgets
190
- * 3. recompute layout from safe viewport
191
- * 4. rebuild
192
- * 5. render
193
- * 6. refocus command input
194
- *
195
- * No partial mutation. No duplicate panels.
196
- */
197
- async handleResize(size) {
198
- // Contract A: Get safe viewport (strict bounds)
199
- const viewport = getSafeViewport(this.screen);
200
- // Contract E: Compute new layout using safe viewport (no mutation)
201
- const newLayout = computeLayout(viewport);
202
- // Contract E: Preserve command input (atomic - get before destroy)
203
- if (this.widgets?.commandLine) {
204
- try {
205
- this.commandInputValue = this.widgets.commandLine.getValue();
206
- }
207
- catch (error) {
208
- // Ignore if commandLine is being destroyed
209
- this.commandInputValue = '';
210
- }
211
- }
212
- // Contract E: Atomic teardown + rebuild (destroy widgets, then rebuild)
213
- // D) Use ASCII borders if in safe mode to prevent symbol corruption
214
- const useAsciiBorders = this.terminalProfile?.isSafeMode || false;
215
- this.widgets = renderFrame(this.screen, newLayout, this.widgets, this.commandInputValue, false, useAsciiBorders);
216
- // Contract E: Re-attach input handlers (widgets were recreated - no mutation of old widgets)
217
- this.attachCommandLineHandlers();
218
- // Contract E: Update current layout (atomic - one assignment)
219
- this.currentLayout = newLayout;
220
- // Contract E: Update overlay if enabled (watermark is handled by renderFrame)
221
- if (this.layoutOverlayEnabled) {
222
- this.updateOverlay();
223
- }
224
- }
225
- /**
226
- * Setup input handling
227
- */
228
- setupInputHandling() {
229
- // Ensure stdin is active (blessed handles this, but ensure it's set)
230
- if (process.stdin.isTTY) {
231
- process.stdin.setRawMode(true);
232
- process.stdin.setEncoding('utf8');
233
- process.stdin.resume();
234
- }
235
- // Re-setup after each resize (widgets may be recreated)
236
- this.attachCommandLineHandlers();
237
- }
238
- /**
239
- * Attach command line handlers (called after resize)
240
- *
241
- * CRITICAL: Manual input handling for broken terminals
242
- * Textbox widget doesn't work in browser terminals (CloudShell/EC2 Instance Connect)
243
- * Handle input manually via screen.key() events
244
- */
245
- attachCommandLineHandlers() {
246
- if (!this.widgets?.commandLine) {
247
- return;
248
- }
249
- const cmdBox = this.widgets.commandLine;
250
- const PROMPT = cmdBox.__prompt || '4runr> ';
251
- // Track if we've already attached handlers to prevent duplicates
252
- if (this.screen.__commandLineHandlersAttached) {
253
- return; // Already attached
254
- }
255
- this.screen.__commandLineHandlersAttached = true;
256
- // Focus command line box
257
- cmdBox.focus();
258
- this.screen.focused = cmdBox;
259
- // Manual input handling via screen.key()
260
- this.screen.key(['C-c'], () => {
261
- process.exit(0);
262
- });
263
- // Handle all keypress events manually
264
- this.screen.on('keypress', async (ch, key) => {
265
- // Only handle if command line is focused
266
- if (this.screen.focused !== cmdBox) {
267
- return;
268
- }
269
- let currentValue = cmdBox.__value || '';
270
- // Handle Enter key (submit)
271
- if (key.name === 'enter' || key.name === 'return') {
272
- if (currentValue.trim()) {
273
- // Execute command
274
- await executeCommandLine(currentValue.trim(), {}, true);
275
- // Clear command line
276
- currentValue = '';
277
- cmdBox.__value = '';
278
- cmdBox.setContent(PROMPT);
279
- this.commandInputValue = '';
280
- // Render
281
- this.screen.render();
282
- }
283
- return;
284
- }
285
- // Handle Backspace
286
- if (key.name === 'backspace' || key.name === 'delete') {
287
- currentValue = currentValue.slice(0, -1);
288
- cmdBox.__value = currentValue;
289
- cmdBox.setContent(PROMPT + currentValue);
290
- this.commandInputValue = currentValue;
291
- this.screen.render();
292
- return;
293
- }
294
- // Handle printable characters (ASCII only to avoid symbol corruption)
295
- if (ch && typeof ch === 'string' && /[\x20-\x7E]/.test(ch)) {
296
- currentValue += ch;
297
- cmdBox.__value = currentValue;
298
- cmdBox.setContent(PROMPT + currentValue);
299
- this.commandInputValue = currentValue;
300
- this.screen.render();
301
- }
302
- });
303
- }
304
- /**
305
- * Setup debug commands
306
- */
307
- setupCommands() {
308
- // dbg:size command
309
- commandRegistry.register({
310
- name: 'dbg:size',
311
- help: 'dbg:size - Show terminal sizing and environment info',
312
- handler: (ctx, args) => {
313
- return handleSizeCommandWithScreen(ctx, args, {
314
- width: this.screen.width,
315
- height: this.screen.height,
316
- cols: this.screen.cols || getTerminalSize(this.screen).cols,
317
- rows: this.screen.rows || getTerminalSize(this.screen).rows,
318
- });
319
- },
320
- });
321
- // dbg:layout toggle command
322
- commandRegistry.register({
323
- name: 'dbg:layout',
324
- help: 'dbg:layout - Toggle layout debug overlay (on/off)',
325
- handler: (ctx, args) => {
326
- const arg = args[0]?.toLowerCase();
327
- const enabled = arg === 'on' || (arg !== 'off' && !this.layoutOverlayEnabled);
328
- this.layoutOverlayEnabled = enabled;
329
- if (this.layoutOverlayEnabled) {
330
- this.createOverlay();
331
- this.updateOverlay();
332
- }
333
- else {
334
- this.removeOverlay();
335
- }
336
- return {
337
- events: [{
338
- id: `overlay-${Date.now()}`,
339
- tag: 'SYS',
340
- level: 'INFO',
341
- msg: `Layout overlay ${this.layoutOverlayEnabled ? 'enabled' : 'disabled'}`,
342
- ts: Date.now(),
343
- }],
344
- actions: [],
345
- };
346
- },
347
- });
348
- // dbg:probe command - Step 5: Visual proof probe (draws marker at safeCols-1)
349
- commandRegistry.register({
350
- name: 'dbg:probe',
351
- help: 'dbg:probe - Draw visual proof marker at right edge (x = safeCols - 1)',
352
- handler: (ctx, args) => {
353
- const events = [];
354
- if (!this.widgets?.viewport) {
355
- events.push({
356
- id: `probe-${Date.now()}`,
357
- tag: 'ERR',
358
- level: 'ERROR',
359
- msg: 'No viewport container found',
360
- ts: Date.now(),
361
- });
362
- return { events, actions: [] };
363
- }
364
- const viewport = getSafeViewport(this.screen);
365
- const viewportBox = this.widgets.viewport;
366
- // Get current content
367
- const currentContent = viewportBox.content || '';
368
- // Draw vertical line at x = safeCols - 1 on every row
369
- let probeContent = '';
370
- for (let row = 0; row < Math.min(viewport.rows, 20); row++) {
371
- const line = ' '.repeat(Math.max(0, viewport.cols - 2)) + '|'; // Vertical line at safeCols - 1
372
- probeContent += line + '\n';
373
- }
374
- // Add probe text at top-right
375
- const probeText = `safeCols=${viewport.cols}`;
376
- const topLine = ' '.repeat(Math.max(0, viewport.cols - probeText.length - 2)) + probeText + '|';
377
- probeContent = topLine + '\n' + probeContent.substring(topLine.length + 1);
378
- // Set content (temporarily)
379
- viewportBox.setContent(probeContent);
380
- this.screen.render();
381
- events.push({
382
- id: `probe-${Date.now()}`,
383
- tag: 'DBG',
384
- level: 'INFO',
385
- msg: `Visual probe drawn: vertical line at x=${viewport.cols - 1}, text="${probeText}"`,
386
- ts: Date.now(),
387
- });
388
- events.push({
389
- id: `probe-${Date.now()}-2`,
390
- tag: 'DBG',
391
- level: 'INFO',
392
- msg: `If marker is visible and scrollbar still appears, overflow is NOT from layout (rogue stdout or DOM issue)`,
393
- ts: Date.now(),
394
- });
395
- // Restore after 3 seconds
396
- setTimeout(() => {
397
- if (this.widgets?.operations) {
398
- const opsBox = this.widgets.operations;
399
- opsBox.setContent(opsBox.content || '');
400
- }
401
- this.screen.render();
402
- }, 3000);
403
- return { events, actions: [] };
404
- },
405
- });
406
- // dbg:viewport command - Rule 5: Proof command for CloudShell
407
- commandRegistry.register({
408
- name: 'dbg:viewport',
409
- help: 'dbg:viewport - Show safe viewport and panel boundaries (proves no scrollbar)',
410
- handler: (ctx, args) => {
411
- const events = [];
412
- if (!this.currentLayout) {
413
- events.push({
414
- id: `viewport-${Date.now()}`,
415
- tag: 'ERR',
416
- level: 'ERROR',
417
- msg: 'No layout computed yet',
418
- ts: Date.now(),
419
- });
420
- return { events, actions: [] };
421
- }
422
- const viewport = getSafeViewport(this.screen);
423
- const { mode, columns, raw } = this.currentLayout;
424
- events.push({
425
- id: `viewport-${Date.now()}-1`,
426
- tag: 'DBG',
427
- level: 'INFO',
428
- msg: `=== Safe Viewport Check (Hard Invariant: x >= safeCols is forbidden) ===`,
429
- ts: Date.now(),
430
- });
431
- // Environment info
432
- events.push({
433
- id: `viewport-${Date.now()}-env`,
434
- tag: 'DBG',
435
- level: 'INFO',
436
- msg: `Platform: ${viewport.platform} | TERM: ${viewport.term} | Browser: ${viewport.isBrowserTerminal ? 'YES' : 'NO'}`,
437
- ts: Date.now(),
438
- });
439
- events.push({
440
- id: `viewport-${Date.now()}-2`,
441
- tag: 'DBG',
442
- level: 'INFO',
443
- msg: `Sources: screen.cols=${viewport.screenCols} stdout=${viewport.stdoutCols || 'N/A'} env=${viewport.envCols || 'N/A'}`,
444
- ts: Date.now(),
445
- });
446
- events.push({
447
- id: `viewport-${Date.now()}-3`,
448
- tag: 'DBG',
449
- level: 'INFO',
450
- msg: `Effective: rawCols=${viewport.rawCols} rawRows=${viewport.rawRows}`,
451
- ts: Date.now(),
452
- });
453
- events.push({
454
- id: `viewport-${Date.now()}-4`,
455
- tag: 'DBG',
456
- level: 'INFO',
457
- msg: `Safe: safeCols=${viewport.cols} safeRows=${viewport.rows} (margins: right=${viewport.rightMargin}, bottom=${viewport.bottomMargin})`,
458
- ts: Date.now(),
459
- });
460
- events.push({
461
- id: `viewport-${Date.now()}-5`,
462
- tag: 'DBG',
463
- level: 'INFO',
464
- msg: `Layout mode: ${mode}`,
465
- ts: Date.now(),
466
- });
467
- // Validate invariant
468
- const violations = validateLayoutInvariant(this.currentLayout, viewport.cols, viewport.rows);
469
- if (violations.length > 0) {
470
- events.push({
471
- id: `viewport-${Date.now()}-violations`,
472
- tag: 'ERR',
473
- level: 'ERROR',
474
- msg: `❌ INVARIANT VIOLATIONS (${violations.length}):`,
475
- ts: Date.now(),
476
- });
477
- for (const violation of violations) {
478
- events.push({
479
- id: `viewport-${Date.now()}-viol-${violation.panel}`,
480
- tag: 'ERR',
481
- level: 'ERROR',
482
- msg: ` ${violation.panel}: ${violation.violation}`,
483
- ts: Date.now(),
484
- });
485
- }
486
- }
487
- else {
488
- events.push({
489
- id: `viewport-${Date.now()}-invariant`,
490
- tag: 'DBG',
491
- level: 'INFO',
492
- msg: `✓ Invariant check: All panels satisfy x + w + borderPad <= safeCols`,
493
- ts: Date.now(),
494
- });
495
- }
496
- // Calculate column widths and right edges
497
- const leftW = columns.left.width;
498
- const centerW = columns.center.width;
499
- const rightW = columns.right.width;
500
- events.push({
501
- id: `viewport-${Date.now()}-widths`,
502
- tag: 'DBG',
503
- level: 'INFO',
504
- msg: `Panel widths: left=${leftW} center=${centerW} right=${rightW} (sum=${leftW + centerW + rightW})`,
505
- ts: Date.now(),
506
- });
507
- // Show right edges with border accounting
508
- const LEFT_BORDER_PAD = 1;
509
- const RIGHT_BORDER_PAD = 1;
510
- if (columns.left.width > 0) {
511
- const leftRightEdge = columns.left.left + columns.left.width + LEFT_BORDER_PAD + RIGHT_BORDER_PAD;
512
- const safe = leftRightEdge <= viewport.cols;
513
- events.push({
514
- id: `viewport-${Date.now()}-left`,
515
- tag: safe ? 'DBG' : 'ERR',
516
- level: safe ? 'INFO' : 'ERROR',
517
- msg: `LEFT: x=${columns.left.left} w=${columns.left.width} rightEdge=${leftRightEdge} (borders:+2) ${safe ? '✓' : '❌'} <= safeCols=${viewport.cols}`,
518
- ts: Date.now(),
519
- });
520
- }
521
- if (columns.center.width > 0) {
522
- const centerRightEdge = columns.center.left + columns.center.width + LEFT_BORDER_PAD + RIGHT_BORDER_PAD;
523
- const safe = centerRightEdge <= viewport.cols;
524
- events.push({
525
- id: `viewport-${Date.now()}-center`,
526
- tag: safe ? 'DBG' : 'ERR',
527
- level: safe ? 'INFO' : 'ERROR',
528
- msg: `CENTER: x=${columns.center.left} w=${columns.center.width} rightEdge=${centerRightEdge} (borders:+2) ${safe ? '✓' : '❌'} <= safeCols=${viewport.cols}`,
529
- ts: Date.now(),
530
- });
531
- }
532
- if (columns.right.width > 0) {
533
- const rightRightEdge = columns.right.left + columns.right.width + LEFT_BORDER_PAD; // No right border
534
- const safe = rightRightEdge <= viewport.cols;
535
- events.push({
536
- id: `viewport-${Date.now()}-right`,
537
- tag: safe ? 'DBG' : 'ERR',
538
- level: safe ? 'INFO' : 'ERROR',
539
- msg: `RIGHT: x=${columns.right.left} w=${columns.right.width} rightEdge=${rightRightEdge} (border:+1, no right) ${safe ? '✓' : '❌'} <= safeCols=${viewport.cols}`,
540
- ts: Date.now(),
541
- });
542
- }
543
- // Command line
544
- const cmdRightEdge = viewport.cols - 1; // Command line uses safeCols - 1 width, left=0, no right border
545
- const cmdSafe = cmdRightEdge < viewport.cols;
546
- events.push({
547
- id: `viewport-${Date.now()}-cmd`,
548
- tag: cmdSafe ? 'DBG' : 'ERR',
549
- level: cmdSafe ? 'INFO' : 'ERROR',
550
- msg: `CMD: x=0 w=${viewport.cols - 1} rightEdge=${cmdRightEdge} ${cmdSafe ? '✓' : '❌'} < safeCols=${viewport.cols}`,
551
- ts: Date.now(),
552
- });
553
- // Final summary
554
- const allSafe = violations.length === 0;
555
- events.push({
556
- id: `viewport-${Date.now()}-summary`,
557
- tag: allSafe ? 'DBG' : 'ERR',
558
- level: allSafe ? 'INFO' : 'ERROR',
559
- msg: allSafe
560
- ? `✓ SAFE: All panels satisfy hard invariant (x >= safeCols forbidden) - No scrollbar possible`
561
- : `❌ UNSAFE: ${violations.length} invariant violation(s) - Horizontal scrollbar will appear!`,
562
- ts: Date.now(),
563
- });
564
- return { events, actions: [] };
565
- },
566
- });
567
- }
568
- /**
569
- * Create overlay box
570
- */
571
- createOverlay() {
572
- if (this.overlayBox) {
573
- return;
574
- }
575
- const blessedLib = blessed;
576
- this.overlayBox = blessedLib.box({
577
- top: 0,
578
- left: 0,
579
- width: '100%',
580
- height: 1,
581
- content: '',
582
- style: {
583
- fg: 'yellow',
584
- },
585
- tags: true,
586
- focusable: false,
587
- });
588
- // Bring to front
589
- this.screen.append(this.overlayBox);
590
- }
591
- /**
592
- * Update overlay content
593
- */
594
- updateOverlay() {
595
- if (!this.overlayBox || !this.currentLayout) {
596
- return;
597
- }
598
- const stats = getResizeStats();
599
- const size = getTerminalSize(this.screen);
600
- const { mode, columns, raw } = this.currentLayout;
601
- // Build overlay line
602
- const parts = [];
603
- parts.push(`cols=${raw.cols} rows=${raw.rows}`);
604
- parts.push(`mode=${mode}`);
605
- parts.push(`left=${columns.left.width} center=${columns.center.width} right=${columns.right.width}`);
606
- if (stats.lastCommittedSize) {
607
- parts.push(`commits=${stats.commitCount} bursts=${stats.eventCount - stats.commitCount}`);
608
- }
609
- const overlayText = parts.join(' | ');
610
- this.overlayBox.setContent(overlayText);
611
- this.screen.render();
612
- }
613
- /**
614
- * Remove overlay
615
- */
616
- removeOverlay() {
617
- if (this.overlayBox) {
618
- try {
619
- if (this.overlayBox.detach) {
620
- this.overlayBox.detach();
621
- }
622
- if (this.overlayBox.destroy) {
623
- this.overlayBox.destroy();
624
- }
625
- }
626
- catch (error) {
627
- // Ignore
628
- }
629
- this.overlayBox = null;
630
- this.screen.render();
631
- }
632
- }
633
- /**
634
- * Destroy V4 TUI
635
- */
636
- destroy() {
637
- // Reset singleton guard
638
- globalThis.__FOURRUNR_V4_TUI_RUNNING__ = false;
639
- // Clear keep-alive interval (Deliverable 1)
640
- const interval = this.screen.__keepAliveInterval;
641
- if (interval) {
642
- clearInterval(interval);
643
- }
644
- this.removeOverlay();
645
- // Clear heartbeat intervals from widgets (Deliverable 3)
646
- if (this.widgets) {
647
- for (const widget of Object.values(this.widgets)) {
648
- if (widget) {
649
- const heartbeatInterval = widget.__heartbeatInterval;
650
- if (heartbeatInterval) {
651
- clearInterval(heartbeatInterval);
652
- }
653
- }
654
- }
655
- }
656
- // Watermark is handled by renderFrame teardown
657
- destroyResizeController();
658
- if (this.widgets) {
659
- try {
660
- if (this.widgets.commandLine.detach) {
661
- this.widgets.commandLine.detach();
662
- }
663
- if (this.widgets.commandLine.destroy) {
664
- this.widgets.commandLine.destroy();
665
- }
666
- }
667
- catch (error) {
668
- // Ignore
669
- }
670
- this.widgets = null;
671
- }
672
- // Deliverable 4: Terminal recovery on exit
673
- try {
674
- this.screen.program?.showCursor();
675
- }
676
- catch {
677
- // Ignore
678
- }
679
- try {
680
- this.screen.destroy();
681
- }
682
- catch (error) {
683
- // Ignore
684
- }
685
- }
686
- }
687
- /**
688
- * Start V4 TUI
689
- *
690
- * ⚠️ FROZEN: This version has display issues.
691
- * Development moved to V5. Use at your own risk.
692
- */
693
- export async function startV4Shell() {
694
- // FROZEN: Warn if V4 is being used
695
- if (!process.env.SUPPRESS_V4_WARNING) {
696
- process.stderr.write('\n⚠️ WARNING: V4 TUI is FROZEN (display issues). Development moved to V5.\n' +
697
- ' This version is preserved for reference only.\n' +
698
- ' Set SUPPRESS_V4_WARNING=1 to suppress this message.\n\n');
699
- }
700
- // Singleton guard - prevent multiple instances
701
- if (globalThis.__FOURRUNR_V4_TUI_RUNNING__) {
702
- // Already running - do nothing
703
- return;
704
- }
705
- // Mark as running BEFORE any UI code executes
706
- globalThis.__FOURRUNR_V4_TUI_RUNNING__ = true;
707
- // D) Never print anything to stdout before screen init
708
- // All boot logs go to stderr only
709
- // B) Force a sane TERM on the server session
710
- // If TERM is broken (like "locale"), set it to something safe
711
- const currentTerm = process.env.TERM || '';
712
- if (!currentTerm || currentTerm === 'locale' || /dumb|unknown/i.test(currentTerm)) {
713
- dbg('TERM is broken:', currentTerm, '- forcing xterm-256color');
714
- process.env.TERM = 'xterm-256color';
715
- if (!process.env.COLORTERM) {
716
- process.env.COLORTERM = 'truecolor';
717
- }
718
- }
719
- // Create initial screen to detect terminal profile (use screen dimensions from process)
720
- // We'll detect profile after creating the real screen
721
- const terminalProfile = getTerminalProfile({
722
- cols: process.stdout.columns || 80,
723
- rows: process.stdout.rows || 24
724
- });
725
- dbg('Terminal profile:', {
726
- isSafeMode: terminalProfile.isSafeMode,
727
- safeCols: terminalProfile.safeCols,
728
- safeRows: terminalProfile.safeRows,
729
- supportsUnicode: terminalProfile.supportsUnicode,
730
- term: terminalProfile.term,
731
- });
732
- // C) Create screen with safe mode config if needed
733
- const screen = blessed.screen({
734
- smartCSR: true, // Better for broken terminals
735
- fastCSR: false,
736
- title: '4Runr OS - V4 Shell (Phase 2)',
737
- fullUnicode: !terminalProfile.isSafeMode, // false in safe mode
738
- unicode: !terminalProfile.isSafeMode, // neo-blessed supports this
739
- autoPadding: false,
740
- terminal: terminalProfile.isSafeMode ? undefined : 'xterm-256color',
741
- // CRITICAL: Ensure output is properly configured
742
- output: process.stdout,
743
- input: process.stdin,
744
- // Force cursor to be hidden initially (command line will show it when focused)
745
- cursor: {
746
- artificial: false,
747
- shape: 'block',
748
- blink: false,
749
- color: null,
750
- },
751
- }); // Cast to any to allow options
752
- // Update terminal profile with actual screen dimensions
753
- const actualProfile = getTerminalProfile(screen);
754
- // CRITICAL: Force safe mode for CloudShell/weak terminals to prevent symbol corruption
755
- // If terminal doesn't support Unicode properly, force ASCII-only mode
756
- if (actualProfile.isSafeMode || !actualProfile.supportsUnicode) {
757
- // Ensure blessed uses ASCII borders only
758
- // We'll pass useAsciiBorders=true to renderFrame, but also ensure screen config is correct
759
- screen.fullUnicode = false;
760
- screen.unicode = false;
761
- }
762
- // Hide cursor (command line handles its own)
763
- if (screen.program?.hideCursor) {
764
- screen.program.hideCursor();
765
- }
766
- // Step 3: Guard against rogue stdout writes (common hidden cause of scrollbar)
767
- // Dynamic safeCols (refresh on each write to handle resize)
768
- // Store original write functions
769
- const originalStdoutWrite = process.stdout.write.bind(process.stdout);
770
- const originalStderrWrite = process.stderr.write.bind(process.stderr);
771
- // Wrap stdout.write to detect/prevent long lines
772
- process.stdout.write = function (chunk, encoding, callback) {
773
- // Get current safeCols (dynamic, handles resize)
774
- const viewport = getSafeViewport(screen);
775
- const safeCols = viewport.cols;
776
- const str = typeof chunk === 'string' ? chunk : chunk.toString();
777
- const lines = str.split('\n');
778
- // Check for lines longer than safeCols
779
- for (const line of lines) {
780
- if (line.length > safeCols - 5) { // -5 for safety margin
781
- // Log warning to eventBus instead of printing (prevents overflow)
782
- eventBus.emit({
783
- id: `stdout-overflow-${Date.now()}`,
784
- tag: 'WARN',
785
- level: 'WARN',
786
- msg: `⚠️ stdout line truncated (${line.length} > ${safeCols - 5}): ${line.substring(0, 50)}...`,
787
- ts: Date.now(),
788
- });
789
- // Truncate line to safeCols - 5
790
- const truncated = line.substring(0, safeCols - 5);
791
- return originalStdoutWrite(truncated + '\n', encoding, callback);
792
- }
793
- }
794
- // Normal write
795
- return originalStdoutWrite(chunk, encoding, callback);
796
- };
797
- // Wrap stderr.write similarly
798
- process.stderr.write = function (chunk, encoding, callback) {
799
- // Get current safeCols (dynamic, handles resize)
800
- const viewport = getSafeViewport(screen);
801
- const safeCols = viewport.cols;
802
- const str = typeof chunk === 'string' ? chunk : chunk.toString();
803
- const lines = str.split('\n');
804
- for (const line of lines) {
805
- if (line.length > safeCols - 5) {
806
- eventBus.emit({
807
- id: `stderr-overflow-${Date.now()}`,
808
- tag: 'WARN',
809
- level: 'WARN',
810
- msg: `⚠️ stderr line truncated (${line.length} > ${safeCols - 5}): ${line.substring(0, 50)}...`,
811
- ts: Date.now(),
812
- });
813
- const truncated = line.substring(0, safeCols - 5);
814
- return originalStderrWrite(truncated + '\n', encoding, callback);
815
- }
816
- }
817
- return originalStderrWrite(chunk, encoding, callback);
818
- };
819
- // Deliverable 1: Attach TUI runtime keep-alive BEFORE creating TUI
820
- // This ensures stdin is active and process stays alive
821
- attachTuiRuntime(screen);
822
- // Create V4 TUI instance
823
- const tui = new V4TUI(screen);
824
- // Subscribe to eventBus (for operations panel updates)
825
- // Must be AFTER tui is created so we can reference it in the closure
826
- const unsubscribe = eventBus.subscribe((event) => {
827
- // Update operations panel if it exists
828
- if (tui.widgets?.operations) {
829
- const time = new Date(event.ts).toLocaleTimeString();
830
- // Get existing content (use content property or getContent if available)
831
- const opsBox = tui.widgets.operations;
832
- const existingContent = opsBox.content || opsBox.getContent?.() || '';
833
- const newLine = `[${time}] [${event.tag}] ${event.msg}`;
834
- const lines = existingContent.split('\n');
835
- lines.push(newLine);
836
- // Limit to last 100 lines (prevent memory bloat)
837
- const displayLines = lines.slice(-100);
838
- opsBox.setContent(displayLines.join('\n'));
839
- // Only render if not currently resizing (to avoid conflicts)
840
- const stats = getResizeStats();
841
- if (!stats.isCommitting) {
842
- screen.render();
843
- }
844
- }
845
- });
846
- // Initialize with error handling
847
- try {
848
- await tui.init();
849
- // CRITICAL: Render the screen to make it visible
850
- // Only render once - multiple renders can cause black screens in CloudShell
851
- screen.render();
852
- // CRITICAL: Force output flush (blessed sometimes needs explicit flush)
853
- try {
854
- const program = screen.program;
855
- if (program && typeof program.flush === 'function') {
856
- program.flush();
857
- }
858
- }
859
- catch {
860
- // Ignore flush errors
861
- }
862
- // A) Log to stderr only (never stdout) - delayed
863
- dbg('Init complete. Screen children:', screen.children.length);
864
- dbg('Screen will stay alive - press Ctrl+C to exit');
865
- // CRITICAL: Force widgets to be visible - ensure they render
866
- if (tui.widgets) {
867
- // Force all widgets to show their content
868
- for (const [name, widget] of Object.entries(tui.widgets)) {
869
- if (widget && name !== 'viewport') {
870
- try {
871
- // Force widget to be displayed
872
- if (typeof widget.setContent === 'function') {
873
- const currentContent = widget.content || '';
874
- if (!currentContent || currentContent.trim() === '') {
875
- // Set minimal content to ensure widget is visible
876
- if (name.includes('posture') || name.includes('resources') || name.includes('assets')) {
877
- widget.setContent(`\n ${name.toUpperCase()} \n`);
878
- }
879
- else if (name === 'operations') {
880
- widget.setContent(`\n OPERATIONS \n`);
881
- }
882
- else if (name === 'network' || name === 'capabilities') {
883
- widget.setContent(`\n ${name.toUpperCase()} \n`);
884
- }
885
- else {
886
- widget.setContent(' '); // At least one space
887
- }
888
- }
889
- }
890
- }
891
- catch (err) {
892
- dbg(`Error setting content for ${name}:`, err);
893
- }
894
- }
895
- }
896
- // Force another render after setting content
897
- screen.render();
898
- }
899
- // CRITICAL: Ensure process stays alive
900
- // In browser terminals, blessed might not keep the event loop alive
901
- // The keep-alive interval should handle this, but verify stdin is active
902
- if (!process.stdin.isPaused()) {
903
- dbg('stdin is active and not paused');
904
- }
905
- else {
906
- dbg('WARNING: stdin is paused - resuming');
907
- process.stdin.resume();
908
- }
909
- // Verify event loop has active handles
910
- const hasListeners = process.stdin.listenerCount('data') > 0 ||
911
- process.stdin.listenerCount('readable') > 0;
912
- dbg('stdin listeners:', process.stdin.listenerCount('data'), 'readable listeners:', process.stdin.listenerCount('readable'));
913
- if (!hasListeners) {
914
- dbg('WARNING: No stdin listeners detected - adding fallback');
915
- // Fallback: add a dummy listener to keep stdin active
916
- process.stdin.on('data', () => {
917
- // Blessed handles actual input, we just keep stdin open
918
- });
919
- }
920
- }
921
- catch (error) {
922
- // A) Init failed - show error immediately (not delayed)
923
- const errorMsg = error instanceof Error ? error.message : String(error);
924
- const errorStack = error instanceof Error ? error.stack : '';
925
- // Try to show error on screen first (most visible)
926
- const program = screen.program;
927
- if (program && typeof program.write === 'function') {
928
- try {
929
- program.write(`\r\n\x1b[31m[V4 INIT ERROR]\x1b[0m\r\n`);
930
- program.write(`Error: ${errorMsg}\r\n`);
931
- if (errorStack) {
932
- // Only show first few lines of stack
933
- const stackLines = errorStack.split('\n').slice(0, 5).join('\n');
934
- program.write(`Stack:\n${stackLines}\n`);
935
- }
936
- program.write(`Press any key to exit...\r\n`);
937
- program.flush();
938
- // Wait for keypress before exiting
939
- screen.once('keypress', () => {
940
- process.exit(1);
941
- });
942
- return; // Don't exit immediately, wait for keypress
943
- }
944
- catch {
945
- // Fallback to stderr if screen write fails
946
- process.stderr.write(`[V4 INIT ERROR] ${errorMsg}\n`);
947
- if (errorStack) {
948
- process.stderr.write(`[V4 INIT ERROR] Stack: ${errorStack.split('\n').slice(0, 5).join('\n')}\n`);
949
- }
950
- }
951
- }
952
- else {
953
- // No screen available - write to stderr immediately
954
- process.stderr.write(`[V4 INIT ERROR] ${errorMsg}\n`);
955
- if (errorStack) {
956
- process.stderr.write(`[V4 INIT ERROR] Stack: ${errorStack.split('\n').slice(0, 5).join('\n')}\n`);
957
- }
958
- }
959
- process.exit(1);
960
- }
961
- // Cleanup on exit (attachTuiRuntime already handles SIGINT/SIGTERM, but we need local cleanup too)
962
- const cleanup = () => {
963
- // Reset singleton guard
964
- globalThis.__FOURRUNR_V4_TUI_RUNNING__ = false;
965
- // Clear keep-alive interval
966
- const interval = screen.__keepAliveInterval;
967
- if (interval) {
968
- clearInterval(interval);
969
- }
970
- // Deliverable 4: Terminal recovery on exit
971
- try {
972
- screen.program?.showCursor();
973
- }
974
- catch {
975
- // Ignore
976
- }
977
- // Restore original stdout/stderr writes
978
- process.stdout.write = originalStdoutWrite;
979
- process.stderr.write = originalStderrWrite;
980
- unsubscribe();
981
- tui.destroy();
982
- try {
983
- screen.destroy();
984
- }
985
- catch {
986
- // Ignore
987
- }
988
- process.exit(0);
989
- };
990
- // Note: attachTuiRuntime already handles SIGINT/SIGTERM, but we keep this as backup
991
- // The runtime handler will call cleanup via screen.destroy()
992
- }
993
- //# sourceMappingURL=index.js.map