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,258 +1,551 @@
1
- const MIN_COLS_NORMAL = 140; // Increased threshold
2
- const MIN_ROWS_NORMAL = 35; // Increased threshold
3
- const MIN_WIDTH = 10;
4
- const MIN_HEIGHT = 3;
5
1
  /**
6
- * Assert rect is within viewport (dev mode)
2
+ * MK1 Layout Engine - Pure math, no blessed imports
3
+ *
4
+ * Computes panel rectangles based on canvas size and layout mode.
5
+ * All rectangles are clamped to prevent overflow.
7
6
  */
8
- function assertRectWithinViewport(rect, safeCols, safeRows, key) {
9
- const rightEdge = rect.left + rect.width;
10
- const bottomEdge = rect.top + rect.height;
11
- if (rect.left < 0 || rect.width < 1) {
12
- console.error(`[LAYOUT_OOB] ${key}: left=${rect.left} width=${rect.width} (must be >= 0 and >= 1)`);
13
- }
14
- if (rightEdge > safeCols) {
15
- console.error(`[LAYOUT_OOB] ${key}: rightEdge=${rightEdge} safeCols=${safeCols} (exceeds by ${rightEdge - safeCols})`);
16
- }
17
- if (bottomEdge > safeRows) {
18
- console.error(`[LAYOUT_OOB] ${key}: bottomEdge=${bottomEdge} safeRows=${safeRows} (exceeds by ${bottomEdge - safeRows})`);
7
+ /**
8
+ * Clamp rectangle to canvas bounds
9
+ * Returns null if clamped size would be invalid
10
+ * - Header/command: minimum w >= 1, h >= 1
11
+ * - Other panels: minimum w >= 3, h >= 3
12
+ */
13
+ export function clampRect(rect, canvasCols, canvasRows, isThin = false) {
14
+ let { x, y, w, h } = rect;
15
+ // Clamp position
16
+ x = Math.max(0, Math.min(x, canvasCols - 1));
17
+ y = Math.max(0, Math.min(y, canvasRows - 1));
18
+ // Clamp width
19
+ const maxW = canvasCols - x;
20
+ w = Math.min(w, maxW);
21
+ // Clamp height
22
+ const maxH = canvasRows - y;
23
+ h = Math.min(h, maxH);
24
+ // Check minimums
25
+ // Header and command line are thin (1 line), allow h >= 1
26
+ const minSize = isThin ? 1 : 3;
27
+ if (w < minSize || h < minSize) {
28
+ return null; // Invalid after clamping
19
29
  }
30
+ return { x, y, w, h };
20
31
  }
21
- export function computeLayout(safeCols, safeRows) {
22
- // Check minimum requirements for normal mode
23
- if (safeCols < MIN_COLS_NORMAL || safeRows < MIN_ROWS_NORMAL) {
24
- const narrowLayout = computeNarrowLayout(safeCols, safeRows);
25
- console.log(`[LAYOUT] mode=narrow reason=threshold safeCols=${safeCols} safeRows=${safeRows}`);
26
- return narrowLayout;
27
- }
28
- // Try normal layout first
29
- const normalLayout = computeNormalLayout(safeCols, safeRows);
30
- // Check for overflow
31
- if (hasOverflow(normalLayout, safeCols, safeRows)) {
32
- const narrowLayout = computeNarrowLayout(safeCols, safeRows);
33
- console.log(`[LAYOUT] mode=narrow reason=overflow safeCols=${safeCols} safeRows=${safeRows}`);
34
- return narrowLayout;
35
- }
36
- // Assert all rects are within viewport (dev mode)
37
- if (process.env.TUI_DEBUG === '1') {
38
- for (const [key, rect] of Object.entries(normalLayout.rects)) {
39
- if (key !== 'WATERMARK') { // Skip watermark
40
- assertRectWithinViewport(rect, safeCols, safeRows, key);
41
- }
32
+ /**
33
+ * Assert no overflow - throws if any rect exceeds canvas
34
+ */
35
+ export function assertNoOverflow(spec, canvas) {
36
+ for (const [name, rect] of Object.entries(spec.rects)) {
37
+ const rightEdge = rect.x + rect.w;
38
+ const bottomEdge = rect.y + rect.h;
39
+ if (rect.x < 0 || rect.y < 0 || rightEdge > canvas.cols || bottomEdge > canvas.rows) {
40
+ throw new Error(`Layout overflow: ${name} at (${rect.x},${rect.y}) size ${rect.w}x${rect.h} ` +
41
+ `exceeds canvas ${canvas.cols}x${canvas.rows}`);
42
42
  }
43
43
  }
44
- console.log(`[LAYOUT] mode=normal safeCols=${safeCols} safeRows=${safeRows}`);
45
- return normalLayout;
46
44
  }
47
45
  /**
48
- * Normal mode: 3-column layout (centered with margins)
49
- * Left stack: POSTURE, RESOURCES, ASSETS
50
- * Center: OPERATIONS (big)
51
- * Right stack: NETWORK, CAPABILITIES
52
- * Bottom: COMMAND_LINE (full width)
46
+ * Compute wide layout (3-column grid)
53
47
  *
54
- * Uses safeCols/safeRows - all rects must fit within these bounds
48
+ * Rule: sum of widths + gutters <= safeCols
49
+ * Rule: nothing ends at x == safeCols (1-col air gap)
50
+ * Rule: borders consume 2 cols (left + right) and 2 rows (top + bottom)
51
+ * So we need to account for border space when computing panel sizes
55
52
  */
56
- function computeNormalLayout(safeCols, safeRows) {
57
- const commandLineHeight = 1;
58
- const statusLineHeight = 1;
59
- const usableRows = safeRows - statusLineHeight - commandLineHeight;
60
- const usableTop = statusLineHeight;
61
- // Add margins to center content and prevent scrollbars
62
- const marginX = 2; // Left/right margin
63
- const contentWidth = safeCols - (marginX * 2);
64
- // Column widths (3 columns) - balanced proportions
65
- const leftColWidth = Math.floor(contentWidth * 0.22); // 22%
66
- const centerColWidth = Math.floor(contentWidth * 0.56); // 56%
67
- const rightColWidth = contentWidth - leftColWidth - centerColWidth; // Remaining ~22%
68
- // Column positions (centered with margin)
69
- const leftColLeft = marginX;
70
- const centerColLeft = marginX + leftColWidth;
71
- const rightColLeft = marginX + leftColWidth + centerColWidth;
72
- // Left stack: split into 3 panels
73
- const leftPanelHeight = Math.floor(usableRows / 3);
74
- const leftRemainder = usableRows - (leftPanelHeight * 3);
75
- // Right stack: split into 2 panels
76
- const rightPanelHeight = Math.floor(usableRows / 2);
77
- const rightRemainder = usableRows - (rightPanelHeight * 2);
78
- const rects = {};
79
- // Status line (full width, no border) - but within safeCols
80
- rects['STATUS'] = {
81
- left: 0,
82
- top: 0,
83
- width: safeCols,
84
- height: statusLineHeight,
85
- };
86
- // Ensure minimum widths to prevent overflow
87
- const minPanelWidth = 15;
88
- const adjustedLeftWidth = Math.max(minPanelWidth, leftColWidth);
89
- const adjustedRightWidth = Math.max(minPanelWidth, rightColWidth);
90
- const adjustedCenterWidth = contentWidth - adjustedLeftWidth - adjustedRightWidth;
91
- // Recalculate positions with adjusted widths
92
- const finalCenterLeft = marginX + adjustedLeftWidth;
93
- const finalRightLeft = marginX + adjustedLeftWidth + adjustedCenterWidth;
94
- // Left column: POSTURE, RESOURCES, ASSETS
95
- rects['POSTURE'] = {
96
- left: leftColLeft,
97
- top: usableTop,
98
- width: adjustedLeftWidth,
99
- height: leftPanelHeight + (leftRemainder > 0 ? 1 : 0),
100
- };
101
- rects['RESOURCES'] = {
102
- left: leftColLeft,
103
- top: usableTop + leftPanelHeight + (leftRemainder > 0 ? 1 : 0),
104
- width: adjustedLeftWidth,
105
- height: leftPanelHeight + (leftRemainder > 1 ? 1 : 0),
106
- };
107
- rects['ASSETS'] = {
108
- left: leftColLeft,
109
- top: usableTop + (leftPanelHeight * 2) + Math.min(leftRemainder, 2),
110
- width: adjustedLeftWidth,
111
- height: leftPanelHeight + (leftRemainder > 2 ? 1 : 0),
112
- };
113
- // Center: OPERATIONS (big)
114
- rects['OPERATIONS'] = {
115
- left: finalCenterLeft,
116
- top: usableTop,
117
- width: adjustedCenterWidth,
118
- height: usableRows,
119
- };
120
- // Right column: NETWORK, CAPABILITIES
121
- rects['NETWORK'] = {
122
- left: finalRightLeft,
123
- top: usableTop,
124
- width: adjustedRightWidth,
125
- height: rightPanelHeight + (rightRemainder > 0 ? 1 : 0),
126
- };
127
- rects['CAPABILITIES'] = {
128
- left: finalRightLeft,
129
- top: usableTop + rightPanelHeight + (rightRemainder > 0 ? 1 : 0),
130
- width: adjustedRightWidth,
131
- height: rightPanelHeight + (rightRemainder > 1 ? 1 : 0),
132
- };
133
- // Command line (full width, bottom, no border) - but within safeCols
134
- rects['COMMAND_LINE'] = {
135
- left: 0,
136
- top: safeRows - commandLineHeight,
137
- width: safeCols,
138
- height: commandLineHeight,
139
- };
140
- // Watermark (top-right, shows version) - within safeCols
141
- const watermarkText = '4RUNR TUI MK1';
142
- rects['WATERMARK'] = {
143
- left: safeCols - watermarkText.length,
144
- top: 0,
145
- width: watermarkText.length,
146
- height: 1,
53
+ function computeWideLayout(canvas) {
54
+ // Phase A: Use safeCols/safeRows from canvas (already computed by getSafeViewport)
55
+ // Phase A: No more RIGHT_GAP here - getSafeViewport already applied it
56
+ // canvas.cols is already safeCols (after RIGHT_GAP), canvas.rows is already safeRows (after BOTTOM_GAP)
57
+ const safeCols = canvas.cols; // Already has RIGHT_GAP applied
58
+ const safeRows = canvas.rows; // Already has BOTTOM_GAP applied
59
+ const GUTTER = 1; // Gap between columns
60
+ const COMMAND_HEIGHT = 3;
61
+ const HEADER_HEIGHT = 1;
62
+ const MIN_MAIN_H = 20;
63
+ const MIN_ROWS = 24;
64
+ // Step 1: SAFE_COLS = screen.cols - 1 (or use canvas.cols which already has RIGHT_GAP applied)
65
+ // canvas.cols is already safeCols (from getSafeViewport with RIGHT_GAP applied)
66
+ const SAFE_COLS = safeCols; // Already has RIGHT_GAP applied in getSafeViewport
67
+ // Step 2: Use fixed widths for left/right, cap OPS width
68
+ // Rule: LEFT_W + GUTTER + OPS_W + GUTTER + RIGHT_W <= SAFE_COLS - 5 (5 unit safety margin)
69
+ // Use outer widths (border included) - all calculations use outer width
70
+ const MIN_LEFT_W = 28; // Minimum outer width for left column
71
+ const MAX_LEFT_W = 50; // Maximum outer width for left column (increased to use space freed from operations)
72
+ const MIN_RIGHT_W = 28; // Minimum outer width for right column
73
+ const MAX_RIGHT_W = 50; // Maximum outer width for right column (increased to use space freed from operations)
74
+ // Step 2: Cap OPS width - user: "operations section smaller its too big"
75
+ const OPS_MAX_W = 140; // Maximum outer width for operations (reduced from 180 to make it smaller)
76
+ const OPS_MIN_W = 60; // Minimum outer width for operations (must be readable)
77
+ // Step 2: Calculate available space for OPS first (operations is capped at OPS_MAX_W)
78
+ // Leave 5 unit safety margin: RIGHT_EDGE <= SAFE_COLS - 5
79
+ // So: LEFT_W + GUTTER + OPS_W + GUTTER + RIGHT_W <= SAFE_COLS - 5
80
+ // Rearranging: LEFT_W + RIGHT_W <= SAFE_COLS - OPS_W - (GUTTER * 2) - 5
81
+ const SAFE_GAP = 5; // 5 unit safety margin for wiggle room
82
+ const maxAvailableForLeftRight = SAFE_COLS - OPS_MAX_W - (GUTTER * 2) - SAFE_GAP;
83
+ // Step 2: Distribute available space to left and right columns (user: "other sections should be bigger")
84
+ // Split the available space 50/50 between left and right
85
+ let leftW = Math.round(maxAvailableForLeftRight / 2);
86
+ let rightW = Math.round(maxAvailableForLeftRight / 2);
87
+ // Step 2: Clamp to min/max bounds
88
+ leftW = Math.max(MIN_LEFT_W, Math.min(MAX_LEFT_W, leftW));
89
+ rightW = Math.max(MIN_RIGHT_W, Math.min(MAX_RIGHT_W, rightW));
90
+ // Step 2: Use these as fixed widths
91
+ const LEFT_W = leftW;
92
+ const RIGHT_W = rightW;
93
+ // Phase A: Validate canvas size (use safeRows directly)
94
+ if (safeRows < MIN_ROWS) {
95
+ throw new Error(`Canvas too small for wide layout: safeRows=${safeRows} < ${MIN_ROWS}`);
96
+ }
97
+ const mainHeight = safeRows - HEADER_HEIGHT - COMMAND_HEIGHT;
98
+ if (mainHeight < MIN_MAIN_H) {
99
+ throw new Error(`Main area too small: height=${mainHeight} < ${MIN_MAIN_H}`);
100
+ }
101
+ // Step 2: Calculate OPS width - operations stays at perfect size (180)
102
+ // Remaining space after left+right+gutters
103
+ const availableForOps = SAFE_COLS - LEFT_W - RIGHT_W - (GUTTER * 2);
104
+ // OPS width is the smaller of available space and OPS_MAX_W
105
+ // User: "operation section is perfect sized" - keep at 180
106
+ let opsW = Math.max(OPS_MIN_W, Math.min(OPS_MAX_W, availableForOps));
107
+ // Step 3: Recompute positions using capped OPS width
108
+ // Step 1: Use explicit x positions, not right: 0 anchoring
109
+ const LEFT_X = 0;
110
+ let OPS_X = LEFT_X + LEFT_W + GUTTER;
111
+ let RIGHT_X = OPS_X + opsW + GUTTER;
112
+ // Step 3: Assert no overflow with 5 unit safety margin
113
+ // RIGHT_EDGE must be <= SAFE_COLS - SAFE_GAP (5 unit safety margin for wiggle room)
114
+ const maxRightEdge = SAFE_COLS - SAFE_GAP;
115
+ if (RIGHT_X + RIGHT_W > maxRightEdge) {
116
+ // Emergency clamp: reduce OPS width to fit with 5 unit gap
117
+ const maxOpsW = maxRightEdge - LEFT_W - RIGHT_W - (GUTTER * 2);
118
+ if (maxOpsW < OPS_MIN_W) {
119
+ throw new Error(`Cannot fit panels with 5 unit safety margin: maxOpsW=${maxOpsW} < OPS_MIN_W=${OPS_MIN_W} ` +
120
+ `(SAFE_COLS=${SAFE_COLS} SAFE_GAP=${SAFE_GAP} LEFT_W=${LEFT_W} RIGHT_W=${RIGHT_W} GUTTER=${GUTTER})`);
121
+ }
122
+ opsW = Math.max(OPS_MIN_W, maxOpsW);
123
+ // Recalculate positions with clamped opsW
124
+ OPS_X = LEFT_X + LEFT_W + GUTTER;
125
+ RIGHT_X = OPS_X + opsW + GUTTER;
126
+ // Verify emergency clamp worked (with 5 unit safety margin)
127
+ if (RIGHT_X + RIGHT_W > maxRightEdge) {
128
+ throw new Error(`Emergency clamp failed: RIGHT_X=${RIGHT_X} RIGHT_W=${RIGHT_W} RIGHT_EDGE=${RIGHT_X + RIGHT_W} > maxRightEdge=${maxRightEdge} (SAFE_COLS=${SAFE_COLS} - SAFE_GAP=${SAFE_GAP})`);
129
+ }
130
+ }
131
+ // Use fixed widths (already set above) - these are outer widths including borders
132
+ // leftW and rightW already declared above, just use them
133
+ const centerW = opsW; // Use the capped OPS width (outer width including borders)
134
+ // Step 3: Final positions (already calculated and verified above)
135
+ const leftX = LEFT_X; // 0
136
+ const centerX = OPS_X;
137
+ const rightX = RIGHT_X;
138
+ // Final verification - ensure right edge has 5 unit safety margin
139
+ // maxRightEdge already declared above, reuse it
140
+ const rightEdge = rightX + rightW;
141
+ if (rightEdge > maxRightEdge) {
142
+ throw new Error(`[LAYOUT ERROR] rightEdge=${rightEdge} > maxRightEdge=${maxRightEdge} (SAFE_COLS=${SAFE_COLS} - SAFE_GAP=${SAFE_GAP}) ` +
143
+ `(LEFT_W=${leftW} OPS_W=${centerW} RIGHT_W=${rightW} GUTTER=${GUTTER} ` +
144
+ `LEFT_X=${leftX} OPS_X=${centerX} RIGHT_X=${rightX})`);
145
+ }
146
+ // Verify we have the 5 unit gap
147
+ const gapCheck = SAFE_COLS - rightEdge;
148
+ if (gapCheck < SAFE_GAP) {
149
+ throw new Error(`[LAYOUT ERROR] Gap too small: gap=${gapCheck} < SAFE_GAP=${SAFE_GAP} ` +
150
+ `(rightEdge=${rightEdge} SAFE_COLS=${SAFE_COLS})`);
151
+ }
152
+ // Build layout spec with final widths (normal or emergency-clamped)
153
+ // Left column panels (split vertically with gaps to prevent double borders)
154
+ const VERTICAL_GAP = 1; // Gap between vertically stacked panels to prevent double borders
155
+ const availableHeightForLeft = mainHeight - (VERTICAL_GAP * 2); // Account for 2 gaps between 3 panels
156
+ const leftPanelH = Math.floor(availableHeightForLeft / 3);
157
+ const leftRemainder = availableHeightForLeft - (leftPanelH * 3);
158
+ // Right column panels (split vertically with gap)
159
+ const availableHeightForRight = mainHeight - VERTICAL_GAP; // Account for 1 gap between 2 panels
160
+ const rightPanelH = Math.floor(availableHeightForRight / 2);
161
+ const rightRemainder = availableHeightForRight - (rightPanelH * 2);
162
+ const headerY = 0;
163
+ const mainY = HEADER_HEIGHT;
164
+ const commandY = canvas.rows - COMMAND_HEIGHT; // Use canvas.rows to position at very bottom
165
+ // Phase E: Header and command span full safeCols width (not beyond)
166
+ const headerW = safeCols; // Use full safeCols (already has RIGHT_GAP applied in getSafeViewport)
167
+ const commandW = safeCols;
168
+ const spec = {
169
+ mode: 'wide',
170
+ reason: 'wide',
171
+ rects: {
172
+ header: {
173
+ x: 0,
174
+ y: headerY,
175
+ w: headerW,
176
+ h: HEADER_HEIGHT,
177
+ },
178
+ posture: {
179
+ x: leftX,
180
+ y: mainY,
181
+ w: leftW,
182
+ h: leftPanelH + (leftRemainder > 0 ? 1 : 0),
183
+ },
184
+ resources: {
185
+ x: leftX,
186
+ y: mainY + leftPanelH + (leftRemainder > 0 ? 1 : 0) + VERTICAL_GAP,
187
+ w: leftW,
188
+ h: leftPanelH + (leftRemainder > 1 ? 1 : 0),
189
+ },
190
+ assets: {
191
+ x: leftX,
192
+ y: mainY + (leftPanelH * 2) + Math.min(leftRemainder, 2) + (VERTICAL_GAP * 2),
193
+ w: leftW,
194
+ h: leftPanelH + (leftRemainder > 2 ? 1 : 0),
195
+ },
196
+ operations: {
197
+ x: centerX,
198
+ y: mainY,
199
+ w: centerW,
200
+ h: mainHeight,
201
+ },
202
+ network: {
203
+ x: rightX,
204
+ y: mainY,
205
+ w: rightW,
206
+ h: rightPanelH + (rightRemainder > 0 ? 1 : 0),
207
+ },
208
+ capabilities: {
209
+ x: rightX,
210
+ y: mainY + rightPanelH + (rightRemainder > 0 ? 1 : 0) + VERTICAL_GAP,
211
+ w: rightW,
212
+ h: rightPanelH + (rightRemainder > 1 ? 1 : 0),
213
+ },
214
+ command: {
215
+ x: 0,
216
+ y: commandY,
217
+ w: commandW, // Use commandW (usableCols), not canvas.cols
218
+ h: COMMAND_HEIGHT,
219
+ },
220
+ },
147
221
  };
148
- return {
149
- mode: 'normal',
150
- cols: safeCols,
151
- rows: safeRows,
152
- rects,
222
+ // Step 5: Acceptance test data - store debug info for logging
223
+ const totalUsedWidth = leftW + GUTTER + centerW + GUTTER + rightW;
224
+ const safetyMargin = SAFE_COLS - rightEdge; // Actual safety margin from right edge (should be >= SAFE_GAP)
225
+ // Phase A/B: Store debug info for logging and offender scanner
226
+ // Step 5: All values for acceptance test verification
227
+ spec._debug = {
228
+ cols: canvas.cols, // This is safeCols (already has RIGHT_GAP)
229
+ rows: canvas.rows, // This is safeRows (already has BOTTOM_GAP)
230
+ safeCols: SAFE_COLS,
231
+ safeRows,
232
+ GUTTER,
233
+ SAFE_GAP,
234
+ LEFT_W,
235
+ RIGHT_W,
236
+ OPS_MAX_W,
237
+ OPS_MIN_W,
238
+ availableForOps,
239
+ leftX,
240
+ leftW,
241
+ centerX,
242
+ centerW,
243
+ rightX,
244
+ rightW,
245
+ rightEdge: rightEdge,
246
+ gap: safetyMargin, // Safety margin from right edge (should be >= SAFE_GAP)
247
+ status: rightEdge <= (SAFE_COLS - SAFE_GAP) ? 'OK' : 'ERROR',
153
248
  };
249
+ // Final safety check already done above - rightEdge verified <= SAFE_COLS
250
+ // Phase E: Clamp all rects to ensure no element exceeds safe bounds
251
+ // Use safeCols/safeRows (already has gaps applied from getSafeViewport)
252
+ for (const [name, rect] of Object.entries(spec.rects)) {
253
+ const isThin = name === 'header' || name === 'command';
254
+ const clamped = clampRect(rect, safeCols, safeRows, isThin);
255
+ if (!clamped) {
256
+ throw new Error(`Panel ${name} invalid after clamping (rect=${rect.x},${rect.y} ${rect.w}x${rect.h} safeCols=${safeCols} safeRows=${safeRows})`);
257
+ }
258
+ // Phase E: Critical anti-scroll rule - verify clamped rect
259
+ if (clamped.x + clamped.w > safeCols || clamped.y + clamped.h > safeRows) {
260
+ throw new Error(`Panel ${name} still exceeds bounds after clamping: ` +
261
+ `rightEdge=${clamped.x + clamped.w} > safeCols=${safeCols} OR ` +
262
+ `bottomEdge=${clamped.y + clamped.h} > safeRows=${safeRows}`);
263
+ }
264
+ spec.rects[name] = clamped;
265
+ }
266
+ // Phase E: Final overflow assertion
267
+ assertNoOverflow(spec, { cols: safeCols, rows: safeRows });
268
+ return spec;
154
269
  }
155
270
  /**
156
- * Narrow mode: Stacked vertically (centered with margins)
157
- * Uses safeCols/safeRows
271
+ * Compute standard layout (same as wide but with adjusted widths)
158
272
  */
159
- function computeNarrowLayout(safeCols, safeRows) {
160
- const commandLineHeight = 1;
161
- const statusLineHeight = 1;
162
- const usableRows = safeRows - statusLineHeight - commandLineHeight;
163
- const usableTop = statusLineHeight;
164
- // Add margins to center content and prevent scrollbars
165
- const marginX = 2;
166
- const contentWidth = safeCols - (marginX * 2);
167
- const minContentWidth = 50; // Minimum usable width
168
- // If too narrow, use minimal margins
169
- const finalMarginX = contentWidth < minContentWidth ? 1 : marginX;
170
- const finalContentWidth = safeCols - (finalMarginX * 2);
171
- // Stack all panels vertically
172
- const panelCount = 6; // POSTURE, RESOURCES, ASSETS, OPERATIONS, NETWORK, CAPABILITIES
173
- const panelHeight = Math.floor(usableRows / panelCount);
174
- const remainder = usableRows - (panelHeight * panelCount);
175
- const rects = {};
176
- // Status line - within safeCols
177
- rects['STATUS'] = {
178
- left: 0,
179
- top: 0,
180
- width: safeCols,
181
- height: statusLineHeight,
182
- };
183
- let currentTop = usableTop;
184
- const panels = ['POSTURE', 'RESOURCES', 'ASSETS', 'OPERATIONS', 'NETWORK', 'CAPABILITIES'];
185
- for (let i = 0; i < panels.length; i++) {
186
- const extraRow = i < remainder ? 1 : 0;
187
- rects[panels[i]] = {
188
- left: finalMarginX,
189
- top: currentTop,
190
- width: finalContentWidth,
191
- height: panelHeight + extraRow,
192
- };
193
- currentTop += panelHeight + extraRow;
273
+ function computeStandardLayout(canvas) {
274
+ const GAP = 1;
275
+ const COMMAND_HEIGHT = 3;
276
+ const HEADER_HEIGHT = 1;
277
+ const AIR_GAP = 1; // 1-col air gap on right and bottom
278
+ const MIN_CENTER_W = 60;
279
+ const MIN_RIGHT_W = 26;
280
+ const MIN_LEFT_W = 26;
281
+ const MIN_MAIN_H = 20;
282
+ const MIN_ROWS = 24;
283
+ // Use safeCols/safeRows (already accounts for padding)
284
+ // Subtract AIR_GAP to ensure nothing ends at safeCols
285
+ const usableCols = canvas.cols - AIR_GAP;
286
+ const usableRows = canvas.rows - AIR_GAP;
287
+ if (usableRows < MIN_ROWS) {
288
+ throw new Error(`Canvas too small for standard layout: rows=${usableRows} < ${MIN_ROWS}`);
194
289
  }
195
- // Command line - within safeCols
196
- rects['COMMAND_LINE'] = {
197
- left: 0,
198
- top: safeRows - commandLineHeight,
199
- width: safeCols,
200
- height: commandLineHeight,
201
- };
202
- // Watermark - within safeCols
203
- const watermarkText = '4RUNR TUI MK1';
204
- rects['WATERMARK'] = {
205
- left: safeCols - watermarkText.length,
206
- top: 0,
207
- width: watermarkText.length,
208
- height: 1,
209
- };
210
- return {
211
- mode: 'narrow',
212
- cols: safeCols,
213
- rows: safeRows,
214
- rects,
290
+ const mainHeight = usableRows - HEADER_HEIGHT - COMMAND_HEIGHT;
291
+ if (mainHeight < MIN_MAIN_H) {
292
+ throw new Error(`Main area too small: height=${mainHeight} < ${MIN_MAIN_H}`);
293
+ }
294
+ // Calculate column widths with priority: center >= 60, right >= 26, left >= 26
295
+ const availableW = usableCols - (GAP * 2);
296
+ const centerW = Math.max(MIN_CENTER_W, Math.floor(availableW * 0.5));
297
+ const rightW = Math.max(MIN_RIGHT_W, Math.floor((availableW - centerW) * 0.4));
298
+ const leftW = availableW - centerW - rightW;
299
+ if (leftW < MIN_LEFT_W) {
300
+ // Adjust: reduce right first, then center if needed
301
+ const needed = MIN_LEFT_W - leftW;
302
+ if (rightW - needed >= MIN_RIGHT_W) {
303
+ const newRightW = rightW - needed;
304
+ const newLeftW = availableW - centerW - newRightW;
305
+ return computeStandardLayoutWithWidths(canvas, newLeftW, centerW, newRightW, GAP, HEADER_HEIGHT, COMMAND_HEIGHT, mainHeight, AIR_GAP);
306
+ }
307
+ else {
308
+ // Must reduce center
309
+ const newCenterW = Math.max(MIN_CENTER_W, centerW - (MIN_LEFT_W - leftW));
310
+ const newRightW = Math.max(MIN_RIGHT_W, rightW);
311
+ const newLeftW = availableW - newCenterW - newRightW;
312
+ return computeStandardLayoutWithWidths(canvas, newLeftW, newCenterW, newRightW, GAP, HEADER_HEIGHT, COMMAND_HEIGHT, mainHeight, AIR_GAP);
313
+ }
314
+ }
315
+ return computeStandardLayoutWithWidths(canvas, leftW, centerW, rightW, GAP, HEADER_HEIGHT, COMMAND_HEIGHT, mainHeight, AIR_GAP);
316
+ }
317
+ function computeStandardLayoutWithWidths(canvas, leftW, centerW, rightW, gap, headerHeight, commandHeight, mainHeight, airGap) {
318
+ const usableCols = canvas.cols - airGap;
319
+ const usableRows = canvas.rows - airGap;
320
+ // Left column panels (split vertically)
321
+ const leftPanelH = Math.floor(mainHeight / 3);
322
+ const leftRemainder = mainHeight - (leftPanelH * 3);
323
+ // Right column panels (split vertically)
324
+ const rightPanelH = Math.floor(mainHeight / 2);
325
+ const rightRemainder = mainHeight - (rightPanelH * 2);
326
+ const headerY = 0;
327
+ const mainY = headerHeight;
328
+ const commandY = canvas.rows - commandHeight; // Use canvas.rows to position at very bottom
329
+ // Compute explicit positions (never use right: 0 or bottom: 0)
330
+ const headerW = usableCols;
331
+ const commandW = usableCols;
332
+ const spec = {
333
+ mode: 'standard',
334
+ reason: 'standard',
335
+ rects: {
336
+ header: {
337
+ x: 0,
338
+ y: headerY,
339
+ w: headerW,
340
+ h: headerHeight,
341
+ },
342
+ posture: {
343
+ x: 0,
344
+ y: mainY,
345
+ w: leftW,
346
+ h: leftPanelH + (leftRemainder > 0 ? 1 : 0),
347
+ },
348
+ resources: {
349
+ x: 0,
350
+ y: mainY + leftPanelH + (leftRemainder > 0 ? 1 : 0),
351
+ w: leftW,
352
+ h: leftPanelH + (leftRemainder > 1 ? 1 : 0),
353
+ },
354
+ assets: {
355
+ x: 0,
356
+ y: mainY + (leftPanelH * 2) + Math.min(leftRemainder, 2),
357
+ w: leftW,
358
+ h: leftPanelH + (leftRemainder > 2 ? 1 : 0),
359
+ },
360
+ operations: {
361
+ x: leftW + gap,
362
+ y: mainY,
363
+ w: centerW,
364
+ h: mainHeight,
365
+ },
366
+ network: {
367
+ x: leftW + gap + centerW + gap,
368
+ y: mainY,
369
+ w: rightW,
370
+ h: rightPanelH + (rightRemainder > 0 ? 1 : 0),
371
+ },
372
+ capabilities: {
373
+ x: leftW + gap + centerW + gap,
374
+ y: mainY + rightPanelH + (rightRemainder > 0 ? 1 : 0),
375
+ w: rightW,
376
+ h: rightPanelH + (rightRemainder > 1 ? 1 : 0),
377
+ },
378
+ command: {
379
+ x: 0,
380
+ y: commandY,
381
+ w: commandW,
382
+ h: commandHeight,
383
+ },
384
+ },
215
385
  };
386
+ // Clamp all rects (header and command are thin, allow h=1)
387
+ // Use usableCols/usableRows for clamping
388
+ for (const [name, rect] of Object.entries(spec.rects)) {
389
+ const isThin = name === 'header' || name === 'command';
390
+ const clamped = clampRect(rect, usableCols, usableRows, isThin);
391
+ if (!clamped) {
392
+ throw new Error(`Panel ${name} invalid after clamping`);
393
+ }
394
+ spec.rects[name] = clamped;
395
+ }
396
+ assertNoOverflow(spec, { cols: usableCols, rows: usableRows });
397
+ return spec;
216
398
  }
217
399
  /**
218
- * Check for overflow violations
219
- * Uses safeCols/safeRows
400
+ * Compute stack layout (everything stacked vertically)
220
401
  */
221
- function hasOverflow(layout, safeCols, safeRows) {
222
- for (const [name, rect] of Object.entries(layout.rects)) {
223
- // Skip watermark (can be tiny)
224
- if (name === 'WATERMARK') {
225
- continue;
226
- }
227
- // Check minimums
228
- if (rect.width < MIN_WIDTH || rect.height < MIN_HEIGHT) {
229
- return true;
402
+ function computeStackLayout(canvas) {
403
+ const HEADER_HEIGHT = 1;
404
+ const COMMAND_HEIGHT = 3;
405
+ const GAP = 1;
406
+ const AIR_GAP = 1; // 1-col air gap on right and bottom
407
+ // Use safeCols/safeRows (already accounts for padding)
408
+ // Subtract AIR_GAP to ensure nothing ends at safeCols
409
+ const usableCols = canvas.cols - AIR_GAP;
410
+ const usableRows = canvas.rows - AIR_GAP;
411
+ const usableHeight = usableRows - HEADER_HEIGHT - COMMAND_HEIGHT;
412
+ const panelCount = 6; // posture, resources, assets, operations, network, capabilities
413
+ const panelHeight = Math.max(3, Math.floor(usableHeight / panelCount));
414
+ const remainder = usableHeight - (panelHeight * panelCount);
415
+ const headerY = 0;
416
+ const commandY = canvas.rows - COMMAND_HEIGHT; // Use canvas.rows to position at very bottom
417
+ // Compute explicit positions (never use right: 0 or bottom: 0)
418
+ const headerW = usableCols;
419
+ const commandW = usableCols;
420
+ let currentY = HEADER_HEIGHT;
421
+ const spec = {
422
+ mode: 'stack',
423
+ reason: 'stack',
424
+ rects: {
425
+ header: {
426
+ x: 0,
427
+ y: headerY,
428
+ w: headerW, // Use headerW (usableCols), not canvas.cols
429
+ h: HEADER_HEIGHT,
430
+ },
431
+ posture: {
432
+ x: 0,
433
+ y: currentY,
434
+ w: usableCols, // Use usableCols, not canvas.cols
435
+ h: panelHeight + (remainder > 0 ? 1 : 0),
436
+ },
437
+ resources: {
438
+ x: 0,
439
+ y: currentY += panelHeight + (remainder > 0 ? 1 : 0),
440
+ w: usableCols, // Use usableCols, not canvas.cols
441
+ h: panelHeight + (remainder > 1 ? 1 : 0),
442
+ },
443
+ assets: {
444
+ x: 0,
445
+ y: currentY += panelHeight + (remainder > 1 ? 1 : 0),
446
+ w: usableCols, // Use usableCols, not canvas.cols
447
+ h: panelHeight + (remainder > 2 ? 1 : 0),
448
+ },
449
+ operations: {
450
+ x: 0,
451
+ y: currentY += panelHeight + (remainder > 2 ? 1 : 0),
452
+ w: usableCols, // Use usableCols, not canvas.cols
453
+ h: panelHeight + (remainder > 3 ? 1 : 0),
454
+ },
455
+ network: {
456
+ x: 0,
457
+ y: currentY += panelHeight + (remainder > 3 ? 1 : 0),
458
+ w: usableCols, // Use usableCols, not canvas.cols
459
+ h: panelHeight + (remainder > 4 ? 1 : 0),
460
+ },
461
+ capabilities: {
462
+ x: 0,
463
+ y: currentY += panelHeight + (remainder > 4 ? 1 : 0),
464
+ w: usableCols, // Use usableCols, not canvas.cols
465
+ h: panelHeight + (remainder > 5 ? 1 : 0),
466
+ },
467
+ command: {
468
+ x: 0,
469
+ y: commandY,
470
+ w: commandW, // Use commandW (usableCols), not canvas.cols
471
+ h: COMMAND_HEIGHT,
472
+ },
473
+ },
474
+ };
475
+ // Clamp all rects (header and command are thin, allow h=1)
476
+ // Use usableCols/usableRows for clamping (already accounts for air gap)
477
+ for (const [name, rect] of Object.entries(spec.rects)) {
478
+ const isThin = name === 'header' || name === 'command';
479
+ const clamped = clampRect(rect, usableCols, usableRows, isThin);
480
+ if (!clamped) {
481
+ throw new Error(`Panel ${name} invalid after clamping`);
230
482
  }
231
- // Check boundaries - must fit within safe viewport
232
- const rightEdge = rect.left + rect.width;
233
- const bottomEdge = rect.top + rect.height;
234
- // Strict boundary check
235
- if (rightEdge > safeCols || bottomEdge > safeRows || rect.left < 0 || rect.top < 0) {
236
- return true;
483
+ spec.rects[name] = clamped;
484
+ }
485
+ assertNoOverflow(spec, canvas);
486
+ return spec;
487
+ }
488
+ /**
489
+ * Get layout mode from environment or auto-detect
490
+ */
491
+ function getLayoutMode(canvas) {
492
+ const envMode = process.env.TUI_LAYOUT;
493
+ if (envMode === 'wide') {
494
+ return { mode: 'wide', reason: 'env=wide' };
495
+ }
496
+ if (envMode === 'standard') {
497
+ return { mode: 'standard', reason: 'env=standard' };
498
+ }
499
+ if (envMode === 'stack') {
500
+ return { mode: 'stack', reason: 'env=stack' };
501
+ }
502
+ // Auto-detect: try wide first, then standard, then stack
503
+ try {
504
+ computeWideLayout(canvas);
505
+ return { mode: 'wide', reason: 'auto' };
506
+ }
507
+ catch {
508
+ // Wide failed, try standard
509
+ try {
510
+ computeStandardLayout(canvas);
511
+ return { mode: 'standard', reason: 'auto' };
237
512
  }
238
- // Additional check: ensure rect dimensions don't exceed safe viewport
239
- if (rect.width > safeCols || rect.height > safeRows) {
240
- return true;
513
+ catch {
514
+ // Both failed, use stack
515
+ return { mode: 'stack', reason: 'auto-fallback' };
241
516
  }
242
517
  }
243
- return false;
244
518
  }
245
519
  /**
246
- * Validate and fix layout (guardrail)
247
- * Uses safeCols/safeRows from layout
520
+ * Compute layout - main entry point
248
521
  */
249
- export function validateLayout(layout) {
250
- const { cols, rows } = layout;
251
- // Check for violations
252
- if (hasOverflow(layout, cols, rows)) {
253
- // Switch to narrow mode and recompute
254
- return computeNarrowLayout(cols, rows);
522
+ export function computeLayout(canvas) {
523
+ const { mode, reason } = getLayoutMode(canvas);
524
+ try {
525
+ if (mode === 'wide') {
526
+ const spec = computeWideLayout(canvas);
527
+ spec.reason = reason;
528
+ return spec;
529
+ }
530
+ else if (mode === 'standard') {
531
+ const spec = computeStandardLayout(canvas);
532
+ spec.reason = reason;
533
+ return spec;
534
+ }
535
+ else {
536
+ const spec = computeStackLayout(canvas);
537
+ spec.reason = reason;
538
+ return spec;
539
+ }
540
+ }
541
+ catch (error) {
542
+ // If requested mode fails, fallback to stack
543
+ if (mode !== 'stack') {
544
+ const spec = computeStackLayout(canvas);
545
+ spec.reason = `${reason}→fallback-stack`;
546
+ return spec;
547
+ }
548
+ throw error;
255
549
  }
256
- return layout;
257
550
  }
258
551
  //# sourceMappingURL=layoutEngine.js.map