@rudderhq/server 0.1.0-canary.0

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 (902) hide show
  1. package/LICENSE +14 -0
  2. package/dist/agent-auth-jwt.d.ts +14 -0
  3. package/dist/agent-auth-jwt.d.ts.map +1 -0
  4. package/dist/agent-auth-jwt.js +119 -0
  5. package/dist/agent-auth-jwt.js.map +1 -0
  6. package/dist/agent-runtimes/codex-models.d.ts +4 -0
  7. package/dist/agent-runtimes/codex-models.d.ts.map +1 -0
  8. package/dist/agent-runtimes/codex-models.js +98 -0
  9. package/dist/agent-runtimes/codex-models.js.map +1 -0
  10. package/dist/agent-runtimes/cursor-models.d.ts +13 -0
  11. package/dist/agent-runtimes/cursor-models.d.ts.map +1 -0
  12. package/dist/agent-runtimes/cursor-models.js +148 -0
  13. package/dist/agent-runtimes/cursor-models.js.map +1 -0
  14. package/dist/agent-runtimes/http/execute.d.ts +3 -0
  15. package/dist/agent-runtimes/http/execute.d.ts.map +1 -0
  16. package/dist/agent-runtimes/http/execute.js +39 -0
  17. package/dist/agent-runtimes/http/execute.js.map +1 -0
  18. package/dist/agent-runtimes/http/index.d.ts +3 -0
  19. package/dist/agent-runtimes/http/index.d.ts.map +1 -0
  20. package/dist/agent-runtimes/http/index.js +20 -0
  21. package/dist/agent-runtimes/http/index.js.map +1 -0
  22. package/dist/agent-runtimes/http/test.d.ts +3 -0
  23. package/dist/agent-runtimes/http/test.d.ts.map +1 -0
  24. package/dist/agent-runtimes/http/test.js +106 -0
  25. package/dist/agent-runtimes/http/test.js.map +1 -0
  26. package/dist/agent-runtimes/index.d.ts +4 -0
  27. package/dist/agent-runtimes/index.d.ts.map +1 -0
  28. package/dist/agent-runtimes/index.js +3 -0
  29. package/dist/agent-runtimes/index.js.map +1 -0
  30. package/dist/agent-runtimes/process/execute.d.ts +3 -0
  31. package/dist/agent-runtimes/process/execute.d.ts.map +1 -0
  32. package/dist/agent-runtimes/process/execute.js +63 -0
  33. package/dist/agent-runtimes/process/execute.js.map +1 -0
  34. package/dist/agent-runtimes/process/index.d.ts +3 -0
  35. package/dist/agent-runtimes/process/index.d.ts.map +1 -0
  36. package/dist/agent-runtimes/process/index.js +23 -0
  37. package/dist/agent-runtimes/process/index.js.map +1 -0
  38. package/dist/agent-runtimes/process/test.d.ts +3 -0
  39. package/dist/agent-runtimes/process/test.d.ts.map +1 -0
  40. package/dist/agent-runtimes/process/test.js +77 -0
  41. package/dist/agent-runtimes/process/test.js.map +1 -0
  42. package/dist/agent-runtimes/registry.d.ts +9 -0
  43. package/dist/agent-runtimes/registry.d.ts.map +1 -0
  44. package/dist/agent-runtimes/registry.js +189 -0
  45. package/dist/agent-runtimes/registry.js.map +1 -0
  46. package/dist/agent-runtimes/types.d.ts +2 -0
  47. package/dist/agent-runtimes/types.d.ts.map +1 -0
  48. package/dist/agent-runtimes/types.js +2 -0
  49. package/dist/agent-runtimes/types.js.map +1 -0
  50. package/dist/agent-runtimes/utils.d.ts +10 -0
  51. package/dist/agent-runtimes/utils.d.ts.map +1 -0
  52. package/dist/agent-runtimes/utils.js +14 -0
  53. package/dist/agent-runtimes/utils.js.map +1 -0
  54. package/dist/agent-workspace-key.d.ts +17 -0
  55. package/dist/agent-workspace-key.d.ts.map +1 -0
  56. package/dist/agent-workspace-key.js +49 -0
  57. package/dist/agent-workspace-key.js.map +1 -0
  58. package/dist/app.d.ts +14 -0
  59. package/dist/app.d.ts.map +1 -0
  60. package/dist/app.js +19 -0
  61. package/dist/app.js.map +1 -0
  62. package/dist/attachment-types.d.ts +33 -0
  63. package/dist/attachment-types.d.ts.map +1 -0
  64. package/dist/attachment-types.js +67 -0
  65. package/dist/attachment-types.js.map +1 -0
  66. package/dist/auth/better-auth.d.ts +24 -0
  67. package/dist/auth/better-auth.d.ts.map +1 -0
  68. package/dist/auth/better-auth.js +108 -0
  69. package/dist/auth/better-auth.js.map +1 -0
  70. package/dist/board-claim.d.ts +23 -0
  71. package/dist/board-claim.d.ts.map +1 -0
  72. package/dist/board-claim.js +115 -0
  73. package/dist/board-claim.js.map +1 -0
  74. package/dist/bootstrap/create-http-app.d.ts +6 -0
  75. package/dist/bootstrap/create-http-app.d.ts.map +1 -0
  76. package/dist/bootstrap/create-http-app.js +122 -0
  77. package/dist/bootstrap/create-http-app.js.map +1 -0
  78. package/dist/bootstrap/plugin-host-runtime.d.ts +116 -0
  79. package/dist/bootstrap/plugin-host-runtime.d.ts.map +1 -0
  80. package/dist/bootstrap/plugin-host-runtime.js +121 -0
  81. package/dist/bootstrap/plugin-host-runtime.js.map +1 -0
  82. package/dist/bootstrap/register-api-routes.d.ts +5 -0
  83. package/dist/bootstrap/register-api-routes.d.ts.map +1 -0
  84. package/dist/bootstrap/register-api-routes.js +65 -0
  85. package/dist/bootstrap/register-api-routes.js.map +1 -0
  86. package/dist/bootstrap/types.d.ts +24 -0
  87. package/dist/bootstrap/types.d.ts.map +1 -0
  88. package/dist/bootstrap/types.js +2 -0
  89. package/dist/bootstrap/types.js.map +1 -0
  90. package/dist/config-file.d.ts +5 -0
  91. package/dist/config-file.d.ts.map +1 -0
  92. package/dist/config-file.js +48 -0
  93. package/dist/config-file.js.map +1 -0
  94. package/dist/config.d.ts +45 -0
  95. package/dist/config.d.ts.map +1 -0
  96. package/dist/config.js +233 -0
  97. package/dist/config.js.map +1 -0
  98. package/dist/dev-server-status.d.ts +29 -0
  99. package/dist/dev-server-status.d.ts.map +1 -0
  100. package/dist/dev-server-status.js +75 -0
  101. package/dist/dev-server-status.js.map +1 -0
  102. package/dist/errors.d.ts +12 -0
  103. package/dist/errors.d.ts.map +1 -0
  104. package/dist/errors.js +28 -0
  105. package/dist/errors.js.map +1 -0
  106. package/dist/home-paths.d.ts +50 -0
  107. package/dist/home-paths.d.ts.map +1 -0
  108. package/dist/home-paths.js +183 -0
  109. package/dist/home-paths.js.map +1 -0
  110. package/dist/index.d.ts +69 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +827 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/langfuse-transcript.d.ts +32 -0
  115. package/dist/langfuse-transcript.d.ts.map +1 -0
  116. package/dist/langfuse-transcript.js +341 -0
  117. package/dist/langfuse-transcript.js.map +1 -0
  118. package/dist/langfuse.d.ts +93 -0
  119. package/dist/langfuse.d.ts.map +1 -0
  120. package/dist/langfuse.js +412 -0
  121. package/dist/langfuse.js.map +1 -0
  122. package/dist/local-runtime.d.ts +67 -0
  123. package/dist/local-runtime.d.ts.map +1 -0
  124. package/dist/local-runtime.js +302 -0
  125. package/dist/local-runtime.js.map +1 -0
  126. package/dist/log-redaction.d.ts +11 -0
  127. package/dist/log-redaction.d.ts.map +1 -0
  128. package/dist/log-redaction.js +118 -0
  129. package/dist/log-redaction.js.map +1 -0
  130. package/dist/middleware/auth.d.ts +12 -0
  131. package/dist/middleware/auth.d.ts.map +1 -0
  132. package/dist/middleware/auth.js +144 -0
  133. package/dist/middleware/auth.js.map +1 -0
  134. package/dist/middleware/board-mutation-guard.d.ts +3 -0
  135. package/dist/middleware/board-mutation-guard.d.ts.map +1 -0
  136. package/dist/middleware/board-mutation-guard.js +59 -0
  137. package/dist/middleware/board-mutation-guard.js.map +1 -0
  138. package/dist/middleware/error-handler.d.ts +17 -0
  139. package/dist/middleware/error-handler.d.ts.map +1 -0
  140. package/dist/middleware/error-handler.js +37 -0
  141. package/dist/middleware/error-handler.js.map +1 -0
  142. package/dist/middleware/index.d.ts +4 -0
  143. package/dist/middleware/index.d.ts.map +1 -0
  144. package/dist/middleware/index.js +4 -0
  145. package/dist/middleware/index.js.map +1 -0
  146. package/dist/middleware/logger.d.ts +4 -0
  147. package/dist/middleware/logger.d.ts.map +1 -0
  148. package/dist/middleware/logger.js +133 -0
  149. package/dist/middleware/logger.js.map +1 -0
  150. package/dist/middleware/private-hostname-guard.d.ts +11 -0
  151. package/dist/middleware/private-hostname-guard.d.ts.map +1 -0
  152. package/dist/middleware/private-hostname-guard.js +78 -0
  153. package/dist/middleware/private-hostname-guard.js.map +1 -0
  154. package/dist/middleware/validate.d.ts +4 -0
  155. package/dist/middleware/validate.d.ts.map +1 -0
  156. package/dist/middleware/validate.js +7 -0
  157. package/dist/middleware/validate.js.map +1 -0
  158. package/dist/onboarding-assets/ceo/AGENTS.md +33 -0
  159. package/dist/onboarding-assets/ceo/HEARTBEAT.md +77 -0
  160. package/dist/onboarding-assets/ceo/SOUL.md +33 -0
  161. package/dist/onboarding-assets/ceo/TOOLS.md +3 -0
  162. package/dist/onboarding-assets/default/AGENTS.md +9 -0
  163. package/dist/onboarding-assets/default/HEARTBEAT.md +36 -0
  164. package/dist/onboarding-assets/default/SOUL.md +23 -0
  165. package/dist/onboarding-assets/default/TOOLS.md +3 -0
  166. package/dist/paths.d.ts +3 -0
  167. package/dist/paths.d.ts.map +1 -0
  168. package/dist/paths.js +31 -0
  169. package/dist/paths.js.map +1 -0
  170. package/dist/realtime/live-events-ws.d.ts +28 -0
  171. package/dist/realtime/live-events-ws.d.ts.map +1 -0
  172. package/dist/realtime/live-events-ws.js +187 -0
  173. package/dist/realtime/live-events-ws.js.map +1 -0
  174. package/dist/redaction.d.ts +4 -0
  175. package/dist/redaction.d.ts.map +1 -0
  176. package/dist/redaction.js +63 -0
  177. package/dist/redaction.js.map +1 -0
  178. package/dist/routes/access.d.ts +57 -0
  179. package/dist/routes/access.d.ts.map +1 -0
  180. package/dist/routes/access.js +2266 -0
  181. package/dist/routes/access.js.map +1 -0
  182. package/dist/routes/activity.d.ts +3 -0
  183. package/dist/routes/activity.d.ts.map +1 -0
  184. package/dist/routes/activity.js +78 -0
  185. package/dist/routes/activity.js.map +1 -0
  186. package/dist/routes/agents.d.ts +3 -0
  187. package/dist/routes/agents.d.ts.map +1 -0
  188. package/dist/routes/agents.js +1913 -0
  189. package/dist/routes/agents.js.map +1 -0
  190. package/dist/routes/approvals.d.ts +3 -0
  191. package/dist/routes/approvals.d.ts.map +1 -0
  192. package/dist/routes/approvals.js +365 -0
  193. package/dist/routes/approvals.js.map +1 -0
  194. package/dist/routes/assets.d.ts +4 -0
  195. package/dist/routes/assets.d.ts.map +1 -0
  196. package/dist/routes/assets.js +309 -0
  197. package/dist/routes/assets.js.map +1 -0
  198. package/dist/routes/authz.d.ts +16 -0
  199. package/dist/routes/authz.d.ts.map +1 -0
  200. package/dist/routes/authz.js +47 -0
  201. package/dist/routes/authz.js.map +1 -0
  202. package/dist/routes/automations.d.ts +3 -0
  203. package/dist/routes/automations.d.ts.map +1 -0
  204. package/dist/routes/automations.js +277 -0
  205. package/dist/routes/automations.js.map +1 -0
  206. package/dist/routes/chats.d.ts +4 -0
  207. package/dist/routes/chats.d.ts.map +1 -0
  208. package/dist/routes/chats.js +1162 -0
  209. package/dist/routes/chats.js.map +1 -0
  210. package/dist/routes/costs.d.ts +3 -0
  211. package/dist/routes/costs.d.ts.map +1 -0
  212. package/dist/routes/costs.js +268 -0
  213. package/dist/routes/costs.js.map +1 -0
  214. package/dist/routes/dashboard.d.ts +3 -0
  215. package/dist/routes/dashboard.d.ts.map +1 -0
  216. package/dist/routes/dashboard.js +15 -0
  217. package/dist/routes/dashboard.js.map +1 -0
  218. package/dist/routes/execution-workspaces.d.ts +3 -0
  219. package/dist/routes/execution-workspaces.d.ts.map +1 -0
  220. package/dist/routes/execution-workspaces.js +165 -0
  221. package/dist/routes/execution-workspaces.js.map +1 -0
  222. package/dist/routes/goals.d.ts +3 -0
  223. package/dist/routes/goals.d.ts.map +1 -0
  224. package/dist/routes/goals.js +95 -0
  225. package/dist/routes/goals.js.map +1 -0
  226. package/dist/routes/health.d.ts +12 -0
  227. package/dist/routes/health.d.ts.map +1 -0
  228. package/dist/routes/health.js +85 -0
  229. package/dist/routes/health.js.map +1 -0
  230. package/dist/routes/index.d.ts +19 -0
  231. package/dist/routes/index.d.ts.map +1 -0
  232. package/dist/routes/index.js +19 -0
  233. package/dist/routes/index.js.map +1 -0
  234. package/dist/routes/instance-settings.d.ts +6 -0
  235. package/dist/routes/instance-settings.d.ts.map +1 -0
  236. package/dist/routes/instance-settings.js +250 -0
  237. package/dist/routes/instance-settings.js.map +1 -0
  238. package/dist/routes/issues-checkout-wakeup.d.ts +9 -0
  239. package/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
  240. package/dist/routes/issues-checkout-wakeup.js +12 -0
  241. package/dist/routes/issues-checkout-wakeup.js.map +1 -0
  242. package/dist/routes/issues.d.ts +4 -0
  243. package/dist/routes/issues.d.ts.map +1 -0
  244. package/dist/routes/issues.js +1615 -0
  245. package/dist/routes/issues.js.map +1 -0
  246. package/dist/routes/llms.d.ts +3 -0
  247. package/dist/routes/llms.d.ts.map +1 -0
  248. package/dist/routes/llms.js +78 -0
  249. package/dist/routes/llms.js.map +1 -0
  250. package/dist/routes/messenger.d.ts +3 -0
  251. package/dist/routes/messenger.d.ts.map +1 -0
  252. package/dist/routes/messenger.js +108 -0
  253. package/dist/routes/messenger.js.map +1 -0
  254. package/dist/routes/org-chart-logo.d.ts +2 -0
  255. package/dist/routes/org-chart-logo.d.ts.map +1 -0
  256. package/dist/routes/org-chart-logo.js +2 -0
  257. package/dist/routes/org-chart-logo.js.map +1 -0
  258. package/dist/routes/org-chart-svg.d.ts +25 -0
  259. package/dist/routes/org-chart-svg.d.ts.map +1 -0
  260. package/dist/routes/org-chart-svg.js +652 -0
  261. package/dist/routes/org-chart-svg.js.map +1 -0
  262. package/dist/routes/organization-skills.d.ts +3 -0
  263. package/dist/routes/organization-skills.d.ts.map +1 -0
  264. package/dist/routes/organization-skills.js +253 -0
  265. package/dist/routes/organization-skills.js.map +1 -0
  266. package/dist/routes/orgs.d.ts +4 -0
  267. package/dist/routes/orgs.d.ts.map +1 -0
  268. package/dist/routes/orgs.js +575 -0
  269. package/dist/routes/orgs.js.map +1 -0
  270. package/dist/routes/plugin-ui-static.d.ts +69 -0
  271. package/dist/routes/plugin-ui-static.d.ts.map +1 -0
  272. package/dist/routes/plugin-ui-static.js +411 -0
  273. package/dist/routes/plugin-ui-static.js.map +1 -0
  274. package/dist/routes/plugins.d.ts +120 -0
  275. package/dist/routes/plugins.d.ts.map +1 -0
  276. package/dist/routes/plugins.js +1776 -0
  277. package/dist/routes/plugins.js.map +1 -0
  278. package/dist/routes/projects.d.ts +3 -0
  279. package/dist/routes/projects.d.ts.map +1 -0
  280. package/dist/routes/projects.js +235 -0
  281. package/dist/routes/projects.js.map +1 -0
  282. package/dist/routes/run-intelligence.d.ts +3 -0
  283. package/dist/routes/run-intelligence.d.ts.map +1 -0
  284. package/dist/routes/run-intelligence.js +58 -0
  285. package/dist/routes/run-intelligence.js.map +1 -0
  286. package/dist/routes/secrets.d.ts +3 -0
  287. package/dist/routes/secrets.d.ts.map +1 -0
  288. package/dist/routes/secrets.js +128 -0
  289. package/dist/routes/secrets.js.map +1 -0
  290. package/dist/routes/sidebar-badges.d.ts +3 -0
  291. package/dist/routes/sidebar-badges.d.ts.map +1 -0
  292. package/dist/routes/sidebar-badges.js +70 -0
  293. package/dist/routes/sidebar-badges.js.map +1 -0
  294. package/dist/secrets/external-stub-providers.d.ts +5 -0
  295. package/dist/secrets/external-stub-providers.d.ts.map +1 -0
  296. package/dist/secrets/external-stub-providers.js +21 -0
  297. package/dist/secrets/external-stub-providers.js.map +1 -0
  298. package/dist/secrets/local-encrypted-provider.d.ts +3 -0
  299. package/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
  300. package/dist/secrets/local-encrypted-provider.js +116 -0
  301. package/dist/secrets/local-encrypted-provider.js.map +1 -0
  302. package/dist/secrets/provider-registry.d.ts +5 -0
  303. package/dist/secrets/provider-registry.d.ts.map +1 -0
  304. package/dist/secrets/provider-registry.js +20 -0
  305. package/dist/secrets/provider-registry.js.map +1 -0
  306. package/dist/secrets/types.d.ts +21 -0
  307. package/dist/secrets/types.d.ts.map +1 -0
  308. package/dist/secrets/types.js +2 -0
  309. package/dist/secrets/types.js.map +1 -0
  310. package/dist/services/access.d.ts +113 -0
  311. package/dist/services/access.d.ts.map +1 -0
  312. package/dist/services/access.js +247 -0
  313. package/dist/services/access.js.map +1 -0
  314. package/dist/services/activity-log.d.ts +17 -0
  315. package/dist/services/activity-log.d.ts.map +1 -0
  316. package/dist/services/activity-log.js +109 -0
  317. package/dist/services/activity-log.js.map +1 -0
  318. package/dist/services/activity.d.ts +472 -0
  319. package/dist/services/activity.d.ts.map +1 -0
  320. package/dist/services/activity.js +134 -0
  321. package/dist/services/activity.js.map +1 -0
  322. package/dist/services/agent-enabled-skills.d.ts +9 -0
  323. package/dist/services/agent-enabled-skills.d.ts.map +1 -0
  324. package/dist/services/agent-enabled-skills.js +89 -0
  325. package/dist/services/agent-enabled-skills.js.map +1 -0
  326. package/dist/services/agent-instructions.d.ts +98 -0
  327. package/dist/services/agent-instructions.d.ts.map +1 -0
  328. package/dist/services/agent-instructions.js +596 -0
  329. package/dist/services/agent-instructions.js.map +1 -0
  330. package/dist/services/agent-name-pool.d.ts +10 -0
  331. package/dist/services/agent-name-pool.d.ts.map +1 -0
  332. package/dist/services/agent-name-pool.js +230 -0
  333. package/dist/services/agent-name-pool.js.map +1 -0
  334. package/dist/services/agent-permissions.d.ts +6 -0
  335. package/dist/services/agent-permissions.d.ts.map +1 -0
  336. package/dist/services/agent-permissions.js +18 -0
  337. package/dist/services/agent-permissions.js.map +1 -0
  338. package/dist/services/agent-run-context.d.ts +142 -0
  339. package/dist/services/agent-run-context.d.ts.map +1 -0
  340. package/dist/services/agent-run-context.js +451 -0
  341. package/dist/services/agent-run-context.js.map +1 -0
  342. package/dist/services/agents.d.ts +1713 -0
  343. package/dist/services/agents.d.ts.map +1 -0
  344. package/dist/services/agents.js +750 -0
  345. package/dist/services/agents.js.map +1 -0
  346. package/dist/services/approvals.d.ts +546 -0
  347. package/dist/services/approvals.d.ts.map +1 -0
  348. package/dist/services/approvals.js +212 -0
  349. package/dist/services/approvals.js.map +1 -0
  350. package/dist/services/assets.d.ts +33 -0
  351. package/dist/services/assets.d.ts.map +1 -0
  352. package/dist/services/assets.js +17 -0
  353. package/dist/services/assets.js.map +1 -0
  354. package/dist/services/automations.d.ts +135 -0
  355. package/dist/services/automations.d.ts.map +1 -0
  356. package/dist/services/automations.js +1105 -0
  357. package/dist/services/automations.js.map +1 -0
  358. package/dist/services/board-auth.d.ts +234 -0
  359. package/dist/services/board-auth.d.ts.map +1 -0
  360. package/dist/services/board-auth.js +295 -0
  361. package/dist/services/board-auth.js.map +1 -0
  362. package/dist/services/budgets.d.ts +38 -0
  363. package/dist/services/budgets.d.ts.map +1 -0
  364. package/dist/services/budgets.js +784 -0
  365. package/dist/services/budgets.js.map +1 -0
  366. package/dist/services/chat-assistant.d.ts +62 -0
  367. package/dist/services/chat-assistant.d.ts.map +1 -0
  368. package/dist/services/chat-assistant.js +943 -0
  369. package/dist/services/chat-assistant.js.map +1 -0
  370. package/dist/services/chat-generation-locks.d.ts +3 -0
  371. package/dist/services/chat-generation-locks.d.ts.map +1 -0
  372. package/dist/services/chat-generation-locks.js +16 -0
  373. package/dist/services/chat-generation-locks.js.map +1 -0
  374. package/dist/services/chats.d.ts +723 -0
  375. package/dist/services/chats.d.ts.map +1 -0
  376. package/dist/services/chats.js +1188 -0
  377. package/dist/services/chats.js.map +1 -0
  378. package/dist/services/costs.d.ts +114 -0
  379. package/dist/services/costs.d.ts.map +1 -0
  380. package/dist/services/costs.js +326 -0
  381. package/dist/services/costs.js.map +1 -0
  382. package/dist/services/cron.d.ts +80 -0
  383. package/dist/services/cron.d.ts.map +1 -0
  384. package/dist/services/cron.js +300 -0
  385. package/dist/services/cron.js.map +1 -0
  386. package/dist/services/dashboard.d.ts +26 -0
  387. package/dist/services/dashboard.d.ts.map +1 -0
  388. package/dist/services/dashboard.js +98 -0
  389. package/dist/services/dashboard.js.map +1 -0
  390. package/dist/services/default-agent-instructions.d.ts +9 -0
  391. package/dist/services/default-agent-instructions.d.ts.map +1 -0
  392. package/dist/services/default-agent-instructions.js +20 -0
  393. package/dist/services/default-agent-instructions.js.map +1 -0
  394. package/dist/services/documents.d.ts +164 -0
  395. package/dist/services/documents.d.ts.map +1 -0
  396. package/dist/services/documents.js +382 -0
  397. package/dist/services/documents.js.map +1 -0
  398. package/dist/services/execution-workspace-policy.d.ts +20 -0
  399. package/dist/services/execution-workspace-policy.d.ts.map +1 -0
  400. package/dist/services/execution-workspace-policy.js +172 -0
  401. package/dist/services/execution-workspace-policy.js.map +1 -0
  402. package/dist/services/execution-workspaces.d.ts +19 -0
  403. package/dist/services/execution-workspaces.d.ts.map +1 -0
  404. package/dist/services/execution-workspaces.js +87 -0
  405. package/dist/services/execution-workspaces.js.map +1 -0
  406. package/dist/services/finance.d.ts +93 -0
  407. package/dist/services/finance.d.ts.map +1 -0
  408. package/dist/services/finance.js +120 -0
  409. package/dist/services/finance.js.map +1 -0
  410. package/dist/services/goals.d.ts +433 -0
  411. package/dist/services/goals.d.ts.map +1 -0
  412. package/dist/services/goals.js +54 -0
  413. package/dist/services/goals.js.map +1 -0
  414. package/dist/services/heartbeat-run-summary.d.ts +2 -0
  415. package/dist/services/heartbeat-run-summary.d.ts.map +1 -0
  416. package/dist/services/heartbeat-run-summary.js +131 -0
  417. package/dist/services/heartbeat-run-summary.js.map +1 -0
  418. package/dist/services/heartbeat.d.ts +2 -0
  419. package/dist/services/heartbeat.d.ts.map +1 -0
  420. package/dist/services/heartbeat.js +2 -0
  421. package/dist/services/heartbeat.js.map +1 -0
  422. package/dist/services/hire-hook.d.ts +14 -0
  423. package/dist/services/hire-hook.d.ts.map +1 -0
  424. package/dist/services/hire-hook.js +85 -0
  425. package/dist/services/hire-hook.js.map +1 -0
  426. package/dist/services/index.d.ts +38 -0
  427. package/dist/services/index.d.ts.map +1 -0
  428. package/dist/services/index.js +38 -0
  429. package/dist/services/index.js.map +1 -0
  430. package/dist/services/instance-settings.d.ts +14 -0
  431. package/dist/services/instance-settings.d.ts.map +1 -0
  432. package/dist/services/instance-settings.js +158 -0
  433. package/dist/services/instance-settings.js.map +1 -0
  434. package/dist/services/issue-approvals.d.ts +56 -0
  435. package/dist/services/issue-approvals.d.ts.map +1 -0
  436. package/dist/services/issue-approvals.js +153 -0
  437. package/dist/services/issue-approvals.js.map +1 -0
  438. package/dist/services/issue-assignment-wakeup.d.ts +32 -0
  439. package/dist/services/issue-assignment-wakeup.d.ts.map +1 -0
  440. package/dist/services/issue-assignment-wakeup.js +43 -0
  441. package/dist/services/issue-assignment-wakeup.js.map +1 -0
  442. package/dist/services/issue-goal-fallback.d.ts +15 -0
  443. package/dist/services/issue-goal-fallback.d.ts.map +1 -0
  444. package/dist/services/issue-goal-fallback.js +15 -0
  445. package/dist/services/issue-goal-fallback.js.map +1 -0
  446. package/dist/services/issues.d.ts +580 -0
  447. package/dist/services/issues.d.ts.map +1 -0
  448. package/dist/services/issues.js +1464 -0
  449. package/dist/services/issues.js.map +1 -0
  450. package/dist/services/knowledge-portability/organization-portability.d.ts +23 -0
  451. package/dist/services/knowledge-portability/organization-portability.d.ts.map +1 -0
  452. package/dist/services/knowledge-portability/organization-portability.js +3795 -0
  453. package/dist/services/knowledge-portability/organization-portability.js.map +1 -0
  454. package/dist/services/knowledge-portability/organization-skills.d.ts +105 -0
  455. package/dist/services/knowledge-portability/organization-skills.d.ts.map +1 -0
  456. package/dist/services/knowledge-portability/organization-skills.js +3172 -0
  457. package/dist/services/knowledge-portability/organization-skills.js.map +1 -0
  458. package/dist/services/live-events.d.ts +17 -0
  459. package/dist/services/live-events.d.ts.map +1 -0
  460. package/dist/services/live-events.js +33 -0
  461. package/dist/services/live-events.js.map +1 -0
  462. package/dist/services/messenger.d.ts +111 -0
  463. package/dist/services/messenger.d.ts.map +1 -0
  464. package/dist/services/messenger.js +774 -0
  465. package/dist/services/messenger.js.map +1 -0
  466. package/dist/services/native-path-picker.d.ts +18 -0
  467. package/dist/services/native-path-picker.d.ts.map +1 -0
  468. package/dist/services/native-path-picker.js +119 -0
  469. package/dist/services/native-path-picker.js.map +1 -0
  470. package/dist/services/operator-profile.d.ts +7 -0
  471. package/dist/services/operator-profile.d.ts.map +1 -0
  472. package/dist/services/operator-profile.js +66 -0
  473. package/dist/services/operator-profile.js.map +1 -0
  474. package/dist/services/organization-export-readme.d.ts +17 -0
  475. package/dist/services/organization-export-readme.d.ts.map +1 -0
  476. package/dist/services/organization-export-readme.js +148 -0
  477. package/dist/services/organization-export-readme.js.map +1 -0
  478. package/dist/services/organization-portability.d.ts +2 -0
  479. package/dist/services/organization-portability.d.ts.map +1 -0
  480. package/dist/services/organization-portability.js +2 -0
  481. package/dist/services/organization-portability.js.map +1 -0
  482. package/dist/services/organization-skills.d.ts +2 -0
  483. package/dist/services/organization-skills.d.ts.map +1 -0
  484. package/dist/services/organization-skills.js +2 -0
  485. package/dist/services/organization-skills.js.map +1 -0
  486. package/dist/services/organization-workspace-browser.d.ts +8 -0
  487. package/dist/services/organization-workspace-browser.d.ts.map +1 -0
  488. package/dist/services/organization-workspace-browser.js +229 -0
  489. package/dist/services/organization-workspace-browser.js.map +1 -0
  490. package/dist/services/organization-workspace.d.ts +5 -0
  491. package/dist/services/organization-workspace.d.ts.map +1 -0
  492. package/dist/services/organization-workspace.js +71 -0
  493. package/dist/services/organization-workspace.js.map +1 -0
  494. package/dist/services/orgs.d.ts +163 -0
  495. package/dist/services/orgs.d.ts.map +1 -0
  496. package/dist/services/orgs.js +327 -0
  497. package/dist/services/orgs.js.map +1 -0
  498. package/dist/services/plugin-capability-validator.d.ts +108 -0
  499. package/dist/services/plugin-capability-validator.d.ts.map +1 -0
  500. package/dist/services/plugin-capability-validator.js +268 -0
  501. package/dist/services/plugin-capability-validator.js.map +1 -0
  502. package/dist/services/plugin-config-validator.d.ts +26 -0
  503. package/dist/services/plugin-config-validator.d.ts.map +1 -0
  504. package/dist/services/plugin-config-validator.js +41 -0
  505. package/dist/services/plugin-config-validator.js.map +1 -0
  506. package/dist/services/plugin-dev-watcher.d.ts +30 -0
  507. package/dist/services/plugin-dev-watcher.d.ts.map +1 -0
  508. package/dist/services/plugin-dev-watcher.js +241 -0
  509. package/dist/services/plugin-dev-watcher.js.map +1 -0
  510. package/dist/services/plugin-event-bus.d.ts +149 -0
  511. package/dist/services/plugin-event-bus.d.ts.map +1 -0
  512. package/dist/services/plugin-event-bus.js +258 -0
  513. package/dist/services/plugin-event-bus.js.map +1 -0
  514. package/dist/services/plugin-host-service-cleanup.d.ts +14 -0
  515. package/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
  516. package/dist/services/plugin-host-service-cleanup.js +37 -0
  517. package/dist/services/plugin-host-service-cleanup.js.map +1 -0
  518. package/dist/services/plugin-host-services.d.ts +13 -0
  519. package/dist/services/plugin-host-services.d.ts.map +1 -0
  520. package/dist/services/plugin-host-services.js +973 -0
  521. package/dist/services/plugin-host-services.js.map +1 -0
  522. package/dist/services/plugin-job-coordinator.d.ts +81 -0
  523. package/dist/services/plugin-job-coordinator.d.ts.map +1 -0
  524. package/dist/services/plugin-job-coordinator.js +172 -0
  525. package/dist/services/plugin-job-coordinator.js.map +1 -0
  526. package/dist/services/plugin-job-scheduler.d.ts +163 -0
  527. package/dist/services/plugin-job-scheduler.d.ts.map +1 -0
  528. package/dist/services/plugin-job-scheduler.js +564 -0
  529. package/dist/services/plugin-job-scheduler.js.map +1 -0
  530. package/dist/services/plugin-job-store.d.ts +208 -0
  531. package/dist/services/plugin-job-store.d.ts.map +1 -0
  532. package/dist/services/plugin-job-store.js +350 -0
  533. package/dist/services/plugin-job-store.js.map +1 -0
  534. package/dist/services/plugin-lifecycle.d.ts +203 -0
  535. package/dist/services/plugin-lifecycle.d.ts.map +1 -0
  536. package/dist/services/plugin-lifecycle.js +476 -0
  537. package/dist/services/plugin-lifecycle.js.map +1 -0
  538. package/dist/services/plugin-loader.d.ts +441 -0
  539. package/dist/services/plugin-loader.d.ts.map +1 -0
  540. package/dist/services/plugin-loader.js +1192 -0
  541. package/dist/services/plugin-loader.js.map +1 -0
  542. package/dist/services/plugin-log-retention.d.ts +20 -0
  543. package/dist/services/plugin-log-retention.d.ts.map +1 -0
  544. package/dist/services/plugin-log-retention.js +63 -0
  545. package/dist/services/plugin-log-retention.js.map +1 -0
  546. package/dist/services/plugin-manifest-validator.d.ts +79 -0
  547. package/dist/services/plugin-manifest-validator.d.ts.map +1 -0
  548. package/dist/services/plugin-manifest-validator.js +84 -0
  549. package/dist/services/plugin-manifest-validator.js.map +1 -0
  550. package/dist/services/plugin-registry.d.ts +2542 -0
  551. package/dist/services/plugin-registry.d.ts.map +1 -0
  552. package/dist/services/plugin-registry.js +539 -0
  553. package/dist/services/plugin-registry.js.map +1 -0
  554. package/dist/services/plugin-runtime-sandbox.d.ts +40 -0
  555. package/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
  556. package/dist/services/plugin-runtime-sandbox.js +154 -0
  557. package/dist/services/plugin-runtime-sandbox.js.map +1 -0
  558. package/dist/services/plugin-secrets-handler.d.ts +81 -0
  559. package/dist/services/plugin-secrets-handler.d.ts.map +1 -0
  560. package/dist/services/plugin-secrets-handler.js +275 -0
  561. package/dist/services/plugin-secrets-handler.js.map +1 -0
  562. package/dist/services/plugin-state-store.d.ts +92 -0
  563. package/dist/services/plugin-state-store.d.ts.map +1 -0
  564. package/dist/services/plugin-state-store.js +190 -0
  565. package/dist/services/plugin-state-store.js.map +1 -0
  566. package/dist/services/plugin-stream-bus.d.ts +29 -0
  567. package/dist/services/plugin-stream-bus.d.ts.map +1 -0
  568. package/dist/services/plugin-stream-bus.js +48 -0
  569. package/dist/services/plugin-stream-bus.js.map +1 -0
  570. package/dist/services/plugin-tool-dispatcher.d.ts +180 -0
  571. package/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
  572. package/dist/services/plugin-tool-dispatcher.js +224 -0
  573. package/dist/services/plugin-tool-dispatcher.js.map +1 -0
  574. package/dist/services/plugin-tool-registry.d.ts +192 -0
  575. package/dist/services/plugin-tool-registry.d.ts.map +1 -0
  576. package/dist/services/plugin-tool-registry.js +224 -0
  577. package/dist/services/plugin-tool-registry.js.map +1 -0
  578. package/dist/services/plugin-worker-manager.d.ts +260 -0
  579. package/dist/services/plugin-worker-manager.d.ts.map +1 -0
  580. package/dist/services/plugin-worker-manager.js +835 -0
  581. package/dist/services/plugin-worker-manager.js.map +1 -0
  582. package/dist/services/projects.d.ts +92 -0
  583. package/dist/services/projects.d.ts.map +1 -0
  584. package/dist/services/projects.js +705 -0
  585. package/dist/services/projects.js.map +1 -0
  586. package/dist/services/quota-windows.d.ts +9 -0
  587. package/dist/services/quota-windows.d.ts.map +1 -0
  588. package/dist/services/quota-windows.js +56 -0
  589. package/dist/services/quota-windows.js.map +1 -0
  590. package/dist/services/resource-catalog.d.ts +29 -0
  591. package/dist/services/resource-catalog.d.ts.map +1 -0
  592. package/dist/services/resource-catalog.js +298 -0
  593. package/dist/services/resource-catalog.js.map +1 -0
  594. package/dist/services/run-intelligence.d.ts +31 -0
  595. package/dist/services/run-intelligence.d.ts.map +1 -0
  596. package/dist/services/run-intelligence.js +315 -0
  597. package/dist/services/run-intelligence.js.map +1 -0
  598. package/dist/services/run-log-store.d.ts +36 -0
  599. package/dist/services/run-log-store.d.ts.map +1 -0
  600. package/dist/services/run-log-store.js +114 -0
  601. package/dist/services/run-log-store.js.map +1 -0
  602. package/dist/services/runtime-kernel/heartbeat.d.ts +882 -0
  603. package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -0
  604. package/dist/services/runtime-kernel/heartbeat.js +4345 -0
  605. package/dist/services/runtime-kernel/heartbeat.js.map +1 -0
  606. package/dist/services/runtime-trace-metadata.d.ts +12 -0
  607. package/dist/services/runtime-trace-metadata.d.ts.map +1 -0
  608. package/dist/services/runtime-trace-metadata.js +13 -0
  609. package/dist/services/runtime-trace-metadata.js.map +1 -0
  610. package/dist/services/secrets.d.ts +511 -0
  611. package/dist/services/secrets.d.ts.map +1 -0
  612. package/dist/services/secrets.js +289 -0
  613. package/dist/services/secrets.js.map +1 -0
  614. package/dist/services/sidebar-badges.d.ts +11 -0
  615. package/dist/services/sidebar-badges.d.ts.map +1 -0
  616. package/dist/services/sidebar-badges.js +43 -0
  617. package/dist/services/sidebar-badges.js.map +1 -0
  618. package/dist/services/work-products.d.ts +14 -0
  619. package/dist/services/work-products.d.ts.map +1 -0
  620. package/dist/services/work-products.js +100 -0
  621. package/dist/services/work-products.js.map +1 -0
  622. package/dist/services/workspace-operation-log-store.d.ts +35 -0
  623. package/dist/services/workspace-operation-log-store.d.ts.map +1 -0
  624. package/dist/services/workspace-operation-log-store.js +115 -0
  625. package/dist/services/workspace-operation-log-store.js.map +1 -0
  626. package/dist/services/workspace-operations.d.ts +46 -0
  627. package/dist/services/workspace-operations.d.ts.map +1 -0
  628. package/dist/services/workspace-operations.js +237 -0
  629. package/dist/services/workspace-operations.js.map +1 -0
  630. package/dist/services/workspace-runtime.d.ts +164 -0
  631. package/dist/services/workspace-runtime.d.ts.map +1 -0
  632. package/dist/services/workspace-runtime.js +1235 -0
  633. package/dist/services/workspace-runtime.js.map +1 -0
  634. package/dist/startup-banner.d.ts +31 -0
  635. package/dist/startup-banner.d.ts.map +1 -0
  636. package/dist/startup-banner.js +121 -0
  637. package/dist/startup-banner.js.map +1 -0
  638. package/dist/storage/index.d.ts +6 -0
  639. package/dist/storage/index.d.ts.map +1 -0
  640. package/dist/storage/index.js +29 -0
  641. package/dist/storage/index.js.map +1 -0
  642. package/dist/storage/local-disk-provider.d.ts +3 -0
  643. package/dist/storage/local-disk-provider.d.ts.map +1 -0
  644. package/dist/storage/local-disk-provider.js +79 -0
  645. package/dist/storage/local-disk-provider.js.map +1 -0
  646. package/dist/storage/provider-registry.d.ts +4 -0
  647. package/dist/storage/provider-registry.d.ts.map +1 -0
  648. package/dist/storage/provider-registry.js +15 -0
  649. package/dist/storage/provider-registry.js.map +1 -0
  650. package/dist/storage/s3-provider.d.ts +11 -0
  651. package/dist/storage/s3-provider.d.ts.map +1 -0
  652. package/dist/storage/s3-provider.js +123 -0
  653. package/dist/storage/s3-provider.js.map +1 -0
  654. package/dist/storage/service.d.ts +3 -0
  655. package/dist/storage/service.d.ts.map +1 -0
  656. package/dist/storage/service.js +120 -0
  657. package/dist/storage/service.js.map +1 -0
  658. package/dist/storage/types.d.ts +55 -0
  659. package/dist/storage/types.d.ts.map +1 -0
  660. package/dist/storage/types.js +2 -0
  661. package/dist/storage/types.js.map +1 -0
  662. package/dist/ui-branding.d.ts +14 -0
  663. package/dist/ui-branding.d.ts.map +1 -0
  664. package/dist/ui-branding.js +201 -0
  665. package/dist/ui-branding.js.map +1 -0
  666. package/dist/version.d.ts +2 -0
  667. package/dist/version.d.ts.map +1 -0
  668. package/dist/version.js +5 -0
  669. package/dist/version.js.map +1 -0
  670. package/package.json +101 -0
  671. package/resources/bundled-skills/para-memory-files/SKILL.md +114 -0
  672. package/resources/bundled-skills/para-memory-files/references/schemas.md +35 -0
  673. package/resources/bundled-skills/rudder/SKILL.md +265 -0
  674. package/resources/bundled-skills/rudder/references/api-reference.md +253 -0
  675. package/resources/bundled-skills/rudder/references/cli-reference.md +67 -0
  676. package/resources/bundled-skills/rudder/references/organization-skills.md +155 -0
  677. package/resources/bundled-skills/rudder-create-agent/SKILL.md +166 -0
  678. package/resources/bundled-skills/rudder-create-agent/references/api-reference.md +172 -0
  679. package/resources/bundled-skills/rudder-create-agent/references/cli-reference.md +126 -0
  680. package/resources/bundled-skills/rudder-create-plugin/SKILL.md +103 -0
  681. package/resources/community-skills/deep-research/README.md +124 -0
  682. package/resources/community-skills/deep-research/SKILL.md +107 -0
  683. package/resources/community-skills/deep-research/reference/continuation.md +169 -0
  684. package/resources/community-skills/deep-research/reference/html-generation.md +103 -0
  685. package/resources/community-skills/deep-research/reference/methodology.md +421 -0
  686. package/resources/community-skills/deep-research/reference/quality-gates.md +197 -0
  687. package/resources/community-skills/deep-research/reference/report-assembly.md +119 -0
  688. package/resources/community-skills/deep-research/reference/weasyprint_guidelines.md +324 -0
  689. package/resources/community-skills/deep-research/requirements.txt +14 -0
  690. package/resources/community-skills/deep-research/scripts/citation_manager.py +177 -0
  691. package/resources/community-skills/deep-research/scripts/md_to_html.py +330 -0
  692. package/resources/community-skills/deep-research/scripts/research_engine.py +582 -0
  693. package/resources/community-skills/deep-research/scripts/source_evaluator.py +292 -0
  694. package/resources/community-skills/deep-research/scripts/validate_report.py +403 -0
  695. package/resources/community-skills/deep-research/scripts/verify_citations.py +426 -0
  696. package/resources/community-skills/deep-research/scripts/verify_html.py +220 -0
  697. package/resources/community-skills/deep-research/templates/mckinsey_report_template.html +443 -0
  698. package/resources/community-skills/deep-research/templates/report_template.md +433 -0
  699. package/resources/community-skills/skill-creator/SKILL.md +9 -0
  700. package/resources/community-skills/software-product-advisor/SKILL.md +290 -0
  701. package/skills/para-memory-files/SKILL.md +114 -0
  702. package/skills/para-memory-files/references/schemas.md +35 -0
  703. package/skills/rudder/SKILL.md +265 -0
  704. package/skills/rudder/references/api-reference.md +253 -0
  705. package/skills/rudder/references/cli-reference.md +67 -0
  706. package/skills/rudder/references/organization-skills.md +155 -0
  707. package/skills/rudder-create-agent/SKILL.md +166 -0
  708. package/skills/rudder-create-agent/references/api-reference.md +172 -0
  709. package/skills/rudder-create-agent/references/cli-reference.md +126 -0
  710. package/skills/rudder-create-plugin/SKILL.md +103 -0
  711. package/ui-dist/android-chrome-192x192.png +0 -0
  712. package/ui-dist/android-chrome-512x512.png +0 -0
  713. package/ui-dist/android-chrome-maskable-512x512.png +0 -0
  714. package/ui-dist/apple-touch-icon.png +0 -0
  715. package/ui-dist/assets/_basePickBy-CjUu04_e.js +1 -0
  716. package/ui-dist/assets/_baseUniq-C9YNlrVG.js +1 -0
  717. package/ui-dist/assets/apl-B4CMkyY2.js +1 -0
  718. package/ui-dist/assets/arc-CSSZfktq.js +1 -0
  719. package/ui-dist/assets/architectureDiagram-2XIMDMQ5-Co78JKUi.js +36 -0
  720. package/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
  721. package/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
  722. package/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
  723. package/ui-dist/assets/blockDiagram-WCTKOSBZ-2KUUIzzz.js +132 -0
  724. package/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
  725. package/ui-dist/assets/c4Diagram-IC4MRINW-C6pq8tPP.js +10 -0
  726. package/ui-dist/assets/channel-BEODbRMk.js +1 -0
  727. package/ui-dist/assets/chunk-4BX2VUAB-ojCLkixe.js +1 -0
  728. package/ui-dist/assets/chunk-55IACEB6-MGONqzmz.js +1 -0
  729. package/ui-dist/assets/chunk-FMBD7UC4-CmGuLv2P.js +15 -0
  730. package/ui-dist/assets/chunk-JSJVCQXG-BNBefVr6.js +1 -0
  731. package/ui-dist/assets/chunk-KX2RTZJC-DIGBQLn5.js +1 -0
  732. package/ui-dist/assets/chunk-NQ4KR5QH-_KEutsaQ.js +220 -0
  733. package/ui-dist/assets/chunk-QZHKN3VN-B6pzyuwm.js +1 -0
  734. package/ui-dist/assets/chunk-WL4C6EOR-B8NDzcfm.js +189 -0
  735. package/ui-dist/assets/classDiagram-VBA2DB6C-CsSqaaRj.js +1 -0
  736. package/ui-dist/assets/classDiagram-v2-RAHNMMFH-CsSqaaRj.js +1 -0
  737. package/ui-dist/assets/clike-B9uivgTg.js +1 -0
  738. package/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
  739. package/ui-dist/assets/clone-5oWMCI0u.js +1 -0
  740. package/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
  741. package/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
  742. package/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
  743. package/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
  744. package/ui-dist/assets/cose-bilkent-S5V4N54A-B1t6ulcV.js +1 -0
  745. package/ui-dist/assets/crystal-SjHAIU92.js +1 -0
  746. package/ui-dist/assets/css-BnMrqG3P.js +1 -0
  747. package/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
  748. package/ui-dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  749. package/ui-dist/assets/d-pRatUO7H.js +1 -0
  750. package/ui-dist/assets/dagre-KLK3FWXG-DWVC5_HJ.js +4 -0
  751. package/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  752. package/ui-dist/assets/diagram-E7M64L7V-C4ztYLox.js +24 -0
  753. package/ui-dist/assets/diagram-IFDJBPK2-DtWBGLnA.js +43 -0
  754. package/ui-dist/assets/diagram-P4PSJMXO-BiqiI4Df.js +24 -0
  755. package/ui-dist/assets/diff-DbItnlRl.js +1 -0
  756. package/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
  757. package/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
  758. package/ui-dist/assets/dylan-DwRh75JA.js +1 -0
  759. package/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
  760. package/ui-dist/assets/ecl-Cabwm37j.js +1 -0
  761. package/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
  762. package/ui-dist/assets/elm-vLlmbW-K.js +1 -0
  763. package/ui-dist/assets/erDiagram-INFDFZHY-CUhr9rIh.js +70 -0
  764. package/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
  765. package/ui-dist/assets/factor-kuTfRLto.js +1 -0
  766. package/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
  767. package/ui-dist/assets/flowDiagram-PKNHOUZH-BEqBmNL-.js +162 -0
  768. package/ui-dist/assets/forth-Ffai-XNe.js +1 -0
  769. package/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
  770. package/ui-dist/assets/ganttDiagram-A5KZAMGK-CdeWhdno.js +292 -0
  771. package/ui-dist/assets/gas-Bneqetm1.js +1 -0
  772. package/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
  773. package/ui-dist/assets/gitGraphDiagram-K3NZZRJ6-CgG66QFg.js +65 -0
  774. package/ui-dist/assets/graph-rmownl79.js +1 -0
  775. package/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
  776. package/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
  777. package/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
  778. package/ui-dist/assets/http-DBlCnlav.js +1 -0
  779. package/ui-dist/assets/idl-BEugSyMb.js +1 -0
  780. package/ui-dist/assets/index-B1YyDqaG.js +1 -0
  781. package/ui-dist/assets/index-B7exNxYd.js +1 -0
  782. package/ui-dist/assets/index-BIuriVDl.js +1 -0
  783. package/ui-dist/assets/index-BT9rfwYt.js +1 -0
  784. package/ui-dist/assets/index-BZhmacJG.js +1 -0
  785. package/ui-dist/assets/index-B_ebS3U_.js +3 -0
  786. package/ui-dist/assets/index-BnQqZOsc.js +1 -0
  787. package/ui-dist/assets/index-BwPbAax6.js +1 -0
  788. package/ui-dist/assets/index-C5i670o5.js +1 -0
  789. package/ui-dist/assets/index-C9KwE7Yr.js +1 -0
  790. package/ui-dist/assets/index-CDId_UjP.js +1 -0
  791. package/ui-dist/assets/index-CI9ydSGM.js +1 -0
  792. package/ui-dist/assets/index-CKpm3WGI.css +1 -0
  793. package/ui-dist/assets/index-CMP_bzP3.js +2 -0
  794. package/ui-dist/assets/index-CRcHIoCW.js +1 -0
  795. package/ui-dist/assets/index-DZqNY-Lg.js +1 -0
  796. package/ui-dist/assets/index-DbDKJhW-.js +7 -0
  797. package/ui-dist/assets/index-Dkg6MwQ_.js +1 -0
  798. package/ui-dist/assets/index-Dn0iitKg.js +1 -0
  799. package/ui-dist/assets/index-GvHywIOA.js +1323 -0
  800. package/ui-dist/assets/index-WtX4Y4Fx.js +13 -0
  801. package/ui-dist/assets/index-iyC5PHC3.js +6 -0
  802. package/ui-dist/assets/index-jMlzlqoV.js +1 -0
  803. package/ui-dist/assets/index-pTIOLGTe.js +1 -0
  804. package/ui-dist/assets/infoDiagram-LFFYTUFH-CEhdbTYQ.js +2 -0
  805. package/ui-dist/assets/init-Gi6I4Gst.js +1 -0
  806. package/ui-dist/assets/ishikawaDiagram-PHBUUO56-g9GiiXI2.js +70 -0
  807. package/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
  808. package/ui-dist/assets/journeyDiagram-4ABVD52K-CheeZzlg.js +139 -0
  809. package/ui-dist/assets/julia-DuME0IfC.js +1 -0
  810. package/ui-dist/assets/kanban-definition-K7BYSVSG-BTpuAgUJ.js +89 -0
  811. package/ui-dist/assets/katex-B1X10hvy.js +261 -0
  812. package/ui-dist/assets/layout-CuBgufef.js +1 -0
  813. package/ui-dist/assets/linear-CnXO6wXw.js +1 -0
  814. package/ui-dist/assets/livescript-BwQOo05w.js +1 -0
  815. package/ui-dist/assets/lua-BgMRiT3U.js +1 -0
  816. package/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
  817. package/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
  818. package/ui-dist/assets/mermaid.core-DVaYxfh9.js +255 -0
  819. package/ui-dist/assets/mindmap-definition-YRQLILUH-00nAuexq.js +68 -0
  820. package/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
  821. package/ui-dist/assets/mllike-CXdrOF99.js +1 -0
  822. package/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
  823. package/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
  824. package/ui-dist/assets/mumps-BT43cFF4.js +1 -0
  825. package/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
  826. package/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
  827. package/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
  828. package/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
  829. package/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
  830. package/ui-dist/assets/oz-BzwKVEFT.js +1 -0
  831. package/ui-dist/assets/pascal--L3eBynH.js +1 -0
  832. package/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
  833. package/ui-dist/assets/pieDiagram-SKSYHLDU-NaOgRqIj.js +30 -0
  834. package/ui-dist/assets/pig-CevX1Tat.js +1 -0
  835. package/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
  836. package/ui-dist/assets/properties-C78fOPTZ.js +1 -0
  837. package/ui-dist/assets/protobuf-ChK-085T.js +1 -0
  838. package/ui-dist/assets/pug-DeIclll2.js +1 -0
  839. package/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
  840. package/ui-dist/assets/python-BuPzkPfP.js +1 -0
  841. package/ui-dist/assets/q-pXgVlZs6.js +1 -0
  842. package/ui-dist/assets/quadrantDiagram-337W2JSQ-Bnf9OCW0.js +7 -0
  843. package/ui-dist/assets/r-B6wPVr8A.js +1 -0
  844. package/ui-dist/assets/requirementDiagram-Z7DCOOCP-BiacZTTh.js +73 -0
  845. package/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
  846. package/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
  847. package/ui-dist/assets/sankeyDiagram-WA2Y5GQK-DOuD4D2Q.js +10 -0
  848. package/ui-dist/assets/sas-B4kiWyti.js +1 -0
  849. package/ui-dist/assets/scheme-C41bIUwD.js +1 -0
  850. package/ui-dist/assets/sequenceDiagram-2WXFIKYE-oV3M_w-H.js +145 -0
  851. package/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
  852. package/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
  853. package/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
  854. package/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
  855. package/ui-dist/assets/solr-DehyRSwq.js +1 -0
  856. package/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
  857. package/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
  858. package/ui-dist/assets/sql-D0XecflT.js +1 -0
  859. package/ui-dist/assets/stateDiagram-RAJIS63D-CdRc2Pqb.js +1 -0
  860. package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-CIMHFJYg.js +1 -0
  861. package/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
  862. package/ui-dist/assets/stylus-B533Al4x.js +1 -0
  863. package/ui-dist/assets/swift-BzpIVaGY.js +1 -0
  864. package/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
  865. package/ui-dist/assets/textile-CnDTJFAw.js +1 -0
  866. package/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
  867. package/ui-dist/assets/tiki-DGYXhP31.js +1 -0
  868. package/ui-dist/assets/timeline-definition-YZTLITO2-BCWQDIwt.js +61 -0
  869. package/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
  870. package/ui-dist/assets/treemap-KZPCXAKY-BvsIxXAi.js +162 -0
  871. package/ui-dist/assets/troff-wAsdV37c.js +1 -0
  872. package/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
  873. package/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  874. package/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
  875. package/ui-dist/assets/vb-CmGdzxic.js +1 -0
  876. package/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
  877. package/ui-dist/assets/velocity-D8B20fx6.js +1 -0
  878. package/ui-dist/assets/vennDiagram-LZ73GAT5-BzibHs4r.js +34 -0
  879. package/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
  880. package/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
  881. package/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
  882. package/ui-dist/assets/xquery-DzFWVndE.js +1 -0
  883. package/ui-dist/assets/xychartDiagram-JWTSCODW-CX_Xt_y-.js +7 -0
  884. package/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
  885. package/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
  886. package/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
  887. package/ui-dist/brands/opencode-logo-light-square.svg +18 -0
  888. package/ui-dist/favicon-16x16.png +0 -0
  889. package/ui-dist/favicon-32x32.png +0 -0
  890. package/ui-dist/favicon-dev-16x16.png +0 -0
  891. package/ui-dist/favicon-dev-32x32.png +0 -0
  892. package/ui-dist/favicon-dev.ico +0 -0
  893. package/ui-dist/favicon.ico +0 -0
  894. package/ui-dist/favicon.svg +1 -0
  895. package/ui-dist/index.html +61 -0
  896. package/ui-dist/rudder-logo.png +0 -0
  897. package/ui-dist/site.webmanifest +30 -0
  898. package/ui-dist/sw.js +42 -0
  899. package/ui-dist/worktree-favicon-16x16.png +0 -0
  900. package/ui-dist/worktree-favicon-32x32.png +0 -0
  901. package/ui-dist/worktree-favicon.ico +0 -0
  902. package/ui-dist/worktree-favicon.svg +1 -0
@@ -0,0 +1,1776 @@
1
+ /**
2
+ * @fileoverview Plugin management REST API routes
3
+ *
4
+ * This module provides Express routes for managing the complete plugin lifecycle:
5
+ * - Listing and filtering plugins by status
6
+ * - Installing plugins from npm or local paths
7
+ * - Uninstalling plugins (soft delete or hard purge)
8
+ * - Enabling/disabling plugins
9
+ * - Running health diagnostics
10
+ * - Upgrading plugins
11
+ * - Retrieving UI slot contributions for frontend rendering
12
+ * - Discovering and executing plugin-contributed agent tools
13
+ *
14
+ * All routes require board-level authentication (assertBoard middleware).
15
+ *
16
+ * @module server/routes/plugins
17
+ * @see doc/plugins/PLUGIN_SPEC.md for the full plugin specification
18
+ */
19
+ import { existsSync } from "node:fs";
20
+ import path from "node:path";
21
+ import { randomUUID } from "node:crypto";
22
+ import { fileURLToPath } from "node:url";
23
+ import { Router } from "express";
24
+ import { and, desc, eq, gte } from "drizzle-orm";
25
+ import { organizations, pluginLogs, pluginWebhookDeliveries } from "@rudderhq/db";
26
+ import { PLUGIN_STATUSES, } from "@rudderhq/shared";
27
+ import { pluginRegistryService } from "../services/plugin-registry.js";
28
+ import { pluginLifecycleManager } from "../services/plugin-lifecycle.js";
29
+ import { getPluginUiContributionMetadata } from "../services/plugin-loader.js";
30
+ import { logActivity } from "../services/activity-log.js";
31
+ import { publishGlobalLiveEvent } from "../services/live-events.js";
32
+ import { JsonRpcCallError, PLUGIN_RPC_ERROR_CODES } from "@rudderhq/plugin-sdk";
33
+ import { assertBoard, assertCompanyAccess, getActorInfo } from "./authz.js";
34
+ import { validateInstanceConfig } from "../services/plugin-config-validator.js";
35
+ /** UUID v4 regex used for plugin ID route resolution. */
36
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
37
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
38
+ const REPO_ROOT = path.resolve(__dirname, "../../..");
39
+ const BUNDLED_PLUGIN_EXAMPLES = [
40
+ {
41
+ packageName: "@rudderhq/plugin-file-browser-example",
42
+ pluginKey: "rudder-file-browser-example",
43
+ displayName: "File Browser (Example)",
44
+ description: "Example plugin that adds a Files link in project navigation plus a project detail file browser.",
45
+ localPath: "packages/plugins/examples/plugin-file-browser-example",
46
+ tag: "example",
47
+ },
48
+ {
49
+ packageName: "@rudderhq/plugin-kitchen-sink-example",
50
+ pluginKey: "rudder-kitchen-sink-example",
51
+ displayName: "Kitchen Sink (Example)",
52
+ description: "Reference plugin that demonstrates the current Rudder plugin API surface, bridge flows, UI extension surfaces, jobs, webhooks, tools, streams, and trusted local workspace/process demos.",
53
+ localPath: "packages/plugins/examples/plugin-kitchen-sink-example",
54
+ tag: "example",
55
+ },
56
+ ];
57
+ function listBundledPluginExamples() {
58
+ return BUNDLED_PLUGIN_EXAMPLES.flatMap((plugin) => {
59
+ const absoluteLocalPath = path.resolve(REPO_ROOT, plugin.localPath);
60
+ if (!existsSync(absoluteLocalPath))
61
+ return [];
62
+ return [{ ...plugin, localPath: absoluteLocalPath }];
63
+ });
64
+ }
65
+ /**
66
+ * Resolve a plugin by either database ID or plugin key.
67
+ *
68
+ * Lookup order:
69
+ * - UUID-like IDs: getById first, then getByKey.
70
+ * - Scoped package keys (e.g. "@scope/name"): getByKey only, never getById.
71
+ * - Other non-UUID IDs: try getById first (test/memory registries may allow this),
72
+ * then fallback to getByKey. Any UUID parse error from getById is ignored.
73
+ *
74
+ * @param registry - The plugin registry service instance
75
+ * @param pluginId - Either a database UUID or plugin key (manifest id)
76
+ * @returns Plugin record or null if not found
77
+ */
78
+ async function resolvePlugin(registry, pluginId) {
79
+ const isUuid = UUID_REGEX.test(pluginId);
80
+ const isScopedPackageKey = pluginId.startsWith("@") || pluginId.includes("/");
81
+ // Scoped package IDs are valid plugin keys but invalid UUIDs.
82
+ // Skip getById() entirely to avoid Postgres uuid parse errors.
83
+ if (isScopedPackageKey && !isUuid) {
84
+ return registry.getByKey(pluginId);
85
+ }
86
+ try {
87
+ const byId = await registry.getById(pluginId);
88
+ if (byId)
89
+ return byId;
90
+ }
91
+ catch (error) {
92
+ const maybeCode = typeof error === "object" && error !== null && "code" in error
93
+ ? error.code
94
+ : undefined;
95
+ // Ignore invalid UUID cast errors and continue with key lookup.
96
+ if (maybeCode !== "22P02") {
97
+ throw error;
98
+ }
99
+ }
100
+ return registry.getByKey(pluginId);
101
+ }
102
+ /**
103
+ * Create Express router for plugin management API.
104
+ *
105
+ * Routes provided:
106
+ *
107
+ * | Method | Path | Description |
108
+ * |--------|------|-------------|
109
+ * | GET | /plugins | List all plugins (optional ?status= filter) |
110
+ * | GET | /plugins/ui-contributions | Get UI slots from ready plugins |
111
+ * | GET | /plugins/:pluginId | Get single plugin by ID or key |
112
+ * | POST | /plugins/install | Install from npm or local path |
113
+ * | DELETE | /plugins/:pluginId | Uninstall (optional ?purge=true) |
114
+ * | POST | /plugins/:pluginId/enable | Enable a plugin |
115
+ * | POST | /plugins/:pluginId/disable | Disable a plugin |
116
+ * | GET | /plugins/:pluginId/health | Run health diagnostics |
117
+ * | POST | /plugins/:pluginId/upgrade | Upgrade to newer version |
118
+ * | GET | /plugins/:pluginId/jobs | List jobs for a plugin |
119
+ * | GET | /plugins/:pluginId/jobs/:jobId/runs | List runs for a job |
120
+ * | POST | /plugins/:pluginId/jobs/:jobId/trigger | Manually trigger a job |
121
+ * | POST | /plugins/:pluginId/webhooks/:endpointKey | Receive inbound webhook |
122
+ * | GET | /plugins/tools | List all available plugin tools |
123
+ * | GET | /plugins/tools?pluginId=... | List tools for a specific plugin |
124
+ * | POST | /plugins/tools/execute | Execute a plugin tool |
125
+ * | GET | /plugins/:pluginId/config | Get current plugin config |
126
+ * | POST | /plugins/:pluginId/config | Save (upsert) plugin config |
127
+ * | POST | /plugins/:pluginId/config/test | Test config via validateConfig RPC |
128
+ * | POST | /plugins/:pluginId/bridge/data | Proxy getData to plugin worker |
129
+ * | POST | /plugins/:pluginId/bridge/action | Proxy performAction to plugin worker |
130
+ * | POST | /plugins/:pluginId/data/:key | Proxy getData to plugin worker (key in URL) |
131
+ * | POST | /plugins/:pluginId/actions/:key | Proxy performAction to plugin worker (key in URL) |
132
+ * | GET | /plugins/:pluginId/bridge/stream/:channel | SSE stream from worker to UI |
133
+ * | GET | /plugins/:pluginId/dashboard | Aggregated health dashboard data |
134
+ *
135
+ * **Route Ordering Note:** Static routes (like /ui-contributions, /tools) must be
136
+ * registered before parameterized routes (like /:pluginId) to prevent Express from
137
+ * matching them as a plugin ID.
138
+ *
139
+ * @param db - Database connection instance
140
+ * @param jobDeps - Optional job scheduling dependencies
141
+ * @param webhookDeps - Optional webhook ingestion dependencies
142
+ * @param toolDeps - Optional tool dispatcher dependencies
143
+ * @param bridgeDeps - Optional bridge proxy dependencies for getData/performAction
144
+ * @returns Express router with plugin routes mounted
145
+ */
146
+ export function pluginRoutes(db, loader, jobDeps, webhookDeps, toolDeps, bridgeDeps) {
147
+ const router = Router();
148
+ const registry = pluginRegistryService(db);
149
+ const lifecycle = pluginLifecycleManager(db, {
150
+ loader,
151
+ workerManager: bridgeDeps?.workerManager ?? webhookDeps?.workerManager,
152
+ });
153
+ async function resolvePluginAuditCompanyIds(req) {
154
+ if (typeof db.select === "function") {
155
+ const rows = await db
156
+ .select({ id: organizations.id })
157
+ .from(organizations);
158
+ return rows.map((row) => row.id);
159
+ }
160
+ if (req.actor.type === "agent" && req.actor.orgId) {
161
+ return [req.actor.orgId];
162
+ }
163
+ if (req.actor.type === "board") {
164
+ return req.actor.orgIds ?? [];
165
+ }
166
+ return [];
167
+ }
168
+ async function logPluginMutationActivity(req, action, entityId, details) {
169
+ const orgIds = await resolvePluginAuditCompanyIds(req);
170
+ if (orgIds.length === 0)
171
+ return;
172
+ const actor = getActorInfo(req);
173
+ await Promise.all(orgIds.map((orgId) => logActivity(db, {
174
+ orgId,
175
+ actorType: actor.actorType,
176
+ actorId: actor.actorId,
177
+ agentId: actor.agentId,
178
+ runId: actor.runId,
179
+ action,
180
+ entityType: "plugin",
181
+ entityId,
182
+ details,
183
+ })));
184
+ }
185
+ /**
186
+ * GET /api/plugins
187
+ *
188
+ * List all installed plugins, optionally filtered by lifecycle status.
189
+ *
190
+ * Query params:
191
+ * - `status` (optional): Filter by lifecycle status. Must be one of the
192
+ * values in `PLUGIN_STATUSES` (`installed`, `ready`, `error`,
193
+ * `upgrade_pending`, `uninstalled`). Returns HTTP 400 if the value is
194
+ * not a recognised status string.
195
+ *
196
+ * Response: `PluginRecord[]`
197
+ */
198
+ router.get("/plugins", async (req, res) => {
199
+ assertBoard(req);
200
+ const rawStatus = req.query.status;
201
+ if (rawStatus !== undefined) {
202
+ if (typeof rawStatus !== "string" || !PLUGIN_STATUSES.includes(rawStatus)) {
203
+ res.status(400).json({
204
+ error: `Invalid status '${String(rawStatus)}'. Must be one of: ${PLUGIN_STATUSES.join(", ")}`,
205
+ });
206
+ return;
207
+ }
208
+ }
209
+ const status = rawStatus;
210
+ const plugins = status
211
+ ? await registry.listByStatus(status)
212
+ : await registry.listInstalled();
213
+ res.json(plugins);
214
+ });
215
+ /**
216
+ * GET /api/plugins/examples
217
+ *
218
+ * Return first-party example plugins bundled in this repo, if present.
219
+ * These can be installed through the normal local-path install flow.
220
+ */
221
+ router.get("/plugins/examples", async (req, res) => {
222
+ assertBoard(req);
223
+ res.json(listBundledPluginExamples());
224
+ });
225
+ // IMPORTANT: Static routes must come before parameterized routes
226
+ // to avoid Express matching "ui-contributions" as a :pluginId
227
+ /**
228
+ * GET /api/plugins/ui-contributions
229
+ *
230
+ * Return UI contributions from all plugins in 'ready' state.
231
+ * Used by the frontend to discover plugin UI slots and launcher metadata.
232
+ *
233
+ * The response is normalized for the frontend slot host:
234
+ * - Only includes plugins with at least one declared UI slot or launcher
235
+ * - Excludes plugins with null/missing manifestJson (defensive)
236
+ * - Slots are extracted from manifest.ui.slots
237
+ * - Launchers are aggregated from legacy manifest.launchers and manifest.ui.launchers
238
+ *
239
+ * Example response:
240
+ * ```json
241
+ * [
242
+ * {
243
+ * "pluginId": "plg_123",
244
+ * "pluginKey": "rudder.claude-usage",
245
+ * "displayName": "Claude Usage",
246
+ * "version": "1.0.0",
247
+ * "uiEntryFile": "index.js",
248
+ * "slots": [],
249
+ * "launchers": [
250
+ * {
251
+ * "id": "claude-usage-toolbar",
252
+ * "displayName": "Claude Usage",
253
+ * "placementZone": "toolbarButton",
254
+ * "action": { "type": "openModal", "target": "ClaudeUsageView" },
255
+ * "render": { "environment": "hostOverlay", "bounds": "wide" }
256
+ * }
257
+ * ]
258
+ * }
259
+ * ]
260
+ * ```
261
+ *
262
+ * Response: PluginUiContribution[]
263
+ */
264
+ router.get("/plugins/ui-contributions", async (req, res) => {
265
+ assertBoard(req);
266
+ const plugins = await registry.listByStatus("ready");
267
+ const contributions = plugins
268
+ .map((plugin) => {
269
+ // Safety check: manifestJson should always exist for ready plugins, but guard against null
270
+ const manifest = plugin.manifestJson;
271
+ if (!manifest)
272
+ return null;
273
+ const uiMetadata = getPluginUiContributionMetadata(manifest);
274
+ if (!uiMetadata)
275
+ return null;
276
+ return {
277
+ pluginId: plugin.id,
278
+ pluginKey: plugin.pluginKey,
279
+ displayName: manifest.displayName,
280
+ version: plugin.version,
281
+ updatedAt: plugin.updatedAt.toISOString(),
282
+ uiEntryFile: uiMetadata.uiEntryFile,
283
+ slots: uiMetadata.slots,
284
+ launchers: uiMetadata.launchers,
285
+ };
286
+ })
287
+ .filter((item) => item !== null);
288
+ res.json(contributions);
289
+ });
290
+ // ===========================================================================
291
+ // Tool discovery and execution routes
292
+ // ===========================================================================
293
+ /**
294
+ * GET /api/plugins/tools
295
+ *
296
+ * List all available plugin-contributed tools in an agent-friendly format.
297
+ *
298
+ * Query params:
299
+ * - `pluginId` (optional): Filter to tools from a specific plugin
300
+ *
301
+ * Response: `AgentToolDescriptor[]`
302
+ * Errors: 501 if tool dispatcher is not configured
303
+ */
304
+ router.get("/plugins/tools", async (req, res) => {
305
+ assertBoard(req);
306
+ if (!toolDeps) {
307
+ res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
308
+ return;
309
+ }
310
+ const pluginId = req.query.pluginId;
311
+ const filter = pluginId ? { pluginId } : undefined;
312
+ const tools = toolDeps.toolDispatcher.listToolsForAgent(filter);
313
+ res.json(tools);
314
+ });
315
+ /**
316
+ * POST /api/plugins/tools/execute
317
+ *
318
+ * Execute a plugin-contributed tool by its namespaced name.
319
+ *
320
+ * This is the primary endpoint used by the agent service to invoke
321
+ * plugin tools during an agent run.
322
+ *
323
+ * Request body:
324
+ * - `tool`: Fully namespaced tool name (e.g., "acme.linear:search-issues")
325
+ * - `parameters`: Parameters matching the tool's declared JSON Schema
326
+ * - `runContext`: Agent run context with agentId, runId, orgId, projectId
327
+ *
328
+ * Response: `ToolExecutionResult`
329
+ * Errors:
330
+ * - 400 if request validation fails
331
+ * - 404 if tool is not found
332
+ * - 501 if tool dispatcher is not configured
333
+ * - 502 if the plugin worker is unavailable or the RPC call fails
334
+ */
335
+ router.post("/plugins/tools/execute", async (req, res) => {
336
+ assertBoard(req);
337
+ if (!toolDeps) {
338
+ res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
339
+ return;
340
+ }
341
+ const body = req.body;
342
+ if (!body) {
343
+ res.status(400).json({ error: "Request body is required" });
344
+ return;
345
+ }
346
+ const { tool, parameters, runContext } = body;
347
+ // Validate required fields
348
+ if (!tool || typeof tool !== "string") {
349
+ res.status(400).json({ error: '"tool" is required and must be a string' });
350
+ return;
351
+ }
352
+ if (!runContext || typeof runContext !== "object") {
353
+ res.status(400).json({ error: '"runContext" is required and must be an object' });
354
+ return;
355
+ }
356
+ if (!runContext.agentId || !runContext.runId || !runContext.orgId || !runContext.projectId) {
357
+ res.status(400).json({
358
+ error: '"runContext" must include agentId, runId, orgId, and projectId',
359
+ });
360
+ return;
361
+ }
362
+ assertCompanyAccess(req, runContext.orgId);
363
+ // Verify the tool exists
364
+ const registeredTool = toolDeps.toolDispatcher.getTool(tool);
365
+ if (!registeredTool) {
366
+ res.status(404).json({ error: `Tool "${tool}" not found` });
367
+ return;
368
+ }
369
+ try {
370
+ const result = await toolDeps.toolDispatcher.executeTool(tool, parameters ?? {}, runContext);
371
+ res.json(result);
372
+ }
373
+ catch (err) {
374
+ const message = err instanceof Error ? err.message : String(err);
375
+ // Distinguish between "worker not running" (502) and other errors (500)
376
+ if (message.includes("not running") || message.includes("worker")) {
377
+ res.status(502).json({ error: message });
378
+ }
379
+ else {
380
+ res.status(500).json({ error: message });
381
+ }
382
+ }
383
+ });
384
+ /**
385
+ * POST /api/plugins/install
386
+ *
387
+ * Install a plugin from npm or a local filesystem path.
388
+ *
389
+ * Request body:
390
+ * - packageName: npm package name or local path (required)
391
+ * - version: Target version for npm packages (optional)
392
+ * - isLocalPath: Set true if packageName is a local path
393
+ *
394
+ * The installer:
395
+ * 1. Downloads from npm or loads from local path
396
+ * 2. Validates the manifest (schema + capability consistency)
397
+ * 3. Registers in the database
398
+ * 4. Transitions to `ready` state if no new capability approval is needed
399
+ *
400
+ * Response: `PluginRecord`
401
+ *
402
+ * Errors:
403
+ * - `400` — validation failure or install error (package not found, bad manifest, etc.)
404
+ * - `500` — installation succeeded but manifest is missing (indicates a loader bug)
405
+ */
406
+ router.post("/plugins/install", async (req, res) => {
407
+ assertBoard(req);
408
+ const { packageName, version, isLocalPath } = req.body;
409
+ // Input validation
410
+ if (!packageName || typeof packageName !== "string") {
411
+ res.status(400).json({ error: "packageName is required and must be a string" });
412
+ return;
413
+ }
414
+ if (version !== undefined && typeof version !== "string") {
415
+ res.status(400).json({ error: "version must be a string if provided" });
416
+ return;
417
+ }
418
+ if (isLocalPath !== undefined && typeof isLocalPath !== "boolean") {
419
+ res.status(400).json({ error: "isLocalPath must be a boolean if provided" });
420
+ return;
421
+ }
422
+ // Validate package name format
423
+ const trimmedPackage = packageName.trim();
424
+ if (trimmedPackage.length === 0) {
425
+ res.status(400).json({ error: "packageName cannot be empty" });
426
+ return;
427
+ }
428
+ // Basic security check for package name (prevent injection)
429
+ if (!isLocalPath && /[<>:"|?*]/.test(trimmedPackage)) {
430
+ res.status(400).json({ error: "packageName contains invalid characters" });
431
+ return;
432
+ }
433
+ try {
434
+ const installOptions = isLocalPath
435
+ ? { localPath: trimmedPackage }
436
+ : { packageName: trimmedPackage, version: version?.trim() };
437
+ const discovered = await loader.installPlugin(installOptions);
438
+ if (!discovered.manifest) {
439
+ res.status(500).json({ error: "Plugin installed but manifest is missing" });
440
+ return;
441
+ }
442
+ // Transition to ready state
443
+ const existingPlugin = await registry.getByKey(discovered.manifest.id);
444
+ if (existingPlugin) {
445
+ await lifecycle.load(existingPlugin.id);
446
+ const updated = await registry.getById(existingPlugin.id);
447
+ await logPluginMutationActivity(req, "plugin.installed", existingPlugin.id, {
448
+ pluginId: existingPlugin.id,
449
+ pluginKey: existingPlugin.pluginKey,
450
+ packageName: updated?.packageName ?? existingPlugin.packageName,
451
+ version: updated?.version ?? existingPlugin.version,
452
+ source: isLocalPath ? "local_path" : "npm",
453
+ });
454
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: existingPlugin.id, action: "installed" } });
455
+ res.json(updated);
456
+ }
457
+ else {
458
+ // This shouldn't happen since installPlugin already registers in the DB
459
+ res.status(500).json({ error: "Plugin installed but not found in registry" });
460
+ }
461
+ }
462
+ catch (err) {
463
+ const message = err instanceof Error ? err.message : String(err);
464
+ res.status(400).json({ error: message });
465
+ }
466
+ });
467
+ /**
468
+ * Map a worker RPC error to a bridge-level error code.
469
+ *
470
+ * JsonRpcCallError carries numeric codes from the plugin RPC error code space.
471
+ * This helper maps them to the string error codes defined in PluginBridgeErrorCode.
472
+ *
473
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
474
+ */
475
+ function mapRpcErrorToBridgeError(err) {
476
+ if (err instanceof JsonRpcCallError) {
477
+ switch (err.code) {
478
+ case PLUGIN_RPC_ERROR_CODES.WORKER_UNAVAILABLE:
479
+ return {
480
+ code: "WORKER_UNAVAILABLE",
481
+ message: err.message,
482
+ details: err.data,
483
+ };
484
+ case PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED:
485
+ return {
486
+ code: "CAPABILITY_DENIED",
487
+ message: err.message,
488
+ details: err.data,
489
+ };
490
+ case PLUGIN_RPC_ERROR_CODES.TIMEOUT:
491
+ return {
492
+ code: "TIMEOUT",
493
+ message: err.message,
494
+ details: err.data,
495
+ };
496
+ case PLUGIN_RPC_ERROR_CODES.WORKER_ERROR:
497
+ return {
498
+ code: "WORKER_ERROR",
499
+ message: err.message,
500
+ details: err.data,
501
+ };
502
+ default:
503
+ return {
504
+ code: "UNKNOWN",
505
+ message: err.message,
506
+ details: err.data,
507
+ };
508
+ }
509
+ }
510
+ const message = err instanceof Error ? err.message : String(err);
511
+ // Worker not running — surface as WORKER_UNAVAILABLE
512
+ if (message.includes("not running") || message.includes("not registered")) {
513
+ return {
514
+ code: "WORKER_UNAVAILABLE",
515
+ message,
516
+ };
517
+ }
518
+ return {
519
+ code: "UNKNOWN",
520
+ message,
521
+ };
522
+ }
523
+ /**
524
+ * POST /api/plugins/:pluginId/bridge/data
525
+ *
526
+ * Proxy a `getData` call from the plugin UI to the plugin worker.
527
+ *
528
+ * This is the server-side half of the `usePluginData(key, params)` bridge hook.
529
+ * The frontend sends a POST with the data key and optional params; the host
530
+ * forwards the call to the worker via the `getData` RPC method and returns
531
+ * the result.
532
+ *
533
+ * Request body:
534
+ * - `key`: Plugin-defined data key (e.g. `"sync-health"`)
535
+ * - `params`: Optional query parameters forwarded to the worker handler
536
+ *
537
+ * Response: The raw result from the worker's `getData` handler
538
+ *
539
+ * Error response body follows the `PluginBridgeError` shape:
540
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
541
+ *
542
+ * Errors:
543
+ * - 400 if request validation fails
544
+ * - 404 if plugin not found
545
+ * - 501 if bridge deps are not configured
546
+ * - 502 if the worker is unavailable or returns an error
547
+ *
548
+ * @see PLUGIN_SPEC.md §13.8 — `getData`
549
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
550
+ */
551
+ router.post("/plugins/:pluginId/bridge/data", async (req, res) => {
552
+ assertBoard(req);
553
+ if (!bridgeDeps) {
554
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
555
+ return;
556
+ }
557
+ const { pluginId } = req.params;
558
+ // Resolve plugin
559
+ const plugin = await resolvePlugin(registry, pluginId);
560
+ if (!plugin) {
561
+ res.status(404).json({ error: "Plugin not found" });
562
+ return;
563
+ }
564
+ // Validate plugin is in ready state
565
+ if (plugin.status !== "ready") {
566
+ const bridgeError = {
567
+ code: "WORKER_UNAVAILABLE",
568
+ message: `Plugin is not ready (current status: ${plugin.status})`,
569
+ };
570
+ res.status(502).json(bridgeError);
571
+ return;
572
+ }
573
+ // Validate request body
574
+ const body = req.body;
575
+ if (!body || !body.key || typeof body.key !== "string") {
576
+ res.status(400).json({ error: '"key" is required and must be a string' });
577
+ return;
578
+ }
579
+ if (body.orgId) {
580
+ assertCompanyAccess(req, body.orgId);
581
+ }
582
+ try {
583
+ const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
584
+ key: body.key,
585
+ params: body.params ?? {},
586
+ renderEnvironment: body.renderEnvironment ?? null,
587
+ });
588
+ res.json({ data: result });
589
+ }
590
+ catch (err) {
591
+ const bridgeError = mapRpcErrorToBridgeError(err);
592
+ res.status(502).json(bridgeError);
593
+ }
594
+ });
595
+ /**
596
+ * POST /api/plugins/:pluginId/bridge/action
597
+ *
598
+ * Proxy a `performAction` call from the plugin UI to the plugin worker.
599
+ *
600
+ * This is the server-side half of the `usePluginAction(key)` bridge hook.
601
+ * The frontend sends a POST with the action key and optional params; the host
602
+ * forwards the call to the worker via the `performAction` RPC method and
603
+ * returns the result.
604
+ *
605
+ * Request body:
606
+ * - `key`: Plugin-defined action key (e.g. `"resync"`)
607
+ * - `params`: Optional parameters forwarded to the worker handler
608
+ *
609
+ * Response: The raw result from the worker's `performAction` handler
610
+ *
611
+ * Error response body follows the `PluginBridgeError` shape:
612
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
613
+ *
614
+ * Errors:
615
+ * - 400 if request validation fails
616
+ * - 404 if plugin not found
617
+ * - 501 if bridge deps are not configured
618
+ * - 502 if the worker is unavailable or returns an error
619
+ *
620
+ * @see PLUGIN_SPEC.md §13.9 — `performAction`
621
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
622
+ */
623
+ router.post("/plugins/:pluginId/bridge/action", async (req, res) => {
624
+ assertBoard(req);
625
+ if (!bridgeDeps) {
626
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
627
+ return;
628
+ }
629
+ const { pluginId } = req.params;
630
+ // Resolve plugin
631
+ const plugin = await resolvePlugin(registry, pluginId);
632
+ if (!plugin) {
633
+ res.status(404).json({ error: "Plugin not found" });
634
+ return;
635
+ }
636
+ // Validate plugin is in ready state
637
+ if (plugin.status !== "ready") {
638
+ const bridgeError = {
639
+ code: "WORKER_UNAVAILABLE",
640
+ message: `Plugin is not ready (current status: ${plugin.status})`,
641
+ };
642
+ res.status(502).json(bridgeError);
643
+ return;
644
+ }
645
+ // Validate request body
646
+ const body = req.body;
647
+ if (!body || !body.key || typeof body.key !== "string") {
648
+ res.status(400).json({ error: '"key" is required and must be a string' });
649
+ return;
650
+ }
651
+ if (body.orgId) {
652
+ assertCompanyAccess(req, body.orgId);
653
+ }
654
+ try {
655
+ const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
656
+ key: body.key,
657
+ params: body.params ?? {},
658
+ renderEnvironment: body.renderEnvironment ?? null,
659
+ });
660
+ res.json({ data: result });
661
+ }
662
+ catch (err) {
663
+ const bridgeError = mapRpcErrorToBridgeError(err);
664
+ res.status(502).json(bridgeError);
665
+ }
666
+ });
667
+ // ===========================================================================
668
+ // URL-keyed bridge routes (key as path parameter)
669
+ // ===========================================================================
670
+ /**
671
+ * POST /api/plugins/:pluginId/data/:key
672
+ *
673
+ * Proxy a `getData` call from the plugin UI to the plugin worker, with the
674
+ * data key specified as a URL path parameter instead of in the request body.
675
+ *
676
+ * This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/data`.
677
+ * The frontend bridge hooks use this endpoint for cleaner URLs.
678
+ *
679
+ * Request body (optional):
680
+ * - `params`: Optional query parameters forwarded to the worker handler
681
+ *
682
+ * Response: The raw result from the worker's `getData` handler wrapped as `{ data: T }`
683
+ *
684
+ * Error response body follows the `PluginBridgeError` shape:
685
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
686
+ *
687
+ * Errors:
688
+ * - 404 if plugin not found
689
+ * - 501 if bridge deps are not configured
690
+ * - 502 if the worker is unavailable or returns an error
691
+ *
692
+ * @see PLUGIN_SPEC.md §13.8 — `getData`
693
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
694
+ */
695
+ router.post("/plugins/:pluginId/data/:key", async (req, res) => {
696
+ assertBoard(req);
697
+ if (!bridgeDeps) {
698
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
699
+ return;
700
+ }
701
+ const { pluginId, key } = req.params;
702
+ // Resolve plugin
703
+ const plugin = await resolvePlugin(registry, pluginId);
704
+ if (!plugin) {
705
+ res.status(404).json({ error: "Plugin not found" });
706
+ return;
707
+ }
708
+ // Validate plugin is in ready state
709
+ if (plugin.status !== "ready") {
710
+ const bridgeError = {
711
+ code: "WORKER_UNAVAILABLE",
712
+ message: `Plugin is not ready (current status: ${plugin.status})`,
713
+ };
714
+ res.status(502).json(bridgeError);
715
+ return;
716
+ }
717
+ const body = req.body;
718
+ if (body?.orgId) {
719
+ assertCompanyAccess(req, body.orgId);
720
+ }
721
+ try {
722
+ const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
723
+ key,
724
+ params: body?.params ?? {},
725
+ renderEnvironment: body?.renderEnvironment ?? null,
726
+ });
727
+ res.json({ data: result });
728
+ }
729
+ catch (err) {
730
+ const bridgeError = mapRpcErrorToBridgeError(err);
731
+ res.status(502).json(bridgeError);
732
+ }
733
+ });
734
+ /**
735
+ * POST /api/plugins/:pluginId/actions/:key
736
+ *
737
+ * Proxy a `performAction` call from the plugin UI to the plugin worker, with
738
+ * the action key specified as a URL path parameter instead of in the request body.
739
+ *
740
+ * This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/action`.
741
+ * The frontend bridge hooks use this endpoint for cleaner URLs.
742
+ *
743
+ * Request body (optional):
744
+ * - `params`: Optional parameters forwarded to the worker handler
745
+ *
746
+ * Response: The raw result from the worker's `performAction` handler wrapped as `{ data: T }`
747
+ *
748
+ * Error response body follows the `PluginBridgeError` shape:
749
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
750
+ *
751
+ * Errors:
752
+ * - 404 if plugin not found
753
+ * - 501 if bridge deps are not configured
754
+ * - 502 if the worker is unavailable or returns an error
755
+ *
756
+ * @see PLUGIN_SPEC.md §13.9 — `performAction`
757
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
758
+ */
759
+ router.post("/plugins/:pluginId/actions/:key", async (req, res) => {
760
+ assertBoard(req);
761
+ if (!bridgeDeps) {
762
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
763
+ return;
764
+ }
765
+ const { pluginId, key } = req.params;
766
+ // Resolve plugin
767
+ const plugin = await resolvePlugin(registry, pluginId);
768
+ if (!plugin) {
769
+ res.status(404).json({ error: "Plugin not found" });
770
+ return;
771
+ }
772
+ // Validate plugin is in ready state
773
+ if (plugin.status !== "ready") {
774
+ const bridgeError = {
775
+ code: "WORKER_UNAVAILABLE",
776
+ message: `Plugin is not ready (current status: ${plugin.status})`,
777
+ };
778
+ res.status(502).json(bridgeError);
779
+ return;
780
+ }
781
+ const body = req.body;
782
+ if (body?.orgId) {
783
+ assertCompanyAccess(req, body.orgId);
784
+ }
785
+ try {
786
+ const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
787
+ key,
788
+ params: body?.params ?? {},
789
+ renderEnvironment: body?.renderEnvironment ?? null,
790
+ });
791
+ res.json({ data: result });
792
+ }
793
+ catch (err) {
794
+ const bridgeError = mapRpcErrorToBridgeError(err);
795
+ res.status(502).json(bridgeError);
796
+ }
797
+ });
798
+ // ===========================================================================
799
+ // SSE stream bridge route
800
+ // ===========================================================================
801
+ /**
802
+ * GET /api/plugins/:pluginId/bridge/stream/:channel
803
+ *
804
+ * Server-Sent Events endpoint for real-time streaming from plugin worker to UI.
805
+ *
806
+ * The worker pushes events via `ctx.streams.emit(channel, event)` which arrive
807
+ * as JSON-RPC notifications to the host, get published on the PluginStreamBus,
808
+ * and are fanned out to all connected SSE clients matching (pluginId, channel,
809
+ * orgId).
810
+ *
811
+ * Query parameters:
812
+ * - `orgId` (required): Scope events to a specific organization
813
+ *
814
+ * SSE event types:
815
+ * - `message`: A data event from the worker (default)
816
+ * - `open`: The worker opened the stream channel
817
+ * - `close`: The worker closed the stream channel — client should disconnect
818
+ *
819
+ * Errors:
820
+ * - 400 if orgId is missing
821
+ * - 404 if plugin not found
822
+ * - 501 if bridge deps or stream bus are not configured
823
+ */
824
+ router.get("/plugins/:pluginId/bridge/stream/:channel", async (req, res) => {
825
+ assertBoard(req);
826
+ if (!bridgeDeps?.streamBus) {
827
+ res.status(501).json({ error: "Plugin stream bridge is not enabled" });
828
+ return;
829
+ }
830
+ const { pluginId, channel } = req.params;
831
+ const orgId = req.query.orgId;
832
+ if (!orgId) {
833
+ res.status(400).json({ error: '"orgId" query parameter is required' });
834
+ return;
835
+ }
836
+ const plugin = await resolvePlugin(registry, pluginId);
837
+ if (!plugin) {
838
+ res.status(404).json({ error: "Plugin not found" });
839
+ return;
840
+ }
841
+ assertCompanyAccess(req, orgId);
842
+ // Set SSE headers
843
+ res.writeHead(200, {
844
+ "Content-Type": "text/event-stream",
845
+ "Cache-Control": "no-cache",
846
+ "Connection": "keep-alive",
847
+ "X-Accel-Buffering": "no",
848
+ });
849
+ res.flushHeaders();
850
+ // Send initial comment to establish the connection
851
+ res.write(":ok\n\n");
852
+ let unsubscribed = false;
853
+ const safeUnsubscribe = () => {
854
+ if (!unsubscribed) {
855
+ unsubscribed = true;
856
+ unsubscribe();
857
+ }
858
+ };
859
+ const unsubscribe = bridgeDeps.streamBus.subscribe(plugin.id, channel, orgId, (event, eventType) => {
860
+ if (unsubscribed || !res.writable)
861
+ return;
862
+ try {
863
+ if (eventType !== "message") {
864
+ res.write(`event: ${eventType}\n`);
865
+ }
866
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
867
+ }
868
+ catch {
869
+ // Connection closed or write error — stop delivering
870
+ safeUnsubscribe();
871
+ }
872
+ });
873
+ req.on("close", safeUnsubscribe);
874
+ res.on("error", safeUnsubscribe);
875
+ });
876
+ /**
877
+ * GET /api/plugins/:pluginId
878
+ *
879
+ * Get detailed information about a single plugin.
880
+ *
881
+ * The :pluginId parameter accepts either:
882
+ * - Database UUID (e.g., "abc123-def456")
883
+ * - Plugin key (e.g., "acme.linear")
884
+ *
885
+ * Response: PluginRecord
886
+ * Errors: 404 if plugin not found
887
+ */
888
+ router.get("/plugins/:pluginId", async (req, res) => {
889
+ assertBoard(req);
890
+ const { pluginId } = req.params;
891
+ const plugin = await resolvePlugin(registry, pluginId);
892
+ if (!plugin) {
893
+ res.status(404).json({ error: "Plugin not found" });
894
+ return;
895
+ }
896
+ // Enrich with worker capabilities when available
897
+ const worker = bridgeDeps?.workerManager.getWorker(plugin.id);
898
+ const supportsConfigTest = worker
899
+ ? worker.supportedMethods.includes("validateConfig")
900
+ : false;
901
+ res.json({ ...plugin, supportsConfigTest });
902
+ });
903
+ /**
904
+ * DELETE /api/plugins/:pluginId
905
+ *
906
+ * Uninstall a plugin.
907
+ *
908
+ * Query params:
909
+ * - purge: If "true", permanently delete all plugin data (hard delete)
910
+ * Otherwise, soft-delete with 30-day data retention
911
+ *
912
+ * Response: PluginRecord (the deleted record)
913
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
914
+ */
915
+ router.delete("/plugins/:pluginId", async (req, res) => {
916
+ assertBoard(req);
917
+ const { pluginId } = req.params;
918
+ const purge = req.query.purge === "true";
919
+ const plugin = await resolvePlugin(registry, pluginId);
920
+ if (!plugin) {
921
+ res.status(404).json({ error: "Plugin not found" });
922
+ return;
923
+ }
924
+ try {
925
+ const result = await lifecycle.unload(plugin.id, purge);
926
+ await logPluginMutationActivity(req, "plugin.uninstalled", plugin.id, {
927
+ pluginId: plugin.id,
928
+ pluginKey: plugin.pluginKey,
929
+ purge,
930
+ });
931
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "uninstalled" } });
932
+ res.json(result);
933
+ }
934
+ catch (err) {
935
+ const message = err instanceof Error ? err.message : String(err);
936
+ res.status(400).json({ error: message });
937
+ }
938
+ });
939
+ /**
940
+ * POST /api/plugins/:pluginId/enable
941
+ *
942
+ * Enable a plugin that is currently disabled or in error state.
943
+ *
944
+ * Transitions the plugin to 'ready' state after loading and validation.
945
+ *
946
+ * Response: PluginRecord
947
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
948
+ */
949
+ router.post("/plugins/:pluginId/enable", async (req, res) => {
950
+ assertBoard(req);
951
+ const { pluginId } = req.params;
952
+ const plugin = await resolvePlugin(registry, pluginId);
953
+ if (!plugin) {
954
+ res.status(404).json({ error: "Plugin not found" });
955
+ return;
956
+ }
957
+ try {
958
+ const result = await lifecycle.enable(plugin.id);
959
+ await logPluginMutationActivity(req, "plugin.enabled", plugin.id, {
960
+ pluginId: plugin.id,
961
+ pluginKey: plugin.pluginKey,
962
+ version: result?.version ?? plugin.version,
963
+ });
964
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "enabled" } });
965
+ res.json(result);
966
+ }
967
+ catch (err) {
968
+ const message = err instanceof Error ? err.message : String(err);
969
+ res.status(400).json({ error: message });
970
+ }
971
+ });
972
+ /**
973
+ * POST /api/plugins/:pluginId/disable
974
+ *
975
+ * Disable a running plugin.
976
+ *
977
+ * Request body (optional):
978
+ * - reason: Human-readable reason for disabling
979
+ *
980
+ * The plugin transitions to 'installed' state and stops processing events.
981
+ *
982
+ * Response: PluginRecord
983
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
984
+ */
985
+ router.post("/plugins/:pluginId/disable", async (req, res) => {
986
+ assertBoard(req);
987
+ const { pluginId } = req.params;
988
+ const body = req.body;
989
+ const reason = body?.reason;
990
+ const plugin = await resolvePlugin(registry, pluginId);
991
+ if (!plugin) {
992
+ res.status(404).json({ error: "Plugin not found" });
993
+ return;
994
+ }
995
+ try {
996
+ const result = await lifecycle.disable(plugin.id, reason);
997
+ await logPluginMutationActivity(req, "plugin.disabled", plugin.id, {
998
+ pluginId: plugin.id,
999
+ pluginKey: plugin.pluginKey,
1000
+ reason: reason ?? null,
1001
+ });
1002
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "disabled" } });
1003
+ res.json(result);
1004
+ }
1005
+ catch (err) {
1006
+ const message = err instanceof Error ? err.message : String(err);
1007
+ res.status(400).json({ error: message });
1008
+ }
1009
+ });
1010
+ /**
1011
+ * GET /api/plugins/:pluginId/health
1012
+ *
1013
+ * Run health diagnostics on a plugin.
1014
+ *
1015
+ * Performs the following checks:
1016
+ * 1. Registry: Plugin is registered in the database
1017
+ * 2. Manifest: Manifest is valid and parseable
1018
+ * 3. Status: Plugin is in 'ready' state
1019
+ * 4. Error state: Plugin has no unhandled errors
1020
+ *
1021
+ * Response: PluginHealthCheckResult
1022
+ * Errors: 404 if plugin not found
1023
+ */
1024
+ router.get("/plugins/:pluginId/health", async (req, res) => {
1025
+ assertBoard(req);
1026
+ const { pluginId } = req.params;
1027
+ const plugin = await resolvePlugin(registry, pluginId);
1028
+ if (!plugin) {
1029
+ res.status(404).json({ error: "Plugin not found" });
1030
+ return;
1031
+ }
1032
+ const checks = [];
1033
+ // Check 1: Plugin is registered
1034
+ checks.push({
1035
+ name: "registry",
1036
+ passed: true,
1037
+ message: "Plugin found in registry",
1038
+ });
1039
+ // Check 2: Manifest is valid
1040
+ const hasValidManifest = Boolean(plugin.manifestJson?.id);
1041
+ checks.push({
1042
+ name: "manifest",
1043
+ passed: hasValidManifest,
1044
+ message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
1045
+ });
1046
+ // Check 3: Plugin status
1047
+ const isHealthy = plugin.status === "ready";
1048
+ checks.push({
1049
+ name: "status",
1050
+ passed: isHealthy,
1051
+ message: `Current status: ${plugin.status}`,
1052
+ });
1053
+ // Check 4: No last error
1054
+ const hasNoError = !plugin.lastError;
1055
+ if (!hasNoError) {
1056
+ checks.push({
1057
+ name: "error_state",
1058
+ passed: false,
1059
+ message: plugin.lastError ?? undefined,
1060
+ });
1061
+ }
1062
+ const result = {
1063
+ pluginId: plugin.id,
1064
+ status: plugin.status,
1065
+ healthy: isHealthy && hasValidManifest && hasNoError,
1066
+ checks,
1067
+ lastError: plugin.lastError ?? undefined,
1068
+ };
1069
+ res.json(result);
1070
+ });
1071
+ /**
1072
+ * GET /api/plugins/:pluginId/logs
1073
+ *
1074
+ * Query recent log entries for a plugin.
1075
+ *
1076
+ * Query params:
1077
+ * - limit: Maximum number of entries (default 25, max 500)
1078
+ * - level: Filter by log level (info, warn, error, debug)
1079
+ * - since: ISO timestamp to filter logs newer than this time
1080
+ *
1081
+ * Response: Array of log entries, newest first.
1082
+ */
1083
+ router.get("/plugins/:pluginId/logs", async (req, res) => {
1084
+ assertBoard(req);
1085
+ const { pluginId } = req.params;
1086
+ const plugin = await resolvePlugin(registry, pluginId);
1087
+ if (!plugin) {
1088
+ res.status(404).json({ error: "Plugin not found" });
1089
+ return;
1090
+ }
1091
+ const limit = Math.min(Math.max(parseInt(req.query.limit, 10) || 25, 1), 500);
1092
+ const level = req.query.level;
1093
+ const since = req.query.since;
1094
+ const conditions = [eq(pluginLogs.pluginId, plugin.id)];
1095
+ if (level) {
1096
+ conditions.push(eq(pluginLogs.level, level));
1097
+ }
1098
+ if (since) {
1099
+ const sinceDate = new Date(since);
1100
+ if (!isNaN(sinceDate.getTime())) {
1101
+ conditions.push(gte(pluginLogs.createdAt, sinceDate));
1102
+ }
1103
+ }
1104
+ const rows = await db
1105
+ .select()
1106
+ .from(pluginLogs)
1107
+ .where(and(...conditions))
1108
+ .orderBy(desc(pluginLogs.createdAt))
1109
+ .limit(limit);
1110
+ res.json(rows);
1111
+ });
1112
+ /**
1113
+ * POST /api/plugins/:pluginId/upgrade
1114
+ *
1115
+ * Upgrade a plugin to a newer version.
1116
+ *
1117
+ * Request body (optional):
1118
+ * - version: Target version (defaults to latest)
1119
+ *
1120
+ * If the upgrade adds new capabilities, the plugin transitions to
1121
+ * 'upgrade_pending' state for board approval. Otherwise, it goes
1122
+ * directly to 'ready'.
1123
+ *
1124
+ * Response: PluginRecord
1125
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
1126
+ */
1127
+ router.post("/plugins/:pluginId/upgrade", async (req, res) => {
1128
+ assertBoard(req);
1129
+ const { pluginId } = req.params;
1130
+ const body = req.body;
1131
+ const version = body?.version;
1132
+ const plugin = await resolvePlugin(registry, pluginId);
1133
+ if (!plugin) {
1134
+ res.status(404).json({ error: "Plugin not found" });
1135
+ return;
1136
+ }
1137
+ try {
1138
+ // Upgrade the plugin - this would typically:
1139
+ // 1. Download the new version
1140
+ // 2. Compare capabilities
1141
+ // 3. If new capabilities, mark as upgrade_pending
1142
+ // 4. Otherwise, transition to ready
1143
+ const result = await lifecycle.upgrade(plugin.id, version);
1144
+ await logPluginMutationActivity(req, "plugin.upgraded", plugin.id, {
1145
+ pluginId: plugin.id,
1146
+ pluginKey: plugin.pluginKey,
1147
+ previousVersion: plugin.version,
1148
+ version: result?.version ?? plugin.version,
1149
+ targetVersion: version ?? null,
1150
+ });
1151
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "upgraded" } });
1152
+ res.json(result);
1153
+ }
1154
+ catch (err) {
1155
+ const message = err instanceof Error ? err.message : String(err);
1156
+ res.status(400).json({ error: message });
1157
+ }
1158
+ });
1159
+ // ===========================================================================
1160
+ // Plugin configuration routes
1161
+ // ===========================================================================
1162
+ /**
1163
+ * GET /api/plugins/:pluginId/config
1164
+ *
1165
+ * Retrieve the current instance configuration for a plugin.
1166
+ *
1167
+ * Returns the `PluginConfig` record if one exists, or `null` if the plugin
1168
+ * has not yet been configured.
1169
+ *
1170
+ * Response: `PluginConfig | null`
1171
+ * Errors: 404 if plugin not found
1172
+ */
1173
+ router.get("/plugins/:pluginId/config", async (req, res) => {
1174
+ assertBoard(req);
1175
+ const { pluginId } = req.params;
1176
+ const plugin = await resolvePlugin(registry, pluginId);
1177
+ if (!plugin) {
1178
+ res.status(404).json({ error: "Plugin not found" });
1179
+ return;
1180
+ }
1181
+ const config = await registry.getConfig(plugin.id);
1182
+ res.json(config);
1183
+ });
1184
+ /**
1185
+ * POST /api/plugins/:pluginId/config
1186
+ *
1187
+ * Save (create or replace) the instance configuration for a plugin.
1188
+ *
1189
+ * The caller provides the full `configJson` object. The server persists it
1190
+ * via `registry.upsertConfig()`.
1191
+ *
1192
+ * Request body:
1193
+ * - `configJson`: Configuration values matching the plugin's `instanceConfigSchema`
1194
+ *
1195
+ * Response: `PluginConfig`
1196
+ * Errors:
1197
+ * - 400 if request validation fails
1198
+ * - 404 if plugin not found
1199
+ */
1200
+ router.post("/plugins/:pluginId/config", async (req, res) => {
1201
+ assertBoard(req);
1202
+ const { pluginId } = req.params;
1203
+ const plugin = await resolvePlugin(registry, pluginId);
1204
+ if (!plugin) {
1205
+ res.status(404).json({ error: "Plugin not found" });
1206
+ return;
1207
+ }
1208
+ const body = req.body;
1209
+ if (!body?.configJson || typeof body.configJson !== "object") {
1210
+ res.status(400).json({ error: '"configJson" is required and must be an object' });
1211
+ return;
1212
+ }
1213
+ // Strip devUiUrl unless the caller is an instance admin. devUiUrl activates
1214
+ // a dev-proxy in the static file route that could be abused for SSRF if any
1215
+ // board-level user were allowed to set it.
1216
+ if ("devUiUrl" in body.configJson &&
1217
+ !(req.actor.type === "board" && req.actor.isInstanceAdmin)) {
1218
+ delete body.configJson.devUiUrl;
1219
+ }
1220
+ // Validate configJson against the plugin's instanceConfigSchema (if declared).
1221
+ // This ensures CLI/API callers get the same validation the UI performs client-side.
1222
+ const schema = plugin.manifestJson?.instanceConfigSchema;
1223
+ if (schema && Object.keys(schema).length > 0) {
1224
+ const validation = validateInstanceConfig(body.configJson, schema);
1225
+ if (!validation.valid) {
1226
+ res.status(400).json({
1227
+ error: "Configuration does not match the plugin's instanceConfigSchema",
1228
+ fieldErrors: validation.errors,
1229
+ });
1230
+ return;
1231
+ }
1232
+ }
1233
+ try {
1234
+ const result = await registry.upsertConfig(plugin.id, {
1235
+ configJson: body.configJson,
1236
+ });
1237
+ await logPluginMutationActivity(req, "plugin.config.updated", plugin.id, {
1238
+ pluginId: plugin.id,
1239
+ pluginKey: plugin.pluginKey,
1240
+ configKeyCount: Object.keys(body.configJson).length,
1241
+ });
1242
+ // Notify the running worker about the config change (PLUGIN_SPEC §25.4.4).
1243
+ // If the worker implements onConfigChanged, send the new config via RPC.
1244
+ // If it doesn't (METHOD_NOT_IMPLEMENTED), restart the worker so it picks
1245
+ // up the new config on re-initialize. If no worker is running, skip.
1246
+ if (bridgeDeps?.workerManager.isRunning(plugin.id)) {
1247
+ try {
1248
+ await bridgeDeps.workerManager.call(plugin.id, "configChanged", { config: body.configJson });
1249
+ }
1250
+ catch (rpcErr) {
1251
+ if (rpcErr instanceof JsonRpcCallError &&
1252
+ rpcErr.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
1253
+ // Worker doesn't handle live config — restart it.
1254
+ try {
1255
+ await lifecycle.restartWorker(plugin.id);
1256
+ }
1257
+ catch {
1258
+ // Restart failure is non-fatal for the config save response.
1259
+ }
1260
+ }
1261
+ // Other RPC errors (timeout, unavailable) are non-fatal — config is
1262
+ // already persisted and will take effect on next worker restart.
1263
+ }
1264
+ }
1265
+ res.json(result);
1266
+ }
1267
+ catch (err) {
1268
+ const message = err instanceof Error ? err.message : String(err);
1269
+ res.status(400).json({ error: message });
1270
+ }
1271
+ });
1272
+ /**
1273
+ * POST /api/plugins/:pluginId/config/test
1274
+ *
1275
+ * Test a plugin configuration without persisting it by calling the plugin
1276
+ * worker's `validateConfig` RPC method.
1277
+ *
1278
+ * Only works when the plugin's worker implements `onValidateConfig`.
1279
+ * If the worker does not implement the method, returns
1280
+ * `{ valid: false, supported: false, message: "..." }` with HTTP 200.
1281
+ *
1282
+ * Request body:
1283
+ * - `configJson`: Configuration values to validate
1284
+ *
1285
+ * Response: `{ valid: boolean; message?: string; supported?: boolean }`
1286
+ * Errors:
1287
+ * - 400 if request validation fails
1288
+ * - 404 if plugin not found
1289
+ * - 501 if bridge deps (worker manager) are not configured
1290
+ * - 502 if the worker is unavailable
1291
+ */
1292
+ router.post("/plugins/:pluginId/config/test", async (req, res) => {
1293
+ assertBoard(req);
1294
+ if (!bridgeDeps) {
1295
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
1296
+ return;
1297
+ }
1298
+ const { pluginId } = req.params;
1299
+ const plugin = await resolvePlugin(registry, pluginId);
1300
+ if (!plugin) {
1301
+ res.status(404).json({ error: "Plugin not found" });
1302
+ return;
1303
+ }
1304
+ if (plugin.status !== "ready") {
1305
+ res.status(400).json({
1306
+ error: `Plugin is not ready (current status: ${plugin.status})`,
1307
+ });
1308
+ return;
1309
+ }
1310
+ const body = req.body;
1311
+ if (!body?.configJson || typeof body.configJson !== "object") {
1312
+ res.status(400).json({ error: '"configJson" is required and must be an object' });
1313
+ return;
1314
+ }
1315
+ // Fast schema-level rejection before hitting the worker RPC.
1316
+ const schema = plugin.manifestJson?.instanceConfigSchema;
1317
+ if (schema && Object.keys(schema).length > 0) {
1318
+ const validation = validateInstanceConfig(body.configJson, schema);
1319
+ if (!validation.valid) {
1320
+ res.status(400).json({
1321
+ error: "Configuration does not match the plugin's instanceConfigSchema",
1322
+ fieldErrors: validation.errors,
1323
+ });
1324
+ return;
1325
+ }
1326
+ }
1327
+ try {
1328
+ const result = await bridgeDeps.workerManager.call(plugin.id, "validateConfig", { config: body.configJson });
1329
+ // The worker returns PluginConfigValidationResult { ok, warnings?, errors? }
1330
+ // Map to the frontend-expected shape { valid, message? }
1331
+ if (result.ok) {
1332
+ const warningText = result.warnings?.length
1333
+ ? `Warnings: ${result.warnings.join("; ")}`
1334
+ : undefined;
1335
+ res.json({ valid: true, message: warningText });
1336
+ }
1337
+ else {
1338
+ const errorText = result.errors?.length
1339
+ ? result.errors.join("; ")
1340
+ : "Configuration validation failed.";
1341
+ res.json({ valid: false, message: errorText });
1342
+ }
1343
+ }
1344
+ catch (err) {
1345
+ // If the worker does not implement validateConfig, return a structured response
1346
+ if (err instanceof JsonRpcCallError &&
1347
+ err.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
1348
+ res.json({
1349
+ valid: false,
1350
+ supported: false,
1351
+ message: "This plugin does not support configuration testing.",
1352
+ });
1353
+ return;
1354
+ }
1355
+ // Worker unavailable or other RPC errors
1356
+ const bridgeError = mapRpcErrorToBridgeError(err);
1357
+ res.status(502).json(bridgeError);
1358
+ }
1359
+ });
1360
+ // ===========================================================================
1361
+ // Job scheduling routes
1362
+ // ===========================================================================
1363
+ /**
1364
+ * GET /api/plugins/:pluginId/jobs
1365
+ *
1366
+ * List all scheduled jobs for a plugin.
1367
+ *
1368
+ * Query params:
1369
+ * - `status` (optional): Filter by job status (`active`, `paused`, `failed`)
1370
+ *
1371
+ * Response: PluginJobRecord[]
1372
+ * Errors: 404 if plugin not found
1373
+ */
1374
+ router.get("/plugins/:pluginId/jobs", async (req, res) => {
1375
+ assertBoard(req);
1376
+ if (!jobDeps) {
1377
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1378
+ return;
1379
+ }
1380
+ const { pluginId } = req.params;
1381
+ const plugin = await resolvePlugin(registry, pluginId);
1382
+ if (!plugin) {
1383
+ res.status(404).json({ error: "Plugin not found" });
1384
+ return;
1385
+ }
1386
+ const rawStatus = req.query.status;
1387
+ const validStatuses = ["active", "paused", "failed"];
1388
+ if (rawStatus !== undefined && !validStatuses.includes(rawStatus)) {
1389
+ res.status(400).json({
1390
+ error: `Invalid status '${rawStatus}'. Must be one of: ${validStatuses.join(", ")}`,
1391
+ });
1392
+ return;
1393
+ }
1394
+ try {
1395
+ const jobs = await jobDeps.jobStore.listJobs(plugin.id, rawStatus);
1396
+ res.json(jobs);
1397
+ }
1398
+ catch (err) {
1399
+ const message = err instanceof Error ? err.message : String(err);
1400
+ res.status(500).json({ error: message });
1401
+ }
1402
+ });
1403
+ /**
1404
+ * GET /api/plugins/:pluginId/jobs/:jobId/runs
1405
+ *
1406
+ * List execution history for a specific job.
1407
+ *
1408
+ * Query params:
1409
+ * - `limit` (optional): Maximum number of runs to return (default: 50)
1410
+ *
1411
+ * Response: PluginJobRunRecord[]
1412
+ * Errors: 404 if plugin not found
1413
+ */
1414
+ router.get("/plugins/:pluginId/jobs/:jobId/runs", async (req, res) => {
1415
+ assertBoard(req);
1416
+ if (!jobDeps) {
1417
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1418
+ return;
1419
+ }
1420
+ const { pluginId, jobId } = req.params;
1421
+ const plugin = await resolvePlugin(registry, pluginId);
1422
+ if (!plugin) {
1423
+ res.status(404).json({ error: "Plugin not found" });
1424
+ return;
1425
+ }
1426
+ const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
1427
+ if (!job) {
1428
+ res.status(404).json({ error: "Job not found" });
1429
+ return;
1430
+ }
1431
+ const limit = req.query.limit ? parseInt(req.query.limit, 10) : 25;
1432
+ if (isNaN(limit) || limit < 1 || limit > 500) {
1433
+ res.status(400).json({ error: "limit must be a number between 1 and 500" });
1434
+ return;
1435
+ }
1436
+ try {
1437
+ const runs = await jobDeps.jobStore.listRunsByJob(jobId, limit);
1438
+ res.json(runs);
1439
+ }
1440
+ catch (err) {
1441
+ const message = err instanceof Error ? err.message : String(err);
1442
+ res.status(500).json({ error: message });
1443
+ }
1444
+ });
1445
+ /**
1446
+ * POST /api/plugins/:pluginId/jobs/:jobId/trigger
1447
+ *
1448
+ * Manually trigger a job execution outside its cron schedule.
1449
+ *
1450
+ * Creates a run with `trigger: "manual"` and dispatches immediately.
1451
+ * The response returns before the job completes (non-blocking).
1452
+ *
1453
+ * Response: `{ runId: string, jobId: string }`
1454
+ * Errors:
1455
+ * - 404 if plugin not found
1456
+ * - 400 if job not found, not active, already running, or worker unavailable
1457
+ */
1458
+ router.post("/plugins/:pluginId/jobs/:jobId/trigger", async (req, res) => {
1459
+ assertBoard(req);
1460
+ if (!jobDeps) {
1461
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1462
+ return;
1463
+ }
1464
+ const { pluginId, jobId } = req.params;
1465
+ const plugin = await resolvePlugin(registry, pluginId);
1466
+ if (!plugin) {
1467
+ res.status(404).json({ error: "Plugin not found" });
1468
+ return;
1469
+ }
1470
+ const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
1471
+ if (!job) {
1472
+ res.status(404).json({ error: "Job not found" });
1473
+ return;
1474
+ }
1475
+ try {
1476
+ const result = await jobDeps.scheduler.triggerJob(jobId, "manual");
1477
+ res.json(result);
1478
+ }
1479
+ catch (err) {
1480
+ const message = err instanceof Error ? err.message : String(err);
1481
+ res.status(400).json({ error: message });
1482
+ }
1483
+ });
1484
+ // ===========================================================================
1485
+ // Webhook ingestion route
1486
+ // ===========================================================================
1487
+ /**
1488
+ * POST /api/plugins/:pluginId/webhooks/:endpointKey
1489
+ *
1490
+ * Receive an inbound webhook delivery for a plugin.
1491
+ *
1492
+ * This route is called by external systems (e.g. GitHub, Linear, Stripe) to
1493
+ * deliver webhook payloads to a plugin. The host validates that:
1494
+ * 1. The plugin exists and is in 'ready' state
1495
+ * 2. The plugin declares the `webhooks.receive` capability
1496
+ * 3. The `endpointKey` matches a declared webhook in the manifest
1497
+ *
1498
+ * The delivery is recorded in the `plugin_webhook_deliveries` table and
1499
+ * dispatched to the worker via the `handleWebhook` RPC method.
1500
+ *
1501
+ * **Note:** This route does NOT require board authentication — webhook
1502
+ * endpoints must be publicly accessible for external callers. Signature
1503
+ * verification is the plugin's responsibility.
1504
+ *
1505
+ * Response: `{ deliveryId: string, status: string }`
1506
+ * Errors:
1507
+ * - 404 if plugin not found or endpointKey not declared
1508
+ * - 400 if plugin is not in ready state or lacks webhooks.receive capability
1509
+ * - 502 if the worker is unavailable or the RPC call fails
1510
+ */
1511
+ router.post("/plugins/:pluginId/webhooks/:endpointKey", async (req, res) => {
1512
+ if (!webhookDeps) {
1513
+ res.status(501).json({ error: "Webhook ingestion is not enabled" });
1514
+ return;
1515
+ }
1516
+ const { pluginId, endpointKey } = req.params;
1517
+ // Step 1: Resolve the plugin
1518
+ const plugin = await resolvePlugin(registry, pluginId);
1519
+ if (!plugin) {
1520
+ res.status(404).json({ error: "Plugin not found" });
1521
+ return;
1522
+ }
1523
+ // Step 2: Validate the plugin is in 'ready' state
1524
+ if (plugin.status !== "ready") {
1525
+ res.status(400).json({
1526
+ error: `Plugin is not ready (current status: ${plugin.status})`,
1527
+ });
1528
+ return;
1529
+ }
1530
+ // Step 3: Validate the plugin has webhooks.receive capability
1531
+ const manifest = plugin.manifestJson;
1532
+ if (!manifest) {
1533
+ res.status(400).json({ error: "Plugin manifest is missing" });
1534
+ return;
1535
+ }
1536
+ const capabilities = manifest.capabilities ?? [];
1537
+ if (!capabilities.includes("webhooks.receive")) {
1538
+ res.status(400).json({
1539
+ error: "Plugin does not have the webhooks.receive capability",
1540
+ });
1541
+ return;
1542
+ }
1543
+ // Step 4: Validate the endpointKey exists in the manifest's webhook declarations
1544
+ const declaredWebhooks = manifest.webhooks ?? [];
1545
+ const webhookDecl = declaredWebhooks.find((w) => w.endpointKey === endpointKey);
1546
+ if (!webhookDecl) {
1547
+ res.status(404).json({
1548
+ error: `Webhook endpoint '${endpointKey}' is not declared by this plugin`,
1549
+ });
1550
+ return;
1551
+ }
1552
+ // Step 5: Extract request data
1553
+ const requestId = randomUUID();
1554
+ const rawHeaders = {};
1555
+ for (const [key, value] of Object.entries(req.headers)) {
1556
+ if (typeof value === "string") {
1557
+ rawHeaders[key] = value;
1558
+ }
1559
+ else if (Array.isArray(value)) {
1560
+ rawHeaders[key] = value.join(", ");
1561
+ }
1562
+ }
1563
+ // Use the raw buffer stashed by the express.json() `verify` callback.
1564
+ // This preserves the exact bytes the provider signed, whereas
1565
+ // JSON.stringify(req.body) would re-serialize and break HMAC verification.
1566
+ const stashedRaw = req.rawBody;
1567
+ const rawBody = stashedRaw ? stashedRaw.toString("utf-8") : "";
1568
+ const parsedBody = req.body;
1569
+ const payload = req.body ?? {};
1570
+ // Step 6: Record the delivery in the database
1571
+ const startedAt = new Date();
1572
+ const [delivery] = await db
1573
+ .insert(pluginWebhookDeliveries)
1574
+ .values({
1575
+ pluginId: plugin.id,
1576
+ webhookKey: endpointKey,
1577
+ status: "pending",
1578
+ payload,
1579
+ headers: rawHeaders,
1580
+ startedAt,
1581
+ })
1582
+ .returning({ id: pluginWebhookDeliveries.id });
1583
+ // Step 7: Dispatch to the worker via handleWebhook RPC
1584
+ try {
1585
+ await webhookDeps.workerManager.call(plugin.id, "handleWebhook", {
1586
+ endpointKey,
1587
+ headers: req.headers,
1588
+ rawBody,
1589
+ parsedBody,
1590
+ requestId,
1591
+ });
1592
+ // Step 8: Update delivery record to success
1593
+ const finishedAt = new Date();
1594
+ const durationMs = finishedAt.getTime() - startedAt.getTime();
1595
+ await db
1596
+ .update(pluginWebhookDeliveries)
1597
+ .set({
1598
+ status: "success",
1599
+ durationMs,
1600
+ finishedAt,
1601
+ })
1602
+ .where(eq(pluginWebhookDeliveries.id, delivery.id));
1603
+ res.status(200).json({
1604
+ deliveryId: delivery.id,
1605
+ status: "success",
1606
+ });
1607
+ }
1608
+ catch (err) {
1609
+ // Step 8 (error): Update delivery record to failed
1610
+ const finishedAt = new Date();
1611
+ const durationMs = finishedAt.getTime() - startedAt.getTime();
1612
+ const errorMessage = err instanceof Error ? err.message : String(err);
1613
+ await db
1614
+ .update(pluginWebhookDeliveries)
1615
+ .set({
1616
+ status: "failed",
1617
+ durationMs,
1618
+ error: errorMessage,
1619
+ finishedAt,
1620
+ })
1621
+ .where(eq(pluginWebhookDeliveries.id, delivery.id));
1622
+ res.status(502).json({
1623
+ deliveryId: delivery.id,
1624
+ status: "failed",
1625
+ error: errorMessage,
1626
+ });
1627
+ }
1628
+ });
1629
+ // ===========================================================================
1630
+ // Plugin health dashboard — aggregated diagnostics for the settings page
1631
+ // ===========================================================================
1632
+ /**
1633
+ * GET /api/plugins/:pluginId/dashboard
1634
+ *
1635
+ * Aggregated health dashboard data for a plugin's settings page.
1636
+ *
1637
+ * Returns worker diagnostics (status, uptime, crash history), recent job
1638
+ * runs, recent webhook deliveries, and the current health check result —
1639
+ * all in a single response to avoid multiple round-trips.
1640
+ *
1641
+ * Response: PluginDashboardData
1642
+ * Errors: 404 if plugin not found
1643
+ */
1644
+ router.get("/plugins/:pluginId/dashboard", async (req, res) => {
1645
+ assertBoard(req);
1646
+ const { pluginId } = req.params;
1647
+ const plugin = await resolvePlugin(registry, pluginId);
1648
+ if (!plugin) {
1649
+ res.status(404).json({ error: "Plugin not found" });
1650
+ return;
1651
+ }
1652
+ // --- Worker diagnostics ---
1653
+ let worker = null;
1654
+ // Try bridgeDeps first (primary source for worker manager), fallback to webhookDeps
1655
+ const wm = bridgeDeps?.workerManager ?? webhookDeps?.workerManager ?? null;
1656
+ if (wm) {
1657
+ const handle = wm.getWorker(plugin.id);
1658
+ if (handle) {
1659
+ const diag = handle.diagnostics();
1660
+ worker = {
1661
+ status: diag.status,
1662
+ pid: diag.pid,
1663
+ uptime: diag.uptime,
1664
+ consecutiveCrashes: diag.consecutiveCrashes,
1665
+ totalCrashes: diag.totalCrashes,
1666
+ pendingRequests: diag.pendingRequests,
1667
+ lastCrashAt: diag.lastCrashAt,
1668
+ nextRestartAt: diag.nextRestartAt,
1669
+ };
1670
+ }
1671
+ }
1672
+ // --- Recent job runs (last 10, newest first) ---
1673
+ let recentJobRuns = [];
1674
+ if (jobDeps) {
1675
+ try {
1676
+ const runs = await jobDeps.jobStore.listRunsByPlugin(plugin.id, undefined, 10);
1677
+ // Also fetch job definitions so we can include jobKey
1678
+ const jobs = await jobDeps.jobStore.listJobs(plugin.id);
1679
+ const jobKeyMap = new Map(jobs.map((j) => [j.id, j.jobKey]));
1680
+ recentJobRuns = runs
1681
+ .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
1682
+ .map((r) => ({
1683
+ id: r.id,
1684
+ jobId: r.jobId,
1685
+ jobKey: jobKeyMap.get(r.jobId) ?? undefined,
1686
+ trigger: r.trigger,
1687
+ status: r.status,
1688
+ durationMs: r.durationMs,
1689
+ error: r.error,
1690
+ startedAt: r.startedAt ? new Date(r.startedAt).toISOString() : null,
1691
+ finishedAt: r.finishedAt ? new Date(r.finishedAt).toISOString() : null,
1692
+ createdAt: new Date(r.createdAt).toISOString(),
1693
+ }));
1694
+ }
1695
+ catch {
1696
+ // Job data unavailable — leave empty
1697
+ }
1698
+ }
1699
+ // --- Recent webhook deliveries (last 10, newest first) ---
1700
+ let recentWebhookDeliveries = [];
1701
+ try {
1702
+ const deliveries = await db
1703
+ .select({
1704
+ id: pluginWebhookDeliveries.id,
1705
+ webhookKey: pluginWebhookDeliveries.webhookKey,
1706
+ status: pluginWebhookDeliveries.status,
1707
+ durationMs: pluginWebhookDeliveries.durationMs,
1708
+ error: pluginWebhookDeliveries.error,
1709
+ startedAt: pluginWebhookDeliveries.startedAt,
1710
+ finishedAt: pluginWebhookDeliveries.finishedAt,
1711
+ createdAt: pluginWebhookDeliveries.createdAt,
1712
+ })
1713
+ .from(pluginWebhookDeliveries)
1714
+ .where(eq(pluginWebhookDeliveries.pluginId, plugin.id))
1715
+ .orderBy(desc(pluginWebhookDeliveries.createdAt))
1716
+ .limit(10);
1717
+ recentWebhookDeliveries = deliveries.map((d) => ({
1718
+ id: d.id,
1719
+ webhookKey: d.webhookKey,
1720
+ status: d.status,
1721
+ durationMs: d.durationMs,
1722
+ error: d.error,
1723
+ startedAt: d.startedAt ? d.startedAt.toISOString() : null,
1724
+ finishedAt: d.finishedAt ? d.finishedAt.toISOString() : null,
1725
+ createdAt: d.createdAt.toISOString(),
1726
+ }));
1727
+ }
1728
+ catch {
1729
+ // Webhook data unavailable — leave empty
1730
+ }
1731
+ // --- Health check (same logic as GET /health) ---
1732
+ const checks = [];
1733
+ checks.push({
1734
+ name: "registry",
1735
+ passed: true,
1736
+ message: "Plugin found in registry",
1737
+ });
1738
+ const hasValidManifest = Boolean(plugin.manifestJson?.id);
1739
+ checks.push({
1740
+ name: "manifest",
1741
+ passed: hasValidManifest,
1742
+ message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
1743
+ });
1744
+ const isHealthy = plugin.status === "ready";
1745
+ checks.push({
1746
+ name: "status",
1747
+ passed: isHealthy,
1748
+ message: `Current status: ${plugin.status}`,
1749
+ });
1750
+ const hasNoError = !plugin.lastError;
1751
+ if (!hasNoError) {
1752
+ checks.push({
1753
+ name: "error_state",
1754
+ passed: false,
1755
+ message: plugin.lastError ?? undefined,
1756
+ });
1757
+ }
1758
+ const health = {
1759
+ pluginId: plugin.id,
1760
+ status: plugin.status,
1761
+ healthy: isHealthy && hasValidManifest && hasNoError,
1762
+ checks,
1763
+ lastError: plugin.lastError ?? undefined,
1764
+ };
1765
+ res.json({
1766
+ pluginId: plugin.id,
1767
+ worker,
1768
+ recentJobRuns,
1769
+ recentWebhookDeliveries,
1770
+ health,
1771
+ checkedAt: new Date().toISOString(),
1772
+ });
1773
+ });
1774
+ return router;
1775
+ }
1776
+ //# sourceMappingURL=plugins.js.map