@rudderhq/server 0.2.5-canary.8 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/dist/bootstrap/plugin-host-runtime.d.ts +39 -39
  2. package/dist/bundled-plugins/plugin-linear/dist/worker.js +101 -147
  3. package/dist/bundled-plugins/plugin-linear/dist/worker.js.map +2 -2
  4. package/dist/bundled-plugins/plugin-linear/package.json +1 -1
  5. package/dist/routes/access-onboarding.helpers.d.ts +142 -0
  6. package/dist/routes/access-onboarding.helpers.d.ts.map +1 -0
  7. package/dist/routes/access-onboarding.helpers.js +762 -0
  8. package/dist/routes/access-onboarding.helpers.js.map +1 -0
  9. package/dist/routes/access.d.ts +2 -48
  10. package/dist/routes/access.d.ts.map +1 -1
  11. package/dist/routes/access.helpers.d.ts +109 -0
  12. package/dist/routes/access.helpers.d.ts.map +1 -0
  13. package/dist/routes/access.helpers.js +460 -0
  14. package/dist/routes/access.helpers.js.map +1 -0
  15. package/dist/routes/access.js +6 -1218
  16. package/dist/routes/access.js.map +1 -1
  17. package/dist/routes/agents.d.ts.map +1 -1
  18. package/dist/routes/agents.js +55 -1057
  19. package/dist/routes/agents.js.map +1 -1
  20. package/dist/routes/agents.management-routes.d.ts +12 -0
  21. package/dist/routes/agents.management-routes.d.ts.map +1 -0
  22. package/dist/routes/agents.management-routes.js +1067 -0
  23. package/dist/routes/agents.management-routes.js.map +1 -0
  24. package/dist/routes/chats.d.ts.map +1 -1
  25. package/dist/routes/chats.js +42 -652
  26. package/dist/routes/chats.js.map +1 -1
  27. package/dist/routes/chats.stream-routes.d.ts +12 -0
  28. package/dist/routes/chats.stream-routes.d.ts.map +1 -0
  29. package/dist/routes/chats.stream-routes.js +666 -0
  30. package/dist/routes/chats.stream-routes.js.map +1 -0
  31. package/dist/routes/issues.comments-attachments.d.ts +12 -0
  32. package/dist/routes/issues.comments-attachments.d.ts.map +1 -0
  33. package/dist/routes/issues.comments-attachments.js +511 -0
  34. package/dist/routes/issues.comments-attachments.js.map +1 -0
  35. package/dist/routes/issues.d.ts.map +1 -1
  36. package/dist/routes/issues.js +43 -1128
  37. package/dist/routes/issues.js.map +1 -1
  38. package/dist/routes/issues.mutations.d.ts +12 -0
  39. package/dist/routes/issues.mutations.d.ts.map +1 -0
  40. package/dist/routes/issues.mutations.js +635 -0
  41. package/dist/routes/issues.mutations.js.map +1 -0
  42. package/dist/routes/plugins.d.ts.map +1 -1
  43. package/dist/routes/plugins.js +14 -694
  44. package/dist/routes/plugins.js.map +1 -1
  45. package/dist/routes/plugins.operations-routes.d.ts +28 -0
  46. package/dist/routes/plugins.operations-routes.d.ts.map +1 -0
  47. package/dist/routes/plugins.operations-routes.js +720 -0
  48. package/dist/routes/plugins.operations-routes.js.map +1 -0
  49. package/dist/services/access.d.ts +21 -21
  50. package/dist/services/activity.d.ts +19 -19
  51. package/dist/services/agents.d.ts +158 -158
  52. package/dist/services/approvals.d.ts +29 -29
  53. package/dist/services/assets.d.ts +8 -8
  54. package/dist/services/automations.d.ts +41 -27
  55. package/dist/services/automations.d.ts.map +1 -1
  56. package/dist/services/automations.js +287 -110
  57. package/dist/services/automations.js.map +1 -1
  58. package/dist/services/automations.scheduler.d.ts +9 -0
  59. package/dist/services/automations.scheduler.d.ts.map +1 -0
  60. package/dist/services/automations.scheduler.js +101 -0
  61. package/dist/services/automations.scheduler.js.map +1 -0
  62. package/dist/services/board-auth.d.ts +32 -32
  63. package/dist/services/calendar.d.ts +26 -26
  64. package/dist/services/chat-assistant.d.ts +3 -47
  65. package/dist/services/chat-assistant.d.ts.map +1 -1
  66. package/dist/services/chat-assistant.helpers.d.ts +156 -0
  67. package/dist/services/chat-assistant.helpers.d.ts.map +1 -0
  68. package/dist/services/chat-assistant.helpers.js +862 -0
  69. package/dist/services/chat-assistant.helpers.js.map +1 -0
  70. package/dist/services/chat-assistant.js +2 -861
  71. package/dist/services/chat-assistant.js.map +1 -1
  72. package/dist/services/chats.d.ts +149 -247
  73. package/dist/services/chats.d.ts.map +1 -1
  74. package/dist/services/chats.helpers.d.ts +117 -0
  75. package/dist/services/chats.helpers.d.ts.map +1 -0
  76. package/dist/services/chats.helpers.js +285 -0
  77. package/dist/services/chats.helpers.js.map +1 -0
  78. package/dist/services/chats.js +6 -286
  79. package/dist/services/chats.js.map +1 -1
  80. package/dist/services/costs.d.ts +8 -8
  81. package/dist/services/finance.d.ts +18 -18
  82. package/dist/services/goals.d.ts +30 -30
  83. package/dist/services/heartbeat.d.ts +3 -1
  84. package/dist/services/heartbeat.d.ts.map +1 -1
  85. package/dist/services/heartbeat.js +3 -1
  86. package/dist/services/heartbeat.js.map +1 -1
  87. package/dist/services/issue-approvals.d.ts +4 -4
  88. package/dist/services/issue-review-wakeup.d.ts +3 -3
  89. package/dist/services/issues.comments-attachments.d.ts +141 -0
  90. package/dist/services/issues.comments-attachments.d.ts.map +1 -0
  91. package/dist/services/issues.comments-attachments.js +313 -0
  92. package/dist/services/issues.comments-attachments.js.map +1 -0
  93. package/dist/services/issues.d.ts +205 -256
  94. package/dist/services/issues.d.ts.map +1 -1
  95. package/dist/services/issues.helpers.d.ts +87 -0
  96. package/dist/services/issues.helpers.d.ts.map +1 -0
  97. package/dist/services/issues.helpers.js +270 -0
  98. package/dist/services/issues.helpers.js.map +1 -0
  99. package/dist/services/issues.js +5 -569
  100. package/dist/services/issues.js.map +1 -1
  101. package/dist/services/knowledge-portability/organization-portability.core.d.ts +210 -0
  102. package/dist/services/knowledge-portability/organization-portability.core.d.ts.map +1 -0
  103. package/dist/services/knowledge-portability/organization-portability.core.js +997 -0
  104. package/dist/services/knowledge-portability/organization-portability.core.js.map +1 -0
  105. package/dist/services/knowledge-portability/organization-portability.d.ts +6 -28
  106. package/dist/services/knowledge-portability/organization-portability.d.ts.map +1 -1
  107. package/dist/services/knowledge-portability/organization-portability.export.d.ts +24 -0
  108. package/dist/services/knowledge-portability/organization-portability.export.d.ts.map +1 -0
  109. package/dist/services/knowledge-portability/organization-portability.export.js +607 -0
  110. package/dist/services/knowledge-portability/organization-portability.export.js.map +1 -0
  111. package/dist/services/knowledge-portability/organization-portability.files.d.ts +69 -0
  112. package/dist/services/knowledge-portability/organization-portability.files.d.ts.map +1 -0
  113. package/dist/services/knowledge-portability/organization-portability.files.js +597 -0
  114. package/dist/services/knowledge-portability/organization-portability.files.js.map +1 -0
  115. package/dist/services/knowledge-portability/organization-portability.import.d.ts +31 -0
  116. package/dist/services/knowledge-portability/organization-portability.import.d.ts.map +1 -0
  117. package/dist/services/knowledge-portability/organization-portability.import.js +575 -0
  118. package/dist/services/knowledge-portability/organization-portability.import.js.map +1 -0
  119. package/dist/services/knowledge-portability/organization-portability.js +37 -3848
  120. package/dist/services/knowledge-portability/organization-portability.js.map +1 -1
  121. package/dist/services/knowledge-portability/organization-portability.package.d.ts +72 -0
  122. package/dist/services/knowledge-portability/organization-portability.package.d.ts.map +1 -0
  123. package/dist/services/knowledge-portability/organization-portability.package.js +749 -0
  124. package/dist/services/knowledge-portability/organization-portability.package.js.map +1 -0
  125. package/dist/services/knowledge-portability/organization-portability.preview.d.ts +18 -0
  126. package/dist/services/knowledge-portability/organization-portability.preview.d.ts.map +1 -0
  127. package/dist/services/knowledge-portability/organization-portability.preview.js +333 -0
  128. package/dist/services/knowledge-portability/organization-portability.preview.js.map +1 -0
  129. package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts +4 -0
  130. package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts.map +1 -0
  131. package/dist/services/knowledge-portability/organization-portability.resolve-source.js +86 -0
  132. package/dist/services/knowledge-portability/organization-portability.resolve-source.js.map +1 -0
  133. package/dist/services/knowledge-portability/organization-skills.catalog.d.ts +221 -0
  134. package/dist/services/knowledge-portability/organization-skills.catalog.d.ts.map +1 -0
  135. package/dist/services/knowledge-portability/organization-skills.catalog.js +999 -0
  136. package/dist/services/knowledge-portability/organization-skills.catalog.js.map +1 -0
  137. package/dist/services/knowledge-portability/organization-skills.d.ts +4 -75
  138. package/dist/services/knowledge-portability/organization-skills.d.ts.map +1 -1
  139. package/dist/services/knowledge-portability/organization-skills.js +11 -2008
  140. package/dist/services/knowledge-portability/organization-skills.js.map +1 -1
  141. package/dist/services/knowledge-portability/organization-skills.scans.d.ts +16 -0
  142. package/dist/services/knowledge-portability/organization-skills.scans.d.ts.map +1 -0
  143. package/dist/services/knowledge-portability/organization-skills.scans.js +300 -0
  144. package/dist/services/knowledge-portability/organization-skills.scans.js.map +1 -0
  145. package/dist/services/knowledge-portability/organization-skills.sources.d.ts +68 -0
  146. package/dist/services/knowledge-portability/organization-skills.sources.d.ts.map +1 -0
  147. package/dist/services/knowledge-portability/organization-skills.sources.js +728 -0
  148. package/dist/services/knowledge-portability/organization-skills.sources.js.map +1 -0
  149. package/dist/services/messenger.d.ts +2 -2
  150. package/dist/services/messenger.js +2 -2
  151. package/dist/services/messenger.js.map +1 -1
  152. package/dist/services/organization-skills.d.ts +3 -1
  153. package/dist/services/organization-skills.d.ts.map +1 -1
  154. package/dist/services/organization-skills.js +3 -1
  155. package/dist/services/organization-skills.js.map +1 -1
  156. package/dist/services/orgs.d.ts +9 -9
  157. package/dist/services/plugin-loader.core.d.ts +14 -0
  158. package/dist/services/plugin-loader.core.d.ts.map +1 -0
  159. package/dist/services/plugin-loader.core.js +905 -0
  160. package/dist/services/plugin-loader.core.js.map +1 -0
  161. package/dist/services/plugin-loader.d.ts +3 -440
  162. package/dist/services/plugin-loader.d.ts.map +1 -1
  163. package/dist/services/plugin-loader.helpers.d.ts +468 -0
  164. package/dist/services/plugin-loader.helpers.d.ts.map +1 -0
  165. package/dist/services/plugin-loader.helpers.js +263 -0
  166. package/dist/services/plugin-loader.helpers.js.map +1 -0
  167. package/dist/services/plugin-loader.js +3 -1191
  168. package/dist/services/plugin-loader.js.map +1 -1
  169. package/dist/services/plugin-loader.worker-paths.d.ts +7 -0
  170. package/dist/services/plugin-loader.worker-paths.d.ts.map +1 -0
  171. package/dist/services/plugin-loader.worker-paths.js +85 -0
  172. package/dist/services/plugin-loader.worker-paths.js.map +1 -0
  173. package/dist/services/plugin-registry.d.ts +123 -123
  174. package/dist/services/projects.d.ts +8 -8
  175. package/dist/services/runtime-kernel/heartbeat.core.d.ts +725 -0
  176. package/dist/services/runtime-kernel/heartbeat.core.d.ts.map +1 -0
  177. package/dist/services/runtime-kernel/heartbeat.core.js +525 -0
  178. package/dist/services/runtime-kernel/heartbeat.core.js.map +1 -0
  179. package/dist/services/runtime-kernel/heartbeat.d.ts +38 -259
  180. package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -1
  181. package/dist/services/runtime-kernel/heartbeat.execute.d.ts +5 -0
  182. package/dist/services/runtime-kernel/heartbeat.execute.d.ts.map +1 -0
  183. package/dist/services/runtime-kernel/heartbeat.execute.js +1052 -0
  184. package/dist/services/runtime-kernel/heartbeat.execute.js.map +1 -0
  185. package/dist/services/runtime-kernel/heartbeat.js +50 -4142
  186. package/dist/services/runtime-kernel/heartbeat.js.map +1 -1
  187. package/dist/services/runtime-kernel/heartbeat.misc.d.ts +30 -0
  188. package/dist/services/runtime-kernel/heartbeat.misc.d.ts.map +1 -0
  189. package/dist/services/runtime-kernel/heartbeat.misc.js +483 -0
  190. package/dist/services/runtime-kernel/heartbeat.misc.js.map +1 -0
  191. package/dist/services/runtime-kernel/heartbeat.recovery.d.ts +38 -0
  192. package/dist/services/runtime-kernel/heartbeat.recovery.d.ts.map +1 -0
  193. package/dist/services/runtime-kernel/heartbeat.recovery.js +605 -0
  194. package/dist/services/runtime-kernel/heartbeat.recovery.js.map +1 -0
  195. package/dist/services/runtime-kernel/heartbeat.release.d.ts +6 -0
  196. package/dist/services/runtime-kernel/heartbeat.release.d.ts.map +1 -0
  197. package/dist/services/runtime-kernel/heartbeat.release.js +398 -0
  198. package/dist/services/runtime-kernel/heartbeat.release.js.map +1 -0
  199. package/dist/services/runtime-kernel/heartbeat.sessions.d.ts +229 -0
  200. package/dist/services/runtime-kernel/heartbeat.sessions.d.ts.map +1 -0
  201. package/dist/services/runtime-kernel/heartbeat.sessions.js +708 -0
  202. package/dist/services/runtime-kernel/heartbeat.sessions.js.map +1 -0
  203. package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts +5 -0
  204. package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts.map +1 -0
  205. package/dist/services/runtime-kernel/heartbeat.wakeup.js +552 -0
  206. package/dist/services/runtime-kernel/heartbeat.wakeup.js.map +1 -0
  207. package/dist/services/secrets.d.ts +25 -25
  208. package/dist/services/sidebar-badges.js +1 -1
  209. package/dist/services/sidebar-badges.js.map +1 -1
  210. package/dist/services/workspace-runtime.comments.d.ts +6 -0
  211. package/dist/services/workspace-runtime.comments.d.ts.map +1 -0
  212. package/dist/services/workspace-runtime.comments.js +17 -0
  213. package/dist/services/workspace-runtime.comments.js.map +1 -0
  214. package/dist/services/workspace-runtime.d.ts +4 -163
  215. package/dist/services/workspace-runtime.d.ts.map +1 -1
  216. package/dist/services/workspace-runtime.helpers.d.ts +163 -0
  217. package/dist/services/workspace-runtime.helpers.d.ts.map +1 -0
  218. package/dist/services/workspace-runtime.helpers.js +360 -0
  219. package/dist/services/workspace-runtime.helpers.js.map +1 -0
  220. package/dist/services/workspace-runtime.js +4 -1236
  221. package/dist/services/workspace-runtime.js.map +1 -1
  222. package/dist/services/workspace-runtime.lifecycle.d.ts +35 -0
  223. package/dist/services/workspace-runtime.lifecycle.d.ts.map +1 -0
  224. package/dist/services/workspace-runtime.lifecycle.js +266 -0
  225. package/dist/services/workspace-runtime.lifecycle.js.map +1 -0
  226. package/dist/services/workspace-runtime.services.d.ts +140 -0
  227. package/dist/services/workspace-runtime.services.d.ts.map +1 -0
  228. package/dist/services/workspace-runtime.services.js +606 -0
  229. package/dist/services/workspace-runtime.services.js.map +1 -0
  230. package/package.json +21 -15
  231. package/ui-dist/assets/{_basePickBy-DeCw-kw3.js → _basePickBy-N8I9ml5Y.js} +1 -1
  232. package/ui-dist/assets/{_baseUniq-CVepsVZm.js → _baseUniq-BuSlpRSQ.js} +1 -1
  233. package/ui-dist/assets/{arc-QifRrkx2.js → arc-qX-dPyA1.js} +1 -1
  234. package/ui-dist/assets/{architectureDiagram-2XIMDMQ5-CT4me0hw.js → architectureDiagram-2XIMDMQ5-DhjkbXsp.js} +1 -1
  235. package/ui-dist/assets/{blockDiagram-WCTKOSBZ-uD6J91MI.js → blockDiagram-WCTKOSBZ-JS-tTu3J.js} +1 -1
  236. package/ui-dist/assets/{c4Diagram-IC4MRINW-D2GM2pzG.js → c4Diagram-IC4MRINW-4DqwCWIx.js} +1 -1
  237. package/ui-dist/assets/channel-CccCW5_a.js +1 -0
  238. package/ui-dist/assets/{chunk-4BX2VUAB-D8pPrlss.js → chunk-4BX2VUAB-T37SqBpp.js} +1 -1
  239. package/ui-dist/assets/{chunk-55IACEB6-CHF68vwj.js → chunk-55IACEB6-BSj9hdqK.js} +1 -1
  240. package/ui-dist/assets/{chunk-FMBD7UC4-CKmGUf9X.js → chunk-FMBD7UC4-Dkrlh0Wk.js} +1 -1
  241. package/ui-dist/assets/{chunk-JSJVCQXG-CTBCV-7X.js → chunk-JSJVCQXG-C0ZE3QdB.js} +1 -1
  242. package/ui-dist/assets/{chunk-KX2RTZJC-DV5XzGob.js → chunk-KX2RTZJC-DOZQM9gW.js} +1 -1
  243. package/ui-dist/assets/{chunk-NQ4KR5QH-B7diT0e4.js → chunk-NQ4KR5QH-5Yr3U2k8.js} +1 -1
  244. package/ui-dist/assets/{chunk-QZHKN3VN-BphcSb1i.js → chunk-QZHKN3VN-CvKTufwF.js} +1 -1
  245. package/ui-dist/assets/{chunk-WL4C6EOR-Bs_jQBMG.js → chunk-WL4C6EOR-IoEM0jyx.js} +1 -1
  246. package/ui-dist/assets/classDiagram-VBA2DB6C-JKk4tCW2.js +1 -0
  247. package/ui-dist/assets/classDiagram-v2-RAHNMMFH-JKk4tCW2.js +1 -0
  248. package/ui-dist/assets/clone-Onaweg8D.js +1 -0
  249. package/ui-dist/assets/{cose-bilkent-S5V4N54A-BxfO0pV9.js → cose-bilkent-S5V4N54A-CTvr1OFj.js} +1 -1
  250. package/ui-dist/assets/{dagre-KLK3FWXG-BiDkAX-Z.js → dagre-KLK3FWXG-UZ-SNjVK.js} +1 -1
  251. package/ui-dist/assets/{diagram-E7M64L7V-Btz_oxkC.js → diagram-E7M64L7V-D7RAN0Hr.js} +1 -1
  252. package/ui-dist/assets/{diagram-IFDJBPK2-Cdp8lQxJ.js → diagram-IFDJBPK2-B4LViaFR.js} +1 -1
  253. package/ui-dist/assets/{diagram-P4PSJMXO-DuTbeAS1.js → diagram-P4PSJMXO-CY1be7ak.js} +1 -1
  254. package/ui-dist/assets/{erDiagram-INFDFZHY-CzoQlOwo.js → erDiagram-INFDFZHY-Dca0KkvJ.js} +1 -1
  255. package/ui-dist/assets/{flowDiagram-PKNHOUZH-Diz_MWi3.js → flowDiagram-PKNHOUZH-i-qMvfwg.js} +1 -1
  256. package/ui-dist/assets/{ganttDiagram-A5KZAMGK-CWeGI1E-.js → ganttDiagram-A5KZAMGK-Wxq2lhbh.js} +1 -1
  257. package/ui-dist/assets/{gitGraphDiagram-K3NZZRJ6-C3QhZnAN.js → gitGraphDiagram-K3NZZRJ6-DwzgPlAY.js} +1 -1
  258. package/ui-dist/assets/{graph-KQH4eaLv.js → graph-BAqf89Tz.js} +1 -1
  259. package/ui-dist/assets/{index-CkEEsJ_9.js → index-4eCzaLuY.js} +1 -1
  260. package/ui-dist/assets/{index-DCOA92Vt.js → index-8uu-nKqK.js} +1 -1
  261. package/ui-dist/assets/{index-DtsZnqcf.js → index-B-1NEcI_.js} +1 -1
  262. package/ui-dist/assets/{index-BvGpil9e.js → index-B0b_3Eu5.js} +1 -1
  263. package/ui-dist/assets/{index-BMhxh9sB.js → index-B8v0eZjP.js} +1 -1
  264. package/ui-dist/assets/{index-aKvEm2pJ.js → index-BN7Moj3u.js} +1 -1
  265. package/ui-dist/assets/{index-iJyjaIGd.js → index-BSpxh3cY.js} +1 -1
  266. package/ui-dist/assets/{index-DhRKQjzu.js → index-BY44RIi9.js} +1 -1
  267. package/ui-dist/assets/{index-Z4rTzdcL.js → index-BhyQJhdZ.js} +1 -1
  268. package/ui-dist/assets/{index-DBxBUiZC.js → index-BkPL_iGU.js} +1 -1
  269. package/ui-dist/assets/{index-CsSppW5U.js → index-BsPfoHXS.js} +1 -1
  270. package/ui-dist/assets/{index-B8J1oewY.js → index-BstW7nmv.js} +1 -1
  271. package/ui-dist/assets/{index-CVZYu_kq.js → index-BwB67Zyz.js} +1 -1
  272. package/ui-dist/assets/index-C2peSkmT.css +1 -0
  273. package/ui-dist/assets/{index-Djz3PL1M.js → index-C3ktOsS_.js} +1 -1
  274. package/ui-dist/assets/{index-BMZfWLwr.js → index-CMyABlS-.js} +1 -1
  275. package/ui-dist/assets/{index-Cqdw7Lnc.js → index-CyBJ8ujC.js} +1 -1
  276. package/ui-dist/assets/{index-Ctp_0y5X.js → index-DAxM2W3O.js} +1 -1
  277. package/ui-dist/assets/{index-_jGthZ-1.js → index-DVZXPmhk.js} +1 -1
  278. package/ui-dist/assets/{index-CBLnbZVL.js → index-Dc19uAyw.js} +1 -1
  279. package/ui-dist/assets/index-DzHrwZu1.js +1511 -0
  280. package/ui-dist/assets/{index-ChTjk1gO.js → index-LJuf53Ye.js} +1 -1
  281. package/ui-dist/assets/{index-wXEAD8rI.js → index-Ugw5VWWz.js} +1 -1
  282. package/ui-dist/assets/{index-ciyPUpT9.js → index-YGraEFR7.js} +1 -1
  283. package/ui-dist/assets/{infoDiagram-LFFYTUFH-DbMzKsuw.js → infoDiagram-LFFYTUFH-jLmDtFVR.js} +1 -1
  284. package/ui-dist/assets/{ishikawaDiagram-PHBUUO56-CcKXcf2V.js → ishikawaDiagram-PHBUUO56-6OGMyLT8.js} +1 -1
  285. package/ui-dist/assets/{journeyDiagram-4ABVD52K-BY2GuHyR.js → journeyDiagram-4ABVD52K-yQjl6E0t.js} +1 -1
  286. package/ui-dist/assets/{kanban-definition-K7BYSVSG-BlZWM0Uz.js → kanban-definition-K7BYSVSG-DkdCeQlS.js} +1 -1
  287. package/ui-dist/assets/{layout-qHGAYgRY.js → layout-CqSYvZ_w.js} +1 -1
  288. package/ui-dist/assets/{linear-BigkGXbh.js → linear-B8xGZaoi.js} +1 -1
  289. package/ui-dist/assets/{mermaid.core-DZ099nW4.js → mermaid.core-AKL_cdyk.js} +4 -4
  290. package/ui-dist/assets/{mindmap-definition-YRQLILUH-CElDqDe0.js → mindmap-definition-YRQLILUH-Zr-dXC0x.js} +1 -1
  291. package/ui-dist/assets/{pieDiagram-SKSYHLDU-I2LDYrgm.js → pieDiagram-SKSYHLDU-BvDAU-Nk.js} +1 -1
  292. package/ui-dist/assets/{quadrantDiagram-337W2JSQ-D-U35edU.js → quadrantDiagram-337W2JSQ-Dn9kM62o.js} +1 -1
  293. package/ui-dist/assets/{requirementDiagram-Z7DCOOCP-FAWtaOKe.js → requirementDiagram-Z7DCOOCP-GIsIh7Sd.js} +1 -1
  294. package/ui-dist/assets/{sankeyDiagram-WA2Y5GQK-CzFHHNNh.js → sankeyDiagram-WA2Y5GQK-CUCuBkuf.js} +1 -1
  295. package/ui-dist/assets/{sequenceDiagram-2WXFIKYE-Cy-UViPL.js → sequenceDiagram-2WXFIKYE-MDpUY2HM.js} +1 -1
  296. package/ui-dist/assets/{stateDiagram-RAJIS63D-BEdt3CLl.js → stateDiagram-RAJIS63D-BymMpuUU.js} +1 -1
  297. package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-Bi2oCU6d.js +1 -0
  298. package/ui-dist/assets/{timeline-definition-YZTLITO2-YD1e-WHS.js → timeline-definition-YZTLITO2-B6ofPhhy.js} +1 -1
  299. package/ui-dist/assets/{treemap-KZPCXAKY-BnqlVkAC.js → treemap-KZPCXAKY-DnLO6w1l.js} +1 -1
  300. package/ui-dist/assets/{vennDiagram-LZ73GAT5-f4WCy3o6.js → vennDiagram-LZ73GAT5-D0MyZIDl.js} +1 -1
  301. package/ui-dist/assets/{xychartDiagram-JWTSCODW-CWA35znA.js → xychartDiagram-JWTSCODW-rADY1iUG.js} +1 -1
  302. package/ui-dist/index.html +2 -2
  303. package/ui-dist/assets/channel-BV7st2TW.js +0 -1
  304. package/ui-dist/assets/classDiagram-VBA2DB6C-Cw_xj5ie.js +0 -1
  305. package/ui-dist/assets/classDiagram-v2-RAHNMMFH-Cw_xj5ie.js +0 -1
  306. package/ui-dist/assets/clone-DGshofUt.js +0 -1
  307. package/ui-dist/assets/index-Ded0dPwB.css +0 -1
  308. package/ui-dist/assets/index-Jhxth516.js +0 -1510
  309. package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-cW7aES_v.js +0 -1
@@ -0,0 +1,905 @@
1
+ /**
2
+ * PluginLoader — discovery, installation, and runtime activation of plugins.
3
+ *
4
+ * This service is the entry point for the plugin system's I/O boundary:
5
+ *
6
+ * 1. **Discovery** — Scans the local plugin directory
7
+ * (`~/.rudder/plugins/`) and `node_modules` for packages matching
8
+ * the `rudder-plugin-*` naming convention. Aggregates results with
9
+ * path-based deduplication.
10
+ *
11
+ * 2. **Installation** — `installPlugin()` downloads from npm (or reads a
12
+ * local path), validates the manifest, checks capability consistency,
13
+ * and persists the install record.
14
+ *
15
+ * 3. **Runtime activation** — `activatePlugin()` wires up a loaded plugin
16
+ * with all runtime services: resolves its entrypoint, builds
17
+ * capability-gated host handlers, spawns a worker process, syncs job
18
+ * declarations, registers event subscriptions, and discovers tools.
19
+ *
20
+ * 4. **Shutdown** — `shutdownAll()` gracefully stops all active workers
21
+ * and unregisters runtime hooks.
22
+ *
23
+ * @see PLUGIN_SPEC.md §8 — Plugin Discovery
24
+ * @see PLUGIN_SPEC.md §10 — Package Contract
25
+ * @see PLUGIN_SPEC.md §12 — Process Model
26
+ */
27
+ import { existsSync } from "node:fs";
28
+ import { readdir, rm, stat } from "node:fs/promises";
29
+ import path from "node:path";
30
+ import { logger } from "../middleware/logger.js";
31
+ import { pluginManifestValidator } from "./plugin-manifest-validator.js";
32
+ import { pluginCapabilityValidator } from "./plugin-capability-validator.js";
33
+ import { pluginRegistryService } from "./plugin-registry.js";
34
+ import { execFileAsync, DEFAULT_LOCAL_PLUGIN_DIR, DEV_TSX_LOADER_PATH, getDeclaredPageRoutePaths, isPluginPackageName, readPackageJson, resolveManifestPath, compareSemver, getMinimumHostVersion } from "./plugin-loader.helpers.js";
35
+ import { resolveWorkerEntrypoint, resolveManagedInstallPackageDir, isPathInsideDir } from "./plugin-loader.worker-paths.js";
36
+ export function pluginLoader(db, options = {}, runtimeServices) {
37
+ const { localPluginDir = DEFAULT_LOCAL_PLUGIN_DIR, enableLocalFilesystem = true, enableNpmDiscovery = true, } = options;
38
+ const registry = pluginRegistryService(db);
39
+ const manifestValidator = pluginManifestValidator();
40
+ const capabilityValidator = pluginCapabilityValidator();
41
+ const log = logger.child({ service: "plugin-loader" });
42
+ const hostVersion = runtimeServices?.instanceInfo.hostVersion;
43
+ async function assertPageRoutePathsAvailable(manifest) {
44
+ const requestedRoutePaths = getDeclaredPageRoutePaths(manifest);
45
+ if (requestedRoutePaths.length === 0)
46
+ return;
47
+ const uniqueRequested = new Set(requestedRoutePaths);
48
+ if (uniqueRequested.size !== requestedRoutePaths.length) {
49
+ throw new Error(`Plugin ${manifest.id} declares duplicate page routePath values`);
50
+ }
51
+ const installedPlugins = await registry.listInstalled();
52
+ for (const plugin of installedPlugins) {
53
+ if (plugin.pluginKey === manifest.id)
54
+ continue;
55
+ const installedManifest = plugin.manifestJson;
56
+ if (!installedManifest)
57
+ continue;
58
+ const installedRoutePaths = new Set(getDeclaredPageRoutePaths(installedManifest));
59
+ const conflictingRoute = requestedRoutePaths.find((routePath) => installedRoutePaths.has(routePath));
60
+ if (conflictingRoute) {
61
+ throw new Error(`Plugin ${manifest.id} routePath "${conflictingRoute}" conflicts with installed plugin ${plugin.pluginKey}`);
62
+ }
63
+ }
64
+ }
65
+ // -------------------------------------------------------------------------
66
+ // Internal helpers
67
+ // -------------------------------------------------------------------------
68
+ /**
69
+ * Fetch a plugin from npm or local path, then parse and validate its manifest.
70
+ *
71
+ * This internal helper encapsulates the core plugin retrieval and validation
72
+ * logic used by both install and upgrade operations. It handles:
73
+ * 1. Resolving the package from npm or local filesystem.
74
+ * 2. Installing the package via npm if necessary.
75
+ * 3. Reading and parsing the plugin manifest.
76
+ * 4. Validating API version compatibility.
77
+ * 5. Validating manifest capabilities.
78
+ *
79
+ * @param installOptions - Options specifying the package to fetch.
80
+ * @returns A `DiscoveredPlugin` object containing the validated manifest.
81
+ */
82
+ async function fetchAndValidate(installOptions) {
83
+ const { packageName, localPath, version, installDir } = installOptions;
84
+ if (!packageName && !localPath) {
85
+ throw new Error("Either packageName or localPath must be provided");
86
+ }
87
+ const targetInstallDir = installDir ?? localPluginDir;
88
+ // Step 1 & 2: Resolve and install package
89
+ let resolvedPackagePath;
90
+ let resolvedPackageName;
91
+ if (localPath) {
92
+ // Local path install — validate the directory exists
93
+ const absLocalPath = path.resolve(localPath);
94
+ if (!existsSync(absLocalPath)) {
95
+ throw new Error(`Local plugin path does not exist: ${absLocalPath}`);
96
+ }
97
+ resolvedPackagePath = absLocalPath;
98
+ const pkgJson = await readPackageJson(absLocalPath);
99
+ resolvedPackageName =
100
+ typeof pkgJson?.["name"] === "string"
101
+ ? pkgJson["name"]
102
+ : path.basename(absLocalPath);
103
+ log.info({ localPath: absLocalPath, packageName: resolvedPackageName }, "plugin-loader: fetching plugin from local path");
104
+ }
105
+ else {
106
+ // npm install
107
+ const spec = version ? `${packageName}@${version}` : packageName;
108
+ log.info({ spec, installDir: targetInstallDir }, "plugin-loader: fetching plugin from npm");
109
+ try {
110
+ // Use execFile (not exec) to avoid shell injection from package name/version.
111
+ // --ignore-scripts prevents preinstall/install/postinstall hooks from
112
+ // executing arbitrary code on the host before manifest validation.
113
+ await execFileAsync("npm", ["install", spec, "--prefix", targetInstallDir, "--save", "--ignore-scripts"], { timeout: 120_000 });
114
+ }
115
+ catch (err) {
116
+ throw new Error(`npm install failed for ${spec}: ${String(err)}`);
117
+ }
118
+ // Resolve the package path after installation
119
+ const nodeModulesPath = path.join(targetInstallDir, "node_modules");
120
+ resolvedPackageName = packageName;
121
+ // Handle scoped packages
122
+ if (resolvedPackageName.startsWith("@")) {
123
+ const [scope, name] = resolvedPackageName.split("/");
124
+ resolvedPackagePath = path.join(nodeModulesPath, scope, name);
125
+ }
126
+ else {
127
+ resolvedPackagePath = path.join(nodeModulesPath, resolvedPackageName);
128
+ }
129
+ if (!existsSync(resolvedPackagePath)) {
130
+ throw new Error(`Package directory not found after installation: ${resolvedPackagePath}`);
131
+ }
132
+ }
133
+ // Step 3: Read and validate plugin manifest
134
+ // Note: this.loadManifest (used via current context)
135
+ const pkgJson = await readPackageJson(resolvedPackagePath);
136
+ if (!pkgJson)
137
+ throw new Error(`Missing package.json at ${resolvedPackagePath}`);
138
+ const manifestPath = resolveManifestPath(resolvedPackagePath, pkgJson);
139
+ if (!manifestPath || !existsSync(manifestPath)) {
140
+ throw new Error(`Package ${resolvedPackageName} at ${resolvedPackagePath} does not appear to be a Rudder plugin (no manifest found).`);
141
+ }
142
+ const manifest = await loadManifestFromPath(manifestPath);
143
+ // Step 4: Reject incompatible plugin API versions
144
+ if (!manifestValidator.getSupportedVersions().includes(manifest.apiVersion)) {
145
+ throw new Error(`Plugin ${manifest.id} declares apiVersion ${manifest.apiVersion} which is not supported by this host. ` +
146
+ `Supported versions: ${manifestValidator.getSupportedVersions().join(", ")}`);
147
+ }
148
+ // Step 5: Validate manifest capabilities are consistent
149
+ const capResult = capabilityValidator.validateManifestCapabilities(manifest);
150
+ if (!capResult.allowed) {
151
+ throw new Error(`Plugin ${manifest.id} manifest has inconsistent capabilities. ` +
152
+ `Missing required capabilities for declared features: ${capResult.missing.join(", ")}`);
153
+ }
154
+ await assertPageRoutePathsAvailable(manifest);
155
+ // Step 6: Reject plugins that require a newer host than the running server
156
+ const minimumHostVersion = getMinimumHostVersion(manifest);
157
+ if (minimumHostVersion && hostVersion) {
158
+ if (compareSemver(hostVersion, minimumHostVersion) < 0) {
159
+ throw new Error(`Plugin ${manifest.id} requires host version ${minimumHostVersion} or newer, ` +
160
+ `but this server is running ${hostVersion}`);
161
+ }
162
+ }
163
+ // Use the version declared in the manifest (required field per the spec)
164
+ const resolvedVersion = manifest.version;
165
+ return {
166
+ packagePath: resolvedPackagePath,
167
+ packageName: resolvedPackageName,
168
+ version: resolvedVersion,
169
+ source: localPath ? "local-filesystem" : "npm",
170
+ manifest,
171
+ };
172
+ }
173
+ /**
174
+ * Attempt to load and validate a plugin manifest from a resolved path.
175
+ * Returns the manifest on success or throws with a descriptive error.
176
+ */
177
+ async function loadManifestFromPath(manifestPath) {
178
+ let raw;
179
+ try {
180
+ // Dynamic import works for both .js (ESM) and .cjs (CJS) manifests
181
+ const mod = await import(manifestPath);
182
+ // The manifest may be the default export or the module itself
183
+ raw = mod["default"] ?? mod;
184
+ }
185
+ catch (err) {
186
+ throw new Error(`Failed to load manifest module at ${manifestPath}: ${String(err)}`);
187
+ }
188
+ return manifestValidator.parseOrThrow(raw);
189
+ }
190
+ /**
191
+ * Build a DiscoveredPlugin from a resolved package directory, or null
192
+ * if the package is not a Rudder plugin.
193
+ */
194
+ async function buildDiscoveredPlugin(packagePath, source) {
195
+ const pkgJson = await readPackageJson(packagePath);
196
+ if (!pkgJson)
197
+ return null;
198
+ const packageName = typeof pkgJson["name"] === "string" ? pkgJson["name"] : "";
199
+ const version = typeof pkgJson["version"] === "string" ? pkgJson["version"] : "0.0.0";
200
+ // Determine if this is a plugin package at all
201
+ const hasPaperclipPlugin = "rudderPlugin" in pkgJson;
202
+ const nameMatchesConvention = isPluginPackageName(packageName);
203
+ if (!hasPaperclipPlugin && !nameMatchesConvention) {
204
+ return null;
205
+ }
206
+ const manifestPath = resolveManifestPath(packagePath, pkgJson);
207
+ if (!manifestPath || !existsSync(manifestPath)) {
208
+ // Found a potential plugin package but no manifest entry point — treat
209
+ // as a discovery-only result with no manifest
210
+ return {
211
+ packagePath,
212
+ packageName,
213
+ version,
214
+ source,
215
+ manifest: null,
216
+ };
217
+ }
218
+ try {
219
+ const manifest = await loadManifestFromPath(manifestPath);
220
+ return {
221
+ packagePath,
222
+ packageName,
223
+ version,
224
+ source,
225
+ manifest,
226
+ };
227
+ }
228
+ catch (err) {
229
+ // Rethrow with context — callers catch and route to the errors array
230
+ throw new Error(`Plugin ${packageName}: ${String(err)}`);
231
+ }
232
+ }
233
+ // -------------------------------------------------------------------------
234
+ // Public API
235
+ // -------------------------------------------------------------------------
236
+ return {
237
+ // -----------------------------------------------------------------------
238
+ // discoverAll
239
+ // -----------------------------------------------------------------------
240
+ async discoverAll(npmSearchDirs) {
241
+ const allDiscovered = [];
242
+ const allErrors = [];
243
+ const sources = [];
244
+ if (enableLocalFilesystem) {
245
+ sources.push("local-filesystem");
246
+ const fsResult = await this.discoverFromLocalFilesystem();
247
+ allDiscovered.push(...fsResult.discovered);
248
+ allErrors.push(...fsResult.errors);
249
+ }
250
+ if (enableNpmDiscovery) {
251
+ sources.push("npm");
252
+ const npmResult = await this.discoverFromNpm(npmSearchDirs);
253
+ // Deduplicate against already-discovered packages (same package path)
254
+ const existingPaths = new Set(allDiscovered.map((d) => d.packagePath));
255
+ for (const plugin of npmResult.discovered) {
256
+ if (!existingPaths.has(plugin.packagePath)) {
257
+ allDiscovered.push(plugin);
258
+ }
259
+ }
260
+ allErrors.push(...npmResult.errors);
261
+ }
262
+ // Future: registry source (options.registryUrl)
263
+ if (options.registryUrl) {
264
+ sources.push("registry");
265
+ log.warn({ registryUrl: options.registryUrl }, "plugin-loader: remote registry discovery is not yet implemented");
266
+ }
267
+ log.info({
268
+ discovered: allDiscovered.length,
269
+ errors: allErrors.length,
270
+ sources,
271
+ }, "plugin-loader: discovery complete");
272
+ return { discovered: allDiscovered, errors: allErrors, sources };
273
+ },
274
+ // -----------------------------------------------------------------------
275
+ // discoverFromLocalFilesystem
276
+ // -----------------------------------------------------------------------
277
+ async discoverFromLocalFilesystem(dir) {
278
+ const scanDir = dir ?? localPluginDir;
279
+ const discovered = [];
280
+ const errors = [];
281
+ if (!existsSync(scanDir)) {
282
+ log.debug({ dir: scanDir }, "plugin-loader: local plugin directory does not exist, skipping");
283
+ return { discovered, errors, sources: ["local-filesystem"] };
284
+ }
285
+ let entries;
286
+ try {
287
+ entries = await readdir(scanDir);
288
+ }
289
+ catch (err) {
290
+ log.warn({ dir: scanDir, err }, "plugin-loader: failed to read local plugin directory");
291
+ return { discovered, errors, sources: ["local-filesystem"] };
292
+ }
293
+ for (const entry of entries) {
294
+ const entryPath = path.join(scanDir, entry);
295
+ // Check if entry is a directory
296
+ let entryStat;
297
+ try {
298
+ entryStat = await stat(entryPath);
299
+ }
300
+ catch {
301
+ continue;
302
+ }
303
+ if (!entryStat.isDirectory())
304
+ continue;
305
+ // Handle scoped packages: @scope/plugin-name is a subdirectory
306
+ if (entry.startsWith("@")) {
307
+ let scopedEntries;
308
+ try {
309
+ scopedEntries = await readdir(entryPath);
310
+ }
311
+ catch {
312
+ continue;
313
+ }
314
+ for (const scopedEntry of scopedEntries) {
315
+ const scopedPath = path.join(entryPath, scopedEntry);
316
+ try {
317
+ const scopedStat = await stat(scopedPath);
318
+ if (!scopedStat.isDirectory())
319
+ continue;
320
+ const plugin = await buildDiscoveredPlugin(scopedPath, "local-filesystem");
321
+ if (plugin)
322
+ discovered.push(plugin);
323
+ }
324
+ catch (err) {
325
+ errors.push({
326
+ packagePath: scopedPath,
327
+ packageName: `${entry}/${scopedEntry}`,
328
+ error: String(err),
329
+ });
330
+ }
331
+ }
332
+ continue;
333
+ }
334
+ try {
335
+ const plugin = await buildDiscoveredPlugin(entryPath, "local-filesystem");
336
+ if (plugin)
337
+ discovered.push(plugin);
338
+ }
339
+ catch (err) {
340
+ const pkgJson = await readPackageJson(entryPath);
341
+ const packageName = typeof pkgJson?.["name"] === "string" ? pkgJson["name"] : entry;
342
+ errors.push({ packagePath: entryPath, packageName, error: String(err) });
343
+ }
344
+ }
345
+ log.debug({ dir: scanDir, discovered: discovered.length, errors: errors.length }, "plugin-loader: local filesystem scan complete");
346
+ return { discovered, errors, sources: ["local-filesystem"] };
347
+ },
348
+ // -----------------------------------------------------------------------
349
+ // discoverFromNpm
350
+ // -----------------------------------------------------------------------
351
+ async discoverFromNpm(searchDirs) {
352
+ const discovered = [];
353
+ const errors = [];
354
+ // Determine the node_modules directories to search.
355
+ // When searchDirs is undefined OR empty, fall back to the conventional
356
+ // defaults (cwd/node_modules and localPluginDir/node_modules).
357
+ // To search nowhere explicitly, pass a non-empty array of non-existent paths.
358
+ const dirsToSearch = searchDirs && searchDirs.length > 0 ? searchDirs : [];
359
+ if (dirsToSearch.length === 0) {
360
+ // Default: search node_modules relative to the process working directory
361
+ // and also the local plugin dir's node_modules
362
+ const cwdNodeModules = path.join(process.cwd(), "node_modules");
363
+ const localNodeModules = path.join(localPluginDir, "node_modules");
364
+ if (existsSync(cwdNodeModules))
365
+ dirsToSearch.push(cwdNodeModules);
366
+ if (existsSync(localNodeModules))
367
+ dirsToSearch.push(localNodeModules);
368
+ }
369
+ for (const nodeModulesDir of dirsToSearch) {
370
+ if (!existsSync(nodeModulesDir))
371
+ continue;
372
+ let entries;
373
+ try {
374
+ entries = await readdir(nodeModulesDir);
375
+ }
376
+ catch {
377
+ continue;
378
+ }
379
+ for (const entry of entries) {
380
+ const entryPath = path.join(nodeModulesDir, entry);
381
+ // Handle scoped packages (@scope/*)
382
+ if (entry.startsWith("@")) {
383
+ let scopedEntries;
384
+ try {
385
+ scopedEntries = await readdir(entryPath);
386
+ }
387
+ catch {
388
+ continue;
389
+ }
390
+ for (const scopedEntry of scopedEntries) {
391
+ const fullName = `${entry}/${scopedEntry}`;
392
+ if (!isPluginPackageName(fullName))
393
+ continue;
394
+ const scopedPath = path.join(entryPath, scopedEntry);
395
+ try {
396
+ const plugin = await buildDiscoveredPlugin(scopedPath, "npm");
397
+ if (plugin)
398
+ discovered.push(plugin);
399
+ }
400
+ catch (err) {
401
+ errors.push({
402
+ packagePath: scopedPath,
403
+ packageName: fullName,
404
+ error: String(err),
405
+ });
406
+ }
407
+ }
408
+ continue;
409
+ }
410
+ // Non-scoped packages: check naming convention
411
+ if (!isPluginPackageName(entry))
412
+ continue;
413
+ let entryStat;
414
+ try {
415
+ entryStat = await stat(entryPath);
416
+ }
417
+ catch {
418
+ continue;
419
+ }
420
+ if (!entryStat.isDirectory())
421
+ continue;
422
+ try {
423
+ const plugin = await buildDiscoveredPlugin(entryPath, "npm");
424
+ if (plugin)
425
+ discovered.push(plugin);
426
+ }
427
+ catch (err) {
428
+ const pkgJson = await readPackageJson(entryPath);
429
+ const packageName = typeof pkgJson?.["name"] === "string" ? pkgJson["name"] : entry;
430
+ errors.push({ packagePath: entryPath, packageName, error: String(err) });
431
+ }
432
+ }
433
+ }
434
+ log.debug({ searchDirs: dirsToSearch, discovered: discovered.length, errors: errors.length }, "plugin-loader: npm discovery scan complete");
435
+ return { discovered, errors, sources: ["npm"] };
436
+ },
437
+ // -----------------------------------------------------------------------
438
+ // loadManifest
439
+ // -----------------------------------------------------------------------
440
+ async loadManifest(packagePath) {
441
+ const pkgJson = await readPackageJson(packagePath);
442
+ if (!pkgJson)
443
+ return null;
444
+ const hasPaperclipPlugin = "rudderPlugin" in pkgJson;
445
+ const packageName = typeof pkgJson["name"] === "string" ? pkgJson["name"] : "";
446
+ const nameMatchesConvention = isPluginPackageName(packageName);
447
+ if (!hasPaperclipPlugin && !nameMatchesConvention) {
448
+ return null;
449
+ }
450
+ const manifestPath = resolveManifestPath(packagePath, pkgJson);
451
+ if (!manifestPath || !existsSync(manifestPath))
452
+ return null;
453
+ return loadManifestFromPath(manifestPath);
454
+ },
455
+ // -----------------------------------------------------------------------
456
+ // installPlugin
457
+ // -----------------------------------------------------------------------
458
+ async installPlugin(installOptions) {
459
+ const discovered = await fetchAndValidate(installOptions);
460
+ // Step 6: Persist install record in Postgres (include packagePath for local installs so the worker can be resolved)
461
+ await registry.install({
462
+ packageName: discovered.packageName,
463
+ packagePath: discovered.source === "local-filesystem" ? discovered.packagePath : undefined,
464
+ }, discovered.manifest);
465
+ log.info({
466
+ pluginId: discovered.manifest.id,
467
+ packageName: discovered.packageName,
468
+ version: discovered.version,
469
+ capabilities: discovered.manifest.capabilities,
470
+ }, "plugin-loader: plugin installed successfully");
471
+ return discovered;
472
+ },
473
+ // -----------------------------------------------------------------------
474
+ // upgradePlugin
475
+ // -----------------------------------------------------------------------
476
+ /**
477
+ * Upgrade an already-installed plugin to a newer version.
478
+ *
479
+ * This method:
480
+ * 1. Fetches and validates the new plugin package using `fetchAndValidate`.
481
+ * 2. Ensures the new manifest ID matches the existing plugin ID for safety.
482
+ * 3. Updates the plugin record in the registry with the new version and manifest.
483
+ *
484
+ * @param pluginId - The UUID of the plugin to upgrade.
485
+ * @param upgradeOptions - Options for the upgrade (packageName, localPath, version).
486
+ * @returns The old and new manifests, along with the discovery metadata.
487
+ * @throws {Error} If the plugin is not found or if the new manifest ID differs.
488
+ */
489
+ async upgradePlugin(pluginId, upgradeOptions) {
490
+ const plugin = (await registry.getById(pluginId));
491
+ if (!plugin)
492
+ throw new Error(`Plugin not found: ${pluginId}`);
493
+ const oldManifest = plugin.manifestJson;
494
+ const { packageName = plugin.packageName,
495
+ // For local-path installs, fall back to the stored packagePath so
496
+ // `upgradePlugin` can re-read the manifest from disk without needing
497
+ // the caller to re-supply the path every time.
498
+ localPath = plugin.packagePath ?? undefined, version, } = upgradeOptions;
499
+ log.info({ pluginId, packageName, version, localPath }, "plugin-loader: upgrading plugin");
500
+ // 1. Fetch/Install the new version
501
+ const discovered = await fetchAndValidate({
502
+ packageName,
503
+ localPath,
504
+ version,
505
+ installDir: localPluginDir,
506
+ });
507
+ const newManifest = discovered.manifest;
508
+ // 2. Validate it's the same plugin ID
509
+ if (newManifest.id !== oldManifest.id) {
510
+ throw new Error(`Upgrade failed: new manifest ID '${newManifest.id}' does not match existing plugin ID '${oldManifest.id}'`);
511
+ }
512
+ // 3. Detect capability escalation — new capabilities not in the old manifest
513
+ const oldCaps = new Set(oldManifest.capabilities ?? []);
514
+ const newCaps = newManifest.capabilities ?? [];
515
+ const escalated = newCaps.filter((c) => !oldCaps.has(c));
516
+ if (escalated.length > 0) {
517
+ log.warn({ pluginId, escalated, oldVersion: oldManifest.version, newVersion: newManifest.version }, "plugin-loader: upgrade introduces new capabilities — requires admin approval");
518
+ throw new Error(`Upgrade for "${pluginId}" introduces new capabilities that require approval: ${escalated.join(", ")}. ` +
519
+ `The previous version declared [${[...oldCaps].join(", ")}]. ` +
520
+ `Please review and approve the capability escalation before upgrading.`);
521
+ }
522
+ // 4. Update the existing record
523
+ await registry.update(pluginId, {
524
+ packageName: discovered.packageName,
525
+ version: discovered.version,
526
+ manifest: newManifest,
527
+ });
528
+ return {
529
+ oldManifest,
530
+ newManifest,
531
+ discovered,
532
+ };
533
+ },
534
+ // -----------------------------------------------------------------------
535
+ // isSupportedApiVersion
536
+ // -----------------------------------------------------------------------
537
+ isSupportedApiVersion(apiVersion) {
538
+ return manifestValidator.getSupportedVersions().includes(apiVersion);
539
+ },
540
+ // -----------------------------------------------------------------------
541
+ // cleanupInstallArtifacts
542
+ // -----------------------------------------------------------------------
543
+ async cleanupInstallArtifacts(plugin) {
544
+ const managedTargets = new Set();
545
+ const managedNodeModulesDir = resolveManagedInstallPackageDir(localPluginDir, plugin.packageName);
546
+ const directManagedDir = path.join(localPluginDir, plugin.packageName);
547
+ managedTargets.add(managedNodeModulesDir);
548
+ if (isPathInsideDir(directManagedDir, localPluginDir)) {
549
+ managedTargets.add(directManagedDir);
550
+ }
551
+ if (plugin.packagePath && isPathInsideDir(plugin.packagePath, localPluginDir)) {
552
+ managedTargets.add(path.resolve(plugin.packagePath));
553
+ }
554
+ const packageJsonPath = path.join(localPluginDir, "package.json");
555
+ if (existsSync(packageJsonPath)) {
556
+ try {
557
+ await execFileAsync("npm", ["uninstall", plugin.packageName, "--prefix", localPluginDir, "--ignore-scripts"], { timeout: 120_000 });
558
+ }
559
+ catch (err) {
560
+ log.warn({
561
+ pluginId: plugin.id,
562
+ pluginKey: plugin.pluginKey,
563
+ packageName: plugin.packageName,
564
+ err: err instanceof Error ? err.message : String(err),
565
+ }, "plugin-loader: npm uninstall failed during cleanup, falling back to direct removal");
566
+ }
567
+ }
568
+ for (const target of managedTargets) {
569
+ if (!existsSync(target))
570
+ continue;
571
+ await rm(target, { recursive: true, force: true });
572
+ }
573
+ },
574
+ // -----------------------------------------------------------------------
575
+ // getLocalPluginDir
576
+ // -----------------------------------------------------------------------
577
+ getLocalPluginDir() {
578
+ return localPluginDir;
579
+ },
580
+ // -----------------------------------------------------------------------
581
+ // hasRuntimeServices
582
+ // -----------------------------------------------------------------------
583
+ hasRuntimeServices() {
584
+ return runtimeServices !== undefined;
585
+ },
586
+ // -----------------------------------------------------------------------
587
+ // -----------------------------------------------------------------------
588
+ // loadAll
589
+ // -----------------------------------------------------------------------
590
+ /**
591
+ * loadAll — Loads and activates all plugins that are currently in 'ready' status.
592
+ *
593
+ * This method is typically called during server startup. It fetches all ready
594
+ * plugins from the registry and attempts to activate them in parallel using
595
+ * Promise.allSettled. Failures in individual plugins do not prevent others from loading.
596
+ *
597
+ * @returns A promise that resolves with summary statistics of the load operation.
598
+ */
599
+ async loadAll() {
600
+ if (!runtimeServices) {
601
+ throw new Error("Cannot loadAll: no PluginRuntimeServices provided. " +
602
+ "Pass runtime services as the third argument to pluginLoader().");
603
+ }
604
+ log.info("plugin-loader: loading all ready plugins");
605
+ // Fetch all plugins in ready status, ordered by installOrder
606
+ const readyPlugins = (await registry.listByStatus("ready"));
607
+ if (readyPlugins.length === 0) {
608
+ log.info("plugin-loader: no ready plugins to load");
609
+ return { total: 0, succeeded: 0, failed: 0, results: [] };
610
+ }
611
+ log.info({ count: readyPlugins.length }, "plugin-loader: found ready plugins to load");
612
+ // Load plugins in parallel
613
+ const results = await Promise.allSettled(readyPlugins.map((plugin) => activatePlugin(plugin)));
614
+ const loadResults = results.map((r, i) => {
615
+ if (r.status === "fulfilled")
616
+ return r.value;
617
+ return {
618
+ plugin: readyPlugins[i],
619
+ success: false,
620
+ error: String(r.reason),
621
+ registered: { worker: false, eventSubscriptions: 0, jobs: 0, webhooks: 0, tools: 0 },
622
+ };
623
+ });
624
+ const succeeded = loadResults.filter((r) => r.success).length;
625
+ const failed = loadResults.filter((r) => !r.success).length;
626
+ log.info({
627
+ total: readyPlugins.length,
628
+ succeeded,
629
+ failed,
630
+ }, "plugin-loader: loadAll complete");
631
+ return {
632
+ total: readyPlugins.length,
633
+ succeeded,
634
+ failed,
635
+ results: loadResults,
636
+ };
637
+ },
638
+ // -----------------------------------------------------------------------
639
+ // loadSingle
640
+ // -----------------------------------------------------------------------
641
+ /**
642
+ * loadSingle — Loads and activates a single plugin by its ID.
643
+ *
644
+ * This method retrieves the plugin from the registry, ensures it's in a valid
645
+ * state, and then calls activatePlugin to start its worker and register its
646
+ * capabilities (tools, jobs, etc.).
647
+ *
648
+ * @param pluginId - The UUID of the plugin to load.
649
+ * @returns A promise that resolves with the result of the activation.
650
+ */
651
+ async loadSingle(pluginId) {
652
+ if (!runtimeServices) {
653
+ throw new Error("Cannot loadSingle: no PluginRuntimeServices provided. " +
654
+ "Pass runtime services as the third argument to pluginLoader().");
655
+ }
656
+ const plugin = (await registry.getById(pluginId));
657
+ if (!plugin) {
658
+ throw new Error(`Plugin not found: ${pluginId}`);
659
+ }
660
+ // If the plugin is in 'installed' status, transition it to 'ready' first.
661
+ // lifecycleManager.load() transitions the status AND activates the plugin
662
+ // via activateReadyPlugin() → loadSingle() (recursive call with 'ready'
663
+ // status) → activatePlugin(). We must NOT call activatePlugin() again here,
664
+ // as that would double-start the worker and duplicate registrations.
665
+ if (plugin.status === "installed") {
666
+ await runtimeServices.lifecycleManager.load(pluginId);
667
+ const updated = (await registry.getById(pluginId));
668
+ if (!updated)
669
+ throw new Error(`Plugin not found after status update: ${pluginId}`);
670
+ return {
671
+ plugin: updated,
672
+ success: true,
673
+ registered: { worker: true, eventSubscriptions: 0, jobs: 0, webhooks: 0, tools: 0 },
674
+ };
675
+ }
676
+ if (plugin.status !== "ready") {
677
+ throw new Error(`Cannot load plugin in status '${plugin.status}'. ` +
678
+ `Plugin must be in 'installed' or 'ready' status.`);
679
+ }
680
+ return activatePlugin(plugin);
681
+ },
682
+ // -----------------------------------------------------------------------
683
+ // unloadSingle
684
+ // -----------------------------------------------------------------------
685
+ async unloadSingle(pluginId, pluginKey) {
686
+ if (!runtimeServices) {
687
+ throw new Error("Cannot unloadSingle: no PluginRuntimeServices provided.");
688
+ }
689
+ log.info({ pluginId, pluginKey }, "plugin-loader: unloading single plugin");
690
+ const { workerManager, eventBus, jobScheduler, toolDispatcher, } = runtimeServices;
691
+ // 1. Unregister from job scheduler (cancels in-flight runs)
692
+ try {
693
+ await jobScheduler.unregisterPlugin(pluginId);
694
+ }
695
+ catch (err) {
696
+ log.warn({ pluginId, err: err instanceof Error ? err.message : String(err) }, "plugin-loader: failed to unregister from job scheduler (best-effort)");
697
+ }
698
+ // 2. Clear event subscriptions
699
+ eventBus.clearPlugin(pluginKey);
700
+ // 3. Unregister agent tools
701
+ toolDispatcher.unregisterPluginTools(pluginKey);
702
+ // 4. Stop the worker process
703
+ try {
704
+ if (workerManager.isRunning(pluginId)) {
705
+ await workerManager.stopWorker(pluginId);
706
+ }
707
+ }
708
+ catch (err) {
709
+ log.warn({ pluginId, err: err instanceof Error ? err.message : String(err) }, "plugin-loader: failed to stop worker during unload (best-effort)");
710
+ }
711
+ log.info({ pluginId, pluginKey }, "plugin-loader: plugin unloaded successfully");
712
+ },
713
+ // -----------------------------------------------------------------------
714
+ // shutdownAll
715
+ // -----------------------------------------------------------------------
716
+ async shutdownAll() {
717
+ if (!runtimeServices) {
718
+ throw new Error("Cannot shutdownAll: no PluginRuntimeServices provided.");
719
+ }
720
+ log.info("plugin-loader: shutting down all plugins");
721
+ const { workerManager, jobScheduler } = runtimeServices;
722
+ // 1. Stop the job scheduler tick loop
723
+ jobScheduler.stop();
724
+ // 2. Stop all worker processes
725
+ await workerManager.stopAll();
726
+ log.info("plugin-loader: all plugins shut down");
727
+ },
728
+ };
729
+ // -------------------------------------------------------------------------
730
+ // Internal: activatePlugin — shared logic for loadAll and loadSingle
731
+ // -------------------------------------------------------------------------
732
+ /**
733
+ * Activate a single plugin: spawn its worker, register event subscriptions,
734
+ * sync jobs, register tools.
735
+ *
736
+ * This is the core orchestration logic shared by `loadAll()` and `loadSingle()`.
737
+ * Failures are caught and reported in the result; the plugin is marked as
738
+ * `error` in the database when activation fails.
739
+ */
740
+ async function activatePlugin(plugin) {
741
+ const manifest = plugin.manifestJson;
742
+ const pluginId = plugin.id;
743
+ const pluginKey = plugin.pluginKey;
744
+ const registered = {
745
+ worker: false,
746
+ eventSubscriptions: 0,
747
+ jobs: 0,
748
+ webhooks: 0,
749
+ tools: 0,
750
+ };
751
+ // Guard: runtime services must exist (callers already checked)
752
+ if (!runtimeServices) {
753
+ return {
754
+ plugin,
755
+ success: false,
756
+ error: "No runtime services available",
757
+ registered,
758
+ };
759
+ }
760
+ const { workerManager, eventBus, jobScheduler, jobStore, toolDispatcher, lifecycleManager, buildHostHandlers, instanceInfo, } = runtimeServices;
761
+ try {
762
+ log.info({ pluginId, pluginKey, version: plugin.version }, "plugin-loader: activating plugin");
763
+ // ------------------------------------------------------------------
764
+ // 1. Resolve worker entrypoint
765
+ // ------------------------------------------------------------------
766
+ const workerEntrypoint = resolveWorkerEntrypoint(plugin, localPluginDir);
767
+ // ------------------------------------------------------------------
768
+ // 2. Build host handlers for this plugin
769
+ // ------------------------------------------------------------------
770
+ const hostHandlers = buildHostHandlers(pluginId, manifest);
771
+ // ------------------------------------------------------------------
772
+ // 3. Retrieve plugin config (if any)
773
+ // ------------------------------------------------------------------
774
+ let config = {};
775
+ try {
776
+ const configRow = await registry.getConfig(pluginId);
777
+ if (configRow && typeof configRow === "object" && "configJson" in configRow) {
778
+ config = configRow.configJson ?? {};
779
+ }
780
+ }
781
+ catch {
782
+ // Config may not exist yet — use empty object
783
+ log.debug({ pluginId }, "plugin-loader: no config found, using empty config");
784
+ }
785
+ // ------------------------------------------------------------------
786
+ // 4. Spawn worker process
787
+ // ------------------------------------------------------------------
788
+ const workerOptions = {
789
+ entrypointPath: workerEntrypoint,
790
+ manifest,
791
+ config,
792
+ instanceInfo,
793
+ apiVersion: manifest.apiVersion,
794
+ hostHandlers,
795
+ autoRestart: true,
796
+ };
797
+ // Repo-local plugin installs can resolve workspace TS sources at runtime
798
+ // (for example @rudderhq/shared exports). Run those workers through
799
+ // the tsx loader so first-party example plugins work in development.
800
+ if (plugin.packagePath && existsSync(DEV_TSX_LOADER_PATH)) {
801
+ workerOptions.execArgv = ["--import", DEV_TSX_LOADER_PATH];
802
+ }
803
+ await workerManager.startWorker(pluginId, workerOptions);
804
+ registered.worker = true;
805
+ log.info({ pluginId, pluginKey }, "plugin-loader: worker started");
806
+ // ------------------------------------------------------------------
807
+ // 5. Sync job declarations and register with scheduler
808
+ // ------------------------------------------------------------------
809
+ const jobDeclarations = manifest.jobs ?? [];
810
+ if (jobDeclarations.length > 0) {
811
+ await jobStore.syncJobDeclarations(pluginId, jobDeclarations);
812
+ await jobScheduler.registerPlugin(pluginId);
813
+ registered.jobs = jobDeclarations.length;
814
+ log.info({ pluginId, pluginKey, jobs: jobDeclarations.length }, "plugin-loader: job declarations synced and plugin registered with scheduler");
815
+ }
816
+ // ------------------------------------------------------------------
817
+ // 6. Register event subscriptions
818
+ //
819
+ // Note: Event subscriptions are declared at runtime by the plugin
820
+ // worker via the SDK's ctx.events.on() calls. The event bus manages
821
+ // per-plugin subscription scoping. Here we ensure the event bus has
822
+ // a scoped handle ready for this plugin — the actual subscriptions
823
+ // are registered by the host handler layer when the worker calls
824
+ // events.subscribe via RPC.
825
+ //
826
+ // The bus.forPlugin() call creates the scoped handle if needed;
827
+ // any previous subscriptions for this plugin are preserved if the
828
+ // worker is restarting.
829
+ // ------------------------------------------------------------------
830
+ const _scopedBus = eventBus.forPlugin(pluginKey);
831
+ registered.eventSubscriptions = eventBus.subscriptionCount(pluginKey);
832
+ log.debug({ pluginId, pluginKey }, "plugin-loader: event bus scoped handle ready");
833
+ // ------------------------------------------------------------------
834
+ // 7. Register webhook endpoints (manifest-declared)
835
+ //
836
+ // Webhooks are statically declared in the manifest. The actual
837
+ // endpoint routing is handled by the plugin routes module which
838
+ // checks the manifest for declared webhooks. No explicit
839
+ // registration step is needed here — the manifest is persisted
840
+ // in the DB and the route handler reads it at request time.
841
+ //
842
+ // We track the count for the result reporting.
843
+ // ------------------------------------------------------------------
844
+ const webhookDeclarations = manifest.webhooks ?? [];
845
+ registered.webhooks = webhookDeclarations.length;
846
+ if (webhookDeclarations.length > 0) {
847
+ log.info({ pluginId, pluginKey, webhooks: webhookDeclarations.length }, "plugin-loader: webhook endpoints declared in manifest");
848
+ }
849
+ // ------------------------------------------------------------------
850
+ // 8. Register agent tools
851
+ // ------------------------------------------------------------------
852
+ const toolDeclarations = manifest.tools ?? [];
853
+ if (toolDeclarations.length > 0) {
854
+ toolDispatcher.registerPluginTools(pluginKey, manifest);
855
+ registered.tools = toolDeclarations.length;
856
+ log.info({ pluginId, pluginKey, tools: toolDeclarations.length }, "plugin-loader: agent tools registered");
857
+ }
858
+ // ------------------------------------------------------------------
859
+ // Done — plugin fully activated
860
+ // ------------------------------------------------------------------
861
+ log.info({
862
+ pluginId,
863
+ pluginKey,
864
+ version: plugin.version,
865
+ registered,
866
+ }, "plugin-loader: plugin activated successfully");
867
+ return { plugin, success: true, registered };
868
+ }
869
+ catch (err) {
870
+ const errorMessage = err instanceof Error ? err.message : String(err);
871
+ log.error({ pluginId, pluginKey, err: errorMessage }, "plugin-loader: failed to activate plugin");
872
+ // Mark the plugin as errored in the database so it is not retried
873
+ // automatically on next startup without operator intervention.
874
+ try {
875
+ await lifecycleManager.markError(pluginId, `Activation failed: ${errorMessage}`);
876
+ }
877
+ catch (markErr) {
878
+ log.error({
879
+ pluginId,
880
+ err: markErr instanceof Error ? markErr.message : String(markErr),
881
+ }, "plugin-loader: failed to mark plugin as error after activation failure");
882
+ }
883
+ return {
884
+ plugin,
885
+ success: false,
886
+ error: errorMessage,
887
+ registered,
888
+ };
889
+ }
890
+ }
891
+ }
892
+ // ---------------------------------------------------------------------------
893
+ // Worker entrypoint resolution
894
+ // ---------------------------------------------------------------------------
895
+ /**
896
+ * Resolve the absolute path to a plugin's worker entrypoint from its manifest
897
+ * and known install locations.
898
+ *
899
+ * The manifest `entrypoints.worker` field is relative to the package root.
900
+ * We check the local plugin directory (where the package was installed) and
901
+ * also the package directory if it was a local-path install.
902
+ *
903
+ * @see PLUGIN_SPEC.md §10 — Package Contract
904
+ */
905
+ //# sourceMappingURL=plugin-loader.core.js.map