@ultrst-armada/krnl 1.0.1 → 1.0.3

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 (235) hide show
  1. package/README.md +67 -65
  2. package/package.json +13 -9
  3. package/packages/cli/dist/bin/krnl.cjs +1535 -9508
  4. package/packages/cli/dist/bin/krnl.js +55 -1915
  5. package/packages/cli/dist/chunk-6SHSECXR.js +1628 -0
  6. package/packages/cli/dist/index.cjs +1244 -7373
  7. package/packages/cli/dist/index.d.cts +45 -2
  8. package/packages/cli/dist/index.d.ts +45 -2
  9. package/packages/cli/dist/index.js +5 -20
  10. package/packages/cli/package.json +17 -10
  11. package/packages/core/dist/index.cjs +3039 -141
  12. package/packages/core/dist/index.d.cts +633 -27
  13. package/packages/core/dist/index.d.ts +633 -27
  14. package/packages/core/dist/index.js +3028 -139
  15. package/packages/core/package.json +15 -7
  16. package/packages/create-krnl/dist/index.cjs +322 -316
  17. package/packages/create-krnl/dist/index.js +322 -316
  18. package/packages/create-krnl/package.json +5 -3
  19. package/packages/eslint-plugin/dist/index.cjs +17 -55
  20. package/packages/eslint-plugin/dist/index.d.cts +8 -43
  21. package/packages/eslint-plugin/dist/index.d.ts +8 -43
  22. package/packages/eslint-plugin/dist/index.js +17 -55
  23. package/packages/eslint-plugin/package.json +5 -4
  24. package/packages/validate/dist/index.cjs +692 -361
  25. package/packages/validate/dist/index.d.cts +12 -14
  26. package/packages/validate/dist/index.d.ts +12 -14
  27. package/packages/validate/dist/index.js +692 -361
  28. package/packages/validate/package.json +14 -7
  29. package/packages/cli/dist/K_ENT_Entity-PQ5MURQY-ZG6FZXXX.js +0 -13
  30. package/packages/cli/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-K4CRQYA5.js +0 -8
  31. package/packages/cli/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-LNPXZYOE.js +0 -110
  32. package/packages/cli/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-3ALZPNX4.js +0 -11
  33. package/packages/cli/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-PJTICYSW.js +0 -11
  34. package/packages/cli/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-M5TYU55O.js +0 -8
  35. package/packages/cli/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-H6STOXRK.js +0 -20
  36. package/packages/cli/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-XPJXSF7D.js +0 -19
  37. package/packages/cli/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-CUYGTWOW.js +0 -7
  38. package/packages/cli/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-VR6T4N6J.js +0 -17
  39. package/packages/cli/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-RLJ4QWDP.js +0 -58
  40. package/packages/cli/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-BOQGUASC.js +0 -22
  41. package/packages/cli/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-XJI7KIT5.js +0 -8
  42. package/packages/cli/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-K5VCWAFW.js +0 -9
  43. package/packages/cli/dist/chunk-3TRM6CYL.js +0 -152
  44. package/packages/cli/dist/chunk-5JDK35TG.js +0 -3872
  45. package/packages/cli/dist/chunk-63PTK33I.js +0 -997
  46. package/packages/cli/dist/chunk-6NIKAMUZ.js +0 -82
  47. package/packages/cli/dist/chunk-BOXWWXQG.js +0 -400
  48. package/packages/cli/dist/chunk-EEKLK7QJ.js +0 -565
  49. package/packages/cli/dist/chunk-EG7T2IAD.js +0 -107
  50. package/packages/cli/dist/chunk-F5EHXE2O.js +0 -1036
  51. package/packages/cli/dist/chunk-F65ANSQG.js +0 -269
  52. package/packages/cli/dist/chunk-FDNCADFE.js +0 -71
  53. package/packages/cli/dist/chunk-GDLRMDAN.js +0 -127
  54. package/packages/cli/dist/chunk-HWMTCMOS.js +0 -656
  55. package/packages/cli/dist/chunk-I74QIQOD.js +0 -5536
  56. package/packages/cli/dist/chunk-JTLSTO25.js +0 -71
  57. package/packages/cli/dist/chunk-JULBBJ27.js +0 -1033
  58. package/packages/cli/dist/chunk-OHVMVRBP.js +0 -117
  59. package/packages/cli/dist/chunk-P2PCLEKX.js +0 -666
  60. package/packages/cli/dist/chunk-PJQIUOX2.js +0 -7767
  61. package/packages/cli/dist/chunk-PPOF3DJW.js +0 -471
  62. package/packages/cli/dist/chunk-Q45257P6.js +0 -173
  63. package/packages/cli/dist/chunk-QNROWGBI.js +0 -1036
  64. package/packages/cli/dist/chunk-RJNYUXZD.js +0 -977
  65. package/packages/cli/dist/chunk-SRTOPJ5W.js +0 -104
  66. package/packages/cli/dist/chunk-TCEX3MPS.js +0 -702
  67. package/packages/cli/dist/chunk-TNOAJO2J.js +0 -675
  68. package/packages/cli/dist/chunk-UR2SUCSF.js +0 -701
  69. package/packages/cli/dist/chunk-X5LOIFM7.js +0 -68
  70. package/packages/cli/dist/chunk-XIRFOO3H.js +0 -589
  71. package/packages/cli/dist/chunk-ZAAV3JXQ.js +0 -809
  72. package/packages/core/dist/K_ENT_Entity-4MB7CU4A.js +0 -12
  73. package/packages/core/dist/K_ENT_Entity-DEJGIDGH.js +0 -12
  74. package/packages/core/dist/K_ENT_Entity-FXZO5UZ2.js +0 -12
  75. package/packages/core/dist/K_ENT_Entity-HDSCXC5F.js +0 -12
  76. package/packages/core/dist/K_ENT_Entity-JILABHLW.js +0 -12
  77. package/packages/core/dist/K_ENT_Entity-PQ5MURQY.js +0 -13
  78. package/packages/core/dist/K_ENT_Entity-ROAKDIHW.js +0 -12
  79. package/packages/core/dist/K_ENT_Entity-TBVFSKDV.js +0 -12
  80. package/packages/core/dist/K_ENT_Entity-ZFLKG3JO.js +0 -12
  81. package/packages/core/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW.js +0 -8
  82. package/packages/core/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF.js +0 -110
  83. package/packages/core/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF.js +0 -9
  84. package/packages/core/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X.js +0 -9
  85. package/packages/core/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW.js +0 -8
  86. package/packages/core/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2.js +0 -20
  87. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-4C6GBQAG.js +0 -18
  88. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-6V23A6F6.js +0 -18
  89. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK.js +0 -19
  90. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-DYLLC5G2.js +0 -18
  91. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-F4FOFAUP.js +0 -18
  92. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-FBOXXMI3.js +0 -18
  93. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-Q73BWLNP.js +0 -18
  94. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QM2C4MVA.js +0 -18
  95. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QUGI6SMP.js +0 -18
  96. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RGMTBHNP.js +0 -18
  97. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RWR7UNDW.js +0 -18
  98. package/packages/core/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7.js +0 -7
  99. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-32MFJJ5Z.js +0 -17
  100. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-4J4CEWRY.js +0 -17
  101. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-A366YHF2.js +0 -17
  102. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-LK4LYJHI.js +0 -17
  103. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU.js +0 -17
  104. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-NW3K63II.js +0 -17
  105. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-QDHTI5ZV.js +0 -17
  106. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-VHCT6VIW.js +0 -17
  107. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-WBRKF24R.js +0 -17
  108. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-XKYQYT6Q.js +0 -17
  109. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-Z2PWZYDZ.js +0 -17
  110. package/packages/core/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5.js +0 -58
  111. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-2EZU7QF4.js +0 -21
  112. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-6G3AQNAV.js +0 -21
  113. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-B2NZMQUG.js +0 -21
  114. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-C2RABMZP.js +0 -21
  115. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-HHE3NZ4F.js +0 -21
  116. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-LHFGR6WK.js +0 -21
  117. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-M74BLM3N.js +0 -21
  118. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-PT6ZA6EA.js +0 -21
  119. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-SP52V3CX.js +0 -21
  120. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF.js +0 -22
  121. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-YNSEUHJJ.js +0 -21
  122. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-M6SBHIVA.js +0 -8
  123. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG.js +0 -8
  124. package/packages/core/dist/K_LIB_Krnl_Telemetry-77FRZ3KV.js +0 -9
  125. package/packages/core/dist/chunk-33L2J7V7.js +0 -82
  126. package/packages/core/dist/chunk-3ES4K2ZP.js +0 -817
  127. package/packages/core/dist/chunk-3SMHVVLL.js +0 -82
  128. package/packages/core/dist/chunk-3UEZ7JQA.js +0 -4877
  129. package/packages/core/dist/chunk-3XIE6KBD.js +0 -4877
  130. package/packages/core/dist/chunk-46ZLCML6.js +0 -107
  131. package/packages/core/dist/chunk-4UEL3DWJ.js +0 -107
  132. package/packages/core/dist/chunk-54GWZ5PC.js +0 -82
  133. package/packages/core/dist/chunk-6QCYRS5L.js +0 -127
  134. package/packages/core/dist/chunk-6ULMHNXR.js +0 -104
  135. package/packages/core/dist/chunk-7WUETJEV.js +0 -117
  136. package/packages/core/dist/chunk-A5KRAYDB.js +0 -107
  137. package/packages/core/dist/chunk-ANEAZ3PO.js +0 -107
  138. package/packages/core/dist/chunk-BE76RL6F.js +0 -82
  139. package/packages/core/dist/chunk-CIARVYDO.js +0 -107
  140. package/packages/core/dist/chunk-CR2ANE62.js +0 -107
  141. package/packages/core/dist/chunk-DI27MOR7.js +0 -173
  142. package/packages/core/dist/chunk-E6RLFHM5.js +0 -596
  143. package/packages/core/dist/chunk-EELAPMNV.js +0 -4877
  144. package/packages/core/dist/chunk-ENZ2RQVJ.js +0 -107
  145. package/packages/core/dist/chunk-F2U6CX4F.js +0 -4877
  146. package/packages/core/dist/chunk-FKG64OHL.js +0 -82
  147. package/packages/core/dist/chunk-FYAZJYM5.js +0 -772
  148. package/packages/core/dist/chunk-G4NP4RDQ.js +0 -82
  149. package/packages/core/dist/chunk-GADIRLRS.js +0 -473
  150. package/packages/core/dist/chunk-GR6CSLQJ.js +0 -772
  151. package/packages/core/dist/chunk-HDS7AT6O.js +0 -772
  152. package/packages/core/dist/chunk-HIMEZUU2.js +0 -71
  153. package/packages/core/dist/chunk-IB4UHG5I.js +0 -596
  154. package/packages/core/dist/chunk-J7ZYNVRS.js +0 -772
  155. package/packages/core/dist/chunk-JVLZU4K7.js +0 -604
  156. package/packages/core/dist/chunk-JYXXI7Q3.js +0 -82
  157. package/packages/core/dist/chunk-K54K2KZW.js +0 -192
  158. package/packages/core/dist/chunk-K6VHLBNH.js +0 -3316
  159. package/packages/core/dist/chunk-KCBP7ZYA.js +0 -596
  160. package/packages/core/dist/chunk-KFQGP6VL.js +0 -33
  161. package/packages/core/dist/chunk-KIUEUI7K.js +0 -82
  162. package/packages/core/dist/chunk-LB67NIZP.js +0 -949
  163. package/packages/core/dist/chunk-LDTYFUNW.js +0 -596
  164. package/packages/core/dist/chunk-MLVWARD4.js +0 -596
  165. package/packages/core/dist/chunk-MPYVXHKO.js +0 -2777
  166. package/packages/core/dist/chunk-MRQ3MITU.js +0 -772
  167. package/packages/core/dist/chunk-MVUN7I7O.js +0 -107
  168. package/packages/core/dist/chunk-NDDOIRW7.js +0 -596
  169. package/packages/core/dist/chunk-O3KDB5MH.js +0 -3330
  170. package/packages/core/dist/chunk-OEINUDSE.js +0 -400
  171. package/packages/core/dist/chunk-OPDENPT4.js +0 -4877
  172. package/packages/core/dist/chunk-P6XEM2LA.js +0 -429
  173. package/packages/core/dist/chunk-QKMRSQV4.js +0 -82
  174. package/packages/core/dist/chunk-R6CCWALL.js +0 -4877
  175. package/packages/core/dist/chunk-RAMMOO73.js +0 -774
  176. package/packages/core/dist/chunk-S3FTZFG6.js +0 -772
  177. package/packages/core/dist/chunk-T2ZVN434.js +0 -4877
  178. package/packages/core/dist/chunk-TFHLDMIA.js +0 -107
  179. package/packages/core/dist/chunk-TI3QUCIJ.js +0 -107
  180. package/packages/core/dist/chunk-TR2BAIGI.js +0 -107
  181. package/packages/core/dist/chunk-UGVVJKC6.js +0 -4877
  182. package/packages/core/dist/chunk-V2DX7YIU.js +0 -984
  183. package/packages/core/dist/chunk-W4IHYUYD.js +0 -772
  184. package/packages/core/dist/chunk-W6WBG5OY.js +0 -4877
  185. package/packages/core/dist/chunk-WN3M7O7H.js +0 -3312
  186. package/packages/core/dist/chunk-WR3NCU7U.js +0 -4877
  187. package/packages/core/dist/chunk-XC6B6L27.js +0 -82
  188. package/packages/core/dist/chunk-XNSE64ZY.js +0 -3316
  189. package/packages/core/dist/chunk-XROES2WN.js +0 -634
  190. package/packages/core/dist/chunk-XSCKNRCZ.js +0 -5020
  191. package/packages/core/dist/chunk-XVABPAUZ.js +0 -82
  192. package/packages/core/dist/chunk-YOBCB5C5.js +0 -596
  193. package/packages/core/dist/chunk-YUK6Q563.js +0 -666
  194. package/packages/core/dist/chunk-YXGL3ZEU.js +0 -1030
  195. package/packages/core/dist/chunk-ZINJ5OUX.js +0 -596
  196. package/packages/core/dist/chunk-ZPFD4BIQ.js +0 -604
  197. package/packages/core/dist/chunk-ZQZBFG6F.js +0 -4826
  198. package/packages/core/dist/chunk-ZZFRJGXM.js +0 -4877
  199. package/packages/create-krnl/dist/K_ENT_Entity-PQ5MURQY-R2OH4VXE.js +0 -14
  200. package/packages/create-krnl/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-AZM5HF4M.js +0 -9
  201. package/packages/create-krnl/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-X5N6SV2S.js +0 -111
  202. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-5PFHF4JU.js +0 -12
  203. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-ED33OQPH.js +0 -12
  204. package/packages/create-krnl/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-YGQLVR4P.js +0 -9
  205. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-VM7CTU2L.js +0 -21
  206. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-Y2GQFJ7I.js +0 -21
  207. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-L3JQWO54.js +0 -8
  208. package/packages/create-krnl/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-KQARASPR.js +0 -19
  209. package/packages/create-krnl/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-OF3IGLVL.js +0 -59
  210. package/packages/create-krnl/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-JOLHKOEX.js +0 -24
  211. package/packages/create-krnl/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-L46LSHKQ.js +0 -10
  212. package/packages/create-krnl/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-4JUPRR3X.js +0 -10
  213. package/packages/create-krnl/dist/chunk-3TRM6CYL.js +0 -152
  214. package/packages/create-krnl/dist/chunk-3URCB3QS.js +0 -127
  215. package/packages/create-krnl/dist/chunk-5JDK35TG.js +0 -3872
  216. package/packages/create-krnl/dist/chunk-A2XAXDOW.js +0 -812
  217. package/packages/create-krnl/dist/chunk-AN6TMQHG.js +0 -1033
  218. package/packages/create-krnl/dist/chunk-BOXWWXQG.js +0 -400
  219. package/packages/create-krnl/dist/chunk-BPTBREBG.js +0 -38
  220. package/packages/create-krnl/dist/chunk-FDNCADFE.js +0 -71
  221. package/packages/create-krnl/dist/chunk-JTLSTO25.js +0 -71
  222. package/packages/create-krnl/dist/chunk-M3NCUIPL.js +0 -107
  223. package/packages/create-krnl/dist/chunk-N2EONSOC.js +0 -7769
  224. package/packages/create-krnl/dist/chunk-OHVMVRBP.js +0 -117
  225. package/packages/create-krnl/dist/chunk-Q45257P6.js +0 -173
  226. package/packages/create-krnl/dist/chunk-QGM4M3NI.js +0 -37
  227. package/packages/create-krnl/dist/chunk-RJNYUXZD.js +0 -977
  228. package/packages/create-krnl/dist/chunk-SRTOPJ5W.js +0 -104
  229. package/packages/create-krnl/dist/chunk-UPBIGEC3.js +0 -666
  230. package/packages/create-krnl/dist/chunk-V2DB7UD7.js +0 -82
  231. package/packages/create-krnl/dist/chunk-WMHLIUI6.js +0 -3644
  232. package/packages/create-krnl/dist/chunk-XIRFOO3H.js +0 -589
  233. package/packages/create-krnl/dist/chunk-Y2CEEVZP.js +0 -5536
  234. package/packages/create-krnl/dist/main-DXUMPBND.js +0 -2217
  235. package/packages/create-krnl/dist/wrapper-SDF2VKX3.js +0 -31
@@ -1,772 +0,0 @@
1
- import {
2
- krnlEntityBase,
3
- krnlLocalFunctionality
4
- } from "./chunk-XSCKNRCZ.js";
5
- import {
6
- ObjectKit
7
- } from "./chunk-MLVWARD4.js";
8
- import {
9
- KrnlSubAppDiscovery,
10
- KrnlSubAppLifecycle,
11
- KrnlSubAppValidator
12
- } from "./chunk-OEINUDSE.js";
13
-
14
- // src/core/K_LIB_Krnl_Flow.ts
15
- var KrnlFlowBuilder = class _KrnlFlowBuilder {
16
- entity;
17
- id;
18
- steps = [];
19
- constructor(entity, id) {
20
- this.entity = entity;
21
- this.id = id;
22
- }
23
- /** Sequential: output of previous step is passed as input to fid */
24
- then(fid) {
25
- this.steps.push({ type: "seq", fid });
26
- return this;
27
- }
28
- /** Branch: predicate on current output routes to trueFid or falseFid */
29
- branch(pred, trueFid, falseFid) {
30
- this.steps.push({ type: "branch", pred, trueFid, falseFid });
31
- return this;
32
- }
33
- /** Parallel: run all fids concurrently with current input, collect results as array */
34
- parallel(...fids) {
35
- this.steps.push({ type: "parallel", fids });
36
- return this;
37
- }
38
- /**
39
- * Register this flow as a krnlLocalFunctionality on the host entity.
40
- * The Flow becomes a first-class capability on the entity.
41
- */
42
- register(opts) {
43
- const steps = [...this.steps];
44
- const entity = this.entity;
45
- const flowId = this.id;
46
- return entity.addLocal({
47
- id: flowId,
48
- visibility: opts?.visibility ?? "public",
49
- description: opts?.description || `Flow [${flowId}] composing [${steps.map((s) => s.fid || (s.fids ? s.fids.join(",") : "branch")).join(" \u2192 ")}]`,
50
- uiSpec: opts?.uiSpec,
51
- intelligenceSpec: opts?.intelligenceSpec,
52
- manifest: opts?.manifest,
53
- api: async (input) => _KrnlFlowBuilder._execute(entity, steps, input)
54
- });
55
- }
56
- /** Execute the flow directly without registering as a functionality */
57
- async run(input) {
58
- return _KrnlFlowBuilder._execute(this.entity, this.steps, input);
59
- }
60
- /**
61
- * Internal step executor walking the entity's functionalities via `entity.call(fid, input)`.
62
- */
63
- static async _execute(entity, steps, input) {
64
- let current = input;
65
- for (const step of steps) {
66
- if (step.type === "seq") {
67
- current = await entity.call(step.fid, current);
68
- } else if (step.type === "branch") {
69
- const matches = step.pred ? step.pred(current) : Boolean(current);
70
- const targetFid = matches ? step.trueFid : step.falseFid;
71
- if (targetFid) {
72
- current = await entity.call(targetFid, current);
73
- }
74
- } else if (step.type === "parallel") {
75
- const fids = step.fids || [];
76
- current = await Promise.all(fids.map((fid) => entity.call(fid, current)));
77
- }
78
- }
79
- return current;
80
- }
81
- };
82
-
83
- // src/core/K_ENT_Entity.ts
84
- var Entity = class _Entity extends krnlEntityBase {
85
- /** Strongly-typed reactive entity state */
86
- state;
87
- /** True while this entity occupies root position and actively self-hosts protocol adapters */
88
- _selfHosting = false;
89
- /** Protocol adapters attached to this entity. Operational only in root position. */
90
- _protocolAdapters = /* @__PURE__ */ new Map();
91
- /** Sub-Apps registered directly under this entity */
92
- _subApps = /* @__PURE__ */ new Map();
93
- /** Reservation state for access control and mutual exclusion */
94
- reservation = {
95
- busy: false,
96
- reservedBy: null,
97
- reservedAt: null
98
- };
99
- /** Discoverability state for network beacons / registries */
100
- discoverable = true;
101
- constructor(name, owner = null, options = {}) {
102
- super(name, owner, options);
103
- this.systemType = "Entity";
104
- this.state = options.initialState ?? {};
105
- }
106
- /**
107
- * Get an immutable, read-only snapshot of current entity state.
108
- */
109
- getState() {
110
- return Object.freeze(ObjectKit.deepClone(this.state));
111
- }
112
- /**
113
- * Mutates the entity state via deep-merge and emits a reactive state:changed event.
114
- */
115
- setState(mutation) {
116
- this.state = ObjectKit.deepMerge(this.state, mutation);
117
- this.emit("state:changed", {
118
- entity: this.entityName,
119
- delta: mutation,
120
- state: this.getState()
121
- });
122
- }
123
- /**
124
- * Resets entity state to a new or initial baseline.
125
- */
126
- resetState(newState) {
127
- this.state = newState ?? {};
128
- this.emit("state:reset", {
129
- entity: this.entityName,
130
- state: this.getState()
131
- });
132
- }
133
- /** Private cache mapping event names to krnlEmitters */
134
- _eventEmitterMap = /* @__PURE__ */ new Map();
135
- /**
136
- * Subscribes a listener to a domain event on this entity.
137
- */
138
- on(event, handler) {
139
- let emitter = this._eventEmitterMap.get(event);
140
- if (!emitter) {
141
- emitter = this.interface.createEmitter(event);
142
- this._eventEmitterMap.set(event, emitter);
143
- }
144
- return emitter.subscribe((msg) => handler(msg.data));
145
- }
146
- /**
147
- * Emits an event with a data payload to all subscribers.
148
- */
149
- emit(event, payload) {
150
- let emitter = this._eventEmitterMap.get(event);
151
- if (!emitter) {
152
- emitter = this.interface.createEmitter(event);
153
- this._eventEmitterMap.set(event, emitter);
154
- }
155
- emitter.pushDataStreamToEmitter(payload);
156
- }
157
- /**
158
- * Dispatches a strongly-typed domain event.
159
- */
160
- emitEvent(event, payload) {
161
- this.emit(String(event), payload);
162
- }
163
- /**
164
- * System flags representing discoverability and reservation status.
165
- */
166
- getSystemFlags() {
167
- return {
168
- discoverable: this.discoverable,
169
- busy: this.reservation.busy,
170
- reservedBy: this.reservation.reservedBy,
171
- reservedAt: this.reservation.reservedAt
172
- };
173
- }
174
- /**
175
- * Set discoverability status.
176
- */
177
- setDiscoverable(value) {
178
- this.discoverable = Boolean(value);
179
- return this.getSystemFlags();
180
- }
181
- /**
182
- * Reserve this entity for exclusive access by serviceName.
183
- */
184
- reserveFor(serviceName = "unknown") {
185
- this.reservation = {
186
- busy: true,
187
- reservedBy: serviceName,
188
- reservedAt: Date.now()
189
- };
190
- return this.getSystemFlags();
191
- }
192
- /**
193
- * Release reservation held by serviceName.
194
- */
195
- releaseReservation(serviceName = null) {
196
- if (serviceName && this.reservation.reservedBy && this.reservation.reservedBy !== serviceName) {
197
- throw new Error(
198
- `[${this.entityName}] Reservation owned by ${this.reservation.reservedBy}; cannot release as ${serviceName}.`
199
- );
200
- }
201
- this.reservation = {
202
- busy: false,
203
- reservedBy: null,
204
- reservedAt: null
205
- };
206
- return this.getSystemFlags();
207
- }
208
- /**
209
- * Guard checking if entity is available for remote caller.
210
- */
211
- _assertAvailableForRemoteAccess(requester = null) {
212
- if (!this.reservation.busy) return;
213
- if (requester && requester === this.reservation.reservedBy) return;
214
- const by = this.reservation.reservedBy || "another service";
215
- throw new Error(`[${this.entityName}] Entity is busy/reserved by ${by}.`);
216
- }
217
- /**
218
- * Get dynamic manifest of all capabilities, flags, and endpoints.
219
- */
220
- getManifest() {
221
- const apiNames = [];
222
- const eventsNames = [];
223
- const api = {};
224
- for (const [id, f] of this.localFunctionalities) {
225
- apiNames.push(id);
226
- api[id] = {
227
- id,
228
- type: "local",
229
- visibility: f.visibility || "public",
230
- manifest: f.manifest || null,
231
- schema: f.schema || null
232
- };
233
- }
234
- for (const [id, f] of this.remoteFunctionalities) {
235
- apiNames.push(id);
236
- api[id] = {
237
- id,
238
- type: "remote",
239
- visibility: f.visibility || "public",
240
- schema: f.schema || null
241
- };
242
- }
243
- return {
244
- entity: this.entityName,
245
- entityName: this.entityName,
246
- type: this.systemType,
247
- flags: this.getSystemFlags(),
248
- apiNames,
249
- eventsNames,
250
- api,
251
- inputs: {
252
- api
253
- }
254
- };
255
- }
256
- /**
257
- * Generates a structured 404 response payload for unmatched routes.
258
- */
259
- getNotFoundResponse(reqPath) {
260
- return {
261
- status: "error",
262
- message: `Route not found: ${reqPath}`,
263
- entity: this.entityName,
264
- availableRoutes: [
265
- "/call/:fid",
266
- "/mcp",
267
- "/acp",
268
- "/manifest",
269
- "/health",
270
- "/events/:fid"
271
- ]
272
- };
273
- }
274
- // ── Protocol Adapter Management ──────────────────────────────────────────
275
- /**
276
- * Attach a protocol adapter to this entity (declarative step during discovery/construction).
277
- * Does NOT start the server. Servers are started only during `finalize()` if this entity is root.
278
- */
279
- attachAdapter(adapter) {
280
- if (!adapter || !adapter.name) {
281
- throw new Error(`[Entity:${this.id}] Invalid protocol adapter provided.`);
282
- }
283
- this._protocolAdapters.set(adapter.name, adapter);
284
- }
285
- /**
286
- * Return all attached protocol adapters.
287
- */
288
- getAdapters() {
289
- return Array.from(this._protocolAdapters.values());
290
- }
291
- /**
292
- * Get a specific protocol adapter by name (e.g. 'https', 'wss').
293
- */
294
- getAdapter(name) {
295
- return this._protocolAdapters.get(name);
296
- }
297
- /**
298
- * Access the WebSocket commComponent adapter if attached.
299
- */
300
- get commComponent() {
301
- return this._protocolAdapters.get("wss");
302
- }
303
- /**
304
- * Access the Unified HTTP adapter if attached.
305
- */
306
- get unifiedHttpAdapter() {
307
- return this._protocolAdapters.get("https");
308
- }
309
- /**
310
- * Port of active listening adapter.
311
- */
312
- get commPort() {
313
- const http = this._protocolAdapters.get("https");
314
- if (http && typeof http.port === "number") return http.port;
315
- const wss = this._protocolAdapters.get("wss");
316
- if (wss && typeof wss.listenPort === "number") return wss.listenPort;
317
- return 10099;
318
- }
319
- // ── Activation / Finalize Lifecycle ──────────────────────────────────────
320
- /**
321
- * Finalizes construction and activates the entity if it occupies root position.
322
- * Called after tree construction and Shell materialization.
323
- */
324
- async finalize(options = {}) {
325
- const hasParent = Boolean(this.hierarchyManager.getOwnerEntity());
326
- if (!hasParent && this._protocolAdapters.size > 0 && !this._selfHosting) {
327
- await this._startHosting(options);
328
- }
329
- }
330
- /**
331
- * Starts all attached protocol adapters.
332
- */
333
- async _startHosting(options = {}) {
334
- if (this._selfHosting) return;
335
- for (const adapter of this._protocolAdapters.values()) {
336
- try {
337
- await adapter.start(this, options);
338
- } catch (err) {
339
- console.error(`[Entity:${this.id}] Error starting adapter '${adapter.name}':`, err.message || err);
340
- throw err;
341
- }
342
- }
343
- this._selfHosting = true;
344
- }
345
- /**
346
- * Stops all self-hosted protocol adapters gracefully.
347
- */
348
- async stopHosting() {
349
- if (!this._selfHosting) return;
350
- for (const adapter of this._protocolAdapters.values()) {
351
- try {
352
- await adapter.stop();
353
- } catch (err) {
354
- console.warn(`[Entity:${this.id}] Warning stopping adapter '${adapter.name}':`, err.message || err);
355
- }
356
- }
357
- this._selfHosting = false;
358
- }
359
- // ── Root / Child Bidirectional State Machine ─────────────────────────────
360
- /**
361
- * Lifecycle hook: called when this entity is adopted as a child component by a parent entity.
362
- * Action: Relinquish root position duties by stopping any self-hosted servers.
363
- * Note: Capability bubbling is handled automatically by the hierarchy manager.
364
- */
365
- async _onAdoptedByParent() {
366
- if (this._selfHosting) {
367
- this._selfHosting = false;
368
- await this.stopHosting();
369
- }
370
- }
371
- /**
372
- * Lifecycle hook: called when this entity is detached or promoted to root position.
373
- * Action: If no parent and adapters exist, activate self-hosting.
374
- */
375
- async _onPromotedToRoot(options = {}) {
376
- const hasParent = Boolean(this.hierarchyManager.getOwnerEntity());
377
- if (!hasParent && this._protocolAdapters.size > 0 && !this._selfHosting) {
378
- await this._startHosting(options);
379
- }
380
- }
381
- // ── Capability Surface & Bubbling Integration ────────────────────────────
382
- /**
383
- * Overrides component functionality addition to notify active protocol adapters.
384
- */
385
- _onComponentFunctionalityAdded(component, functionality) {
386
- super._onComponentFunctionalityAdded(component, functionality);
387
- if (this._selfHosting) {
388
- this._notifyAdaptersOfSurfaceChange();
389
- }
390
- }
391
- /**
392
- * Notifies all attached protocol adapters that the exposed capability surface has changed.
393
- * Idempotent: adapters diff and reconcile their route mappings.
394
- */
395
- _notifyAdaptersOfSurfaceChange() {
396
- for (const adapter of this._protocolAdapters.values()) {
397
- try {
398
- adapter.onCapabilitySurfaceChanged(this);
399
- } catch (err) {
400
- console.warn(`[Entity:${this.id}] Adapter '${adapter.name}' surface change notification error:`, err.message || err);
401
- }
402
- }
403
- }
404
- // ── Qualified Capability Projections & Resolution ────────────────────────
405
- /**
406
- * Computes the hierarchical qualified ID for a local functionality ID.
407
- * e.g. "Root.OrderService.settings"
408
- */
409
- getQualifiedId(fid) {
410
- const parent = this.hierarchyManager.getOwnerEntity();
411
- if (parent && typeof parent.getQualifiedId === "function") {
412
- return `${parent.getQualifiedId(this.id)}.${fid}`;
413
- }
414
- return `${this.id}.${fid}`;
415
- }
416
- /**
417
- * Resolves an external qualified capability ID to the owning Entity instance and local fid.
418
- * The caller/adapter invokes:
419
- * const res = root.resolveCapability("Root.OrderService.settings");
420
- * return await res.owner.call(res.fid, input);
421
- */
422
- resolveCapability(qualifiedId) {
423
- return this._resolveCapabilityRecursive(qualifiedId);
424
- }
425
- _resolveCapabilityRecursive(qualifiedId) {
426
- for (const [fid, func] of this.localFunctionalities) {
427
- if (func.visibility === "public" || func.visibility === "protected" || !func.visibility) {
428
- if (this.getQualifiedId(fid) === qualifiedId || fid === qualifiedId) {
429
- return { owner: this, fid };
430
- }
431
- }
432
- }
433
- for (const child of this.hierarchyManager.getAllOwnedComponentEntities()) {
434
- if (typeof child._resolveCapabilityRecursive === "function") {
435
- const res = child._resolveCapabilityRecursive(qualifiedId);
436
- if (res) return res;
437
- }
438
- }
439
- return void 0;
440
- }
441
- // ── Sub-App Integration & Lifecycle ───────────────────────────────────────
442
- /**
443
- * Discovers sub-apps in the specified directory (or default 'subapps/').
444
- */
445
- async discoverSubApps(searchPath) {
446
- const targetDir = searchPath || "subapps";
447
- return await KrnlSubAppDiscovery.discoverSubApps(targetDir);
448
- }
449
- /**
450
- * Loads, validates, registers, and initializes a sub-app onto this entity.
451
- */
452
- async loadSubApp(descriptorOrPath, config = {}) {
453
- let descriptor = null;
454
- if (typeof descriptorOrPath === "string") {
455
- descriptor = await KrnlSubAppDiscovery.locateDescriptor(descriptorOrPath);
456
- if (!descriptor) {
457
- throw new Error(`[Entity:${this.id}] Could not locate a valid sub-app descriptor at '${descriptorOrPath}'.`);
458
- }
459
- } else {
460
- descriptor = descriptorOrPath;
461
- }
462
- const instance = await KrnlSubAppLifecycle.loadAndRegister(this, descriptor, config);
463
- if (instance.state === "READY") {
464
- this._registerSubAppInstance(instance);
465
- } else if (instance.state === "ERROR") {
466
- console.warn(`[Entity:${this.id}] Sub-app '${instance.id}' failed registration:`, instance.error?.message);
467
- }
468
- this._subApps.set(instance.id, instance);
469
- return instance;
470
- }
471
- /**
472
- * Programmatically registers a sub-app registration object.
473
- */
474
- async registerSubApp(registration, descriptor) {
475
- const subAppId = registration.name || descriptor?.id || `subapp_${Date.now()}`;
476
- const desc = descriptor || {
477
- id: subAppId,
478
- path: "",
479
- registrationPath: "",
480
- manifest: { name: subAppId, version: "1.0.0" }
481
- };
482
- const instance = {
483
- id: subAppId,
484
- state: "VALIDATING",
485
- manifest: desc.manifest || { name: subAppId, version: "1.0.0" },
486
- descriptor: desc,
487
- operations: /* @__PURE__ */ new Map(),
488
- error: null,
489
- errorDetails: [],
490
- loadedAt: Date.now()
491
- };
492
- const existingCaps = /* @__PURE__ */ new Set();
493
- for (const k of this.localFunctionalities.keys()) existingCaps.add(k);
494
- for (const k of this.remoteFunctionalities.keys()) existingCaps.add(k);
495
- const check = KrnlSubAppValidator.validateRegistration(registration, existingCaps, subAppId);
496
- if (!check.valid) {
497
- instance.state = "ERROR";
498
- instance.errorDetails = check.errors;
499
- instance.error = new Error(`[SubApp:${subAppId}] Registration validation failed: ${check.errors.map((e) => e.message).join(", ")}`);
500
- this._subApps.set(subAppId, instance);
501
- return instance;
502
- }
503
- instance.state = "REGISTERED";
504
- instance.registration = registration;
505
- for (const op of registration.operations) {
506
- instance.operations.set(op.name, op);
507
- }
508
- this._registerSubAppInstance(instance);
509
- if (typeof registration.onInitialize === "function") {
510
- instance.state = "INITIALIZING";
511
- const regContext = {
512
- entity: this,
513
- services: this._serviceContainer || { get: () => void 0, has: () => false, register: () => {
514
- }, list: () => [] },
515
- operations: {
516
- register: (op) => this.registerSubAppOperations(subAppId, [op]),
517
- registerBatch: (ops) => this.registerSubAppOperations(subAppId, ops),
518
- get: (name) => instance.operations.get(name),
519
- list: () => Array.from(instance.operations.values())
520
- },
521
- events: {
522
- emit: (event, data) => this.interface?.getEmitter(event)?.pushDataStreamToEmitter(data),
523
- on: (event, listener) => this.interface?.getEmitter(event)?.subscribe((m) => listener(m.data || m)) || (() => {
524
- })
525
- },
526
- config: {},
527
- logger: this.logger || console
528
- };
529
- await registration.onInitialize(regContext);
530
- }
531
- instance.state = "READY";
532
- instance.readyAt = Date.now();
533
- this._subApps.set(subAppId, instance);
534
- return instance;
535
- }
536
- /**
537
- * Internal helper: wraps sub-app operations into first-class Entity functionalities.
538
- */
539
- _registerSubAppInstance(instance) {
540
- if (!instance.operations) return;
541
- for (const op of instance.operations.values()) {
542
- this._wrapAndAddSubAppOperation(instance.id, op);
543
- }
544
- if (this._selfHosting) {
545
- this._notifyAdaptersOfSurfaceChange();
546
- }
547
- }
548
- /**
549
- * Wraps a single operation definition into a krnlLocalFunctionality and binds to this Entity.
550
- */
551
- _wrapAndAddSubAppOperation(subAppId, op) {
552
- const qualifiedFid = `${subAppId}.${op.name}`;
553
- const atomConfig = {
554
- id: qualifiedFid,
555
- visibility: op.visibility || "public",
556
- description: op.description || "",
557
- method: op.method || "POST",
558
- schema: {
559
- input: op.input || null,
560
- output: op.output || null
561
- },
562
- metadata: op.metadata || {},
563
- api: async (input, ctx) => {
564
- return await op.handler(input, {
565
- caller: ctx?.caller,
566
- callerPort: ctx?.callerPort,
567
- accessKey: ctx?.accessKey,
568
- entity: this,
569
- metadata: op.metadata
570
- });
571
- }
572
- };
573
- const localAtom = new krnlLocalFunctionality(atomConfig);
574
- this.addLocal(localAtom);
575
- if (!this.localFunctionalities.has(op.name) && !this.remoteFunctionalities.has(op.name)) {
576
- const aliasAtom = new krnlLocalFunctionality({
577
- ...atomConfig,
578
- id: op.name
579
- });
580
- this.addLocal(aliasAtom);
581
- }
582
- }
583
- /**
584
- * Registers additional operations under an existing sub-app.
585
- */
586
- registerSubAppOperations(subAppId, operations) {
587
- const instance = this._subApps.get(subAppId);
588
- for (const op of operations) {
589
- if (instance) {
590
- instance.operations.set(op.name, op);
591
- }
592
- this._wrapAndAddSubAppOperation(subAppId, op);
593
- }
594
- if (this._selfHosting) {
595
- this._notifyAdaptersOfSurfaceChange();
596
- }
597
- }
598
- /**
599
- * Unregisters and disposes a sub-app from this entity.
600
- */
601
- async unregisterSubApp(subAppId) {
602
- const instance = this._subApps.get(subAppId);
603
- if (!instance) return;
604
- for (const opName of instance.operations.keys()) {
605
- const qualifiedFid = `${subAppId}.${opName}`;
606
- if (this.localFunctionalities.has(qualifiedFid)) {
607
- const func = this.localFunctionalities.get(qualifiedFid);
608
- if (func && typeof func._unregisterFromInterface === "function") {
609
- func._unregisterFromInterface();
610
- }
611
- this.localFunctionalities.delete(qualifiedFid);
612
- }
613
- if (this.localFunctionalities.has(opName)) {
614
- const func = this.localFunctionalities.get(opName);
615
- if (func && typeof func._unregisterFromInterface === "function") {
616
- func._unregisterFromInterface();
617
- }
618
- this.localFunctionalities.delete(opName);
619
- }
620
- }
621
- await KrnlSubAppLifecycle.dispose(instance);
622
- this._subApps.delete(subAppId);
623
- if (this._selfHosting) {
624
- this._notifyAdaptersOfSurfaceChange();
625
- }
626
- }
627
- /**
628
- * Retrieve a registered sub-app instance by ID.
629
- */
630
- getSubApp(subAppId) {
631
- return this._subApps.get(subAppId);
632
- }
633
- /**
634
- * Returns all sub-app instances registered under this entity.
635
- */
636
- getSubApps() {
637
- return Array.from(this._subApps.values());
638
- }
639
- // ── Manifest Aggregation (Kernel Declares → Shell Materializes) ──────────
640
- /**
641
- * Aggregates dependency manifests from all local functionalities, sub-apps, and descendant entities.
642
- * Returns a consolidated workspace requirements document.
643
- */
644
- getWorkspaceRequirements() {
645
- const reqs = {
646
- dependencies: {},
647
- devDependencies: {},
648
- buildRequirements: [],
649
- resources: [],
650
- conflicts: []
651
- };
652
- this._aggregateManifestInto(reqs);
653
- return reqs;
654
- }
655
- _aggregateManifestInto(reqs) {
656
- this.localFunctionalities.forEach((func) => {
657
- if (func.manifest) {
658
- _Entity._mergeManifestRequirements(reqs, func.manifest, `${this.id}:${func.id}`);
659
- }
660
- });
661
- this._subApps.forEach((subApp) => {
662
- if (subApp.manifest) {
663
- _Entity._mergeManifestRequirements(reqs, subApp.manifest, `${this.id}:${subApp.id}`);
664
- }
665
- });
666
- this.hierarchyManager.getAllOwnedComponentEntities().forEach((child) => {
667
- if (typeof child._aggregateManifestInto === "function") {
668
- child._aggregateManifestInto(reqs);
669
- }
670
- });
671
- }
672
- static _mergeManifestRequirements(target, manifest, sourceId) {
673
- if (manifest.dependencies) {
674
- for (const [pkg, ver] of Object.entries(manifest.dependencies)) {
675
- if (target.dependencies[pkg] && target.dependencies[pkg] !== ver) {
676
- target.conflicts = target.conflicts || [];
677
- target.conflicts.push({
678
- package: pkg,
679
- versionA: target.dependencies[pkg],
680
- versionB: ver,
681
- sources: [sourceId]
682
- });
683
- } else {
684
- target.dependencies[pkg] = ver;
685
- }
686
- }
687
- }
688
- if (manifest.devDependencies) {
689
- for (const [pkg, ver] of Object.entries(manifest.devDependencies)) {
690
- target.devDependencies[pkg] = ver;
691
- }
692
- }
693
- if (manifest.buildRequirements) {
694
- for (const req of manifest.buildRequirements) {
695
- if (!target.buildRequirements.includes(req)) {
696
- target.buildRequirements.push(req);
697
- }
698
- }
699
- }
700
- if (manifest.resources) {
701
- for (const res of manifest.resources) {
702
- target.resources.push(res);
703
- }
704
- }
705
- }
706
- // ── UI Spec Recursive Aggregation ────────────────────────────────────────
707
- /**
708
- * Aggregates UI specifications from all functionalities and sub-apps across the entity tree.
709
- * Qualified IDs ensure namespace stability and avoid collisions.
710
- */
711
- aggregateUI() {
712
- const list = [];
713
- this.localFunctionalities.forEach((func, fid) => {
714
- if (func.uiSpec) {
715
- list.push({
716
- qualifiedId: this.getQualifiedId(fid),
717
- uiSpec: func.uiSpec,
718
- source: this
719
- });
720
- }
721
- });
722
- this._subApps.forEach((subApp) => {
723
- const uiConfig = subApp.registration?.ui || subApp.manifest?.ui;
724
- if (uiConfig) {
725
- list.push({
726
- qualifiedId: this.getQualifiedId(subApp.id),
727
- uiSpec: typeof uiConfig === "string" ? { entry: uiConfig } : uiConfig,
728
- source: this
729
- });
730
- }
731
- });
732
- this.hierarchyManager.getAllOwnedComponentEntities().forEach((child) => {
733
- if (typeof child.aggregateUI === "function") {
734
- list.push(...child.aggregateUI());
735
- }
736
- });
737
- return list;
738
- }
739
- // ── Flow Factory ─────────────────────────────────────────────────────────
740
- /**
741
- * Create a FlowBuilder instance bound to this entity.
742
- */
743
- flow(id) {
744
- return new KrnlFlowBuilder(this, id);
745
- }
746
- /**
747
- * Clean disposal of all entity resources, sub-apps, child components, and adapters.
748
- */
749
- dispose() {
750
- if (this._selfHosting) {
751
- this.stopHosting().catch(() => {
752
- });
753
- }
754
- for (const subApp of this._subApps.values()) {
755
- KrnlSubAppLifecycle.dispose(subApp).catch(() => {
756
- });
757
- }
758
- this._subApps.clear();
759
- for (const adapter of this._protocolAdapters.values()) {
760
- if (typeof adapter.dispose === "function") {
761
- adapter.dispose();
762
- }
763
- }
764
- this._protocolAdapters.clear();
765
- super.dispose();
766
- }
767
- };
768
-
769
- export {
770
- KrnlFlowBuilder,
771
- Entity
772
- };