@loom-framework/core 0.1.0-alpha.19 → 0.1.0-alpha.190

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 (815) hide show
  1. package/builtin-skills/antd/SKILL.md +266 -0
  2. package/builtin-skills/antv-g2-chart/SKILL.md +1067 -0
  3. package/builtin-skills/antv-g2-chart/references/animations/g2-animation-intro.md +176 -0
  4. package/builtin-skills/antv-g2-chart/references/animations/g2-animation-keyframe.md +149 -0
  5. package/builtin-skills/antv-g2-chart/references/animations/g2-animation-types.md +253 -0
  6. package/builtin-skills/antv-g2-chart/references/components/g2-comp-annotation.md +237 -0
  7. package/builtin-skills/antv-g2-chart/references/components/g2-comp-axis-config.md +648 -0
  8. package/builtin-skills/antv-g2-chart/references/components/g2-comp-axis-radar.md +219 -0
  9. package/builtin-skills/antv-g2-chart/references/components/g2-comp-label-config.md +174 -0
  10. package/builtin-skills/antv-g2-chart/references/components/g2-comp-legend-category.md +278 -0
  11. package/builtin-skills/antv-g2-chart/references/components/g2-comp-legend-config.md +363 -0
  12. package/builtin-skills/antv-g2-chart/references/components/g2-comp-legend-continuous.md +264 -0
  13. package/builtin-skills/antv-g2-chart/references/components/g2-comp-scrollbar.md +276 -0
  14. package/builtin-skills/antv-g2-chart/references/components/g2-comp-slider.md +333 -0
  15. package/builtin-skills/antv-g2-chart/references/components/g2-comp-title.md +149 -0
  16. package/builtin-skills/antv-g2-chart/references/components/g2-comp-tooltip-config.md +358 -0
  17. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-facet-circle.md +97 -0
  18. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-facet-rect.md +241 -0
  19. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-geo-map.md +210 -0
  20. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-geoview.md +143 -0
  21. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-repeat-matrix.md +171 -0
  22. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-space-flex.md +142 -0
  23. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-space-layer.md +149 -0
  24. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-timing-keyframe.md +91 -0
  25. package/builtin-skills/antv-g2-chart/references/compositions/g2-comp-view.md +309 -0
  26. package/builtin-skills/antv-g2-chart/references/concepts/g2-concept-chart-selection.md +235 -0
  27. package/builtin-skills/antv-g2-chart/references/concepts/g2-concept-color-theory.md +287 -0
  28. package/builtin-skills/antv-g2-chart/references/concepts/g2-concept-visual-channels.md +180 -0
  29. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-cartesian.md +131 -0
  30. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-fisheye.md +131 -0
  31. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-helix.md +141 -0
  32. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-parallel.md +129 -0
  33. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-polar.md +143 -0
  34. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-radial.md +214 -0
  35. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-theta.md +171 -0
  36. package/builtin-skills/antv-g2-chart/references/coordinates/g2-coord-transpose.md +195 -0
  37. package/builtin-skills/antv-g2-chart/references/core/g2-core-chart-init.md +266 -0
  38. package/builtin-skills/antv-g2-chart/references/core/g2-core-encode-channel.md +197 -0
  39. package/builtin-skills/antv-g2-chart/references/core/g2-core-view-composition.md +224 -0
  40. package/builtin-skills/antv-g2-chart/references/data/g2-data-ema.md +190 -0
  41. package/builtin-skills/antv-g2-chart/references/data/g2-data-fetch.md +167 -0
  42. package/builtin-skills/antv-g2-chart/references/data/g2-data-filter.md +212 -0
  43. package/builtin-skills/antv-g2-chart/references/data/g2-data-fold.md +260 -0
  44. package/builtin-skills/antv-g2-chart/references/data/g2-data-format-tabular.md +280 -0
  45. package/builtin-skills/antv-g2-chart/references/data/g2-data-kde.md +426 -0
  46. package/builtin-skills/antv-g2-chart/references/data/g2-data-log.md +140 -0
  47. package/builtin-skills/antv-g2-chart/references/data/g2-data-slice.md +147 -0
  48. package/builtin-skills/antv-g2-chart/references/data/g2-data-sort.md +251 -0
  49. package/builtin-skills/antv-g2-chart/references/data/g2-data-sortby.md +183 -0
  50. package/builtin-skills/antv-g2-chart/references/data/g2-data-transform-patterns.md +394 -0
  51. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-adaptive-filter.md +118 -0
  52. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brush-axis.md +112 -0
  53. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brush-filter.md +122 -0
  54. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brush-x-y-highlight.md +127 -0
  55. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brush-xy.md +118 -0
  56. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brush.md +184 -0
  57. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brushx-filter.md +170 -0
  58. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brushx-highlight.md +186 -0
  59. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brushy-filter.md +170 -0
  60. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-brushy-highlight.md +185 -0
  61. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-chart-index.md +127 -0
  62. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-drilldown.md +149 -0
  63. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-highlight-by.md +125 -0
  64. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-highlight.md +235 -0
  65. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-hover-scale.md +109 -0
  66. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-point-move.md +152 -0
  67. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-select-by.md +133 -0
  68. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-element-select.md +249 -0
  69. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-fisheye.md +117 -0
  70. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-legend-filter.md +130 -0
  71. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-legend-highlight.md +130 -0
  72. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-poptip.md +105 -0
  73. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-scrollbar-filter.md +144 -0
  74. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-slider-filter.md +231 -0
  75. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-slider-wheel.md +138 -0
  76. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-tooltip.md +192 -0
  77. package/builtin-skills/antv-g2-chart/references/interactions/g2-interaction-treemap-drilldown.md +152 -0
  78. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-contrast-reverse.md +170 -0
  79. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-exceed-adjust.md +146 -0
  80. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-overflow-hide.md +185 -0
  81. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-overflow-stroke.md +147 -0
  82. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-overlap-dodge-y.md +225 -0
  83. package/builtin-skills/antv-g2-chart/references/label-transform/g2-label-transform-overlap-hide.md +213 -0
  84. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-arc-diagram.md +196 -0
  85. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-arc-donut.md +148 -0
  86. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-arc-pie.md +212 -0
  87. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-area-basic.md +168 -0
  88. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-area-stacked.md +150 -0
  89. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-beeswarm.md +134 -0
  90. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-bi-directional-bar.md +297 -0
  91. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-box-boxplot.md +163 -0
  92. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-boxplot.md +340 -0
  93. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-bullet.md +203 -0
  94. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-cell-heatmap.md +370 -0
  95. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-chord.md +341 -0
  96. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-connector.md +126 -0
  97. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-contourline.md +243 -0
  98. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-density.md +457 -0
  99. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-distribution-curve.md +298 -0
  100. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-funnel.md +329 -0
  101. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-gantt.md +208 -0
  102. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-gauge.md +247 -0
  103. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-heatmap.md +130 -0
  104. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-histogram.md +186 -0
  105. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-image.md +129 -0
  106. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-interval-basic.md +528 -0
  107. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-interval-grouped.md +161 -0
  108. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-interval-normalized.md +147 -0
  109. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-interval-stacked.md +183 -0
  110. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-k-chart.md +237 -0
  111. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-line-basic.md +353 -0
  112. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-line-multi.md +156 -0
  113. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-linex-liney.md +176 -0
  114. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-link.md +134 -0
  115. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-liquid.md +125 -0
  116. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-mosaic.md +257 -0
  117. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-pack.md +424 -0
  118. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-parallel.md +195 -0
  119. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-partition.md +275 -0
  120. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-path.md +135 -0
  121. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-point-bubble.md +138 -0
  122. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-point-scatter.md +177 -0
  123. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-polygon.md +130 -0
  124. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-radar.md +231 -0
  125. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-radial-bar.md +226 -0
  126. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-range-rangey.md +253 -0
  127. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-rangex.md +293 -0
  128. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-rect.md +115 -0
  129. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-regression-curve.md +276 -0
  130. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-rose.md +182 -0
  131. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-sankey.md +217 -0
  132. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-shape.md +160 -0
  133. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-spiral.md +257 -0
  134. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-sunburst.md +327 -0
  135. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-text.md +309 -0
  136. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-tree.md +235 -0
  137. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-treemap.md +426 -0
  138. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-vector.md +108 -0
  139. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-venn.md +204 -0
  140. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-violin.md +307 -0
  141. package/builtin-skills/antv-g2-chart/references/marks/g2-mark-wordcloud.md +155 -0
  142. package/builtin-skills/antv-g2-chart/references/palette/g2-palette-category10.md +196 -0
  143. package/builtin-skills/antv-g2-chart/references/palette/g2-palette-category20.md +238 -0
  144. package/builtin-skills/antv-g2-chart/references/patterns/g2-pattern-performance.md +181 -0
  145. package/builtin-skills/antv-g2-chart/references/patterns/g2-pattern-responsive.md +232 -0
  146. package/builtin-skills/antv-g2-chart/references/patterns/g2-pattern-v4-to-v5.md +223 -0
  147. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-band.md +127 -0
  148. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-linear.md +259 -0
  149. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-log.md +226 -0
  150. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-ordinal.md +135 -0
  151. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-point.md +242 -0
  152. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-pow-sqrt.md +124 -0
  153. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-quantile-quantize.md +119 -0
  154. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-sequential.md +267 -0
  155. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-threshold.md +133 -0
  156. package/builtin-skills/antv-g2-chart/references/scales/g2-scale-time.md +159 -0
  157. package/builtin-skills/antv-g2-chart/references/themes/g2-theme-builtin.md +192 -0
  158. package/builtin-skills/antv-g2-chart/references/themes/g2-theme-custom.md +183 -0
  159. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-bin.md +153 -0
  160. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-binx.md +133 -0
  161. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-diffy.md +130 -0
  162. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-dodgex.md +90 -0
  163. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-flexx.md +115 -0
  164. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-group.md +233 -0
  165. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-groupcolor.md +182 -0
  166. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-groupx.md +265 -0
  167. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-groupy.md +167 -0
  168. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-jitter.md +149 -0
  169. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-jitterx.md +177 -0
  170. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-jittery.md +177 -0
  171. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-normalizey.md +83 -0
  172. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-pack.md +164 -0
  173. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-sample.md +143 -0
  174. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-select.md +147 -0
  175. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-selectx.md +179 -0
  176. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-selecty.md +179 -0
  177. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-sort-color.md +115 -0
  178. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-sortx.md +285 -0
  179. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-sorty.md +117 -0
  180. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-stack-enter.md +158 -0
  181. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-stacky.md +218 -0
  182. package/builtin-skills/antv-g2-chart/references/transforms/g2-transform-symmetryy.md +122 -0
  183. package/builtin-skills/app-skill/SKILL.md +47 -0
  184. package/builtin-skills/app-skill/references/auth.md +180 -0
  185. package/builtin-skills/app-skill/references/data-semantics.md +44 -0
  186. package/builtin-skills/app-skill/references/events.md +365 -0
  187. package/builtin-skills/app-skill/references/evolution.md +90 -0
  188. package/builtin-skills/app-skill/references/feeder.md +184 -0
  189. package/builtin-skills/app-skill/references/model.md +124 -0
  190. package/builtin-skills/app-skill/references/models.md +59 -0
  191. package/builtin-skills/app-skill/references/notification.md +123 -0
  192. package/builtin-skills/app-skill/references/process-builder.md +420 -0
  193. package/builtin-skills/app-skill/references/process.md +458 -0
  194. package/builtin-skills/chart-visualization/SKILL.md +101 -0
  195. package/builtin-skills/loom/SKILL.md +308 -0
  196. package/builtin-skills/loom/references/README.md +285 -0
  197. package/builtin-skills/loom/references/dashboard.md +259 -0
  198. package/builtin-skills/loom/references/data-model.md +306 -0
  199. package/builtin-skills/loom/references/eject.md +111 -0
  200. package/builtin-skills/yuque-reader/SKILL.md +43 -0
  201. package/builtin-skills/yuque-reader/references/config.md +52 -0
  202. package/builtin-skills/yuque-reader/scripts/fetch_doc.py +121 -0
  203. package/dist/adapter-base.d.ts +31 -0
  204. package/dist/adapter-base.d.ts.map +1 -0
  205. package/dist/adapter-base.js +69 -0
  206. package/dist/adapter-base.js.map +1 -0
  207. package/dist/adapter-factory.d.ts +8 -0
  208. package/dist/adapter-factory.d.ts.map +1 -0
  209. package/dist/adapter-factory.js +25 -0
  210. package/dist/adapter-factory.js.map +1 -0
  211. package/dist/adapter-filesystem.d.ts +25 -11
  212. package/dist/adapter-filesystem.d.ts.map +1 -1
  213. package/dist/adapter-filesystem.js +230 -52
  214. package/dist/adapter-filesystem.js.map +1 -1
  215. package/dist/adapter-sqlite.d.ts +9 -23
  216. package/dist/adapter-sqlite.d.ts.map +1 -1
  217. package/dist/adapter-sqlite.js +94 -55
  218. package/dist/adapter-sqlite.js.map +1 -1
  219. package/dist/adapters/base.d.ts +31 -0
  220. package/dist/adapters/base.d.ts.map +1 -0
  221. package/dist/adapters/base.js +69 -0
  222. package/dist/adapters/base.js.map +1 -0
  223. package/dist/adapters/factory.d.ts +8 -0
  224. package/dist/adapters/factory.d.ts.map +1 -0
  225. package/dist/adapters/factory.js +25 -0
  226. package/dist/adapters/factory.js.map +1 -0
  227. package/dist/adapters/filesystem.d.ts +46 -0
  228. package/dist/adapters/filesystem.d.ts.map +1 -0
  229. package/dist/adapters/filesystem.js +321 -0
  230. package/dist/adapters/filesystem.js.map +1 -0
  231. package/dist/adapters/index.d.ts +10 -0
  232. package/dist/adapters/index.d.ts.map +1 -0
  233. package/dist/adapters/index.js +8 -0
  234. package/dist/adapters/index.js.map +1 -0
  235. package/dist/adapters/sqlite.d.ts +37 -0
  236. package/dist/adapters/sqlite.d.ts.map +1 -0
  237. package/dist/adapters/sqlite.js +264 -0
  238. package/dist/adapters/sqlite.js.map +1 -0
  239. package/dist/backend/ai/button-resolver.d.ts +18 -0
  240. package/dist/backend/ai/button-resolver.d.ts.map +1 -0
  241. package/dist/backend/ai/button-resolver.js +58 -0
  242. package/dist/backend/ai/button-resolver.js.map +1 -0
  243. package/dist/backend/ai/content-blocks.d.ts +18 -0
  244. package/dist/backend/ai/content-blocks.d.ts.map +1 -0
  245. package/dist/backend/ai/content-blocks.js +66 -0
  246. package/dist/backend/ai/content-blocks.js.map +1 -0
  247. package/dist/backend/ai/engine.d.ts +65 -0
  248. package/dist/backend/ai/engine.d.ts.map +1 -0
  249. package/dist/backend/ai/engine.js +238 -0
  250. package/dist/backend/ai/engine.js.map +1 -0
  251. package/dist/backend/ai/index.d.ts +11 -0
  252. package/dist/backend/ai/index.d.ts.map +1 -0
  253. package/dist/backend/ai/index.js +8 -0
  254. package/dist/backend/ai/index.js.map +1 -0
  255. package/dist/backend/ai/output-parser.d.ts +36 -0
  256. package/dist/backend/ai/output-parser.d.ts.map +1 -0
  257. package/dist/backend/ai/output-parser.js +264 -0
  258. package/dist/backend/ai/output-parser.js.map +1 -0
  259. package/dist/backend/ai/session-manager.d.ts +106 -0
  260. package/dist/backend/ai/session-manager.d.ts.map +1 -0
  261. package/dist/backend/ai/session-manager.js +304 -0
  262. package/dist/backend/ai/session-manager.js.map +1 -0
  263. package/dist/backend/auth/jwt.d.ts +16 -0
  264. package/dist/backend/auth/jwt.d.ts.map +1 -0
  265. package/dist/backend/auth/jwt.js +57 -0
  266. package/dist/backend/auth/jwt.js.map +1 -0
  267. package/dist/backend/auth/password.d.ts +10 -0
  268. package/dist/backend/auth/password.d.ts.map +1 -0
  269. package/dist/backend/auth/password.js +19 -0
  270. package/dist/backend/auth/password.js.map +1 -0
  271. package/dist/backend/auth/rbac.d.ts +36 -0
  272. package/dist/backend/auth/rbac.d.ts.map +1 -0
  273. package/dist/backend/auth/rbac.js +130 -0
  274. package/dist/backend/auth/rbac.js.map +1 -0
  275. package/dist/backend/auth/request-context.d.ts +15 -0
  276. package/dist/backend/auth/request-context.d.ts.map +1 -0
  277. package/dist/backend/auth/request-context.js +17 -0
  278. package/dist/backend/auth/request-context.js.map +1 -0
  279. package/dist/backend/auth/service-token.d.ts +11 -0
  280. package/dist/backend/auth/service-token.d.ts.map +1 -0
  281. package/dist/backend/auth/service-token.js +13 -0
  282. package/dist/backend/auth/service-token.js.map +1 -0
  283. package/dist/backend/auth/token-store.d.ts +28 -0
  284. package/dist/backend/auth/token-store.d.ts.map +1 -0
  285. package/dist/backend/auth/token-store.js +84 -0
  286. package/dist/backend/auth/token-store.js.map +1 -0
  287. package/dist/backend/auth/user-store.d.ts +42 -0
  288. package/dist/backend/auth/user-store.d.ts.map +1 -0
  289. package/dist/backend/auth/user-store.js +112 -0
  290. package/dist/backend/auth/user-store.js.map +1 -0
  291. package/dist/backend/events/event-bus.d.ts +39 -0
  292. package/dist/backend/events/event-bus.d.ts.map +1 -0
  293. package/dist/backend/events/event-bus.js +182 -0
  294. package/dist/backend/events/event-bus.js.map +1 -0
  295. package/dist/backend/events/event-emitting-adapter.d.ts +31 -0
  296. package/dist/backend/events/event-emitting-adapter.d.ts.map +1 -0
  297. package/dist/backend/events/event-emitting-adapter.js +70 -0
  298. package/dist/backend/events/event-emitting-adapter.js.map +1 -0
  299. package/dist/backend/events/event-registry.d.ts +22 -0
  300. package/dist/backend/events/event-registry.d.ts.map +1 -0
  301. package/dist/backend/events/event-registry.js +35 -0
  302. package/dist/backend/events/event-registry.js.map +1 -0
  303. package/dist/backend/events/index.d.ts +7 -0
  304. package/dist/backend/events/index.d.ts.map +1 -0
  305. package/dist/backend/events/index.js +7 -0
  306. package/dist/backend/events/index.js.map +1 -0
  307. package/dist/backend/events/subscription-service.d.ts +46 -0
  308. package/dist/backend/events/subscription-service.d.ts.map +1 -0
  309. package/dist/backend/events/subscription-service.js +220 -0
  310. package/dist/backend/events/subscription-service.js.map +1 -0
  311. package/dist/backend/index.d.ts +93 -0
  312. package/dist/backend/index.d.ts.map +1 -0
  313. package/dist/backend/index.js +481 -0
  314. package/dist/backend/index.js.map +1 -0
  315. package/dist/backend/lifecycle/index.d.ts +2 -0
  316. package/dist/backend/lifecycle/index.d.ts.map +1 -0
  317. package/dist/backend/lifecycle/index.js +2 -0
  318. package/dist/backend/lifecycle/index.js.map +1 -0
  319. package/dist/backend/lifecycle/manager.d.ts +73 -0
  320. package/dist/backend/lifecycle/manager.d.ts.map +1 -0
  321. package/dist/backend/lifecycle/manager.js +684 -0
  322. package/dist/backend/lifecycle/manager.js.map +1 -0
  323. package/dist/backend/loom-paths.d.ts +30 -0
  324. package/dist/backend/loom-paths.d.ts.map +1 -0
  325. package/dist/backend/loom-paths.js +49 -0
  326. package/dist/backend/loom-paths.js.map +1 -0
  327. package/dist/backend/notifications/interpolate.d.ts +6 -0
  328. package/dist/backend/notifications/interpolate.d.ts.map +1 -0
  329. package/dist/backend/notifications/interpolate.js +11 -0
  330. package/dist/backend/notifications/interpolate.js.map +1 -0
  331. package/dist/backend/notifications/notification-storage.d.ts +27 -0
  332. package/dist/backend/notifications/notification-storage.d.ts.map +1 -0
  333. package/dist/backend/notifications/notification-storage.js +160 -0
  334. package/dist/backend/notifications/notification-storage.js.map +1 -0
  335. package/dist/backend/observe/index.d.ts +6 -0
  336. package/dist/backend/observe/index.d.ts.map +1 -0
  337. package/dist/backend/observe/index.js +5 -0
  338. package/dist/backend/observe/index.js.map +1 -0
  339. package/dist/backend/observe/logger.d.ts +26 -0
  340. package/dist/backend/observe/logger.d.ts.map +1 -0
  341. package/dist/backend/observe/logger.js +68 -0
  342. package/dist/backend/observe/logger.js.map +1 -0
  343. package/dist/backend/observe/types.d.ts +26 -0
  344. package/dist/backend/observe/types.d.ts.map +1 -0
  345. package/dist/backend/observe/types.js +7 -0
  346. package/dist/backend/observe/types.js.map +1 -0
  347. package/dist/backend/process/engine.d.ts +127 -0
  348. package/dist/backend/process/engine.d.ts.map +1 -0
  349. package/dist/backend/process/engine.js +668 -0
  350. package/dist/backend/process/engine.js.map +1 -0
  351. package/dist/backend/process/index.d.ts +8 -0
  352. package/dist/backend/process/index.d.ts.map +1 -0
  353. package/dist/backend/process/index.js +7 -0
  354. package/dist/backend/process/index.js.map +1 -0
  355. package/dist/backend/process/logger.d.ts +38 -0
  356. package/dist/backend/process/logger.d.ts.map +1 -0
  357. package/dist/backend/process/logger.js +198 -0
  358. package/dist/backend/process/logger.js.map +1 -0
  359. package/dist/backend/process/metrics-store.d.ts +32 -0
  360. package/dist/backend/process/metrics-store.d.ts.map +1 -0
  361. package/dist/backend/process/metrics-store.js +108 -0
  362. package/dist/backend/process/metrics-store.js.map +1 -0
  363. package/dist/backend/process/migrate.d.ts +12 -0
  364. package/dist/backend/process/migrate.d.ts.map +1 -0
  365. package/dist/backend/process/migrate.js +145 -0
  366. package/dist/backend/process/migrate.js.map +1 -0
  367. package/dist/backend/process/process-helpers.d.ts +13 -0
  368. package/dist/backend/process/process-helpers.d.ts.map +1 -0
  369. package/dist/backend/process/process-helpers.js +23 -0
  370. package/dist/backend/process/process-helpers.js.map +1 -0
  371. package/dist/backend/process/queue.d.ts +33 -0
  372. package/dist/backend/process/queue.d.ts.map +1 -0
  373. package/dist/backend/process/queue.js +94 -0
  374. package/dist/backend/process/queue.js.map +1 -0
  375. package/dist/backend/process/registry.d.ts +64 -0
  376. package/dist/backend/process/registry.d.ts.map +1 -0
  377. package/dist/backend/process/registry.js +277 -0
  378. package/dist/backend/process/registry.js.map +1 -0
  379. package/dist/backend/process/trigger.d.ts +39 -0
  380. package/dist/backend/process/trigger.d.ts.map +1 -0
  381. package/dist/backend/process/trigger.js +162 -0
  382. package/dist/backend/process/trigger.js.map +1 -0
  383. package/dist/backend/routes/ai-config.d.ts +18 -0
  384. package/dist/backend/routes/ai-config.d.ts.map +1 -0
  385. package/dist/backend/routes/ai-config.js +227 -0
  386. package/dist/backend/routes/ai-config.js.map +1 -0
  387. package/dist/backend/routes/auth-routes.d.ts +33 -0
  388. package/dist/backend/routes/auth-routes.d.ts.map +1 -0
  389. package/dist/backend/routes/auth-routes.js +528 -0
  390. package/dist/backend/routes/auth-routes.js.map +1 -0
  391. package/dist/backend/routes/chat-sse.d.ts +17 -0
  392. package/dist/backend/routes/chat-sse.d.ts.map +1 -0
  393. package/dist/backend/routes/chat-sse.js +60 -0
  394. package/dist/backend/routes/chat-sse.js.map +1 -0
  395. package/dist/backend/routes/chat.d.ts +30 -0
  396. package/dist/backend/routes/chat.d.ts.map +1 -0
  397. package/dist/backend/routes/chat.js +258 -0
  398. package/dist/backend/routes/chat.js.map +1 -0
  399. package/dist/backend/routes/config-writer.d.ts +94 -0
  400. package/dist/backend/routes/config-writer.d.ts.map +1 -0
  401. package/dist/backend/routes/config-writer.js +538 -0
  402. package/dist/backend/routes/config-writer.js.map +1 -0
  403. package/dist/backend/routes/data.d.ts +16 -0
  404. package/dist/backend/routes/data.d.ts.map +1 -0
  405. package/dist/backend/routes/data.js +371 -0
  406. package/dist/backend/routes/data.js.map +1 -0
  407. package/dist/backend/routes/event-routes.d.ts +22 -0
  408. package/dist/backend/routes/event-routes.d.ts.map +1 -0
  409. package/dist/backend/routes/event-routes.js +153 -0
  410. package/dist/backend/routes/event-routes.js.map +1 -0
  411. package/dist/backend/routes/health.d.ts +7 -0
  412. package/dist/backend/routes/health.d.ts.map +1 -0
  413. package/dist/backend/routes/health.js +15 -0
  414. package/dist/backend/routes/health.js.map +1 -0
  415. package/dist/backend/routes/index.d.ts +24 -0
  416. package/dist/backend/routes/index.d.ts.map +1 -0
  417. package/dist/backend/routes/index.js +16 -0
  418. package/dist/backend/routes/index.js.map +1 -0
  419. package/dist/backend/routes/lifecycle-routes.d.ts +10 -0
  420. package/dist/backend/routes/lifecycle-routes.d.ts.map +1 -0
  421. package/dist/backend/routes/lifecycle-routes.js +54 -0
  422. package/dist/backend/routes/lifecycle-routes.js.map +1 -0
  423. package/dist/backend/routes/notification-routes.d.ts +22 -0
  424. package/dist/backend/routes/notification-routes.d.ts.map +1 -0
  425. package/dist/backend/routes/notification-routes.js +129 -0
  426. package/dist/backend/routes/notification-routes.js.map +1 -0
  427. package/dist/backend/routes/process-routes.d.ts +22 -0
  428. package/dist/backend/routes/process-routes.d.ts.map +1 -0
  429. package/dist/backend/routes/process-routes.js +542 -0
  430. package/dist/backend/routes/process-routes.js.map +1 -0
  431. package/dist/backend/routes/session-routes.d.ts +22 -0
  432. package/dist/backend/routes/session-routes.d.ts.map +1 -0
  433. package/dist/backend/routes/session-routes.js +97 -0
  434. package/dist/backend/routes/session-routes.js.map +1 -0
  435. package/dist/backend/routes/skill-archive.d.ts +13 -0
  436. package/dist/backend/routes/skill-archive.d.ts.map +1 -0
  437. package/dist/backend/routes/skill-archive.js +84 -0
  438. package/dist/backend/routes/skill-archive.js.map +1 -0
  439. package/dist/backend/routes/skill-parser.d.ts +41 -0
  440. package/dist/backend/routes/skill-parser.d.ts.map +1 -0
  441. package/dist/backend/routes/skill-parser.js +184 -0
  442. package/dist/backend/routes/skill-parser.js.map +1 -0
  443. package/dist/backend/routes/skill-service.d.ts +113 -0
  444. package/dist/backend/routes/skill-service.d.ts.map +1 -0
  445. package/dist/backend/routes/skill-service.js +265 -0
  446. package/dist/backend/routes/skill-service.js.map +1 -0
  447. package/dist/backend/routes/skills.d.ts +18 -0
  448. package/dist/backend/routes/skills.d.ts.map +1 -0
  449. package/dist/backend/routes/skills.js +168 -0
  450. package/dist/backend/routes/skills.js.map +1 -0
  451. package/dist/backend/routes/upload.d.ts +25 -0
  452. package/dist/backend/routes/upload.d.ts.map +1 -0
  453. package/dist/backend/routes/upload.js +100 -0
  454. package/dist/backend/routes/upload.js.map +1 -0
  455. package/dist/backend/services/skill-archive.d.ts +13 -0
  456. package/dist/backend/services/skill-archive.d.ts.map +1 -0
  457. package/dist/backend/services/skill-archive.js +84 -0
  458. package/dist/backend/services/skill-archive.js.map +1 -0
  459. package/dist/backend/services/skill-parser.d.ts +41 -0
  460. package/dist/backend/services/skill-parser.d.ts.map +1 -0
  461. package/dist/backend/services/skill-parser.js +184 -0
  462. package/dist/backend/services/skill-parser.js.map +1 -0
  463. package/dist/backend/services/skill-service.d.ts +113 -0
  464. package/dist/backend/services/skill-service.d.ts.map +1 -0
  465. package/dist/backend/services/skill-service.js +265 -0
  466. package/dist/backend/services/skill-service.js.map +1 -0
  467. package/dist/bin.d.ts +8 -0
  468. package/dist/bin.d.ts.map +1 -0
  469. package/dist/bin.js +12 -0
  470. package/dist/bin.js.map +1 -0
  471. package/dist/capability-generator.d.ts +21 -6
  472. package/dist/capability-generator.d.ts.map +1 -1
  473. package/dist/capability-generator.js +88 -261
  474. package/dist/capability-generator.js.map +1 -1
  475. package/dist/cli/commands/auth.d.ts +11 -0
  476. package/dist/cli/commands/auth.d.ts.map +1 -0
  477. package/dist/cli/commands/auth.js +211 -0
  478. package/dist/cli/commands/auth.js.map +1 -0
  479. package/dist/cli/commands/build.d.ts +11 -0
  480. package/dist/cli/commands/build.d.ts.map +1 -0
  481. package/dist/cli/commands/build.js +170 -0
  482. package/dist/cli/commands/build.js.map +1 -0
  483. package/dist/cli/commands/data.d.ts +15 -0
  484. package/dist/cli/commands/data.d.ts.map +1 -0
  485. package/dist/cli/commands/data.js +220 -0
  486. package/dist/cli/commands/data.js.map +1 -0
  487. package/dist/cli/commands/dev.d.ts +8 -0
  488. package/dist/cli/commands/dev.d.ts.map +1 -0
  489. package/dist/cli/commands/dev.js +114 -0
  490. package/dist/cli/commands/dev.js.map +1 -0
  491. package/dist/cli/commands/eject.d.ts +12 -0
  492. package/dist/cli/commands/eject.d.ts.map +1 -0
  493. package/dist/cli/commands/eject.js +280 -0
  494. package/dist/cli/commands/eject.js.map +1 -0
  495. package/dist/cli/commands/event.d.ts +13 -0
  496. package/dist/cli/commands/event.d.ts.map +1 -0
  497. package/dist/cli/commands/event.js +379 -0
  498. package/dist/cli/commands/event.js.map +1 -0
  499. package/dist/cli/commands/generate-capabilities.d.ts +8 -0
  500. package/dist/cli/commands/generate-capabilities.d.ts.map +1 -0
  501. package/dist/cli/commands/generate-capabilities.js +41 -0
  502. package/dist/cli/commands/generate-capabilities.js.map +1 -0
  503. package/dist/cli/commands/generate-cli-command.d.ts +8 -0
  504. package/dist/cli/commands/generate-cli-command.d.ts.map +1 -0
  505. package/dist/cli/commands/generate-cli-command.js +64 -0
  506. package/dist/cli/commands/generate-cli-command.js.map +1 -0
  507. package/dist/cli/commands/generate-dashboard.d.ts +9 -0
  508. package/dist/cli/commands/generate-dashboard.d.ts.map +1 -0
  509. package/dist/cli/commands/generate-dashboard.js +113 -0
  510. package/dist/cli/commands/generate-dashboard.js.map +1 -0
  511. package/dist/cli/commands/generate-notification.d.ts +9 -0
  512. package/dist/cli/commands/generate-notification.d.ts.map +1 -0
  513. package/dist/cli/commands/generate-notification.js +24 -0
  514. package/dist/cli/commands/generate-notification.js.map +1 -0
  515. package/dist/cli/commands/generate-page.d.ts +9 -0
  516. package/dist/cli/commands/generate-page.d.ts.map +1 -0
  517. package/dist/cli/commands/generate-page.js +105 -0
  518. package/dist/cli/commands/generate-page.js.map +1 -0
  519. package/dist/cli/commands/generate-skill.d.ts +8 -0
  520. package/dist/cli/commands/generate-skill.d.ts.map +1 -0
  521. package/dist/cli/commands/generate-skill.js +75 -0
  522. package/dist/cli/commands/generate-skill.js.map +1 -0
  523. package/dist/cli/commands/generate-system-settings.d.ts +10 -0
  524. package/dist/cli/commands/generate-system-settings.d.ts.map +1 -0
  525. package/dist/cli/commands/generate-system-settings.js +56 -0
  526. package/dist/cli/commands/generate-system-settings.js.map +1 -0
  527. package/dist/cli/commands/generate.d.ts +6 -0
  528. package/dist/cli/commands/generate.d.ts.map +1 -0
  529. package/dist/cli/commands/generate.js +21 -0
  530. package/dist/cli/commands/generate.js.map +1 -0
  531. package/dist/cli/commands/init.d.ts +8 -0
  532. package/dist/cli/commands/init.d.ts.map +1 -0
  533. package/dist/cli/commands/init.js +384 -0
  534. package/dist/cli/commands/init.js.map +1 -0
  535. package/dist/cli/commands/lifecycle.d.ts +8 -0
  536. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  537. package/dist/cli/commands/lifecycle.js +166 -0
  538. package/dist/cli/commands/lifecycle.js.map +1 -0
  539. package/dist/cli/commands/model.d.ts +9 -0
  540. package/dist/cli/commands/model.d.ts.map +1 -0
  541. package/dist/cli/commands/model.js +218 -0
  542. package/dist/cli/commands/model.js.map +1 -0
  543. package/dist/cli/commands/notification.d.ts +8 -0
  544. package/dist/cli/commands/notification.d.ts.map +1 -0
  545. package/dist/cli/commands/notification.js +179 -0
  546. package/dist/cli/commands/notification.js.map +1 -0
  547. package/dist/cli/commands/observe.d.ts +9 -0
  548. package/dist/cli/commands/observe.d.ts.map +1 -0
  549. package/dist/cli/commands/observe.js +142 -0
  550. package/dist/cli/commands/observe.js.map +1 -0
  551. package/dist/cli/commands/process.d.ts +8 -0
  552. package/dist/cli/commands/process.d.ts.map +1 -0
  553. package/dist/cli/commands/process.js +630 -0
  554. package/dist/cli/commands/process.js.map +1 -0
  555. package/dist/cli/commands/role.d.ts +12 -0
  556. package/dist/cli/commands/role.d.ts.map +1 -0
  557. package/dist/cli/commands/role.js +208 -0
  558. package/dist/cli/commands/role.js.map +1 -0
  559. package/dist/cli/commands/serve.d.ts +12 -0
  560. package/dist/cli/commands/serve.d.ts.map +1 -0
  561. package/dist/cli/commands/serve.js +43 -0
  562. package/dist/cli/commands/serve.js.map +1 -0
  563. package/dist/cli/commands/skill.d.ts +9 -0
  564. package/dist/cli/commands/skill.d.ts.map +1 -0
  565. package/dist/cli/commands/skill.js +186 -0
  566. package/dist/cli/commands/skill.js.map +1 -0
  567. package/dist/cli/commands/user-cmd.d.ts +9 -0
  568. package/dist/cli/commands/user-cmd.d.ts.map +1 -0
  569. package/dist/cli/commands/user-cmd.js +195 -0
  570. package/dist/cli/commands/user-cmd.js.map +1 -0
  571. package/dist/cli/framework.d.ts +28 -0
  572. package/dist/cli/framework.d.ts.map +1 -0
  573. package/dist/cli/framework.js +29 -0
  574. package/dist/cli/framework.js.map +1 -0
  575. package/dist/cli/generators/capability-generator.d.ts +35 -0
  576. package/dist/cli/generators/capability-generator.d.ts.map +1 -0
  577. package/dist/cli/generators/capability-generator.js +371 -0
  578. package/dist/cli/generators/capability-generator.js.map +1 -0
  579. package/dist/cli/helpers/app-tsx-utils.d.ts +12 -0
  580. package/dist/cli/helpers/app-tsx-utils.d.ts.map +1 -0
  581. package/dist/cli/helpers/app-tsx-utils.js +22 -0
  582. package/dist/cli/helpers/app-tsx-utils.js.map +1 -0
  583. package/dist/cli/helpers/app-tsx-wiring-engine.d.ts +70 -0
  584. package/dist/cli/helpers/app-tsx-wiring-engine.d.ts.map +1 -0
  585. package/dist/cli/helpers/app-tsx-wiring-engine.js +535 -0
  586. package/dist/cli/helpers/app-tsx-wiring-engine.js.map +1 -0
  587. package/dist/cli/helpers/app-tsx-wiring.d.ts +19 -0
  588. package/dist/cli/helpers/app-tsx-wiring.d.ts.map +1 -0
  589. package/dist/cli/helpers/app-tsx-wiring.js +145 -0
  590. package/dist/cli/helpers/app-tsx-wiring.js.map +1 -0
  591. package/dist/cli/helpers/auth-client.d.ts +19 -0
  592. package/dist/cli/helpers/auth-client.d.ts.map +1 -0
  593. package/dist/cli/helpers/auth-client.js +42 -0
  594. package/dist/cli/helpers/auth-client.js.map +1 -0
  595. package/dist/cli/helpers/backup.d.ts +16 -0
  596. package/dist/cli/helpers/backup.d.ts.map +1 -0
  597. package/dist/cli/helpers/backup.js +34 -0
  598. package/dist/cli/helpers/backup.js.map +1 -0
  599. package/dist/cli/helpers/column-template.d.ts +20 -0
  600. package/dist/cli/helpers/column-template.d.ts.map +1 -0
  601. package/dist/cli/helpers/column-template.js +165 -0
  602. package/dist/cli/helpers/column-template.js.map +1 -0
  603. package/dist/cli/helpers/duration.d.ts +5 -0
  604. package/dist/cli/helpers/duration.d.ts.map +1 -0
  605. package/dist/cli/helpers/duration.js +5 -0
  606. package/dist/cli/helpers/duration.js.map +1 -0
  607. package/dist/cli/helpers/field-template.d.ts +14 -0
  608. package/dist/cli/helpers/field-template.d.ts.map +1 -0
  609. package/dist/cli/helpers/field-template.js +117 -0
  610. package/dist/cli/helpers/field-template.js.map +1 -0
  611. package/dist/cli/helpers/i18n-template.d.ts +21 -0
  612. package/dist/cli/helpers/i18n-template.d.ts.map +1 -0
  613. package/dist/cli/helpers/i18n-template.js +69 -0
  614. package/dist/cli/helpers/i18n-template.js.map +1 -0
  615. package/dist/cli/helpers/naming.d.ts +11 -0
  616. package/dist/cli/helpers/naming.d.ts.map +1 -0
  617. package/dist/cli/helpers/naming.js +21 -0
  618. package/dist/cli/helpers/naming.js.map +1 -0
  619. package/dist/cli/helpers/system-page-config.d.ts +27 -0
  620. package/dist/cli/helpers/system-page-config.d.ts.map +1 -0
  621. package/dist/cli/helpers/system-page-config.js +82 -0
  622. package/dist/cli/helpers/system-page-config.js.map +1 -0
  623. package/dist/cli/index.d.ts +9 -0
  624. package/dist/cli/index.d.ts.map +1 -0
  625. package/dist/cli/index.js +51 -0
  626. package/dist/cli/index.js.map +1 -0
  627. package/dist/cli/lib/credentials.d.ts +27 -0
  628. package/dist/cli/lib/credentials.d.ts.map +1 -0
  629. package/dist/cli/lib/credentials.js +112 -0
  630. package/dist/cli/lib/credentials.js.map +1 -0
  631. package/dist/cli/templates/auth-wiring.d.ts +17 -0
  632. package/dist/cli/templates/auth-wiring.d.ts.map +1 -0
  633. package/dist/cli/templates/auth-wiring.js +31 -0
  634. package/dist/cli/templates/auth-wiring.js.map +1 -0
  635. package/dist/cli/templates/backend-entry.d.ts +5 -0
  636. package/dist/cli/templates/backend-entry.d.ts.map +1 -0
  637. package/dist/cli/templates/backend-entry.js +17 -0
  638. package/dist/cli/templates/backend-entry.js.map +1 -0
  639. package/dist/cli/templates/claude-md.d.ts +20 -0
  640. package/dist/cli/templates/claude-md.d.ts.map +1 -0
  641. package/dist/cli/templates/claude-md.js +123 -0
  642. package/dist/cli/templates/claude-md.js.map +1 -0
  643. package/dist/cli/templates/crud-page.d.ts +14 -0
  644. package/dist/cli/templates/crud-page.d.ts.map +1 -0
  645. package/dist/cli/templates/crud-page.js +436 -0
  646. package/dist/cli/templates/crud-page.js.map +1 -0
  647. package/dist/cli/templates/dashboard-page.d.ts +11 -0
  648. package/dist/cli/templates/dashboard-page.d.ts.map +1 -0
  649. package/dist/cli/templates/dashboard-page.js +613 -0
  650. package/dist/cli/templates/dashboard-page.js.map +1 -0
  651. package/dist/cli/templates/event-management-page.d.ts +8 -0
  652. package/dist/cli/templates/event-management-page.d.ts.map +1 -0
  653. package/dist/cli/templates/event-management-page.js +724 -0
  654. package/dist/cli/templates/event-management-page.js.map +1 -0
  655. package/dist/cli/templates/frontend-entry.d.ts +11 -0
  656. package/dist/cli/templates/frontend-entry.d.ts.map +1 -0
  657. package/dist/cli/templates/frontend-entry.js +94 -0
  658. package/dist/cli/templates/frontend-entry.js.map +1 -0
  659. package/dist/cli/templates/gitignore.d.ts +5 -0
  660. package/dist/cli/templates/gitignore.d.ts.map +1 -0
  661. package/dist/cli/templates/gitignore.js +13 -0
  662. package/dist/cli/templates/gitignore.js.map +1 -0
  663. package/dist/cli/templates/index.d.ts +21 -0
  664. package/dist/cli/templates/index.d.ts.map +1 -0
  665. package/dist/cli/templates/index.js +21 -0
  666. package/dist/cli/templates/index.js.map +1 -0
  667. package/dist/cli/templates/login-page.d.ts +8 -0
  668. package/dist/cli/templates/login-page.d.ts.map +1 -0
  669. package/dist/cli/templates/login-page.js +67 -0
  670. package/dist/cli/templates/login-page.js.map +1 -0
  671. package/dist/cli/templates/loom-config.d.ts +15 -0
  672. package/dist/cli/templates/loom-config.d.ts.map +1 -0
  673. package/dist/cli/templates/loom-config.js +91 -0
  674. package/dist/cli/templates/loom-config.js.map +1 -0
  675. package/dist/cli/templates/model-management-page.d.ts +8 -0
  676. package/dist/cli/templates/model-management-page.d.ts.map +1 -0
  677. package/dist/cli/templates/model-management-page.js +373 -0
  678. package/dist/cli/templates/model-management-page.js.map +1 -0
  679. package/dist/cli/templates/notification-center-page.d.ts +8 -0
  680. package/dist/cli/templates/notification-center-page.d.ts.map +1 -0
  681. package/dist/cli/templates/notification-center-page.js +240 -0
  682. package/dist/cli/templates/notification-center-page.js.map +1 -0
  683. package/dist/cli/templates/notification-detail-page.d.ts +8 -0
  684. package/dist/cli/templates/notification-detail-page.d.ts.map +1 -0
  685. package/dist/cli/templates/notification-detail-page.js +87 -0
  686. package/dist/cli/templates/notification-detail-page.js.map +1 -0
  687. package/dist/cli/templates/package-json.d.ts +9 -0
  688. package/dist/cli/templates/package-json.d.ts.map +1 -0
  689. package/dist/cli/templates/package-json.js +41 -0
  690. package/dist/cli/templates/package-json.js.map +1 -0
  691. package/dist/cli/templates/process-management-page.d.ts +8 -0
  692. package/dist/cli/templates/process-management-page.d.ts.map +1 -0
  693. package/dist/cli/templates/process-management-page.js +542 -0
  694. package/dist/cli/templates/process-management-page.js.map +1 -0
  695. package/dist/cli/templates/readme.d.ts +9 -0
  696. package/dist/cli/templates/readme.d.ts.map +1 -0
  697. package/dist/cli/templates/readme.js +47 -0
  698. package/dist/cli/templates/readme.js.map +1 -0
  699. package/dist/cli/templates/skill-management-page.d.ts +8 -0
  700. package/dist/cli/templates/skill-management-page.d.ts.map +1 -0
  701. package/dist/cli/templates/skill-management-page.js +476 -0
  702. package/dist/cli/templates/skill-management-page.js.map +1 -0
  703. package/dist/cli/templates/system-settings-page.d.ts +10 -0
  704. package/dist/cli/templates/system-settings-page.d.ts.map +1 -0
  705. package/dist/cli/templates/system-settings-page.js +768 -0
  706. package/dist/cli/templates/system-settings-page.js.map +1 -0
  707. package/dist/cli/templates/tsconfig.d.ts +6 -0
  708. package/dist/cli/templates/tsconfig.d.ts.map +1 -0
  709. package/dist/cli/templates/tsconfig.js +41 -0
  710. package/dist/cli/templates/tsconfig.js.map +1 -0
  711. package/dist/cli/templates/user-management-page.d.ts +8 -0
  712. package/dist/cli/templates/user-management-page.d.ts.map +1 -0
  713. package/dist/cli/templates/user-management-page.js +497 -0
  714. package/dist/cli/templates/user-management-page.js.map +1 -0
  715. package/dist/cli/templates/vite-config.d.ts +9 -0
  716. package/dist/cli/templates/vite-config.d.ts.map +1 -0
  717. package/dist/cli/templates/vite-config.js +26 -0
  718. package/dist/cli/templates/vite-config.js.map +1 -0
  719. package/dist/cli/utils.d.ts +10 -0
  720. package/dist/cli/utils.d.ts.map +1 -0
  721. package/dist/cli/utils.js +31 -0
  722. package/dist/cli/utils.js.map +1 -0
  723. package/dist/commands.d.ts +1 -5
  724. package/dist/commands.d.ts.map +1 -1
  725. package/dist/commands.js +0 -11
  726. package/dist/commands.js.map +1 -1
  727. package/dist/config.d.ts +2010 -95
  728. package/dist/config.d.ts.map +1 -1
  729. package/dist/config.js +195 -16
  730. package/dist/config.js.map +1 -1
  731. package/dist/dashboard-config.d.ts +149 -0
  732. package/dist/dashboard-config.d.ts.map +1 -0
  733. package/dist/dashboard-config.js +40 -0
  734. package/dist/dashboard-config.js.map +1 -0
  735. package/dist/index.d.ts +24 -9
  736. package/dist/index.d.ts.map +1 -1
  737. package/dist/index.js +20 -5
  738. package/dist/index.js.map +1 -1
  739. package/dist/server-bin.d.ts +12 -0
  740. package/dist/server-bin.d.ts.map +1 -0
  741. package/dist/server-bin.js +43 -0
  742. package/dist/server-bin.js.map +1 -0
  743. package/dist/system-prompt.d.ts +20 -0
  744. package/dist/system-prompt.d.ts.map +1 -0
  745. package/dist/system-prompt.js +140 -0
  746. package/dist/system-prompt.js.map +1 -0
  747. package/dist/types/adapter.d.ts +30 -0
  748. package/dist/types/adapter.d.ts.map +1 -0
  749. package/dist/types/adapter.js +5 -0
  750. package/dist/types/adapter.js.map +1 -0
  751. package/dist/types/ai.d.ts +78 -0
  752. package/dist/types/ai.d.ts.map +1 -0
  753. package/dist/types/ai.js +5 -0
  754. package/dist/types/ai.js.map +1 -0
  755. package/dist/types/auth.d.ts +62 -0
  756. package/dist/types/auth.d.ts.map +1 -0
  757. package/dist/types/auth.js +5 -0
  758. package/dist/types/auth.js.map +1 -0
  759. package/dist/types/chat.d.ts +47 -0
  760. package/dist/types/chat.d.ts.map +1 -0
  761. package/dist/types/chat.js +8 -0
  762. package/dist/types/chat.js.map +1 -0
  763. package/dist/types/command.d.ts +25 -0
  764. package/dist/types/command.d.ts.map +1 -0
  765. package/dist/types/command.js +5 -0
  766. package/dist/types/command.js.map +1 -0
  767. package/dist/types/config.d.ts +69 -0
  768. package/dist/types/config.d.ts.map +1 -0
  769. package/dist/types/config.js +5 -0
  770. package/dist/types/config.js.map +1 -0
  771. package/dist/types/dashboard.d.ts +59 -0
  772. package/dist/types/dashboard.d.ts.map +1 -0
  773. package/dist/types/dashboard.js +5 -0
  774. package/dist/types/dashboard.js.map +1 -0
  775. package/dist/types/event.d.ts +109 -0
  776. package/dist/types/event.d.ts.map +1 -0
  777. package/dist/types/event.js +38 -0
  778. package/dist/types/event.js.map +1 -0
  779. package/dist/types/index.d.ts +22 -0
  780. package/dist/types/index.d.ts.map +1 -0
  781. package/dist/types/index.js +9 -0
  782. package/dist/types/index.js.map +1 -0
  783. package/dist/types/lifecycle.d.ts +71 -0
  784. package/dist/types/lifecycle.d.ts.map +1 -0
  785. package/dist/types/lifecycle.js +10 -0
  786. package/dist/types/lifecycle.js.map +1 -0
  787. package/dist/types/locale.d.ts +21 -0
  788. package/dist/types/locale.d.ts.map +1 -0
  789. package/dist/types/locale.js +36 -0
  790. package/dist/types/locale.js.map +1 -0
  791. package/dist/types/model.d.ts +71 -0
  792. package/dist/types/model.d.ts.map +1 -0
  793. package/dist/types/model.js +5 -0
  794. package/dist/types/model.js.map +1 -0
  795. package/dist/types/notification.d.ts +33 -0
  796. package/dist/types/notification.d.ts.map +1 -0
  797. package/dist/types/notification.js +5 -0
  798. package/dist/types/notification.js.map +1 -0
  799. package/dist/types/process.d.ts +233 -0
  800. package/dist/types/process.d.ts.map +1 -0
  801. package/dist/types/process.js +5 -0
  802. package/dist/types/process.js.map +1 -0
  803. package/dist/types.d.ts +4 -199
  804. package/dist/types.d.ts.map +1 -1
  805. package/dist/types.js +4 -3
  806. package/dist/types.js.map +1 -1
  807. package/dist/utils/duration.d.ts +8 -0
  808. package/dist/utils/duration.d.ts.map +1 -0
  809. package/dist/utils/duration.js +22 -0
  810. package/dist/utils/duration.js.map +1 -0
  811. package/dist/utils/id.d.ts +7 -0
  812. package/dist/utils/id.d.ts.map +1 -0
  813. package/dist/utils/id.js +9 -0
  814. package/dist/utils/id.js.map +1 -0
  815. package/package.json +30 -5
@@ -0,0 +1,684 @@
1
+ /**
2
+ * LifecycleManager — manages long-running lifecycle scripts with
3
+ * auto-restart, exponential backoff, memory limits, and graceful shutdown.
4
+ */
5
+ import { spawn } from 'node:child_process';
6
+ import { execSync } from 'node:child_process';
7
+ import fs from 'fs/promises';
8
+ import path from 'path';
9
+ import { deriveLifecycleNames } from '../process/process-helpers.js';
10
+ // ---------------------------------------------------------------------------
11
+ // Defaults
12
+ // ---------------------------------------------------------------------------
13
+ const DEFAULT_SHUTDOWN_TIMEOUT_MS = 5_000;
14
+ const DEFAULT_RESTART = true;
15
+ const DEFAULT_MAX_RESTARTS = 5;
16
+ const DEFAULT_RESTART_WINDOW_MS = 60_000;
17
+ const DEFAULT_BACKOFF_INITIAL_MS = 1_000;
18
+ const DEFAULT_BACKOFF_MAX_MS = 30_000;
19
+ const DEFAULT_BACKOFF_MULTIPLIER = 2.0;
20
+ const DEFAULT_MEMORY_LIMIT_MB = 512;
21
+ const DEFAULT_ENABLED = true;
22
+ const MEMORY_CHECK_INTERVAL_MS = 5_000;
23
+ const PID_DIR = '.loom/.pids';
24
+ // ---------------------------------------------------------------------------
25
+ // LifecycleManager
26
+ // ---------------------------------------------------------------------------
27
+ export class LifecycleManager {
28
+ config;
29
+ eventBus;
30
+ projectRoot;
31
+ serverPort;
32
+ processes = new Map();
33
+ /** Index: command → primary script name currently running that command */
34
+ commandPrimary = new Map();
35
+ pidDir;
36
+ constructor(config, eventBus, projectRoot, serverPort) {
37
+ this.config = config;
38
+ this.eventBus = eventBus;
39
+ this.projectRoot = projectRoot;
40
+ this.serverPort = serverPort ?? Number(process.env.LOOM_SERVER_PORT ?? 3000);
41
+ this.pidDir = path.join(projectRoot, PID_DIR);
42
+ }
43
+ // -----------------------------------------------------------------------
44
+ // Public API
45
+ // -----------------------------------------------------------------------
46
+ /** Start all enabled lifecycle scripts. Cleans up orphan processes from previous runs first. */
47
+ async startAll() {
48
+ await this.cleanOrphanProcesses();
49
+ for (const proc of this.processes.values()) {
50
+ if (proc.config.enabled === false) {
51
+ continue;
52
+ }
53
+ this.spawnProcess(proc);
54
+ }
55
+ }
56
+ /** Stop all running lifecycle scripts in parallel. */
57
+ async stopAll() {
58
+ const stops = [];
59
+ for (const proc of this.processes.values()) {
60
+ if (proc.status === 'running' || proc.status === 'starting' || proc.status === 'backoff') {
61
+ stops.push(this.stopProcess(proc));
62
+ }
63
+ }
64
+ await Promise.all(stops);
65
+ }
66
+ /** Resolve to the primary script — follow mirrorsPrimary if set. */
67
+ resolvePrimary(name) {
68
+ const proc = this.processes.get(name);
69
+ if (!proc)
70
+ return undefined;
71
+ if (proc.mirrorsPrimary) {
72
+ return this.processes.get(proc.mirrorsPrimary) ?? proc;
73
+ }
74
+ return proc;
75
+ }
76
+ /** Manually start a single script by name. */
77
+ async start(name) {
78
+ const proc = this.processes.get(name);
79
+ if (!proc) {
80
+ throw new Error(`Lifecycle script "${name}" not found`);
81
+ }
82
+ if (proc.status === 'running' || proc.status === 'starting') {
83
+ return; // already running
84
+ }
85
+ this.spawnProcess(proc);
86
+ }
87
+ /** Manually stop a single script by name. If mirroring, stops the primary. */
88
+ async stop(name) {
89
+ const primary = this.resolvePrimary(name);
90
+ if (!primary) {
91
+ throw new Error(`Lifecycle script "${name}" not found`);
92
+ }
93
+ // Clear mirror links for all scripts with the same command before stopping
94
+ const command = primary.config.command;
95
+ for (const other of this.processes.values()) {
96
+ if (other.mirrorsPrimary === primary.name) {
97
+ other.mirrorsPrimary = undefined;
98
+ other.status = 'stopped';
99
+ other.startedAt = undefined;
100
+ other.pid = undefined;
101
+ }
102
+ }
103
+ await this.stopProcess(primary);
104
+ }
105
+ /** Restart a single script by name. If mirroring, restarts the primary. */
106
+ async restart(name) {
107
+ const primary = this.resolvePrimary(name);
108
+ if (!primary) {
109
+ throw new Error(`Lifecycle script "${name}" not found`);
110
+ }
111
+ await this.stopProcess(primary);
112
+ this.spawnProcess(primary);
113
+ }
114
+ /** Return status info for all managed scripts. */
115
+ listStatus() {
116
+ const result = [];
117
+ for (const proc of this.processes.values()) {
118
+ result.push(this.toScriptInfo(proc));
119
+ }
120
+ return result;
121
+ }
122
+ /** Return status info for a single script. */
123
+ getStatus(name) {
124
+ const proc = this.processes.get(name);
125
+ if (!proc)
126
+ return undefined;
127
+ return this.toScriptInfo(proc);
128
+ }
129
+ /** Dynamically add a script at runtime. Engine parameters are filled from global config. */
130
+ addScript(script) {
131
+ if (this.processes.has(script.name)) {
132
+ return; // already exists with same name, skip silently
133
+ }
134
+ const fullScript = {
135
+ ...script,
136
+ restart: this.config.restart,
137
+ maxRestarts: this.config.maxRestarts,
138
+ restartWindowMs: this.config.restartWindowMs,
139
+ backoffInitialMs: this.config.backoffInitialMs,
140
+ backoffMaxMs: this.config.backoffMaxMs,
141
+ backoffMultiplier: this.config.backoffMultiplier,
142
+ memoryLimitMb: this.config.memoryLimitMb,
143
+ shutdownTimeoutMs: this.config.shutdownTimeoutMs,
144
+ };
145
+ this.processes.set(script.name, {
146
+ name: script.name,
147
+ config: fullScript,
148
+ childProcess: null,
149
+ status: 'stopped',
150
+ restartCount: 0,
151
+ windowStart: Date.now(),
152
+ currentBackoffMs: 0,
153
+ });
154
+ }
155
+ /**
156
+ * Sync lifecycle scripts from ProcessRegistry.
157
+ * For each Process with sources that has an event binding
158
+ * in subscriptions, auto-register LifecycleScripts.
159
+ * Uses deriveLifecycleNames() for multi-source naming.
160
+ * Skips if a script with that name already exists.
161
+ */
162
+ syncFromProcessRegistry(processes, subscriptions = []) {
163
+ for (const proc of processes) {
164
+ if (proc.sources.length === 0)
165
+ continue;
166
+ if (proc.paused)
167
+ continue;
168
+ const hasEventBinding = subscriptions.some(s => s.handler === 'process' && s.config.process === proc.name);
169
+ if (hasEventBinding) {
170
+ const names = deriveLifecycleNames(proc.name, proc.sources);
171
+ proc.sources.forEach((source, i) => {
172
+ this.addScript({
173
+ name: names[i],
174
+ command: source.command,
175
+ env: source.env,
176
+ });
177
+ });
178
+ }
179
+ }
180
+ }
181
+ /** Dynamically remove a script and stop it if running. */
182
+ async removeScript(name) {
183
+ const proc = this.processes.get(name);
184
+ if (!proc) {
185
+ throw new Error(`Lifecycle script "${name}" not found`);
186
+ }
187
+ // If this script is a primary being removed, disconnect all mirrors
188
+ for (const other of this.processes.values()) {
189
+ if (other.mirrorsPrimary === name) {
190
+ other.mirrorsPrimary = undefined;
191
+ other.status = 'stopped';
192
+ other.startedAt = undefined;
193
+ other.pid = undefined;
194
+ }
195
+ }
196
+ await this.stopProcess(proc);
197
+ this.processes.delete(name);
198
+ }
199
+ // -----------------------------------------------------------------------
200
+ // Process lifecycle
201
+ // -----------------------------------------------------------------------
202
+ spawnProcess(proc) {
203
+ if (proc.childProcess && !proc.childProcess.killed && proc.status === 'running') {
204
+ return; // already running
205
+ }
206
+ // Command dedup: if another script with the same command is already running,
207
+ // mark this as a mirror — no second process spawned.
208
+ const existingPrimary = this.commandPrimary.get(proc.config.command);
209
+ if (existingPrimary && existingPrimary !== proc.name) {
210
+ const primary = this.processes.get(existingPrimary);
211
+ if (primary && (primary.status === 'running' || primary.status === 'starting' || primary.status === 'backoff')) {
212
+ console.log(`[lifecycle] Script "${proc.name}" mirrors "${existingPrimary}" (same command: "${proc.config.command}")`);
213
+ proc.mirrorsPrimary = existingPrimary;
214
+ return;
215
+ }
216
+ }
217
+ proc.mirrorsPrimary = undefined;
218
+ proc.status = 'starting';
219
+ // Build environment
220
+ const mergedEnv = {
221
+ ...process.env,
222
+ LOOM_SERVER_URL: `http://localhost:${this.serverPort}`,
223
+ LOOM_PROJECT_ROOT: this.projectRoot,
224
+ LOOM_SCRIPT_NAME: proc.name,
225
+ };
226
+ // Merge user-configured env (user overrides take precedence)
227
+ if (proc.config.env) {
228
+ Object.assign(mergedEnv, proc.config.env);
229
+ }
230
+ const child = spawn(proc.config.command, {
231
+ shell: true,
232
+ cwd: this.projectRoot,
233
+ env: mergedEnv,
234
+ detached: true,
235
+ });
236
+ proc.childProcess = child;
237
+ // Pipe stdout/stderr with prefix
238
+ child.stdout?.on('data', (data) => {
239
+ const lines = data.toString().split('\n');
240
+ for (const line of lines) {
241
+ if (line.length > 0) {
242
+ console.log(`[lifecycle:${proc.name}] ${line}`);
243
+ }
244
+ }
245
+ });
246
+ child.stderr?.on('data', (data) => {
247
+ const lines = data.toString().split('\n');
248
+ for (const line of lines) {
249
+ if (line.length > 0) {
250
+ console.error(`[lifecycle:${proc.name}] ${line}`);
251
+ }
252
+ }
253
+ });
254
+ // Handle spawn errors
255
+ child.on('error', (err) => {
256
+ console.error(`[lifecycle:${proc.name}] spawn error: ${err.message}`);
257
+ proc.status = 'failed';
258
+ proc.lastError = err.message;
259
+ this.eventBus?.emit(`lifecycle:failed:${proc.name}`, {
260
+ name: proc.name,
261
+ error: err.message,
262
+ });
263
+ });
264
+ // Set running state once process is confirmed alive
265
+ if (child.pid) {
266
+ proc.status = 'running';
267
+ proc.startedAt = new Date().toISOString();
268
+ proc.pid = child.pid;
269
+ proc.lastError = undefined;
270
+ this.commandPrimary.set(proc.config.command, proc.name);
271
+ this.writePidFile(proc.name, child.pid);
272
+ this.eventBus?.emit(`lifecycle:started:${proc.name}`, {
273
+ name: proc.name,
274
+ pid: child.pid,
275
+ });
276
+ this.startMemoryCheck(proc);
277
+ }
278
+ else {
279
+ // For shell mode, pid may be set asynchronously
280
+ child.on('spawn', () => {
281
+ proc.status = 'running';
282
+ proc.startedAt = new Date().toISOString();
283
+ proc.pid = child.pid ?? undefined;
284
+ proc.lastError = undefined;
285
+ if (child.pid) {
286
+ this.commandPrimary.set(proc.config.command, proc.name);
287
+ this.writePidFile(proc.name, child.pid);
288
+ }
289
+ this.eventBus?.emit(`lifecycle:started:${proc.name}`, {
290
+ name: proc.name,
291
+ pid: child.pid,
292
+ });
293
+ this.startMemoryCheck(proc);
294
+ });
295
+ }
296
+ // Handle exit
297
+ child.on('exit', (code, signal) => {
298
+ this.clearTimers(proc);
299
+ this.removePidFile(proc.name);
300
+ proc.pid = undefined;
301
+ if (proc.status === 'stopping') {
302
+ // We initiated the stop — do not restart
303
+ this.markStopped(proc);
304
+ this.eventBus?.emit(`lifecycle:stopped:${proc.name}`, {
305
+ name: proc.name,
306
+ code,
307
+ signal,
308
+ });
309
+ return;
310
+ }
311
+ if (code === 0) {
312
+ // Normal exit (e.g. script finished on its own) — do not restart
313
+ this.markStopped(proc);
314
+ this.eventBus?.emit(`lifecycle:stopped:${proc.name}`, {
315
+ name: proc.name,
316
+ code,
317
+ signal,
318
+ });
319
+ }
320
+ else {
321
+ // Abnormal exit (non-zero code or killed by signal) — handle as crash (may restart)
322
+ this.handleCrash(proc, code, signal);
323
+ }
324
+ });
325
+ }
326
+ // -----------------------------------------------------------------------
327
+ // Crash handling with exponential backoff
328
+ // -----------------------------------------------------------------------
329
+ handleCrash(proc, code, signal) {
330
+ const exitReason = signal
331
+ ? `killed by signal ${signal}`
332
+ : `exited with code ${code}`;
333
+ const errorMsg = `Process ${exitReason}`;
334
+ proc.lastError = errorMsg;
335
+ proc.status = 'failed';
336
+ this.eventBus?.emit(`lifecycle:failed:${proc.name}`, {
337
+ name: proc.name,
338
+ code,
339
+ signal,
340
+ error: errorMsg,
341
+ });
342
+ const shouldRestart = proc.config.restart ?? DEFAULT_RESTART;
343
+ if (!shouldRestart) {
344
+ return;
345
+ }
346
+ // Sliding window reset
347
+ const windowMs = proc.config.restartWindowMs ?? DEFAULT_RESTART_WINDOW_MS;
348
+ if (Date.now() - proc.windowStart > windowMs) {
349
+ proc.restartCount = 0;
350
+ proc.windowStart = Date.now();
351
+ }
352
+ proc.restartCount++;
353
+ const maxRestarts = proc.config.maxRestarts ?? DEFAULT_MAX_RESTARTS;
354
+ if (proc.restartCount > maxRestarts) {
355
+ proc.status = 'failed';
356
+ this.eventBus?.emit(`lifecycle:circuit_open:${proc.name}`, {
357
+ name: proc.name,
358
+ restartCount: proc.restartCount,
359
+ maxRestarts,
360
+ });
361
+ return;
362
+ }
363
+ // Calculate exponential backoff
364
+ const initialMs = proc.config.backoffInitialMs ?? DEFAULT_BACKOFF_INITIAL_MS;
365
+ const maxMs = proc.config.backoffMaxMs ?? DEFAULT_BACKOFF_MAX_MS;
366
+ const multiplier = proc.config.backoffMultiplier ?? DEFAULT_BACKOFF_MULTIPLIER;
367
+ const backoffMs = Math.min(initialMs * Math.pow(multiplier, proc.restartCount - 1), maxMs);
368
+ proc.currentBackoffMs = backoffMs;
369
+ proc.status = 'backoff';
370
+ this.eventBus?.emit(`lifecycle:restart:${proc.name}`, {
371
+ name: proc.name,
372
+ restartCount: proc.restartCount,
373
+ backoffMs,
374
+ });
375
+ // Schedule restart after backoff
376
+ proc.backoffTimer = setTimeout(() => {
377
+ proc.backoffTimer = undefined;
378
+ this.spawnProcess(proc);
379
+ }, backoffMs);
380
+ }
381
+ // -----------------------------------------------------------------------
382
+ // Graceful stop
383
+ // -----------------------------------------------------------------------
384
+ async stopProcess(proc) {
385
+ this.clearTimers(proc);
386
+ this.removePidFile(proc.name);
387
+ if (!proc.childProcess || proc.childProcess.killed) {
388
+ this.markStopped(proc);
389
+ proc.childProcess = null;
390
+ return;
391
+ }
392
+ const wasRunning = proc.status === 'running' || proc.status === 'starting' || proc.status === 'backoff';
393
+ if (!wasRunning) {
394
+ return;
395
+ }
396
+ proc.status = 'stopping';
397
+ const shutdownMs = proc.config.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS;
398
+ return new Promise((resolve) => {
399
+ const child = proc.childProcess;
400
+ let resolved = false;
401
+ const done = () => {
402
+ if (!resolved) {
403
+ resolved = true;
404
+ this.markStopped(proc);
405
+ proc.childProcess = null;
406
+ resolve();
407
+ }
408
+ };
409
+ // Listen for exit
410
+ child.on('exit', () => {
411
+ done();
412
+ });
413
+ // Send SIGTERM to entire process group
414
+ try {
415
+ if (child.pid) {
416
+ process.kill(-child.pid, 'SIGTERM');
417
+ }
418
+ else {
419
+ child.kill('SIGTERM');
420
+ }
421
+ }
422
+ catch {
423
+ // Process may have already exited
424
+ done();
425
+ return;
426
+ }
427
+ // Force kill after timeout
428
+ const forceTimer = setTimeout(() => {
429
+ if (!resolved && !child.killed) {
430
+ try {
431
+ if (child.pid) {
432
+ process.kill(-child.pid, 'SIGKILL');
433
+ }
434
+ else {
435
+ child.kill('SIGKILL');
436
+ }
437
+ }
438
+ catch {
439
+ // already dead
440
+ }
441
+ done();
442
+ }
443
+ }, shutdownMs);
444
+ // If process exits before timeout, clean up timer
445
+ child.on('exit', () => {
446
+ clearTimeout(forceTimer);
447
+ });
448
+ });
449
+ }
450
+ // -----------------------------------------------------------------------
451
+ // Memory check
452
+ // -----------------------------------------------------------------------
453
+ startMemoryCheck(proc) {
454
+ this.clearMemoryCheck(proc);
455
+ proc.memoryCheckTimer = setInterval(() => {
456
+ this.checkMemory(proc);
457
+ }, MEMORY_CHECK_INTERVAL_MS);
458
+ }
459
+ checkMemory(proc) {
460
+ const pid = proc.pid;
461
+ if (!pid || !proc.childProcess || proc.childProcess.killed) {
462
+ return;
463
+ }
464
+ const limitMb = proc.config.memoryLimitMb ?? DEFAULT_MEMORY_LIMIT_MB;
465
+ const limitKb = limitMb * 1024;
466
+ try {
467
+ const output = execSync(`ps -o rss= -p ${pid}`, {
468
+ encoding: 'utf-8',
469
+ timeout: 3_000,
470
+ }).trim();
471
+ const rssKb = parseInt(output, 10);
472
+ if (isNaN(rssKb)) {
473
+ return;
474
+ }
475
+ if (rssKb > limitKb) {
476
+ console.error(`[lifecycle:${proc.name}] memory limit exceeded: ${Math.round(rssKb / 1024)}MB > ${limitMb}MB, killing process`);
477
+ this.eventBus?.emit(`lifecycle:memory_exceeded:${proc.name}`, {
478
+ name: proc.name,
479
+ rssMb: Math.round(rssKb / 1024),
480
+ limitMb,
481
+ });
482
+ // Mark as stopping so the exit handler doesn't treat this as a crash
483
+ proc.status = 'stopping';
484
+ // Graceful kill: SIGTERM then SIGKILL after timeout
485
+ const shutdownMs = proc.config.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS;
486
+ try {
487
+ if (proc.childProcess.pid) {
488
+ process.kill(-proc.childProcess.pid, 'SIGTERM');
489
+ }
490
+ else {
491
+ proc.childProcess.kill('SIGTERM');
492
+ }
493
+ }
494
+ catch {
495
+ // already dead
496
+ }
497
+ setTimeout(() => {
498
+ if (proc.childProcess && !proc.childProcess.killed) {
499
+ try {
500
+ if (proc.childProcess.pid) {
501
+ process.kill(-proc.childProcess.pid, 'SIGKILL');
502
+ }
503
+ else {
504
+ proc.childProcess.kill('SIGKILL');
505
+ }
506
+ }
507
+ catch {
508
+ // already dead
509
+ }
510
+ }
511
+ }, shutdownMs);
512
+ }
513
+ }
514
+ catch {
515
+ // ps command failed — process likely already exited, skip check
516
+ }
517
+ }
518
+ // -----------------------------------------------------------------------
519
+ // Helpers
520
+ // -----------------------------------------------------------------------
521
+ clearTimers(proc) {
522
+ this.clearBackoff(proc);
523
+ this.clearMemoryCheck(proc);
524
+ }
525
+ clearBackoff(proc) {
526
+ if (proc.backoffTimer) {
527
+ clearTimeout(proc.backoffTimer);
528
+ proc.backoffTimer = undefined;
529
+ }
530
+ }
531
+ clearMemoryCheck(proc) {
532
+ if (proc.memoryCheckTimer) {
533
+ clearInterval(proc.memoryCheckTimer);
534
+ proc.memoryCheckTimer = undefined;
535
+ }
536
+ }
537
+ /** Mark a process as stopped and clear start-time metadata. */
538
+ markStopped(proc) {
539
+ // Clear command primary if this was the primary
540
+ if (this.commandPrimary.get(proc.config.command) === proc.name) {
541
+ this.commandPrimary.delete(proc.config.command);
542
+ }
543
+ proc.status = 'stopped';
544
+ proc.startedAt = undefined;
545
+ proc.pid = undefined;
546
+ }
547
+ // -----------------------------------------------------------------------
548
+ // PID file management & orphan cleanup
549
+ // -----------------------------------------------------------------------
550
+ /** Write PID file so we can clean up orphans after server restart. */
551
+ async writePidFile(name, pid) {
552
+ try {
553
+ await fs.mkdir(this.pidDir, { recursive: true });
554
+ await fs.writeFile(path.join(this.pidDir, `${name}.pid`), String(pid), 'utf-8');
555
+ }
556
+ catch {
557
+ // Non-critical — best effort
558
+ }
559
+ }
560
+ /** Remove PID file on clean stop/exit. */
561
+ async removePidFile(name) {
562
+ try {
563
+ await fs.unlink(path.join(this.pidDir, `${name}.pid`)).catch(() => { });
564
+ }
565
+ catch {
566
+ // Non-critical
567
+ }
568
+ }
569
+ /**
570
+ * Kill orphan processes from a previous server run.
571
+ * Reads PID files from .loom/.pids/, verifies the process still exists,
572
+ * and kills the entire process group before spawning new ones.
573
+ */
574
+ async cleanOrphanProcesses() {
575
+ try {
576
+ const entries = await fs.readdir(this.pidDir).catch(() => []);
577
+ const pidFiles = entries.filter(f => f.endsWith('.pid'));
578
+ for (const pidFile of pidFiles) {
579
+ const filePath = path.join(this.pidDir, pidFile);
580
+ try {
581
+ const pidStr = await fs.readFile(filePath, 'utf-8');
582
+ const pid = parseInt(pidStr.trim(), 10);
583
+ if (isNaN(pid)) {
584
+ await fs.unlink(filePath).catch(() => { });
585
+ continue;
586
+ }
587
+ // Check if the process still exists
588
+ try {
589
+ process.kill(pid, 0); // signal 0 = existence check
590
+ }
591
+ catch {
592
+ // Process doesn't exist anymore — just clean up the PID file
593
+ await fs.unlink(filePath).catch(() => { });
594
+ continue;
595
+ }
596
+ // Process is still alive — kill the entire process group
597
+ console.log(`[lifecycle] Cleaning up orphan process: ${pidFile.replace('.pid', '')} (PID ${pid}, PGID ${pid})`);
598
+ try {
599
+ process.kill(-pid, 'SIGTERM');
600
+ }
601
+ catch {
602
+ // Process group may not exist, try killing just the process
603
+ try {
604
+ process.kill(pid, 'SIGTERM');
605
+ }
606
+ catch {
607
+ // Already dead
608
+ }
609
+ }
610
+ // Give it a moment, then force kill if still alive
611
+ await new Promise((resolve) => {
612
+ const forceTimer = setTimeout(() => {
613
+ try {
614
+ process.kill(-pid, 'SIGKILL');
615
+ }
616
+ catch { /* already dead */ }
617
+ try {
618
+ process.kill(pid, 'SIGKILL');
619
+ }
620
+ catch { /* already dead */ }
621
+ resolve();
622
+ }, 3_000);
623
+ // Poll for process exit
624
+ const checkInterval = setInterval(() => {
625
+ try {
626
+ process.kill(pid, 0);
627
+ }
628
+ catch {
629
+ // Process is gone
630
+ clearInterval(checkInterval);
631
+ clearTimeout(forceTimer);
632
+ resolve();
633
+ }
634
+ }, 200);
635
+ });
636
+ await fs.unlink(filePath).catch(() => { });
637
+ }
638
+ catch (err) {
639
+ console.error(`[lifecycle] Error cleaning up orphan ${pidFile}:`, err instanceof Error ? err.message : String(err));
640
+ }
641
+ }
642
+ if (pidFiles.length > 0) {
643
+ // Ensure PID directory exists for new runs
644
+ await fs.mkdir(this.pidDir, { recursive: true });
645
+ }
646
+ }
647
+ catch {
648
+ // Non-critical — best effort
649
+ }
650
+ }
651
+ toScriptInfo(proc) {
652
+ // If mirroring another script, return the primary's runtime status
653
+ if (proc.mirrorsPrimary) {
654
+ const primary = this.processes.get(proc.mirrorsPrimary);
655
+ if (primary) {
656
+ return {
657
+ name: proc.name,
658
+ command: proc.config.command,
659
+ status: primary.status,
660
+ pid: primary.pid,
661
+ restartCount: primary.restartCount,
662
+ currentBackoffMs: primary.currentBackoffMs,
663
+ lastError: primary.lastError,
664
+ startedAt: primary.startedAt,
665
+ enabled: proc.config.enabled ?? DEFAULT_ENABLED,
666
+ };
667
+ }
668
+ // Primary gone — clear mirror and return stopped
669
+ proc.mirrorsPrimary = undefined;
670
+ }
671
+ return {
672
+ name: proc.name,
673
+ command: proc.config.command,
674
+ status: proc.status,
675
+ pid: proc.pid,
676
+ restartCount: proc.restartCount,
677
+ currentBackoffMs: proc.currentBackoffMs,
678
+ lastError: proc.lastError,
679
+ startedAt: proc.startedAt,
680
+ enabled: proc.config.enabled ?? DEFAULT_ENABLED,
681
+ };
682
+ }
683
+ }
684
+ //# sourceMappingURL=manager.js.map