@mastra/factory 0.28.0 → 0.29.0-alpha.1

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 (407) hide show
  1. package/README.md +26 -8
  2. package/dist/board-changes.d.ts +16 -0
  3. package/dist/board-changes.d.ts.map +1 -0
  4. package/dist/board-changes.js +40 -0
  5. package/dist/board-changes.js.map +1 -0
  6. package/dist/boards/index.js +2 -1
  7. package/dist/boards/reroute.d.ts +31 -0
  8. package/dist/boards/reroute.d.ts.map +1 -0
  9. package/dist/boards/reroute.js +71 -0
  10. package/dist/boards/reroute.js.map +1 -0
  11. package/dist/boards/semantics.d.ts +1 -3
  12. package/dist/boards/semantics.d.ts.map +1 -1
  13. package/dist/boards/semantics.js +1 -5
  14. package/dist/boards/semantics.js.map +1 -1
  15. package/dist/environment/repository-access.d.ts +2 -0
  16. package/dist/environment/repository-access.d.ts.map +1 -1
  17. package/dist/environment/repository-access.js +9 -4
  18. package/dist/environment/repository-access.js.map +1 -1
  19. package/dist/factory.d.ts +4 -0
  20. package/dist/factory.d.ts.map +1 -1
  21. package/dist/factory.js +60 -9
  22. package/dist/factory.js.map +1 -1
  23. package/dist/integrations/base.d.ts +17 -0
  24. package/dist/integrations/base.d.ts.map +1 -1
  25. package/dist/integrations/dependabot/default-rules.d.ts +38 -0
  26. package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
  27. package/dist/integrations/dependabot/default-rules.js +63 -0
  28. package/dist/integrations/dependabot/default-rules.js.map +1 -0
  29. package/dist/integrations/dependabot/rules.d.ts +42 -0
  30. package/dist/integrations/dependabot/rules.d.ts.map +1 -0
  31. package/dist/integrations/dependabot/rules.js +187 -0
  32. package/dist/integrations/dependabot/rules.js.map +1 -0
  33. package/dist/integrations/dependabot/sync.d.ts +76 -0
  34. package/dist/integrations/dependabot/sync.d.ts.map +1 -0
  35. package/dist/integrations/dependabot/sync.js +111 -0
  36. package/dist/integrations/dependabot/sync.js.map +1 -0
  37. package/dist/integrations/github/pull-request-source.js +2 -1
  38. package/dist/integrations/github/pull-request-source.js.map +1 -1
  39. package/dist/integrations/github/reconcile-worker.js +1 -1
  40. package/dist/integrations/github/reconcile-worker.js.map +1 -1
  41. package/dist/integrations/github/routes.d.ts.map +1 -1
  42. package/dist/integrations/github/routes.js +7 -2
  43. package/dist/integrations/github/routes.js.map +1 -1
  44. package/dist/integrations/github/rules.d.ts +5 -2
  45. package/dist/integrations/github/rules.d.ts.map +1 -1
  46. package/dist/integrations/github/rules.js +16 -13
  47. package/dist/integrations/github/rules.js.map +1 -1
  48. package/dist/integrations/github/sandbox.d.ts +12 -0
  49. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  50. package/dist/integrations/github/sandbox.js +24 -3
  51. package/dist/integrations/github/sandbox.js.map +1 -1
  52. package/dist/integrations/gitlab/default-rules.js +2 -1
  53. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  54. package/dist/integrations/gitlab/discovery.d.ts +16 -0
  55. package/dist/integrations/gitlab/discovery.d.ts.map +1 -0
  56. package/dist/integrations/gitlab/discovery.js +107 -0
  57. package/dist/integrations/gitlab/discovery.js.map +1 -0
  58. package/dist/integrations/gitlab/integration.d.ts.map +1 -1
  59. package/dist/integrations/gitlab/integration.js +1 -2
  60. package/dist/integrations/gitlab/integration.js.map +1 -1
  61. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
  62. package/dist/integrations/gitlab/issue-reconciler.js +1 -0
  63. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
  64. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
  65. package/dist/integrations/gitlab/merge-request-reconciler.js +26 -10
  66. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
  67. package/dist/integrations/gitlab/reconciler.d.ts.map +1 -1
  68. package/dist/integrations/gitlab/reconciler.js +4 -2
  69. package/dist/integrations/gitlab/reconciler.js.map +1 -1
  70. package/dist/integrations/gitlab/reconciliation-config.d.ts +0 -1
  71. package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -1
  72. package/dist/integrations/gitlab/reconciliation-config.js +2 -8
  73. package/dist/integrations/gitlab/reconciliation-config.js.map +1 -1
  74. package/dist/integrations/gitlab/routes.d.ts +17 -0
  75. package/dist/integrations/gitlab/routes.d.ts.map +1 -1
  76. package/dist/integrations/gitlab/routes.js +28 -22
  77. package/dist/integrations/gitlab/routes.js.map +1 -1
  78. package/dist/integrations/gitlab/rules.d.ts +10 -4
  79. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  80. package/dist/integrations/gitlab/rules.js +32 -8
  81. package/dist/integrations/gitlab/rules.js.map +1 -1
  82. package/dist/integrations/incidentio/integration.d.ts +2 -1
  83. package/dist/integrations/incidentio/integration.d.ts.map +1 -1
  84. package/dist/integrations/incidentio/integration.js +7 -7
  85. package/dist/integrations/incidentio/integration.js.map +1 -1
  86. package/dist/integrations/incidentio/issue-reconciler.d.ts +7 -0
  87. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
  88. package/dist/integrations/incidentio/issue-reconciler.js +36 -1
  89. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
  90. package/dist/integrations/incidentio/reconciliation-config.d.ts +0 -1
  91. package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -1
  92. package/dist/integrations/incidentio/reconciliation-config.js +2 -5
  93. package/dist/integrations/incidentio/reconciliation-config.js.map +1 -1
  94. package/dist/integrations/incidentio/routes.d.ts +24 -8
  95. package/dist/integrations/incidentio/routes.d.ts.map +1 -1
  96. package/dist/integrations/incidentio/routes.js +33 -35
  97. package/dist/integrations/incidentio/routes.js.map +1 -1
  98. package/dist/integrations/incidentio/rules.d.ts +0 -4
  99. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  100. package/dist/integrations/incidentio/rules.js +17 -14
  101. package/dist/integrations/incidentio/rules.js.map +1 -1
  102. package/dist/integrations/intake-discovery.d.ts +44 -0
  103. package/dist/integrations/intake-discovery.d.ts.map +1 -0
  104. package/dist/integrations/intake-discovery.js +60 -0
  105. package/dist/integrations/intake-discovery.js.map +1 -0
  106. package/dist/integrations/issue-reconcile-worker.js +1 -1
  107. package/dist/integrations/issue-reconcile-worker.js.map +1 -1
  108. package/dist/integrations/issue-reconciler.d.ts +7 -0
  109. package/dist/integrations/issue-reconciler.d.ts.map +1 -1
  110. package/dist/integrations/issue-reconciler.js +47 -12
  111. package/dist/integrations/issue-reconciler.js.map +1 -1
  112. package/dist/integrations/jira/integration.d.ts +3 -2
  113. package/dist/integrations/jira/integration.d.ts.map +1 -1
  114. package/dist/integrations/jira/integration.js +5 -7
  115. package/dist/integrations/jira/integration.js.map +1 -1
  116. package/dist/integrations/jira/issue-reconciler.d.ts +17 -1
  117. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
  118. package/dist/integrations/jira/issue-reconciler.js +34 -1
  119. package/dist/integrations/jira/issue-reconciler.js.map +1 -1
  120. package/dist/integrations/jira/reconciliation-config.d.ts +0 -1
  121. package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -1
  122. package/dist/integrations/jira/reconciliation-config.js +2 -5
  123. package/dist/integrations/jira/reconciliation-config.js.map +1 -1
  124. package/dist/integrations/jira/routes.d.ts +0 -7
  125. package/dist/integrations/jira/routes.d.ts.map +1 -1
  126. package/dist/integrations/jira/routes.js +2 -12
  127. package/dist/integrations/jira/routes.js.map +1 -1
  128. package/dist/integrations/jira/rules.d.ts +0 -4
  129. package/dist/integrations/jira/rules.d.ts.map +1 -1
  130. package/dist/integrations/jira/rules.js +3 -13
  131. package/dist/integrations/jira/rules.js.map +1 -1
  132. package/dist/integrations/kept-cards.d.ts +49 -0
  133. package/dist/integrations/kept-cards.d.ts.map +1 -0
  134. package/dist/integrations/kept-cards.js +97 -0
  135. package/dist/integrations/kept-cards.js.map +1 -0
  136. package/dist/integrations/linear/intake-discovery.d.ts +34 -0
  137. package/dist/integrations/linear/intake-discovery.d.ts.map +1 -0
  138. package/dist/integrations/linear/intake-discovery.js +112 -0
  139. package/dist/integrations/linear/intake-discovery.js.map +1 -0
  140. package/dist/integrations/linear/integration.d.ts.map +1 -1
  141. package/dist/integrations/linear/integration.js +1 -4
  142. package/dist/integrations/linear/integration.js.map +1 -1
  143. package/dist/integrations/linear/issue-reconciler.d.ts +13 -4
  144. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  145. package/dist/integrations/linear/issue-reconciler.js +24 -20
  146. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  147. package/dist/integrations/linear/reconciliation-config.d.ts +0 -1
  148. package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -1
  149. package/dist/integrations/linear/reconciliation-config.js +2 -8
  150. package/dist/integrations/linear/reconciliation-config.js.map +1 -1
  151. package/dist/integrations/linear/routes.d.ts +0 -2
  152. package/dist/integrations/linear/routes.d.ts.map +1 -1
  153. package/dist/integrations/linear/routes.js +3 -9
  154. package/dist/integrations/linear/routes.js.map +1 -1
  155. package/dist/integrations/platform/api-client.d.ts +2 -0
  156. package/dist/integrations/platform/api-client.d.ts.map +1 -1
  157. package/dist/integrations/platform/api-client.js +6 -1
  158. package/dist/integrations/platform/api-client.js.map +1 -1
  159. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  160. package/dist/integrations/platform/connect/routes.js +8 -1
  161. package/dist/integrations/platform/connect/routes.js.map +1 -1
  162. package/dist/integrations/platform/github/event-worker.d.ts +17 -0
  163. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  164. package/dist/integrations/platform/github/event-worker.js +89 -7
  165. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  166. package/dist/integrations/platform/github/integration.d.ts +20 -1
  167. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  168. package/dist/integrations/platform/github/integration.js +54 -3
  169. package/dist/integrations/platform/github/integration.js.map +1 -1
  170. package/dist/integrations/platform/gitlab/event-worker.js +1 -1
  171. package/dist/integrations/platform/gitlab/event-worker.js.map +1 -1
  172. package/dist/integrations/platform/incidentio/integration.d.ts +3 -2
  173. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
  174. package/dist/integrations/platform/incidentio/integration.js +7 -7
  175. package/dist/integrations/platform/incidentio/integration.js.map +1 -1
  176. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  177. package/dist/integrations/platform/jira/integration.js +4 -7
  178. package/dist/integrations/platform/jira/integration.js.map +1 -1
  179. package/dist/integrations/platform/jira/routes.d.ts +0 -7
  180. package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
  181. package/dist/integrations/platform/jira/routes.js +2 -12
  182. package/dist/integrations/platform/jira/routes.js.map +1 -1
  183. package/dist/integrations/platform/linear/event-worker.d.ts +2 -2
  184. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
  185. package/dist/integrations/platform/linear/event-worker.js +1 -1
  186. package/dist/integrations/platform/linear/event-worker.js.map +1 -1
  187. package/dist/integrations/platform/linear/integration.d.ts +1 -0
  188. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  189. package/dist/integrations/platform/linear/integration.js +7 -7
  190. package/dist/integrations/platform/linear/integration.js.map +1 -1
  191. package/dist/integrations/platform/vanta/integration.d.ts +38 -0
  192. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
  193. package/dist/integrations/platform/vanta/integration.js +149 -0
  194. package/dist/integrations/platform/vanta/integration.js.map +1 -0
  195. package/dist/integrations/reconciliation-config.d.ts +0 -1
  196. package/dist/integrations/reconciliation-config.d.ts.map +1 -1
  197. package/dist/integrations/reconciliation-config.js +1 -8
  198. package/dist/integrations/reconciliation-config.js.map +1 -1
  199. package/dist/integrations/slack/channel-reply-processor.js +1 -1
  200. package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
  201. package/dist/integrations/startup-summary.d.ts +8 -0
  202. package/dist/integrations/startup-summary.d.ts.map +1 -0
  203. package/dist/integrations/startup-summary.js +36 -0
  204. package/dist/integrations/startup-summary.js.map +1 -0
  205. package/dist/integrations/vanta/default-rules.d.ts +34 -0
  206. package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
  207. package/dist/integrations/vanta/default-rules.js +61 -0
  208. package/dist/integrations/vanta/default-rules.js.map +1 -0
  209. package/dist/integrations/vanta/rules.d.ts +40 -0
  210. package/dist/integrations/vanta/rules.d.ts.map +1 -0
  211. package/dist/integrations/vanta/rules.js +208 -0
  212. package/dist/integrations/vanta/rules.js.map +1 -0
  213. package/dist/integrations/vanta/sync.d.ts +40 -0
  214. package/dist/integrations/vanta/sync.d.ts.map +1 -0
  215. package/dist/integrations/vanta/sync.js +81 -0
  216. package/dist/integrations/vanta/sync.js.map +1 -0
  217. package/dist/linked-repositories-changed.d.ts +14 -0
  218. package/dist/linked-repositories-changed.d.ts.map +1 -0
  219. package/dist/linked-repositories-changed.js +48 -0
  220. package/dist/linked-repositories-changed.js.map +1 -0
  221. package/dist/mcp/routes.d.ts.map +1 -1
  222. package/dist/mcp/routes.js +1 -1
  223. package/dist/mcp/routes.js.map +1 -1
  224. package/dist/routes/board-snapshot.d.ts +8 -1
  225. package/dist/routes/board-snapshot.d.ts.map +1 -1
  226. package/dist/routes/board-snapshot.js +23 -2
  227. package/dist/routes/board-snapshot.js.map +1 -1
  228. package/dist/routes/contracts.d.ts +322 -0
  229. package/dist/routes/contracts.d.ts.map +1 -1
  230. package/dist/routes/contracts.js +202 -5
  231. package/dist/routes/contracts.js.map +1 -1
  232. package/dist/routes/intake-routes.d.ts +3 -0
  233. package/dist/routes/intake-routes.d.ts.map +1 -1
  234. package/dist/routes/intake-routes.js +44 -0
  235. package/dist/routes/intake-routes.js.map +1 -1
  236. package/dist/routes/knowledge.d.ts.map +1 -1
  237. package/dist/routes/knowledge.js +3 -2
  238. package/dist/routes/knowledge.js.map +1 -1
  239. package/dist/routes/run-queue.d.ts +17 -0
  240. package/dist/routes/run-queue.d.ts.map +1 -0
  241. package/dist/routes/run-queue.js +69 -0
  242. package/dist/routes/run-queue.js.map +1 -0
  243. package/dist/routes/source-control-sessions.d.ts +1 -1
  244. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  245. package/dist/routes/source-control-sessions.js +109 -3
  246. package/dist/routes/source-control-sessions.js.map +1 -1
  247. package/dist/routes/surface.d.ts +14 -1
  248. package/dist/routes/surface.d.ts.map +1 -1
  249. package/dist/routes/surface.js +76 -11
  250. package/dist/routes/surface.js.map +1 -1
  251. package/dist/routes/work-item-selection.d.ts +4 -5
  252. package/dist/routes/work-item-selection.d.ts.map +1 -1
  253. package/dist/routes/work-item-selection.js +11 -23
  254. package/dist/routes/work-item-selection.js.map +1 -1
  255. package/dist/routes/work-item-starters.d.ts.map +1 -1
  256. package/dist/routes/work-item-starters.js +4 -21
  257. package/dist/routes/work-item-starters.js.map +1 -1
  258. package/dist/routes/work-items.d.ts +5 -0
  259. package/dist/routes/work-items.d.ts.map +1 -1
  260. package/dist/routes/work-items.js +129 -36
  261. package/dist/routes/work-items.js.map +1 -1
  262. package/dist/rules/dispatch-errors.d.ts +3 -0
  263. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  264. package/dist/rules/dispatch-errors.js +5 -0
  265. package/dist/rules/dispatch-errors.js.map +1 -1
  266. package/dist/rules/dispatcher.d.ts +15 -1
  267. package/dist/rules/dispatcher.d.ts.map +1 -1
  268. package/dist/rules/dispatcher.js +48 -20
  269. package/dist/rules/dispatcher.js.map +1 -1
  270. package/dist/rules/index.d.ts +2 -2
  271. package/dist/rules/index.d.ts.map +1 -1
  272. package/dist/rules/index.js +2 -2
  273. package/dist/rules/review-source-tool.js +2 -1
  274. package/dist/rules/review-source-tool.js.map +1 -1
  275. package/dist/rules/start-coordinator.d.ts +6 -1
  276. package/dist/rules/start-coordinator.d.ts.map +1 -1
  277. package/dist/rules/start-coordinator.js +6 -2
  278. package/dist/rules/start-coordinator.js.map +1 -1
  279. package/dist/rules/transition-service.d.ts.map +1 -1
  280. package/dist/rules/transition-service.js +3 -2
  281. package/dist/rules/transition-service.js.map +1 -1
  282. package/dist/rules/types.d.ts +71 -3
  283. package/dist/rules/types.d.ts.map +1 -1
  284. package/dist/rules/types.js +10 -2
  285. package/dist/rules/types.js.map +1 -1
  286. package/dist/rules/validation.d.ts.map +1 -1
  287. package/dist/rules/validation.js +5 -0
  288. package/dist/rules/validation.js.map +1 -1
  289. package/dist/session/factory-session.d.ts +20 -5
  290. package/dist/session/factory-session.d.ts.map +1 -1
  291. package/dist/session/factory-session.js +20 -6
  292. package/dist/session/factory-session.js.map +1 -1
  293. package/dist/storage/domains/audit/actions.d.ts +1 -1
  294. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  295. package/dist/storage/domains/audit/actions.js +2 -1
  296. package/dist/storage/domains/audit/actions.js.map +1 -1
  297. package/dist/storage/domains/audit/actors.d.ts.map +1 -1
  298. package/dist/storage/domains/audit/actors.js +1 -1
  299. package/dist/storage/domains/audit/actors.js.map +1 -1
  300. package/dist/storage/domains/intake/base.d.ts +1 -1
  301. package/dist/storage/domains/intake/base.js +2 -2
  302. package/dist/storage/domains/intake/base.js.map +1 -1
  303. package/dist/storage/domains/projects/base.d.ts +10 -0
  304. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  305. package/dist/storage/domains/projects/base.js +24 -2
  306. package/dist/storage/domains/projects/base.js.map +1 -1
  307. package/dist/storage/domains/source-control/base.d.ts +32 -0
  308. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  309. package/dist/storage/domains/source-control/base.js +54 -4
  310. package/dist/storage/domains/source-control/base.js.map +1 -1
  311. package/dist/storage/domains/source-control/inmemory.d.ts +3 -0
  312. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  313. package/dist/storage/domains/source-control/inmemory.js +17 -0
  314. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  315. package/dist/storage/domains/work-items/base.d.ts +16 -4
  316. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  317. package/dist/storage/domains/work-items/base.js +28 -1
  318. package/dist/storage/domains/work-items/base.js.map +1 -1
  319. package/dist/timing.d.ts +8 -1
  320. package/dist/timing.d.ts.map +1 -1
  321. package/dist/timing.js +10 -2
  322. package/dist/timing.js.map +1 -1
  323. package/dist/tools/approval-tools.d.ts +20 -0
  324. package/dist/tools/approval-tools.d.ts.map +1 -1
  325. package/dist/tools/approval-tools.js +79 -30
  326. package/dist/tools/approval-tools.js.map +1 -1
  327. package/dist/tools/audit-events-tool.d.ts +1 -1
  328. package/dist/tools/messaging-tools.d.ts.map +1 -1
  329. package/dist/tools/messaging-tools.js +1 -1
  330. package/dist/tools/messaging-tools.js.map +1 -1
  331. package/dist/tools/read-tools.d.ts +0 -2
  332. package/dist/tools/read-tools.d.ts.map +1 -1
  333. package/dist/tools/read-tools.js +2 -7
  334. package/dist/tools/read-tools.js.map +1 -1
  335. package/dist/tools/reports.d.ts +3 -0
  336. package/dist/tools/reports.d.ts.map +1 -1
  337. package/dist/tools/reports.js +3 -3
  338. package/dist/tools/reports.js.map +1 -1
  339. package/dist/tools/run-watch.d.ts +14 -2
  340. package/dist/tools/run-watch.d.ts.map +1 -1
  341. package/dist/tools/run-watch.js +24 -4
  342. package/dist/tools/run-watch.js.map +1 -1
  343. package/dist/tools/session-tools.d.ts.map +1 -1
  344. package/dist/tools/session-tools.js +17 -6
  345. package/dist/tools/session-tools.js.map +1 -1
  346. package/dist/tools/side-sessions.d.ts.map +1 -1
  347. package/dist/tools/side-sessions.js +1 -1
  348. package/dist/tools/side-sessions.js.map +1 -1
  349. package/dist/tools/work-item-tools.d.ts.map +1 -1
  350. package/dist/tools/work-item-tools.js +12 -2
  351. package/dist/tools/work-item-tools.js.map +1 -1
  352. package/dist/work-item-branch.d.ts +1 -1
  353. package/dist/work-item-branch.d.ts.map +1 -1
  354. package/dist/work-item-branch.js +2 -0
  355. package/dist/work-item-branch.js.map +1 -1
  356. package/dist/work-items/board-filter-options.d.ts +5 -0
  357. package/dist/work-items/board-filter-options.d.ts.map +1 -0
  358. package/dist/work-items/board-filter-options.js +27 -0
  359. package/dist/work-items/board-filter-options.js.map +1 -0
  360. package/dist/work-items/board-phases.d.ts +28 -0
  361. package/dist/work-items/board-phases.d.ts.map +1 -0
  362. package/dist/work-items/board-phases.js +165 -0
  363. package/dist/work-items/board-phases.js.map +1 -0
  364. package/dist/work-items/card-facts.d.ts +24 -0
  365. package/dist/work-items/card-facts.d.ts.map +1 -0
  366. package/dist/work-items/card-facts.js +75 -0
  367. package/dist/work-items/card-facts.js.map +1 -0
  368. package/dist/work-items/card-labels.d.ts +5 -0
  369. package/dist/work-items/card-labels.d.ts.map +1 -0
  370. package/dist/work-items/card-labels.js +13 -0
  371. package/dist/work-items/card-labels.js.map +1 -0
  372. package/dist/work-items/card-number.d.ts +10 -0
  373. package/dist/work-items/card-number.d.ts.map +1 -0
  374. package/dist/work-items/card-number.js +15 -0
  375. package/dist/work-items/card-number.js.map +1 -0
  376. package/dist/work-items/card-people.d.ts +25 -0
  377. package/dist/work-items/card-people.d.ts.map +1 -0
  378. package/dist/work-items/card-people.js +100 -0
  379. package/dist/work-items/card-people.js.map +1 -0
  380. package/dist/work-items/card-search-text.d.ts +4 -0
  381. package/dist/work-items/card-search-text.d.ts.map +1 -0
  382. package/dist/work-items/card-search-text.js +15 -0
  383. package/dist/work-items/card-search-text.js.map +1 -0
  384. package/dist/work-items/card-source-filters.d.ts +23 -0
  385. package/dist/work-items/card-source-filters.d.ts.map +1 -0
  386. package/dist/work-items/card-source-filters.js +25 -0
  387. package/dist/work-items/card-source-filters.js.map +1 -0
  388. package/dist/work-items/create-work-item.d.ts +0 -6
  389. package/dist/work-items/create-work-item.d.ts.map +1 -1
  390. package/dist/work-items/create-work-item.js +2 -7
  391. package/dist/work-items/create-work-item.js.map +1 -1
  392. package/dist/work-items/list-related-cards.d.ts +4 -0
  393. package/dist/work-items/list-related-cards.d.ts.map +1 -0
  394. package/dist/work-items/list-related-cards.js +24 -0
  395. package/dist/work-items/list-related-cards.js.map +1 -0
  396. package/dist/work-items/search-words.d.ts +5 -0
  397. package/dist/work-items/search-words.d.ts.map +1 -0
  398. package/dist/work-items/search-words.js +12 -0
  399. package/dist/work-items/search-words.js.map +1 -0
  400. package/dist/work-items/source-external-id.d.ts +4 -0
  401. package/dist/work-items/source-external-id.d.ts.map +1 -0
  402. package/dist/work-items/source-external-id.js +9 -0
  403. package/dist/work-items/source-external-id.js.map +1 -0
  404. package/dist/workspace.d.ts.map +1 -1
  405. package/dist/workspace.js +92 -47
  406. package/dist/workspace.js.map +1 -1
  407. package/package.json +9 -8
@@ -1 +1 @@
1
- {"version":3,"file":"channel-reply-processor.js","names":[],"sources":["../../../src/integrations/slack/channel-reply-processor.ts"],"sourcesContent":["import type { ProcessInputStepArgs, Processor } from '@mastra/core/processors';\nimport { factorySettingsUrl, factoryUiOrigin } from '../../links.js';\n\n/** Mirrors `REPLY_TOOL_NAME` in `reply-tool.ts`, which imports this module. */\nconst REPLY_TOOL = 'reply_in_thread';\n\nconst ID = 'factory-channel-reply';\n\nexport const SESSION_LINK_LABEL = 'Open session ↗';\n\n/**\n * Chat surfaces show what the agent writes as-is, so a bare `#28467`,\n * `FACT-526` or `52db47cd` is a dead end for the reader. Every channel run\n * gets this, whether it speaks in reply text or through the reply tool.\n */\nconst LINK_REFERENCES = [\n 'Write every pull request, issue, commit, Linear ticket or other reference you mention in the thread as a markdown link to its page, with the ID as plain link text: [#28467](https://github.com/<owner>/<repo>/pull/28467), [52db47cd](https://github.com/<owner>/<repo>/commit/52db47cd), [FACT-526](<the ticket URL>). Never leave one as a bare ID or wrap it in code formatting.',\n \"Build GitHub and GitLab links from the repository the reference belongs to, from the repositories listed in your environment or a tool result; with more than one repository, don't assume which one a bare number belongs to. Build Linear links from the workspace URL pattern in the `linear_get_issue` tool description, or from a URL a tool returned. Don't guess a URL; leave a reference unlinked only when you can't work out its URL.\",\n 'Link Factory work items and sessions the same way, with the `url` the Factory tools return: [#123](<item url>). When something needs a person, ask them for it here and link the item; only send them to the web UI when the channel cannot do it, and then link the exact page.',\n].join('\\n');\n\n/**\n * Tells the agent how to open a reply when the run came in over a chat\n * channel (Slack, …): acknowledge a job in one line that names it — \"On it —\n * sleeping 30s, then running the echo\" — before starting, so the sender sees\n * a task-specific first message rather than a silent typing status until the\n * first tool finishes. The channel driver posts that opener on its own before\n * the tool widget, so the instruction and the rendering agree. The session\n * link is not the model's job: `FactoryChannelSessionLinkProcessor` appends it\n * to the first reply of a new session, so it is there whether or not the\n * model judged the request worth an opener. A run on a Slack-linked session\n * that didn't start from Slack gets a shorter note on when to post there; runs\n * with no channel at all (Studio, API, boards) get nothing.\n */\nexport class FactoryChannelReplyProcessor implements Processor {\n readonly id = ID;\n\n processInputStep({ messageList, requestContext, tools }: ProcessInputStepArgs) {\n if (!requestContext?.get('channel')) {\n // A run on a Slack-linked session that didn't start from a Slack message\n // (a web prompt, a woken run) still has the reply tool; core's channel\n // prompt says the thread is linked, this says how to use it.\n if (!tools || !(REPLY_TOOL in tools)) return undefined;\n messageList.addSystem(\n {\n role: 'system',\n content: `Post to that thread with \\`${REPLY_TOOL}\\`. This request came from outside it, so don't post an opener or progress there; post the outcome when the people in the thread asked for this work or are waiting on it, or when you're asked to. Don't write a note about what you posted. When you open a pull request, its link is posted to this thread for you, and again when it merges, so don't post the link yourself.\\n${LINK_REFERENCES}`,\n },\n ID,\n );\n return { messageList };\n }\n // With reply text hidden the thread only sees what the reply tool posts,\n // so the opener advice becomes advice about when to call it.\n const content =\n tools && REPLY_TOOL in tools\n ? [\n `Only messages you send with \\`${REPLY_TOOL}\\` reach this thread; your other text stays in the session. Don't write a note about what you posted. After a reply, either keep working or end your turn with an empty message; any text you write after posting is wasted.`,\n `When a request will take tools or more than a moment, post one short line first that says what you are about to do, then do the work and post the outcome when you finish — not a replay of the steps.`,\n `Post again in between only when you need an answer or have news the people in the thread would want. When a message needs nothing from you, don't call it.`,\n `When you open a pull request, its link is posted to this thread for you, and again when it merges, so don't post the link yourself.`,\n ]\n : [\n 'When a request will take tools or more than a moment to answer, reply first with one short line that says what you are about to do — \"On it — <the task in a few words>.\" — then do the work; the opener posts as its own message before any progress is shown. Give direct answers and trivial replies without an opener.',\n 'Finish with the outcome, not a replay of the steps.',\n ];\n messageList.addSystem({ role: 'system', content: [...content, LINK_REFERENCES].join('\\n') }, ID);\n return { messageList };\n }\n}\n\nexport interface SessionLinkTarget {\n threadId: string;\n sessionId: string;\n resourceId: string;\n factoryProjectId?: string;\n}\n\n/**\n * The web URL for a session, or undefined without a public origin. Same\n * routes the Factory UI navigates to: a repo-backed thread's Factory session\n * id is the workspace segment; chat-only threads keep the literal `channel`\n * segment and name their session in the query; a session with no factory\n * falls back to the factory-agnostic /threads/ redirect, which forwards the\n * query through.\n */\nexport function sessionLink({\n threadId,\n sessionId,\n resourceId,\n factoryProjectId,\n}: SessionLinkTarget): string | undefined {\n const origin = factoryUiOrigin();\n if (!origin) return undefined;\n const isChatOnly = resourceId.startsWith('channel:');\n const sessionParam = `?sessionId=${encodeURIComponent(sessionId)}`;\n if (!factoryProjectId) return `${origin}/threads/${encodeURIComponent(threadId)}${sessionParam}`;\n const workspaceSegment = isChatOnly ? 'channel' : encodeURIComponent(sessionId);\n return `${origin}/factories/${encodeURIComponent(factoryProjectId)}/workspaces/${workspaceSegment}/threads/${encodeURIComponent(threadId)}${isChatOnly ? sessionParam : ''}`;\n}\n\nexport function modelSettingsLink(factoryProjectId: string): string | undefined {\n return factorySettingsUrl(factoryProjectId, 'models');\n}\n\n/** `VOICE_INPUT_ANCHOR` in factory-ui's `settingsSections.ts`; the voice section scrolls itself into view on this hash. */\nexport function voiceSettingsLink(factoryProjectId: string): string | undefined {\n const models = modelSettingsLink(factoryProjectId);\n return models && `${models}#voice-input`;\n}\n"],"mappings":";;;AAIA,MAAM,aAAa;AAEnB,MAAM,KAAK;AAEX,MAAa,qBAAqB;;;;;;AAOlC,MAAM,kBAAkB;CACtB;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;;;;;AAeX,IAAa,+BAAb,MAA+D;CAC7D,KAAc;CAEd,iBAAiB,EAAE,aAAa,gBAAgB,SAA+B;EAC7E,IAAI,CAAC,gBAAgB,IAAI,SAAS,GAAG;GAInC,IAAI,CAAC,SAAS,EAAE,cAAc,QAAQ,OAAO,KAAA;GAC7C,YAAY,UACV;IACE,MAAM;IACN,SAAS,8BAA8B,WAAW,qXAAqX;GACza,GACA,EACF;GACA,OAAO,EAAE,YAAY;EACvB;EAGA,MAAM,UACJ,SAAS,cAAc,QACnB;GACE,iCAAiC,WAAW;GAC5C;GACA;GACA;EACF,IACA,CACE,gUACA,qDACF;EACN,YAAY,UAAU;GAAE,MAAM;GAAU,SAAS,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC,KAAK,IAAI;EAAE,GAAG,EAAE;EAC/F,OAAO,EAAE,YAAY;CACvB;AACF;;;;;;;;;AAiBA,SAAgB,YAAY,EAC1B,UACA,WACA,YACA,oBACwC;CACxC,MAAM,SAAS,gBAAgB;CAC/B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,aAAa,WAAW,WAAW,UAAU;CACnD,MAAM,eAAe,cAAc,mBAAmB,SAAS;CAC/D,IAAI,CAAC,kBAAkB,OAAO,GAAG,OAAO,WAAW,mBAAmB,QAAQ,IAAI;CAElF,OAAO,GAAG,OAAO,aAAa,mBAAmB,gBAAgB,EAAE,cAD1C,aAAa,YAAY,mBAAmB,SAAS,EACoB,WAAW,mBAAmB,QAAQ,IAAI,aAAa,eAAe;AAC1K;AAEA,SAAgB,kBAAkB,kBAA8C;CAC9E,OAAO,mBAAmB,kBAAkB,QAAQ;AACtD;;AAGA,SAAgB,kBAAkB,kBAA8C;CAC9E,MAAM,SAAS,kBAAkB,gBAAgB;CACjD,OAAO,UAAU,GAAG,OAAO;AAC7B"}
1
+ {"version":3,"file":"channel-reply-processor.js","names":[],"sources":["../../../src/integrations/slack/channel-reply-processor.ts"],"sourcesContent":["import type { ProcessInputStepArgs, Processor } from '@mastra/core/processors';\nimport { factorySettingsUrl, factoryUiOrigin } from '../../links.js';\n\n/** Mirrors `REPLY_TOOL_NAME` in `reply-tool.ts`, which imports this module. */\nconst REPLY_TOOL = 'reply_in_thread';\n\nconst ID = 'factory-channel-reply';\n\nexport const SESSION_LINK_LABEL = 'Open session ↗';\n\n/**\n * Chat surfaces show what the agent writes as-is, so a bare `#28467`,\n * `FACT-526` or `52db47cd` is a dead end for the reader. Every channel run\n * gets this, whether it speaks in reply text or through the reply tool.\n */\nconst LINK_REFERENCES = [\n 'Write every pull request, issue, commit, Linear ticket or other reference you mention in the thread as a markdown link to its page, with the ID as plain link text: [#28467](https://github.com/<owner>/<repo>/pull/28467), [52db47cd](https://github.com/<owner>/<repo>/commit/52db47cd), [FACT-526](<the ticket URL>). Never leave one as a bare ID or wrap it in code formatting.',\n \"Build GitHub and GitLab links from the repository the reference belongs to, from the repositories listed in your environment or a tool result; with more than one repository, don't assume which one a bare number belongs to. Build Linear links from the workspace URL pattern in the `linear_get_issue` tool description, or from a URL a tool returned. Don't guess a URL; leave a reference unlinked only when you can't work out its URL.\",\n 'Link Factory work items and sessions the same way, with the `url` the Factory tools return: [#123](<item url>). When something needs a person, ask them for it here and link the item; only send them to the web UI when the channel cannot do it, and then link the exact page.',\n].join('\\n');\n\n/**\n * Tells the agent how to open a reply when the run came in over a chat\n * channel (Slack, …): acknowledge a job in one line that names it — \"On it —\n * sleeping 30s, then running the echo\" — before starting, so the sender sees\n * a task-specific first message rather than a silent typing status until the\n * first tool finishes. The channel driver posts that opener on its own before\n * the tool widget, so the instruction and the rendering agree. The session\n * link is not the model's job: `FactoryChannelSessionLinkProcessor` appends it\n * to the first reply of a new session, so it is there whether or not the\n * model judged the request worth an opener. A run on a Slack-linked session\n * that didn't start from Slack gets a shorter note on when to post there; runs\n * with no channel at all (Studio, API, boards) get nothing.\n */\nexport class FactoryChannelReplyProcessor implements Processor {\n readonly id = ID;\n\n processInputStep({ messageList, requestContext, tools }: ProcessInputStepArgs) {\n if (!requestContext?.get('channel')) {\n // A run on a Slack-linked session that didn't start from a Slack message\n // (a web prompt, a woken run) still has the reply tool; core's channel\n // prompt says the thread is linked, this says how to use it.\n if (!tools || !(REPLY_TOOL in tools)) return undefined;\n messageList.addSystem(\n {\n role: 'system',\n content: `Post to that thread with \\`${REPLY_TOOL}\\`. This request came from outside it, so don't post an opener or progress there; post the outcome when the people in the thread asked for this work or are waiting on it, or when you're asked to. Don't write a note about what you posted. When you open a pull request, its link is posted to this thread for you, and again when it merges, so don't post the link yourself.\\n${LINK_REFERENCES}`,\n },\n ID,\n );\n return { messageList };\n }\n // With reply text hidden the thread only sees what the reply tool posts,\n // so the opener advice becomes advice about when to call it.\n const content =\n tools && REPLY_TOOL in tools\n ? [\n `Only messages you send with \\`${REPLY_TOOL}\\` reach this thread; your other text stays in the session. Don't write a note about what you posted. After a reply, either keep working or end your turn with an empty message; any text you write after posting is wasted.`,\n `When a request will take tools or more than a moment, post one short line first that says what you are about to do, then do the work and post the outcome when you finish — not a replay of the steps.`,\n `Post again in between only when you need an answer or have news the people in the thread would want. When a message that doesn't mention you needs nothing from you, don't call it.`,\n `When you open a pull request, its link is posted to this thread for you, and again when it merges, so don't post the link yourself.`,\n ]\n : [\n 'When a request will take tools or more than a moment to answer, reply first with one short line that says what you are about to do — \"On it — <the task in a few words>.\" — then do the work; the opener posts as its own message before any progress is shown. Give direct answers and trivial replies without an opener.',\n 'Finish with the outcome, not a replay of the steps.',\n ];\n messageList.addSystem({ role: 'system', content: [...content, LINK_REFERENCES].join('\\n') }, ID);\n return { messageList };\n }\n}\n\nexport interface SessionLinkTarget {\n threadId: string;\n sessionId: string;\n resourceId: string;\n factoryProjectId?: string;\n}\n\n/**\n * The web URL for a session, or undefined without a public origin. Same\n * routes the Factory UI navigates to: a repo-backed thread's Factory session\n * id is the workspace segment; chat-only threads keep the literal `channel`\n * segment and name their session in the query; a session with no factory\n * falls back to the factory-agnostic /threads/ redirect, which forwards the\n * query through.\n */\nexport function sessionLink({\n threadId,\n sessionId,\n resourceId,\n factoryProjectId,\n}: SessionLinkTarget): string | undefined {\n const origin = factoryUiOrigin();\n if (!origin) return undefined;\n const isChatOnly = resourceId.startsWith('channel:');\n const sessionParam = `?sessionId=${encodeURIComponent(sessionId)}`;\n if (!factoryProjectId) return `${origin}/threads/${encodeURIComponent(threadId)}${sessionParam}`;\n const workspaceSegment = isChatOnly ? 'channel' : encodeURIComponent(sessionId);\n return `${origin}/factories/${encodeURIComponent(factoryProjectId)}/workspaces/${workspaceSegment}/threads/${encodeURIComponent(threadId)}${isChatOnly ? sessionParam : ''}`;\n}\n\nexport function modelSettingsLink(factoryProjectId: string): string | undefined {\n return factorySettingsUrl(factoryProjectId, 'models');\n}\n\n/** `VOICE_INPUT_ANCHOR` in factory-ui's `settingsSections.ts`; the voice section scrolls itself into view on this hash. */\nexport function voiceSettingsLink(factoryProjectId: string): string | undefined {\n const models = modelSettingsLink(factoryProjectId);\n return models && `${models}#voice-input`;\n}\n"],"mappings":";;;AAIA,MAAM,aAAa;AAEnB,MAAM,KAAK;AAEX,MAAa,qBAAqB;;;;;;AAOlC,MAAM,kBAAkB;CACtB;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;;;;;AAeX,IAAa,+BAAb,MAA+D;CAC7D,KAAc;CAEd,iBAAiB,EAAE,aAAa,gBAAgB,SAA+B;EAC7E,IAAI,CAAC,gBAAgB,IAAI,SAAS,GAAG;GAInC,IAAI,CAAC,SAAS,EAAE,cAAc,QAAQ,OAAO,KAAA;GAC7C,YAAY,UACV;IACE,MAAM;IACN,SAAS,8BAA8B,WAAW,qXAAqX;GACza,GACA,EACF;GACA,OAAO,EAAE,YAAY;EACvB;EAGA,MAAM,UACJ,SAAS,cAAc,QACnB;GACE,iCAAiC,WAAW;GAC5C;GACA;GACA;EACF,IACA,CACE,gUACA,qDACF;EACN,YAAY,UAAU;GAAE,MAAM;GAAU,SAAS,CAAC,GAAG,SAAS,eAAe,CAAC,CAAC,KAAK,IAAI;EAAE,GAAG,EAAE;EAC/F,OAAO,EAAE,YAAY;CACvB;AACF;;;;;;;;;AAiBA,SAAgB,YAAY,EAC1B,UACA,WACA,YACA,oBACwC;CACxC,MAAM,SAAS,gBAAgB;CAC/B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,aAAa,WAAW,WAAW,UAAU;CACnD,MAAM,eAAe,cAAc,mBAAmB,SAAS;CAC/D,IAAI,CAAC,kBAAkB,OAAO,GAAG,OAAO,WAAW,mBAAmB,QAAQ,IAAI;CAElF,OAAO,GAAG,OAAO,aAAa,mBAAmB,gBAAgB,EAAE,cAD1C,aAAa,YAAY,mBAAmB,SAAS,EACoB,WAAW,mBAAmB,QAAQ,IAAI,aAAa,eAAe;AAC1K;AAEA,SAAgB,kBAAkB,kBAA8C;CAC9E,OAAO,mBAAmB,kBAAkB,QAAQ;AACtD;;AAGA,SAAgB,kBAAkB,kBAA8C;CAC9E,MAAM,SAAS,kBAAkB,gBAAgB;CACjD,OAAO,UAAU,GAAG,OAAO;AAC7B"}
@@ -0,0 +1,8 @@
1
+ import type { FactoryIntegration } from './base.js';
2
+ /**
3
+ * One line saying which integrations have a connected account, so a fresh
4
+ * project doesn't read as if every provider were in use.
5
+ */
6
+ export declare function describeIntegrations(integrations: readonly FactoryIntegration[]): Promise<string | undefined>;
7
+ export declare function logIntegrationSummary(integrations: readonly FactoryIntegration[]): Promise<void>;
8
+ //# sourceMappingURL=startup-summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-summary.d.ts","sourceRoot":"","sources":["../../src/integrations/startup-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAepD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkBnH;AAED,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtG"}
@@ -0,0 +1,36 @@
1
+ // src/integrations/startup-summary.ts
2
+ const DISPLAY_NAMES = {
3
+ github: "GitHub",
4
+ gitlab: "GitLab",
5
+ incidentio: "incident.io",
6
+ jira: "Jira",
7
+ linear: "Linear",
8
+ vanta: "Vanta"
9
+ };
10
+ function displayName(id) {
11
+ return DISPLAY_NAMES[id] ?? id;
12
+ }
13
+ /**
14
+ * One line saying which integrations have a connected account, so a fresh
15
+ * project doesn't read as if every provider were in use.
16
+ */
17
+ async function describeIntegrations(integrations) {
18
+ const statuses = await Promise.all(integrations.map((integration) => integration.hasActiveConnections?.().then((connected) => connected ? "connected" : "available", () => "status unknown")));
19
+ const groups = {
20
+ connected: [],
21
+ available: [],
22
+ "status unknown": []
23
+ };
24
+ statuses.forEach((status, i) => status && groups[status].push(displayName(integrations[i].id)));
25
+ const parts = Object.entries(groups).filter(([, names]) => names.length > 0).map(([status, names]) => `${names.join(", ")} ${status}`);
26
+ if (parts.length === 0) return void 0;
27
+ if (groups.connected.length === 0 && groups["status unknown"].length === 0) parts.unshift("none connected");
28
+ return `Intake: ${parts.join(" · ")}`;
29
+ }
30
+ async function logIntegrationSummary(integrations) {
31
+ const line = await describeIntegrations(integrations);
32
+ if (line) console.info(`◇ ${line}`);
33
+ }
34
+ export { describeIntegrations, logIntegrationSummary };
35
+
36
+ //# sourceMappingURL=startup-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-summary.js","names":[],"sources":["../../src/integrations/startup-summary.ts"],"sourcesContent":["import type { FactoryIntegration } from './base.js';\n\nconst DISPLAY_NAMES: Record<string, string> = {\n github: 'GitHub',\n gitlab: 'GitLab',\n incidentio: 'incident.io',\n jira: 'Jira',\n linear: 'Linear',\n vanta: 'Vanta',\n};\n\nfunction displayName(id: string): string {\n return DISPLAY_NAMES[id] ?? id;\n}\n\n/**\n * One line saying which integrations have a connected account, so a fresh\n * project doesn't read as if every provider were in use.\n */\nexport async function describeIntegrations(integrations: readonly FactoryIntegration[]): Promise<string | undefined> {\n const statuses = await Promise.all(\n integrations.map(integration =>\n integration.hasActiveConnections?.().then(\n connected => (connected ? 'connected' : 'available'),\n () => 'status unknown' as const,\n ),\n ),\n );\n const groups = { connected: [] as string[], available: [] as string[], 'status unknown': [] as string[] };\n statuses.forEach((status, i) => status && groups[status].push(displayName(integrations[i]!.id)));\n\n const parts = Object.entries(groups)\n .filter(([, names]) => names.length > 0)\n .map(([status, names]) => `${names.join(', ')} ${status}`);\n if (parts.length === 0) return undefined;\n if (groups.connected.length === 0 && groups['status unknown'].length === 0) parts.unshift('none connected');\n return `Intake: ${parts.join(' · ')}`;\n}\n\nexport async function logIntegrationSummary(integrations: readonly FactoryIntegration[]): Promise<void> {\n const line = await describeIntegrations(integrations);\n if (line) console.info(`◇ ${line}`);\n}\n"],"mappings":";AAEA,MAAM,gBAAwC;CAC5C,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAEA,SAAS,YAAY,IAAoB;CACvC,OAAO,cAAc,OAAO;AAC9B;;;;;AAMA,eAAsB,qBAAqB,cAA0E;CACnH,MAAM,WAAW,MAAM,QAAQ,IAC7B,aAAa,KAAI,gBACf,YAAY,uBAAuB,CAAC,CAAC,MACnC,cAAc,YAAY,cAAc,mBAClC,gBACR,CACF,CACF;CACA,MAAM,SAAS;EAAE,WAAW,CAAC;EAAe,WAAW,CAAC;EAAe,kBAAkB,CAAC;CAAc;CACxG,SAAS,SAAS,QAAQ,MAAM,UAAU,OAAO,OAAO,CAAC,KAAK,YAAY,aAAa,EAAE,CAAE,EAAE,CAAC,CAAC;CAE/F,MAAM,QAAQ,OAAO,QAAQ,MAAM,CAAC,CACjC,QAAQ,GAAG,WAAW,MAAM,SAAS,CAAC,CAAC,CACvC,KAAK,CAAC,QAAQ,WAAW,GAAG,MAAM,KAAK,IAAI,EAAE,GAAG,QAAQ;CAC3D,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;CAC/B,IAAI,OAAO,UAAU,WAAW,KAAK,OAAO,iBAAiB,CAAC,WAAW,GAAG,MAAM,QAAQ,gBAAgB;CAC1G,OAAO,WAAW,MAAM,KAAK,KAAK;AACpC;AAEA,eAAsB,sBAAsB,cAA4D;CACtG,MAAM,OAAO,MAAM,qBAAqB,YAAY;CACpD,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM;AACpC"}
@@ -0,0 +1,34 @@
1
+ import type { FactoryRuleHandler, FactoryVantaEventName, FactoryVantaRuleContext } from '../../rules/types.js';
2
+ export type VantaEventRules = Readonly<Record<FactoryVantaEventName, FactoryRuleHandler<FactoryVantaRuleContext> | null>>;
3
+ declare function vantaVulnerabilityObserved(context: FactoryVantaRuleContext): {
4
+ readonly type: 'upsertLinkedWorkItem';
5
+ readonly idempotencyKey: `${string}:vulnerability-intake`;
6
+ readonly board: string;
7
+ readonly source: 'vanta-vulnerability';
8
+ readonly sourceKey: string;
9
+ readonly title: string;
10
+ readonly description: string;
11
+ readonly url: string | null;
12
+ readonly stage: string;
13
+ readonly metadata: {
14
+ readonly identifier: string;
15
+ readonly body?: string | undefined;
16
+ readonly state: "open" | "resolved";
17
+ readonly severity: string | null;
18
+ readonly packageIdentifier: string | null;
19
+ readonly fixable: boolean | null;
20
+ readonly remediateBy: string | null;
21
+ readonly author: 'vanta';
22
+ readonly labels: string[];
23
+ readonly sourceCreatedAt: string;
24
+ readonly createdAt: string;
25
+ readonly updatedAt: string;
26
+ };
27
+ } | undefined;
28
+ declare function vantaVulnerabilityClosed(context: FactoryVantaRuleContext): import("../../rules/types.js").FactoryTransitionDecision | undefined;
29
+ export declare const defaultVantaRules: Readonly<{
30
+ vulnerabilityObserved: typeof vantaVulnerabilityObserved;
31
+ vulnerabilityClosed: typeof vantaVulnerabilityClosed;
32
+ }>;
33
+ export {};
34
+ //# sourceMappingURL=default-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/vanta/default-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/G,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC,CAClF,CAAC;AAkBF,iBAAS,0BAA0B,CAAC,OAAO,EAAE,uBAAuB;mBAI1D,sBAAsB;;;qBAIpB,qBAAqB;;;;;;;;;;;;;;yBAcnB,OAAO;yBACsB,MAAM,EAAE;;;;;cAMlD;AAED,iBAAS,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,wEAYjE;AAED,eAAO,MAAM,iBAAiB;;;EAGF,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { closedByRoutes } from "../../rules/event-rules.js";
2
+ // src/integrations/vanta/default-rules.ts
3
+ const MAX_DESCRIPTION_LENGTH = 8e3;
4
+ function vantaDescription(vulnerability) {
5
+ const text = [[
6
+ `**Vulnerability:** ${vulnerability.name}`,
7
+ vulnerability.packageIdentifier && `**Package:** \`${vulnerability.packageIdentifier}\``,
8
+ vulnerability.severity && `**Severity:** ${vulnerability.severity}`,
9
+ vulnerability.fixable !== null && `**Fixable:** ${vulnerability.fixable ? "yes" : "no"}`,
10
+ vulnerability.remediateBy && `**Remediate by:** ${vulnerability.remediateBy.slice(0, 10)}`,
11
+ vulnerability.url && `**Details:** ${vulnerability.url}`
12
+ ].filter((fact) => typeof fact === "string").map((fact) => `- ${fact}`).join("\n"), vulnerability.description?.trim()].filter(Boolean).join("\n\n");
13
+ return text.length <= MAX_DESCRIPTION_LENGTH ? text : `${text.slice(0, 7999)}…`;
14
+ }
15
+ function vantaVulnerabilityObserved(context) {
16
+ if (context.item || !context.intake) return;
17
+ const { vulnerability } = context;
18
+ return {
19
+ type: "upsertLinkedWorkItem",
20
+ idempotencyKey: `${context.ingress.id}:vulnerability-intake`,
21
+ board: context.intake.board,
22
+ source: "vanta-vulnerability",
23
+ sourceKey: vulnerability.id,
24
+ title: vulnerability.title,
25
+ description: vantaDescription(vulnerability),
26
+ url: vulnerability.url,
27
+ stage: context.intake.initialPhase,
28
+ metadata: {
29
+ identifier: vulnerability.name,
30
+ ...vulnerability.description ? { body: vulnerability.description } : {},
31
+ state: vulnerability.state,
32
+ severity: vulnerability.severity,
33
+ packageIdentifier: vulnerability.packageIdentifier,
34
+ fixable: vulnerability.fixable,
35
+ remediateBy: vulnerability.remediateBy,
36
+ author: "vanta",
37
+ labels: [...vulnerability.labels],
38
+ sourceCreatedAt: vulnerability.createdAt,
39
+ createdAt: vulnerability.createdAt,
40
+ updatedAt: vulnerability.createdAt
41
+ }
42
+ };
43
+ }
44
+ function vantaVulnerabilityClosed(context) {
45
+ if (!context.item || context.item.source !== "vanta-vulnerability") return;
46
+ const closure = context.boardClosure;
47
+ if (!context.board || !closure || closure.itemTerminal) return;
48
+ return closedByRoutes(false, {
49
+ idempotencyKey: `${context.ingress.id}:vulnerability-closed`,
50
+ board: context.board,
51
+ stage: closure.completed.phase,
52
+ message: { text: `Vanta no longer lists ${context.vulnerability.name} as active; this ${closure.boardTitle} card was moved to ${closure.completed.title}.` }
53
+ });
54
+ }
55
+ const defaultVantaRules = Object.freeze({
56
+ vulnerabilityObserved: vantaVulnerabilityObserved,
57
+ vulnerabilityClosed: vantaVulnerabilityClosed
58
+ });
59
+ export { defaultVantaRules };
60
+
61
+ //# sourceMappingURL=default-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/vanta/default-rules.ts"],"sourcesContent":["import { closedByRoutes } from '../../rules/event-rules.js';\nimport type { FactoryRuleHandler, FactoryVantaEventName, FactoryVantaRuleContext } from '../../rules/types.js';\n\nexport type VantaEventRules = Readonly<\n Record<FactoryVantaEventName, FactoryRuleHandler<FactoryVantaRuleContext> | null>\n>;\n\nconst MAX_DESCRIPTION_LENGTH = 8000;\n\nfunction vantaDescription(vulnerability: FactoryVantaRuleContext['vulnerability']): string {\n const facts = [\n `**Vulnerability:** ${vulnerability.name}`,\n vulnerability.packageIdentifier && `**Package:** \\`${vulnerability.packageIdentifier}\\``,\n vulnerability.severity && `**Severity:** ${vulnerability.severity}`,\n vulnerability.fixable !== null && `**Fixable:** ${vulnerability.fixable ? 'yes' : 'no'}`,\n vulnerability.remediateBy && `**Remediate by:** ${vulnerability.remediateBy.slice(0, 10)}`,\n vulnerability.url && `**Details:** ${vulnerability.url}`,\n ].filter((fact): fact is string => typeof fact === 'string');\n const parts = [facts.map(fact => `- ${fact}`).join('\\n'), vulnerability.description?.trim()].filter(Boolean);\n const text = parts.join('\\n\\n');\n return text.length <= MAX_DESCRIPTION_LENGTH ? text : `${text.slice(0, MAX_DESCRIPTION_LENGTH - 1)}…`;\n}\n\nfunction vantaVulnerabilityObserved(context: FactoryVantaRuleContext) {\n if (context.item || !context.intake) return;\n const { vulnerability } = context;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:vulnerability-intake`,\n // Filed on the default board's first phase; the project's intake routes place it from there.\n board: context.intake.board,\n source: 'vanta-vulnerability',\n sourceKey: vulnerability.id,\n title: vulnerability.title,\n description: vantaDescription(vulnerability),\n url: vulnerability.url,\n stage: context.intake.initialPhase,\n metadata: {\n identifier: vulnerability.name,\n ...(vulnerability.description ? { body: vulnerability.description } : {}),\n state: vulnerability.state,\n severity: vulnerability.severity,\n packageIdentifier: vulnerability.packageIdentifier,\n fixable: vulnerability.fixable,\n remediateBy: vulnerability.remediateBy,\n author: 'vanta',\n labels: [...vulnerability.labels] as string[],\n sourceCreatedAt: vulnerability.createdAt,\n createdAt: vulnerability.createdAt,\n updatedAt: vulnerability.createdAt,\n },\n } as const;\n}\n\nfunction vantaVulnerabilityClosed(context: FactoryVantaRuleContext) {\n if (!context.item || context.item.source !== 'vanta-vulnerability') return;\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n return closedByRoutes(false, {\n idempotencyKey: `${context.ingress.id}:vulnerability-closed`,\n board: context.board,\n stage: closure.completed.phase,\n message: {\n text: `Vanta no longer lists ${context.vulnerability.name} as active; this ${closure.boardTitle} card was moved to ${closure.completed.title}.`,\n },\n });\n}\n\nexport const defaultVantaRules = Object.freeze({\n vulnerabilityObserved: vantaVulnerabilityObserved,\n vulnerabilityClosed: vantaVulnerabilityClosed,\n} satisfies VantaEventRules);\n"],"mappings":";;AAOA,MAAM,yBAAyB;AAE/B,SAAS,iBAAiB,eAAiE;CAUzF,MAAM,OADQ,CARA;EACZ,sBAAsB,cAAc;EACpC,cAAc,qBAAqB,kBAAkB,cAAc,kBAAkB;EACrF,cAAc,YAAY,iBAAiB,cAAc;EACzD,cAAc,YAAY,QAAQ,gBAAgB,cAAc,UAAU,QAAQ;EAClF,cAAc,eAAe,qBAAqB,cAAc,YAAY,MAAM,GAAG,EAAE;EACvF,cAAc,OAAO,gBAAgB,cAAc;CACrD,CAAC,CAAC,QAAQ,SAAyB,OAAO,SAAS,QAChC,CAAC,CAAC,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,KAAK,IAAI,GAAG,cAAc,aAAa,KAAK,CAAC,CAAC,CAAC,OAAO,OACnF,CAAC,CAAC,KAAK,MAAM;CAC9B,OAAO,KAAK,UAAU,yBAAyB,OAAO,GAAG,KAAK,MAAM,GAAG,IAA0B,EAAE;AACrG;AAEA,SAAS,2BAA2B,SAAkC;CACpE,IAAI,QAAQ,QAAQ,CAAC,QAAQ,QAAQ;CACrC,MAAM,EAAE,kBAAkB;CAC1B,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EAEtC,OAAO,QAAQ,OAAO;EACtB,QAAQ;EACR,WAAW,cAAc;EACzB,OAAO,cAAc;EACrB,aAAa,iBAAiB,aAAa;EAC3C,KAAK,cAAc;EACnB,OAAO,QAAQ,OAAO;EACtB,UAAU;GACR,YAAY,cAAc;GAC1B,GAAI,cAAc,cAAc,EAAE,MAAM,cAAc,YAAY,IAAI,CAAC;GACvE,OAAO,cAAc;GACrB,UAAU,cAAc;GACxB,mBAAmB,cAAc;GACjC,SAAS,cAAc;GACvB,aAAa,cAAc;GAC3B,QAAQ;GACR,QAAQ,CAAC,GAAG,cAAc,MAAM;GAChC,iBAAiB,cAAc;GAC/B,WAAW,cAAc;GACzB,WAAW,cAAc;EAC3B;CACF;AACF;AAEA,SAAS,yBAAyB,SAAkC;CAClE,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,WAAW,uBAAuB;CACpE,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,QAAQ,SAAS,CAAC,WAAW,QAAQ,cAAc;CACxD,OAAO,eAAe,OAAO;EAC3B,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EACtC,OAAO,QAAQ;EACf,OAAO,QAAQ,UAAU;EACzB,SAAS,EACP,MAAM,yBAAyB,QAAQ,cAAc,KAAK,mBAAmB,QAAQ,WAAW,qBAAqB,QAAQ,UAAU,MAAM,GAC/I;CACF,CAAC;AACH;AAEA,MAAa,oBAAoB,OAAO,OAAO;CAC7C,uBAAuB;CACvB,qBAAqB;AACvB,CAA2B"}
@@ -0,0 +1,40 @@
1
+ import type { BoardEventFacts } from '../../boards/board-events.js';
2
+ import type { BoardRegistry } from '../../boards/index.js';
3
+ import type { ProjectBoardSource } from '../../boards/project-boards.js';
4
+ import type { FactoryVantaRuleContext } from '../../rules/types.js';
5
+ import type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';
6
+ import type { WorkItemsStorage } from '../../storage/domains/work-items/base.js';
7
+ import type { IntegrationContext } from '../base.js';
8
+ import type { VantaEventRules } from './default-rules.js';
9
+ /** Labels every Vanta card carries, so the Security intake route matches them like any `security`-labeled issue. */
10
+ export declare function vantaLabels(severity: string | null): string[];
11
+ export type VantaVulnerabilityIngress = FactoryVantaRuleContext['vulnerability'];
12
+ export interface VantaRulesOptions {
13
+ projects: Pick<FactoryProjectsStorage, 'get'>;
14
+ storage: WorkItemsStorage;
15
+ configVersion: string;
16
+ boards: BoardRegistry | ProjectBoardSource;
17
+ rules?: VantaEventRules;
18
+ }
19
+ export interface VantaRulesIngress {
20
+ orgId: string;
21
+ userId: string;
22
+ factoryProjectId: string;
23
+ /** Every vulnerability Vanta currently lists as active. Open cards missing from it are closed. */
24
+ vulnerabilities: VantaVulnerabilityIngress[];
25
+ }
26
+ type IngressStatus = 'committed' | 'replayed' | 'missing';
27
+ /** A first sighting of an active vulnerability creates its card; dropping off Vanta's active list closes it. */
28
+ export declare function boardEventFor(context: Pick<FactoryVantaRuleContext, 'event' | 'item'>): BoardEventFacts | undefined;
29
+ export declare class VantaRules {
30
+ #private;
31
+ private readonly options;
32
+ constructor(options: VantaRulesOptions);
33
+ ingest(input: VantaRulesIngress): Promise<{
34
+ status: IngressStatus;
35
+ ingested: number;
36
+ }>;
37
+ }
38
+ export declare function attachVantaRules(context: IntegrationContext): ((input: VantaRulesIngress) => Promise<unknown>) | undefined;
39
+ export {};
40
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/vanta/rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,KAAK,EAAE,uBAAuB,EAAuB,MAAM,sBAAsB,CAAC;AAGzF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,KAAK,EAAQ,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,oHAAoH;AACpH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAE7D;AAED,MAAM,MAAM,yBAAyB,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,aAAa,GAAG,kBAAkB,CAAC;IAC3C,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,kGAAkG;IAClG,eAAe,EAAE,yBAAyB,EAAE,CAAC;CAC9C;AAED,KAAK,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAE1D,gHAAgH;AAChH,wBAAgB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG,eAAe,GAAG,SAAS,CAKnH;AAsBD,qBAAa,UAAU;;IAGT,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,iBAAiB,EAEtD;IAMK,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAwB3F;CAsGF;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,kBAAkB,GAC1B,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAS9D"}
@@ -0,0 +1,208 @@
1
+ import { closeReason } from "../../boards/board-events.js";
2
+ import "../../boards/index.js";
3
+ import { boardForWorkItem, rulePhaseField, withBoardClosure, withIntakeTarget } from "../../boards/semantics.js";
4
+ import { toBoardSource } from "../../boards/project-boards.js";
5
+ import { routeEventDecision } from "../../rules/event-rules.js";
6
+ import { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from "../../rules/validation.js";
7
+ import { defaultVantaRules } from "./default-rules.js";
8
+ // src/integrations/vanta/rules.ts
9
+ const MAX_STALE_RULE_ATTEMPTS = 3;
10
+ /** Labels every Vanta card carries, so the Security intake route matches them like any `security`-labeled issue. */
11
+ function vantaLabels(severity) {
12
+ return [
13
+ "security",
14
+ "vanta",
15
+ ...severity ? [`severity:${severity.toLowerCase()}`] : []
16
+ ];
17
+ }
18
+ /** A first sighting of an active vulnerability creates its card; dropping off Vanta's active list closes it. */
19
+ function boardEventFor(context) {
20
+ if (context.event === "vulnerabilityClosed") return {
21
+ type: "work_item.closed",
22
+ reason: closeReason(false)
23
+ };
24
+ return context.item ? void 0 : { type: "work_item.created" };
25
+ }
26
+ /** The closing ingress for a card whose vulnerability Vanta stopped listing, rebuilt from the card. */
27
+ function resolvedFromCard(sourceKey, item) {
28
+ const metadata = item.metadata ?? {};
29
+ const text = (key) => typeof metadata[key] === "string" ? metadata[key] : null;
30
+ return {
31
+ id: sourceKey,
32
+ name: text("identifier") ?? sourceKey,
33
+ title: item.title,
34
+ description: null,
35
+ url: item.externalSource?.url ?? null,
36
+ state: "resolved",
37
+ severity: text("severity"),
38
+ packageIdentifier: text("packageIdentifier"),
39
+ fixable: null,
40
+ remediateBy: text("remediateBy"),
41
+ labels: [],
42
+ createdAt: text("sourceCreatedAt") ?? (/* @__PURE__ */ new Date(0)).toISOString()
43
+ };
44
+ }
45
+ var VantaRules = class {
46
+ options;
47
+ #rules;
48
+ constructor(options) {
49
+ this.options = options;
50
+ this.#rules = options.rules ?? defaultVantaRules;
51
+ }
52
+ #boards(scope) {
53
+ return toBoardSource(this.options.boards).forProject(scope);
54
+ }
55
+ async ingest(input) {
56
+ if (!await this.options.projects.get({
57
+ orgId: input.orgId,
58
+ id: input.factoryProjectId
59
+ })) return {
60
+ status: "missing",
61
+ ingested: 0
62
+ };
63
+ await toBoardSource(this.options.boards).load(input);
64
+ const items = await this.options.storage.listShared({
65
+ orgId: input.orgId,
66
+ factoryProjectId: input.factoryProjectId
67
+ });
68
+ const itemsBySourceKey = new Map(items.filter((item) => item.externalSource?.integrationId === "vanta" && item.externalSource.type === "vulnerability").map((item) => [item.externalSource?.externalId, item]));
69
+ const statuses = [];
70
+ const active = new Set(input.vulnerabilities.map((vulnerability) => vulnerability.id));
71
+ for (const vulnerability of input.vulnerabilities) {
72
+ const relatedItem = itemsBySourceKey.get(vulnerability.id);
73
+ statuses.push(await this.#ingestAlert(input, vulnerability, relatedItem && structuredClone(relatedItem)));
74
+ }
75
+ for (const [sourceKey, item] of itemsBySourceKey) {
76
+ if (!sourceKey || active.has(sourceKey) || item.metadata?.state === "resolved") continue;
77
+ statuses.push(await this.#ingestAlert(input, resolvedFromCard(sourceKey, item), structuredClone(item)));
78
+ }
79
+ if (statuses.includes("committed")) return {
80
+ status: "committed",
81
+ ingested: statuses.length
82
+ };
83
+ if (statuses.includes("replayed")) return {
84
+ status: "replayed",
85
+ ingested: statuses.length
86
+ };
87
+ return {
88
+ status: "missing",
89
+ ingested: statuses.length
90
+ };
91
+ }
92
+ async #ingestAlert(input, alert, relatedItem, attempt = 1) {
93
+ const closed = alert.state === "resolved";
94
+ if (closed && !relatedItem) return "missing";
95
+ const ingressId = `vanta:${alert.id}:${alert.state}`;
96
+ const actor = {
97
+ type: "human",
98
+ id: input.userId
99
+ };
100
+ const event = closed ? "vulnerabilityClosed" : "vulnerabilityObserved";
101
+ const boards = this.#boards(input);
102
+ const context = {
103
+ tenant: {
104
+ orgId: input.orgId,
105
+ projectId: input.factoryProjectId
106
+ },
107
+ actor,
108
+ ingress: {
109
+ type: "vanta",
110
+ id: ingressId
111
+ },
112
+ cause: `vanta.${event}`,
113
+ causalChain: [],
114
+ configVersion: this.options.configVersion,
115
+ ...relatedItem ? {
116
+ item: {
117
+ id: relatedItem.id,
118
+ source: "vanta-vulnerability",
119
+ sourceKey: relatedItem.externalSource?.externalId ?? null,
120
+ parentWorkItemId: relatedItem.parentWorkItemId,
121
+ title: relatedItem.title,
122
+ url: relatedItem.externalSource?.url ?? null,
123
+ stages: relatedItem.stages,
124
+ workItem: relatedItem.workItem,
125
+ acceptedAt: relatedItem.acceptedAt,
126
+ metadata: relatedItem.metadata
127
+ },
128
+ board: boardForWorkItem(relatedItem),
129
+ itemRevision: relatedItem.revision,
130
+ ...withBoardClosure(boards, relatedItem),
131
+ ...rulePhaseField(boards, relatedItem)
132
+ } : {},
133
+ ...withIntakeTarget(boards),
134
+ event,
135
+ vulnerability: alert
136
+ };
137
+ const boardEvent = boardEventFor(context);
138
+ if (boardEvent) context.boardEvent = boardEvent;
139
+ const rule = this.#rules[event];
140
+ let decision = void 0;
141
+ let decisions = [];
142
+ let outcome = { status: "accepted" };
143
+ try {
144
+ decision = rule ? await rule(Object.freeze(context)) : void 0;
145
+ if (decision?.type === "reject") outcome = {
146
+ status: "rejected",
147
+ code: decision.code,
148
+ reason: decision.reason
149
+ };
150
+ else if (decision) decisions = validateFactoryRuleDecisions([decision]).map((entry) => {
151
+ assertFactoryDecisionTarget(entry, boards, relatedItem ? boardForWorkItem(relatedItem) : void 0);
152
+ return { ...entry };
153
+ });
154
+ } catch (error) {
155
+ outcome = {
156
+ status: "rejected",
157
+ code: "rule_error",
158
+ reason: error instanceof Error ? error.message.slice(0, 2e3) : "Factory Vanta rule failed."
159
+ };
160
+ }
161
+ if (!decision && outcome.status === "accepted") {
162
+ const routed = await routeEventDecision(context, this.options.storage, {
163
+ orgId: input.orgId,
164
+ factoryProjectId: input.factoryProjectId
165
+ });
166
+ if (routed) decisions = [{ ...routed }];
167
+ }
168
+ const committed = await this.options.storage.commitRuleEvaluation({
169
+ orgId: input.orgId,
170
+ factoryProjectId: input.factoryProjectId,
171
+ workItemId: relatedItem?.id ?? null,
172
+ ingress: {
173
+ identity: ingressId,
174
+ triggerType: `vanta.${event}`
175
+ },
176
+ configVersion: this.options.configVersion,
177
+ expectedRevision: relatedItem?.revision ?? null,
178
+ actor,
179
+ outcome,
180
+ decisions,
181
+ causalChain: [],
182
+ now: /* @__PURE__ */ new Date()
183
+ });
184
+ if (committed.status === "stale") {
185
+ if (attempt >= MAX_STALE_RULE_ATTEMPTS) throw new Error(`Factory Vanta rule evaluation for ${ingressId} kept losing revision races.`);
186
+ const fresh = relatedItem ? await this.options.storage.get({
187
+ orgId: input.orgId,
188
+ id: relatedItem.id
189
+ }) : null;
190
+ if (relatedItem && !fresh) return "missing";
191
+ return this.#ingestAlert(input, alert, fresh ?? void 0, attempt + 1);
192
+ }
193
+ return committed.status;
194
+ }
195
+ };
196
+ function attachVantaRules(context) {
197
+ if (!context.runtime) return void 0;
198
+ const rules = new VantaRules({
199
+ projects: context.storage.projects,
200
+ storage: context.runtime.workItems,
201
+ configVersion: context.runtime.configVersion,
202
+ boards: context.runtime.boards
203
+ });
204
+ return (input) => rules.ingest(input);
205
+ }
206
+ export { VantaRules, attachVantaRules, boardEventFor, vantaLabels };
207
+
208
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../../../src/integrations/vanta/rules.ts"],"sourcesContent":["import { closeReason } from '../../boards/board-events.js';\nimport type { BoardEventFacts } from '../../boards/board-events.js';\nimport { boardForWorkItem, rulePhaseField, withBoardClosure, withIntakeTarget } from '../../boards/index.js';\nimport type { BoardRegistry } from '../../boards/index.js';\nimport { toBoardSource } from '../../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../../boards/project-boards.js';\nimport { routeEventDecision } from '../../rules/event-rules.js';\nimport type { FactoryVantaRuleContext, FactoryRuleDecision } from '../../rules/types.js';\nimport { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from '../../rules/validation.js';\nimport type { StoredBoardScope } from '../../storage/domains/boards/base.js';\nimport type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';\nimport type { Card, WorkItemsStorage } from '../../storage/domains/work-items/base.js';\nimport type { IntegrationContext } from '../base.js';\nimport { defaultVantaRules } from './default-rules.js';\nimport type { VantaEventRules } from './default-rules.js';\n\nconst MAX_STALE_RULE_ATTEMPTS = 3;\n\n/** Labels every Vanta card carries, so the Security intake route matches them like any `security`-labeled issue. */\nexport function vantaLabels(severity: string | null): string[] {\n return ['security', 'vanta', ...(severity ? [`severity:${severity.toLowerCase()}`] : [])];\n}\n\nexport type VantaVulnerabilityIngress = FactoryVantaRuleContext['vulnerability'];\n\nexport interface VantaRulesOptions {\n projects: Pick<FactoryProjectsStorage, 'get'>;\n storage: WorkItemsStorage;\n configVersion: string;\n boards: BoardRegistry | ProjectBoardSource;\n rules?: VantaEventRules;\n}\n\nexport interface VantaRulesIngress {\n orgId: string;\n userId: string;\n factoryProjectId: string;\n /** Every vulnerability Vanta currently lists as active. Open cards missing from it are closed. */\n vulnerabilities: VantaVulnerabilityIngress[];\n}\n\ntype IngressStatus = 'committed' | 'replayed' | 'missing';\n\n/** A first sighting of an active vulnerability creates its card; dropping off Vanta's active list closes it. */\nexport function boardEventFor(context: Pick<FactoryVantaRuleContext, 'event' | 'item'>): BoardEventFacts | undefined {\n if (context.event === 'vulnerabilityClosed') {\n return { type: 'work_item.closed', reason: closeReason(false) };\n }\n return context.item ? undefined : { type: 'work_item.created' };\n}\n\n/** The closing ingress for a card whose vulnerability Vanta stopped listing, rebuilt from the card. */\nfunction resolvedFromCard(sourceKey: string, item: Card): VantaVulnerabilityIngress {\n const metadata = item.metadata ?? {};\n const text = (key: string) => (typeof metadata[key] === 'string' ? (metadata[key] as string) : null);\n return {\n id: sourceKey,\n name: text('identifier') ?? sourceKey,\n title: item.title,\n description: null,\n url: item.externalSource?.url ?? null,\n state: 'resolved',\n severity: text('severity'),\n packageIdentifier: text('packageIdentifier'),\n fixable: null,\n remediateBy: text('remediateBy'),\n labels: [],\n createdAt: text('sourceCreatedAt') ?? new Date(0).toISOString(),\n };\n}\n\nexport class VantaRules {\n readonly #rules: VantaEventRules;\n\n constructor(private readonly options: VantaRulesOptions) {\n this.#rules = options.rules ?? defaultVantaRules;\n }\n\n #boards(scope: StoredBoardScope): BoardRegistry {\n return toBoardSource(this.options.boards).forProject(scope);\n }\n\n async ingest(input: VantaRulesIngress): Promise<{ status: IngressStatus; ingested: number }> {\n const project = await this.options.projects.get({ orgId: input.orgId, id: input.factoryProjectId });\n if (!project) return { status: 'missing', ingested: 0 };\n await toBoardSource(this.options.boards).load(input);\n\n const items = await this.options.storage.listShared({ orgId: input.orgId, factoryProjectId: input.factoryProjectId });\n const itemsBySourceKey = new Map(\n items\n .filter(item => item.externalSource?.integrationId === 'vanta' && item.externalSource.type === 'vulnerability')\n .map(item => [item.externalSource?.externalId, item]),\n );\n const statuses: IngressStatus[] = [];\n const active = new Set(input.vulnerabilities.map(vulnerability => vulnerability.id));\n for (const vulnerability of input.vulnerabilities) {\n const relatedItem = itemsBySourceKey.get(vulnerability.id);\n statuses.push(await this.#ingestAlert(input, vulnerability, relatedItem && structuredClone(relatedItem)));\n }\n for (const [sourceKey, item] of itemsBySourceKey) {\n if (!sourceKey || active.has(sourceKey) || item.metadata?.state === 'resolved') continue;\n statuses.push(await this.#ingestAlert(input, resolvedFromCard(sourceKey, item), structuredClone(item)));\n }\n if (statuses.includes('committed')) return { status: 'committed', ingested: statuses.length };\n if (statuses.includes('replayed')) return { status: 'replayed', ingested: statuses.length };\n return { status: 'missing', ingested: statuses.length };\n }\n\n async #ingestAlert(\n input: VantaRulesIngress,\n alert: VantaVulnerabilityIngress,\n relatedItem: Card | undefined,\n attempt = 1,\n ): Promise<IngressStatus> {\n const closed = alert.state === 'resolved';\n // A resolved vulnerability Factory never filed stays off the board.\n if (closed && !relatedItem) return 'missing';\n\n const ingressId = `vanta:${alert.id}:${alert.state}`;\n const actor = { type: 'human' as const, id: input.userId };\n const event = closed ? 'vulnerabilityClosed' : 'vulnerabilityObserved';\n const boards = this.#boards(input);\n const context: FactoryVantaRuleContext = {\n tenant: { orgId: input.orgId, projectId: input.factoryProjectId },\n actor,\n ingress: { type: 'vanta', id: ingressId },\n cause: `vanta.${event}`,\n causalChain: [],\n configVersion: this.options.configVersion,\n ...(relatedItem\n ? {\n item: {\n id: relatedItem.id,\n source: 'vanta-vulnerability',\n sourceKey: relatedItem.externalSource?.externalId ?? null,\n parentWorkItemId: relatedItem.parentWorkItemId,\n title: relatedItem.title,\n url: relatedItem.externalSource?.url ?? null,\n stages: relatedItem.stages,\n workItem: relatedItem.workItem,\n acceptedAt: relatedItem.acceptedAt,\n metadata: relatedItem.metadata,\n },\n board: boardForWorkItem(relatedItem),\n itemRevision: relatedItem.revision,\n ...withBoardClosure(boards, relatedItem),\n ...rulePhaseField(boards, relatedItem),\n }\n : {}),\n ...withIntakeTarget(boards),\n event,\n vulnerability: alert,\n };\n const boardEvent = boardEventFor(context);\n if (boardEvent) context.boardEvent = boardEvent;\n\n const rule = this.#rules[event];\n let decision: FactoryRuleDecision | void = undefined;\n let decisions: Record<string, unknown>[] = [];\n let outcome: { status: 'accepted' | 'rejected'; code?: string; reason?: string } = { status: 'accepted' };\n try {\n decision = rule ? await rule(Object.freeze(context)) : undefined;\n if (decision?.type === 'reject') {\n outcome = { status: 'rejected', code: decision.code, reason: decision.reason };\n } else if (decision) {\n decisions = validateFactoryRuleDecisions([decision]).map(entry => {\n assertFactoryDecisionTarget(entry, boards, relatedItem ? boardForWorkItem(relatedItem) : undefined);\n return { ...entry };\n });\n }\n } catch (error) {\n outcome = {\n status: 'rejected',\n code: 'rule_error',\n reason: error instanceof Error ? error.message.slice(0, 2_000) : 'Factory Vanta rule failed.',\n };\n }\n if (!decision && outcome.status === 'accepted') {\n const routed = await routeEventDecision(context, this.options.storage, {\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n });\n if (routed) decisions = [{ ...routed }];\n }\n\n const committed = await this.options.storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: relatedItem?.id ?? null,\n ingress: { identity: ingressId, triggerType: `vanta.${event}` },\n configVersion: this.options.configVersion,\n expectedRevision: relatedItem?.revision ?? null,\n actor,\n outcome,\n decisions,\n causalChain: [],\n now: new Date(),\n });\n if (committed.status === 'stale') {\n if (attempt >= MAX_STALE_RULE_ATTEMPTS) {\n throw new Error(`Factory Vanta rule evaluation for ${ingressId} kept losing revision races.`);\n }\n const fresh = relatedItem ? await this.options.storage.get({ orgId: input.orgId, id: relatedItem.id }) : null;\n if (relatedItem && !fresh) return 'missing';\n return this.#ingestAlert(input, alert, fresh ?? undefined, attempt + 1);\n }\n return committed.status;\n }\n}\n\nexport function attachVantaRules(\n context: IntegrationContext,\n): ((input: VantaRulesIngress) => Promise<unknown>) | undefined {\n if (!context.runtime) return undefined;\n const rules = new VantaRules({\n projects: context.storage.projects,\n storage: context.runtime.workItems,\n configVersion: context.runtime.configVersion,\n boards: context.runtime.boards,\n });\n return input => rules.ingest(input);\n}\n"],"mappings":"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"}
@@ -0,0 +1,40 @@
1
+ import type { IssueReconcileSummary } from '../issue-reconciler.js';
2
+ import type { VantaRulesIngress, VantaVulnerabilityIngress } from './rules.js';
3
+ export declare const VANTA_VULNERABILITIES_SOURCE_ID = "vanta:vulnerabilities";
4
+ export declare const DEFAULT_VANTA_SYNC_INTERVAL_MS: number;
5
+ /** The subset of Vanta's `GET /v1/vulnerabilities` item Factory reads. */
6
+ export interface VantaVulnerability {
7
+ id: string;
8
+ name: string;
9
+ description?: string | null;
10
+ packageIdentifier?: string | null;
11
+ severity?: string | null;
12
+ isFixable?: boolean | null;
13
+ remediateByDate?: string | null;
14
+ firstDetectedDate?: string | null;
15
+ externalURL?: string | null;
16
+ }
17
+ /** Lists a complete snapshot for one org, or null when its connections cannot be reconciled safely. */
18
+ export type VantaVulnerabilityLister = (orgId: string) => Promise<VantaVulnerability[] | null>;
19
+ export declare function toVantaIngress(vulnerability: VantaVulnerability): VantaVulnerabilityIngress;
20
+ /**
21
+ * Reads a complete snapshot for each organization and hands it to that organization's
22
+ * Factory projects taking Vanta intake. Unavailable snapshots are never reconciled.
23
+ */
24
+ export declare function createVantaSync(options: {
25
+ /**
26
+ * Whether any Vanta connection is active. Without one the vulnerability list
27
+ * is empty, which would read as every filed vulnerability being resolved.
28
+ */
29
+ connected: () => Promise<boolean>;
30
+ listVulnerabilities: VantaVulnerabilityLister;
31
+ listProjects: () => Promise<ReadonlyArray<{
32
+ orgId: string;
33
+ id: string;
34
+ }>>;
35
+ intakeEnabled: (orgId: string) => Promise<boolean>;
36
+ boundProjectIds: (orgId: string) => Promise<string[]>;
37
+ ingest: (input: VantaRulesIngress) => Promise<unknown>;
38
+ userId: string;
39
+ }): () => Promise<IssueReconcileSummary>;
40
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/integrations/vanta/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,+BAA+B,0BAA0B,CAAC;AACvE,eAAO,MAAM,8BAA8B,QAAc,CAAC;AAE1D,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,uGAAuG;AACvG,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAAC;AAE/F,wBAAgB,cAAc,CAAC,aAAa,EAAE,kBAAkB,GAAG,yBAAyB,CAkB3F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,mBAAmB,EAAE,wBAAwB,CAAC;IAC9C,YAAY,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1E,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACtD,MAAM,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAkDvC"}
@@ -0,0 +1,81 @@
1
+ import { vantaLabels } from "./rules.js";
2
+ // src/integrations/vanta/sync.ts
3
+ const VANTA_VULNERABILITIES_SOURCE_ID = "vanta:vulnerabilities";
4
+ const DEFAULT_VANTA_SYNC_INTERVAL_MS = 9e5;
5
+ function toVantaIngress(vulnerability) {
6
+ const severity = vulnerability.severity?.toLowerCase() ?? null;
7
+ const packageIdentifier = vulnerability.packageIdentifier ?? null;
8
+ return {
9
+ id: vulnerability.id,
10
+ name: vulnerability.name,
11
+ title: packageIdentifier ? `${packageIdentifier}: ${vulnerability.name}` : vulnerability.name,
12
+ description: vulnerability.description && vulnerability.description !== vulnerability.name ? vulnerability.description : null,
13
+ url: vulnerability.externalURL ?? null,
14
+ state: "open",
15
+ severity,
16
+ packageIdentifier,
17
+ fixable: vulnerability.isFixable ?? null,
18
+ remediateBy: vulnerability.remediateByDate ?? null,
19
+ labels: vantaLabels(severity),
20
+ createdAt: vulnerability.firstDetectedDate ?? (/* @__PURE__ */ new Date(0)).toISOString()
21
+ };
22
+ }
23
+ /**
24
+ * Reads a complete snapshot for each organization and hands it to that organization's
25
+ * Factory projects taking Vanta intake. Unavailable snapshots are never reconciled.
26
+ */
27
+ function createVantaSync(options) {
28
+ return async () => {
29
+ const summary = {
30
+ projects: 0,
31
+ checked: 0,
32
+ updated: 0,
33
+ closed: 0,
34
+ missing: 0,
35
+ failed: 0,
36
+ errors: []
37
+ };
38
+ if (!await options.connected()) return summary;
39
+ const projects = await options.listProjects();
40
+ if (projects.length === 0) return summary;
41
+ const orgTargets = /* @__PURE__ */ new Map();
42
+ for (const project of projects) try {
43
+ let target = orgTargets.get(project.orgId);
44
+ if (!target) {
45
+ const enabled = await options.intakeEnabled(project.orgId);
46
+ target = {
47
+ enabled,
48
+ bound: enabled ? await options.boundProjectIds(project.orgId) : [],
49
+ loaded: false,
50
+ vulnerabilities: null
51
+ };
52
+ orgTargets.set(project.orgId, target);
53
+ }
54
+ if (!target.enabled || target.bound.length > 0 && !target.bound.includes(project.id)) continue;
55
+ if (!target.loaded) {
56
+ const snapshot = await options.listVulnerabilities(project.orgId);
57
+ target.vulnerabilities = snapshot?.map(toVantaIngress) ?? null;
58
+ target.loaded = true;
59
+ }
60
+ if (target.vulnerabilities === null) continue;
61
+ await options.ingest({
62
+ orgId: project.orgId,
63
+ userId: options.userId,
64
+ factoryProjectId: project.id,
65
+ vulnerabilities: target.vulnerabilities
66
+ });
67
+ summary.projects += 1;
68
+ summary.checked += target.vulnerabilities.length;
69
+ } catch (error) {
70
+ summary.failed += 1;
71
+ summary.errors.push({
72
+ projectId: project.id,
73
+ error: error instanceof Error ? error.message : String(error)
74
+ });
75
+ }
76
+ return summary;
77
+ };
78
+ }
79
+ export { DEFAULT_VANTA_SYNC_INTERVAL_MS, VANTA_VULNERABILITIES_SOURCE_ID, createVantaSync, toVantaIngress };
80
+
81
+ //# sourceMappingURL=sync.js.map