@dealdesk/server 2026.527.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 (1311) hide show
  1. package/LICENSE +21 -0
  2. package/dist/__tests__/helpers/embedded-postgres.d.ts +2 -0
  3. package/dist/__tests__/helpers/embedded-postgres.d.ts.map +1 -0
  4. package/dist/__tests__/helpers/embedded-postgres.js +2 -0
  5. package/dist/__tests__/helpers/embedded-postgres.js.map +1 -0
  6. package/dist/adapters/builtin-adapter-types.d.ts +5 -0
  7. package/dist/adapters/builtin-adapter-types.d.ts.map +1 -0
  8. package/dist/adapters/builtin-adapter-types.js +18 -0
  9. package/dist/adapters/builtin-adapter-types.js.map +1 -0
  10. package/dist/adapters/codex-models.d.ts +5 -0
  11. package/dist/adapters/codex-models.d.ts.map +1 -0
  12. package/dist/adapters/codex-models.js +105 -0
  13. package/dist/adapters/codex-models.js.map +1 -0
  14. package/dist/adapters/cursor-models.d.ts +13 -0
  15. package/dist/adapters/cursor-models.d.ts.map +1 -0
  16. package/dist/adapters/cursor-models.js +148 -0
  17. package/dist/adapters/cursor-models.js.map +1 -0
  18. package/dist/adapters/http/execute.d.ts +3 -0
  19. package/dist/adapters/http/execute.d.ts.map +1 -0
  20. package/dist/adapters/http/execute.js +51 -0
  21. package/dist/adapters/http/execute.js.map +1 -0
  22. package/dist/adapters/http/execute.test.d.ts +2 -0
  23. package/dist/adapters/http/execute.test.d.ts.map +1 -0
  24. package/dist/adapters/http/execute.test.js +40 -0
  25. package/dist/adapters/http/execute.test.js.map +1 -0
  26. package/dist/adapters/http/index.d.ts +3 -0
  27. package/dist/adapters/http/index.d.ts.map +1 -0
  28. package/dist/adapters/http/index.js +20 -0
  29. package/dist/adapters/http/index.js.map +1 -0
  30. package/dist/adapters/http/test.d.ts +3 -0
  31. package/dist/adapters/http/test.d.ts.map +1 -0
  32. package/dist/adapters/http/test.js +106 -0
  33. package/dist/adapters/http/test.js.map +1 -0
  34. package/dist/adapters/index.d.ts +4 -0
  35. package/dist/adapters/index.d.ts.map +1 -0
  36. package/dist/adapters/index.js +3 -0
  37. package/dist/adapters/index.js.map +1 -0
  38. package/dist/adapters/plugin-loader.d.ts +28 -0
  39. package/dist/adapters/plugin-loader.d.ts.map +1 -0
  40. package/dist/adapters/plugin-loader.js +196 -0
  41. package/dist/adapters/plugin-loader.js.map +1 -0
  42. package/dist/adapters/process/execute.d.ts +3 -0
  43. package/dist/adapters/process/execute.d.ts.map +1 -0
  44. package/dist/adapters/process/execute.js +70 -0
  45. package/dist/adapters/process/execute.js.map +1 -0
  46. package/dist/adapters/process/index.d.ts +3 -0
  47. package/dist/adapters/process/index.d.ts.map +1 -0
  48. package/dist/adapters/process/index.js +23 -0
  49. package/dist/adapters/process/index.js.map +1 -0
  50. package/dist/adapters/process/test.d.ts +3 -0
  51. package/dist/adapters/process/test.d.ts.map +1 -0
  52. package/dist/adapters/process/test.js +77 -0
  53. package/dist/adapters/process/test.js.map +1 -0
  54. package/dist/adapters/registry.d.ts +69 -0
  55. package/dist/adapters/registry.d.ts.map +1 -0
  56. package/dist/adapters/registry.js +589 -0
  57. package/dist/adapters/registry.js.map +1 -0
  58. package/dist/adapters/types.d.ts +2 -0
  59. package/dist/adapters/types.d.ts.map +1 -0
  60. package/dist/adapters/types.js +2 -0
  61. package/dist/adapters/types.js.map +1 -0
  62. package/dist/adapters/utils.d.ts +43 -0
  63. package/dist/adapters/utils.d.ts.map +1 -0
  64. package/dist/adapters/utils.js +52 -0
  65. package/dist/adapters/utils.js.map +1 -0
  66. package/dist/agent-auth-jwt.d.ts +14 -0
  67. package/dist/agent-auth-jwt.d.ts.map +1 -0
  68. package/dist/agent-auth-jwt.js +117 -0
  69. package/dist/agent-auth-jwt.js.map +1 -0
  70. package/dist/app.d.ts +43 -0
  71. package/dist/app.d.ts.map +1 -0
  72. package/dist/app.js +426 -0
  73. package/dist/app.js.map +1 -0
  74. package/dist/attachment-types.d.ts +23 -0
  75. package/dist/attachment-types.d.ts.map +1 -0
  76. package/dist/attachment-types.js +91 -0
  77. package/dist/attachment-types.js.map +1 -0
  78. package/dist/auth/better-auth.d.ts +33 -0
  79. package/dist/auth/better-auth.d.ts.map +1 -0
  80. package/dist/auth/better-auth.js +133 -0
  81. package/dist/auth/better-auth.js.map +1 -0
  82. package/dist/board-claim.d.ts +23 -0
  83. package/dist/board-claim.d.ts.map +1 -0
  84. package/dist/board-claim.js +115 -0
  85. package/dist/board-claim.js.map +1 -0
  86. package/dist/config-file.d.ts +3 -0
  87. package/dist/config-file.d.ts.map +1 -0
  88. package/dist/config-file.js +16 -0
  89. package/dist/config-file.js.map +1 -0
  90. package/dist/config.d.ts +50 -0
  91. package/dist/config.d.ts.map +1 -0
  92. package/dist/config.js +233 -0
  93. package/dist/config.js.map +1 -0
  94. package/dist/deal-desk/enrichment/__tests__/apollo-client.test.d.ts +2 -0
  95. package/dist/deal-desk/enrichment/__tests__/apollo-client.test.d.ts.map +1 -0
  96. package/dist/deal-desk/enrichment/__tests__/apollo-client.test.js +168 -0
  97. package/dist/deal-desk/enrichment/__tests__/apollo-client.test.js.map +1 -0
  98. package/dist/deal-desk/enrichment/__tests__/apollo-config.test.d.ts +2 -0
  99. package/dist/deal-desk/enrichment/__tests__/apollo-config.test.d.ts.map +1 -0
  100. package/dist/deal-desk/enrichment/__tests__/apollo-config.test.js +63 -0
  101. package/dist/deal-desk/enrichment/__tests__/apollo-config.test.js.map +1 -0
  102. package/dist/deal-desk/enrichment/__tests__/resolve-contact-email.test.d.ts +2 -0
  103. package/dist/deal-desk/enrichment/__tests__/resolve-contact-email.test.d.ts.map +1 -0
  104. package/dist/deal-desk/enrichment/__tests__/resolve-contact-email.test.js +127 -0
  105. package/dist/deal-desk/enrichment/__tests__/resolve-contact-email.test.js.map +1 -0
  106. package/dist/deal-desk/enrichment/apollo-client.d.ts +57 -0
  107. package/dist/deal-desk/enrichment/apollo-client.d.ts.map +1 -0
  108. package/dist/deal-desk/enrichment/apollo-client.js +263 -0
  109. package/dist/deal-desk/enrichment/apollo-client.js.map +1 -0
  110. package/dist/deal-desk/enrichment/apollo-config.d.ts +56 -0
  111. package/dist/deal-desk/enrichment/apollo-config.d.ts.map +1 -0
  112. package/dist/deal-desk/enrichment/apollo-config.js +58 -0
  113. package/dist/deal-desk/enrichment/apollo-config.js.map +1 -0
  114. package/dist/deal-desk/enrichment/resolve-contact-email.d.ts +62 -0
  115. package/dist/deal-desk/enrichment/resolve-contact-email.d.ts.map +1 -0
  116. package/dist/deal-desk/enrichment/resolve-contact-email.js +199 -0
  117. package/dist/deal-desk/enrichment/resolve-contact-email.js.map +1 -0
  118. package/dist/deal-desk/gmail/__tests__/client-config.test.d.ts +2 -0
  119. package/dist/deal-desk/gmail/__tests__/client-config.test.d.ts.map +1 -0
  120. package/dist/deal-desk/gmail/__tests__/client-config.test.js +73 -0
  121. package/dist/deal-desk/gmail/__tests__/client-config.test.js.map +1 -0
  122. package/dist/deal-desk/gmail/__tests__/oauth.test.d.ts +2 -0
  123. package/dist/deal-desk/gmail/__tests__/oauth.test.d.ts.map +1 -0
  124. package/dist/deal-desk/gmail/__tests__/oauth.test.js +38 -0
  125. package/dist/deal-desk/gmail/__tests__/oauth.test.js.map +1 -0
  126. package/dist/deal-desk/gmail/__tests__/redirect-uri.test.d.ts +2 -0
  127. package/dist/deal-desk/gmail/__tests__/redirect-uri.test.d.ts.map +1 -0
  128. package/dist/deal-desk/gmail/__tests__/redirect-uri.test.js +74 -0
  129. package/dist/deal-desk/gmail/__tests__/redirect-uri.test.js.map +1 -0
  130. package/dist/deal-desk/gmail/__tests__/send.test.d.ts +2 -0
  131. package/dist/deal-desk/gmail/__tests__/send.test.d.ts.map +1 -0
  132. package/dist/deal-desk/gmail/__tests__/send.test.js +44 -0
  133. package/dist/deal-desk/gmail/__tests__/send.test.js.map +1 -0
  134. package/dist/deal-desk/gmail/__tests__/tokens.test.d.ts +2 -0
  135. package/dist/deal-desk/gmail/__tests__/tokens.test.d.ts.map +1 -0
  136. package/dist/deal-desk/gmail/__tests__/tokens.test.js +69 -0
  137. package/dist/deal-desk/gmail/__tests__/tokens.test.js.map +1 -0
  138. package/dist/deal-desk/gmail/client-config.d.ts +51 -0
  139. package/dist/deal-desk/gmail/client-config.d.ts.map +1 -0
  140. package/dist/deal-desk/gmail/client-config.js +38 -0
  141. package/dist/deal-desk/gmail/client-config.js.map +1 -0
  142. package/dist/deal-desk/gmail/oauth.d.ts +26 -0
  143. package/dist/deal-desk/gmail/oauth.d.ts.map +1 -0
  144. package/dist/deal-desk/gmail/oauth.js +50 -0
  145. package/dist/deal-desk/gmail/oauth.js.map +1 -0
  146. package/dist/deal-desk/gmail/redirect-uri.d.ts +8 -0
  147. package/dist/deal-desk/gmail/redirect-uri.d.ts.map +1 -0
  148. package/dist/deal-desk/gmail/redirect-uri.js +83 -0
  149. package/dist/deal-desk/gmail/redirect-uri.js.map +1 -0
  150. package/dist/deal-desk/gmail/send.d.ts +19 -0
  151. package/dist/deal-desk/gmail/send.d.ts.map +1 -0
  152. package/dist/deal-desk/gmail/send.js +39 -0
  153. package/dist/deal-desk/gmail/send.js.map +1 -0
  154. package/dist/deal-desk/gmail/tokens.d.ts +50 -0
  155. package/dist/deal-desk/gmail/tokens.d.ts.map +1 -0
  156. package/dist/deal-desk/gmail/tokens.js +50 -0
  157. package/dist/deal-desk/gmail/tokens.js.map +1 -0
  158. package/dist/deal-desk/intermediary-campaign.d.ts +4 -0
  159. package/dist/deal-desk/intermediary-campaign.d.ts.map +1 -0
  160. package/dist/deal-desk/intermediary-campaign.js +26 -0
  161. package/dist/deal-desk/intermediary-campaign.js.map +1 -0
  162. package/dist/deal-desk/seeds/role-templates.d.ts +10 -0
  163. package/dist/deal-desk/seeds/role-templates.d.ts.map +1 -0
  164. package/dist/deal-desk/seeds/role-templates.js +110 -0
  165. package/dist/deal-desk/seeds/role-templates.js.map +1 -0
  166. package/dist/deal-desk/seeds/seed-role-templates.d.ts +3 -0
  167. package/dist/deal-desk/seeds/seed-role-templates.d.ts.map +1 -0
  168. package/dist/deal-desk/seeds/seed-role-templates.js +39 -0
  169. package/dist/deal-desk/seeds/seed-role-templates.js.map +1 -0
  170. package/dist/deal-desk/target-service.d.ts +131 -0
  171. package/dist/deal-desk/target-service.d.ts.map +1 -0
  172. package/dist/deal-desk/target-service.js +169 -0
  173. package/dist/deal-desk/target-service.js.map +1 -0
  174. package/dist/deal-desk/tools/__tests__/apollo-api-key.test.d.ts +2 -0
  175. package/dist/deal-desk/tools/__tests__/apollo-api-key.test.d.ts.map +1 -0
  176. package/dist/deal-desk/tools/__tests__/apollo-api-key.test.js +122 -0
  177. package/dist/deal-desk/tools/__tests__/apollo-api-key.test.js.map +1 -0
  178. package/dist/deal-desk/tools/__tests__/create-contact.test.d.ts +2 -0
  179. package/dist/deal-desk/tools/__tests__/create-contact.test.d.ts.map +1 -0
  180. package/dist/deal-desk/tools/__tests__/create-contact.test.js +73 -0
  181. package/dist/deal-desk/tools/__tests__/create-contact.test.js.map +1 -0
  182. package/dist/deal-desk/tools/__tests__/deal-desk-tools.test.d.ts +2 -0
  183. package/dist/deal-desk/tools/__tests__/deal-desk-tools.test.d.ts.map +1 -0
  184. package/dist/deal-desk/tools/__tests__/deal-desk-tools.test.js +193 -0
  185. package/dist/deal-desk/tools/__tests__/deal-desk-tools.test.js.map +1 -0
  186. package/dist/deal-desk/tools/__tests__/email-accounts.test.d.ts +2 -0
  187. package/dist/deal-desk/tools/__tests__/email-accounts.test.d.ts.map +1 -0
  188. package/dist/deal-desk/tools/__tests__/email-accounts.test.js +71 -0
  189. package/dist/deal-desk/tools/__tests__/email-accounts.test.js.map +1 -0
  190. package/dist/deal-desk/tools/__tests__/enrich-contact.test.d.ts +2 -0
  191. package/dist/deal-desk/tools/__tests__/enrich-contact.test.d.ts.map +1 -0
  192. package/dist/deal-desk/tools/__tests__/enrich-contact.test.js +183 -0
  193. package/dist/deal-desk/tools/__tests__/enrich-contact.test.js.map +1 -0
  194. package/dist/deal-desk/tools/__tests__/gmail-client-config.test.d.ts +2 -0
  195. package/dist/deal-desk/tools/__tests__/gmail-client-config.test.d.ts.map +1 -0
  196. package/dist/deal-desk/tools/__tests__/gmail-client-config.test.js +67 -0
  197. package/dist/deal-desk/tools/__tests__/gmail-client-config.test.js.map +1 -0
  198. package/dist/deal-desk/tools/__tests__/helpers/where-introspection.d.ts +2 -0
  199. package/dist/deal-desk/tools/__tests__/helpers/where-introspection.d.ts.map +1 -0
  200. package/dist/deal-desk/tools/__tests__/helpers/where-introspection.js +29 -0
  201. package/dist/deal-desk/tools/__tests__/helpers/where-introspection.js.map +1 -0
  202. package/dist/deal-desk/tools/__tests__/outreach-approve.test.d.ts +2 -0
  203. package/dist/deal-desk/tools/__tests__/outreach-approve.test.d.ts.map +1 -0
  204. package/dist/deal-desk/tools/__tests__/outreach-approve.test.js +258 -0
  205. package/dist/deal-desk/tools/__tests__/outreach-approve.test.js.map +1 -0
  206. package/dist/deal-desk/tools/__tests__/outreach-draft.test.d.ts +2 -0
  207. package/dist/deal-desk/tools/__tests__/outreach-draft.test.d.ts.map +1 -0
  208. package/dist/deal-desk/tools/__tests__/outreach-draft.test.js +115 -0
  209. package/dist/deal-desk/tools/__tests__/outreach-draft.test.js.map +1 -0
  210. package/dist/deal-desk/tools/__tests__/outreach-edit.test.d.ts +2 -0
  211. package/dist/deal-desk/tools/__tests__/outreach-edit.test.d.ts.map +1 -0
  212. package/dist/deal-desk/tools/__tests__/outreach-edit.test.js +169 -0
  213. package/dist/deal-desk/tools/__tests__/outreach-edit.test.js.map +1 -0
  214. package/dist/deal-desk/tools/__tests__/outreach-list-pending.test.d.ts +2 -0
  215. package/dist/deal-desk/tools/__tests__/outreach-list-pending.test.d.ts.map +1 -0
  216. package/dist/deal-desk/tools/__tests__/outreach-list-pending.test.js +59 -0
  217. package/dist/deal-desk/tools/__tests__/outreach-list-pending.test.js.map +1 -0
  218. package/dist/deal-desk/tools/__tests__/test-gmail-send.test.d.ts +2 -0
  219. package/dist/deal-desk/tools/__tests__/test-gmail-send.test.d.ts.map +1 -0
  220. package/dist/deal-desk/tools/__tests__/test-gmail-send.test.js +98 -0
  221. package/dist/deal-desk/tools/__tests__/test-gmail-send.test.js.map +1 -0
  222. package/dist/deal-desk/tools/apollo-api-key.d.ts +11 -0
  223. package/dist/deal-desk/tools/apollo-api-key.d.ts.map +1 -0
  224. package/dist/deal-desk/tools/apollo-api-key.js +70 -0
  225. package/dist/deal-desk/tools/apollo-api-key.js.map +1 -0
  226. package/dist/deal-desk/tools/create-contact.d.ts +28 -0
  227. package/dist/deal-desk/tools/create-contact.d.ts.map +1 -0
  228. package/dist/deal-desk/tools/create-contact.js +52 -0
  229. package/dist/deal-desk/tools/create-contact.js.map +1 -0
  230. package/dist/deal-desk/tools/create-intermediary.d.ts +62 -0
  231. package/dist/deal-desk/tools/create-intermediary.d.ts.map +1 -0
  232. package/dist/deal-desk/tools/create-intermediary.js +105 -0
  233. package/dist/deal-desk/tools/create-intermediary.js.map +1 -0
  234. package/dist/deal-desk/tools/create-target.d.ts +8 -0
  235. package/dist/deal-desk/tools/create-target.d.ts.map +1 -0
  236. package/dist/deal-desk/tools/create-target.js +56 -0
  237. package/dist/deal-desk/tools/create-target.js.map +1 -0
  238. package/dist/deal-desk/tools/enrich-contact.d.ts +22 -0
  239. package/dist/deal-desk/tools/enrich-contact.d.ts.map +1 -0
  240. package/dist/deal-desk/tools/enrich-contact.js +85 -0
  241. package/dist/deal-desk/tools/enrich-contact.js.map +1 -0
  242. package/dist/deal-desk/tools/get-target.d.ts +5 -0
  243. package/dist/deal-desk/tools/get-target.d.ts.map +1 -0
  244. package/dist/deal-desk/tools/get-target.js +33 -0
  245. package/dist/deal-desk/tools/get-target.js.map +1 -0
  246. package/dist/deal-desk/tools/gmail-client-config.d.ts +20 -0
  247. package/dist/deal-desk/tools/gmail-client-config.d.ts.map +1 -0
  248. package/dist/deal-desk/tools/gmail-client-config.js +43 -0
  249. package/dist/deal-desk/tools/gmail-client-config.js.map +1 -0
  250. package/dist/deal-desk/tools/index.d.ts +39 -0
  251. package/dist/deal-desk/tools/index.d.ts.map +1 -0
  252. package/dist/deal-desk/tools/index.js +208 -0
  253. package/dist/deal-desk/tools/index.js.map +1 -0
  254. package/dist/deal-desk/tools/intermediary-outreach-draft.d.ts +21 -0
  255. package/dist/deal-desk/tools/intermediary-outreach-draft.d.ts.map +1 -0
  256. package/dist/deal-desk/tools/intermediary-outreach-draft.js +59 -0
  257. package/dist/deal-desk/tools/intermediary-outreach-draft.js.map +1 -0
  258. package/dist/deal-desk/tools/list-intermediaries.d.ts +20 -0
  259. package/dist/deal-desk/tools/list-intermediaries.d.ts.map +1 -0
  260. package/dist/deal-desk/tools/list-intermediaries.js +74 -0
  261. package/dist/deal-desk/tools/list-intermediaries.js.map +1 -0
  262. package/dist/deal-desk/tools/list-targets.d.ts +20 -0
  263. package/dist/deal-desk/tools/list-targets.d.ts.map +1 -0
  264. package/dist/deal-desk/tools/list-targets.js +73 -0
  265. package/dist/deal-desk/tools/list-targets.js.map +1 -0
  266. package/dist/deal-desk/tools/outreach-approve.d.ts +18 -0
  267. package/dist/deal-desk/tools/outreach-approve.d.ts.map +1 -0
  268. package/dist/deal-desk/tools/outreach-approve.js +229 -0
  269. package/dist/deal-desk/tools/outreach-approve.js.map +1 -0
  270. package/dist/deal-desk/tools/outreach-draft.d.ts +32 -0
  271. package/dist/deal-desk/tools/outreach-draft.d.ts.map +1 -0
  272. package/dist/deal-desk/tools/outreach-draft.js +101 -0
  273. package/dist/deal-desk/tools/outreach-draft.js.map +1 -0
  274. package/dist/deal-desk/tools/outreach-edit.d.ts +6 -0
  275. package/dist/deal-desk/tools/outreach-edit.d.ts.map +1 -0
  276. package/dist/deal-desk/tools/outreach-edit.js +94 -0
  277. package/dist/deal-desk/tools/outreach-edit.js.map +1 -0
  278. package/dist/deal-desk/tools/outreach-list-pending.d.ts +4 -0
  279. package/dist/deal-desk/tools/outreach-list-pending.d.ts.map +1 -0
  280. package/dist/deal-desk/tools/outreach-list-pending.js +55 -0
  281. package/dist/deal-desk/tools/outreach-list-pending.js.map +1 -0
  282. package/dist/deal-desk/tools/record-intermediary-touch.d.ts +20 -0
  283. package/dist/deal-desk/tools/record-intermediary-touch.d.ts.map +1 -0
  284. package/dist/deal-desk/tools/record-intermediary-touch.js +80 -0
  285. package/dist/deal-desk/tools/record-intermediary-touch.js.map +1 -0
  286. package/dist/deal-desk/tools/test-gmail-send.d.ts +21 -0
  287. package/dist/deal-desk/tools/test-gmail-send.d.ts.map +1 -0
  288. package/dist/deal-desk/tools/test-gmail-send.js +65 -0
  289. package/dist/deal-desk/tools/test-gmail-send.js.map +1 -0
  290. package/dist/deal-desk/tools/update-target.d.ts +6 -0
  291. package/dist/deal-desk/tools/update-target.d.ts.map +1 -0
  292. package/dist/deal-desk/tools/update-target.js +43 -0
  293. package/dist/deal-desk/tools/update-target.js.map +1 -0
  294. package/dist/dev-runner-worktree.d.ts +15 -0
  295. package/dist/dev-runner-worktree.d.ts.map +1 -0
  296. package/dist/dev-runner-worktree.js +68 -0
  297. package/dist/dev-runner-worktree.js.map +1 -0
  298. package/dist/dev-server-status.d.ts +27 -0
  299. package/dist/dev-server-status.d.ts.map +1 -0
  300. package/dist/dev-server-status.js +74 -0
  301. package/dist/dev-server-status.js.map +1 -0
  302. package/dist/dev-watch-ignore.d.ts +2 -0
  303. package/dist/dev-watch-ignore.d.ts.map +1 -0
  304. package/dist/dev-watch-ignore.js +36 -0
  305. package/dist/dev-watch-ignore.js.map +1 -0
  306. package/dist/embedded-postgres-watchdog.d.ts +12 -0
  307. package/dist/embedded-postgres-watchdog.d.ts.map +1 -0
  308. package/dist/embedded-postgres-watchdog.js +21 -0
  309. package/dist/embedded-postgres-watchdog.js.map +1 -0
  310. package/dist/errors.d.ts +12 -0
  311. package/dist/errors.d.ts.map +1 -0
  312. package/dist/errors.js +28 -0
  313. package/dist/errors.js.map +1 -0
  314. package/dist/home-paths.d.ts +15 -0
  315. package/dist/home-paths.d.ts.map +1 -0
  316. package/dist/home-paths.js +48 -0
  317. package/dist/home-paths.js.map +1 -0
  318. package/dist/index.d.ts +10 -0
  319. package/dist/index.d.ts.map +1 -0
  320. package/dist/index.js +787 -0
  321. package/dist/index.js.map +1 -0
  322. package/dist/lib/join-request-dedupe.d.ts +11 -0
  323. package/dist/lib/join-request-dedupe.d.ts.map +1 -0
  324. package/dist/lib/join-request-dedupe.js +49 -0
  325. package/dist/lib/join-request-dedupe.js.map +1 -0
  326. package/dist/log-redaction.d.ts +11 -0
  327. package/dist/log-redaction.d.ts.map +1 -0
  328. package/dist/log-redaction.js +122 -0
  329. package/dist/log-redaction.js.map +1 -0
  330. package/dist/middleware/auth.d.ts +12 -0
  331. package/dist/middleware/auth.d.ts.map +1 -0
  332. package/dist/middleware/auth.js +302 -0
  333. package/dist/middleware/auth.js.map +1 -0
  334. package/dist/middleware/board-mutation-guard.d.ts +3 -0
  335. package/dist/middleware/board-mutation-guard.d.ts.map +1 -0
  336. package/dist/middleware/board-mutation-guard.js +67 -0
  337. package/dist/middleware/board-mutation-guard.js.map +1 -0
  338. package/dist/middleware/error-handler.d.ts +17 -0
  339. package/dist/middleware/error-handler.d.ts.map +1 -0
  340. package/dist/middleware/error-handler.js +45 -0
  341. package/dist/middleware/error-handler.js.map +1 -0
  342. package/dist/middleware/http-log-policy.d.ts +2 -0
  343. package/dist/middleware/http-log-policy.d.ts.map +1 -0
  344. package/dist/middleware/http-log-policy.js +52 -0
  345. package/dist/middleware/http-log-policy.js.map +1 -0
  346. package/dist/middleware/index.d.ts +4 -0
  347. package/dist/middleware/index.d.ts.map +1 -0
  348. package/dist/middleware/index.js +4 -0
  349. package/dist/middleware/index.js.map +1 -0
  350. package/dist/middleware/logger.d.ts +4 -0
  351. package/dist/middleware/logger.d.ts.map +1 -0
  352. package/dist/middleware/logger.js +92 -0
  353. package/dist/middleware/logger.js.map +1 -0
  354. package/dist/middleware/private-hostname-guard.d.ts +11 -0
  355. package/dist/middleware/private-hostname-guard.d.ts.map +1 -0
  356. package/dist/middleware/private-hostname-guard.js +78 -0
  357. package/dist/middleware/private-hostname-guard.js.map +1 -0
  358. package/dist/middleware/validate.d.ts +4 -0
  359. package/dist/middleware/validate.d.ts.map +1 -0
  360. package/dist/middleware/validate.js +7 -0
  361. package/dist/middleware/validate.js.map +1 -0
  362. package/dist/onboarding-assets/ceo/AGENTS.md +59 -0
  363. package/dist/onboarding-assets/ceo/HEARTBEAT.md +85 -0
  364. package/dist/onboarding-assets/ceo/SOUL.md +33 -0
  365. package/dist/onboarding-assets/ceo/TOOLS.md +3 -0
  366. package/dist/onboarding-assets/default/AGENTS.md +17 -0
  367. package/dist/paths.d.ts +3 -0
  368. package/dist/paths.d.ts.map +1 -0
  369. package/dist/paths.js +31 -0
  370. package/dist/paths.js.map +1 -0
  371. package/dist/realtime/live-events-ws.d.ts +28 -0
  372. package/dist/realtime/live-events-ws.d.ts.map +1 -0
  373. package/dist/realtime/live-events-ws.js +187 -0
  374. package/dist/realtime/live-events-ws.js.map +1 -0
  375. package/dist/redaction.d.ts +5 -0
  376. package/dist/redaction.d.ts.map +1 -0
  377. package/dist/redaction.js +98 -0
  378. package/dist/redaction.js.map +1 -0
  379. package/dist/routes/__tests__/deal-desk-thesis.test.d.ts +2 -0
  380. package/dist/routes/__tests__/deal-desk-thesis.test.d.ts.map +1 -0
  381. package/dist/routes/__tests__/deal-desk-thesis.test.js +53 -0
  382. package/dist/routes/__tests__/deal-desk-thesis.test.js.map +1 -0
  383. package/dist/routes/__tests__/gmail-oauth.test.d.ts +2 -0
  384. package/dist/routes/__tests__/gmail-oauth.test.d.ts.map +1 -0
  385. package/dist/routes/__tests__/gmail-oauth.test.js +99 -0
  386. package/dist/routes/__tests__/gmail-oauth.test.js.map +1 -0
  387. package/dist/routes/access.d.ts +82 -0
  388. package/dist/routes/access.d.ts.map +1 -0
  389. package/dist/routes/access.js +3411 -0
  390. package/dist/routes/access.js.map +1 -0
  391. package/dist/routes/activity.d.ts +3 -0
  392. package/dist/routes/activity.d.ts.map +1 -0
  393. package/dist/routes/activity.js +90 -0
  394. package/dist/routes/activity.js.map +1 -0
  395. package/dist/routes/adapters.d.ts +16 -0
  396. package/dist/routes/adapters.d.ts.map +1 -0
  397. package/dist/routes/adapters.js +527 -0
  398. package/dist/routes/adapters.js.map +1 -0
  399. package/dist/routes/agents.d.ts +6 -0
  400. package/dist/routes/agents.d.ts.map +1 -0
  401. package/dist/routes/agents.js +2765 -0
  402. package/dist/routes/agents.js.map +1 -0
  403. package/dist/routes/approvals.d.ts +6 -0
  404. package/dist/routes/approvals.d.ts.map +1 -0
  405. package/dist/routes/approvals.js +300 -0
  406. package/dist/routes/approvals.js.map +1 -0
  407. package/dist/routes/assets.d.ts +4 -0
  408. package/dist/routes/assets.d.ts.map +1 -0
  409. package/dist/routes/assets.js +309 -0
  410. package/dist/routes/assets.js.map +1 -0
  411. package/dist/routes/auth.d.ts +3 -0
  412. package/dist/routes/auth.d.ts.map +1 -0
  413. package/dist/routes/auth.js +82 -0
  414. package/dist/routes/auth.js.map +1 -0
  415. package/dist/routes/authz.d.ts +19 -0
  416. package/dist/routes/authz.d.ts.map +1 -0
  417. package/dist/routes/authz.js +75 -0
  418. package/dist/routes/authz.js.map +1 -0
  419. package/dist/routes/companies.d.ts +4 -0
  420. package/dist/routes/companies.d.ts.map +1 -0
  421. package/dist/routes/companies.js +359 -0
  422. package/dist/routes/companies.js.map +1 -0
  423. package/dist/routes/company-skills.d.ts +3 -0
  424. package/dist/routes/company-skills.d.ts.map +1 -0
  425. package/dist/routes/company-skills.js +258 -0
  426. package/dist/routes/company-skills.js.map +1 -0
  427. package/dist/routes/costs.d.ts +11 -0
  428. package/dist/routes/costs.d.ts.map +1 -0
  429. package/dist/routes/costs.js +307 -0
  430. package/dist/routes/costs.js.map +1 -0
  431. package/dist/routes/dashboard.d.ts +3 -0
  432. package/dist/routes/dashboard.d.ts.map +1 -0
  433. package/dist/routes/dashboard.js +15 -0
  434. package/dist/routes/dashboard.js.map +1 -0
  435. package/dist/routes/deal-desk.d.ts +83 -0
  436. package/dist/routes/deal-desk.d.ts.map +1 -0
  437. package/dist/routes/deal-desk.js +288 -0
  438. package/dist/routes/deal-desk.js.map +1 -0
  439. package/dist/routes/deal-desk.test.d.ts +2 -0
  440. package/dist/routes/deal-desk.test.d.ts.map +1 -0
  441. package/dist/routes/deal-desk.test.js +291 -0
  442. package/dist/routes/deal-desk.test.js.map +1 -0
  443. package/dist/routes/environment-selection.d.ts +13 -0
  444. package/dist/routes/environment-selection.d.ts.map +1 -0
  445. package/dist/routes/environment-selection.js +30 -0
  446. package/dist/routes/environment-selection.js.map +1 -0
  447. package/dist/routes/environments.d.ts +6 -0
  448. package/dist/routes/environments.d.ts.map +1 -0
  449. package/dist/routes/environments.js +408 -0
  450. package/dist/routes/environments.js.map +1 -0
  451. package/dist/routes/execution-workspaces.d.ts +3 -0
  452. package/dist/routes/execution-workspaces.d.ts.map +1 -0
  453. package/dist/routes/execution-workspaces.js +536 -0
  454. package/dist/routes/execution-workspaces.js.map +1 -0
  455. package/dist/routes/gmail-oauth.d.ts +14 -0
  456. package/dist/routes/gmail-oauth.d.ts.map +1 -0
  457. package/dist/routes/gmail-oauth.js +124 -0
  458. package/dist/routes/gmail-oauth.js.map +1 -0
  459. package/dist/routes/goals.d.ts +3 -0
  460. package/dist/routes/goals.d.ts.map +1 -0
  461. package/dist/routes/goals.js +101 -0
  462. package/dist/routes/goals.js.map +1 -0
  463. package/dist/routes/health.d.ts +9 -0
  464. package/dist/routes/health.d.ts.map +1 -0
  465. package/dist/routes/health.js +114 -0
  466. package/dist/routes/health.js.map +1 -0
  467. package/dist/routes/inbox-dismissals.d.ts +3 -0
  468. package/dist/routes/inbox-dismissals.d.ts.map +1 -0
  469. package/dist/routes/inbox-dismissals.js +58 -0
  470. package/dist/routes/inbox-dismissals.js.map +1 -0
  471. package/dist/routes/index.d.ts +21 -0
  472. package/dist/routes/index.d.ts.map +1 -0
  473. package/dist/routes/index.js +21 -0
  474. package/dist/routes/index.js.map +1 -0
  475. package/dist/routes/instance-database-backups.d.ts +15 -0
  476. package/dist/routes/instance-database-backups.d.ts.map +1 -0
  477. package/dist/routes/instance-database-backups.js +12 -0
  478. package/dist/routes/instance-database-backups.js.map +1 -0
  479. package/dist/routes/instance-settings.d.ts +3 -0
  480. package/dist/routes/instance-settings.d.ts.map +1 -0
  481. package/dist/routes/instance-settings.js +110 -0
  482. package/dist/routes/instance-settings.js.map +1 -0
  483. package/dist/routes/issue-tree-control.d.ts +3 -0
  484. package/dist/routes/issue-tree-control.d.ts.map +1 -0
  485. package/dist/routes/issue-tree-control.js +363 -0
  486. package/dist/routes/issue-tree-control.js.map +1 -0
  487. package/dist/routes/issues-checkout-wakeup.d.ts +9 -0
  488. package/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
  489. package/dist/routes/issues-checkout-wakeup.js +12 -0
  490. package/dist/routes/issues-checkout-wakeup.js.map +1 -0
  491. package/dist/routes/issues.d.ts +23 -0
  492. package/dist/routes/issues.d.ts.map +1 -0
  493. package/dist/routes/issues.js +4094 -0
  494. package/dist/routes/issues.js.map +1 -0
  495. package/dist/routes/llms.d.ts +3 -0
  496. package/dist/routes/llms.d.ts.map +1 -0
  497. package/dist/routes/llms.js +80 -0
  498. package/dist/routes/llms.js.map +1 -0
  499. package/dist/routes/org-chart-svg.d.ts +25 -0
  500. package/dist/routes/org-chart-svg.d.ts.map +1 -0
  501. package/dist/routes/org-chart-svg.js +656 -0
  502. package/dist/routes/org-chart-svg.js.map +1 -0
  503. package/dist/routes/plugin-ui-static.d.ts +69 -0
  504. package/dist/routes/plugin-ui-static.d.ts.map +1 -0
  505. package/dist/routes/plugin-ui-static.js +411 -0
  506. package/dist/routes/plugin-ui-static.js.map +1 -0
  507. package/dist/routes/plugins.d.ts +121 -0
  508. package/dist/routes/plugins.d.ts.map +1 -0
  509. package/dist/routes/plugins.js +2184 -0
  510. package/dist/routes/plugins.js.map +1 -0
  511. package/dist/routes/projects.d.ts +3 -0
  512. package/dist/routes/projects.d.ts.map +1 -0
  513. package/dist/routes/projects.js +572 -0
  514. package/dist/routes/projects.js.map +1 -0
  515. package/dist/routes/routines.d.ts +6 -0
  516. package/dist/routes/routines.d.ts.map +1 -0
  517. package/dist/routes/routines.js +417 -0
  518. package/dist/routes/routines.js.map +1 -0
  519. package/dist/routes/secrets.d.ts +3 -0
  520. package/dist/routes/secrets.d.ts.map +1 -0
  521. package/dist/routes/secrets.js +392 -0
  522. package/dist/routes/secrets.js.map +1 -0
  523. package/dist/routes/sidebar-badges.d.ts +3 -0
  524. package/dist/routes/sidebar-badges.d.ts.map +1 -0
  525. package/dist/routes/sidebar-badges.js +68 -0
  526. package/dist/routes/sidebar-badges.js.map +1 -0
  527. package/dist/routes/sidebar-preferences.d.ts +3 -0
  528. package/dist/routes/sidebar-preferences.d.ts.map +1 -0
  529. package/dist/routes/sidebar-preferences.js +63 -0
  530. package/dist/routes/sidebar-preferences.js.map +1 -0
  531. package/dist/routes/user-profiles.d.ts +3 -0
  532. package/dist/routes/user-profiles.d.ts.map +1 -0
  533. package/dist/routes/user-profiles.js +337 -0
  534. package/dist/routes/user-profiles.js.map +1 -0
  535. package/dist/routes/workspace-command-authz.d.ts +14 -0
  536. package/dist/routes/workspace-command-authz.d.ts.map +1 -0
  537. package/dist/routes/workspace-command-authz.js +83 -0
  538. package/dist/routes/workspace-command-authz.js.map +1 -0
  539. package/dist/routes/workspace-runtime-service-authz.d.ts +12 -0
  540. package/dist/routes/workspace-runtime-service-authz.d.ts.map +1 -0
  541. package/dist/routes/workspace-runtime-service-authz.js +96 -0
  542. package/dist/routes/workspace-runtime-service-authz.js.map +1 -0
  543. package/dist/runtime-api.d.ts +19 -0
  544. package/dist/runtime-api.d.ts.map +1 -0
  545. package/dist/runtime-api.js +137 -0
  546. package/dist/runtime-api.js.map +1 -0
  547. package/dist/secrets/aws-secrets-manager-provider.d.ts +87 -0
  548. package/dist/secrets/aws-secrets-manager-provider.d.ts.map +1 -0
  549. package/dist/secrets/aws-secrets-manager-provider.js +748 -0
  550. package/dist/secrets/aws-secrets-manager-provider.js.map +1 -0
  551. package/dist/secrets/configured-provider.d.ts +3 -0
  552. package/dist/secrets/configured-provider.d.ts.map +1 -0
  553. package/dist/secrets/configured-provider.js +8 -0
  554. package/dist/secrets/configured-provider.js.map +1 -0
  555. package/dist/secrets/external-stub-providers.d.ts +5 -0
  556. package/dist/secrets/external-stub-providers.d.ts.map +1 -0
  557. package/dist/secrets/external-stub-providers.js +71 -0
  558. package/dist/secrets/external-stub-providers.js.map +1 -0
  559. package/dist/secrets/local-encrypted-provider.d.ts +3 -0
  560. package/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
  561. package/dist/secrets/local-encrypted-provider.js +244 -0
  562. package/dist/secrets/local-encrypted-provider.js.map +1 -0
  563. package/dist/secrets/provider-registry.d.ts +6 -0
  564. package/dist/secrets/provider-registry.d.ts.map +1 -0
  565. package/dist/secrets/provider-registry.js +24 -0
  566. package/dist/secrets/provider-registry.js.map +1 -0
  567. package/dist/secrets/types.d.ts +131 -0
  568. package/dist/secrets/types.d.ts.map +1 -0
  569. package/dist/secrets/types.js +36 -0
  570. package/dist/secrets/types.js.map +1 -0
  571. package/dist/services/access.d.ts +171 -0
  572. package/dist/services/access.d.ts.map +1 -0
  573. package/dist/services/access.js +522 -0
  574. package/dist/services/access.js.map +1 -0
  575. package/dist/services/activity-log.d.ts +19 -0
  576. package/dist/services/activity-log.d.ts.map +1 -0
  577. package/dist/services/activity-log.js +99 -0
  578. package/dist/services/activity-log.js.map +1 -0
  579. package/dist/services/activity.d.ts +462 -0
  580. package/dist/services/activity.d.ts.map +1 -0
  581. package/dist/services/activity.js +443 -0
  582. package/dist/services/activity.js.map +1 -0
  583. package/dist/services/adapter-plugin-store.d.ts +36 -0
  584. package/dist/services/adapter-plugin-store.d.ts.map +1 -0
  585. package/dist/services/adapter-plugin-store.js +154 -0
  586. package/dist/services/adapter-plugin-store.js.map +1 -0
  587. package/dist/services/agent-instructions.d.ts +91 -0
  588. package/dist/services/agent-instructions.d.ts.map +1 -0
  589. package/dist/services/agent-instructions.js +580 -0
  590. package/dist/services/agent-instructions.js.map +1 -0
  591. package/dist/services/agent-permissions.d.ts +6 -0
  592. package/dist/services/agent-permissions.d.ts.map +1 -0
  593. package/dist/services/agent-permissions.js +18 -0
  594. package/dist/services/agent-permissions.js.map +1 -0
  595. package/dist/services/agent-start-lock.d.ts +2 -0
  596. package/dist/services/agent-start-lock.d.ts.map +1 -0
  597. package/dist/services/agent-start-lock.js +43 -0
  598. package/dist/services/agent-start-lock.js.map +1 -0
  599. package/dist/services/agents.d.ts +2253 -0
  600. package/dist/services/agents.d.ts.map +1 -0
  601. package/dist/services/agents.js +609 -0
  602. package/dist/services/agents.js.map +1 -0
  603. package/dist/services/approvals.d.ts +546 -0
  604. package/dist/services/approvals.d.ts.map +1 -0
  605. package/dist/services/approvals.js +212 -0
  606. package/dist/services/approvals.js.map +1 -0
  607. package/dist/services/assets.d.ts +33 -0
  608. package/dist/services/assets.d.ts.map +1 -0
  609. package/dist/services/assets.js +17 -0
  610. package/dist/services/assets.js.map +1 -0
  611. package/dist/services/board-auth.d.ts +239 -0
  612. package/dist/services/board-auth.d.ts.map +1 -0
  613. package/dist/services/board-auth.js +300 -0
  614. package/dist/services/board-auth.js.map +1 -0
  615. package/dist/services/budgets.d.ts +38 -0
  616. package/dist/services/budgets.d.ts.map +1 -0
  617. package/dist/services/budgets.js +784 -0
  618. package/dist/services/budgets.js.map +1 -0
  619. package/dist/services/companies.d.ts +154 -0
  620. package/dist/services/companies.d.ts.map +1 -0
  621. package/dist/services/companies.js +286 -0
  622. package/dist/services/companies.js.map +1 -0
  623. package/dist/services/company-export-readme.d.ts +17 -0
  624. package/dist/services/company-export-readme.d.ts.map +1 -0
  625. package/dist/services/company-export-readme.js +148 -0
  626. package/dist/services/company-export-readme.js.map +1 -0
  627. package/dist/services/company-member-roles.d.ts +9 -0
  628. package/dist/services/company-member-roles.d.ts.map +1 -0
  629. package/dist/services/company-member-roles.js +46 -0
  630. package/dist/services/company-member-roles.js.map +1 -0
  631. package/dist/services/company-portability.d.ts +24 -0
  632. package/dist/services/company-portability.d.ts.map +1 -0
  633. package/dist/services/company-portability.js +4077 -0
  634. package/dist/services/company-portability.js.map +1 -0
  635. package/dist/services/company-search-rate-limit.d.ts +22 -0
  636. package/dist/services/company-search-rate-limit.d.ts.map +1 -0
  637. package/dist/services/company-search-rate-limit.js +38 -0
  638. package/dist/services/company-search-rate-limit.js.map +1 -0
  639. package/dist/services/company-search.d.ts +8 -0
  640. package/dist/services/company-search.d.ts.map +1 -0
  641. package/dist/services/company-search.js +626 -0
  642. package/dist/services/company-search.js.map +1 -0
  643. package/dist/services/company-skills.d.ts +77 -0
  644. package/dist/services/company-skills.d.ts.map +1 -0
  645. package/dist/services/company-skills.js +2131 -0
  646. package/dist/services/company-skills.js.map +1 -0
  647. package/dist/services/cost-backfill.d.ts +16 -0
  648. package/dist/services/cost-backfill.d.ts.map +1 -0
  649. package/dist/services/cost-backfill.js +115 -0
  650. package/dist/services/cost-backfill.js.map +1 -0
  651. package/dist/services/cost-ledger.d.ts +28 -0
  652. package/dist/services/cost-ledger.d.ts.map +1 -0
  653. package/dist/services/cost-ledger.js +140 -0
  654. package/dist/services/cost-ledger.js.map +1 -0
  655. package/dist/services/cost-ledger.test.d.ts +2 -0
  656. package/dist/services/cost-ledger.test.d.ts.map +1 -0
  657. package/dist/services/cost-ledger.test.js +50 -0
  658. package/dist/services/cost-ledger.test.js.map +1 -0
  659. package/dist/services/cost-pipeline-health.d.ts +4 -0
  660. package/dist/services/cost-pipeline-health.d.ts.map +1 -0
  661. package/dist/services/cost-pipeline-health.js +42 -0
  662. package/dist/services/cost-pipeline-health.js.map +1 -0
  663. package/dist/services/costs.d.ts +128 -0
  664. package/dist/services/costs.d.ts.map +1 -0
  665. package/dist/services/costs.js +412 -0
  666. package/dist/services/costs.js.map +1 -0
  667. package/dist/services/cron.d.ts +80 -0
  668. package/dist/services/cron.d.ts.map +1 -0
  669. package/dist/services/cron.js +300 -0
  670. package/dist/services/cron.js.map +1 -0
  671. package/dist/services/dashboard.d.ts +34 -0
  672. package/dist/services/dashboard.d.ts.map +1 -0
  673. package/dist/services/dashboard.js +142 -0
  674. package/dist/services/dashboard.js.map +1 -0
  675. package/dist/services/default-agent-instructions.d.ts +9 -0
  676. package/dist/services/default-agent-instructions.d.ts.map +1 -0
  677. package/dist/services/default-agent-instructions.js +20 -0
  678. package/dist/services/default-agent-instructions.js.map +1 -0
  679. package/dist/services/documents.d.ts +199 -0
  680. package/dist/services/documents.d.ts.map +1 -0
  681. package/dist/services/documents.js +411 -0
  682. package/dist/services/documents.js.map +1 -0
  683. package/dist/services/environment-config.d.ts +55 -0
  684. package/dist/services/environment-config.d.ts.map +1 -0
  685. package/dist/services/environment-config.js +441 -0
  686. package/dist/services/environment-config.js.map +1 -0
  687. package/dist/services/environment-execution-target.d.ts +21 -0
  688. package/dist/services/environment-execution-target.d.ts.map +1 -0
  689. package/dist/services/environment-execution-target.js +121 -0
  690. package/dist/services/environment-execution-target.js.map +1 -0
  691. package/dist/services/environment-probe.d.ts +9 -0
  692. package/dist/services/environment-probe.d.ts.map +1 -0
  693. package/dist/services/environment-probe.js +106 -0
  694. package/dist/services/environment-probe.js.map +1 -0
  695. package/dist/services/environment-run-orchestrator.d.ts +124 -0
  696. package/dist/services/environment-run-orchestrator.d.ts.map +1 -0
  697. package/dist/services/environment-run-orchestrator.js +392 -0
  698. package/dist/services/environment-run-orchestrator.js.map +1 -0
  699. package/dist/services/environment-runtime.d.ts +90 -0
  700. package/dist/services/environment-runtime.d.ts.map +1 -0
  701. package/dist/services/environment-runtime.js +968 -0
  702. package/dist/services/environment-runtime.js.map +1 -0
  703. package/dist/services/environments.d.ts +36 -0
  704. package/dist/services/environments.d.ts.map +1 -0
  705. package/dist/services/environments.js +260 -0
  706. package/dist/services/environments.js.map +1 -0
  707. package/dist/services/execution-workspace-policy.d.ts +30 -0
  708. package/dist/services/execution-workspace-policy.d.ts.map +1 -0
  709. package/dist/services/execution-workspace-policy.js +195 -0
  710. package/dist/services/execution-workspace-policy.js.map +1 -0
  711. package/dist/services/execution-workspaces.d.ts +30 -0
  712. package/dist/services/execution-workspaces.d.ts.map +1 -0
  713. package/dist/services/execution-workspaces.js +635 -0
  714. package/dist/services/execution-workspaces.js.map +1 -0
  715. package/dist/services/feedback-redaction.d.ts +23 -0
  716. package/dist/services/feedback-redaction.d.ts.map +1 -0
  717. package/dist/services/feedback-redaction.js +150 -0
  718. package/dist/services/feedback-redaction.js.map +1 -0
  719. package/dist/services/feedback-share-client.d.ts +9 -0
  720. package/dist/services/feedback-share-client.d.ts.map +1 -0
  721. package/dist/services/feedback-share-client.js +46 -0
  722. package/dist/services/feedback-share-client.js.map +1 -0
  723. package/dist/services/feedback.d.ts +93 -0
  724. package/dist/services/feedback.d.ts.map +1 -0
  725. package/dist/services/feedback.js +1717 -0
  726. package/dist/services/feedback.js.map +1 -0
  727. package/dist/services/finance.d.ts +93 -0
  728. package/dist/services/finance.d.ts.map +1 -0
  729. package/dist/services/finance.js +120 -0
  730. package/dist/services/finance.js.map +1 -0
  731. package/dist/services/github-fetch.d.ts +4 -0
  732. package/dist/services/github-fetch.d.ts.map +1 -0
  733. package/dist/services/github-fetch.js +23 -0
  734. package/dist/services/github-fetch.js.map +1 -0
  735. package/dist/services/goals.d.ts +433 -0
  736. package/dist/services/goals.d.ts.map +1 -0
  737. package/dist/services/goals.js +54 -0
  738. package/dist/services/goals.js.map +1 -0
  739. package/dist/services/heartbeat-run-summary.d.ts +7 -0
  740. package/dist/services/heartbeat-run-summary.d.ts.map +1 -0
  741. package/dist/services/heartbeat-run-summary.js +84 -0
  742. package/dist/services/heartbeat-run-summary.js.map +1 -0
  743. package/dist/services/heartbeat-stop-metadata.d.ts +28 -0
  744. package/dist/services/heartbeat-stop-metadata.d.ts.map +1 -0
  745. package/dist/services/heartbeat-stop-metadata.js +86 -0
  746. package/dist/services/heartbeat-stop-metadata.js.map +1 -0
  747. package/dist/services/heartbeat-stop-metadata.test.d.ts +2 -0
  748. package/dist/services/heartbeat-stop-metadata.test.d.ts.map +1 -0
  749. package/dist/services/heartbeat-stop-metadata.test.js +93 -0
  750. package/dist/services/heartbeat-stop-metadata.test.js.map +1 -0
  751. package/dist/services/heartbeat.d.ts +1546 -0
  752. package/dist/services/heartbeat.d.ts.map +1 -0
  753. package/dist/services/heartbeat.js +7854 -0
  754. package/dist/services/heartbeat.js.map +1 -0
  755. package/dist/services/hire-hook.d.ts +14 -0
  756. package/dist/services/hire-hook.d.ts.map +1 -0
  757. package/dist/services/hire-hook.js +85 -0
  758. package/dist/services/hire-hook.js.map +1 -0
  759. package/dist/services/inbox-dismissals.d.ts +22 -0
  760. package/dist/services/inbox-dismissals.d.ts.map +1 -0
  761. package/dist/services/inbox-dismissals.js +33 -0
  762. package/dist/services/inbox-dismissals.js.map +1 -0
  763. package/dist/services/index.d.ts +45 -0
  764. package/dist/services/index.d.ts.map +1 -0
  765. package/dist/services/index.js +45 -0
  766. package/dist/services/index.js.map +1 -0
  767. package/dist/services/instance-settings.d.ts +11 -0
  768. package/dist/services/instance-settings.d.ts.map +1 -0
  769. package/dist/services/instance-settings.js +138 -0
  770. package/dist/services/instance-settings.js.map +1 -0
  771. package/dist/services/invite-grants.d.ts +15 -0
  772. package/dist/services/invite-grants.d.ts.map +1 -0
  773. package/dist/services/invite-grants.js +50 -0
  774. package/dist/services/invite-grants.js.map +1 -0
  775. package/dist/services/issue-approvals.d.ts +56 -0
  776. package/dist/services/issue-approvals.d.ts.map +1 -0
  777. package/dist/services/issue-approvals.js +153 -0
  778. package/dist/services/issue-approvals.js.map +1 -0
  779. package/dist/services/issue-assignment-wakeup.d.ts +29 -0
  780. package/dist/services/issue-assignment-wakeup.d.ts.map +1 -0
  781. package/dist/services/issue-assignment-wakeup.js +22 -0
  782. package/dist/services/issue-assignment-wakeup.js.map +1 -0
  783. package/dist/services/issue-continuation-summary.d.ts +68 -0
  784. package/dist/services/issue-continuation-summary.d.ts.map +1 -0
  785. package/dist/services/issue-continuation-summary.js +222 -0
  786. package/dist/services/issue-continuation-summary.js.map +1 -0
  787. package/dist/services/issue-execution-policy.d.ts +93 -0
  788. package/dist/services/issue-execution-policy.d.ts.map +1 -0
  789. package/dist/services/issue-execution-policy.js +838 -0
  790. package/dist/services/issue-execution-policy.js.map +1 -0
  791. package/dist/services/issue-goal-fallback.d.ts +18 -0
  792. package/dist/services/issue-goal-fallback.d.ts.map +1 -0
  793. package/dist/services/issue-goal-fallback.js +33 -0
  794. package/dist/services/issue-goal-fallback.js.map +1 -0
  795. package/dist/services/issue-liveness.d.ts +3 -0
  796. package/dist/services/issue-liveness.d.ts.map +1 -0
  797. package/dist/services/issue-liveness.js +2 -0
  798. package/dist/services/issue-liveness.js.map +1 -0
  799. package/dist/services/issue-recovery-actions.d.ts +40 -0
  800. package/dist/services/issue-recovery-actions.d.ts.map +1 -0
  801. package/dist/services/issue-recovery-actions.js +204 -0
  802. package/dist/services/issue-recovery-actions.js.map +1 -0
  803. package/dist/services/issue-references.d.ts +21 -0
  804. package/dist/services/issue-references.d.ts.map +1 -0
  805. package/dist/services/issue-references.js +318 -0
  806. package/dist/services/issue-references.js.map +1 -0
  807. package/dist/services/issue-thread-interactions.d.ts +76 -0
  808. package/dist/services/issue-thread-interactions.d.ts.map +1 -0
  809. package/dist/services/issue-thread-interactions.js +923 -0
  810. package/dist/services/issue-thread-interactions.js.map +1 -0
  811. package/dist/services/issue-thread-interactions.test.d.ts +2 -0
  812. package/dist/services/issue-thread-interactions.test.d.ts.map +1 -0
  813. package/dist/services/issue-thread-interactions.test.js +195 -0
  814. package/dist/services/issue-thread-interactions.test.js.map +1 -0
  815. package/dist/services/issue-tree-control.d.ts +89 -0
  816. package/dist/services/issue-tree-control.d.ts.map +1 -0
  817. package/dist/services/issue-tree-control.js +933 -0
  818. package/dist/services/issue-tree-control.js.map +1 -0
  819. package/dist/services/issues.d.ts +744 -0
  820. package/dist/services/issues.d.ts.map +1 -0
  821. package/dist/services/issues.js +3374 -0
  822. package/dist/services/issues.js.map +1 -0
  823. package/dist/services/json-schema-secret-refs.d.ts +5 -0
  824. package/dist/services/json-schema-secret-refs.d.ts.map +1 -0
  825. package/dist/services/json-schema-secret-refs.js +67 -0
  826. package/dist/services/json-schema-secret-refs.js.map +1 -0
  827. package/dist/services/live-events.d.ts +17 -0
  828. package/dist/services/live-events.d.ts.map +1 -0
  829. package/dist/services/live-events.js +33 -0
  830. package/dist/services/live-events.js.map +1 -0
  831. package/dist/services/local-service-supervisor.d.ts +56 -0
  832. package/dist/services/local-service-supervisor.d.ts.map +1 -0
  833. package/dist/services/local-service-supervisor.js +284 -0
  834. package/dist/services/local-service-supervisor.js.map +1 -0
  835. package/dist/services/plugin-capability-validator.d.ts +108 -0
  836. package/dist/services/plugin-capability-validator.d.ts.map +1 -0
  837. package/dist/services/plugin-capability-validator.js +313 -0
  838. package/dist/services/plugin-capability-validator.js.map +1 -0
  839. package/dist/services/plugin-config-validator.d.ts +26 -0
  840. package/dist/services/plugin-config-validator.d.ts.map +1 -0
  841. package/dist/services/plugin-config-validator.js +41 -0
  842. package/dist/services/plugin-config-validator.js.map +1 -0
  843. package/dist/services/plugin-database.d.ts +49 -0
  844. package/dist/services/plugin-database.d.ts.map +1 -0
  845. package/dist/services/plugin-database.js +440 -0
  846. package/dist/services/plugin-database.js.map +1 -0
  847. package/dist/services/plugin-dev-watcher.d.ts +30 -0
  848. package/dist/services/plugin-dev-watcher.d.ts.map +1 -0
  849. package/dist/services/plugin-dev-watcher.js +246 -0
  850. package/dist/services/plugin-dev-watcher.js.map +1 -0
  851. package/dist/services/plugin-environment-driver.d.ts +126 -0
  852. package/dist/services/plugin-environment-driver.d.ts.map +1 -0
  853. package/dist/services/plugin-environment-driver.js +226 -0
  854. package/dist/services/plugin-environment-driver.js.map +1 -0
  855. package/dist/services/plugin-event-bus.d.ts +149 -0
  856. package/dist/services/plugin-event-bus.d.ts.map +1 -0
  857. package/dist/services/plugin-event-bus.js +258 -0
  858. package/dist/services/plugin-event-bus.js.map +1 -0
  859. package/dist/services/plugin-host-service-cleanup.d.ts +14 -0
  860. package/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
  861. package/dist/services/plugin-host-service-cleanup.js +37 -0
  862. package/dist/services/plugin-host-service-cleanup.js.map +1 -0
  863. package/dist/services/plugin-host-services.d.ts +17 -0
  864. package/dist/services/plugin-host-services.d.ts.map +1 -0
  865. package/dist/services/plugin-host-services.js +1867 -0
  866. package/dist/services/plugin-host-services.js.map +1 -0
  867. package/dist/services/plugin-job-coordinator.d.ts +81 -0
  868. package/dist/services/plugin-job-coordinator.d.ts.map +1 -0
  869. package/dist/services/plugin-job-coordinator.js +172 -0
  870. package/dist/services/plugin-job-coordinator.js.map +1 -0
  871. package/dist/services/plugin-job-scheduler.d.ts +163 -0
  872. package/dist/services/plugin-job-scheduler.d.ts.map +1 -0
  873. package/dist/services/plugin-job-scheduler.js +459 -0
  874. package/dist/services/plugin-job-scheduler.js.map +1 -0
  875. package/dist/services/plugin-job-store.d.ts +208 -0
  876. package/dist/services/plugin-job-store.d.ts.map +1 -0
  877. package/dist/services/plugin-job-store.js +350 -0
  878. package/dist/services/plugin-job-store.js.map +1 -0
  879. package/dist/services/plugin-lifecycle.d.ts +203 -0
  880. package/dist/services/plugin-lifecycle.d.ts.map +1 -0
  881. package/dist/services/plugin-lifecycle.js +476 -0
  882. package/dist/services/plugin-lifecycle.js.map +1 -0
  883. package/dist/services/plugin-loader.d.ts +445 -0
  884. package/dist/services/plugin-loader.d.ts.map +1 -0
  885. package/dist/services/plugin-loader.js +1273 -0
  886. package/dist/services/plugin-loader.js.map +1 -0
  887. package/dist/services/plugin-local-folders.d.ts +49 -0
  888. package/dist/services/plugin-local-folders.d.ts.map +1 -0
  889. package/dist/services/plugin-local-folders.js +506 -0
  890. package/dist/services/plugin-local-folders.js.map +1 -0
  891. package/dist/services/plugin-log-retention.d.ts +20 -0
  892. package/dist/services/plugin-log-retention.d.ts.map +1 -0
  893. package/dist/services/plugin-log-retention.js +63 -0
  894. package/dist/services/plugin-log-retention.js.map +1 -0
  895. package/dist/services/plugin-managed-agents.d.ts +15 -0
  896. package/dist/services/plugin-managed-agents.d.ts.map +1 -0
  897. package/dist/services/plugin-managed-agents.js +458 -0
  898. package/dist/services/plugin-managed-agents.js.map +1 -0
  899. package/dist/services/plugin-managed-routines.d.ts +41 -0
  900. package/dist/services/plugin-managed-routines.d.ts.map +1 -0
  901. package/dist/services/plugin-managed-routines.js +416 -0
  902. package/dist/services/plugin-managed-routines.js.map +1 -0
  903. package/dist/services/plugin-managed-skills.d.ts +14 -0
  904. package/dist/services/plugin-managed-skills.d.ts.map +1 -0
  905. package/dist/services/plugin-managed-skills.js +264 -0
  906. package/dist/services/plugin-managed-skills.js.map +1 -0
  907. package/dist/services/plugin-manifest-validator.d.ts +79 -0
  908. package/dist/services/plugin-manifest-validator.d.ts.map +1 -0
  909. package/dist/services/plugin-manifest-validator.js +84 -0
  910. package/dist/services/plugin-manifest-validator.js.map +1 -0
  911. package/dist/services/plugin-registry.d.ts +2550 -0
  912. package/dist/services/plugin-registry.d.ts.map +1 -0
  913. package/dist/services/plugin-registry.js +581 -0
  914. package/dist/services/plugin-registry.js.map +1 -0
  915. package/dist/services/plugin-runtime-sandbox.d.ts +40 -0
  916. package/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
  917. package/dist/services/plugin-runtime-sandbox.js +154 -0
  918. package/dist/services/plugin-runtime-sandbox.js.map +1 -0
  919. package/dist/services/plugin-secrets-handler.d.ts +83 -0
  920. package/dist/services/plugin-secrets-handler.d.ts.map +1 -0
  921. package/dist/services/plugin-secrets-handler.js +168 -0
  922. package/dist/services/plugin-secrets-handler.js.map +1 -0
  923. package/dist/services/plugin-state-store.d.ts +92 -0
  924. package/dist/services/plugin-state-store.d.ts.map +1 -0
  925. package/dist/services/plugin-state-store.js +190 -0
  926. package/dist/services/plugin-state-store.js.map +1 -0
  927. package/dist/services/plugin-stream-bus.d.ts +29 -0
  928. package/dist/services/plugin-stream-bus.d.ts.map +1 -0
  929. package/dist/services/plugin-stream-bus.js +48 -0
  930. package/dist/services/plugin-stream-bus.js.map +1 -0
  931. package/dist/services/plugin-tool-dispatcher.d.ts +180 -0
  932. package/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
  933. package/dist/services/plugin-tool-dispatcher.js +224 -0
  934. package/dist/services/plugin-tool-dispatcher.js.map +1 -0
  935. package/dist/services/plugin-tool-registry.d.ts +192 -0
  936. package/dist/services/plugin-tool-registry.d.ts.map +1 -0
  937. package/dist/services/plugin-tool-registry.js +224 -0
  938. package/dist/services/plugin-tool-registry.js.map +1 -0
  939. package/dist/services/plugin-worker-manager.d.ts +262 -0
  940. package/dist/services/plugin-worker-manager.d.ts.map +1 -0
  941. package/dist/services/plugin-worker-manager.js +842 -0
  942. package/dist/services/plugin-worker-manager.js.map +1 -0
  943. package/dist/services/productivity-review.d.ts +83 -0
  944. package/dist/services/productivity-review.d.ts.map +1 -0
  945. package/dist/services/productivity-review.js +652 -0
  946. package/dist/services/productivity-review.js.map +1 -0
  947. package/dist/services/project-workspace-runtime-config.d.ts +4 -0
  948. package/dist/services/project-workspace-runtime-config.d.ts.map +1 -0
  949. package/dist/services/project-workspace-runtime-config.js +54 -0
  950. package/dist/services/project-workspace-runtime-config.js.map +1 -0
  951. package/dist/services/projects.d.ts +99 -0
  952. package/dist/services/projects.d.ts.map +1 -0
  953. package/dist/services/projects.js +822 -0
  954. package/dist/services/projects.js.map +1 -0
  955. package/dist/services/quota-windows.d.ts +9 -0
  956. package/dist/services/quota-windows.d.ts.map +1 -0
  957. package/dist/services/quota-windows.js +56 -0
  958. package/dist/services/quota-windows.js.map +1 -0
  959. package/dist/services/recovery/index.d.ts +10 -0
  960. package/dist/services/recovery/index.d.ts.map +1 -0
  961. package/dist/services/recovery/index.js +6 -0
  962. package/dist/services/recovery/index.js.map +1 -0
  963. package/dist/services/recovery/issue-graph-liveness.d.ts +85 -0
  964. package/dist/services/recovery/issue-graph-liveness.d.ts.map +1 -0
  965. package/dist/services/recovery/issue-graph-liveness.js +356 -0
  966. package/dist/services/recovery/issue-graph-liveness.js.map +1 -0
  967. package/dist/services/recovery/model-profile-hint.d.ts +8 -0
  968. package/dist/services/recovery/model-profile-hint.d.ts.map +1 -0
  969. package/dist/services/recovery/model-profile-hint.js +11 -0
  970. package/dist/services/recovery/model-profile-hint.js.map +1 -0
  971. package/dist/services/recovery/origins.d.ts +36 -0
  972. package/dist/services/recovery/origins.d.ts.map +1 -0
  973. package/dist/services/recovery/origins.js +45 -0
  974. package/dist/services/recovery/origins.js.map +1 -0
  975. package/dist/services/recovery/pause-hold-guard.d.ts +6 -0
  976. package/dist/services/recovery/pause-hold-guard.d.ts.map +1 -0
  977. package/dist/services/recovery/pause-hold-guard.js +6 -0
  978. package/dist/services/recovery/pause-hold-guard.js.map +1 -0
  979. package/dist/services/recovery/run-liveness-continuations.d.ts +50 -0
  980. package/dist/services/recovery/run-liveness-continuations.d.ts.map +1 -0
  981. package/dist/services/recovery/run-liveness-continuations.js +117 -0
  982. package/dist/services/recovery/run-liveness-continuations.js.map +1 -0
  983. package/dist/services/recovery/service.d.ts +256 -0
  984. package/dist/services/recovery/service.d.ts.map +1 -0
  985. package/dist/services/recovery/service.js +2441 -0
  986. package/dist/services/recovery/service.js.map +1 -0
  987. package/dist/services/recovery/successful-run-handoff.d.ts +89 -0
  988. package/dist/services/recovery/successful-run-handoff.d.ts.map +1 -0
  989. package/dist/services/recovery/successful-run-handoff.js +304 -0
  990. package/dist/services/recovery/successful-run-handoff.js.map +1 -0
  991. package/dist/services/recovery/successful-run-handoff.test.d.ts +2 -0
  992. package/dist/services/recovery/successful-run-handoff.test.d.ts.map +1 -0
  993. package/dist/services/recovery/successful-run-handoff.test.js +270 -0
  994. package/dist/services/recovery/successful-run-handoff.test.js.map +1 -0
  995. package/dist/services/routines.d.ts +166 -0
  996. package/dist/services/routines.d.ts.map +1 -0
  997. package/dist/services/routines.js +1969 -0
  998. package/dist/services/routines.js.map +1 -0
  999. package/dist/services/run-continuations.d.ts +3 -0
  1000. package/dist/services/run-continuations.d.ts.map +1 -0
  1001. package/dist/services/run-continuations.js +2 -0
  1002. package/dist/services/run-continuations.js.map +1 -0
  1003. package/dist/services/run-liveness.d.ts +46 -0
  1004. package/dist/services/run-liveness.d.ts.map +1 -0
  1005. package/dist/services/run-liveness.js +275 -0
  1006. package/dist/services/run-liveness.js.map +1 -0
  1007. package/dist/services/run-log-store.d.ts +34 -0
  1008. package/dist/services/run-log-store.d.ts.map +1 -0
  1009. package/dist/services/run-log-store.js +111 -0
  1010. package/dist/services/run-log-store.js.map +1 -0
  1011. package/dist/services/sandbox-provider-runtime.d.ts +132 -0
  1012. package/dist/services/sandbox-provider-runtime.d.ts.map +1 -0
  1013. package/dist/services/sandbox-provider-runtime.js +216 -0
  1014. package/dist/services/sandbox-provider-runtime.js.map +1 -0
  1015. package/dist/services/secrets.d.ts +1962 -0
  1016. package/dist/services/secrets.d.ts.map +1 -0
  1017. package/dist/services/secrets.js +1686 -0
  1018. package/dist/services/secrets.js.map +1 -0
  1019. package/dist/services/sidebar-badges.d.ts +14 -0
  1020. package/dist/services/sidebar-badges.d.ts.map +1 -0
  1021. package/dist/services/sidebar-badges.js +48 -0
  1022. package/dist/services/sidebar-badges.js.map +1 -0
  1023. package/dist/services/sidebar-preferences.d.ts +9 -0
  1024. package/dist/services/sidebar-preferences.d.ts.map +1 -0
  1025. package/dist/services/sidebar-preferences.js +82 -0
  1026. package/dist/services/sidebar-preferences.js.map +1 -0
  1027. package/dist/services/work-products.d.ts +14 -0
  1028. package/dist/services/work-products.d.ts.map +1 -0
  1029. package/dist/services/work-products.js +100 -0
  1030. package/dist/services/work-products.js.map +1 -0
  1031. package/dist/services/workspace-operation-log-store.d.ts +33 -0
  1032. package/dist/services/workspace-operation-log-store.d.ts.map +1 -0
  1033. package/dist/services/workspace-operation-log-store.js +110 -0
  1034. package/dist/services/workspace-operation-log-store.js.map +1 -0
  1035. package/dist/services/workspace-operations.d.ts +44 -0
  1036. package/dist/services/workspace-operations.d.ts.map +1 -0
  1037. package/dist/services/workspace-operations.js +211 -0
  1038. package/dist/services/workspace-operations.js.map +1 -0
  1039. package/dist/services/workspace-realization.d.ts +33 -0
  1040. package/dist/services/workspace-realization.d.ts.map +1 -0
  1041. package/dist/services/workspace-realization.js +221 -0
  1042. package/dist/services/workspace-realization.js.map +1 -0
  1043. package/dist/services/workspace-runtime-read-model.d.ts +92 -0
  1044. package/dist/services/workspace-runtime-read-model.d.ts.map +1 -0
  1045. package/dist/services/workspace-runtime-read-model.js +67 -0
  1046. package/dist/services/workspace-runtime-read-model.js.map +1 -0
  1047. package/dist/services/workspace-runtime.d.ts +238 -0
  1048. package/dist/services/workspace-runtime.d.ts.map +1 -0
  1049. package/dist/services/workspace-runtime.js +2388 -0
  1050. package/dist/services/workspace-runtime.js.map +1 -0
  1051. package/dist/startup-banner.d.ts +32 -0
  1052. package/dist/startup-banner.d.ts.map +1 -0
  1053. package/dist/startup-banner.js +89 -0
  1054. package/dist/startup-banner.js.map +1 -0
  1055. package/dist/storage/index.d.ts +6 -0
  1056. package/dist/storage/index.d.ts.map +1 -0
  1057. package/dist/storage/index.js +29 -0
  1058. package/dist/storage/index.js.map +1 -0
  1059. package/dist/storage/local-disk-provider.d.ts +3 -0
  1060. package/dist/storage/local-disk-provider.d.ts.map +1 -0
  1061. package/dist/storage/local-disk-provider.js +79 -0
  1062. package/dist/storage/local-disk-provider.js.map +1 -0
  1063. package/dist/storage/provider-registry.d.ts +4 -0
  1064. package/dist/storage/provider-registry.d.ts.map +1 -0
  1065. package/dist/storage/provider-registry.js +15 -0
  1066. package/dist/storage/provider-registry.js.map +1 -0
  1067. package/dist/storage/s3-provider.d.ts +11 -0
  1068. package/dist/storage/s3-provider.d.ts.map +1 -0
  1069. package/dist/storage/s3-provider.js +123 -0
  1070. package/dist/storage/s3-provider.js.map +1 -0
  1071. package/dist/storage/service.d.ts +3 -0
  1072. package/dist/storage/service.d.ts.map +1 -0
  1073. package/dist/storage/service.js +120 -0
  1074. package/dist/storage/service.js.map +1 -0
  1075. package/dist/storage/types.d.ts +55 -0
  1076. package/dist/storage/types.d.ts.map +1 -0
  1077. package/dist/storage/types.js +2 -0
  1078. package/dist/storage/types.js.map +1 -0
  1079. package/dist/telemetry.d.ts +6 -0
  1080. package/dist/telemetry.d.ts.map +1 -0
  1081. package/dist/telemetry.js +20 -0
  1082. package/dist/telemetry.js.map +1 -0
  1083. package/dist/ui-branding.d.ts +13 -0
  1084. package/dist/ui-branding.d.ts.map +1 -0
  1085. package/dist/ui-branding.js +188 -0
  1086. package/dist/ui-branding.js.map +1 -0
  1087. package/dist/utils/coalesced-error-logger.d.ts +11 -0
  1088. package/dist/utils/coalesced-error-logger.d.ts.map +1 -0
  1089. package/dist/utils/coalesced-error-logger.js +21 -0
  1090. package/dist/utils/coalesced-error-logger.js.map +1 -0
  1091. package/dist/version.d.ts +2 -0
  1092. package/dist/version.d.ts.map +1 -0
  1093. package/dist/version.js +5 -0
  1094. package/dist/version.js.map +1 -0
  1095. package/dist/vite-html-renderer.d.ts +18 -0
  1096. package/dist/vite-html-renderer.d.ts.map +1 -0
  1097. package/dist/vite-html-renderer.js +61 -0
  1098. package/dist/vite-html-renderer.js.map +1 -0
  1099. package/dist/worktree-config.d.ts +19 -0
  1100. package/dist/worktree-config.d.ts.map +1 -0
  1101. package/dist/worktree-config.js +368 -0
  1102. package/dist/worktree-config.js.map +1 -0
  1103. package/package.json +95 -0
  1104. package/skills/deal-desk-outreach/SKILL.md +77 -0
  1105. package/skills/dealdesk/SKILL.md +109 -0
  1106. package/skills/dealdesk/references/api-reference.md +899 -0
  1107. package/skills/dealdesk/references/company-skills.md +193 -0
  1108. package/skills/dealdesk/references/issue-workspaces.md +80 -0
  1109. package/skills/dealdesk/references/routines.md +187 -0
  1110. package/skills/dealdesk/references/workflows.md +141 -0
  1111. package/skills/dealdesk-converting-plans-to-tasks/SKILL.md +110 -0
  1112. package/skills/dealdesk-create-agent/SKILL.md +124 -0
  1113. package/skills/dealdesk-create-agent/references/agent-instruction-templates.md +123 -0
  1114. package/skills/dealdesk-create-agent/references/agents/coder.md +64 -0
  1115. package/skills/dealdesk-create-agent/references/agents/qa.md +88 -0
  1116. package/skills/dealdesk-create-agent/references/agents/securityengineer.md +135 -0
  1117. package/skills/dealdesk-create-agent/references/agents/uxdesigner.md +115 -0
  1118. package/skills/dealdesk-create-agent/references/api-reference.md +110 -0
  1119. package/skills/dealdesk-create-agent/references/baseline-role-guide.md +168 -0
  1120. package/skills/dealdesk-create-agent/references/draft-review-checklist.md +95 -0
  1121. package/skills/dealdesk-create-plugin/SKILL.md +92 -0
  1122. package/skills/dealdesk-dev/SKILL.md +103 -0
  1123. package/skills/diagnose-why-work-stopped/SKILL.md +161 -0
  1124. package/skills/para-memory-files/SKILL.md +104 -0
  1125. package/skills/para-memory-files/references/schemas.md +35 -0
  1126. package/skills/terminal-bench-loop/SKILL.md +236 -0
  1127. package/ui-dist/android-chrome-192x192.png +0 -0
  1128. package/ui-dist/android-chrome-512x512.png +0 -0
  1129. package/ui-dist/apple-touch-icon.png +0 -0
  1130. package/ui-dist/assets/_basePickBy-CaQZTZgE.js +1 -0
  1131. package/ui-dist/assets/_baseUniq-DvA-iyvx.js +1 -0
  1132. package/ui-dist/assets/apl-B4CMkyY2.js +1 -0
  1133. package/ui-dist/assets/arc-_uwl-PL9.js +1 -0
  1134. package/ui-dist/assets/architectureDiagram-VXUJARFQ-hoEr3qym.js +36 -0
  1135. package/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
  1136. package/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
  1137. package/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
  1138. package/ui-dist/assets/blockDiagram-VD42YOAC-BpNmbQ9P.js +122 -0
  1139. package/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
  1140. package/ui-dist/assets/c4Diagram-YG6GDRKO-BG14x8dM.js +10 -0
  1141. package/ui-dist/assets/channel-NmuAvKfd.js +1 -0
  1142. package/ui-dist/assets/chunk-4BX2VUAB-Cb1YcG81.js +1 -0
  1143. package/ui-dist/assets/chunk-55IACEB6-DkMTjrQj.js +1 -0
  1144. package/ui-dist/assets/chunk-B4BG7PRW-BD6QmYfE.js +165 -0
  1145. package/ui-dist/assets/chunk-DI55MBZ5-B_xkiL3H.js +220 -0
  1146. package/ui-dist/assets/chunk-FMBD7UC4-DC95tjc1.js +15 -0
  1147. package/ui-dist/assets/chunk-QN33PNHL-BkIJ2KXA.js +1 -0
  1148. package/ui-dist/assets/chunk-QZHKN3VN-BWUNV7If.js +1 -0
  1149. package/ui-dist/assets/chunk-TZMSLE5B-NQYnSIs1.js +1 -0
  1150. package/ui-dist/assets/classDiagram-2ON5EDUG-eS4kRH8R.js +1 -0
  1151. package/ui-dist/assets/classDiagram-v2-WZHVMYZB-eS4kRH8R.js +1 -0
  1152. package/ui-dist/assets/clike-B9uivgTg.js +1 -0
  1153. package/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
  1154. package/ui-dist/assets/clone-CbA0swX6.js +1 -0
  1155. package/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
  1156. package/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
  1157. package/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
  1158. package/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
  1159. package/ui-dist/assets/cose-bilkent-S5V4N54A-BHo6DkZj.js +1 -0
  1160. package/ui-dist/assets/crystal-SjHAIU92.js +1 -0
  1161. package/ui-dist/assets/css-BnMrqG3P.js +1 -0
  1162. package/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
  1163. package/ui-dist/assets/cytoscape.esm-jbPEKk2Y.js +321 -0
  1164. package/ui-dist/assets/d-pRatUO7H.js +1 -0
  1165. package/ui-dist/assets/dagre-6UL2VRFP-CfzNlqfr.js +4 -0
  1166. package/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  1167. package/ui-dist/assets/diagram-PSM6KHXK-DjPk4Vl5.js +24 -0
  1168. package/ui-dist/assets/diagram-QEK2KX5R-ClmlUcpT.js +43 -0
  1169. package/ui-dist/assets/diagram-S2PKOQOG-B68LEXtz.js +24 -0
  1170. package/ui-dist/assets/diff-DbItnlRl.js +1 -0
  1171. package/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
  1172. package/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
  1173. package/ui-dist/assets/dylan-DwRh75JA.js +1 -0
  1174. package/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
  1175. package/ui-dist/assets/ecl-Cabwm37j.js +1 -0
  1176. package/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
  1177. package/ui-dist/assets/elm-vLlmbW-K.js +1 -0
  1178. package/ui-dist/assets/erDiagram-Q2GNP2WA-CJSnga5T.js +60 -0
  1179. package/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
  1180. package/ui-dist/assets/factor-kuTfRLto.js +1 -0
  1181. package/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
  1182. package/ui-dist/assets/flowDiagram-NV44I4VS-Drmp4DHd.js +162 -0
  1183. package/ui-dist/assets/forth-Ffai-XNe.js +1 -0
  1184. package/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
  1185. package/ui-dist/assets/ganttDiagram-JELNMOA3-C8ffQ-2u.js +267 -0
  1186. package/ui-dist/assets/gas-Bneqetm1.js +1 -0
  1187. package/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
  1188. package/ui-dist/assets/gitGraphDiagram-V2S2FVAM-CPjF6oPQ.js +65 -0
  1189. package/ui-dist/assets/graph-B2qUgzgo.js +1 -0
  1190. package/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
  1191. package/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
  1192. package/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
  1193. package/ui-dist/assets/http-DBlCnlav.js +1 -0
  1194. package/ui-dist/assets/idl-BEugSyMb.js +1 -0
  1195. package/ui-dist/assets/index-6t3ZNnLR.js +1 -0
  1196. package/ui-dist/assets/index-ARl1W2jj.js +1 -0
  1197. package/ui-dist/assets/index-B9T1xuwJ.js +13 -0
  1198. package/ui-dist/assets/index-BAhZurej.js +2 -0
  1199. package/ui-dist/assets/index-BJ9IksfS.js +1 -0
  1200. package/ui-dist/assets/index-BKv2WUK1.js +1 -0
  1201. package/ui-dist/assets/index-BT7YS1Ir.js +3 -0
  1202. package/ui-dist/assets/index-Bkj-OIiI.js +1 -0
  1203. package/ui-dist/assets/index-CNEquZvK.js +1 -0
  1204. package/ui-dist/assets/index-CPGHpqpR.js +1 -0
  1205. package/ui-dist/assets/index-CW2NmfmI.js +1 -0
  1206. package/ui-dist/assets/index-Cf8smU9e.js +1 -0
  1207. package/ui-dist/assets/index-CrrVEpWP.js +537 -0
  1208. package/ui-dist/assets/index-CtebvrC7.js +1 -0
  1209. package/ui-dist/assets/index-CuwS3-lF.js +1 -0
  1210. package/ui-dist/assets/index-D1D5GrGc.js +1 -0
  1211. package/ui-dist/assets/index-DLN9KwFF.css +1 -0
  1212. package/ui-dist/assets/index-DWfkKcGS.js +1 -0
  1213. package/ui-dist/assets/index-DXzbokce.js +6 -0
  1214. package/ui-dist/assets/index-DY03uqeZ.js +1 -0
  1215. package/ui-dist/assets/index-DnDdXZYl.js +1 -0
  1216. package/ui-dist/assets/index-DvRp33UU.js +1 -0
  1217. package/ui-dist/assets/index-FnWH4Q9P.js +7 -0
  1218. package/ui-dist/assets/index-O_WP0QsK.js +1 -0
  1219. package/ui-dist/assets/infoDiagram-HS3SLOUP-DLOW6p4c.js +2 -0
  1220. package/ui-dist/assets/init-Gi6I4Gst.js +1 -0
  1221. package/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
  1222. package/ui-dist/assets/journeyDiagram-XKPGCS4Q-oYaaSMQP.js +139 -0
  1223. package/ui-dist/assets/julia-DuME0IfC.js +1 -0
  1224. package/ui-dist/assets/kanban-definition-3W4ZIXB7-BE7mgk6q.js +89 -0
  1225. package/ui-dist/assets/katex-B95LWT_Q.js +261 -0
  1226. package/ui-dist/assets/layout-Cq5BDWzM.js +1 -0
  1227. package/ui-dist/assets/linear-HnEHTC6F.js +1 -0
  1228. package/ui-dist/assets/livescript-BwQOo05w.js +1 -0
  1229. package/ui-dist/assets/lua-BgMRiT3U.js +1 -0
  1230. package/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
  1231. package/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
  1232. package/ui-dist/assets/mermaid.core-JMROPF3S.js +250 -0
  1233. package/ui-dist/assets/mindmap-definition-VGOIOE7T-DoeZEBQU.js +68 -0
  1234. package/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
  1235. package/ui-dist/assets/mllike-CXdrOF99.js +1 -0
  1236. package/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
  1237. package/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
  1238. package/ui-dist/assets/mumps-BT43cFF4.js +1 -0
  1239. package/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
  1240. package/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
  1241. package/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
  1242. package/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
  1243. package/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
  1244. package/ui-dist/assets/oz-BzwKVEFT.js +1 -0
  1245. package/ui-dist/assets/pascal--L3eBynH.js +1 -0
  1246. package/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
  1247. package/ui-dist/assets/pieDiagram-ADFJNKIX-BtfKQ-xw.js +30 -0
  1248. package/ui-dist/assets/pig-CevX1Tat.js +1 -0
  1249. package/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
  1250. package/ui-dist/assets/properties-C78fOPTZ.js +1 -0
  1251. package/ui-dist/assets/protobuf-ChK-085T.js +1 -0
  1252. package/ui-dist/assets/pug-DeIclll2.js +1 -0
  1253. package/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
  1254. package/ui-dist/assets/python-BuPzkPfP.js +1 -0
  1255. package/ui-dist/assets/q-pXgVlZs6.js +1 -0
  1256. package/ui-dist/assets/quadrantDiagram-AYHSOK5B-CIrjVDBB.js +7 -0
  1257. package/ui-dist/assets/r-B6wPVr8A.js +1 -0
  1258. package/ui-dist/assets/requirementDiagram-UZGBJVZJ-CNQ5h-EW.js +64 -0
  1259. package/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
  1260. package/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
  1261. package/ui-dist/assets/sankeyDiagram-TZEHDZUN-CrOSPDz5.js +10 -0
  1262. package/ui-dist/assets/sas-B4kiWyti.js +1 -0
  1263. package/ui-dist/assets/scheme-C41bIUwD.js +1 -0
  1264. package/ui-dist/assets/sequenceDiagram-WL72ISMW-D96XuK7n.js +145 -0
  1265. package/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
  1266. package/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
  1267. package/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
  1268. package/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
  1269. package/ui-dist/assets/solr-DehyRSwq.js +1 -0
  1270. package/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
  1271. package/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
  1272. package/ui-dist/assets/sql-D0XecflT.js +1 -0
  1273. package/ui-dist/assets/stateDiagram-FKZM4ZOC-BOf9izkD.js +1 -0
  1274. package/ui-dist/assets/stateDiagram-v2-4FDKWEC3-DEhq019K.js +1 -0
  1275. package/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
  1276. package/ui-dist/assets/stylus-B533Al4x.js +1 -0
  1277. package/ui-dist/assets/swift-BzpIVaGY.js +1 -0
  1278. package/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
  1279. package/ui-dist/assets/textile-CnDTJFAw.js +1 -0
  1280. package/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
  1281. package/ui-dist/assets/tiki-DGYXhP31.js +1 -0
  1282. package/ui-dist/assets/timeline-definition-IT6M3QCI-_lAaYcUI.js +61 -0
  1283. package/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
  1284. package/ui-dist/assets/treemap-GDKQZRPO-BS18z8ox.js +154 -0
  1285. package/ui-dist/assets/troff-wAsdV37c.js +1 -0
  1286. package/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
  1287. package/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  1288. package/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
  1289. package/ui-dist/assets/vb-CmGdzxic.js +1 -0
  1290. package/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
  1291. package/ui-dist/assets/velocity-D8B20fx6.js +1 -0
  1292. package/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
  1293. package/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
  1294. package/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
  1295. package/ui-dist/assets/xquery-DzFWVndE.js +1 -0
  1296. package/ui-dist/assets/xychartDiagram-PRI3JC2R-X82nn6D0.js +7 -0
  1297. package/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
  1298. package/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
  1299. package/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
  1300. package/ui-dist/brands/opencode-logo-light-square.svg +18 -0
  1301. package/ui-dist/favicon-16x16.png +0 -0
  1302. package/ui-dist/favicon-32x32.png +0 -0
  1303. package/ui-dist/favicon.ico +0 -0
  1304. package/ui-dist/favicon.svg +10 -0
  1305. package/ui-dist/index.html +49 -0
  1306. package/ui-dist/site.webmanifest +30 -0
  1307. package/ui-dist/sw.js +42 -0
  1308. package/ui-dist/worktree-favicon-16x16.png +0 -0
  1309. package/ui-dist/worktree-favicon-32x32.png +0 -0
  1310. package/ui-dist/worktree-favicon.ico +0 -0
  1311. package/ui-dist/worktree-favicon.svg +10 -0
@@ -0,0 +1,2184 @@
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, and sensitive instance-wide
15
+ * mutations such as install/upgrade require instance-admin privileges.
16
+ *
17
+ * @module server/routes/plugins
18
+ * @see doc/plugins/PLUGIN_SPEC.md for the full plugin specification
19
+ */
20
+ import { existsSync } from "node:fs";
21
+ import path from "node:path";
22
+ import { randomUUID } from "node:crypto";
23
+ import { fileURLToPath } from "node:url";
24
+ import { Router } from "express";
25
+ import { and, desc, eq, gte } from "drizzle-orm";
26
+ import { agents, companies, heartbeatRuns, pluginLogs, pluginWebhookDeliveries, projects, } from "@dealdesk/db";
27
+ import { PLUGIN_STATUSES, } from "@dealdesk/shared";
28
+ import { pluginRegistryService } from "../services/plugin-registry.js";
29
+ import { pluginLifecycleManager } from "../services/plugin-lifecycle.js";
30
+ import { getPluginUiContributionMetadata } from "../services/plugin-loader.js";
31
+ import { logActivity } from "../services/activity-log.js";
32
+ import { publishGlobalLiveEvent } from "../services/live-events.js";
33
+ import { issueService } from "../services/issues.js";
34
+ import { JsonRpcCallError, PLUGIN_RPC_ERROR_CODES } from "@dealdesk/plugin-sdk";
35
+ import { assertAuthenticated, assertBoard, assertBoardOrgAccess, assertCompanyAccess, assertInstanceAdmin, getActorInfo, } from "./authz.js";
36
+ import { validateInstanceConfig } from "../services/plugin-config-validator.js";
37
+ import { findLocalFolderDeclaration, getStoredLocalFolders, inspectPluginLocalFolder, requireLocalFolderDeclaration, setStoredLocalFolder, } from "../services/plugin-local-folders.js";
38
+ import { extractSecretRefPathsFromConfig, PLUGIN_SECRET_REFS_DISABLED_MESSAGE, } from "../services/plugin-secrets-handler.js";
39
+ import { badRequest, forbidden, notFound, unauthorized, unprocessable } from "../errors.js";
40
+ /** UUID v4 regex used for plugin ID route resolution. */
41
+ 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;
42
+ const PLUGIN_API_BODY_LIMIT_BYTES = 1_000_000;
43
+ const PLUGIN_SCOPED_API_RESPONSE_HEADER_ALLOWLIST = new Set([
44
+ "cache-control",
45
+ "etag",
46
+ "last-modified",
47
+ "x-request-id",
48
+ ]);
49
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
50
+ const REPO_ROOT = path.resolve(__dirname, "../../..");
51
+ const BUNDLED_PLUGIN_EXAMPLES = [
52
+ {
53
+ packageName: "@dealdesk/plugin-hello-world-example",
54
+ pluginKey: "dealdesk.hello-world-example",
55
+ displayName: "Hello World Widget (Example)",
56
+ description: "Reference UI plugin that adds a simple Hello World widget to the DealDesk dashboard.",
57
+ localPath: "packages/plugins/examples/plugin-hello-world-example",
58
+ tag: "example",
59
+ },
60
+ {
61
+ packageName: "@dealdesk/plugin-file-browser-example",
62
+ pluginKey: "dealdesk-file-browser-example",
63
+ displayName: "File Browser (Example)",
64
+ description: "Example plugin that adds a Files link in project navigation plus a project detail file browser.",
65
+ localPath: "packages/plugins/examples/plugin-file-browser-example",
66
+ tag: "example",
67
+ },
68
+ {
69
+ packageName: "@dealdesk/plugin-kitchen-sink-example",
70
+ pluginKey: "dealdesk-kitchen-sink-example",
71
+ displayName: "Kitchen Sink (Example)",
72
+ description: "Reference plugin that demonstrates the current DealDesk plugin API surface, bridge flows, UI extension surfaces, jobs, webhooks, tools, streams, and trusted local workspace/process demos.",
73
+ localPath: "packages/plugins/examples/plugin-kitchen-sink-example",
74
+ tag: "example",
75
+ },
76
+ {
77
+ packageName: "@dealdesk/plugin-orchestration-smoke-example",
78
+ pluginKey: "dealdesk.plugin-orchestration-smoke-example",
79
+ displayName: "Orchestration Smoke (Example)",
80
+ description: "Acceptance fixture for scoped plugin routes, restricted database namespaces, issue orchestration, documents, wakeups, summaries, and UI status surfaces.",
81
+ localPath: "packages/plugins/examples/plugin-orchestration-smoke-example",
82
+ tag: "example",
83
+ },
84
+ ];
85
+ function listBundledPluginExamples() {
86
+ return BUNDLED_PLUGIN_EXAMPLES.flatMap((plugin) => {
87
+ const absoluteLocalPath = path.resolve(REPO_ROOT, plugin.localPath);
88
+ if (!existsSync(absoluteLocalPath))
89
+ return [];
90
+ return [{ ...plugin, localPath: absoluteLocalPath }];
91
+ });
92
+ }
93
+ /**
94
+ * Resolve a plugin by either database ID or plugin key.
95
+ *
96
+ * Lookup order:
97
+ * - UUID-like IDs: getById first, then getByKey.
98
+ * - All non-UUID values: getByKey only, never getById. The persisted plugin
99
+ * ID column is a PostgreSQL UUID, so probing it with keys such as
100
+ * "acme.plugin" raises a database cast error before a key lookup can happen.
101
+ *
102
+ * @param registry - The plugin registry service instance
103
+ * @param pluginId - Either a database UUID or plugin key (manifest id)
104
+ * @returns Plugin record or null if not found
105
+ */
106
+ async function resolvePlugin(registry, pluginId) {
107
+ const isUuid = UUID_REGEX.test(pluginId);
108
+ if (!isUuid) {
109
+ return registry.getByKey(pluginId);
110
+ }
111
+ const byId = await registry.getById(pluginId);
112
+ if (byId)
113
+ return byId;
114
+ return registry.getByKey(pluginId);
115
+ }
116
+ /**
117
+ * Create Express router for plugin management API.
118
+ *
119
+ * Routes provided:
120
+ *
121
+ * | Method | Path | Description |
122
+ * |--------|------|-------------|
123
+ * | GET | /plugins | List all plugins (optional ?status= filter) |
124
+ * | GET | /plugins/ui-contributions | Get UI slots from ready plugins |
125
+ * | GET | /plugins/:pluginId | Get single plugin by ID or key |
126
+ * | POST | /plugins/install | Install from npm or local path |
127
+ * | DELETE | /plugins/:pluginId | Uninstall (optional ?purge=true) |
128
+ * | POST | /plugins/:pluginId/enable | Enable a plugin |
129
+ * | POST | /plugins/:pluginId/disable | Disable a plugin |
130
+ * | GET | /plugins/:pluginId/health | Run health diagnostics |
131
+ * | POST | /plugins/:pluginId/upgrade | Upgrade to newer version |
132
+ * | GET | /plugins/:pluginId/jobs | List jobs for a plugin |
133
+ * | GET | /plugins/:pluginId/jobs/:jobId/runs | List runs for a job |
134
+ * | POST | /plugins/:pluginId/jobs/:jobId/trigger | Manually trigger a job |
135
+ * | POST | /plugins/:pluginId/webhooks/:endpointKey | Receive inbound webhook |
136
+ * | GET | /plugins/tools | List all available plugin tools |
137
+ * | GET | /plugins/tools?pluginId=... | List tools for a specific plugin |
138
+ * | POST | /plugins/tools/execute | Execute a plugin tool |
139
+ * | GET | /plugins/:pluginId/config | Get current plugin config |
140
+ * | POST | /plugins/:pluginId/config | Save (upsert) plugin config |
141
+ * | POST | /plugins/:pluginId/config/test | Test config via validateConfig RPC |
142
+ * | POST | /plugins/:pluginId/bridge/data | Proxy getData to plugin worker |
143
+ * | POST | /plugins/:pluginId/bridge/action | Proxy performAction to plugin worker |
144
+ * | POST | /plugins/:pluginId/data/:key | Proxy getData to plugin worker (key in URL) |
145
+ * | POST | /plugins/:pluginId/actions/:key | Proxy performAction to plugin worker (key in URL) |
146
+ * | GET | /plugins/:pluginId/bridge/stream/:channel | SSE stream from worker to UI |
147
+ * | GET | /plugins/:pluginId/dashboard | Aggregated health dashboard data |
148
+ *
149
+ * **Route Ordering Note:** Static routes (like /ui-contributions, /tools) must be
150
+ * registered before parameterized routes (like /:pluginId) to prevent Express from
151
+ * matching them as a plugin ID.
152
+ *
153
+ * @param db - Database connection instance
154
+ * @param jobDeps - Optional job scheduling dependencies
155
+ * @param webhookDeps - Optional webhook ingestion dependencies
156
+ * @param toolDeps - Optional tool dispatcher dependencies
157
+ * @param bridgeDeps - Optional bridge proxy dependencies for getData/performAction
158
+ * @returns Express router with plugin routes mounted
159
+ */
160
+ export function pluginRoutes(db, loader, jobDeps, webhookDeps, toolDeps, bridgeDeps) {
161
+ const router = Router();
162
+ const registry = pluginRegistryService(db);
163
+ const lifecycle = pluginLifecycleManager(db, {
164
+ loader,
165
+ workerManager: bridgeDeps?.workerManager ?? webhookDeps?.workerManager,
166
+ });
167
+ const issuesSvc = issueService(db);
168
+ function matchScopedApiRoute(route, method, requestPath) {
169
+ if (route.method !== method)
170
+ return null;
171
+ const normalize = (value) => value.replace(/\/+$/, "") || "/";
172
+ const routeSegments = normalize(route.path).split("/").filter(Boolean);
173
+ const requestSegments = normalize(requestPath).split("/").filter(Boolean);
174
+ if (routeSegments.length !== requestSegments.length)
175
+ return null;
176
+ const params = {};
177
+ for (let i = 0; i < routeSegments.length; i += 1) {
178
+ const routeSegment = routeSegments[i];
179
+ const requestSegment = requestSegments[i];
180
+ if (routeSegment.startsWith(":")) {
181
+ params[routeSegment.slice(1)] = decodeURIComponent(requestSegment);
182
+ continue;
183
+ }
184
+ if (routeSegment !== requestSegment)
185
+ return null;
186
+ }
187
+ return params;
188
+ }
189
+ function sanitizePluginRequestHeaders(req) {
190
+ const safeHeaderNames = new Set([
191
+ "accept",
192
+ "content-type",
193
+ "user-agent",
194
+ "x-dealdesk-run-id",
195
+ "x-request-id",
196
+ ]);
197
+ const headers = {};
198
+ for (const [name, value] of Object.entries(req.headers)) {
199
+ const lower = name.toLowerCase();
200
+ if (!safeHeaderNames.has(lower))
201
+ continue;
202
+ if (Array.isArray(value)) {
203
+ headers[lower] = value.join(", ");
204
+ }
205
+ else if (typeof value === "string") {
206
+ headers[lower] = value;
207
+ }
208
+ }
209
+ return headers;
210
+ }
211
+ function applyPluginScopedApiResponseHeaders(res, headers) {
212
+ for (const [name, value] of Object.entries(headers ?? {})) {
213
+ const lower = name.toLowerCase();
214
+ if (!PLUGIN_SCOPED_API_RESPONSE_HEADER_ALLOWLIST.has(lower))
215
+ continue;
216
+ res.setHeader(lower, value);
217
+ }
218
+ }
219
+ function normalizeQuery(query) {
220
+ const normalized = {};
221
+ for (const [key, value] of Object.entries(query)) {
222
+ if (typeof value === "string") {
223
+ normalized[key] = value;
224
+ }
225
+ else if (Array.isArray(value)) {
226
+ normalized[key] = value.map((entry) => String(entry));
227
+ }
228
+ }
229
+ return normalized;
230
+ }
231
+ async function resolveScopedApiCompanyId(route, params, req) {
232
+ const resolution = route.companyResolution;
233
+ if (!resolution) {
234
+ if (req.actor.type === "agent" && req.actor.companyId)
235
+ return req.actor.companyId;
236
+ return null;
237
+ }
238
+ if (resolution.from === "body") {
239
+ const body = req.body;
240
+ const companyId = body?.[resolution.key ?? ""];
241
+ return typeof companyId === "string" ? companyId : null;
242
+ }
243
+ if (resolution.from === "query") {
244
+ const value = req.query[resolution.key ?? ""];
245
+ return typeof value === "string" ? value : null;
246
+ }
247
+ const issueId = params[resolution.param ?? ""];
248
+ if (!issueId)
249
+ return null;
250
+ const issue = await issuesSvc.getById(issueId);
251
+ return issue?.companyId ?? null;
252
+ }
253
+ function assertScopedApiAuth(req, route) {
254
+ if (route.auth === "board") {
255
+ assertBoard(req);
256
+ return;
257
+ }
258
+ if (route.auth === "agent") {
259
+ assertAuthenticated(req);
260
+ if (req.actor.type !== "agent")
261
+ throw forbidden("Agent access required");
262
+ return;
263
+ }
264
+ if (route.auth === "webhook") {
265
+ throw unprocessable("Webhook-scoped plugin API routes require a signature verifier and are not enabled");
266
+ }
267
+ assertAuthenticated(req);
268
+ if (req.actor.type !== "board" && req.actor.type !== "agent") {
269
+ throw forbidden("Board or agent access required");
270
+ }
271
+ }
272
+ async function enforceScopedApiCheckout(req, route, params, companyId) {
273
+ const policy = route.checkoutPolicy ?? "none";
274
+ if (policy === "none" || req.actor.type !== "agent")
275
+ return;
276
+ const issueId = params.issueId;
277
+ if (!issueId) {
278
+ throw unprocessable("Checkout-protected plugin API routes require an issueId route parameter");
279
+ }
280
+ const issue = await issuesSvc.getById(issueId);
281
+ if (!issue || issue.companyId !== companyId) {
282
+ throw notFound("Issue not found");
283
+ }
284
+ if (policy === "required-for-agent-in-progress") {
285
+ if (issue.status !== "in_progress" || issue.assigneeAgentId !== req.actor.agentId)
286
+ return;
287
+ }
288
+ const runId = req.actor.runId?.trim();
289
+ if (!runId) {
290
+ throw unauthorized("Agent run id required");
291
+ }
292
+ if (!req.actor.agentId) {
293
+ throw forbidden("Agent authentication required");
294
+ }
295
+ await issuesSvc.assertCheckoutOwner(issueId, req.actor.agentId, runId);
296
+ }
297
+ async function resolvePluginAuditCompanyIds(req) {
298
+ if (typeof db.select === "function") {
299
+ const rows = await db
300
+ .select({ id: companies.id })
301
+ .from(companies);
302
+ return rows.map((row) => row.id);
303
+ }
304
+ if (req.actor.type === "agent" && req.actor.companyId) {
305
+ return [req.actor.companyId];
306
+ }
307
+ if (req.actor.type === "board") {
308
+ return req.actor.companyIds ?? [];
309
+ }
310
+ return [];
311
+ }
312
+ async function logPluginMutationActivity(req, action, entityId, details) {
313
+ const companyIds = await resolvePluginAuditCompanyIds(req);
314
+ if (companyIds.length === 0)
315
+ return;
316
+ const actor = getActorInfo(req);
317
+ await Promise.all(companyIds.map((companyId) => logActivity(db, {
318
+ companyId,
319
+ actorType: actor.actorType,
320
+ actorId: actor.actorId,
321
+ agentId: actor.agentId,
322
+ runId: actor.runId,
323
+ action,
324
+ entityType: "plugin",
325
+ entityId,
326
+ details,
327
+ })));
328
+ }
329
+ function assertPluginBridgeScope(req, companyId) {
330
+ if (companyId === undefined || companyId === null) {
331
+ assertInstanceAdmin(req);
332
+ return undefined;
333
+ }
334
+ if (typeof companyId !== "string" || companyId.trim().length === 0) {
335
+ throw badRequest('"companyId" must be a non-empty string when provided');
336
+ }
337
+ assertCompanyAccess(req, companyId);
338
+ return companyId;
339
+ }
340
+ async function validateToolRunContextScope(runContext) {
341
+ const [agent] = await db
342
+ .select({ companyId: agents.companyId })
343
+ .from(agents)
344
+ .where(eq(agents.id, runContext.agentId))
345
+ .limit(1);
346
+ if (!agent || agent.companyId !== runContext.companyId) {
347
+ return '"runContext.agentId" does not belong to "runContext.companyId"';
348
+ }
349
+ const [run] = await db
350
+ .select({ companyId: heartbeatRuns.companyId, agentId: heartbeatRuns.agentId })
351
+ .from(heartbeatRuns)
352
+ .where(eq(heartbeatRuns.id, runContext.runId))
353
+ .limit(1);
354
+ if (!run || run.companyId !== runContext.companyId) {
355
+ return '"runContext.runId" does not belong to "runContext.companyId"';
356
+ }
357
+ if (run.agentId !== runContext.agentId) {
358
+ return '"runContext.runId" does not belong to "runContext.agentId"';
359
+ }
360
+ const [project] = await db
361
+ .select({ companyId: projects.companyId })
362
+ .from(projects)
363
+ .where(eq(projects.id, runContext.projectId))
364
+ .limit(1);
365
+ if (!project || project.companyId !== runContext.companyId) {
366
+ return '"runContext.projectId" does not belong to "runContext.companyId"';
367
+ }
368
+ return null;
369
+ }
370
+ /**
371
+ * GET /api/plugins
372
+ *
373
+ * List all installed plugins, optionally filtered by lifecycle status.
374
+ *
375
+ * Query params:
376
+ * - `status` (optional): Filter by lifecycle status. Must be one of the
377
+ * values in `PLUGIN_STATUSES` (`installed`, `ready`, `error`,
378
+ * `upgrade_pending`, `uninstalled`). Returns HTTP 400 if the value is
379
+ * not a recognised status string.
380
+ *
381
+ * Response: `PluginRecord[]`
382
+ */
383
+ router.get("/plugins", async (req, res) => {
384
+ assertBoardOrgAccess(req);
385
+ const rawStatus = req.query.status;
386
+ if (rawStatus !== undefined) {
387
+ if (typeof rawStatus !== "string" || !PLUGIN_STATUSES.includes(rawStatus)) {
388
+ res.status(400).json({
389
+ error: `Invalid status '${String(rawStatus)}'. Must be one of: ${PLUGIN_STATUSES.join(", ")}`,
390
+ });
391
+ return;
392
+ }
393
+ }
394
+ const status = rawStatus;
395
+ const plugins = status
396
+ ? await registry.listByStatus(status)
397
+ : await registry.listInstalled();
398
+ res.json(plugins);
399
+ });
400
+ /**
401
+ * GET /api/plugins/examples
402
+ *
403
+ * Return first-party example plugins bundled in this repo, if present.
404
+ * These can be installed through the normal local-path install flow.
405
+ */
406
+ router.get("/plugins/examples", async (req, res) => {
407
+ assertBoardOrgAccess(req);
408
+ res.json(listBundledPluginExamples());
409
+ });
410
+ // IMPORTANT: Static routes must come before parameterized routes
411
+ // to avoid Express matching "ui-contributions" as a :pluginId
412
+ /**
413
+ * GET /api/plugins/ui-contributions
414
+ *
415
+ * Return UI contributions from all plugins in 'ready' state.
416
+ * Used by the frontend to discover plugin UI slots and launcher metadata.
417
+ *
418
+ * The response is normalized for the frontend slot host:
419
+ * - Only includes plugins with at least one declared UI slot or launcher
420
+ * - Excludes plugins with null/missing manifestJson (defensive)
421
+ * - Slots are extracted from manifest.ui.slots
422
+ * - Launchers are aggregated from legacy manifest.launchers and manifest.ui.launchers
423
+ *
424
+ * Example response:
425
+ * ```json
426
+ * [
427
+ * {
428
+ * "pluginId": "plg_123",
429
+ * "pluginKey": "dealdesk.claude-usage",
430
+ * "displayName": "Claude Usage",
431
+ * "version": "1.0.0",
432
+ * "uiEntryFile": "index.js",
433
+ * "slots": [],
434
+ * "launchers": [
435
+ * {
436
+ * "id": "claude-usage-toolbar",
437
+ * "displayName": "Claude Usage",
438
+ * "placementZone": "toolbarButton",
439
+ * "action": { "type": "openModal", "target": "ClaudeUsageView" },
440
+ * "render": { "environment": "hostOverlay", "bounds": "wide" }
441
+ * }
442
+ * ]
443
+ * }
444
+ * ]
445
+ * ```
446
+ *
447
+ * Response: PluginUiContribution[]
448
+ */
449
+ router.get("/plugins/ui-contributions", async (req, res) => {
450
+ assertBoardOrgAccess(req);
451
+ const plugins = await registry.listByStatus("ready");
452
+ const contributions = plugins
453
+ .map((plugin) => {
454
+ // Safety check: manifestJson should always exist for ready plugins, but guard against null
455
+ const manifest = plugin.manifestJson;
456
+ if (!manifest)
457
+ return null;
458
+ const uiMetadata = getPluginUiContributionMetadata(manifest);
459
+ if (!uiMetadata)
460
+ return null;
461
+ return {
462
+ pluginId: plugin.id,
463
+ pluginKey: plugin.pluginKey,
464
+ displayName: manifest.displayName,
465
+ version: plugin.version,
466
+ updatedAt: plugin.updatedAt.toISOString(),
467
+ uiEntryFile: uiMetadata.uiEntryFile,
468
+ slots: uiMetadata.slots,
469
+ launchers: uiMetadata.launchers,
470
+ };
471
+ })
472
+ .filter((item) => item !== null);
473
+ res.json(contributions);
474
+ });
475
+ // ===========================================================================
476
+ // Tool discovery and execution routes
477
+ // ===========================================================================
478
+ /**
479
+ * GET /api/plugins/tools
480
+ *
481
+ * List all available plugin-contributed tools in an agent-friendly format.
482
+ *
483
+ * Query params:
484
+ * - `pluginId` (optional): Filter to tools from a specific plugin
485
+ *
486
+ * Response: `AgentToolDescriptor[]`
487
+ * Errors: 501 if tool dispatcher is not configured
488
+ */
489
+ router.get("/plugins/tools", async (req, res) => {
490
+ assertBoardOrgAccess(req);
491
+ if (!toolDeps) {
492
+ res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
493
+ return;
494
+ }
495
+ const pluginId = req.query.pluginId;
496
+ const filter = pluginId ? { pluginId } : undefined;
497
+ const tools = toolDeps.toolDispatcher.listToolsForAgent(filter);
498
+ res.json(tools);
499
+ });
500
+ /**
501
+ * POST /api/plugins/tools/execute
502
+ *
503
+ * Execute a plugin-contributed tool by its namespaced name.
504
+ *
505
+ * This is the primary endpoint used by the agent service to invoke
506
+ * plugin tools during an agent run.
507
+ *
508
+ * Request body:
509
+ * - `tool`: Fully namespaced tool name (e.g., "acme.linear:search-issues")
510
+ * - `parameters`: Parameters matching the tool's declared JSON Schema
511
+ * - `runContext`: Agent run context with agentId, runId, companyId, projectId
512
+ *
513
+ * Response: `ToolExecutionResult`
514
+ * Errors:
515
+ * - 400 if request validation fails
516
+ * - 404 if tool is not found
517
+ * - 501 if tool dispatcher is not configured
518
+ * - 502 if the plugin worker is unavailable or the RPC call fails
519
+ */
520
+ router.post("/plugins/tools/execute", async (req, res) => {
521
+ assertBoardOrgAccess(req);
522
+ if (!toolDeps) {
523
+ res.status(501).json({ error: "Plugin tool dispatch is not enabled" });
524
+ return;
525
+ }
526
+ const body = req.body;
527
+ if (!body) {
528
+ res.status(400).json({ error: "Request body is required" });
529
+ return;
530
+ }
531
+ const { tool, parameters, runContext } = body;
532
+ // Validate required fields
533
+ if (!tool || typeof tool !== "string") {
534
+ res.status(400).json({ error: '"tool" is required and must be a string' });
535
+ return;
536
+ }
537
+ if (!runContext || typeof runContext !== "object") {
538
+ res.status(400).json({ error: '"runContext" is required and must be an object' });
539
+ return;
540
+ }
541
+ if (!runContext.agentId || !runContext.runId || !runContext.companyId || !runContext.projectId) {
542
+ res.status(400).json({
543
+ error: '"runContext" must include agentId, runId, companyId, and projectId',
544
+ });
545
+ return;
546
+ }
547
+ assertCompanyAccess(req, runContext.companyId);
548
+ const scopeError = await validateToolRunContextScope(runContext);
549
+ if (scopeError) {
550
+ res.status(403).json({ error: scopeError });
551
+ return;
552
+ }
553
+ // Verify the tool exists
554
+ const registeredTool = toolDeps.toolDispatcher.getTool(tool);
555
+ if (!registeredTool) {
556
+ res.status(404).json({ error: `Tool "${tool}" not found` });
557
+ return;
558
+ }
559
+ try {
560
+ const result = await toolDeps.toolDispatcher.executeTool(tool, parameters ?? {}, runContext);
561
+ res.json(result);
562
+ }
563
+ catch (err) {
564
+ const message = err instanceof Error ? err.message : String(err);
565
+ // Distinguish between "worker not running" (502) and other errors (500)
566
+ if (message.includes("not running") || message.includes("worker")) {
567
+ res.status(502).json({ error: message });
568
+ }
569
+ else {
570
+ res.status(500).json({ error: message });
571
+ }
572
+ }
573
+ });
574
+ /**
575
+ * POST /api/plugins/install
576
+ *
577
+ * Install a plugin from npm or a local filesystem path.
578
+ *
579
+ * Instance-wide plugin installation is restricted to instance admins because
580
+ * the install flow fetches and inspects package contents on the host.
581
+ *
582
+ * Request body:
583
+ * - packageName: npm package name or local path (required)
584
+ * - version: Target version for npm packages (optional)
585
+ * - isLocalPath: Set true if packageName is a local path
586
+ *
587
+ * The installer:
588
+ * 1. Downloads from npm or loads from local path
589
+ * 2. Validates the manifest (schema + capability consistency)
590
+ * 3. Registers in the database
591
+ * 4. Transitions to `ready` state if no new capability approval is needed
592
+ *
593
+ * Response: `PluginRecord`
594
+ *
595
+ * Errors:
596
+ * - `400` — validation failure or install error (package not found, bad manifest, etc.)
597
+ * - `500` — installation succeeded but manifest is missing (indicates a loader bug)
598
+ */
599
+ router.post("/plugins/install", async (req, res) => {
600
+ assertInstanceAdmin(req);
601
+ const { packageName, version, isLocalPath } = req.body;
602
+ // Input validation
603
+ if (!packageName || typeof packageName !== "string") {
604
+ res.status(400).json({ error: "packageName is required and must be a string" });
605
+ return;
606
+ }
607
+ if (version !== undefined && typeof version !== "string") {
608
+ res.status(400).json({ error: "version must be a string if provided" });
609
+ return;
610
+ }
611
+ if (isLocalPath !== undefined && typeof isLocalPath !== "boolean") {
612
+ res.status(400).json({ error: "isLocalPath must be a boolean if provided" });
613
+ return;
614
+ }
615
+ // Validate package name format
616
+ const trimmedPackage = packageName.trim();
617
+ if (trimmedPackage.length === 0) {
618
+ res.status(400).json({ error: "packageName cannot be empty" });
619
+ return;
620
+ }
621
+ // Basic security check for package name (prevent injection)
622
+ if (!isLocalPath && /[<>:"|?*]/.test(trimmedPackage)) {
623
+ res.status(400).json({ error: "packageName contains invalid characters" });
624
+ return;
625
+ }
626
+ try {
627
+ const installOptions = isLocalPath
628
+ ? { localPath: trimmedPackage }
629
+ : { packageName: trimmedPackage, version: version?.trim() };
630
+ const discovered = await loader.installPlugin(installOptions);
631
+ if (!discovered.manifest) {
632
+ res.status(500).json({ error: "Plugin installed but manifest is missing" });
633
+ return;
634
+ }
635
+ // Transition to ready state
636
+ const existingPlugin = await registry.getByKey(discovered.manifest.id);
637
+ if (existingPlugin) {
638
+ await lifecycle.load(existingPlugin.id);
639
+ const updated = await registry.getById(existingPlugin.id);
640
+ await logPluginMutationActivity(req, "plugin.installed", existingPlugin.id, {
641
+ pluginId: existingPlugin.id,
642
+ pluginKey: existingPlugin.pluginKey,
643
+ packageName: updated?.packageName ?? existingPlugin.packageName,
644
+ version: updated?.version ?? existingPlugin.version,
645
+ source: isLocalPath ? "local_path" : "npm",
646
+ });
647
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: existingPlugin.id, action: "installed" } });
648
+ res.json(updated);
649
+ }
650
+ else {
651
+ // This shouldn't happen since installPlugin already registers in the DB
652
+ res.status(500).json({ error: "Plugin installed but not found in registry" });
653
+ }
654
+ }
655
+ catch (err) {
656
+ const message = err instanceof Error ? err.message : String(err);
657
+ res.status(400).json({ error: message });
658
+ }
659
+ });
660
+ /**
661
+ * Map a worker RPC error to a bridge-level error code.
662
+ *
663
+ * JsonRpcCallError carries numeric codes from the plugin RPC error code space.
664
+ * This helper maps them to the string error codes defined in PluginBridgeErrorCode.
665
+ *
666
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
667
+ */
668
+ function mapRpcErrorToBridgeError(err) {
669
+ if (err instanceof JsonRpcCallError) {
670
+ switch (err.code) {
671
+ case PLUGIN_RPC_ERROR_CODES.WORKER_UNAVAILABLE:
672
+ return {
673
+ code: "WORKER_UNAVAILABLE",
674
+ message: err.message,
675
+ details: err.data,
676
+ };
677
+ case PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED:
678
+ return {
679
+ code: "CAPABILITY_DENIED",
680
+ message: err.message,
681
+ details: err.data,
682
+ };
683
+ case PLUGIN_RPC_ERROR_CODES.TIMEOUT:
684
+ return {
685
+ code: "TIMEOUT",
686
+ message: err.message,
687
+ details: err.data,
688
+ };
689
+ case PLUGIN_RPC_ERROR_CODES.WORKER_ERROR:
690
+ return {
691
+ code: "WORKER_ERROR",
692
+ message: err.message,
693
+ details: err.data,
694
+ };
695
+ default:
696
+ return {
697
+ code: "UNKNOWN",
698
+ message: err.message,
699
+ details: err.data,
700
+ };
701
+ }
702
+ }
703
+ const message = err instanceof Error ? err.message : String(err);
704
+ // Worker not running — surface as WORKER_UNAVAILABLE
705
+ if (message.includes("not running") || message.includes("not registered")) {
706
+ return {
707
+ code: "WORKER_UNAVAILABLE",
708
+ message,
709
+ };
710
+ }
711
+ return {
712
+ code: "UNKNOWN",
713
+ message,
714
+ };
715
+ }
716
+ /**
717
+ * POST /api/plugins/:pluginId/bridge/data
718
+ *
719
+ * Proxy a `getData` call from the plugin UI to the plugin worker.
720
+ *
721
+ * This is the server-side half of the `usePluginData(key, params)` bridge hook.
722
+ * The frontend sends a POST with the data key and optional params; the host
723
+ * forwards the call to the worker via the `getData` RPC method and returns
724
+ * the result.
725
+ *
726
+ * Request body:
727
+ * - `key`: Plugin-defined data key (e.g. `"sync-health"`)
728
+ * - `params`: Optional query parameters forwarded to the worker handler
729
+ *
730
+ * Response: The raw result from the worker's `getData` handler
731
+ *
732
+ * Error response body follows the `PluginBridgeError` shape:
733
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
734
+ *
735
+ * Errors:
736
+ * - 400 if request validation fails
737
+ * - 404 if plugin not found
738
+ * - 501 if bridge deps are not configured
739
+ * - 502 if the worker is unavailable or returns an error
740
+ *
741
+ * @see PLUGIN_SPEC.md §13.8 — `getData`
742
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
743
+ */
744
+ router.post("/plugins/:pluginId/bridge/data", async (req, res) => {
745
+ assertBoardOrgAccess(req);
746
+ if (!bridgeDeps) {
747
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
748
+ return;
749
+ }
750
+ const { pluginId } = req.params;
751
+ // Resolve plugin
752
+ const plugin = await resolvePlugin(registry, pluginId);
753
+ if (!plugin) {
754
+ res.status(404).json({ error: "Plugin not found" });
755
+ return;
756
+ }
757
+ // Validate plugin is in ready state
758
+ if (plugin.status !== "ready") {
759
+ const bridgeError = {
760
+ code: "WORKER_UNAVAILABLE",
761
+ message: `Plugin is not ready (current status: ${plugin.status})`,
762
+ };
763
+ res.status(502).json(bridgeError);
764
+ return;
765
+ }
766
+ // Validate request body
767
+ const body = req.body;
768
+ if (!body || !body.key || typeof body.key !== "string") {
769
+ res.status(400).json({ error: '"key" is required and must be a string' });
770
+ return;
771
+ }
772
+ assertPluginBridgeScope(req, body.companyId);
773
+ try {
774
+ const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
775
+ key: body.key,
776
+ params: body.params ?? {},
777
+ renderEnvironment: body.renderEnvironment ?? null,
778
+ });
779
+ res.json({ data: result });
780
+ }
781
+ catch (err) {
782
+ const bridgeError = mapRpcErrorToBridgeError(err);
783
+ res.status(502).json(bridgeError);
784
+ }
785
+ });
786
+ /**
787
+ * POST /api/plugins/:pluginId/bridge/action
788
+ *
789
+ * Proxy a `performAction` call from the plugin UI to the plugin worker.
790
+ *
791
+ * This is the server-side half of the `usePluginAction(key)` bridge hook.
792
+ * The frontend sends a POST with the action key and optional params; the host
793
+ * forwards the call to the worker via the `performAction` RPC method and
794
+ * returns the result.
795
+ *
796
+ * Request body:
797
+ * - `key`: Plugin-defined action key (e.g. `"resync"`)
798
+ * - `params`: Optional parameters forwarded to the worker handler
799
+ *
800
+ * Response: The raw result from the worker's `performAction` handler
801
+ *
802
+ * Error response body follows the `PluginBridgeError` shape:
803
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
804
+ *
805
+ * Errors:
806
+ * - 400 if request validation fails
807
+ * - 404 if plugin not found
808
+ * - 501 if bridge deps are not configured
809
+ * - 502 if the worker is unavailable or returns an error
810
+ *
811
+ * @see PLUGIN_SPEC.md §13.9 — `performAction`
812
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
813
+ */
814
+ router.post("/plugins/:pluginId/bridge/action", async (req, res) => {
815
+ assertBoardOrgAccess(req);
816
+ if (!bridgeDeps) {
817
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
818
+ return;
819
+ }
820
+ const { pluginId } = req.params;
821
+ // Resolve plugin
822
+ const plugin = await resolvePlugin(registry, pluginId);
823
+ if (!plugin) {
824
+ res.status(404).json({ error: "Plugin not found" });
825
+ return;
826
+ }
827
+ // Validate plugin is in ready state
828
+ if (plugin.status !== "ready") {
829
+ const bridgeError = {
830
+ code: "WORKER_UNAVAILABLE",
831
+ message: `Plugin is not ready (current status: ${plugin.status})`,
832
+ };
833
+ res.status(502).json(bridgeError);
834
+ return;
835
+ }
836
+ // Validate request body
837
+ const body = req.body;
838
+ if (!body || !body.key || typeof body.key !== "string") {
839
+ res.status(400).json({ error: '"key" is required and must be a string' });
840
+ return;
841
+ }
842
+ assertPluginBridgeScope(req, body.companyId);
843
+ try {
844
+ const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
845
+ key: body.key,
846
+ params: body.params ?? {},
847
+ renderEnvironment: body.renderEnvironment ?? null,
848
+ });
849
+ res.json({ data: result });
850
+ }
851
+ catch (err) {
852
+ const bridgeError = mapRpcErrorToBridgeError(err);
853
+ res.status(502).json(bridgeError);
854
+ }
855
+ });
856
+ // ===========================================================================
857
+ // URL-keyed bridge routes (key as path parameter)
858
+ // ===========================================================================
859
+ /**
860
+ * POST /api/plugins/:pluginId/data/:key
861
+ *
862
+ * Proxy a `getData` call from the plugin UI to the plugin worker, with the
863
+ * data key specified as a URL path parameter instead of in the request body.
864
+ *
865
+ * This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/data`.
866
+ * The frontend bridge hooks use this endpoint for cleaner URLs.
867
+ *
868
+ * Request body (optional):
869
+ * - `params`: Optional query parameters forwarded to the worker handler
870
+ *
871
+ * Response: The raw result from the worker's `getData` handler wrapped as `{ data: T }`
872
+ *
873
+ * Error response body follows the `PluginBridgeError` shape:
874
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
875
+ *
876
+ * Errors:
877
+ * - 404 if plugin not found
878
+ * - 501 if bridge deps are not configured
879
+ * - 502 if the worker is unavailable or returns an error
880
+ *
881
+ * @see PLUGIN_SPEC.md §13.8 — `getData`
882
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
883
+ */
884
+ router.post("/plugins/:pluginId/data/:key", async (req, res) => {
885
+ assertBoardOrgAccess(req);
886
+ if (!bridgeDeps) {
887
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
888
+ return;
889
+ }
890
+ const { pluginId, key } = req.params;
891
+ // Resolve plugin
892
+ const plugin = await resolvePlugin(registry, pluginId);
893
+ if (!plugin) {
894
+ res.status(404).json({ error: "Plugin not found" });
895
+ return;
896
+ }
897
+ // Validate plugin is in ready state
898
+ if (plugin.status !== "ready") {
899
+ const bridgeError = {
900
+ code: "WORKER_UNAVAILABLE",
901
+ message: `Plugin is not ready (current status: ${plugin.status})`,
902
+ };
903
+ res.status(502).json(bridgeError);
904
+ return;
905
+ }
906
+ const body = req.body;
907
+ assertPluginBridgeScope(req, body?.companyId);
908
+ try {
909
+ const result = await bridgeDeps.workerManager.call(plugin.id, "getData", {
910
+ key,
911
+ params: body?.params ?? {},
912
+ renderEnvironment: body?.renderEnvironment ?? null,
913
+ });
914
+ res.json({ data: result });
915
+ }
916
+ catch (err) {
917
+ const bridgeError = mapRpcErrorToBridgeError(err);
918
+ res.status(502).json(bridgeError);
919
+ }
920
+ });
921
+ /**
922
+ * POST /api/plugins/:pluginId/actions/:key
923
+ *
924
+ * Proxy a `performAction` call from the plugin UI to the plugin worker, with
925
+ * the action key specified as a URL path parameter instead of in the request body.
926
+ *
927
+ * This is a REST-friendly alternative to `POST /plugins/:pluginId/bridge/action`.
928
+ * The frontend bridge hooks use this endpoint for cleaner URLs.
929
+ *
930
+ * Request body (optional):
931
+ * - `params`: Optional parameters forwarded to the worker handler
932
+ *
933
+ * Response: The raw result from the worker's `performAction` handler wrapped as `{ data: T }`
934
+ *
935
+ * Error response body follows the `PluginBridgeError` shape:
936
+ * `{ code: PluginBridgeErrorCode, message: string, details?: unknown }`
937
+ *
938
+ * Errors:
939
+ * - 404 if plugin not found
940
+ * - 501 if bridge deps are not configured
941
+ * - 502 if the worker is unavailable or returns an error
942
+ *
943
+ * @see PLUGIN_SPEC.md §13.9 — `performAction`
944
+ * @see PLUGIN_SPEC.md §19.7 — Error Propagation Through The Bridge
945
+ */
946
+ router.post("/plugins/:pluginId/actions/:key", async (req, res) => {
947
+ assertBoardOrgAccess(req);
948
+ if (!bridgeDeps) {
949
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
950
+ return;
951
+ }
952
+ const { pluginId, key } = req.params;
953
+ // Resolve plugin
954
+ const plugin = await resolvePlugin(registry, pluginId);
955
+ if (!plugin) {
956
+ res.status(404).json({ error: "Plugin not found" });
957
+ return;
958
+ }
959
+ // Validate plugin is in ready state
960
+ if (plugin.status !== "ready") {
961
+ const bridgeError = {
962
+ code: "WORKER_UNAVAILABLE",
963
+ message: `Plugin is not ready (current status: ${plugin.status})`,
964
+ };
965
+ res.status(502).json(bridgeError);
966
+ return;
967
+ }
968
+ const body = req.body;
969
+ assertPluginBridgeScope(req, body?.companyId);
970
+ try {
971
+ const result = await bridgeDeps.workerManager.call(plugin.id, "performAction", {
972
+ key,
973
+ params: body?.params ?? {},
974
+ renderEnvironment: body?.renderEnvironment ?? null,
975
+ });
976
+ res.json({ data: result });
977
+ }
978
+ catch (err) {
979
+ const bridgeError = mapRpcErrorToBridgeError(err);
980
+ res.status(502).json(bridgeError);
981
+ }
982
+ });
983
+ // ===========================================================================
984
+ // SSE stream bridge route
985
+ // ===========================================================================
986
+ /**
987
+ * GET /api/plugins/:pluginId/bridge/stream/:channel
988
+ *
989
+ * Server-Sent Events endpoint for real-time streaming from plugin worker to UI.
990
+ *
991
+ * The worker pushes events via `ctx.streams.emit(channel, event)` which arrive
992
+ * as JSON-RPC notifications to the host, get published on the PluginStreamBus,
993
+ * and are fanned out to all connected SSE clients matching (pluginId, channel,
994
+ * companyId).
995
+ *
996
+ * Query parameters:
997
+ * - `companyId` (required): Scope events to a specific company
998
+ *
999
+ * SSE event types:
1000
+ * - `message`: A data event from the worker (default)
1001
+ * - `open`: The worker opened the stream channel
1002
+ * - `close`: The worker closed the stream channel — client should disconnect
1003
+ *
1004
+ * Errors:
1005
+ * - 400 if companyId is missing
1006
+ * - 404 if plugin not found
1007
+ * - 501 if bridge deps or stream bus are not configured
1008
+ */
1009
+ router.get("/plugins/:pluginId/bridge/stream/:channel", async (req, res) => {
1010
+ assertBoardOrgAccess(req);
1011
+ if (!bridgeDeps?.streamBus) {
1012
+ res.status(501).json({ error: "Plugin stream bridge is not enabled" });
1013
+ return;
1014
+ }
1015
+ const { pluginId, channel } = req.params;
1016
+ const companyId = req.query.companyId;
1017
+ if (!companyId) {
1018
+ res.status(400).json({ error: '"companyId" query parameter is required' });
1019
+ return;
1020
+ }
1021
+ const plugin = await resolvePlugin(registry, pluginId);
1022
+ if (!plugin) {
1023
+ res.status(404).json({ error: "Plugin not found" });
1024
+ return;
1025
+ }
1026
+ assertCompanyAccess(req, companyId);
1027
+ // Set SSE headers
1028
+ res.writeHead(200, {
1029
+ "Content-Type": "text/event-stream",
1030
+ "Cache-Control": "no-cache",
1031
+ "Connection": "keep-alive",
1032
+ "X-Accel-Buffering": "no",
1033
+ });
1034
+ res.flushHeaders();
1035
+ // Send initial comment to establish the connection
1036
+ res.write(":ok\n\n");
1037
+ let unsubscribed = false;
1038
+ const safeUnsubscribe = () => {
1039
+ if (!unsubscribed) {
1040
+ unsubscribed = true;
1041
+ unsubscribe();
1042
+ }
1043
+ };
1044
+ const unsubscribe = bridgeDeps.streamBus.subscribe(plugin.id, channel, companyId, (event, eventType) => {
1045
+ if (unsubscribed || !res.writable)
1046
+ return;
1047
+ try {
1048
+ if (eventType !== "message") {
1049
+ res.write(`event: ${eventType}\n`);
1050
+ }
1051
+ res.write(`data: ${JSON.stringify(event)}\n\n`);
1052
+ }
1053
+ catch {
1054
+ // Connection closed or write error — stop delivering
1055
+ safeUnsubscribe();
1056
+ }
1057
+ });
1058
+ req.on("close", safeUnsubscribe);
1059
+ res.on("error", safeUnsubscribe);
1060
+ });
1061
+ router.use("/plugins/:pluginId/api", async (req, res) => {
1062
+ if (!bridgeDeps) {
1063
+ res.status(501).json({ error: "Plugin scoped API routes are not enabled" });
1064
+ return;
1065
+ }
1066
+ const { pluginId } = req.params;
1067
+ const plugin = await resolvePlugin(registry, pluginId);
1068
+ if (!plugin) {
1069
+ res.status(404).json({ error: "Plugin not found" });
1070
+ return;
1071
+ }
1072
+ if (plugin.status !== "ready") {
1073
+ res.status(503).json({ error: `Plugin is not ready (current status: ${plugin.status})` });
1074
+ return;
1075
+ }
1076
+ const isWorkerRunning = typeof bridgeDeps.workerManager.isRunning === "function"
1077
+ ? bridgeDeps.workerManager.isRunning(plugin.id)
1078
+ : true;
1079
+ if (!isWorkerRunning) {
1080
+ res.status(503).json({ error: "Plugin worker is not running" });
1081
+ return;
1082
+ }
1083
+ if (!plugin.manifestJson.capabilities.includes("api.routes.register")) {
1084
+ res.status(404).json({ error: "Plugin does not expose scoped API routes" });
1085
+ return;
1086
+ }
1087
+ const requestPath = req.path || "/";
1088
+ const routes = plugin.manifestJson.apiRoutes ?? [];
1089
+ const match = routes
1090
+ .map((route) => ({ route, params: matchScopedApiRoute(route, req.method, requestPath) }))
1091
+ .find((candidate) => candidate.params !== null);
1092
+ if (!match || !match.params) {
1093
+ res.status(404).json({ error: "Plugin API route not found" });
1094
+ return;
1095
+ }
1096
+ try {
1097
+ assertScopedApiAuth(req, match.route);
1098
+ const companyId = await resolveScopedApiCompanyId(match.route, match.params, req);
1099
+ if (!companyId) {
1100
+ res.status(400).json({ error: "Unable to resolve company for plugin API route" });
1101
+ return;
1102
+ }
1103
+ assertCompanyAccess(req, companyId);
1104
+ await enforceScopedApiCheckout(req, match.route, match.params, companyId);
1105
+ if (req.method !== "GET" && req.headers["content-type"] && !req.is("application/json")) {
1106
+ res.status(415).json({ error: "Plugin API routes accept JSON requests only" });
1107
+ return;
1108
+ }
1109
+ const requestBody = req.body ?? null;
1110
+ const bodySize = Buffer.byteLength(JSON.stringify(requestBody));
1111
+ if (bodySize > PLUGIN_API_BODY_LIMIT_BYTES) {
1112
+ res.status(413).json({ error: "Plugin API request body is too large" });
1113
+ return;
1114
+ }
1115
+ const actor = getActorInfo(req);
1116
+ const input = {
1117
+ routeKey: match.route.routeKey,
1118
+ method: req.method,
1119
+ path: requestPath,
1120
+ params: match.params,
1121
+ query: normalizeQuery(req.query),
1122
+ body: requestBody,
1123
+ actor: {
1124
+ actorType: actor.actorType,
1125
+ actorId: actor.actorId,
1126
+ agentId: actor.agentId,
1127
+ userId: actor.actorType === "user" ? actor.actorId : null,
1128
+ runId: actor.runId,
1129
+ },
1130
+ companyId,
1131
+ headers: sanitizePluginRequestHeaders(req),
1132
+ };
1133
+ const result = await bridgeDeps.workerManager.call(plugin.id, "handleApiRequest", input);
1134
+ const status = Number.isInteger(result.status) && Number(result.status) >= 200 && Number(result.status) <= 599
1135
+ ? Number(result.status)
1136
+ : 200;
1137
+ applyPluginScopedApiResponseHeaders(res, result.headers);
1138
+ if (status === 204) {
1139
+ res.status(status).end();
1140
+ }
1141
+ else {
1142
+ res.status(status).json(result.body ?? null);
1143
+ }
1144
+ }
1145
+ catch (err) {
1146
+ const status = typeof err.status === "number"
1147
+ ? err.status
1148
+ : err instanceof JsonRpcCallError && err.code === PLUGIN_RPC_ERROR_CODES.CAPABILITY_DENIED
1149
+ ? 403
1150
+ : err instanceof JsonRpcCallError && err.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED
1151
+ ? 501
1152
+ : err instanceof JsonRpcCallError
1153
+ ? 502
1154
+ : 500;
1155
+ res.status(status).json({
1156
+ error: err instanceof Error ? err.message : String(err),
1157
+ });
1158
+ }
1159
+ });
1160
+ /**
1161
+ * GET /api/plugins/:pluginId
1162
+ *
1163
+ * Get detailed information about a single plugin.
1164
+ *
1165
+ * The :pluginId parameter accepts either:
1166
+ * - Database UUID (e.g., "abc123-def456")
1167
+ * - Plugin key (e.g., "acme.linear")
1168
+ *
1169
+ * Response: PluginRecord
1170
+ * Errors: 404 if plugin not found
1171
+ */
1172
+ router.get("/plugins/:pluginId", async (req, res) => {
1173
+ assertBoardOrgAccess(req);
1174
+ const { pluginId } = req.params;
1175
+ const plugin = await resolvePlugin(registry, pluginId);
1176
+ if (!plugin) {
1177
+ res.status(404).json({ error: "Plugin not found" });
1178
+ return;
1179
+ }
1180
+ // Enrich with worker capabilities when available
1181
+ const worker = bridgeDeps?.workerManager.getWorker(plugin.id);
1182
+ const supportsConfigTest = worker
1183
+ ? worker.supportedMethods.includes("validateConfig")
1184
+ : false;
1185
+ res.json({ ...plugin, supportsConfigTest });
1186
+ });
1187
+ /**
1188
+ * DELETE /api/plugins/:pluginId
1189
+ *
1190
+ * Uninstall a plugin.
1191
+ *
1192
+ * Query params:
1193
+ * - purge: If "true", permanently delete all plugin data (hard delete)
1194
+ * Otherwise, soft-delete with 30-day data retention
1195
+ *
1196
+ * Response: PluginRecord (the deleted record)
1197
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
1198
+ */
1199
+ router.delete("/plugins/:pluginId", async (req, res) => {
1200
+ assertInstanceAdmin(req);
1201
+ const { pluginId } = req.params;
1202
+ const purge = req.query.purge === "true";
1203
+ const plugin = await resolvePlugin(registry, pluginId);
1204
+ if (!plugin) {
1205
+ res.status(404).json({ error: "Plugin not found" });
1206
+ return;
1207
+ }
1208
+ try {
1209
+ const result = await lifecycle.unload(plugin.id, purge);
1210
+ await logPluginMutationActivity(req, "plugin.uninstalled", plugin.id, {
1211
+ pluginId: plugin.id,
1212
+ pluginKey: plugin.pluginKey,
1213
+ purge,
1214
+ });
1215
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "uninstalled" } });
1216
+ res.json(result);
1217
+ }
1218
+ catch (err) {
1219
+ const message = err instanceof Error ? err.message : String(err);
1220
+ res.status(400).json({ error: message });
1221
+ }
1222
+ });
1223
+ /**
1224
+ * POST /api/plugins/:pluginId/enable
1225
+ *
1226
+ * Enable a plugin that is currently disabled or in error state.
1227
+ *
1228
+ * Transitions the plugin to 'ready' state after loading and validation.
1229
+ *
1230
+ * Response: PluginRecord
1231
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
1232
+ */
1233
+ router.post("/plugins/:pluginId/enable", async (req, res) => {
1234
+ assertInstanceAdmin(req);
1235
+ const { pluginId } = req.params;
1236
+ const plugin = await resolvePlugin(registry, pluginId);
1237
+ if (!plugin) {
1238
+ res.status(404).json({ error: "Plugin not found" });
1239
+ return;
1240
+ }
1241
+ try {
1242
+ const result = await lifecycle.enable(plugin.id);
1243
+ await logPluginMutationActivity(req, "plugin.enabled", plugin.id, {
1244
+ pluginId: plugin.id,
1245
+ pluginKey: plugin.pluginKey,
1246
+ version: result?.version ?? plugin.version,
1247
+ });
1248
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "enabled" } });
1249
+ res.json(result);
1250
+ }
1251
+ catch (err) {
1252
+ const message = err instanceof Error ? err.message : String(err);
1253
+ res.status(400).json({ error: message });
1254
+ }
1255
+ });
1256
+ /**
1257
+ * POST /api/plugins/:pluginId/disable
1258
+ *
1259
+ * Disable a running plugin.
1260
+ *
1261
+ * Request body (optional):
1262
+ * - reason: Human-readable reason for disabling
1263
+ *
1264
+ * The plugin transitions to 'installed' state and stops processing events.
1265
+ *
1266
+ * Response: PluginRecord
1267
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
1268
+ */
1269
+ router.post("/plugins/:pluginId/disable", async (req, res) => {
1270
+ assertInstanceAdmin(req);
1271
+ const { pluginId } = req.params;
1272
+ const body = req.body;
1273
+ const reason = body?.reason;
1274
+ const plugin = await resolvePlugin(registry, pluginId);
1275
+ if (!plugin) {
1276
+ res.status(404).json({ error: "Plugin not found" });
1277
+ return;
1278
+ }
1279
+ try {
1280
+ const result = await lifecycle.disable(plugin.id, reason);
1281
+ await logPluginMutationActivity(req, "plugin.disabled", plugin.id, {
1282
+ pluginId: plugin.id,
1283
+ pluginKey: plugin.pluginKey,
1284
+ reason: reason ?? null,
1285
+ });
1286
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "disabled" } });
1287
+ res.json(result);
1288
+ }
1289
+ catch (err) {
1290
+ const message = err instanceof Error ? err.message : String(err);
1291
+ res.status(400).json({ error: message });
1292
+ }
1293
+ });
1294
+ /**
1295
+ * GET /api/plugins/:pluginId/health
1296
+ *
1297
+ * Run health diagnostics on a plugin.
1298
+ *
1299
+ * Performs the following checks:
1300
+ * 1. Registry: Plugin is registered in the database
1301
+ * 2. Manifest: Manifest is valid and parseable
1302
+ * 3. Status: Plugin is in 'ready' state
1303
+ * 4. Error state: Plugin has no unhandled errors
1304
+ *
1305
+ * Response: PluginHealthCheckResult
1306
+ * Errors: 404 if plugin not found
1307
+ */
1308
+ router.get("/plugins/:pluginId/health", async (req, res) => {
1309
+ assertBoardOrgAccess(req);
1310
+ const { pluginId } = req.params;
1311
+ const plugin = await resolvePlugin(registry, pluginId);
1312
+ if (!plugin) {
1313
+ res.status(404).json({ error: "Plugin not found" });
1314
+ return;
1315
+ }
1316
+ const checks = [];
1317
+ // Check 1: Plugin is registered
1318
+ checks.push({
1319
+ name: "registry",
1320
+ passed: true,
1321
+ message: "Plugin found in registry",
1322
+ });
1323
+ // Check 2: Manifest is valid
1324
+ const hasValidManifest = Boolean(plugin.manifestJson?.id);
1325
+ checks.push({
1326
+ name: "manifest",
1327
+ passed: hasValidManifest,
1328
+ message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
1329
+ });
1330
+ // Check 3: Plugin status
1331
+ const isHealthy = plugin.status === "ready";
1332
+ checks.push({
1333
+ name: "status",
1334
+ passed: isHealthy,
1335
+ message: `Current status: ${plugin.status}`,
1336
+ });
1337
+ // Check 4: No last error
1338
+ const hasNoError = !plugin.lastError;
1339
+ if (!hasNoError) {
1340
+ checks.push({
1341
+ name: "error_state",
1342
+ passed: false,
1343
+ message: plugin.lastError ?? undefined,
1344
+ });
1345
+ }
1346
+ const result = {
1347
+ pluginId: plugin.id,
1348
+ status: plugin.status,
1349
+ healthy: isHealthy && hasValidManifest && hasNoError,
1350
+ checks,
1351
+ lastError: plugin.lastError ?? undefined,
1352
+ };
1353
+ res.json(result);
1354
+ });
1355
+ /**
1356
+ * GET /api/plugins/:pluginId/logs
1357
+ *
1358
+ * Query recent log entries for a plugin.
1359
+ *
1360
+ * Query params:
1361
+ * - limit: Maximum number of entries (default 25, max 500)
1362
+ * - level: Filter by log level (info, warn, error, debug)
1363
+ * - since: ISO timestamp to filter logs newer than this time
1364
+ *
1365
+ * Response: Array of log entries, newest first.
1366
+ */
1367
+ router.get("/plugins/:pluginId/logs", async (req, res) => {
1368
+ assertBoardOrgAccess(req);
1369
+ const { pluginId } = req.params;
1370
+ const plugin = await resolvePlugin(registry, pluginId);
1371
+ if (!plugin) {
1372
+ res.status(404).json({ error: "Plugin not found" });
1373
+ return;
1374
+ }
1375
+ const limit = Math.min(Math.max(parseInt(req.query.limit, 10) || 25, 1), 500);
1376
+ const level = req.query.level;
1377
+ const since = req.query.since;
1378
+ const conditions = [eq(pluginLogs.pluginId, plugin.id)];
1379
+ if (level) {
1380
+ conditions.push(eq(pluginLogs.level, level));
1381
+ }
1382
+ if (since) {
1383
+ const sinceDate = new Date(since);
1384
+ if (!isNaN(sinceDate.getTime())) {
1385
+ conditions.push(gte(pluginLogs.createdAt, sinceDate));
1386
+ }
1387
+ }
1388
+ const rows = await db
1389
+ .select()
1390
+ .from(pluginLogs)
1391
+ .where(and(...conditions))
1392
+ .orderBy(desc(pluginLogs.createdAt))
1393
+ .limit(limit);
1394
+ res.json(rows);
1395
+ });
1396
+ /**
1397
+ * POST /api/plugins/:pluginId/upgrade
1398
+ *
1399
+ * Upgrade a plugin to a newer version.
1400
+ *
1401
+ * Upgrades are restricted to instance admins because they fetch and inspect
1402
+ * new package contents on the host before activation.
1403
+ *
1404
+ * Request body (optional):
1405
+ * - version: Target version (defaults to latest)
1406
+ *
1407
+ * If the upgrade adds new capabilities, the plugin transitions to
1408
+ * 'upgrade_pending' state for board approval. Otherwise, it goes
1409
+ * directly to 'ready'.
1410
+ *
1411
+ * Response: PluginRecord
1412
+ * Errors: 404 if plugin not found, 400 for lifecycle errors
1413
+ */
1414
+ router.post("/plugins/:pluginId/upgrade", async (req, res) => {
1415
+ assertInstanceAdmin(req);
1416
+ const { pluginId } = req.params;
1417
+ const body = req.body;
1418
+ const version = body?.version;
1419
+ const plugin = await resolvePlugin(registry, pluginId);
1420
+ if (!plugin) {
1421
+ res.status(404).json({ error: "Plugin not found" });
1422
+ return;
1423
+ }
1424
+ try {
1425
+ // Upgrade the plugin - this would typically:
1426
+ // 1. Download the new version
1427
+ // 2. Compare capabilities
1428
+ // 3. If new capabilities, mark as upgrade_pending
1429
+ // 4. Otherwise, transition to ready
1430
+ const result = await lifecycle.upgrade(plugin.id, version);
1431
+ await logPluginMutationActivity(req, "plugin.upgraded", plugin.id, {
1432
+ pluginId: plugin.id,
1433
+ pluginKey: plugin.pluginKey,
1434
+ previousVersion: plugin.version,
1435
+ version: result?.version ?? plugin.version,
1436
+ targetVersion: version ?? null,
1437
+ });
1438
+ publishGlobalLiveEvent({ type: "plugin.ui.updated", payload: { pluginId: plugin.id, action: "upgraded" } });
1439
+ res.json(result);
1440
+ }
1441
+ catch (err) {
1442
+ const message = err instanceof Error ? err.message : String(err);
1443
+ res.status(400).json({ error: message });
1444
+ }
1445
+ });
1446
+ // ===========================================================================
1447
+ // Plugin configuration routes
1448
+ // ===========================================================================
1449
+ /**
1450
+ * GET /api/plugins/:pluginId/config
1451
+ *
1452
+ * Retrieve the current instance configuration for a plugin.
1453
+ *
1454
+ * Returns the `PluginConfig` record if one exists, or `null` if the plugin
1455
+ * has not yet been configured.
1456
+ *
1457
+ * Response: `PluginConfig | null`
1458
+ * Errors: 404 if plugin not found
1459
+ */
1460
+ router.get("/plugins/:pluginId/config", async (req, res) => {
1461
+ assertBoardOrgAccess(req);
1462
+ const { pluginId } = req.params;
1463
+ const plugin = await resolvePlugin(registry, pluginId);
1464
+ if (!plugin) {
1465
+ res.status(404).json({ error: "Plugin not found" });
1466
+ return;
1467
+ }
1468
+ const config = await registry.getConfig(plugin.id);
1469
+ res.json(config);
1470
+ });
1471
+ /**
1472
+ * POST /api/plugins/:pluginId/config
1473
+ *
1474
+ * Save (create or replace) the instance configuration for a plugin.
1475
+ *
1476
+ * The caller provides the full `configJson` object. The server persists it
1477
+ * via `registry.upsertConfig()`.
1478
+ *
1479
+ * Request body:
1480
+ * - `configJson`: Configuration values matching the plugin's `instanceConfigSchema`
1481
+ *
1482
+ * Response: `PluginConfig`
1483
+ * Errors:
1484
+ * - 400 if request validation fails
1485
+ * - 404 if plugin not found
1486
+ */
1487
+ router.post("/plugins/:pluginId/config", async (req, res) => {
1488
+ assertInstanceAdmin(req);
1489
+ const { pluginId } = req.params;
1490
+ const plugin = await resolvePlugin(registry, pluginId);
1491
+ if (!plugin) {
1492
+ res.status(404).json({ error: "Plugin not found" });
1493
+ return;
1494
+ }
1495
+ const body = req.body;
1496
+ if (!body?.configJson || typeof body.configJson !== "object") {
1497
+ res.status(400).json({ error: '"configJson" is required and must be an object' });
1498
+ return;
1499
+ }
1500
+ // Strip devUiUrl unless the caller is an instance admin. devUiUrl activates
1501
+ // a dev-proxy in the static file route that could be abused for SSRF if any
1502
+ // board-level user were allowed to set it.
1503
+ if ("devUiUrl" in body.configJson &&
1504
+ !(req.actor.type === "board" && req.actor.isInstanceAdmin)) {
1505
+ delete body.configJson.devUiUrl;
1506
+ }
1507
+ // Validate configJson against the plugin's instanceConfigSchema (if declared).
1508
+ // This ensures CLI/API callers get the same validation the UI performs client-side.
1509
+ const schema = plugin.manifestJson?.instanceConfigSchema;
1510
+ if (schema && Object.keys(schema).length > 0) {
1511
+ const validation = validateInstanceConfig(body.configJson, schema);
1512
+ if (!validation.valid) {
1513
+ res.status(400).json({
1514
+ error: "Configuration does not match the plugin's instanceConfigSchema",
1515
+ fieldErrors: validation.errors,
1516
+ });
1517
+ return;
1518
+ }
1519
+ }
1520
+ try {
1521
+ const secretRefsByPath = extractSecretRefPathsFromConfig(body.configJson, schema);
1522
+ if (secretRefsByPath.size > 0) {
1523
+ res.status(422).json({ error: PLUGIN_SECRET_REFS_DISABLED_MESSAGE });
1524
+ return;
1525
+ }
1526
+ const result = await registry.upsertConfig(plugin.id, {
1527
+ configJson: body.configJson,
1528
+ });
1529
+ await logPluginMutationActivity(req, "plugin.config.updated", plugin.id, {
1530
+ pluginId: plugin.id,
1531
+ pluginKey: plugin.pluginKey,
1532
+ configKeyCount: Object.keys(body.configJson).length,
1533
+ });
1534
+ // Notify the running worker about the config change (PLUGIN_SPEC §25.4.4).
1535
+ // If the worker implements onConfigChanged, send the new config via RPC.
1536
+ // If it doesn't (METHOD_NOT_IMPLEMENTED), restart the worker so it picks
1537
+ // up the new config on re-initialize. If no worker is running, skip.
1538
+ if (bridgeDeps?.workerManager.isRunning(plugin.id)) {
1539
+ try {
1540
+ await bridgeDeps.workerManager.call(plugin.id, "configChanged", { config: body.configJson });
1541
+ }
1542
+ catch (rpcErr) {
1543
+ if (rpcErr instanceof JsonRpcCallError &&
1544
+ rpcErr.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
1545
+ // Worker doesn't handle live config — restart it.
1546
+ try {
1547
+ await lifecycle.restartWorker(plugin.id);
1548
+ }
1549
+ catch {
1550
+ // Restart failure is non-fatal for the config save response.
1551
+ }
1552
+ }
1553
+ // Other RPC errors (timeout, unavailable) are non-fatal — config is
1554
+ // already persisted and will take effect on next worker restart.
1555
+ }
1556
+ }
1557
+ res.json(result);
1558
+ }
1559
+ catch (err) {
1560
+ const message = err instanceof Error ? err.message : String(err);
1561
+ res.status(400).json({ error: message });
1562
+ }
1563
+ });
1564
+ /**
1565
+ * POST /api/plugins/:pluginId/config/test
1566
+ *
1567
+ * Test a plugin configuration without persisting it by calling the plugin
1568
+ * worker's `validateConfig` RPC method.
1569
+ *
1570
+ * Only works when the plugin's worker implements `onValidateConfig`.
1571
+ * If the worker does not implement the method, returns
1572
+ * `{ valid: false, supported: false, message: "..." }` with HTTP 200.
1573
+ *
1574
+ * Request body:
1575
+ * - `configJson`: Configuration values to validate
1576
+ *
1577
+ * Response: `{ valid: boolean; message?: string; supported?: boolean }`
1578
+ * Errors:
1579
+ * - 400 if request validation fails
1580
+ * - 404 if plugin not found
1581
+ * - 501 if bridge deps (worker manager) are not configured
1582
+ * - 502 if the worker is unavailable
1583
+ */
1584
+ router.post("/plugins/:pluginId/config/test", async (req, res) => {
1585
+ assertBoardOrgAccess(req);
1586
+ if (!bridgeDeps) {
1587
+ res.status(501).json({ error: "Plugin bridge is not enabled" });
1588
+ return;
1589
+ }
1590
+ const { pluginId } = req.params;
1591
+ const plugin = await resolvePlugin(registry, pluginId);
1592
+ if (!plugin) {
1593
+ res.status(404).json({ error: "Plugin not found" });
1594
+ return;
1595
+ }
1596
+ if (plugin.status !== "ready") {
1597
+ res.status(400).json({
1598
+ error: `Plugin is not ready (current status: ${plugin.status})`,
1599
+ });
1600
+ return;
1601
+ }
1602
+ const body = req.body;
1603
+ if (!body?.configJson || typeof body.configJson !== "object") {
1604
+ res.status(400).json({ error: '"configJson" is required and must be an object' });
1605
+ return;
1606
+ }
1607
+ // Fast schema-level rejection before hitting the worker RPC.
1608
+ const schema = plugin.manifestJson?.instanceConfigSchema;
1609
+ if (schema && Object.keys(schema).length > 0) {
1610
+ const validation = validateInstanceConfig(body.configJson, schema);
1611
+ if (!validation.valid) {
1612
+ res.status(400).json({
1613
+ error: "Configuration does not match the plugin's instanceConfigSchema",
1614
+ fieldErrors: validation.errors,
1615
+ });
1616
+ return;
1617
+ }
1618
+ }
1619
+ try {
1620
+ const result = await bridgeDeps.workerManager.call(plugin.id, "validateConfig", { config: body.configJson });
1621
+ // The worker returns PluginConfigValidationResult { ok, warnings?, errors? }
1622
+ // Map to the frontend-expected shape { valid, message? }
1623
+ if (result.ok) {
1624
+ const warningText = result.warnings?.length
1625
+ ? `Warnings: ${result.warnings.join("; ")}`
1626
+ : undefined;
1627
+ res.json({ valid: true, message: warningText });
1628
+ }
1629
+ else {
1630
+ const errorText = result.errors?.length
1631
+ ? result.errors.join("; ")
1632
+ : "Configuration validation failed.";
1633
+ res.json({ valid: false, message: errorText });
1634
+ }
1635
+ }
1636
+ catch (err) {
1637
+ // If the worker does not implement validateConfig, return a structured response
1638
+ if (err instanceof JsonRpcCallError &&
1639
+ err.code === PLUGIN_RPC_ERROR_CODES.METHOD_NOT_IMPLEMENTED) {
1640
+ res.json({
1641
+ valid: false,
1642
+ supported: false,
1643
+ message: "This plugin does not support configuration testing.",
1644
+ });
1645
+ return;
1646
+ }
1647
+ // Worker unavailable or other RPC errors
1648
+ const bridgeError = mapRpcErrorToBridgeError(err);
1649
+ res.status(502).json(bridgeError);
1650
+ }
1651
+ });
1652
+ // ===========================================================================
1653
+ // Job scheduling routes
1654
+ // ===========================================================================
1655
+ /**
1656
+ * GET /api/plugins/:pluginId/jobs
1657
+ *
1658
+ * List all scheduled jobs for a plugin.
1659
+ *
1660
+ * Query params:
1661
+ * - `status` (optional): Filter by job status (`active`, `paused`, `failed`)
1662
+ *
1663
+ * Response: PluginJobRecord[]
1664
+ * Errors: 404 if plugin not found
1665
+ */
1666
+ router.get("/plugins/:pluginId/jobs", async (req, res) => {
1667
+ assertBoardOrgAccess(req);
1668
+ if (!jobDeps) {
1669
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1670
+ return;
1671
+ }
1672
+ const { pluginId } = req.params;
1673
+ const plugin = await resolvePlugin(registry, pluginId);
1674
+ if (!plugin) {
1675
+ res.status(404).json({ error: "Plugin not found" });
1676
+ return;
1677
+ }
1678
+ const rawStatus = req.query.status;
1679
+ const validStatuses = ["active", "paused", "failed"];
1680
+ if (rawStatus !== undefined && !validStatuses.includes(rawStatus)) {
1681
+ res.status(400).json({
1682
+ error: `Invalid status '${rawStatus}'. Must be one of: ${validStatuses.join(", ")}`,
1683
+ });
1684
+ return;
1685
+ }
1686
+ try {
1687
+ const jobs = await jobDeps.jobStore.listJobs(plugin.id, rawStatus);
1688
+ res.json(jobs);
1689
+ }
1690
+ catch (err) {
1691
+ const message = err instanceof Error ? err.message : String(err);
1692
+ res.status(500).json({ error: message });
1693
+ }
1694
+ });
1695
+ /**
1696
+ * GET /api/plugins/:pluginId/jobs/:jobId/runs
1697
+ *
1698
+ * List execution history for a specific job.
1699
+ *
1700
+ * Query params:
1701
+ * - `limit` (optional): Maximum number of runs to return (default: 50)
1702
+ *
1703
+ * Response: PluginJobRunRecord[]
1704
+ * Errors: 404 if plugin not found
1705
+ */
1706
+ router.get("/plugins/:pluginId/jobs/:jobId/runs", async (req, res) => {
1707
+ assertBoardOrgAccess(req);
1708
+ if (!jobDeps) {
1709
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1710
+ return;
1711
+ }
1712
+ const { pluginId, jobId } = req.params;
1713
+ const plugin = await resolvePlugin(registry, pluginId);
1714
+ if (!plugin) {
1715
+ res.status(404).json({ error: "Plugin not found" });
1716
+ return;
1717
+ }
1718
+ const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
1719
+ if (!job) {
1720
+ res.status(404).json({ error: "Job not found" });
1721
+ return;
1722
+ }
1723
+ const limit = req.query.limit ? parseInt(req.query.limit, 10) : 25;
1724
+ if (isNaN(limit) || limit < 1 || limit > 500) {
1725
+ res.status(400).json({ error: "limit must be a number between 1 and 500" });
1726
+ return;
1727
+ }
1728
+ try {
1729
+ const runs = await jobDeps.jobStore.listRunsByJob(jobId, limit);
1730
+ res.json(runs);
1731
+ }
1732
+ catch (err) {
1733
+ const message = err instanceof Error ? err.message : String(err);
1734
+ res.status(500).json({ error: message });
1735
+ }
1736
+ });
1737
+ /**
1738
+ * POST /api/plugins/:pluginId/jobs/:jobId/trigger
1739
+ *
1740
+ * Manually trigger a job execution outside its cron schedule.
1741
+ *
1742
+ * Creates a run with `trigger: "manual"` and dispatches immediately.
1743
+ * The response returns before the job completes (non-blocking).
1744
+ *
1745
+ * Response: `{ runId: string, jobId: string }`
1746
+ * Errors:
1747
+ * - 404 if plugin not found
1748
+ * - 400 if job not found, not active, already running, or worker unavailable
1749
+ */
1750
+ router.post("/plugins/:pluginId/jobs/:jobId/trigger", async (req, res) => {
1751
+ assertInstanceAdmin(req);
1752
+ if (!jobDeps) {
1753
+ res.status(501).json({ error: "Job scheduling is not enabled" });
1754
+ return;
1755
+ }
1756
+ const { pluginId, jobId } = req.params;
1757
+ const plugin = await resolvePlugin(registry, pluginId);
1758
+ if (!plugin) {
1759
+ res.status(404).json({ error: "Plugin not found" });
1760
+ return;
1761
+ }
1762
+ const job = await jobDeps.jobStore.getJobByIdForPlugin(plugin.id, jobId);
1763
+ if (!job) {
1764
+ res.status(404).json({ error: "Job not found" });
1765
+ return;
1766
+ }
1767
+ try {
1768
+ const result = await jobDeps.scheduler.triggerJob(jobId, "manual");
1769
+ res.json(result);
1770
+ }
1771
+ catch (err) {
1772
+ const message = err instanceof Error ? err.message : String(err);
1773
+ res.status(400).json({ error: message });
1774
+ }
1775
+ });
1776
+ // ===========================================================================
1777
+ // Webhook ingestion route
1778
+ // ===========================================================================
1779
+ /**
1780
+ * POST /api/plugins/:pluginId/webhooks/:endpointKey
1781
+ *
1782
+ * Receive an inbound webhook delivery for a plugin.
1783
+ *
1784
+ * This route is called by external systems (e.g. GitHub, Linear, Stripe) to
1785
+ * deliver webhook payloads to a plugin. The host validates that:
1786
+ * 1. The plugin exists and is in 'ready' state
1787
+ * 2. The plugin declares the `webhooks.receive` capability
1788
+ * 3. The `endpointKey` matches a declared webhook in the manifest
1789
+ *
1790
+ * The delivery is recorded in the `plugin_webhook_deliveries` table and
1791
+ * dispatched to the worker via the `handleWebhook` RPC method.
1792
+ *
1793
+ * **Note:** This route does NOT require board authentication — webhook
1794
+ * endpoints must be publicly accessible for external callers. Signature
1795
+ * verification is the plugin's responsibility.
1796
+ *
1797
+ * Response: `{ deliveryId: string, status: string }`
1798
+ * Errors:
1799
+ * - 404 if plugin not found or endpointKey not declared
1800
+ * - 400 if plugin is not in ready state or lacks webhooks.receive capability
1801
+ * - 502 if the worker is unavailable or the RPC call fails
1802
+ */
1803
+ router.post("/plugins/:pluginId/webhooks/:endpointKey", async (req, res) => {
1804
+ if (!webhookDeps) {
1805
+ res.status(501).json({ error: "Webhook ingestion is not enabled" });
1806
+ return;
1807
+ }
1808
+ const { pluginId, endpointKey } = req.params;
1809
+ // Step 1: Resolve the plugin
1810
+ const plugin = await resolvePlugin(registry, pluginId);
1811
+ if (!plugin) {
1812
+ res.status(404).json({ error: "Plugin not found" });
1813
+ return;
1814
+ }
1815
+ // Step 2: Validate the plugin is in 'ready' state
1816
+ if (plugin.status !== "ready") {
1817
+ res.status(400).json({
1818
+ error: `Plugin is not ready (current status: ${plugin.status})`,
1819
+ });
1820
+ return;
1821
+ }
1822
+ // Step 3: Validate the plugin has webhooks.receive capability
1823
+ const manifest = plugin.manifestJson;
1824
+ if (!manifest) {
1825
+ res.status(400).json({ error: "Plugin manifest is missing" });
1826
+ return;
1827
+ }
1828
+ const capabilities = manifest.capabilities ?? [];
1829
+ if (!capabilities.includes("webhooks.receive")) {
1830
+ res.status(400).json({
1831
+ error: "Plugin does not have the webhooks.receive capability",
1832
+ });
1833
+ return;
1834
+ }
1835
+ // Step 4: Validate the endpointKey exists in the manifest's webhook declarations
1836
+ const declaredWebhooks = manifest.webhooks ?? [];
1837
+ const webhookDecl = declaredWebhooks.find((w) => w.endpointKey === endpointKey);
1838
+ if (!webhookDecl) {
1839
+ res.status(404).json({
1840
+ error: `Webhook endpoint '${endpointKey}' is not declared by this plugin`,
1841
+ });
1842
+ return;
1843
+ }
1844
+ // Step 5: Extract request data
1845
+ const requestId = randomUUID();
1846
+ const rawHeaders = {};
1847
+ for (const [key, value] of Object.entries(req.headers)) {
1848
+ if (typeof value === "string") {
1849
+ rawHeaders[key] = value;
1850
+ }
1851
+ else if (Array.isArray(value)) {
1852
+ rawHeaders[key] = value.join(", ");
1853
+ }
1854
+ }
1855
+ // Use the raw buffer stashed by the express.json() `verify` callback.
1856
+ // This preserves the exact bytes the provider signed, whereas
1857
+ // JSON.stringify(req.body) would re-serialize and break HMAC verification.
1858
+ const stashedRaw = req.rawBody;
1859
+ const rawBody = stashedRaw ? stashedRaw.toString("utf-8") : "";
1860
+ const parsedBody = req.body;
1861
+ const payload = req.body ?? {};
1862
+ // Step 6: Record the delivery in the database
1863
+ const startedAt = new Date();
1864
+ const [delivery] = await db
1865
+ .insert(pluginWebhookDeliveries)
1866
+ .values({
1867
+ pluginId: plugin.id,
1868
+ webhookKey: endpointKey,
1869
+ status: "pending",
1870
+ payload,
1871
+ headers: rawHeaders,
1872
+ startedAt,
1873
+ })
1874
+ .returning({ id: pluginWebhookDeliveries.id });
1875
+ // Step 7: Dispatch to the worker via handleWebhook RPC
1876
+ try {
1877
+ await webhookDeps.workerManager.call(plugin.id, "handleWebhook", {
1878
+ endpointKey,
1879
+ headers: req.headers,
1880
+ rawBody,
1881
+ parsedBody,
1882
+ requestId,
1883
+ });
1884
+ // Step 8: Update delivery record to success
1885
+ const finishedAt = new Date();
1886
+ const durationMs = finishedAt.getTime() - startedAt.getTime();
1887
+ await db
1888
+ .update(pluginWebhookDeliveries)
1889
+ .set({
1890
+ status: "success",
1891
+ durationMs,
1892
+ finishedAt,
1893
+ })
1894
+ .where(eq(pluginWebhookDeliveries.id, delivery.id));
1895
+ res.status(200).json({
1896
+ deliveryId: delivery.id,
1897
+ status: "success",
1898
+ });
1899
+ }
1900
+ catch (err) {
1901
+ // Step 8 (error): Update delivery record to failed
1902
+ const finishedAt = new Date();
1903
+ const durationMs = finishedAt.getTime() - startedAt.getTime();
1904
+ const errorMessage = err instanceof Error ? err.message : String(err);
1905
+ await db
1906
+ .update(pluginWebhookDeliveries)
1907
+ .set({
1908
+ status: "failed",
1909
+ durationMs,
1910
+ error: errorMessage,
1911
+ finishedAt,
1912
+ })
1913
+ .where(eq(pluginWebhookDeliveries.id, delivery.id));
1914
+ res.status(502).json({
1915
+ deliveryId: delivery.id,
1916
+ status: "failed",
1917
+ error: errorMessage,
1918
+ });
1919
+ }
1920
+ });
1921
+ // ===========================================================================
1922
+ // Company-scoped trusted local folders
1923
+ // ===========================================================================
1924
+ router.get("/plugins/:pluginId/companies/:companyId/local-folders", async (req, res) => {
1925
+ assertBoardOrgAccess(req);
1926
+ const { pluginId, companyId } = req.params;
1927
+ assertCompanyAccess(req, companyId);
1928
+ const plugin = await resolvePlugin(registry, pluginId);
1929
+ if (!plugin) {
1930
+ res.status(404).json({ error: "Plugin not found" });
1931
+ return;
1932
+ }
1933
+ const settings = await registry.getCompanySettings(plugin.id, companyId);
1934
+ const storedFolders = getStoredLocalFolders(settings?.settingsJson);
1935
+ const declarations = plugin.manifestJson.localFolders ?? [];
1936
+ const folderKeys = declarations.map((declaration) => declaration.folderKey);
1937
+ const statuses = await Promise.all(folderKeys.map((folderKey) => inspectPluginLocalFolder({
1938
+ folderKey,
1939
+ declaration: findLocalFolderDeclaration(declarations, folderKey),
1940
+ storedConfig: storedFolders[folderKey] ?? null,
1941
+ })));
1942
+ res.json({
1943
+ pluginId: plugin.id,
1944
+ companyId,
1945
+ declarations,
1946
+ folders: statuses,
1947
+ });
1948
+ });
1949
+ router.get("/plugins/:pluginId/companies/:companyId/local-folders/:folderKey/status", async (req, res) => {
1950
+ assertBoardOrgAccess(req);
1951
+ const { pluginId, companyId, folderKey } = req.params;
1952
+ assertCompanyAccess(req, companyId);
1953
+ const plugin = await resolvePlugin(registry, pluginId);
1954
+ if (!plugin) {
1955
+ res.status(404).json({ error: "Plugin not found" });
1956
+ return;
1957
+ }
1958
+ const settings = await registry.getCompanySettings(plugin.id, companyId);
1959
+ const storedFolders = getStoredLocalFolders(settings?.settingsJson);
1960
+ const declarations = plugin.manifestJson.localFolders ?? [];
1961
+ const declaration = requireLocalFolderDeclaration(declarations, folderKey);
1962
+ const status = await inspectPluginLocalFolder({
1963
+ folderKey,
1964
+ declaration,
1965
+ storedConfig: storedFolders[folderKey] ?? null,
1966
+ });
1967
+ res.json(status);
1968
+ });
1969
+ router.post("/plugins/:pluginId/companies/:companyId/local-folders/:folderKey/validate", async (req, res) => {
1970
+ assertBoardOrgAccess(req);
1971
+ const { pluginId, companyId, folderKey } = req.params;
1972
+ assertCompanyAccess(req, companyId);
1973
+ const plugin = await resolvePlugin(registry, pluginId);
1974
+ if (!plugin) {
1975
+ res.status(404).json({ error: "Plugin not found" });
1976
+ return;
1977
+ }
1978
+ const body = req.body;
1979
+ if (typeof body?.path !== "string" || body.path.trim().length === 0) {
1980
+ res.status(400).json({ error: '"path" is required and must be a non-empty string' });
1981
+ return;
1982
+ }
1983
+ const declaration = requireLocalFolderDeclaration(plugin.manifestJson.localFolders ?? [], folderKey);
1984
+ const status = await inspectPluginLocalFolder({
1985
+ folderKey,
1986
+ declaration,
1987
+ overrideConfig: {
1988
+ path: body.path,
1989
+ },
1990
+ });
1991
+ res.json(status);
1992
+ });
1993
+ router.put("/plugins/:pluginId/companies/:companyId/local-folders/:folderKey", async (req, res) => {
1994
+ assertBoardOrgAccess(req);
1995
+ const { pluginId, companyId, folderKey } = req.params;
1996
+ assertCompanyAccess(req, companyId);
1997
+ const plugin = await resolvePlugin(registry, pluginId);
1998
+ if (!plugin) {
1999
+ res.status(404).json({ error: "Plugin not found" });
2000
+ return;
2001
+ }
2002
+ const body = req.body;
2003
+ if (typeof body?.path !== "string" || body.path.trim().length === 0) {
2004
+ res.status(400).json({ error: '"path" is required and must be a non-empty string' });
2005
+ return;
2006
+ }
2007
+ const existing = await registry.getCompanySettings(plugin.id, companyId);
2008
+ const declaration = requireLocalFolderDeclaration(plugin.manifestJson.localFolders ?? [], folderKey);
2009
+ const status = await inspectPluginLocalFolder({
2010
+ folderKey,
2011
+ declaration,
2012
+ storedConfig: getStoredLocalFolders(existing?.settingsJson)[folderKey] ?? null,
2013
+ overrideConfig: {
2014
+ path: body.path,
2015
+ },
2016
+ });
2017
+ const nextSettings = setStoredLocalFolder(existing?.settingsJson, folderKey, {
2018
+ path: body.path,
2019
+ access: status.access,
2020
+ requiredDirectories: status.requiredDirectories,
2021
+ requiredFiles: status.requiredFiles,
2022
+ });
2023
+ await registry.upsertCompanySettings(plugin.id, companyId, {
2024
+ enabled: existing?.enabled ?? true,
2025
+ settingsJson: nextSettings,
2026
+ lastError: status.healthy ? null : status.problems.map((item) => item.message).join("; "),
2027
+ });
2028
+ await logPluginMutationActivity(req, "plugin.local_folder.configured", plugin.id, {
2029
+ pluginId: plugin.id,
2030
+ pluginKey: plugin.pluginKey,
2031
+ companyId,
2032
+ folderKey,
2033
+ healthy: status.healthy,
2034
+ });
2035
+ res.json(status);
2036
+ });
2037
+ // ===========================================================================
2038
+ // Plugin health dashboard — aggregated diagnostics for the settings page
2039
+ // ===========================================================================
2040
+ /**
2041
+ * GET /api/plugins/:pluginId/dashboard
2042
+ *
2043
+ * Aggregated health dashboard data for a plugin's settings page.
2044
+ *
2045
+ * Returns worker diagnostics (status, uptime, crash history), recent job
2046
+ * runs, recent webhook deliveries, and the current health check result —
2047
+ * all in a single response to avoid multiple round-trips.
2048
+ *
2049
+ * Response: PluginDashboardData
2050
+ * Errors: 404 if plugin not found
2051
+ */
2052
+ router.get("/plugins/:pluginId/dashboard", async (req, res) => {
2053
+ assertBoardOrgAccess(req);
2054
+ const { pluginId } = req.params;
2055
+ const plugin = await resolvePlugin(registry, pluginId);
2056
+ if (!plugin) {
2057
+ res.status(404).json({ error: "Plugin not found" });
2058
+ return;
2059
+ }
2060
+ // --- Worker diagnostics ---
2061
+ let worker = null;
2062
+ // Try bridgeDeps first (primary source for worker manager), fallback to webhookDeps
2063
+ const wm = bridgeDeps?.workerManager ?? webhookDeps?.workerManager ?? null;
2064
+ if (wm) {
2065
+ const handle = wm.getWorker(plugin.id);
2066
+ if (handle) {
2067
+ const diag = handle.diagnostics();
2068
+ worker = {
2069
+ status: diag.status,
2070
+ pid: diag.pid,
2071
+ uptime: diag.uptime,
2072
+ consecutiveCrashes: diag.consecutiveCrashes,
2073
+ totalCrashes: diag.totalCrashes,
2074
+ pendingRequests: diag.pendingRequests,
2075
+ lastCrashAt: diag.lastCrashAt,
2076
+ nextRestartAt: diag.nextRestartAt,
2077
+ };
2078
+ }
2079
+ }
2080
+ // --- Recent job runs (last 10, newest first) ---
2081
+ let recentJobRuns = [];
2082
+ if (jobDeps) {
2083
+ try {
2084
+ const runs = await jobDeps.jobStore.listRunsByPlugin(plugin.id, undefined, 10);
2085
+ // Also fetch job definitions so we can include jobKey
2086
+ const jobs = await jobDeps.jobStore.listJobs(plugin.id);
2087
+ const jobKeyMap = new Map(jobs.map((j) => [j.id, j.jobKey]));
2088
+ recentJobRuns = runs
2089
+ .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
2090
+ .map((r) => ({
2091
+ id: r.id,
2092
+ jobId: r.jobId,
2093
+ jobKey: jobKeyMap.get(r.jobId) ?? undefined,
2094
+ trigger: r.trigger,
2095
+ status: r.status,
2096
+ durationMs: r.durationMs,
2097
+ error: r.error,
2098
+ startedAt: r.startedAt ? new Date(r.startedAt).toISOString() : null,
2099
+ finishedAt: r.finishedAt ? new Date(r.finishedAt).toISOString() : null,
2100
+ createdAt: new Date(r.createdAt).toISOString(),
2101
+ }));
2102
+ }
2103
+ catch {
2104
+ // Job data unavailable — leave empty
2105
+ }
2106
+ }
2107
+ // --- Recent webhook deliveries (last 10, newest first) ---
2108
+ let recentWebhookDeliveries = [];
2109
+ try {
2110
+ const deliveries = await db
2111
+ .select({
2112
+ id: pluginWebhookDeliveries.id,
2113
+ webhookKey: pluginWebhookDeliveries.webhookKey,
2114
+ status: pluginWebhookDeliveries.status,
2115
+ durationMs: pluginWebhookDeliveries.durationMs,
2116
+ error: pluginWebhookDeliveries.error,
2117
+ startedAt: pluginWebhookDeliveries.startedAt,
2118
+ finishedAt: pluginWebhookDeliveries.finishedAt,
2119
+ createdAt: pluginWebhookDeliveries.createdAt,
2120
+ })
2121
+ .from(pluginWebhookDeliveries)
2122
+ .where(eq(pluginWebhookDeliveries.pluginId, plugin.id))
2123
+ .orderBy(desc(pluginWebhookDeliveries.createdAt))
2124
+ .limit(10);
2125
+ recentWebhookDeliveries = deliveries.map((d) => ({
2126
+ id: d.id,
2127
+ webhookKey: d.webhookKey,
2128
+ status: d.status,
2129
+ durationMs: d.durationMs,
2130
+ error: d.error,
2131
+ startedAt: d.startedAt ? d.startedAt.toISOString() : null,
2132
+ finishedAt: d.finishedAt ? d.finishedAt.toISOString() : null,
2133
+ createdAt: d.createdAt.toISOString(),
2134
+ }));
2135
+ }
2136
+ catch {
2137
+ // Webhook data unavailable — leave empty
2138
+ }
2139
+ // --- Health check (same logic as GET /health) ---
2140
+ const checks = [];
2141
+ checks.push({
2142
+ name: "registry",
2143
+ passed: true,
2144
+ message: "Plugin found in registry",
2145
+ });
2146
+ const hasValidManifest = Boolean(plugin.manifestJson?.id);
2147
+ checks.push({
2148
+ name: "manifest",
2149
+ passed: hasValidManifest,
2150
+ message: hasValidManifest ? "Manifest is valid" : "Manifest is invalid or missing",
2151
+ });
2152
+ const isHealthy = plugin.status === "ready";
2153
+ checks.push({
2154
+ name: "status",
2155
+ passed: isHealthy,
2156
+ message: `Current status: ${plugin.status}`,
2157
+ });
2158
+ const hasNoError = !plugin.lastError;
2159
+ if (!hasNoError) {
2160
+ checks.push({
2161
+ name: "error_state",
2162
+ passed: false,
2163
+ message: plugin.lastError ?? undefined,
2164
+ });
2165
+ }
2166
+ const health = {
2167
+ pluginId: plugin.id,
2168
+ status: plugin.status,
2169
+ healthy: isHealthy && hasValidManifest && hasNoError,
2170
+ checks,
2171
+ lastError: plugin.lastError ?? undefined,
2172
+ };
2173
+ res.json({
2174
+ pluginId: plugin.id,
2175
+ worker,
2176
+ recentJobRuns,
2177
+ recentWebhookDeliveries,
2178
+ health,
2179
+ checkedAt: new Date().toISOString(),
2180
+ });
2181
+ });
2182
+ return router;
2183
+ }
2184
+ //# sourceMappingURL=plugins.js.map