@mastra/factory 0.28.0-alpha.9 → 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 (348) hide show
  1. package/README.md +67 -46
  2. package/dist/boards/board-writes.d.ts +3 -3
  3. package/dist/boards/board-writes.d.ts.map +1 -1
  4. package/dist/boards/board-writes.js +24 -20
  5. package/dist/boards/board-writes.js.map +1 -1
  6. package/dist/boards/project-boards.d.ts +20 -0
  7. package/dist/boards/project-boards.d.ts.map +1 -1
  8. package/dist/boards/project-boards.js +35 -11
  9. package/dist/boards/project-boards.js.map +1 -1
  10. package/dist/boards/registry.d.ts.map +1 -1
  11. package/dist/boards/registry.js +0 -3
  12. package/dist/boards/registry.js.map +1 -1
  13. package/dist/boards/reroute.d.ts +31 -0
  14. package/dist/boards/reroute.d.ts.map +1 -0
  15. package/dist/boards/reroute.js +71 -0
  16. package/dist/boards/reroute.js.map +1 -0
  17. package/dist/capabilities/version-control.d.ts +6 -1
  18. package/dist/capabilities/version-control.d.ts.map +1 -1
  19. package/dist/environment/build-runner.d.ts +13 -2
  20. package/dist/environment/build-runner.d.ts.map +1 -1
  21. package/dist/environment/build-runner.js +42 -0
  22. package/dist/environment/build-runner.js.map +1 -1
  23. package/dist/environment/build-schedule.js +1 -1
  24. package/dist/environment/build-schedule.js.map +1 -1
  25. package/dist/environment/build-workflow.d.ts +6 -4
  26. package/dist/environment/build-workflow.d.ts.map +1 -1
  27. package/dist/environment/build-workflow.js +70 -66
  28. package/dist/environment/build-workflow.js.map +1 -1
  29. package/dist/environment/build.d.ts +22 -7
  30. package/dist/environment/build.d.ts.map +1 -1
  31. package/dist/environment/build.js +73 -15
  32. package/dist/environment/build.js.map +1 -1
  33. package/dist/environment/heads.d.ts +1 -1
  34. package/dist/environment/heads.d.ts.map +1 -1
  35. package/dist/environment/heads.js +4 -1
  36. package/dist/environment/heads.js.map +1 -1
  37. package/dist/environment/repository-access.d.ts +15 -0
  38. package/dist/environment/repository-access.d.ts.map +1 -0
  39. package/dist/environment/repository-access.js +60 -0
  40. package/dist/environment/repository-access.js.map +1 -0
  41. package/dist/factory.d.ts +5 -2
  42. package/dist/factory.d.ts.map +1 -1
  43. package/dist/factory.js +40 -30
  44. package/dist/factory.js.map +1 -1
  45. package/dist/integrations/base.d.ts +8 -0
  46. package/dist/integrations/base.d.ts.map +1 -1
  47. package/dist/integrations/dependabot/default-rules.d.ts +38 -0
  48. package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
  49. package/dist/integrations/dependabot/default-rules.js +63 -0
  50. package/dist/integrations/dependabot/default-rules.js.map +1 -0
  51. package/dist/integrations/dependabot/rules.d.ts +42 -0
  52. package/dist/integrations/dependabot/rules.d.ts.map +1 -0
  53. package/dist/integrations/dependabot/rules.js +187 -0
  54. package/dist/integrations/dependabot/rules.js.map +1 -0
  55. package/dist/integrations/dependabot/sync.d.ts +76 -0
  56. package/dist/integrations/dependabot/sync.d.ts.map +1 -0
  57. package/dist/integrations/dependabot/sync.js +111 -0
  58. package/dist/integrations/dependabot/sync.js.map +1 -0
  59. package/dist/integrations/github/routes.d.ts.map +1 -1
  60. package/dist/integrations/github/routes.js +7 -2
  61. package/dist/integrations/github/routes.js.map +1 -1
  62. package/dist/integrations/github/sandbox-release.d.ts +12 -0
  63. package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
  64. package/dist/integrations/github/sandbox-release.js +16 -1
  65. package/dist/integrations/github/sandbox-release.js.map +1 -1
  66. package/dist/integrations/github/sandbox.d.ts +12 -0
  67. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  68. package/dist/integrations/github/sandbox.js +22 -1
  69. package/dist/integrations/github/sandbox.js.map +1 -1
  70. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  71. package/dist/integrations/platform/connect/routes.js +4 -0
  72. package/dist/integrations/platform/connect/routes.js.map +1 -1
  73. package/dist/integrations/platform/github/event-worker.d.ts +5 -0
  74. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  75. package/dist/integrations/platform/github/event-worker.js +33 -2
  76. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  77. package/dist/integrations/platform/github/integration.d.ts +19 -1
  78. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  79. package/dist/integrations/platform/github/integration.js +183 -105
  80. package/dist/integrations/platform/github/integration.js.map +1 -1
  81. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  82. package/dist/integrations/platform/jira/integration.js +5 -1
  83. package/dist/integrations/platform/jira/integration.js.map +1 -1
  84. package/dist/integrations/platform/vanta/integration.d.ts +33 -0
  85. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
  86. package/dist/integrations/platform/vanta/integration.js +133 -0
  87. package/dist/integrations/platform/vanta/integration.js.map +1 -0
  88. package/dist/integrations/slack/integration.d.ts.map +1 -1
  89. package/dist/integrations/slack/integration.js +7 -4
  90. package/dist/integrations/slack/integration.js.map +1 -1
  91. package/dist/integrations/vanta/default-rules.d.ts +34 -0
  92. package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
  93. package/dist/integrations/vanta/default-rules.js +61 -0
  94. package/dist/integrations/vanta/default-rules.js.map +1 -0
  95. package/dist/integrations/vanta/rules.d.ts +40 -0
  96. package/dist/integrations/vanta/rules.d.ts.map +1 -0
  97. package/dist/integrations/vanta/rules.js +208 -0
  98. package/dist/integrations/vanta/rules.js.map +1 -0
  99. package/dist/integrations/vanta/sync.d.ts +36 -0
  100. package/dist/integrations/vanta/sync.d.ts.map +1 -0
  101. package/dist/integrations/vanta/sync.js +73 -0
  102. package/dist/integrations/vanta/sync.js.map +1 -0
  103. package/dist/mcp/routes.d.ts.map +1 -1
  104. package/dist/mcp/routes.js +3 -5
  105. package/dist/mcp/routes.js.map +1 -1
  106. package/dist/routes/board-snapshot.d.ts +24 -1
  107. package/dist/routes/board-snapshot.d.ts.map +1 -1
  108. package/dist/routes/board-snapshot.js +75 -7
  109. package/dist/routes/board-snapshot.js.map +1 -1
  110. package/dist/routes/boards.d.ts +2 -3
  111. package/dist/routes/boards.d.ts.map +1 -1
  112. package/dist/routes/boards.js.map +1 -1
  113. package/dist/routes/contracts.d.ts +307 -0
  114. package/dist/routes/contracts.d.ts.map +1 -1
  115. package/dist/routes/contracts.js +253 -9
  116. package/dist/routes/contracts.js.map +1 -1
  117. package/dist/routes/intake-routes.d.ts +3 -0
  118. package/dist/routes/intake-routes.d.ts.map +1 -1
  119. package/dist/routes/intake-routes.js +44 -0
  120. package/dist/routes/intake-routes.js.map +1 -1
  121. package/dist/routes/knowledge.d.ts.map +1 -1
  122. package/dist/routes/knowledge.js +3 -2
  123. package/dist/routes/knowledge.js.map +1 -1
  124. package/dist/routes/projects.d.ts.map +1 -1
  125. package/dist/routes/projects.js +5 -0
  126. package/dist/routes/projects.js.map +1 -1
  127. package/dist/routes/sandbox-envs.d.ts +2 -0
  128. package/dist/routes/sandbox-envs.d.ts.map +1 -1
  129. package/dist/routes/sandbox-envs.js +3 -0
  130. package/dist/routes/sandbox-envs.js.map +1 -1
  131. package/dist/routes/source-control-sessions.d.ts +1 -1
  132. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  133. package/dist/routes/source-control-sessions.js +109 -3
  134. package/dist/routes/source-control-sessions.js.map +1 -1
  135. package/dist/routes/source-control-settings.d.ts +2 -0
  136. package/dist/routes/source-control-settings.d.ts.map +1 -1
  137. package/dist/routes/source-control-settings.js +5 -0
  138. package/dist/routes/source-control-settings.js.map +1 -1
  139. package/dist/routes/surface.d.ts +8 -1
  140. package/dist/routes/surface.d.ts.map +1 -1
  141. package/dist/routes/surface.js +74 -10
  142. package/dist/routes/surface.js.map +1 -1
  143. package/dist/routes/work-item-activity.d.ts +11 -0
  144. package/dist/routes/work-item-activity.d.ts.map +1 -0
  145. package/dist/routes/work-item-activity.js +25 -0
  146. package/dist/routes/work-item-activity.js.map +1 -0
  147. package/dist/routes/work-item-selection.d.ts +14 -0
  148. package/dist/routes/work-item-selection.d.ts.map +1 -0
  149. package/dist/routes/work-item-selection.js +44 -0
  150. package/dist/routes/work-item-selection.js.map +1 -0
  151. package/dist/routes/work-item-starters.d.ts +29 -0
  152. package/dist/routes/work-item-starters.d.ts.map +1 -0
  153. package/dist/routes/work-item-starters.js +152 -0
  154. package/dist/routes/work-item-starters.js.map +1 -0
  155. package/dist/routes/work-items.d.ts.map +1 -1
  156. package/dist/routes/work-items.js +239 -16
  157. package/dist/routes/work-items.js.map +1 -1
  158. package/dist/rules/dispatch-errors.d.ts +3 -0
  159. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  160. package/dist/rules/dispatch-errors.js +9 -0
  161. package/dist/rules/dispatch-errors.js.map +1 -1
  162. package/dist/rules/dispatcher.d.ts +4 -1
  163. package/dist/rules/dispatcher.d.ts.map +1 -1
  164. package/dist/rules/dispatcher.js +122 -33
  165. package/dist/rules/dispatcher.js.map +1 -1
  166. package/dist/rules/index.d.ts +2 -2
  167. package/dist/rules/index.d.ts.map +1 -1
  168. package/dist/rules/index.js +2 -2
  169. package/dist/rules/processor.d.ts +2 -0
  170. package/dist/rules/processor.d.ts.map +1 -1
  171. package/dist/rules/processor.js +18 -4
  172. package/dist/rules/processor.js.map +1 -1
  173. package/dist/rules/start-coordinator.d.ts +6 -1
  174. package/dist/rules/start-coordinator.d.ts.map +1 -1
  175. package/dist/rules/start-coordinator.js +6 -2
  176. package/dist/rules/start-coordinator.js.map +1 -1
  177. package/dist/rules/transition-service.d.ts +20 -2
  178. package/dist/rules/transition-service.d.ts.map +1 -1
  179. package/dist/rules/transition-service.js +43 -20
  180. package/dist/rules/transition-service.js.map +1 -1
  181. package/dist/rules/types.d.ts +71 -3
  182. package/dist/rules/types.d.ts.map +1 -1
  183. package/dist/rules/types.js +10 -2
  184. package/dist/rules/types.js.map +1 -1
  185. package/dist/rules/validation.d.ts.map +1 -1
  186. package/dist/rules/validation.js +5 -0
  187. package/dist/rules/validation.js.map +1 -1
  188. package/dist/sandbox/context-sandboxes.d.ts +70 -0
  189. package/dist/sandbox/context-sandboxes.d.ts.map +1 -0
  190. package/dist/sandbox/context-sandboxes.js +120 -0
  191. package/dist/sandbox/context-sandboxes.js.map +1 -0
  192. package/dist/sandbox/session-retirement.d.ts +11 -4
  193. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  194. package/dist/sandbox/session-retirement.js +39 -13
  195. package/dist/sandbox/session-retirement.js.map +1 -1
  196. package/dist/session/factory-session.d.ts +20 -5
  197. package/dist/session/factory-session.d.ts.map +1 -1
  198. package/dist/session/factory-session.js +20 -6
  199. package/dist/session/factory-session.js.map +1 -1
  200. package/dist/session/live-sessions.d.ts +1 -1
  201. package/dist/session/live-sessions.d.ts.map +1 -1
  202. package/dist/session/live-sessions.js +12 -2
  203. package/dist/session/live-sessions.js.map +1 -1
  204. package/dist/storage/domains/audit/actions.d.ts +1 -1
  205. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  206. package/dist/storage/domains/audit/actions.js +2 -1
  207. package/dist/storage/domains/audit/actions.js.map +1 -1
  208. package/dist/storage/domains/audit/actors.d.ts.map +1 -1
  209. package/dist/storage/domains/audit/actors.js +1 -1
  210. package/dist/storage/domains/audit/actors.js.map +1 -1
  211. package/dist/storage/domains/boards/base.d.ts +25 -5
  212. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  213. package/dist/storage/domains/boards/base.js +57 -20
  214. package/dist/storage/domains/boards/base.js.map +1 -1
  215. package/dist/storage/domains/intake/base.d.ts +1 -1
  216. package/dist/storage/domains/intake/base.js +2 -2
  217. package/dist/storage/domains/intake/base.js.map +1 -1
  218. package/dist/storage/domains/projects/base.d.ts +16 -2
  219. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  220. package/dist/storage/domains/projects/base.js +32 -5
  221. package/dist/storage/domains/projects/base.js.map +1 -1
  222. package/dist/storage/domains/work-items/base.d.ts +60 -8
  223. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  224. package/dist/storage/domains/work-items/base.js +180 -18
  225. package/dist/storage/domains/work-items/base.js.map +1 -1
  226. package/dist/storage/domains/work-items/cards.d.ts +1 -0
  227. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  228. package/dist/storage/domains/work-items/cards.js +32 -8
  229. package/dist/storage/domains/work-items/cards.js.map +1 -1
  230. package/dist/storage/domains/work-items/legacy-review.d.ts +19 -1
  231. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -1
  232. package/dist/storage/domains/work-items/legacy-review.js +62 -3
  233. package/dist/storage/domains/work-items/legacy-review.js.map +1 -1
  234. package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -0
  235. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  236. package/dist/storage/domains/work-items/work-item-schema.js +46 -18
  237. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  238. package/dist/tools/annotations.d.ts.map +1 -1
  239. package/dist/tools/annotations.js +4 -0
  240. package/dist/tools/annotations.js.map +1 -1
  241. package/dist/tools/approval-tools.d.ts +20 -0
  242. package/dist/tools/approval-tools.d.ts.map +1 -1
  243. package/dist/tools/approval-tools.js +79 -30
  244. package/dist/tools/approval-tools.js.map +1 -1
  245. package/dist/tools/audit-events-tool.d.ts +29 -0
  246. package/dist/tools/audit-events-tool.d.ts.map +1 -0
  247. package/dist/tools/audit-events-tool.js +180 -0
  248. package/dist/tools/audit-events-tool.js.map +1 -0
  249. package/dist/tools/index.d.ts +2 -1
  250. package/dist/tools/index.d.ts.map +1 -1
  251. package/dist/tools/index.js +2 -0
  252. package/dist/tools/index.js.map +1 -1
  253. package/dist/tools/messaging-tools.d.ts.map +1 -1
  254. package/dist/tools/messaging-tools.js +1 -1
  255. package/dist/tools/messaging-tools.js.map +1 -1
  256. package/dist/tools/permissions.d.ts.map +1 -1
  257. package/dist/tools/permissions.js +1 -0
  258. package/dist/tools/permissions.js.map +1 -1
  259. package/dist/tools/read-tools.d.ts +0 -2
  260. package/dist/tools/read-tools.d.ts.map +1 -1
  261. package/dist/tools/read-tools.js +2 -7
  262. package/dist/tools/read-tools.js.map +1 -1
  263. package/dist/tools/reports.d.ts +3 -0
  264. package/dist/tools/reports.d.ts.map +1 -1
  265. package/dist/tools/reports.js +3 -3
  266. package/dist/tools/reports.js.map +1 -1
  267. package/dist/tools/run-watch.d.ts +14 -2
  268. package/dist/tools/run-watch.d.ts.map +1 -1
  269. package/dist/tools/run-watch.js +24 -4
  270. package/dist/tools/run-watch.js.map +1 -1
  271. package/dist/tools/session-tools.d.ts.map +1 -1
  272. package/dist/tools/session-tools.js +17 -6
  273. package/dist/tools/session-tools.js.map +1 -1
  274. package/dist/tools/sessions-state-processor.js +1 -1
  275. package/dist/tools/sessions-state-processor.js.map +1 -1
  276. package/dist/tools/side-sessions.d.ts.map +1 -1
  277. package/dist/tools/side-sessions.js +1 -1
  278. package/dist/tools/side-sessions.js.map +1 -1
  279. package/dist/tools/work-item-tools.d.ts.map +1 -1
  280. package/dist/tools/work-item-tools.js +12 -2
  281. package/dist/tools/work-item-tools.js.map +1 -1
  282. package/dist/work-item-branch.d.ts +1 -1
  283. package/dist/work-item-branch.d.ts.map +1 -1
  284. package/dist/work-item-branch.js +2 -0
  285. package/dist/work-item-branch.js.map +1 -1
  286. package/dist/work-items/board-check.d.ts +11 -0
  287. package/dist/work-items/board-check.d.ts.map +1 -0
  288. package/dist/work-items/board-check.js +20 -0
  289. package/dist/work-items/board-check.js.map +1 -0
  290. package/dist/work-items/board-filter-options.d.ts +5 -0
  291. package/dist/work-items/board-filter-options.d.ts.map +1 -0
  292. package/dist/work-items/board-filter-options.js +27 -0
  293. package/dist/work-items/board-filter-options.js.map +1 -0
  294. package/dist/work-items/board-phases.d.ts +28 -0
  295. package/dist/work-items/board-phases.d.ts.map +1 -0
  296. package/dist/work-items/board-phases.js +165 -0
  297. package/dist/work-items/board-phases.js.map +1 -0
  298. package/dist/work-items/card-facts.d.ts +24 -0
  299. package/dist/work-items/card-facts.d.ts.map +1 -0
  300. package/dist/work-items/card-facts.js +75 -0
  301. package/dist/work-items/card-facts.js.map +1 -0
  302. package/dist/work-items/card-labels.d.ts +5 -0
  303. package/dist/work-items/card-labels.d.ts.map +1 -0
  304. package/dist/work-items/card-labels.js +13 -0
  305. package/dist/work-items/card-labels.js.map +1 -0
  306. package/dist/work-items/card-number.d.ts +10 -0
  307. package/dist/work-items/card-number.d.ts.map +1 -0
  308. package/dist/work-items/card-number.js +15 -0
  309. package/dist/work-items/card-number.js.map +1 -0
  310. package/dist/work-items/card-people.d.ts +25 -0
  311. package/dist/work-items/card-people.d.ts.map +1 -0
  312. package/dist/work-items/card-people.js +100 -0
  313. package/dist/work-items/card-people.js.map +1 -0
  314. package/dist/work-items/card-search-text.d.ts +4 -0
  315. package/dist/work-items/card-search-text.d.ts.map +1 -0
  316. package/dist/work-items/card-search-text.js +15 -0
  317. package/dist/work-items/card-search-text.js.map +1 -0
  318. package/dist/work-items/card-source-filters.d.ts +23 -0
  319. package/dist/work-items/card-source-filters.d.ts.map +1 -0
  320. package/dist/work-items/card-source-filters.js +25 -0
  321. package/dist/work-items/card-source-filters.js.map +1 -0
  322. package/dist/work-items/create-work-item.d.ts +0 -6
  323. package/dist/work-items/create-work-item.d.ts.map +1 -1
  324. package/dist/work-items/create-work-item.js +2 -7
  325. package/dist/work-items/create-work-item.js.map +1 -1
  326. package/dist/work-items/list-related-cards.d.ts +4 -0
  327. package/dist/work-items/list-related-cards.d.ts.map +1 -0
  328. package/dist/work-items/list-related-cards.js +24 -0
  329. package/dist/work-items/list-related-cards.js.map +1 -0
  330. package/dist/work-items/related-cards.d.ts +21 -0
  331. package/dist/work-items/related-cards.d.ts.map +1 -0
  332. package/dist/work-items/related-cards.js +45 -0
  333. package/dist/work-items/related-cards.js.map +1 -0
  334. package/dist/work-items/search-words.d.ts +5 -0
  335. package/dist/work-items/search-words.d.ts.map +1 -0
  336. package/dist/work-items/search-words.js +12 -0
  337. package/dist/work-items/search-words.js.map +1 -0
  338. package/dist/work-items/split-migration.d.ts.map +1 -1
  339. package/dist/work-items/split-migration.js +6 -2
  340. package/dist/work-items/split-migration.js.map +1 -1
  341. package/dist/workspace.d.ts +0 -1
  342. package/dist/workspace.d.ts.map +1 -1
  343. package/dist/workspace.js +140 -78
  344. package/dist/workspace.js.map +1 -1
  345. package/factory-skills/factory-build/SKILL.md +1 -1
  346. package/factory-skills/factory-self-review/SKILL.md +1 -1
  347. package/factory-skills/factory-triage/SKILL.md +4 -4
  348. package/package.json +17 -16
@@ -1,4 +1,6 @@
1
1
  import { loose } from "../../../routes/route.js";
2
+ import { attachDependabotRules } from "../../dependabot/rules.js";
3
+ import { createDependabotSync } from "../../dependabot/sync.js";
2
4
  import { GithubAppIdentity } from "../../github/app-identity.js";
3
5
  import { resolveGithubRules } from "../../github/default-rules.js";
4
6
  import { attachGithubIssueReconciler } from "../../github/issue-reconciler.js";
@@ -13,9 +15,19 @@ import { PlatformGithubEventWorker } from "./event-worker.js";
13
15
  import { registerApiRoute } from "@mastra/core/server";
14
16
  import { Octokit } from "@octokit/rest";
15
17
  // src/integrations/platform/github/integration.ts
18
+ /**
19
+ * Status reason for a settled installation list. A personal install Platform withholds would otherwise
20
+ * read as "nothing installed", so say so; any usable installation still means ready.
21
+ */
22
+ function githubStatusReason(hasUsableInstallation, hiddenPersonalInstallReason) {
23
+ if (hasUsableInstallation) return "ready";
24
+ return hiddenPersonalInstallReason ? "personal_install_hidden" : "not_connected";
25
+ }
16
26
  const PAGE_SIZE = 30;
17
27
  const OPEN_ISSUE_DISCOVERY_MAX_PAGES = 5;
18
28
  const API_PREFIX = "/v1/server";
29
+ /** Intake config id that opts repositories into Dependabot alert sync. */
30
+ const DEPENDABOT_INTAKE_ID = "dependabot";
19
31
  const CHECK_TITLE_LIMIT = 255;
20
32
  const CHECK_TEXT_LIMIT = 65535;
21
33
  /**
@@ -33,10 +45,11 @@ const PLATFORM_GITHUB_APP_SLUG = "mastra-platform";
33
45
  const INSTALLATION_REPOS_CACHE_TTL_MS = 3e4;
34
46
  /**
35
47
  * How long a minted repository-scoped token may be reused. GitHub
36
- * installation tokens live ~60 minutes; 5 minutes keeps a wide validity
37
- * margin while collapsing the per-session-materialization mint round trip.
48
+ * installation tokens live ~60 minutes. A session re-mints the token it
49
+ * installed after `GITHUB_TOKEN_REFRESH_AFTER_MS` (30 minutes), so a token
50
+ * served from this cache is at most 50 minutes old when it is replaced.
38
51
  */
39
- const REPOSITORY_ACCESS_CACHE_TTL_MS = 3e5;
52
+ const REPOSITORY_ACCESS_CACHE_TTL_MS = 12e5;
40
53
  /**
41
54
  * How long a collaborator permission lookup may be reused. The reconcile
42
55
  * sweep re-stamps every open card's author and the event tail gates every
@@ -109,10 +122,37 @@ var PlatformGithubIntegration = class {
109
122
  #installationReposCache = /* @__PURE__ */ new Map();
110
123
  /** `orgId:repositoryId` → cached repository access (TTL-bounded). */
111
124
  #repositoryAccessCache = /* @__PURE__ */ new Map();
125
+ /**
126
+ * In-flight mints by the same key as `#repositoryAccessCache`. Sessions that
127
+ * boot together all miss the cache at once; without this each one minted its
128
+ * own token and drained the Platform's per-installation mint budget.
129
+ */
130
+ #repositoryAccessInFlight = /* @__PURE__ */ new Map();
131
+ #mintOnce(cacheKey, mint) {
132
+ const cached = this.#repositoryAccessCache.get(cacheKey);
133
+ if (cached && cached.expiresAt > Date.now()) return Promise.resolve(cached.access);
134
+ this.#repositoryAccessCache.delete(cacheKey);
135
+ const inFlight = this.#repositoryAccessInFlight.get(cacheKey);
136
+ if (inFlight) return inFlight;
137
+ const pending = mint().finally(() => this.#repositoryAccessInFlight.delete(cacheKey));
138
+ this.#repositoryAccessInFlight.set(cacheKey, pending);
139
+ return pending;
140
+ }
112
141
  /** `owner/repo:login` → cached collaborator permission (TTL-bounded). */
113
142
  #collaboratorPermissionCache = /* @__PURE__ */ new Map();
114
143
  /** Same key → lookup already in flight, so overlapping callers share one request. */
115
144
  #collaboratorPermissionInFlight = /* @__PURE__ */ new Map();
145
+ /** Dependabot opt-in: its sources are the same repositories; cards arrive through the alert sync, not intake items. */
146
+ additionalIntakes = [{
147
+ id: DEPENDABOT_INTAKE_ID,
148
+ intake: {
149
+ listSources: (input) => this.intake.listSources(input),
150
+ listItems: async () => ({
151
+ items: [],
152
+ nextCursor: null
153
+ })
154
+ }
155
+ }];
116
156
  intake = {
117
157
  resolveIntakeDispatch: (input) => this.#resolveIntakeDispatch(input),
118
158
  listSources: async ({ orgId, userId }) => {
@@ -201,6 +241,7 @@ var PlatformGithubIntegration = class {
201
241
  sourceId,
202
242
  title: pullRequest.title,
203
243
  status: pullRequest.state,
244
+ labels: pullRequest.labels,
204
245
  createdAt: pullRequest.createdAt,
205
246
  updatedAt: pullRequest.updatedAt,
206
247
  metadata: {
@@ -273,68 +314,30 @@ var PlatformGithubIntegration = class {
273
314
  },
274
315
  getRepositoryAccess: async ({ orgId, repositoryId }) => {
275
316
  const cacheKey = `${orgId}:${repositoryId}`;
276
- const cached = this.#repositoryAccessCache.get(cacheKey);
277
- if (cached && cached.expiresAt > Date.now()) return cached.access;
278
- this.#repositoryAccessCache.delete(cacheKey);
279
- const repository = await this.storage.repositories.get({
280
- orgId,
281
- id: repositoryId
282
- });
283
- if (!repository) throw new Error("Version-control repository not found.");
284
- const cloneUrl = `https://github.com/${repository.slug}.git`;
285
- const installation = await this.storage.installations.get({
286
- orgId,
287
- id: repository.installationId
288
- });
289
- if (!installation) throw new Error("Version-control installation not found.");
290
- const installationId = parsePositiveInteger(installation.externalId);
291
- if (installationId === null) throw new Error("GitHub installation id is invalid.");
292
- const repositoryName = splitRepository(repository.slug).repo;
293
- try {
294
- const access = {
295
- cloneUrl,
296
- authorization: {
297
- scheme: "bearer",
298
- token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
299
- repositories: [repositoryName],
300
- permissions: REPOSITORY_TOKEN_PERMISSIONS
301
- })).token
302
- }
303
- };
304
- setBounded(this.#repositoryAccessCache, cacheKey, {
305
- access,
306
- expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
317
+ return this.#mintOnce(cacheKey, async () => {
318
+ const repository = await this.storage.repositories.get({
319
+ orgId,
320
+ id: repositoryId
307
321
  });
308
- return access;
309
- } catch (err) {
310
- if (!isDeadInstallation(err) || !installation.accountName) throw err;
311
- const candidates = (await this.storage.installations.list({ orgId })).map((inst, index) => ({
312
- inst,
313
- index
314
- })).filter(({ inst }) => inst.accountName === installation.accountName && inst.id !== installation.id).sort((a, b) => b.inst.createdAt.getTime() - a.inst.createdAt.getTime() || b.index - a.index).map(({ inst }) => inst);
315
- for (const candidate of candidates) {
316
- const candidateInstallationId = parsePositiveInteger(candidate.externalId);
317
- if (candidateInstallationId === null) continue;
318
- let token;
319
- try {
320
- token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${candidateInstallationId}/token`, {
321
- repositories: [repositoryName],
322
- permissions: REPOSITORY_TOKEN_PERMISSIONS
323
- });
324
- } catch (candidateErr) {
325
- if (isDeadInstallation(candidateErr)) continue;
326
- throw candidateErr;
327
- }
328
- await this.storage.repositories.migrateInstallation({
329
- orgId,
330
- id: repositoryId,
331
- newInstallationId: candidate.id
332
- });
322
+ if (!repository) throw new Error("Version-control repository not found.");
323
+ const cloneUrl = `https://github.com/${repository.slug}.git`;
324
+ const installation = await this.storage.installations.get({
325
+ orgId,
326
+ id: repository.installationId
327
+ });
328
+ if (!installation) throw new Error("Version-control installation not found.");
329
+ const installationId = parsePositiveInteger(installation.externalId);
330
+ if (installationId === null) throw new Error("GitHub installation id is invalid.");
331
+ const repositoryName = splitRepository(repository.slug).repo;
332
+ try {
333
333
  const access = {
334
334
  cloneUrl,
335
335
  authorization: {
336
336
  scheme: "bearer",
337
- token: token.token
337
+ token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
338
+ repositories: [repositoryName],
339
+ permissions: REPOSITORY_TOKEN_PERMISSIONS
340
+ })).token
338
341
  }
339
342
  };
340
343
  setBounded(this.#repositoryAccessCache, cacheKey, {
@@ -342,47 +345,88 @@ var PlatformGithubIntegration = class {
342
345
  expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
343
346
  });
344
347
  return access;
348
+ } catch (err) {
349
+ if (!isDeadInstallation(err) || !installation.accountName) throw err;
350
+ const candidates = (await this.storage.installations.list({ orgId })).map((inst, index) => ({
351
+ inst,
352
+ index
353
+ })).filter(({ inst }) => inst.accountName === installation.accountName && inst.id !== installation.id).sort((a, b) => b.inst.createdAt.getTime() - a.inst.createdAt.getTime() || b.index - a.index).map(({ inst }) => inst);
354
+ for (const candidate of candidates) {
355
+ const candidateInstallationId = parsePositiveInteger(candidate.externalId);
356
+ if (candidateInstallationId === null) continue;
357
+ let token;
358
+ try {
359
+ token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${candidateInstallationId}/token`, {
360
+ repositories: [repositoryName],
361
+ permissions: REPOSITORY_TOKEN_PERMISSIONS
362
+ });
363
+ } catch (candidateErr) {
364
+ if (isDeadInstallation(candidateErr)) continue;
365
+ throw candidateErr;
366
+ }
367
+ await this.storage.repositories.migrateInstallation({
368
+ orgId,
369
+ id: repositoryId,
370
+ newInstallationId: candidate.id
371
+ });
372
+ const access = {
373
+ cloneUrl,
374
+ authorization: {
375
+ scheme: "bearer",
376
+ token: token.token
377
+ }
378
+ };
379
+ setBounded(this.#repositoryAccessCache, cacheKey, {
380
+ access,
381
+ expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
382
+ });
383
+ return access;
384
+ }
385
+ throw err;
345
386
  }
346
- throw err;
347
- }
387
+ });
348
388
  },
349
389
  getRepositoriesAccess: async ({ orgId, repositoryIds }) => {
350
390
  const ids = [...new Set(repositoryIds)];
351
391
  if (ids.length === 0 || ids.length > MAX_REPOSITORIES_PER_TOKEN) return void 0;
352
392
  const cacheKey = `${orgId}:${[...ids].sort().join(",")}`;
353
- const cached = this.#repositoryAccessCache.get(cacheKey);
354
- if (cached && cached.expiresAt > Date.now()) return cached.access;
355
- this.#repositoryAccessCache.delete(cacheKey);
356
- const repositories = await Promise.all(ids.map((id) => this.storage.repositories.get({
357
- orgId,
358
- id
359
- })));
360
- if (repositories.some((repository) => !repository)) throw new Error("Version-control repository not found.");
361
- const found = repositories;
362
- if (new Set(found.map((repository) => repository.installationId)).size !== 1) return void 0;
363
- const installation = await this.storage.installations.get({
364
- orgId,
365
- id: found[0].installationId
366
- });
367
- if (!installation) throw new Error("Version-control installation not found.");
368
- const installationId = parsePositiveInteger(installation.externalId);
369
- if (installationId === null) throw new Error("GitHub installation id is invalid.");
370
- const token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
371
- repositories: found.map((repository) => splitRepository(repository.slug).repo),
372
- permissions: REPOSITORY_TOKEN_PERMISSIONS
373
- });
374
- const access = {
375
- cloneUrl: `https://github.com/${found[0].slug}.git`,
376
- authorization: {
393
+ return this.#mintOnce(cacheKey, async () => {
394
+ const repositories = await Promise.all(ids.map((id) => this.storage.repositories.get({
395
+ orgId,
396
+ id
397
+ })));
398
+ if (repositories.some((repository) => !repository)) throw new Error("Version-control repository not found.");
399
+ const found = repositories;
400
+ if (new Set(found.map((repository) => repository.installationId)).size !== 1) return void 0;
401
+ const installation = await this.storage.installations.get({
402
+ orgId,
403
+ id: found[0].installationId
404
+ });
405
+ if (!installation) throw new Error("Version-control installation not found.");
406
+ const installationId = parsePositiveInteger(installation.externalId);
407
+ if (installationId === null) throw new Error("GitHub installation id is invalid.");
408
+ const authorization = {
377
409
  scheme: "bearer",
378
- token: token.token
379
- }
380
- };
381
- setBounded(this.#repositoryAccessCache, cacheKey, {
382
- access,
383
- expiresAt: Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS
410
+ token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
411
+ repositories: found.map((repository) => splitRepository(repository.slug).repo),
412
+ permissions: REPOSITORY_TOKEN_PERMISSIONS
413
+ })).token
414
+ };
415
+ const expiresAt = Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS;
416
+ const access = {
417
+ cloneUrl: `https://github.com/${found[0].slug}.git`,
418
+ authorization,
419
+ repositories: Object.fromEntries(found.map((repository) => [repository.id, {
420
+ cloneUrl: `https://github.com/${repository.slug}.git`,
421
+ authorization
422
+ }]))
423
+ };
424
+ setBounded(this.#repositoryAccessCache, cacheKey, {
425
+ access,
426
+ expiresAt
427
+ });
428
+ return access;
384
429
  });
385
- return access;
386
430
  },
387
431
  listPullRequests: (input) => this.#listPullRequests(input),
388
432
  getPullRequest: (input) => this.#getPullRequest(input),
@@ -538,7 +582,7 @@ var PlatformGithubIntegration = class {
538
582
  reason: "organization_required",
539
583
  diagnostics: this.diagnostics()
540
584
  });
541
- const [installations, userConnection] = await Promise.all([this.#syncInstallations(tenant.orgId, tenant.userId), this.#fetchUserConnection(tenant.userId)]);
585
+ const [{ installations, hiddenPersonalInstallReason }, userConnection] = await Promise.all([this.#syncInstallations(tenant.orgId, tenant.userId), this.#fetchUserConnection(tenant.userId)]);
542
586
  return c.json({
543
587
  enabled: true,
544
588
  sandboxEnabled: !!ctx.sandbox,
@@ -550,7 +594,7 @@ var PlatformGithubIntegration = class {
550
594
  })),
551
595
  userConnected: userConnection.connected,
552
596
  userGithubUsername: userConnection.githubUsername,
553
- reason: installations.length > 0 ? "ready" : "not_connected",
597
+ reason: githubStatusReason(installations.length > 0, hiddenPersonalInstallReason),
554
598
  diagnostics: this.diagnostics()
555
599
  });
556
600
  }
@@ -626,16 +670,20 @@ var PlatformGithubIntegration = class {
626
670
  }
627
671
  }
628
672
  async #syncInstallations(orgId, userId) {
629
- const usableInstallations = (await this.#client.request("GET", `${API_PREFIX}/github-app/installations`)).installations.filter((installation) => installation.usable && !installation.suspendedAt);
630
- return Promise.all(usableInstallations.map((installation) => this.versionControl.registerInstallation({
631
- orgId,
632
- userId,
633
- installation: {
634
- externalId: String(installation.installationId),
635
- accountName: installation.accountLogin,
636
- accountType: installation.accountType
637
- }
638
- })));
673
+ const result = await this.#client.request("GET", `${API_PREFIX}/github-app/installations`);
674
+ const usableInstallations = result.installations.filter((installation) => installation.usable && !installation.suspendedAt);
675
+ return {
676
+ installations: await Promise.all(usableInstallations.map((installation) => this.versionControl.registerInstallation({
677
+ orgId,
678
+ userId,
679
+ installation: {
680
+ externalId: String(installation.installationId),
681
+ accountName: installation.accountLogin,
682
+ accountType: installation.accountType
683
+ }
684
+ }))),
685
+ hiddenPersonalInstallReason: result.hiddenPersonalInstallReason ?? void 0
686
+ };
639
687
  }
640
688
  workers(ctx) {
641
689
  if (!this.#pollingEnabled && !this.#pullRequestReconcileEnabled && !this.#issueReconcileEnabled) return [];
@@ -648,6 +696,7 @@ var PlatformGithubIntegration = class {
648
696
  ingestFactoryEvent: attachGithubRules(this, ctx),
649
697
  reconcileFactoryState: this.#pullRequestReconcileEnabled ? attachGithubReconciler(this, ctx, (input) => this.fetchPullRequestState(input)) : void 0,
650
698
  discoverPullRequests: this.#pullRequestReconcileEnabled ? attachGithubPullRequestDiscovery(this, ctx, openPullRequestLister(this.versionControl)) : void 0,
699
+ syncDependabotAlerts: this.#issueReconcileEnabled ? this.#dependabotSync(ctx) : void 0,
651
700
  reconcileIssuesFactoryState: this.#issueReconcileEnabled ? attachGithubIssueReconciler(this, ctx, (input) => this.fetchIssueState(input), (input) => this.listOpenIssueStates(input)) : void 0,
652
701
  pollEventsEnabled: this.#pollingEnabled,
653
702
  intervalMs: this.#pollingIntervalMs,
@@ -663,6 +712,35 @@ var PlatformGithubIntegration = class {
663
712
  }
664
713
  })];
665
714
  }
715
+ #dependabotSync(ctx) {
716
+ const ingest = attachDependabotRules(ctx);
717
+ if (!ingest) return void 0;
718
+ return createDependabotSync({
719
+ listAlerts: (input) => this.listDependabotAlerts(input),
720
+ listProjects: (args) => this.storage.projectRepositories.listByExternalRepository(args),
721
+ repositoryEnabled: async ({ orgId, repository }) => {
722
+ const config = (await ctx.storage.intake.getConfig({
723
+ orgId,
724
+ integrationIds: [DEPENDABOT_INTAKE_ID]
725
+ }))[DEPENDABOT_INTAKE_ID];
726
+ return Boolean(config?.enabled && config.sourceIds?.includes(repository));
727
+ },
728
+ ingest,
729
+ userId: "factory-rule-dispatcher"
730
+ });
731
+ }
732
+ /** Lists a repository's Dependabot alerts in one state through the Platform GitHub proxy. */
733
+ async listDependabotAlerts(input) {
734
+ const { owner, repo } = splitRepository(input.repository);
735
+ const state = input.state === "open" ? "open" : "fixed,dismissed,auto_dismissed";
736
+ const query = new URLSearchParams({
737
+ state,
738
+ per_page: "100",
739
+ sort: "updated",
740
+ direction: "desc"
741
+ });
742
+ return (await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/dependabot/alerts?${query}`)).alerts;
743
+ }
666
744
  /**
667
745
  * Reads live PR state through the Platform GitHub proxy for the merge
668
746
  * reconciler. Returns undefined when the PR cannot be resolved (missing,