@mastra/factory 0.28.0 → 0.29.0-alpha.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 (224) hide show
  1. package/README.md +6 -4
  2. package/dist/boards/reroute.d.ts +31 -0
  3. package/dist/boards/reroute.d.ts.map +1 -0
  4. package/dist/boards/reroute.js +71 -0
  5. package/dist/boards/reroute.js.map +1 -0
  6. package/dist/environment/repository-access.d.ts +2 -0
  7. package/dist/environment/repository-access.d.ts.map +1 -1
  8. package/dist/environment/repository-access.js +9 -4
  9. package/dist/environment/repository-access.js.map +1 -1
  10. package/dist/factory.d.ts.map +1 -1
  11. package/dist/factory.js +9 -6
  12. package/dist/factory.js.map +1 -1
  13. package/dist/integrations/base.d.ts +8 -0
  14. package/dist/integrations/base.d.ts.map +1 -1
  15. package/dist/integrations/dependabot/default-rules.d.ts +38 -0
  16. package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
  17. package/dist/integrations/dependabot/default-rules.js +63 -0
  18. package/dist/integrations/dependabot/default-rules.js.map +1 -0
  19. package/dist/integrations/dependabot/rules.d.ts +42 -0
  20. package/dist/integrations/dependabot/rules.d.ts.map +1 -0
  21. package/dist/integrations/dependabot/rules.js +187 -0
  22. package/dist/integrations/dependabot/rules.js.map +1 -0
  23. package/dist/integrations/dependabot/sync.d.ts +76 -0
  24. package/dist/integrations/dependabot/sync.d.ts.map +1 -0
  25. package/dist/integrations/dependabot/sync.js +111 -0
  26. package/dist/integrations/dependabot/sync.js.map +1 -0
  27. package/dist/integrations/github/routes.d.ts.map +1 -1
  28. package/dist/integrations/github/routes.js +7 -2
  29. package/dist/integrations/github/routes.js.map +1 -1
  30. package/dist/integrations/github/sandbox.d.ts +12 -0
  31. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  32. package/dist/integrations/github/sandbox.js +22 -1
  33. package/dist/integrations/github/sandbox.js.map +1 -1
  34. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  35. package/dist/integrations/platform/connect/routes.js +4 -0
  36. package/dist/integrations/platform/connect/routes.js.map +1 -1
  37. package/dist/integrations/platform/github/event-worker.d.ts +5 -0
  38. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  39. package/dist/integrations/platform/github/event-worker.js +33 -2
  40. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  41. package/dist/integrations/platform/github/integration.d.ts +19 -1
  42. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  43. package/dist/integrations/platform/github/integration.js +46 -0
  44. package/dist/integrations/platform/github/integration.js.map +1 -1
  45. package/dist/integrations/platform/vanta/integration.d.ts +33 -0
  46. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
  47. package/dist/integrations/platform/vanta/integration.js +133 -0
  48. package/dist/integrations/platform/vanta/integration.js.map +1 -0
  49. package/dist/integrations/vanta/default-rules.d.ts +34 -0
  50. package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
  51. package/dist/integrations/vanta/default-rules.js +61 -0
  52. package/dist/integrations/vanta/default-rules.js.map +1 -0
  53. package/dist/integrations/vanta/rules.d.ts +40 -0
  54. package/dist/integrations/vanta/rules.d.ts.map +1 -0
  55. package/dist/integrations/vanta/rules.js +208 -0
  56. package/dist/integrations/vanta/rules.js.map +1 -0
  57. package/dist/integrations/vanta/sync.d.ts +36 -0
  58. package/dist/integrations/vanta/sync.d.ts.map +1 -0
  59. package/dist/integrations/vanta/sync.js +73 -0
  60. package/dist/integrations/vanta/sync.js.map +1 -0
  61. package/dist/mcp/routes.d.ts.map +1 -1
  62. package/dist/mcp/routes.js +1 -1
  63. package/dist/mcp/routes.js.map +1 -1
  64. package/dist/routes/board-snapshot.d.ts +8 -1
  65. package/dist/routes/board-snapshot.d.ts.map +1 -1
  66. package/dist/routes/board-snapshot.js +23 -2
  67. package/dist/routes/board-snapshot.js.map +1 -1
  68. package/dist/routes/contracts.d.ts +205 -0
  69. package/dist/routes/contracts.d.ts.map +1 -1
  70. package/dist/routes/contracts.js +159 -5
  71. package/dist/routes/contracts.js.map +1 -1
  72. package/dist/routes/intake-routes.d.ts +3 -0
  73. package/dist/routes/intake-routes.d.ts.map +1 -1
  74. package/dist/routes/intake-routes.js +44 -0
  75. package/dist/routes/intake-routes.js.map +1 -1
  76. package/dist/routes/knowledge.d.ts.map +1 -1
  77. package/dist/routes/knowledge.js +3 -2
  78. package/dist/routes/knowledge.js.map +1 -1
  79. package/dist/routes/source-control-sessions.d.ts +1 -1
  80. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  81. package/dist/routes/source-control-sessions.js +109 -3
  82. package/dist/routes/source-control-sessions.js.map +1 -1
  83. package/dist/routes/surface.d.ts +6 -1
  84. package/dist/routes/surface.d.ts.map +1 -1
  85. package/dist/routes/surface.js +72 -9
  86. package/dist/routes/surface.js.map +1 -1
  87. package/dist/routes/work-item-selection.d.ts +0 -4
  88. package/dist/routes/work-item-selection.d.ts.map +1 -1
  89. package/dist/routes/work-item-selection.js +4 -21
  90. package/dist/routes/work-item-selection.js.map +1 -1
  91. package/dist/routes/work-item-starters.d.ts.map +1 -1
  92. package/dist/routes/work-item-starters.js +4 -21
  93. package/dist/routes/work-item-starters.js.map +1 -1
  94. package/dist/routes/work-items.d.ts.map +1 -1
  95. package/dist/routes/work-items.js +112 -36
  96. package/dist/routes/work-items.js.map +1 -1
  97. package/dist/rules/dispatch-errors.d.ts +3 -0
  98. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  99. package/dist/rules/dispatch-errors.js +5 -0
  100. package/dist/rules/dispatch-errors.js.map +1 -1
  101. package/dist/rules/dispatcher.d.ts +2 -0
  102. package/dist/rules/dispatcher.d.ts.map +1 -1
  103. package/dist/rules/dispatcher.js +39 -18
  104. package/dist/rules/dispatcher.js.map +1 -1
  105. package/dist/rules/index.d.ts +2 -2
  106. package/dist/rules/index.d.ts.map +1 -1
  107. package/dist/rules/index.js +2 -2
  108. package/dist/rules/start-coordinator.d.ts +6 -1
  109. package/dist/rules/start-coordinator.d.ts.map +1 -1
  110. package/dist/rules/start-coordinator.js +6 -2
  111. package/dist/rules/start-coordinator.js.map +1 -1
  112. package/dist/rules/transition-service.d.ts.map +1 -1
  113. package/dist/rules/transition-service.js +3 -2
  114. package/dist/rules/transition-service.js.map +1 -1
  115. package/dist/rules/types.d.ts +71 -3
  116. package/dist/rules/types.d.ts.map +1 -1
  117. package/dist/rules/types.js +10 -2
  118. package/dist/rules/types.js.map +1 -1
  119. package/dist/rules/validation.d.ts.map +1 -1
  120. package/dist/rules/validation.js +5 -0
  121. package/dist/rules/validation.js.map +1 -1
  122. package/dist/session/factory-session.d.ts +20 -5
  123. package/dist/session/factory-session.d.ts.map +1 -1
  124. package/dist/session/factory-session.js +20 -6
  125. package/dist/session/factory-session.js.map +1 -1
  126. package/dist/storage/domains/audit/actions.d.ts +1 -1
  127. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  128. package/dist/storage/domains/audit/actions.js +2 -1
  129. package/dist/storage/domains/audit/actions.js.map +1 -1
  130. package/dist/storage/domains/audit/actors.d.ts.map +1 -1
  131. package/dist/storage/domains/audit/actors.js +1 -1
  132. package/dist/storage/domains/audit/actors.js.map +1 -1
  133. package/dist/storage/domains/intake/base.d.ts +1 -1
  134. package/dist/storage/domains/intake/base.js +2 -2
  135. package/dist/storage/domains/intake/base.js.map +1 -1
  136. package/dist/storage/domains/projects/base.d.ts +8 -0
  137. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  138. package/dist/storage/domains/projects/base.js +11 -1
  139. package/dist/storage/domains/projects/base.js.map +1 -1
  140. package/dist/storage/domains/work-items/base.d.ts +15 -4
  141. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  142. package/dist/storage/domains/work-items/base.js +19 -1
  143. package/dist/storage/domains/work-items/base.js.map +1 -1
  144. package/dist/tools/approval-tools.d.ts +20 -0
  145. package/dist/tools/approval-tools.d.ts.map +1 -1
  146. package/dist/tools/approval-tools.js +79 -30
  147. package/dist/tools/approval-tools.js.map +1 -1
  148. package/dist/tools/audit-events-tool.d.ts +1 -1
  149. package/dist/tools/messaging-tools.d.ts.map +1 -1
  150. package/dist/tools/messaging-tools.js +1 -1
  151. package/dist/tools/messaging-tools.js.map +1 -1
  152. package/dist/tools/read-tools.d.ts +0 -2
  153. package/dist/tools/read-tools.d.ts.map +1 -1
  154. package/dist/tools/read-tools.js +2 -7
  155. package/dist/tools/read-tools.js.map +1 -1
  156. package/dist/tools/reports.d.ts +3 -0
  157. package/dist/tools/reports.d.ts.map +1 -1
  158. package/dist/tools/reports.js +3 -3
  159. package/dist/tools/reports.js.map +1 -1
  160. package/dist/tools/run-watch.d.ts +14 -2
  161. package/dist/tools/run-watch.d.ts.map +1 -1
  162. package/dist/tools/run-watch.js +24 -4
  163. package/dist/tools/run-watch.js.map +1 -1
  164. package/dist/tools/session-tools.d.ts.map +1 -1
  165. package/dist/tools/session-tools.js +17 -6
  166. package/dist/tools/session-tools.js.map +1 -1
  167. package/dist/tools/side-sessions.d.ts.map +1 -1
  168. package/dist/tools/side-sessions.js +1 -1
  169. package/dist/tools/side-sessions.js.map +1 -1
  170. package/dist/tools/work-item-tools.d.ts.map +1 -1
  171. package/dist/tools/work-item-tools.js +12 -2
  172. package/dist/tools/work-item-tools.js.map +1 -1
  173. package/dist/work-item-branch.d.ts +1 -1
  174. package/dist/work-item-branch.d.ts.map +1 -1
  175. package/dist/work-item-branch.js +2 -0
  176. package/dist/work-item-branch.js.map +1 -1
  177. package/dist/work-items/board-filter-options.d.ts +5 -0
  178. package/dist/work-items/board-filter-options.d.ts.map +1 -0
  179. package/dist/work-items/board-filter-options.js +27 -0
  180. package/dist/work-items/board-filter-options.js.map +1 -0
  181. package/dist/work-items/board-phases.d.ts +28 -0
  182. package/dist/work-items/board-phases.d.ts.map +1 -0
  183. package/dist/work-items/board-phases.js +165 -0
  184. package/dist/work-items/board-phases.js.map +1 -0
  185. package/dist/work-items/card-facts.d.ts +24 -0
  186. package/dist/work-items/card-facts.d.ts.map +1 -0
  187. package/dist/work-items/card-facts.js +75 -0
  188. package/dist/work-items/card-facts.js.map +1 -0
  189. package/dist/work-items/card-labels.d.ts +5 -0
  190. package/dist/work-items/card-labels.d.ts.map +1 -0
  191. package/dist/work-items/card-labels.js +13 -0
  192. package/dist/work-items/card-labels.js.map +1 -0
  193. package/dist/work-items/card-number.d.ts +10 -0
  194. package/dist/work-items/card-number.d.ts.map +1 -0
  195. package/dist/work-items/card-number.js +15 -0
  196. package/dist/work-items/card-number.js.map +1 -0
  197. package/dist/work-items/card-people.d.ts +25 -0
  198. package/dist/work-items/card-people.d.ts.map +1 -0
  199. package/dist/work-items/card-people.js +100 -0
  200. package/dist/work-items/card-people.js.map +1 -0
  201. package/dist/work-items/card-search-text.d.ts +4 -0
  202. package/dist/work-items/card-search-text.d.ts.map +1 -0
  203. package/dist/work-items/card-search-text.js +15 -0
  204. package/dist/work-items/card-search-text.js.map +1 -0
  205. package/dist/work-items/card-source-filters.d.ts +23 -0
  206. package/dist/work-items/card-source-filters.d.ts.map +1 -0
  207. package/dist/work-items/card-source-filters.js +25 -0
  208. package/dist/work-items/card-source-filters.js.map +1 -0
  209. package/dist/work-items/create-work-item.d.ts +0 -6
  210. package/dist/work-items/create-work-item.d.ts.map +1 -1
  211. package/dist/work-items/create-work-item.js +2 -7
  212. package/dist/work-items/create-work-item.js.map +1 -1
  213. package/dist/work-items/list-related-cards.d.ts +4 -0
  214. package/dist/work-items/list-related-cards.d.ts.map +1 -0
  215. package/dist/work-items/list-related-cards.js +24 -0
  216. package/dist/work-items/list-related-cards.js.map +1 -0
  217. package/dist/work-items/search-words.d.ts +5 -0
  218. package/dist/work-items/search-words.d.ts.map +1 -0
  219. package/dist/work-items/search-words.js +12 -0
  220. package/dist/work-items/search-words.js.map +1 -0
  221. package/dist/workspace.d.ts.map +1 -1
  222. package/dist/workspace.js +92 -47
  223. package/dist/workspace.js.map +1 -1
  224. package/package.json +6 -5
@@ -204,6 +204,14 @@ export interface FactoryIntegration {
204
204
  readonly id: string;
205
205
  /** Issue-oriented capability consumed by Intake. */
206
206
  readonly intake?: Intake;
207
+ /**
208
+ * Further intake settings this integration owns under their own ids (e.g. GitHub's `dependabot`),
209
+ * so the intake config API and UI accept and list sources for them.
210
+ */
211
+ readonly additionalIntakes?: ReadonlyArray<{
212
+ id: string;
213
+ intake: Pick<Intake, 'listSources' | 'listItems'>;
214
+ }>;
207
215
  /** Repository, installation, and pull-request capability. */
208
216
  readonly versionControl?: VersionControl;
209
217
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/integrations/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD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G,SAAS,CAAC;KACnD,GAAG,IAAI,CAAC;IACT;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjF;;;OAGG;IACH,YAAY,CAAC,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,gBAAgB,CAAC;IAC1E;;;;;OAKG;IACH,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,gBAAgB,CAAC,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,0BAA0B,CAAC;QAAC,cAAc,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrH;;;;;;;;OAQG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,kBAAkB,GAAG,YAAY,EAAE,CAAC;IAClD;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;IAC1D;;;OAGG;IACH,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,KAAK,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC9C"}
@@ -0,0 +1,38 @@
1
+ import type { FactoryDependabotEventName, FactoryDependabotRuleContext, FactoryRuleHandler } from '../../rules/types.js';
2
+ export type DependabotEventRules = Readonly<Record<FactoryDependabotEventName, FactoryRuleHandler<FactoryDependabotRuleContext> | null>>;
3
+ export declare function isClosedDependabotState(state: string): boolean;
4
+ declare function dependabotAlertObserved(context: FactoryDependabotRuleContext): {
5
+ readonly type: 'upsertLinkedWorkItem';
6
+ readonly idempotencyKey: `${string}:alert-intake`;
7
+ readonly board: string;
8
+ readonly source: 'github-dependabot-alert';
9
+ readonly sourceKey: string;
10
+ readonly title: string;
11
+ readonly description?: string | undefined;
12
+ readonly url: string;
13
+ readonly stage: string;
14
+ readonly metadata: {
15
+ readonly identifier: `${string}#dependabot-${number}`;
16
+ readonly repository: string;
17
+ readonly number: number;
18
+ readonly state: string;
19
+ readonly severity: string | null;
20
+ readonly packageName: string | null;
21
+ readonly ecosystem: string | null;
22
+ readonly manifestPath: string | null;
23
+ readonly ghsaId: string | null;
24
+ readonly cveId: string | null;
25
+ readonly author: 'dependabot';
26
+ readonly labels: string[];
27
+ readonly sourceCreatedAt: string;
28
+ readonly createdAt: string;
29
+ readonly updatedAt: string;
30
+ };
31
+ } | undefined;
32
+ declare function dependabotAlertClosed(context: FactoryDependabotRuleContext): import("../../rules/types.js").FactoryTransitionDecision | undefined;
33
+ export declare const defaultDependabotRules: Readonly<{
34
+ alertObserved: typeof dependabotAlertObserved;
35
+ alertClosed: typeof dependabotAlertClosed;
36
+ }>;
37
+ export {};
38
+ //# sourceMappingURL=default-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/dependabot/default-rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,4BAA4B,CAAC,GAAG,IAAI,CAAC,CAC5F,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,4BAA4B;mBAI5D,sBAAsB;;;qBAIpB,yBAAyB;;;;;;;iBAO/B,UAAU;iBACV,UAAU;iBACV,MAAM;iBACN,KAAK;iBACL,QAAQ;iBACR,WAAW;iBACX,SAAS;iBACT,YAAY;iBACZ,MAAM;iBACN,KAAK;iBACL,MAAM,EAAE,YAAY;iBACpB,MAAM,EAAuB,MAAM,EAAE;iBACrC,eAAe;iBACf,SAAS;iBACT,SAAS;;cAGd;AAED,iBAAS,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,wEAgBnE;AAED,eAAO,MAAM,sBAAsB;;;EAGF,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { closedByRoutes } from "../../rules/event-rules.js";
2
+ // src/integrations/dependabot/default-rules.ts
3
+ const CLOSED_STATES = /* @__PURE__ */ new Set([
4
+ "dismissed",
5
+ "fixed",
6
+ "auto_dismissed"
7
+ ]);
8
+ function isClosedDependabotState(state) {
9
+ return CLOSED_STATES.has(state);
10
+ }
11
+ function dependabotAlertObserved(context) {
12
+ if (context.item || !context.intake) return;
13
+ const { alert } = context;
14
+ return {
15
+ type: "upsertLinkedWorkItem",
16
+ idempotencyKey: `${context.ingress.id}:alert-intake`,
17
+ board: context.intake.board,
18
+ source: "github-dependabot-alert",
19
+ sourceKey: alert.id,
20
+ title: alert.title,
21
+ ...alert.description ? { description: alert.description } : {},
22
+ url: alert.url,
23
+ stage: context.intake.initialPhase,
24
+ metadata: {
25
+ identifier: `${alert.repository}#dependabot-${alert.number}`,
26
+ repository: alert.repository,
27
+ number: alert.number,
28
+ state: alert.state,
29
+ severity: alert.severity,
30
+ packageName: alert.packageName,
31
+ ecosystem: alert.ecosystem,
32
+ manifestPath: alert.manifestPath,
33
+ ghsaId: alert.ghsaId,
34
+ cveId: alert.cveId,
35
+ author: "dependabot",
36
+ labels: [...alert.labels],
37
+ sourceCreatedAt: alert.createdAt,
38
+ createdAt: alert.createdAt,
39
+ updatedAt: alert.updatedAt
40
+ }
41
+ };
42
+ }
43
+ function dependabotAlertClosed(context) {
44
+ if (!context.item || context.item.source !== "github-dependabot-alert") return;
45
+ const closure = context.boardClosure;
46
+ if (!context.board || !closure || closure.itemTerminal) return;
47
+ if (!isClosedDependabotState(context.alert.state)) return;
48
+ const canceled = context.alert.state !== "fixed";
49
+ const target = canceled ? closure.canceled : closure.completed;
50
+ return closedByRoutes(canceled, {
51
+ idempotencyKey: `${context.ingress.id}:alert-closed`,
52
+ board: context.board,
53
+ stage: target.phase,
54
+ message: { text: `Dependabot alert ${context.alert.repository}#${context.alert.number} was ${context.alert.state.replace("_", " ")}; this ${closure.boardTitle} card was moved to ${target.title}.` }
55
+ });
56
+ }
57
+ const defaultDependabotRules = Object.freeze({
58
+ alertObserved: dependabotAlertObserved,
59
+ alertClosed: dependabotAlertClosed
60
+ });
61
+ export { defaultDependabotRules, isClosedDependabotState };
62
+
63
+ //# sourceMappingURL=default-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/dependabot/default-rules.ts"],"sourcesContent":["import { closedByRoutes } from '../../rules/event-rules.js';\nimport type {\n FactoryDependabotEventName,\n FactoryDependabotRuleContext,\n FactoryRuleHandler,\n} from '../../rules/types.js';\n\nexport type DependabotEventRules = Readonly<\n Record<FactoryDependabotEventName, FactoryRuleHandler<FactoryDependabotRuleContext> | null>\n>;\n\nconst CLOSED_STATES = new Set(['dismissed', 'fixed', 'auto_dismissed']);\n\nexport function isClosedDependabotState(state: string): boolean {\n return CLOSED_STATES.has(state);\n}\n\nfunction dependabotAlertObserved(context: FactoryDependabotRuleContext) {\n if (context.item || !context.intake) return;\n const { alert } = context;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:alert-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: 'github-dependabot-alert',\n sourceKey: alert.id,\n title: alert.title,\n ...(alert.description ? { description: alert.description } : {}),\n url: alert.url,\n stage: context.intake.initialPhase,\n metadata: {\n identifier: `${alert.repository}#dependabot-${alert.number}`,\n repository: alert.repository,\n number: alert.number,\n state: alert.state,\n severity: alert.severity,\n packageName: alert.packageName,\n ecosystem: alert.ecosystem,\n manifestPath: alert.manifestPath,\n ghsaId: alert.ghsaId,\n cveId: alert.cveId,\n author: 'dependabot',\n labels: [...alert.labels] as string[],\n sourceCreatedAt: alert.createdAt,\n createdAt: alert.createdAt,\n updatedAt: alert.updatedAt,\n },\n } as const;\n}\n\nfunction dependabotAlertClosed(context: FactoryDependabotRuleContext) {\n if (!context.item || context.item.source !== 'github-dependabot-alert') return;\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n if (!isClosedDependabotState(context.alert.state)) return;\n // A fix completes the card; any dismissal cancels it.\n const canceled = context.alert.state !== 'fixed';\n const target = canceled ? closure.canceled : closure.completed;\n return closedByRoutes(canceled, {\n idempotencyKey: `${context.ingress.id}:alert-closed`,\n board: context.board,\n stage: target.phase,\n message: {\n text: `Dependabot alert ${context.alert.repository}#${context.alert.number} was ${context.alert.state.replace('_', ' ')}; this ${closure.boardTitle} card was moved to ${target.title}.`,\n },\n });\n}\n\nexport const defaultDependabotRules = Object.freeze({\n alertObserved: dependabotAlertObserved,\n alertClosed: dependabotAlertClosed,\n} satisfies DependabotEventRules);\n"],"mappings":";;AAWA,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAa;CAAS;AAAgB,CAAC;AAEtE,SAAgB,wBAAwB,OAAwB;CAC9D,OAAO,cAAc,IAAI,KAAK;AAChC;AAEA,SAAS,wBAAwB,SAAuC;CACtE,IAAI,QAAQ,QAAQ,CAAC,QAAQ,QAAQ;CACrC,MAAM,EAAE,UAAU;CAClB,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EAEtC,OAAO,QAAQ,OAAO;EACtB,QAAQ;EACR,WAAW,MAAM;EACjB,OAAO,MAAM;EACb,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;EAC9D,KAAK,MAAM;EACX,OAAO,QAAQ,OAAO;EACtB,UAAU;GACR,YAAY,GAAG,MAAM,WAAW,cAAc,MAAM;GACpD,YAAY,MAAM;GAClB,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,UAAU,MAAM;GAChB,aAAa,MAAM;GACnB,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,QAAQ;GACR,QAAQ,CAAC,GAAG,MAAM,MAAM;GACxB,iBAAiB,MAAM;GACvB,WAAW,MAAM;GACjB,WAAW,MAAM;EACnB;CACF;AACF;AAEA,SAAS,sBAAsB,SAAuC;CACpE,IAAI,CAAC,QAAQ,QAAQ,QAAQ,KAAK,WAAW,2BAA2B;CACxE,MAAM,UAAU,QAAQ;CACxB,IAAI,CAAC,QAAQ,SAAS,CAAC,WAAW,QAAQ,cAAc;CACxD,IAAI,CAAC,wBAAwB,QAAQ,MAAM,KAAK,GAAG;CAEnD,MAAM,WAAW,QAAQ,MAAM,UAAU;CACzC,MAAM,SAAS,WAAW,QAAQ,WAAW,QAAQ;CACrD,OAAO,eAAe,UAAU;EAC9B,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EACtC,OAAO,QAAQ;EACf,OAAO,OAAO;EACd,SAAS,EACP,MAAM,oBAAoB,QAAQ,MAAM,WAAW,GAAG,QAAQ,MAAM,OAAO,OAAO,QAAQ,MAAM,MAAM,QAAQ,KAAK,GAAG,EAAE,SAAS,QAAQ,WAAW,qBAAqB,OAAO,MAAM,GACxL;CACF,CAAC;AACH;AAEA,MAAa,yBAAyB,OAAO,OAAO;CAClD,eAAe;CACf,aAAa;AACf,CAAgC"}
@@ -0,0 +1,42 @@
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 { FactoryDependabotRuleContext } 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 { DependabotEventRules } from './default-rules.js';
9
+ /** Labels every Dependabot card carries, so intake routes can match them like any labeled issue. */
10
+ export declare function dependabotLabels(severity: string | null): string[];
11
+ export type DependabotAlertIngress = FactoryDependabotRuleContext['alert'];
12
+ export interface DependabotRulesOptions {
13
+ projects: Pick<FactoryProjectsStorage, 'get'>;
14
+ storage: WorkItemsStorage;
15
+ configVersion: string;
16
+ boards: BoardRegistry | ProjectBoardSource;
17
+ rules?: DependabotEventRules;
18
+ }
19
+ export interface DependabotRulesIngress {
20
+ orgId: string;
21
+ userId: string;
22
+ factoryProjectId: string;
23
+ alerts: DependabotAlertIngress[];
24
+ }
25
+ type IngressStatus = 'committed' | 'replayed' | 'missing';
26
+ /**
27
+ * A first sighting of an open alert creates its card; a fixed or dismissed one closes it. An open
28
+ * alert that already has a card reopens it, which the intake routes apply only to a finished card.
29
+ */
30
+ export declare function boardEventFor(context: Pick<FactoryDependabotRuleContext, 'event' | 'alert' | 'item'>): BoardEventFacts | undefined;
31
+ export declare class DependabotRules {
32
+ #private;
33
+ private readonly options;
34
+ constructor(options: DependabotRulesOptions);
35
+ ingest(input: DependabotRulesIngress): Promise<{
36
+ status: IngressStatus;
37
+ ingested: number;
38
+ }>;
39
+ }
40
+ export declare function attachDependabotRules(context: IntegrationContext): ((input: DependabotRulesIngress) => Promise<unknown>) | undefined;
41
+ export {};
42
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/integrations/dependabot/rules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAA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sB,EAE3D;IAMK,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAwBhG;CAsGF;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,GAC1B,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CASnE"}
@@ -0,0 +1,187 @@
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 { defaultDependabotRules, isClosedDependabotState } from "./default-rules.js";
8
+ // src/integrations/dependabot/rules.ts
9
+ const MAX_STALE_RULE_ATTEMPTS = 3;
10
+ /** Labels every Dependabot card carries, so intake routes can match them like any labeled issue. */
11
+ function dependabotLabels(severity) {
12
+ return [
13
+ "security",
14
+ "dependabot",
15
+ ...severity ? [`severity:${severity}`] : []
16
+ ];
17
+ }
18
+ /**
19
+ * A first sighting of an open alert creates its card; a fixed or dismissed one closes it. An open
20
+ * alert that already has a card reopens it, which the intake routes apply only to a finished card.
21
+ */
22
+ function boardEventFor(context) {
23
+ if (context.event === "alertClosed") return {
24
+ type: "work_item.closed",
25
+ reason: closeReason(context.alert.state !== "fixed")
26
+ };
27
+ return context.item ? { type: "work_item.reopened" } : { type: "work_item.created" };
28
+ }
29
+ var DependabotRules = class {
30
+ options;
31
+ #rules;
32
+ constructor(options) {
33
+ this.options = options;
34
+ this.#rules = options.rules ?? defaultDependabotRules;
35
+ }
36
+ #boards(scope) {
37
+ return toBoardSource(this.options.boards).forProject(scope);
38
+ }
39
+ async ingest(input) {
40
+ if (!await this.options.projects.get({
41
+ orgId: input.orgId,
42
+ id: input.factoryProjectId
43
+ })) return {
44
+ status: "missing",
45
+ ingested: 0
46
+ };
47
+ await toBoardSource(this.options.boards).load(input);
48
+ const items = await this.options.storage.listShared({
49
+ orgId: input.orgId,
50
+ factoryProjectId: input.factoryProjectId
51
+ });
52
+ const itemsBySourceKey = new Map(items.filter((item) => item.externalSource?.integrationId === "github" && item.externalSource.type === "dependabot-alert").map((item) => [item.externalSource?.externalId, item]));
53
+ const statuses = [];
54
+ for (const alert of input.alerts) {
55
+ const relatedItem = itemsBySourceKey.get(alert.id);
56
+ statuses.push(await this.#ingestAlert(input, alert, relatedItem && structuredClone(relatedItem)));
57
+ }
58
+ if (statuses.includes("committed")) return {
59
+ status: "committed",
60
+ ingested: statuses.length
61
+ };
62
+ if (statuses.includes("replayed")) return {
63
+ status: "replayed",
64
+ ingested: statuses.length
65
+ };
66
+ return {
67
+ status: "missing",
68
+ ingested: statuses.length
69
+ };
70
+ }
71
+ async #ingestAlert(input, alert, relatedItem, attempt = 1) {
72
+ const closed = isClosedDependabotState(alert.state);
73
+ if (closed && !relatedItem) return "missing";
74
+ const ingressId = `dependabot:${alert.id}:${alert.state}:${alert.updatedAt}`;
75
+ const actor = {
76
+ type: "human",
77
+ id: input.userId
78
+ };
79
+ const event = closed ? "alertClosed" : "alertObserved";
80
+ const boards = this.#boards(input);
81
+ const context = {
82
+ tenant: {
83
+ orgId: input.orgId,
84
+ projectId: input.factoryProjectId
85
+ },
86
+ actor,
87
+ ingress: {
88
+ type: "github",
89
+ id: ingressId
90
+ },
91
+ cause: `dependabot.${event}`,
92
+ causalChain: [],
93
+ configVersion: this.options.configVersion,
94
+ ...relatedItem ? {
95
+ item: {
96
+ id: relatedItem.id,
97
+ source: "github-dependabot-alert",
98
+ sourceKey: relatedItem.externalSource?.externalId ?? null,
99
+ parentWorkItemId: relatedItem.parentWorkItemId,
100
+ title: relatedItem.title,
101
+ url: relatedItem.externalSource?.url ?? null,
102
+ stages: relatedItem.stages,
103
+ workItem: relatedItem.workItem,
104
+ acceptedAt: relatedItem.acceptedAt,
105
+ metadata: relatedItem.metadata
106
+ },
107
+ board: boardForWorkItem(relatedItem),
108
+ itemRevision: relatedItem.revision,
109
+ ...withBoardClosure(boards, relatedItem),
110
+ ...rulePhaseField(boards, relatedItem)
111
+ } : {},
112
+ ...withIntakeTarget(boards),
113
+ event,
114
+ alert
115
+ };
116
+ const boardEvent = boardEventFor(context);
117
+ if (boardEvent) context.boardEvent = boardEvent;
118
+ const rule = this.#rules[event];
119
+ let decision = void 0;
120
+ let decisions = [];
121
+ let outcome = { status: "accepted" };
122
+ try {
123
+ decision = rule ? await rule(Object.freeze(context)) : void 0;
124
+ if (decision?.type === "reject") outcome = {
125
+ status: "rejected",
126
+ code: decision.code,
127
+ reason: decision.reason
128
+ };
129
+ else if (decision) decisions = validateFactoryRuleDecisions([decision]).map((entry) => {
130
+ assertFactoryDecisionTarget(entry, boards, relatedItem ? boardForWorkItem(relatedItem) : void 0);
131
+ return { ...entry };
132
+ });
133
+ } catch (error) {
134
+ outcome = {
135
+ status: "rejected",
136
+ code: "rule_error",
137
+ reason: error instanceof Error ? error.message.slice(0, 2e3) : "Factory Dependabot rule failed."
138
+ };
139
+ }
140
+ if (!decision && outcome.status === "accepted") {
141
+ const routed = await routeEventDecision(context, this.options.storage, {
142
+ orgId: input.orgId,
143
+ factoryProjectId: input.factoryProjectId
144
+ });
145
+ if (routed) decisions = [{ ...routed }];
146
+ }
147
+ const committed = await this.options.storage.commitRuleEvaluation({
148
+ orgId: input.orgId,
149
+ factoryProjectId: input.factoryProjectId,
150
+ workItemId: relatedItem?.id ?? null,
151
+ ingress: {
152
+ identity: ingressId,
153
+ triggerType: `dependabot.${event}`
154
+ },
155
+ configVersion: this.options.configVersion,
156
+ expectedRevision: relatedItem?.revision ?? null,
157
+ actor,
158
+ outcome,
159
+ decisions,
160
+ causalChain: [],
161
+ now: /* @__PURE__ */ new Date()
162
+ });
163
+ if (committed.status === "stale") {
164
+ if (attempt >= MAX_STALE_RULE_ATTEMPTS) throw new Error(`Factory Dependabot rule evaluation for ${ingressId} kept losing revision races.`);
165
+ const fresh = relatedItem ? await this.options.storage.get({
166
+ orgId: input.orgId,
167
+ id: relatedItem.id
168
+ }) : null;
169
+ if (relatedItem && !fresh) return "missing";
170
+ return this.#ingestAlert(input, alert, fresh ?? void 0, attempt + 1);
171
+ }
172
+ return committed.status;
173
+ }
174
+ };
175
+ function attachDependabotRules(context) {
176
+ if (!context.runtime) return void 0;
177
+ const rules = new DependabotRules({
178
+ projects: context.storage.projects,
179
+ storage: context.runtime.workItems,
180
+ configVersion: context.runtime.configVersion,
181
+ boards: context.runtime.boards
182
+ });
183
+ return (input) => rules.ingest(input);
184
+ }
185
+ export { DependabotRules, attachDependabotRules, boardEventFor, dependabotLabels };
186
+
187
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../../../src/integrations/dependabot/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 { FactoryDependabotRuleContext, 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 { defaultDependabotRules, isClosedDependabotState } from './default-rules.js';\nimport type { DependabotEventRules } from './default-rules.js';\n\nconst MAX_STALE_RULE_ATTEMPTS = 3;\n\n/** Labels every Dependabot card carries, so intake routes can match them like any labeled issue. */\nexport function dependabotLabels(severity: string | null): string[] {\n return ['security', 'dependabot', ...(severity ? [`severity:${severity}`] : [])];\n}\n\nexport type DependabotAlertIngress = FactoryDependabotRuleContext['alert'];\n\nexport interface DependabotRulesOptions {\n projects: Pick<FactoryProjectsStorage, 'get'>;\n storage: WorkItemsStorage;\n configVersion: string;\n boards: BoardRegistry | ProjectBoardSource;\n rules?: DependabotEventRules;\n}\n\nexport interface DependabotRulesIngress {\n orgId: string;\n userId: string;\n factoryProjectId: string;\n alerts: DependabotAlertIngress[];\n}\n\ntype IngressStatus = 'committed' | 'replayed' | 'missing';\n\n/**\n * A first sighting of an open alert creates its card; a fixed or dismissed one closes it. An open\n * alert that already has a card reopens it, which the intake routes apply only to a finished card.\n */\nexport function boardEventFor(\n context: Pick<FactoryDependabotRuleContext, 'event' | 'alert' | 'item'>,\n): BoardEventFacts | undefined {\n if (context.event === 'alertClosed') {\n return { type: 'work_item.closed', reason: closeReason(context.alert.state !== 'fixed') };\n }\n return context.item ? { type: 'work_item.reopened' } : { type: 'work_item.created' };\n}\n\nexport class DependabotRules {\n readonly #rules: DependabotEventRules;\n\n constructor(private readonly options: DependabotRulesOptions) {\n this.#rules = options.rules ?? defaultDependabotRules;\n }\n\n #boards(scope: StoredBoardScope): BoardRegistry {\n return toBoardSource(this.options.boards).forProject(scope);\n }\n\n async ingest(input: DependabotRulesIngress): 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({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n });\n const itemsBySourceKey = new Map(\n items\n .filter(\n item => item.externalSource?.integrationId === 'github' && item.externalSource.type === 'dependabot-alert',\n )\n .map(item => [item.externalSource?.externalId, item]),\n );\n const statuses: IngressStatus[] = [];\n for (const alert of input.alerts) {\n const relatedItem = itemsBySourceKey.get(alert.id);\n statuses.push(await this.#ingestAlert(input, alert, relatedItem && structuredClone(relatedItem)));\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: DependabotRulesIngress,\n alert: DependabotAlertIngress,\n relatedItem: Card | undefined,\n attempt = 1,\n ): Promise<IngressStatus> {\n const closed = isClosedDependabotState(alert.state);\n // A closed alert Factory never filed stays off the board.\n if (closed && !relatedItem) return 'missing';\n\n const ingressId = `dependabot:${alert.id}:${alert.state}:${alert.updatedAt}`;\n const actor = { type: 'human' as const, id: input.userId };\n const event = closed ? 'alertClosed' : 'alertObserved';\n const boards = this.#boards(input);\n const context: FactoryDependabotRuleContext = {\n tenant: { orgId: input.orgId, projectId: input.factoryProjectId },\n actor,\n ingress: { type: 'github', id: ingressId },\n cause: `dependabot.${event}`,\n causalChain: [],\n configVersion: this.options.configVersion,\n ...(relatedItem\n ? {\n item: {\n id: relatedItem.id,\n source: 'github-dependabot-alert',\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 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 Dependabot 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: `dependabot.${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 Dependabot 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 attachDependabotRules(\n context: IntegrationContext,\n): ((input: DependabotRulesIngress) => Promise<unknown>) | undefined {\n if (!context.runtime) return undefined;\n const rules = new DependabotRules({\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":";;;;;;;;AAgBA,MAAM,0BAA0B;;AAGhC,SAAgB,iBAAiB,UAAmC;CAClE,OA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I,eAAe,CAAC,OAAO,OAAO;GAClC,OAAO,KAAK,aAAa,OAAO,OAAO,SAAS,KAAA,GAAW,UAAU,CAAC;EACxE;EACA,OAAO,UAAU;CACnB;AACF;AAEA,SAAgB,sBACd,SACmE;CACnE,IAAI,CAAC,QAAQ,SAAS,OAAO,KAAA;CAC7B,MAAM,QAAQ,IAAI,gBAAgB;EAChC,UAAU,QAAQ,QAAQ;EAC1B,SAAS,QAAQ,QAAQ;EACzB,eAAe,QAAQ,QAAQ;EAC/B,QAAQ,QAAQ,QAAQ;CAC1B,CAAC;CACD,QAAO,UAAS,MAAM,OAAO,KAAK;AACpC"}
@@ -0,0 +1,76 @@
1
+ import type { ReconcileRepository } from '../github/rules.js';
2
+ import type { DependabotAlertIngress, DependabotRulesIngress } from './rules.js';
3
+ export declare const DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS: number;
4
+ /** The subset of GitHub's Dependabot alert payload Factory reads. */
5
+ export interface GithubDependabotAlert {
6
+ number: number;
7
+ state: string;
8
+ html_url?: string;
9
+ created_at?: string;
10
+ updated_at?: string;
11
+ dependency?: {
12
+ package?: {
13
+ name?: string;
14
+ ecosystem?: string;
15
+ } | null;
16
+ manifest_path?: string | null;
17
+ } | null;
18
+ security_advisory?: {
19
+ ghsa_id?: string;
20
+ cve_id?: string | null;
21
+ summary?: string;
22
+ description?: string | null;
23
+ severity?: string;
24
+ } | null;
25
+ security_vulnerability?: {
26
+ severity?: string;
27
+ vulnerable_version_range?: string | null;
28
+ first_patched_version?: {
29
+ identifier?: string;
30
+ } | null;
31
+ } | null;
32
+ }
33
+ /**
34
+ * Lists a repository's Dependabot alerts in the given states. Throws when the alerts
35
+ * can't be read (Dependabot alerts disabled, missing permission, proxy error).
36
+ */
37
+ export type DependabotAlertLister = (input: {
38
+ installationId: number;
39
+ repository: string;
40
+ state: 'open' | 'closed';
41
+ }) => Promise<GithubDependabotAlert[]>;
42
+ export interface DependabotSyncSummary {
43
+ repositories: number;
44
+ alerts: number;
45
+ failed: number;
46
+ errors: Array<{
47
+ repository: string;
48
+ error: string;
49
+ }>;
50
+ }
51
+ export type DependabotSync = (targets: ReconcileRepository[]) => Promise<DependabotSyncSummary>;
52
+ export declare function truncateDescription(text: string): string;
53
+ export declare function toDependabotIngress(repository: string, alert: GithubDependabotAlert): DependabotAlertIngress;
54
+ /**
55
+ * Reads each linked repository's open and recently closed Dependabot alerts and hands them to
56
+ * every Factory project the repository is linked to. A repository whose alerts can't be read is
57
+ * counted as failed and skipped; the rest of the sweep carries on.
58
+ */
59
+ export declare function createDependabotSync(options: {
60
+ listAlerts: DependabotAlertLister;
61
+ listProjects: (input: {
62
+ installationExternalId: string;
63
+ repositoryExternalId: string;
64
+ }) => Promise<ReadonlyArray<{
65
+ orgId: string;
66
+ factoryProjectId: string;
67
+ }>>;
68
+ /** Opt-in gate: whether the org chose to sync Dependabot alerts for this repository. */
69
+ repositoryEnabled: (input: {
70
+ orgId: string;
71
+ repository: string;
72
+ }) => Promise<boolean>;
73
+ ingest: (input: DependabotRulesIngress) => Promise<unknown>;
74
+ userId: string;
75
+ }): DependabotSync;
76
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/integrations/dependabot/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEjF,eAAO,MAAM,mCAAmC,QAAc,CAAC;AAE/D,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE;QAAE,OAAO,CA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BAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAuB5G;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,UAAU,EAAE,qBAAqB,CAAC;IAClC,YAAY,EAAE,CAAC,KAAK,EAAE;QACpB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,oBAAoB,EAAE,MAAM,CAAC;KAC9B,KAAK,OAAO,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1E,wFAAwF;IACxF,iBAAiB,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtF,MAAM,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,cAAc,CAiDjB"}
@@ -0,0 +1,111 @@
1
+ import { dependabotLabels } from "./rules.js";
2
+ // src/integrations/dependabot/sync.ts
3
+ const DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS = 9e5;
4
+ function dependabotDescription(alert) {
5
+ const advisory = alert.security_advisory;
6
+ const vulnerability = alert.security_vulnerability;
7
+ const facts = [
8
+ alert.dependency?.package?.name && `**Package:** \`${alert.dependency.package.name}\`${alert.dependency.package.ecosystem ? ` (${alert.dependency.package.ecosystem})` : ""}`,
9
+ alert.dependency?.manifest_path && `**Manifest:** \`${alert.dependency.manifest_path}\``,
10
+ (advisory?.severity ?? vulnerability?.severity) && `**Severity:** ${advisory?.severity ?? vulnerability?.severity}`,
11
+ vulnerability?.vulnerable_version_range && `**Vulnerable versions:** \`${vulnerability.vulnerable_version_range}\``,
12
+ vulnerability?.first_patched_version?.identifier && `**Patched in:** \`${vulnerability.first_patched_version.identifier}\``,
13
+ [advisory?.ghsa_id, advisory?.cve_id].filter(Boolean).length > 0 && `**Advisory:** ${[advisory?.ghsa_id, advisory?.cve_id].filter(Boolean).join(", ")}`
14
+ ].filter((fact) => typeof fact === "string");
15
+ const parts = [
16
+ advisory?.summary?.trim(),
17
+ facts.map((fact) => `- ${fact}`).join("\n"),
18
+ advisory?.description?.trim()
19
+ ].filter(Boolean);
20
+ return parts.length > 0 ? truncateDescription(parts.join("\n\n")) : null;
21
+ }
22
+ const MAX_DESCRIPTION_LENGTH = 8e3;
23
+ function truncateDescription(text) {
24
+ return text.length <= MAX_DESCRIPTION_LENGTH ? text : `${text.slice(0, 7999)}…`;
25
+ }
26
+ function toDependabotIngress(repository, alert) {
27
+ const severity = alert.security_advisory?.severity ?? alert.security_vulnerability?.severity ?? null;
28
+ const packageName = alert.dependency?.package?.name ?? null;
29
+ const summary = alert.security_advisory?.summary ?? `Dependabot alert #${alert.number}`;
30
+ const createdAt = alert.created_at ?? (/* @__PURE__ */ new Date(0)).toISOString();
31
+ return {
32
+ id: `${repository}#dependabot-${alert.number}`,
33
+ number: alert.number,
34
+ repository,
35
+ title: packageName ? `${packageName}: ${summary}` : summary,
36
+ url: alert.html_url ?? `https://github.com/${repository}/security/dependabot/${alert.number}`,
37
+ state: alert.state,
38
+ severity,
39
+ packageName,
40
+ ecosystem: alert.dependency?.package?.ecosystem ?? null,
41
+ manifestPath: alert.dependency?.manifest_path ?? null,
42
+ description: dependabotDescription(alert),
43
+ ghsaId: alert.security_advisory?.ghsa_id ?? null,
44
+ cveId: alert.security_advisory?.cve_id ?? null,
45
+ labels: dependabotLabels(severity),
46
+ createdAt,
47
+ updatedAt: alert.updated_at ?? createdAt
48
+ };
49
+ }
50
+ /**
51
+ * Reads each linked repository's open and recently closed Dependabot alerts and hands them to
52
+ * every Factory project the repository is linked to. A repository whose alerts can't be read is
53
+ * counted as failed and skipped; the rest of the sweep carries on.
54
+ */
55
+ function createDependabotSync(options) {
56
+ return async (targets) => {
57
+ const summary = {
58
+ repositories: 0,
59
+ alerts: 0,
60
+ failed: 0,
61
+ errors: []
62
+ };
63
+ for (const target of targets) try {
64
+ const linked = await options.listProjects({
65
+ installationExternalId: String(target.installationId),
66
+ repositoryExternalId: String(target.id)
67
+ });
68
+ const projects = [];
69
+ for (const project of linked) if (await options.repositoryEnabled({
70
+ orgId: project.orgId,
71
+ repository: target.fullName
72
+ })) projects.push(project);
73
+ if (projects.length === 0) continue;
74
+ const [open, closed] = await Promise.all([options.listAlerts({
75
+ installationId: target.installationId,
76
+ repository: target.fullName,
77
+ state: "open"
78
+ }), options.listAlerts({
79
+ installationId: target.installationId,
80
+ repository: target.fullName,
81
+ state: "closed"
82
+ })]);
83
+ const alerts = [...open, ...closed].map((alert) => toDependabotIngress(target.fullName, alert));
84
+ for (const project of projects) try {
85
+ await options.ingest({
86
+ orgId: project.orgId,
87
+ userId: options.userId,
88
+ factoryProjectId: project.factoryProjectId,
89
+ alerts
90
+ });
91
+ } catch (error) {
92
+ summary.errors.push({
93
+ repository: target.fullName,
94
+ error: error instanceof Error ? error.message : String(error)
95
+ });
96
+ }
97
+ summary.repositories += 1;
98
+ summary.alerts += alerts.length;
99
+ } catch (error) {
100
+ summary.failed += 1;
101
+ summary.errors.push({
102
+ repository: target.fullName,
103
+ error: error instanceof Error ? error.message : String(error)
104
+ });
105
+ }
106
+ return summary;
107
+ };
108
+ }
109
+ export { DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS, createDependabotSync, toDependabotIngress, truncateDescription };
110
+
111
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","names":[],"sources":["../../../src/integrations/dependabot/sync.ts"],"sourcesContent":["import type { ReconcileRepository } from '../github/rules.js';\nimport { dependabotLabels } from './rules.js';\nimport type { DependabotAlertIngress, DependabotRulesIngress } from './rules.js';\n\nexport const DEFAULT_DEPENDABOT_SYNC_INTERVAL_MS = 15 * 60_000;\n\n/** The subset of GitHub's Dependabot alert payload Factory reads. */\nexport interface GithubDependabotAlert {\n number: number;\n state: string;\n html_url?: string;\n created_at?: string;\n updated_at?: string;\n dependency?: { package?: { name?: string; ecosystem?: string } | null; manifest_path?: string | null } | null;\n security_advisory?: {\n ghsa_id?: string;\n cve_id?: string | null;\n summary?: string;\n description?: string | null;\n severity?: string;\n } | null;\n security_vulnerability?: {\n severity?: string;\n vulnerable_version_range?: string | null;\n first_patched_version?: { identifier?: string } | null;\n } | null;\n}\n\n/**\n * Lists a repository's Dependabot alerts in the given states. Throws when the alerts\n * can't be read (Dependabot alerts disabled, missing permission, proxy error).\n */\nexport type DependabotAlertLister = (input: {\n installationId: number;\n repository: string;\n state: 'open' | 'closed';\n}) => Promise<GithubDependabotAlert[]>;\n\nexport interface DependabotSyncSummary {\n repositories: number;\n alerts: number;\n failed: number;\n errors: Array<{ repository: string; error: string }>;\n}\n\nexport type DependabotSync = (targets: ReconcileRepository[]) => Promise<DependabotSyncSummary>;\n\nfunction dependabotDescription(alert: GithubDependabotAlert): string | null {\n const advisory = alert.security_advisory;\n const vulnerability = alert.security_vulnerability;\n const facts = [\n alert.dependency?.package?.name &&\n `**Package:** \\`${alert.dependency.package.name}\\`${alert.dependency.package.ecosystem ? ` (${alert.dependency.package.ecosystem})` : ''}`,\n alert.dependency?.manifest_path && `**Manifest:** \\`${alert.dependency.manifest_path}\\``,\n (advisory?.severity ?? vulnerability?.severity) && `**Severity:** ${advisory?.severity ?? vulnerability?.severity}`,\n vulnerability?.vulnerable_version_range && `**Vulnerable versions:** \\`${vulnerability.vulnerable_version_range}\\``,\n vulnerability?.first_patched_version?.identifier &&\n `**Patched in:** \\`${vulnerability.first_patched_version.identifier}\\``,\n [advisory?.ghsa_id, advisory?.cve_id].filter(Boolean).length > 0 &&\n `**Advisory:** ${[advisory?.ghsa_id, advisory?.cve_id].filter(Boolean).join(', ')}`,\n ].filter((fact): fact is string => typeof fact === 'string');\n const parts = [\n advisory?.summary?.trim(),\n facts.map(fact => `- ${fact}`).join('\\n'),\n advisory?.description?.trim(),\n ].filter(Boolean);\n return parts.length > 0 ? truncateDescription(parts.join('\\n\\n')) : null;\n}\n\nconst MAX_DESCRIPTION_LENGTH = 8000;\n\nexport function truncateDescription(text: string): string {\n return text.length <= MAX_DESCRIPTION_LENGTH ? text : `${text.slice(0, MAX_DESCRIPTION_LENGTH - 1)}…`;\n}\n\nexport function toDependabotIngress(repository: string, alert: GithubDependabotAlert): DependabotAlertIngress {\n const severity = alert.security_advisory?.severity ?? alert.security_vulnerability?.severity ?? null;\n const packageName = alert.dependency?.package?.name ?? null;\n const summary = alert.security_advisory?.summary ?? `Dependabot alert #${alert.number}`;\n const createdAt = alert.created_at ?? new Date(0).toISOString();\n return {\n id: `${repository}#dependabot-${alert.number}`,\n number: alert.number,\n repository,\n title: packageName ? `${packageName}: ${summary}` : summary,\n url: alert.html_url ?? `https://github.com/${repository}/security/dependabot/${alert.number}`,\n state: alert.state,\n severity,\n packageName,\n ecosystem: alert.dependency?.package?.ecosystem ?? null,\n manifestPath: alert.dependency?.manifest_path ?? null,\n description: dependabotDescription(alert),\n ghsaId: alert.security_advisory?.ghsa_id ?? null,\n cveId: alert.security_advisory?.cve_id ?? null,\n labels: dependabotLabels(severity),\n createdAt,\n updatedAt: alert.updated_at ?? createdAt,\n };\n}\n\n/**\n * Reads each linked repository's open and recently closed Dependabot alerts and hands them to\n * every Factory project the repository is linked to. A repository whose alerts can't be read is\n * counted as failed and skipped; the rest of the sweep carries on.\n */\nexport function createDependabotSync(options: {\n listAlerts: DependabotAlertLister;\n listProjects: (input: {\n installationExternalId: string;\n repositoryExternalId: string;\n }) => Promise<ReadonlyArray<{ orgId: string; factoryProjectId: string }>>;\n /** Opt-in gate: whether the org chose to sync Dependabot alerts for this repository. */\n repositoryEnabled: (input: { orgId: string; repository: string }) => Promise<boolean>;\n ingest: (input: DependabotRulesIngress) => Promise<unknown>;\n userId: string;\n}): DependabotSync {\n return async targets => {\n const summary: DependabotSyncSummary = { repositories: 0, alerts: 0, failed: 0, errors: [] };\n for (const target of targets) {\n try {\n const linked = await options.listProjects({\n installationExternalId: String(target.installationId),\n repositoryExternalId: String(target.id),\n });\n const projects = [];\n for (const project of linked) {\n if (await options.repositoryEnabled({ orgId: project.orgId, repository: target.fullName })) {\n projects.push(project);\n }\n }\n if (projects.length === 0) continue;\n const [open, closed] = await Promise.all([\n options.listAlerts({ installationId: target.installationId, repository: target.fullName, state: 'open' }),\n options.listAlerts({ installationId: target.installationId, repository: target.fullName, state: 'closed' }),\n ]);\n const alerts = [...open, ...closed].map(alert => toDependabotIngress(target.fullName, alert));\n // One project's failed ingest is reported without starving the others linked to the repo.\n for (const project of projects) {\n try {\n await options.ingest({\n orgId: project.orgId,\n userId: options.userId,\n factoryProjectId: project.factoryProjectId,\n alerts,\n });\n } catch (error) {\n summary.errors.push({\n repository: target.fullName,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n summary.repositories += 1;\n summary.alerts += alerts.length;\n } catch (error) {\n summary.failed += 1;\n summary.errors.push({\n repository: target.fullName,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return summary;\n };\n}\n"],"mappings":";;AAIA,MAAa,sCAAsC;AA2CnD,SAAS,sBAAsB,OAA6C;CAC1E,MAAM,WAAW,MAAM;CACvB,MAAM,gBAAgB,MAAM;CAC5B,MAAM,QAAQ;EACZ,MAAM,YAAY,SAAS,QACzB,kBAAkB,MAAM,WAAW,QAAQ,KAAK,IAAI,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,WAAW,QAAQ,UAAU,KAAK;EACxI,MAAM,YAAY,iBAAiB,mBAAmB,MAAM,WAAW,cAAc;GACpF,UAAU,YAAY,eAAe,aAAa,iBAAiB,UAAU,YAAY,eAAe;EACzG,eAAe,4BAA4B,8BAA8B,cAAc,yBAAyB;EAChH,eAAe,uBAAuB,cACpC,q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