@mastra/factory 0.0.0-aggregate-trace-20261015182851

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 (926) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +671 -0
  3. package/dist/auth.d.ts +201 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +623 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/boards/define-board.d.ts +111 -0
  8. package/dist/boards/define-board.d.ts.map +1 -0
  9. package/dist/boards/define-board.js +156 -0
  10. package/dist/boards/define-board.js.map +1 -0
  11. package/dist/boards/index.d.ts +14 -0
  12. package/dist/boards/index.d.ts.map +1 -0
  13. package/dist/boards/index.js +21 -0
  14. package/dist/boards/index.js.map +1 -0
  15. package/dist/boards/registry.d.ts +16 -0
  16. package/dist/boards/registry.d.ts.map +1 -0
  17. package/dist/boards/registry.js +25 -0
  18. package/dist/boards/registry.js.map +1 -0
  19. package/dist/boards/relocate.d.ts +21 -0
  20. package/dist/boards/relocate.d.ts.map +1 -0
  21. package/dist/boards/relocate.js +58 -0
  22. package/dist/boards/relocate.js.map +1 -0
  23. package/dist/boards/review.d.ts +6 -0
  24. package/dist/boards/review.d.ts.map +1 -0
  25. package/dist/boards/review.js +104 -0
  26. package/dist/boards/review.js.map +1 -0
  27. package/dist/boards/semantics.d.ts +68 -0
  28. package/dist/boards/semantics.d.ts.map +1 -0
  29. package/dist/boards/semantics.js +119 -0
  30. package/dist/boards/semantics.js.map +1 -0
  31. package/dist/boards/transition-policy.d.ts +67 -0
  32. package/dist/boards/transition-policy.d.ts.map +1 -0
  33. package/dist/boards/transition-policy.js +36 -0
  34. package/dist/boards/transition-policy.js.map +1 -0
  35. package/dist/boards/work-tool-rules.d.ts +8 -0
  36. package/dist/boards/work-tool-rules.d.ts.map +1 -0
  37. package/dist/boards/work-tool-rules.js +20 -0
  38. package/dist/boards/work-tool-rules.js.map +1 -0
  39. package/dist/boards/work-transition-policy.d.ts +3 -0
  40. package/dist/boards/work-transition-policy.d.ts.map +1 -0
  41. package/dist/boards/work-transition-policy.js +46 -0
  42. package/dist/boards/work-transition-policy.js.map +1 -0
  43. package/dist/boards/work.d.ts +4 -0
  44. package/dist/boards/work.d.ts.map +1 -0
  45. package/dist/boards/work.js +222 -0
  46. package/dist/boards/work.js.map +1 -0
  47. package/dist/capabilities/connection.d.ts +9 -0
  48. package/dist/capabilities/connection.d.ts.map +1 -0
  49. package/dist/capabilities/connection.js +1 -0
  50. package/dist/capabilities/intake.d.ts +153 -0
  51. package/dist/capabilities/intake.d.ts.map +1 -0
  52. package/dist/capabilities/intake.js +1 -0
  53. package/dist/capabilities/version-control.d.ts +268 -0
  54. package/dist/capabilities/version-control.d.ts.map +1 -0
  55. package/dist/capabilities/version-control.js +1 -0
  56. package/dist/environment/build-runner.d.ts +72 -0
  57. package/dist/environment/build-runner.d.ts.map +1 -0
  58. package/dist/environment/build-runner.js +131 -0
  59. package/dist/environment/build-runner.js.map +1 -0
  60. package/dist/environment/build-schedule.d.ts +40 -0
  61. package/dist/environment/build-schedule.d.ts.map +1 -0
  62. package/dist/environment/build-schedule.js +94 -0
  63. package/dist/environment/build-schedule.js.map +1 -0
  64. package/dist/environment/build-workflow.d.ts +62 -0
  65. package/dist/environment/build-workflow.d.ts.map +1 -0
  66. package/dist/environment/build-workflow.js +149 -0
  67. package/dist/environment/build-workflow.js.map +1 -0
  68. package/dist/environment/build.d.ts +111 -0
  69. package/dist/environment/build.d.ts.map +1 -0
  70. package/dist/environment/build.js +344 -0
  71. package/dist/environment/build.js.map +1 -0
  72. package/dist/environment/heads.d.ts +36 -0
  73. package/dist/environment/heads.d.ts.map +1 -0
  74. package/dist/environment/heads.js +60 -0
  75. package/dist/environment/heads.js.map +1 -0
  76. package/dist/factory.d.ts +225 -0
  77. package/dist/factory.d.ts.map +1 -0
  78. package/dist/factory.js +1006 -0
  79. package/dist/factory.js.map +1 -0
  80. package/dist/feed-events.d.ts +13 -0
  81. package/dist/feed-events.d.ts.map +1 -0
  82. package/dist/feed-events.js +25 -0
  83. package/dist/feed-events.js.map +1 -0
  84. package/dist/index.d.ts +22 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +15 -0
  87. package/dist/integrations/base.d.ts +302 -0
  88. package/dist/integrations/base.d.ts.map +1 -0
  89. package/dist/integrations/base.js +1 -0
  90. package/dist/integrations/github/acceptance-labels.d.ts +16 -0
  91. package/dist/integrations/github/acceptance-labels.d.ts.map +1 -0
  92. package/dist/integrations/github/acceptance-labels.js +55 -0
  93. package/dist/integrations/github/acceptance-labels.js.map +1 -0
  94. package/dist/integrations/github/app-identity.d.ts +43 -0
  95. package/dist/integrations/github/app-identity.d.ts.map +1 -0
  96. package/dist/integrations/github/app-identity.js +62 -0
  97. package/dist/integrations/github/app-identity.js.map +1 -0
  98. package/dist/integrations/github/commits.d.ts +40 -0
  99. package/dist/integrations/github/commits.d.ts.map +1 -0
  100. package/dist/integrations/github/commits.js +48 -0
  101. package/dist/integrations/github/commits.js.map +1 -0
  102. package/dist/integrations/github/config.d.ts +60 -0
  103. package/dist/integrations/github/config.d.ts.map +1 -0
  104. package/dist/integrations/github/config.js +42 -0
  105. package/dist/integrations/github/config.js.map +1 -0
  106. package/dist/integrations/github/default-rules.d.ts +218 -0
  107. package/dist/integrations/github/default-rules.d.ts.map +1 -0
  108. package/dist/integrations/github/default-rules.js +296 -0
  109. package/dist/integrations/github/default-rules.js.map +1 -0
  110. package/dist/integrations/github/integration.d.ts +270 -0
  111. package/dist/integrations/github/integration.d.ts.map +1 -0
  112. package/dist/integrations/github/integration.js +1375 -0
  113. package/dist/integrations/github/integration.js.map +1 -0
  114. package/dist/integrations/github/issue-reconciler.d.ts +28 -0
  115. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -0
  116. package/dist/integrations/github/issue-reconciler.js +138 -0
  117. package/dist/integrations/github/issue-reconciler.js.map +1 -0
  118. package/dist/integrations/github/pat.d.ts +38 -0
  119. package/dist/integrations/github/pat.d.ts.map +1 -0
  120. package/dist/integrations/github/pat.js +59 -0
  121. package/dist/integrations/github/pat.js.map +1 -0
  122. package/dist/integrations/github/provenance.d.ts +34 -0
  123. package/dist/integrations/github/provenance.d.ts.map +1 -0
  124. package/dist/integrations/github/provenance.js +91 -0
  125. package/dist/integrations/github/provenance.js.map +1 -0
  126. package/dist/integrations/github/reconcile-worker.d.ts +45 -0
  127. package/dist/integrations/github/reconcile-worker.d.ts.map +1 -0
  128. package/dist/integrations/github/reconcile-worker.js +189 -0
  129. package/dist/integrations/github/reconcile-worker.js.map +1 -0
  130. package/dist/integrations/github/reconciliation-config.d.ts +3 -0
  131. package/dist/integrations/github/reconciliation-config.d.ts.map +1 -0
  132. package/dist/integrations/github/reconciliation-config.js +19 -0
  133. package/dist/integrations/github/reconciliation-config.js.map +1 -0
  134. package/dist/integrations/github/routes.d.ts +90 -0
  135. package/dist/integrations/github/routes.d.ts.map +1 -0
  136. package/dist/integrations/github/routes.js +1362 -0
  137. package/dist/integrations/github/routes.js.map +1 -0
  138. package/dist/integrations/github/rules.d.ts +173 -0
  139. package/dist/integrations/github/rules.d.ts.map +1 -0
  140. package/dist/integrations/github/rules.js +1021 -0
  141. package/dist/integrations/github/rules.js.map +1 -0
  142. package/dist/integrations/github/sandbox-release.d.ts +25 -0
  143. package/dist/integrations/github/sandbox-release.d.ts.map +1 -0
  144. package/dist/integrations/github/sandbox-release.js +38 -0
  145. package/dist/integrations/github/sandbox-release.js.map +1 -0
  146. package/dist/integrations/github/sandbox.d.ts +234 -0
  147. package/dist/integrations/github/sandbox.d.ts.map +1 -0
  148. package/dist/integrations/github/sandbox.js +947 -0
  149. package/dist/integrations/github/sandbox.js.map +1 -0
  150. package/dist/integrations/github/session-subscriptions.d.ts +28 -0
  151. package/dist/integrations/github/session-subscriptions.d.ts.map +1 -0
  152. package/dist/integrations/github/session-subscriptions.js +283 -0
  153. package/dist/integrations/github/session-subscriptions.js.map +1 -0
  154. package/dist/integrations/github/settle-or-abort.d.ts +7 -0
  155. package/dist/integrations/github/settle-or-abort.d.ts.map +1 -0
  156. package/dist/integrations/github/settle-or-abort.js +25 -0
  157. package/dist/integrations/github/settle-or-abort.js.map +1 -0
  158. package/dist/integrations/github/stale-reviews.d.ts +22 -0
  159. package/dist/integrations/github/stale-reviews.d.ts.map +1 -0
  160. package/dist/integrations/github/stale-reviews.js +70 -0
  161. package/dist/integrations/github/stale-reviews.js.map +1 -0
  162. package/dist/integrations/github/subscriptions.d.ts +54 -0
  163. package/dist/integrations/github/subscriptions.d.ts.map +1 -0
  164. package/dist/integrations/github/subscriptions.js +64 -0
  165. package/dist/integrations/github/subscriptions.js.map +1 -0
  166. package/dist/integrations/github/token-refresh.d.ts +31 -0
  167. package/dist/integrations/github/token-refresh.d.ts.map +1 -0
  168. package/dist/integrations/github/token-refresh.js +42 -0
  169. package/dist/integrations/github/token-refresh.js.map +1 -0
  170. package/dist/integrations/github/webhook.d.ts +139 -0
  171. package/dist/integrations/github/webhook.d.ts.map +1 -0
  172. package/dist/integrations/github/webhook.js +432 -0
  173. package/dist/integrations/github/webhook.js.map +1 -0
  174. package/dist/integrations/gitlab/agent-tools.d.ts +14 -0
  175. package/dist/integrations/gitlab/agent-tools.d.ts.map +1 -0
  176. package/dist/integrations/gitlab/agent-tools.js +42 -0
  177. package/dist/integrations/gitlab/agent-tools.js.map +1 -0
  178. package/dist/integrations/gitlab/api.d.ts +222 -0
  179. package/dist/integrations/gitlab/api.d.ts.map +1 -0
  180. package/dist/integrations/gitlab/api.js +274 -0
  181. package/dist/integrations/gitlab/api.js.map +1 -0
  182. package/dist/integrations/gitlab/default-rules.d.ts +125 -0
  183. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -0
  184. package/dist/integrations/gitlab/default-rules.js +180 -0
  185. package/dist/integrations/gitlab/default-rules.js.map +1 -0
  186. package/dist/integrations/gitlab/integration.d.ts +138 -0
  187. package/dist/integrations/gitlab/integration.d.ts.map +1 -0
  188. package/dist/integrations/gitlab/integration.js +705 -0
  189. package/dist/integrations/gitlab/integration.js.map +1 -0
  190. package/dist/integrations/gitlab/issue-reconciler.d.ts +6 -0
  191. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -0
  192. package/dist/integrations/gitlab/issue-reconciler.js +123 -0
  193. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -0
  194. package/dist/integrations/gitlab/merge-request-reconciler.d.ts +6 -0
  195. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -0
  196. package/dist/integrations/gitlab/merge-request-reconciler.js +267 -0
  197. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -0
  198. package/dist/integrations/gitlab/reconciler.d.ts +5 -0
  199. package/dist/integrations/gitlab/reconciler.d.ts.map +1 -0
  200. package/dist/integrations/gitlab/reconciler.js +31 -0
  201. package/dist/integrations/gitlab/reconciler.js.map +1 -0
  202. package/dist/integrations/gitlab/reconciliation-config.d.ts +3 -0
  203. package/dist/integrations/gitlab/reconciliation-config.d.ts.map +1 -0
  204. package/dist/integrations/gitlab/reconciliation-config.js +17 -0
  205. package/dist/integrations/gitlab/reconciliation-config.js.map +1 -0
  206. package/dist/integrations/gitlab/routes.d.ts +20 -0
  207. package/dist/integrations/gitlab/routes.d.ts.map +1 -0
  208. package/dist/integrations/gitlab/routes.js +474 -0
  209. package/dist/integrations/gitlab/routes.js.map +1 -0
  210. package/dist/integrations/gitlab/rules.d.ts +35 -0
  211. package/dist/integrations/gitlab/rules.d.ts.map +1 -0
  212. package/dist/integrations/gitlab/rules.js +502 -0
  213. package/dist/integrations/gitlab/rules.js.map +1 -0
  214. package/dist/integrations/gitlab/session-subscriptions.d.ts +32 -0
  215. package/dist/integrations/gitlab/session-subscriptions.d.ts.map +1 -0
  216. package/dist/integrations/gitlab/session-subscriptions.js +193 -0
  217. package/dist/integrations/gitlab/session-subscriptions.js.map +1 -0
  218. package/dist/integrations/gitlab/subscriptions.d.ts +70 -0
  219. package/dist/integrations/gitlab/subscriptions.d.ts.map +1 -0
  220. package/dist/integrations/gitlab/subscriptions.js +76 -0
  221. package/dist/integrations/gitlab/subscriptions.js.map +1 -0
  222. package/dist/integrations/gitlab/version-control.d.ts +16 -0
  223. package/dist/integrations/gitlab/version-control.d.ts.map +1 -0
  224. package/dist/integrations/gitlab/version-control.js +621 -0
  225. package/dist/integrations/gitlab/version-control.js.map +1 -0
  226. package/dist/integrations/gitlab/webhook-dispatch.d.ts +75 -0
  227. package/dist/integrations/gitlab/webhook-dispatch.d.ts.map +1 -0
  228. package/dist/integrations/gitlab/webhook-dispatch.js +235 -0
  229. package/dist/integrations/gitlab/webhook-dispatch.js.map +1 -0
  230. package/dist/integrations/gitlab/webhook.d.ts +72 -0
  231. package/dist/integrations/gitlab/webhook.d.ts.map +1 -0
  232. package/dist/integrations/gitlab/webhook.js +201 -0
  233. package/dist/integrations/gitlab/webhook.js.map +1 -0
  234. package/dist/integrations/incidentio/agent-tools.d.ts +49 -0
  235. package/dist/integrations/incidentio/agent-tools.d.ts.map +1 -0
  236. package/dist/integrations/incidentio/agent-tools.js +90 -0
  237. package/dist/integrations/incidentio/agent-tools.js.map +1 -0
  238. package/dist/integrations/incidentio/api.d.ts +400 -0
  239. package/dist/integrations/incidentio/api.d.ts.map +1 -0
  240. package/dist/integrations/incidentio/api.js +192 -0
  241. package/dist/integrations/incidentio/api.js.map +1 -0
  242. package/dist/integrations/incidentio/claim.d.ts +8 -0
  243. package/dist/integrations/incidentio/claim.d.ts.map +1 -0
  244. package/dist/integrations/incidentio/claim.js +14 -0
  245. package/dist/integrations/incidentio/claim.js.map +1 -0
  246. package/dist/integrations/incidentio/default-rules.d.ts +46 -0
  247. package/dist/integrations/incidentio/default-rules.d.ts.map +1 -0
  248. package/dist/integrations/incidentio/default-rules.js +68 -0
  249. package/dist/integrations/incidentio/default-rules.js.map +1 -0
  250. package/dist/integrations/incidentio/intake.d.ts +10 -0
  251. package/dist/integrations/incidentio/intake.d.ts.map +1 -0
  252. package/dist/integrations/incidentio/intake.js +307 -0
  253. package/dist/integrations/incidentio/intake.js.map +1 -0
  254. package/dist/integrations/incidentio/integration.d.ts +63 -0
  255. package/dist/integrations/incidentio/integration.d.ts.map +1 -0
  256. package/dist/integrations/incidentio/integration.js +141 -0
  257. package/dist/integrations/incidentio/integration.js.map +1 -0
  258. package/dist/integrations/incidentio/issue-reconciler.d.ts +10 -0
  259. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -0
  260. package/dist/integrations/incidentio/issue-reconciler.js +75 -0
  261. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -0
  262. package/dist/integrations/incidentio/reconciliation-config.d.ts +3 -0
  263. package/dist/integrations/incidentio/reconciliation-config.d.ts.map +1 -0
  264. package/dist/integrations/incidentio/reconciliation-config.js +17 -0
  265. package/dist/integrations/incidentio/reconciliation-config.js.map +1 -0
  266. package/dist/integrations/incidentio/routes.d.ts +76 -0
  267. package/dist/integrations/incidentio/routes.d.ts.map +1 -0
  268. package/dist/integrations/incidentio/routes.js +249 -0
  269. package/dist/integrations/incidentio/routes.js.map +1 -0
  270. package/dist/integrations/incidentio/rules.d.ts +55 -0
  271. package/dist/integrations/incidentio/rules.d.ts.map +1 -0
  272. package/dist/integrations/incidentio/rules.js +189 -0
  273. package/dist/integrations/incidentio/rules.js.map +1 -0
  274. package/dist/integrations/issue-reconcile-worker.d.ts +19 -0
  275. package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -0
  276. package/dist/integrations/issue-reconcile-worker.js +97 -0
  277. package/dist/integrations/issue-reconcile-worker.js.map +1 -0
  278. package/dist/integrations/issue-reconciler.d.ts +51 -0
  279. package/dist/integrations/issue-reconciler.d.ts.map +1 -0
  280. package/dist/integrations/issue-reconciler.js +158 -0
  281. package/dist/integrations/issue-reconciler.js.map +1 -0
  282. package/dist/integrations/jira/adf.d.ts +26 -0
  283. package/dist/integrations/jira/adf.d.ts.map +1 -0
  284. package/dist/integrations/jira/adf.js +73 -0
  285. package/dist/integrations/jira/adf.js.map +1 -0
  286. package/dist/integrations/jira/agent-tools.d.ts +45 -0
  287. package/dist/integrations/jira/agent-tools.d.ts.map +1 -0
  288. package/dist/integrations/jira/agent-tools.js +87 -0
  289. package/dist/integrations/jira/agent-tools.js.map +1 -0
  290. package/dist/integrations/jira/api.d.ts +157 -0
  291. package/dist/integrations/jira/api.d.ts.map +1 -0
  292. package/dist/integrations/jira/api.js +141 -0
  293. package/dist/integrations/jira/api.js.map +1 -0
  294. package/dist/integrations/jira/claim.d.ts +9 -0
  295. package/dist/integrations/jira/claim.d.ts.map +1 -0
  296. package/dist/integrations/jira/claim.js +15 -0
  297. package/dist/integrations/jira/claim.js.map +1 -0
  298. package/dist/integrations/jira/default-rules.d.ts +47 -0
  299. package/dist/integrations/jira/default-rules.d.ts.map +1 -0
  300. package/dist/integrations/jira/default-rules.js +69 -0
  301. package/dist/integrations/jira/default-rules.js.map +1 -0
  302. package/dist/integrations/jira/integration.d.ts +114 -0
  303. package/dist/integrations/jira/integration.d.ts.map +1 -0
  304. package/dist/integrations/jira/integration.js +407 -0
  305. package/dist/integrations/jira/integration.js.map +1 -0
  306. package/dist/integrations/jira/issue-reconciler.d.ts +10 -0
  307. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -0
  308. package/dist/integrations/jira/issue-reconciler.js +70 -0
  309. package/dist/integrations/jira/issue-reconciler.js.map +1 -0
  310. package/dist/integrations/jira/reconciliation-config.d.ts +3 -0
  311. package/dist/integrations/jira/reconciliation-config.d.ts.map +1 -0
  312. package/dist/integrations/jira/reconciliation-config.js +17 -0
  313. package/dist/integrations/jira/reconciliation-config.js.map +1 -0
  314. package/dist/integrations/jira/routes.d.ts +54 -0
  315. package/dist/integrations/jira/routes.d.ts.map +1 -0
  316. package/dist/integrations/jira/routes.js +260 -0
  317. package/dist/integrations/jira/routes.js.map +1 -0
  318. package/dist/integrations/jira/rules.d.ts +57 -0
  319. package/dist/integrations/jira/rules.d.ts.map +1 -0
  320. package/dist/integrations/jira/rules.js +189 -0
  321. package/dist/integrations/jira/rules.js.map +1 -0
  322. package/dist/integrations/linear/agent-tools.d.ts +34 -0
  323. package/dist/integrations/linear/agent-tools.d.ts.map +1 -0
  324. package/dist/integrations/linear/agent-tools.js +87 -0
  325. package/dist/integrations/linear/agent-tools.js.map +1 -0
  326. package/dist/integrations/linear/claim.d.ts +8 -0
  327. package/dist/integrations/linear/claim.d.ts.map +1 -0
  328. package/dist/integrations/linear/claim.js +14 -0
  329. package/dist/integrations/linear/claim.js.map +1 -0
  330. package/dist/integrations/linear/default-rules.d.ts +46 -0
  331. package/dist/integrations/linear/default-rules.d.ts.map +1 -0
  332. package/dist/integrations/linear/default-rules.js +70 -0
  333. package/dist/integrations/linear/default-rules.js.map +1 -0
  334. package/dist/integrations/linear/integration.d.ts +260 -0
  335. package/dist/integrations/linear/integration.d.ts.map +1 -0
  336. package/dist/integrations/linear/integration.js +900 -0
  337. package/dist/integrations/linear/integration.js.map +1 -0
  338. package/dist/integrations/linear/issue-reconciler.d.ts +8 -0
  339. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -0
  340. package/dist/integrations/linear/issue-reconciler.js +73 -0
  341. package/dist/integrations/linear/issue-reconciler.js.map +1 -0
  342. package/dist/integrations/linear/reconciliation-config.d.ts +3 -0
  343. package/dist/integrations/linear/reconciliation-config.d.ts.map +1 -0
  344. package/dist/integrations/linear/reconciliation-config.js +21 -0
  345. package/dist/integrations/linear/reconciliation-config.js.map +1 -0
  346. package/dist/integrations/linear/routes.d.ts +81 -0
  347. package/dist/integrations/linear/routes.d.ts.map +1 -0
  348. package/dist/integrations/linear/routes.js +380 -0
  349. package/dist/integrations/linear/routes.js.map +1 -0
  350. package/dist/integrations/linear/rules.d.ts +54 -0
  351. package/dist/integrations/linear/rules.d.ts.map +1 -0
  352. package/dist/integrations/linear/rules.js +189 -0
  353. package/dist/integrations/linear/rules.js.map +1 -0
  354. package/dist/integrations/linear/storage.d.ts +65 -0
  355. package/dist/integrations/linear/storage.d.ts.map +1 -0
  356. package/dist/integrations/linear/storage.js +1 -0
  357. package/dist/integrations/platform/api-client.d.ts +26 -0
  358. package/dist/integrations/platform/api-client.d.ts.map +1 -0
  359. package/dist/integrations/platform/api-client.js +177 -0
  360. package/dist/integrations/platform/api-client.js.map +1 -0
  361. package/dist/integrations/platform/connect/routes.d.ts +39 -0
  362. package/dist/integrations/platform/connect/routes.d.ts.map +1 -0
  363. package/dist/integrations/platform/connect/routes.js +133 -0
  364. package/dist/integrations/platform/connect/routes.js.map +1 -0
  365. package/dist/integrations/platform/github/event-worker.d.ts +58 -0
  366. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -0
  367. package/dist/integrations/platform/github/event-worker.js +449 -0
  368. package/dist/integrations/platform/github/event-worker.js.map +1 -0
  369. package/dist/integrations/platform/github/integration.d.ts +89 -0
  370. package/dist/integrations/platform/github/integration.d.ts.map +1 -0
  371. package/dist/integrations/platform/github/integration.js +1266 -0
  372. package/dist/integrations/platform/github/integration.js.map +1 -0
  373. package/dist/integrations/platform/gitlab/event-worker.d.ts +64 -0
  374. package/dist/integrations/platform/gitlab/event-worker.d.ts.map +1 -0
  375. package/dist/integrations/platform/gitlab/event-worker.js +305 -0
  376. package/dist/integrations/platform/gitlab/event-worker.js.map +1 -0
  377. package/dist/integrations/platform/gitlab/integration.d.ts +57 -0
  378. package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -0
  379. package/dist/integrations/platform/gitlab/integration.js +113 -0
  380. package/dist/integrations/platform/gitlab/integration.js.map +1 -0
  381. package/dist/integrations/platform/incidentio/integration.d.ts +74 -0
  382. package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -0
  383. package/dist/integrations/platform/incidentio/integration.js +406 -0
  384. package/dist/integrations/platform/incidentio/integration.js.map +1 -0
  385. package/dist/integrations/platform/jira/agent-tools.d.ts +36 -0
  386. package/dist/integrations/platform/jira/agent-tools.d.ts.map +1 -0
  387. package/dist/integrations/platform/jira/agent-tools.js +85 -0
  388. package/dist/integrations/platform/jira/agent-tools.js.map +1 -0
  389. package/dist/integrations/platform/jira/integration.d.ts +65 -0
  390. package/dist/integrations/platform/jira/integration.d.ts.map +1 -0
  391. package/dist/integrations/platform/jira/integration.js +546 -0
  392. package/dist/integrations/platform/jira/integration.js.map +1 -0
  393. package/dist/integrations/platform/jira/routes.d.ts +55 -0
  394. package/dist/integrations/platform/jira/routes.d.ts.map +1 -0
  395. package/dist/integrations/platform/jira/routes.js +274 -0
  396. package/dist/integrations/platform/jira/routes.js.map +1 -0
  397. package/dist/integrations/platform/linear/event-worker.d.ts +105 -0
  398. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -0
  399. package/dist/integrations/platform/linear/event-worker.js +379 -0
  400. package/dist/integrations/platform/linear/event-worker.js.map +1 -0
  401. package/dist/integrations/platform/linear/integration.d.ts +92 -0
  402. package/dist/integrations/platform/linear/integration.d.ts.map +1 -0
  403. package/dist/integrations/platform/linear/integration.js +754 -0
  404. package/dist/integrations/platform/linear/integration.js.map +1 -0
  405. package/dist/integrations/pull-request-head.d.ts +18 -0
  406. package/dist/integrations/pull-request-head.d.ts.map +1 -0
  407. package/dist/integrations/pull-request-head.js +45 -0
  408. package/dist/integrations/pull-request-head.js.map +1 -0
  409. package/dist/integrations/reconciliation-config.d.ts +3 -0
  410. package/dist/integrations/reconciliation-config.d.ts.map +1 -0
  411. package/dist/integrations/reconciliation-config.js +16 -0
  412. package/dist/integrations/reconciliation-config.js.map +1 -0
  413. package/dist/integrations/slack/connect-route.d.ts +46 -0
  414. package/dist/integrations/slack/connect-route.d.ts.map +1 -0
  415. package/dist/integrations/slack/connect-route.js +186 -0
  416. package/dist/integrations/slack/connect-route.js.map +1 -0
  417. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +8 -0
  418. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +1 -0
  419. package/dist/integrations/slack/emoji-shortcodes.generated.js +1985 -0
  420. package/dist/integrations/slack/emoji-shortcodes.generated.js.map +1 -0
  421. package/dist/integrations/slack/emoji.d.ts +3 -0
  422. package/dist/integrations/slack/emoji.d.ts.map +1 -0
  423. package/dist/integrations/slack/emoji.js +12 -0
  424. package/dist/integrations/slack/emoji.js.map +1 -0
  425. package/dist/integrations/slack/feed-publisher.d.ts +26 -0
  426. package/dist/integrations/slack/feed-publisher.d.ts.map +1 -0
  427. package/dist/integrations/slack/feed-publisher.js +44 -0
  428. package/dist/integrations/slack/feed-publisher.js.map +1 -0
  429. package/dist/integrations/slack/integration.d.ts +80 -0
  430. package/dist/integrations/slack/integration.d.ts.map +1 -0
  431. package/dist/integrations/slack/integration.js +93 -0
  432. package/dist/integrations/slack/integration.js.map +1 -0
  433. package/dist/integrations/slack/slack.d.ts +205 -0
  434. package/dist/integrations/slack/slack.d.ts.map +1 -0
  435. package/dist/integrations/slack/slack.js +653 -0
  436. package/dist/integrations/slack/slack.js.map +1 -0
  437. package/dist/integrations/subscription-session.d.ts +49 -0
  438. package/dist/integrations/subscription-session.d.ts.map +1 -0
  439. package/dist/integrations/subscription-session.js +103 -0
  440. package/dist/integrations/subscription-session.js.map +1 -0
  441. package/dist/integrations/workos/integration.d.ts +39 -0
  442. package/dist/integrations/workos/integration.d.ts.map +1 -0
  443. package/dist/integrations/workos/integration.js +91 -0
  444. package/dist/integrations/workos/integration.js.map +1 -0
  445. package/dist/packages/_internals/workspace/dist/index.js +48 -0
  446. package/dist/packages/_internals/workspace/dist/index.js.map +1 -0
  447. package/dist/platform-auth-host.d.ts +4 -0
  448. package/dist/platform-auth-host.d.ts.map +1 -0
  449. package/dist/platform-auth-host.js +18 -0
  450. package/dist/platform-auth-host.js.map +1 -0
  451. package/dist/review-verdict.d.ts +6 -0
  452. package/dist/review-verdict.d.ts.map +1 -0
  453. package/dist/review-verdict.js +14 -0
  454. package/dist/review-verdict.js.map +1 -0
  455. package/dist/routes/attention-activity.d.ts +23 -0
  456. package/dist/routes/attention-activity.d.ts.map +1 -0
  457. package/dist/routes/attention-activity.js +152 -0
  458. package/dist/routes/attention-activity.js.map +1 -0
  459. package/dist/routes/attention-parked.d.ts +22 -0
  460. package/dist/routes/attention-parked.d.ts.map +1 -0
  461. package/dist/routes/attention-parked.js +136 -0
  462. package/dist/routes/attention-parked.js.map +1 -0
  463. package/dist/routes/attention-proposed.d.ts +3 -0
  464. package/dist/routes/attention-proposed.d.ts.map +1 -0
  465. package/dist/routes/attention-proposed.js +21 -0
  466. package/dist/routes/attention-proposed.js.map +1 -0
  467. package/dist/routes/attention-providers.d.ts +159 -0
  468. package/dist/routes/attention-providers.d.ts.map +1 -0
  469. package/dist/routes/attention-providers.js +524 -0
  470. package/dist/routes/attention-providers.js.map +1 -0
  471. package/dist/routes/attention.d.ts +23 -0
  472. package/dist/routes/attention.d.ts.map +1 -0
  473. package/dist/routes/attention.js +219 -0
  474. package/dist/routes/attention.js.map +1 -0
  475. package/dist/routes/automation-runs.d.ts +37 -0
  476. package/dist/routes/automation-runs.d.ts.map +1 -0
  477. package/dist/routes/automation-runs.js +196 -0
  478. package/dist/routes/automation-runs.js.map +1 -0
  479. package/dist/routes/config.d.ts +238 -0
  480. package/dist/routes/config.d.ts.map +1 -0
  481. package/dist/routes/config.js +1011 -0
  482. package/dist/routes/config.js.map +1 -0
  483. package/dist/routes/contracts.d.ts +1080 -0
  484. package/dist/routes/contracts.d.ts.map +1 -0
  485. package/dist/routes/contracts.js +673 -0
  486. package/dist/routes/contracts.js.map +1 -0
  487. package/dist/routes/custom-provider-source.d.ts +52 -0
  488. package/dist/routes/custom-provider-source.d.ts.map +1 -0
  489. package/dist/routes/custom-provider-source.js +124 -0
  490. package/dist/routes/custom-provider-source.js.map +1 -0
  491. package/dist/routes/fs.d.ts +189 -0
  492. package/dist/routes/fs.d.ts.map +1 -0
  493. package/dist/routes/fs.js +916 -0
  494. package/dist/routes/fs.js.map +1 -0
  495. package/dist/routes/intake.d.ts +64 -0
  496. package/dist/routes/intake.d.ts.map +1 -0
  497. package/dist/routes/intake.js +627 -0
  498. package/dist/routes/intake.js.map +1 -0
  499. package/dist/routes/knowledge.d.ts +247 -0
  500. package/dist/routes/knowledge.d.ts.map +1 -0
  501. package/dist/routes/knowledge.js +1128 -0
  502. package/dist/routes/knowledge.js.map +1 -0
  503. package/dist/routes/oauth.d.ts +43 -0
  504. package/dist/routes/oauth.d.ts.map +1 -0
  505. package/dist/routes/oauth.js +477 -0
  506. package/dist/routes/oauth.js.map +1 -0
  507. package/dist/routes/projects.d.ts +68 -0
  508. package/dist/routes/projects.d.ts.map +1 -0
  509. package/dist/routes/projects.js +919 -0
  510. package/dist/routes/projects.js.map +1 -0
  511. package/dist/routes/provider-credentials.d.ts +82 -0
  512. package/dist/routes/provider-credentials.d.ts.map +1 -0
  513. package/dist/routes/provider-credentials.js +80 -0
  514. package/dist/routes/provider-credentials.js.map +1 -0
  515. package/dist/routes/route.d.ts +48 -0
  516. package/dist/routes/route.d.ts.map +1 -0
  517. package/dist/routes/route.js +15 -0
  518. package/dist/routes/route.js.map +1 -0
  519. package/dist/routes/skills.d.ts +30 -0
  520. package/dist/routes/skills.d.ts.map +1 -0
  521. package/dist/routes/skills.js +198 -0
  522. package/dist/routes/skills.js.map +1 -0
  523. package/dist/routes/source-control-sessions.d.ts +22 -0
  524. package/dist/routes/source-control-sessions.d.ts.map +1 -0
  525. package/dist/routes/source-control-sessions.js +356 -0
  526. package/dist/routes/source-control-sessions.js.map +1 -0
  527. package/dist/routes/source-control-settings.d.ts +10 -0
  528. package/dist/routes/source-control-settings.d.ts.map +1 -0
  529. package/dist/routes/source-control-settings.js +87 -0
  530. package/dist/routes/source-control-settings.js.map +1 -0
  531. package/dist/routes/supervisor.d.ts +25 -0
  532. package/dist/routes/supervisor.d.ts.map +1 -0
  533. package/dist/routes/supervisor.js +35 -0
  534. package/dist/routes/supervisor.js.map +1 -0
  535. package/dist/routes/surface.d.ts +133 -0
  536. package/dist/routes/surface.d.ts.map +1 -0
  537. package/dist/routes/surface.js +518 -0
  538. package/dist/routes/surface.js.map +1 -0
  539. package/dist/routes/telemetry.d.ts +13 -0
  540. package/dist/routes/telemetry.d.ts.map +1 -0
  541. package/dist/routes/telemetry.js +60 -0
  542. package/dist/routes/telemetry.js.map +1 -0
  543. package/dist/routes/tenant-credentials.d.ts +87 -0
  544. package/dist/routes/tenant-credentials.d.ts.map +1 -0
  545. package/dist/routes/tenant-credentials.js +219 -0
  546. package/dist/routes/tenant-credentials.js.map +1 -0
  547. package/dist/routes/work-items.d.ts +49 -0
  548. package/dist/routes/work-items.d.ts.map +1 -0
  549. package/dist/routes/work-items.js +633 -0
  550. package/dist/routes/work-items.js.map +1 -0
  551. package/dist/rules/binding-context.d.ts +59 -0
  552. package/dist/rules/binding-context.d.ts.map +1 -0
  553. package/dist/rules/binding-context.js +134 -0
  554. package/dist/rules/binding-context.js.map +1 -0
  555. package/dist/rules/decision-applicability.d.ts +32 -0
  556. package/dist/rules/decision-applicability.d.ts.map +1 -0
  557. package/dist/rules/decision-applicability.js +56 -0
  558. package/dist/rules/decision-applicability.js.map +1 -0
  559. package/dist/rules/dispatch-errors.d.ts +13 -0
  560. package/dist/rules/dispatch-errors.d.ts.map +1 -0
  561. package/dist/rules/dispatch-errors.js +105 -0
  562. package/dist/rules/dispatch-errors.js.map +1 -0
  563. package/dist/rules/dispatcher.d.ts +86 -0
  564. package/dist/rules/dispatcher.d.ts.map +1 -0
  565. package/dist/rules/dispatcher.js +1159 -0
  566. package/dist/rules/dispatcher.js.map +1 -0
  567. package/dist/rules/event-rules.d.ts +23 -0
  568. package/dist/rules/event-rules.d.ts.map +1 -0
  569. package/dist/rules/event-rules.js +46 -0
  570. package/dist/rules/event-rules.js.map +1 -0
  571. package/dist/rules/index.d.ts +6 -0
  572. package/dist/rules/index.d.ts.map +1 -0
  573. package/dist/rules/index.js +4 -0
  574. package/dist/rules/processor.d.ts +90 -0
  575. package/dist/rules/processor.d.ts.map +1 -0
  576. package/dist/rules/processor.js +486 -0
  577. package/dist/rules/processor.js.map +1 -0
  578. package/dist/rules/resolve.d.ts +15 -0
  579. package/dist/rules/resolve.d.ts.map +1 -0
  580. package/dist/rules/resolve.js +23 -0
  581. package/dist/rules/resolve.js.map +1 -0
  582. package/dist/rules/review-source-tool.d.ts +105 -0
  583. package/dist/rules/review-source-tool.d.ts.map +1 -0
  584. package/dist/rules/review-source-tool.js +109 -0
  585. package/dist/rules/review-source-tool.js.map +1 -0
  586. package/dist/rules/start-coordinator.d.ts +64 -0
  587. package/dist/rules/start-coordinator.d.ts.map +1 -0
  588. package/dist/rules/start-coordinator.js +246 -0
  589. package/dist/rules/start-coordinator.js.map +1 -0
  590. package/dist/rules/terminal-cleanup.d.ts +38 -0
  591. package/dist/rules/terminal-cleanup.d.ts.map +1 -0
  592. package/dist/rules/terminal-cleanup.js +68 -0
  593. package/dist/rules/terminal-cleanup.js.map +1 -0
  594. package/dist/rules/tools.d.ts +15 -0
  595. package/dist/rules/tools.d.ts.map +1 -0
  596. package/dist/rules/tools.js +185 -0
  597. package/dist/rules/tools.js.map +1 -0
  598. package/dist/rules/transition-service.d.ts +93 -0
  599. package/dist/rules/transition-service.d.ts.map +1 -0
  600. package/dist/rules/transition-service.js +402 -0
  601. package/dist/rules/transition-service.js.map +1 -0
  602. package/dist/rules/types.d.ts +553 -0
  603. package/dist/rules/types.d.ts.map +1 -0
  604. package/dist/rules/types.js +154 -0
  605. package/dist/rules/types.js.map +1 -0
  606. package/dist/rules/validation.d.ts +21 -0
  607. package/dist/rules/validation.d.ts.map +1 -0
  608. package/dist/rules/validation.js +327 -0
  609. package/dist/rules/validation.js.map +1 -0
  610. package/dist/sandbox/callback-factory-sandbox.d.ts +15 -0
  611. package/dist/sandbox/callback-factory-sandbox.d.ts.map +1 -0
  612. package/dist/sandbox/callback-factory-sandbox.js +22 -0
  613. package/dist/sandbox/callback-factory-sandbox.js.map +1 -0
  614. package/dist/sandbox/git-ref.d.ts +7 -0
  615. package/dist/sandbox/git-ref.d.ts.map +1 -0
  616. package/dist/sandbox/git-ref.js +15 -0
  617. package/dist/sandbox/git-ref.js.map +1 -0
  618. package/dist/sandbox/local-factory-sandbox.d.ts +20 -0
  619. package/dist/sandbox/local-factory-sandbox.d.ts.map +1 -0
  620. package/dist/sandbox/local-factory-sandbox.js +27 -0
  621. package/dist/sandbox/local-factory-sandbox.js.map +1 -0
  622. package/dist/sandbox/materialization.d.ts +41 -0
  623. package/dist/sandbox/materialization.d.ts.map +1 -0
  624. package/dist/sandbox/materialization.js +18 -0
  625. package/dist/sandbox/materialization.js.map +1 -0
  626. package/dist/sandbox/session-retirement.d.ts +45 -0
  627. package/dist/sandbox/session-retirement.d.ts.map +1 -0
  628. package/dist/sandbox/session-retirement.js +153 -0
  629. package/dist/sandbox/session-retirement.js.map +1 -0
  630. package/dist/sandbox/session-sandbox.d.ts +185 -0
  631. package/dist/sandbox/session-sandbox.d.ts.map +1 -0
  632. package/dist/sandbox/session-sandbox.js +248 -0
  633. package/dist/sandbox/session-sandbox.js.map +1 -0
  634. package/dist/sandbox/workdir.d.ts +45 -0
  635. package/dist/sandbox/workdir.d.ts.map +1 -0
  636. package/dist/sandbox/workdir.js +64 -0
  637. package/dist/sandbox/workdir.js.map +1 -0
  638. package/dist/secret-encryption.d.ts +25 -0
  639. package/dist/secret-encryption.d.ts.map +1 -0
  640. package/dist/secret-encryption.js +107 -0
  641. package/dist/secret-encryption.js.map +1 -0
  642. package/dist/server-error.d.ts +12 -0
  643. package/dist/server-error.d.ts.map +1 -0
  644. package/dist/server-error.js +16 -0
  645. package/dist/server-error.js.map +1 -0
  646. package/dist/session/credential-policy.d.ts +20 -0
  647. package/dist/session/credential-policy.d.ts.map +1 -0
  648. package/dist/session/credential-policy.js +70 -0
  649. package/dist/session/credential-policy.js.map +1 -0
  650. package/dist/session/default-model-hydration.d.ts +46 -0
  651. package/dist/session/default-model-hydration.d.ts.map +1 -0
  652. package/dist/session/default-model-hydration.js +85 -0
  653. package/dist/session/default-model-hydration.js.map +1 -0
  654. package/dist/session/environment-repositories.d.ts +31 -0
  655. package/dist/session/environment-repositories.d.ts.map +1 -0
  656. package/dist/session/environment-repositories.js +89 -0
  657. package/dist/session/environment-repositories.js.map +1 -0
  658. package/dist/session/environment-state-processor.d.ts +59 -0
  659. package/dist/session/environment-state-processor.d.ts.map +1 -0
  660. package/dist/session/environment-state-processor.js +105 -0
  661. package/dist/session/environment-state-processor.js.map +1 -0
  662. package/dist/session/factory-session.d.ts +159 -0
  663. package/dist/session/factory-session.d.ts.map +1 -0
  664. package/dist/session/factory-session.js +226 -0
  665. package/dist/session/factory-session.js.map +1 -0
  666. package/dist/session/filesystem-capture.d.ts +50 -0
  667. package/dist/session/filesystem-capture.d.ts.map +1 -0
  668. package/dist/session/filesystem-capture.js +231 -0
  669. package/dist/session/filesystem-capture.js.map +1 -0
  670. package/dist/session/first-exec-capture.d.ts +38 -0
  671. package/dist/session/first-exec-capture.d.ts.map +1 -0
  672. package/dist/session/first-exec-capture.js +91 -0
  673. package/dist/session/first-exec-capture.js.map +1 -0
  674. package/dist/session/first-message-capture.d.ts +33 -0
  675. package/dist/session/first-message-capture.d.ts.map +1 -0
  676. package/dist/session/first-message-capture.js +35 -0
  677. package/dist/session/first-message-capture.js.map +1 -0
  678. package/dist/session/live-sessions.d.ts +63 -0
  679. package/dist/session/live-sessions.d.ts.map +1 -0
  680. package/dist/session/live-sessions.js +90 -0
  681. package/dist/session/live-sessions.js.map +1 -0
  682. package/dist/session/memory-settings-hydration.d.ts +36 -0
  683. package/dist/session/memory-settings-hydration.d.ts.map +1 -0
  684. package/dist/session/memory-settings-hydration.js +43 -0
  685. package/dist/session/memory-settings-hydration.js.map +1 -0
  686. package/dist/session/org-seed.d.ts +67 -0
  687. package/dist/session/org-seed.d.ts.map +1 -0
  688. package/dist/session/org-seed.js +53 -0
  689. package/dist/session/org-seed.js.map +1 -0
  690. package/dist/session/run-audit.d.ts +54 -0
  691. package/dist/session/run-audit.d.ts.map +1 -0
  692. package/dist/session/run-audit.js +124 -0
  693. package/dist/session/run-audit.js.map +1 -0
  694. package/dist/session/session-title.d.ts +7 -0
  695. package/dist/session/session-title.d.ts.map +1 -0
  696. package/dist/session/session-title.js +14 -0
  697. package/dist/session/session-title.js.map +1 -0
  698. package/dist/session/shell-commands.d.ts +5 -0
  699. package/dist/session/shell-commands.d.ts.map +1 -0
  700. package/dist/session/shell-commands.js +25 -0
  701. package/dist/session/shell-commands.js.map +1 -0
  702. package/dist/session/source-control-tools.d.ts +25 -0
  703. package/dist/session/source-control-tools.d.ts.map +1 -0
  704. package/dist/session/source-control-tools.js +594 -0
  705. package/dist/session/source-control-tools.js.map +1 -0
  706. package/dist/session/thread-title-mirror.d.ts +35 -0
  707. package/dist/session/thread-title-mirror.d.ts.map +1 -0
  708. package/dist/session/thread-title-mirror.js +51 -0
  709. package/dist/session/thread-title-mirror.js.map +1 -0
  710. package/dist/session/work-item-repository.d.ts +21 -0
  711. package/dist/session/work-item-repository.d.ts.map +1 -0
  712. package/dist/session/work-item-repository.js +113 -0
  713. package/dist/session/work-item-repository.js.map +1 -0
  714. package/dist/skills/catalog.d.ts +14 -0
  715. package/dist/skills/catalog.d.ts.map +1 -0
  716. package/dist/skills/catalog.js +62 -0
  717. package/dist/skills/catalog.js.map +1 -0
  718. package/dist/skills/service.d.ts +70 -0
  719. package/dist/skills/service.d.ts.map +1 -0
  720. package/dist/skills/service.js +88 -0
  721. package/dist/skills/service.js.map +1 -0
  722. package/dist/spa-static.d.ts +33 -0
  723. package/dist/spa-static.d.ts.map +1 -0
  724. package/dist/spa-static.js +104 -0
  725. package/dist/spa-static.js.map +1 -0
  726. package/dist/state-signing.d.ts +59 -0
  727. package/dist/state-signing.d.ts.map +1 -0
  728. package/dist/state-signing.js +83 -0
  729. package/dist/state-signing.js.map +1 -0
  730. package/dist/storage/domains/audit/actions.d.ts +24 -0
  731. package/dist/storage/domains/audit/actions.d.ts.map +1 -0
  732. package/dist/storage/domains/audit/actions.js +69 -0
  733. package/dist/storage/domains/audit/actions.js.map +1 -0
  734. package/dist/storage/domains/audit/actors.d.ts +5 -0
  735. package/dist/storage/domains/audit/actors.d.ts.map +1 -0
  736. package/dist/storage/domains/audit/actors.js +25 -0
  737. package/dist/storage/domains/audit/actors.js.map +1 -0
  738. package/dist/storage/domains/audit/agent-audit.d.ts +30 -0
  739. package/dist/storage/domains/audit/agent-audit.d.ts.map +1 -0
  740. package/dist/storage/domains/audit/agent-audit.js +93 -0
  741. package/dist/storage/domains/audit/agent-audit.js.map +1 -0
  742. package/dist/storage/domains/audit/base.d.ts +133 -0
  743. package/dist/storage/domains/audit/base.d.ts.map +1 -0
  744. package/dist/storage/domains/audit/base.js +206 -0
  745. package/dist/storage/domains/audit/base.js.map +1 -0
  746. package/dist/storage/domains/audit/domain.d.ts +79 -0
  747. package/dist/storage/domains/audit/domain.d.ts.map +1 -0
  748. package/dist/storage/domains/audit/domain.js +248 -0
  749. package/dist/storage/domains/audit/domain.js.map +1 -0
  750. package/dist/storage/domains/audit/wire.d.ts +24 -0
  751. package/dist/storage/domains/audit/wire.d.ts.map +1 -0
  752. package/dist/storage/domains/audit/wire.js +16 -0
  753. package/dist/storage/domains/audit/wire.js.map +1 -0
  754. package/dist/storage/domains/channel-identity/base.d.ts +100 -0
  755. package/dist/storage/domains/channel-identity/base.d.ts.map +1 -0
  756. package/dist/storage/domains/channel-identity/base.js +164 -0
  757. package/dist/storage/domains/channel-identity/base.js.map +1 -0
  758. package/dist/storage/domains/comments/activity.d.ts +40 -0
  759. package/dist/storage/domains/comments/activity.d.ts.map +1 -0
  760. package/dist/storage/domains/comments/activity.js +94 -0
  761. package/dist/storage/domains/comments/activity.js.map +1 -0
  762. package/dist/storage/domains/comments/actor.d.ts +51 -0
  763. package/dist/storage/domains/comments/actor.d.ts.map +1 -0
  764. package/dist/storage/domains/comments/actor.js +38 -0
  765. package/dist/storage/domains/comments/actor.js.map +1 -0
  766. package/dist/storage/domains/comments/base.d.ts +245 -0
  767. package/dist/storage/domains/comments/base.d.ts.map +1 -0
  768. package/dist/storage/domains/comments/base.js +533 -0
  769. package/dist/storage/domains/comments/base.js.map +1 -0
  770. package/dist/storage/domains/comments/domain.d.ts +135 -0
  771. package/dist/storage/domains/comments/domain.d.ts.map +1 -0
  772. package/dist/storage/domains/comments/domain.js +285 -0
  773. package/dist/storage/domains/comments/domain.js.map +1 -0
  774. package/dist/storage/domains/comments/feed-context.d.ts +22 -0
  775. package/dist/storage/domains/comments/feed-context.d.ts.map +1 -0
  776. package/dist/storage/domains/comments/feed-context.js +89 -0
  777. package/dist/storage/domains/comments/feed-context.js.map +1 -0
  778. package/dist/storage/domains/comments/feed-sync.d.ts +21 -0
  779. package/dist/storage/domains/comments/feed-sync.d.ts.map +1 -0
  780. package/dist/storage/domains/comments/feed-sync.js +1 -0
  781. package/dist/storage/domains/comments/parse.d.ts +23 -0
  782. package/dist/storage/domains/comments/parse.d.ts.map +1 -0
  783. package/dist/storage/domains/comments/parse.js +90 -0
  784. package/dist/storage/domains/comments/parse.js.map +1 -0
  785. package/dist/storage/domains/comments/routes.d.ts +24 -0
  786. package/dist/storage/domains/comments/routes.d.ts.map +1 -0
  787. package/dist/storage/domains/comments/routes.js +302 -0
  788. package/dist/storage/domains/comments/routes.js.map +1 -0
  789. package/dist/storage/domains/comments/schema.d.ts +5 -0
  790. package/dist/storage/domains/comments/schema.d.ts.map +1 -0
  791. package/dist/storage/domains/comments/schema.js +179 -0
  792. package/dist/storage/domains/comments/schema.js.map +1 -0
  793. package/dist/storage/domains/comments/wire.d.ts +40 -0
  794. package/dist/storage/domains/comments/wire.d.ts.map +1 -0
  795. package/dist/storage/domains/comments/wire.js +37 -0
  796. package/dist/storage/domains/comments/wire.js.map +1 -0
  797. package/dist/storage/domains/credentials/base.d.ts +136 -0
  798. package/dist/storage/domains/credentials/base.d.ts.map +1 -0
  799. package/dist/storage/domains/credentials/base.js +294 -0
  800. package/dist/storage/domains/credentials/base.js.map +1 -0
  801. package/dist/storage/domains/custom-providers/base.d.ts +59 -0
  802. package/dist/storage/domains/custom-providers/base.d.ts.map +1 -0
  803. package/dist/storage/domains/custom-providers/base.js +176 -0
  804. package/dist/storage/domains/custom-providers/base.js.map +1 -0
  805. package/dist/storage/domains/filesystem/base.d.ts +26 -0
  806. package/dist/storage/domains/filesystem/base.d.ts.map +1 -0
  807. package/dist/storage/domains/filesystem/base.js +74 -0
  808. package/dist/storage/domains/filesystem/base.js.map +1 -0
  809. package/dist/storage/domains/intake/base.d.ts +150 -0
  810. package/dist/storage/domains/intake/base.d.ts.map +1 -0
  811. package/dist/storage/domains/intake/base.js +431 -0
  812. package/dist/storage/domains/intake/base.js.map +1 -0
  813. package/dist/storage/domains/integrations/base.d.ts +128 -0
  814. package/dist/storage/domains/integrations/base.d.ts.map +1 -0
  815. package/dist/storage/domains/integrations/base.js +333 -0
  816. package/dist/storage/domains/integrations/base.js.map +1 -0
  817. package/dist/storage/domains/memory-settings/base.d.ts +58 -0
  818. package/dist/storage/domains/memory-settings/base.d.ts.map +1 -0
  819. package/dist/storage/domains/memory-settings/base.js +129 -0
  820. package/dist/storage/domains/memory-settings/base.js.map +1 -0
  821. package/dist/storage/domains/model-defaults/base.d.ts +29 -0
  822. package/dist/storage/domains/model-defaults/base.d.ts.map +1 -0
  823. package/dist/storage/domains/model-defaults/base.js +79 -0
  824. package/dist/storage/domains/model-defaults/base.js.map +1 -0
  825. package/dist/storage/domains/projects/base.d.ts +191 -0
  826. package/dist/storage/domains/projects/base.d.ts.map +1 -0
  827. package/dist/storage/domains/projects/base.js +352 -0
  828. package/dist/storage/domains/projects/base.js.map +1 -0
  829. package/dist/storage/domains/queue-health/base.d.ts +52 -0
  830. package/dist/storage/domains/queue-health/base.d.ts.map +1 -0
  831. package/dist/storage/domains/queue-health/base.js +122 -0
  832. package/dist/storage/domains/queue-health/base.js.map +1 -0
  833. package/dist/storage/domains/source-control/base.d.ts +422 -0
  834. package/dist/storage/domains/source-control/base.d.ts.map +1 -0
  835. package/dist/storage/domains/source-control/base.js +1114 -0
  836. package/dist/storage/domains/source-control/base.js.map +1 -0
  837. package/dist/storage/domains/source-control/inmemory.d.ts +147 -0
  838. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -0
  839. package/dist/storage/domains/source-control/inmemory.js +416 -0
  840. package/dist/storage/domains/source-control/inmemory.js.map +1 -0
  841. package/dist/storage/domains/work-items/base.d.ts +794 -0
  842. package/dist/storage/domains/work-items/base.d.ts.map +1 -0
  843. package/dist/storage/domains/work-items/base.js +2747 -0
  844. package/dist/storage/domains/work-items/base.js.map +1 -0
  845. package/dist/storage/domains/work-items/board-version.d.ts +26 -0
  846. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -0
  847. package/dist/storage/domains/work-items/board-version.js +110 -0
  848. package/dist/storage/domains/work-items/board-version.js.map +1 -0
  849. package/dist/storage/domains/work-items/metrics.d.ts +97 -0
  850. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -0
  851. package/dist/storage/domains/work-items/metrics.js +226 -0
  852. package/dist/storage/domains/work-items/metrics.js.map +1 -0
  853. package/dist/supervisor/health-worker.d.ts +19 -0
  854. package/dist/supervisor/health-worker.d.ts.map +1 -0
  855. package/dist/supervisor/health-worker.js +74 -0
  856. package/dist/supervisor/health-worker.js.map +1 -0
  857. package/dist/supervisor/health.d.ts +79 -0
  858. package/dist/supervisor/health.d.ts.map +1 -0
  859. package/dist/supervisor/health.js +228 -0
  860. package/dist/supervisor/health.js.map +1 -0
  861. package/dist/supervisor/instructions.d.ts +6 -0
  862. package/dist/supervisor/instructions.d.ts.map +1 -0
  863. package/dist/supervisor/instructions.js +66 -0
  864. package/dist/supervisor/instructions.js.map +1 -0
  865. package/dist/supervisor/read-tools.d.ts +43 -0
  866. package/dist/supervisor/read-tools.d.ts.map +1 -0
  867. package/dist/supervisor/read-tools.js +343 -0
  868. package/dist/supervisor/read-tools.js.map +1 -0
  869. package/dist/supervisor/session-messaging.d.ts +26 -0
  870. package/dist/supervisor/session-messaging.d.ts.map +1 -0
  871. package/dist/supervisor/session-messaging.js +21 -0
  872. package/dist/supervisor/session-messaging.js.map +1 -0
  873. package/dist/supervisor/session.d.ts +38 -0
  874. package/dist/supervisor/session.d.ts.map +1 -0
  875. package/dist/supervisor/session.js +79 -0
  876. package/dist/supervisor/session.js.map +1 -0
  877. package/dist/supervisor/write-tools.d.ts +30 -0
  878. package/dist/supervisor/write-tools.d.ts.map +1 -0
  879. package/dist/supervisor/write-tools.js +231 -0
  880. package/dist/supervisor/write-tools.js.map +1 -0
  881. package/dist/telemetry-types.d.ts +7 -0
  882. package/dist/telemetry-types.d.ts.map +1 -0
  883. package/dist/telemetry-types.js +24 -0
  884. package/dist/telemetry-types.js.map +1 -0
  885. package/dist/telemetry.d.ts +9 -0
  886. package/dist/telemetry.d.ts.map +1 -0
  887. package/dist/telemetry.js +47 -0
  888. package/dist/telemetry.js.map +1 -0
  889. package/dist/timing.d.ts +15 -0
  890. package/dist/timing.d.ts.map +1 -0
  891. package/dist/timing.js +34 -0
  892. package/dist/timing.js.map +1 -0
  893. package/dist/work-item-branch.d.ts +33 -0
  894. package/dist/work-item-branch.d.ts.map +1 -0
  895. package/dist/work-item-branch.js +70 -0
  896. package/dist/work-item-branch.js.map +1 -0
  897. package/dist/workspace.d.ts +131 -0
  898. package/dist/workspace.d.ts.map +1 -0
  899. package/dist/workspace.js +995 -0
  900. package/dist/workspace.js.map +1 -0
  901. package/factory-skills/configure-factory-rules/SKILL.md +122 -0
  902. package/factory-skills/factory-complete-issue/SKILL.md +24 -0
  903. package/factory-skills/factory-gitlab-rereview/SKILL.md +22 -0
  904. package/factory-skills/factory-gitlab-review/SKILL.md +48 -0
  905. package/factory-skills/factory-plan/SKILL.md +72 -0
  906. package/factory-skills/factory-rereview/SKILL.md +225 -0
  907. package/factory-skills/factory-review/SKILL.md +214 -0
  908. package/factory-skills/factory-review/references/archaeology.md +225 -0
  909. package/factory-skills/factory-review/references/categories/README.md +34 -0
  910. package/factory-skills/factory-review/references/categories/behavior-change.md +36 -0
  911. package/factory-skills/factory-review/references/categories/bug-fix.md +37 -0
  912. package/factory-skills/factory-review/references/categories/docs.md +32 -0
  913. package/factory-skills/factory-review/references/categories/experimental-flagged.md +34 -0
  914. package/factory-skills/factory-review/references/categories/infra-tooling.md +37 -0
  915. package/factory-skills/factory-review/references/categories/internal-capability.md +35 -0
  916. package/factory-skills/factory-review/references/categories/large-cross-cutting.md +35 -0
  917. package/factory-skills/factory-review/references/categories/mechanical.md +36 -0
  918. package/factory-skills/factory-review/references/categories/performance.md +33 -0
  919. package/factory-skills/factory-review/references/categories/public-api.md +38 -0
  920. package/factory-skills/factory-review/references/categories/refactor.md +35 -0
  921. package/factory-skills/factory-review/references/categories/revert.md +31 -0
  922. package/factory-skills/factory-review/references/categories/schema-storage.md +39 -0
  923. package/factory-skills/factory-review/references/categories/security.md +35 -0
  924. package/factory-skills/factory-review/references/categories/tests-only.md +38 -0
  925. package/factory-skills/factory-triage/SKILL.md +197 -0
  926. package/package.json +92 -0
@@ -0,0 +1,1362 @@
1
+ import { AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL } from "../../rules/types.js";
2
+ import { listRepositoryCommits } from "./commits.js";
3
+ import { clearGithubPat, getGithubPatStatus, setGithubPat } from "./pat.js";
4
+ import { isValidGitRef } from "../../sandbox/git-ref.js";
5
+ import { MaterializeError, SetupCommandError, commitAll, pushBranch } from "./sandbox.js";
6
+ import { requireExec } from "../../sandbox/materialization.js";
7
+ import { sanitizeSegment } from "../../sandbox/workdir.js";
8
+ import { peekSessionSandbox } from "../../sandbox/session-sandbox.js";
9
+ import { listPullRequestSubscriptionsForThread, subscribeToPullRequest } from "./subscriptions.js";
10
+ import { polledPullRequestEvent } from "./rules.js";
11
+ import { waitForPendingFilesystemCapture } from "../../session/filesystem-capture.js";
12
+ import { normalizeSessionTitle } from "../../session/session-title.js";
13
+ import { getGithubFeatureDiagnostics, isGithubFeatureEnabled } from "./config.js";
14
+ import { reclaimDeletedSessionSandbox } from "./sandbox-release.js";
15
+ import { handleGithubWebhook } from "./webhook.js";
16
+ import { RequestContext } from "@mastra/core/request-context";
17
+ import { registerApiRoute } from "@mastra/core/server";
18
+ import { UniqueViolationError } from "@mastra/core/storage";
19
+ import { resolveModel } from "@mastra/code-sdk/agents/model";
20
+ //#region src/integrations/github/routes.ts
21
+ const sessionOperationLocks = /* @__PURE__ */ new Map();
22
+ const USER_SESSION_BRANCH_PREFIX = "user/session-";
23
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
24
+ /**
25
+ * Serialize same-session mutations within one Factory process. Factory sessions
26
+ * normally issue these operations sequentially, so this lock is probably not
27
+ * necessary; keep the cheap local guard until that invariant is enforced by
28
+ * the request protocol. It intentionally does not consume a database connection.
29
+ */
30
+ function withSessionOperationLock(sessionId, fn) {
31
+ const next = (sessionOperationLocks.get(sessionId) ?? Promise.resolve()).then(fn, fn);
32
+ const tail = next.then(() => void 0, () => void 0);
33
+ sessionOperationLocks.set(sessionId, tail);
34
+ tail.then(() => {
35
+ if (sessionOperationLocks.get(sessionId) === tail) sessionOperationLocks.delete(sessionId);
36
+ });
37
+ return next;
38
+ }
39
+ /** Erase a route handler's path-parameterized context to a plain `Context`. */
40
+ function loose(c) {
41
+ return c;
42
+ }
43
+ function pullRequestNumberFromUrl(value, expectedRepo) {
44
+ try {
45
+ const url = new URL(value);
46
+ const match = url.pathname.match(/^\/([^/]+\/[^/]+)\/pull\/(\d+)\/?$/);
47
+ if (url.protocol !== "https:" || url.hostname !== "github.com" || match?.[1]?.toLowerCase() !== expectedRepo.toLowerCase()) return;
48
+ const number = Number(match[2]);
49
+ return Number.isInteger(number) && number > 0 ? number : void 0;
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ function isJsonObject(value) {
55
+ return typeof value === "object" && value !== null && !Array.isArray(value);
56
+ }
57
+ /**
58
+ * Resolve the org-scoped tenant for a GitHub request. GitHub project features
59
+ * are org-owned, so they require both a signed-in user and a WorkOS
60
+ * organization. Returns the `(orgId, userId)` tenant (with `orgId` narrowed to a
61
+ * non-null string) or a ready-to-return error response: 401 when unauthenticated,
62
+ * 403 when the user has no organization (personal account).
63
+ *
64
+ * Resolves the session from the request cookie itself (via `auth.ensureUser`)
65
+ * instead of relying on the auth gate's context stash: on platform deploys
66
+ * custom `apiRoutes` run on an isolated sub-app context where the gate's
67
+ * `c.set(...)` is invisible. When the gate stash IS visible (local Hono
68
+ * server), `auth.ensureUser` returns the cached user and this is a no-op.
69
+ */
70
+ async function resolveOrgTenant(c, auth) {
71
+ await auth.ensureUser(c);
72
+ const tenant = auth.tenant(c);
73
+ if (!tenant) return { response: c.json({ error: "unauthorized" }, 401) };
74
+ if (!tenant.orgId) return { response: c.json({
75
+ error: "organization_required",
76
+ message: "GitHub projects require a WorkOS organization. Personal accounts cannot connect repositories."
77
+ }, 403) };
78
+ return { tenant: {
79
+ orgId: tenant.orgId,
80
+ userId: tenant.userId
81
+ } };
82
+ }
83
+ /**
84
+ * Parse a 1-based `page` query param. Missing means page 1; anything that is
85
+ * not a small positive integer is rejected (`null`).
86
+ */
87
+ function parseListPage(raw) {
88
+ if (raw === void 0) return 1;
89
+ if (!/^\d{1,5}$/.test(raw)) return null;
90
+ const page = Number(raw);
91
+ return page >= 1 ? page : null;
92
+ }
93
+ function parseResourceNumber(raw) {
94
+ if (raw === void 0 || !/^\d{1,10}$/.test(raw)) return null;
95
+ const parsed = Number(raw);
96
+ return parsed > 0 ? parsed : null;
97
+ }
98
+ const VALID_ISSUE_LABEL_FILTERS = /* @__PURE__ */ new Set([AUTO_TRIAGED_LABEL, NEEDS_APPROVAL_LABEL]);
99
+ function parseIssueLabelFilter(raw) {
100
+ if (raw === void 0 || raw === "") return void 0;
101
+ if (VALID_ISSUE_LABEL_FILTERS.has(raw)) return raw;
102
+ return null;
103
+ }
104
+ async function resolveProjectRepository(args) {
105
+ const projectRepository = await args.github.sourceControlStorage.projectRepositories.get({
106
+ orgId: args.orgId,
107
+ id: args.projectRepositoryId
108
+ });
109
+ if (!projectRepository) return null;
110
+ const connection = await args.github.sourceControlStorage.connections.get({
111
+ orgId: args.orgId,
112
+ id: projectRepository.connectionId
113
+ });
114
+ if (!connection) return null;
115
+ const repository = await args.github.sourceControlStorage.repositories.get({
116
+ orgId: args.orgId,
117
+ id: projectRepository.repositoryId
118
+ });
119
+ if (!repository) return null;
120
+ const installation = await args.github.sourceControlStorage.installations.get({
121
+ orgId: args.orgId,
122
+ id: connection.installationId
123
+ });
124
+ if (!installation) return null;
125
+ return {
126
+ ...projectRepository,
127
+ connection,
128
+ installation,
129
+ repository,
130
+ factoryProjectId: connection.factoryProjectId,
131
+ defaultBranch: projectRepository.branch ?? repository.defaultBranch
132
+ };
133
+ }
134
+ function polledIssueEvent(project, issue) {
135
+ const repositoryId = Number(project.repository.externalId);
136
+ const assigneeLogins = issue.assignees ?? (issue.assignee ? [issue.assignee] : []);
137
+ return {
138
+ event: "issues",
139
+ deliveryId: `poll:${repositoryId}:issue:${issue.number}:${issue.createdAt}`,
140
+ payload: {
141
+ action: "opened",
142
+ installation: { id: Number(project.installation.externalId) },
143
+ repository: {
144
+ id: repositoryId,
145
+ full_name: project.repository.slug
146
+ },
147
+ sender: { login: issue.author ?? "__unknown__" },
148
+ issue: {
149
+ number: issue.number,
150
+ title: issue.title,
151
+ html_url: issue.url,
152
+ created_at: issue.createdAt,
153
+ assignees: assigneeLogins.map((login) => ({ login })),
154
+ labels: issue.labels.map((name) => ({ name }))
155
+ }
156
+ }
157
+ };
158
+ }
159
+ function listedPullRequestEvent(project, pullRequest) {
160
+ return polledPullRequestEvent(reconcileRepositoryOf(project), pullRequest.number, listedOpenPullRequestState(pullRequest));
161
+ }
162
+ function reconcileRepositoryOf(project) {
163
+ return {
164
+ id: Number(project.repository.externalId),
165
+ fullName: project.repository.slug,
166
+ installationId: Number(project.installation.externalId)
167
+ };
168
+ }
169
+ function listedOpenPullRequestState(pullRequest) {
170
+ return {
171
+ title: pullRequest.title,
172
+ url: pullRequest.url,
173
+ state: "open",
174
+ draft: false,
175
+ merged: false,
176
+ assignees: pullRequest.assignees,
177
+ requestedReviewers: pullRequest.requestedReviewers,
178
+ labels: pullRequest.labels,
179
+ headBranch: pullRequest.headBranch,
180
+ baseBranch: pullRequest.baseBranch,
181
+ author: pullRequest.author ?? void 0,
182
+ createdAt: pullRequest.createdAt
183
+ };
184
+ }
185
+ async function ingestPolledEvents(events, ingestFactoryEvent) {
186
+ if (!ingestFactoryEvent) return;
187
+ const rejected = (await Promise.allSettled(events.map((event) => ingestFactoryEvent(event)))).find((result) => result.status === "rejected");
188
+ if (rejected) console.warn("[Mastra Factory] Failed to ingest polled GitHub events", { error: rejected.reason });
189
+ }
190
+ const LINKED_BACKLOG_MAX_PAGES = 5;
191
+ function listedIssueOf(issue) {
192
+ return {
193
+ number: Number(issue.id),
194
+ title: issue.title,
195
+ url: issue.url,
196
+ author: issue.author,
197
+ assignee: issue.assignee,
198
+ assignees: issue.assignees,
199
+ labels: issue.labels,
200
+ createdAt: issue.createdAt
201
+ };
202
+ }
203
+ function listedPullRequestOf(pr) {
204
+ return {
205
+ number: Number(pr.id),
206
+ title: pr.title,
207
+ url: pr.url,
208
+ author: pr.author,
209
+ assignees: pr.assignees ?? [],
210
+ requestedReviewers: pr.requestedReviewers ?? [],
211
+ labels: pr.labels ?? [],
212
+ headBranch: pr.headBranch,
213
+ baseBranch: pr.baseBranch,
214
+ createdAt: pr.createdAt
215
+ };
216
+ }
217
+ /**
218
+ * Feed a just-linked repository's open issues and pull requests through the
219
+ * same rules ingress the list routes use, so its backlog reaches the board
220
+ * without anyone browsing it. Rows owned by another integration don't resolve
221
+ * through this integration's storage handle and are skipped.
222
+ */
223
+ async function ingestLinkedRepositoryBacklog(args) {
224
+ if (!args.ingestFactoryEvent) return;
225
+ const project = await resolveProjectRepository(args);
226
+ if (!project) return;
227
+ const connection = {
228
+ type: "app-installation",
229
+ installationId: Number(project.installation.externalId)
230
+ };
231
+ const sourceId = project.repository.slug;
232
+ for (let page = 1; page <= LINKED_BACKLOG_MAX_PAGES; page += 1) {
233
+ const { issues, nextCursor } = await args.github.intake.listIssues({
234
+ connection,
235
+ sourceIds: [sourceId],
236
+ cursor: String(page)
237
+ });
238
+ await ingestPolledEvents(issues.map((issue) => polledIssueEvent(project, listedIssueOf(issue))), args.ingestFactoryEvent);
239
+ if (nextCursor === null) break;
240
+ }
241
+ for (let page = 1; page <= LINKED_BACKLOG_MAX_PAGES; page += 1) {
242
+ const { pullRequests, nextCursor } = await args.github.versionControl.listPullRequests({
243
+ connection,
244
+ sourceId,
245
+ includeDrafts: false,
246
+ cursor: String(page)
247
+ });
248
+ await ingestPolledEvents(pullRequests.map((pr) => listedPullRequestEvent(project, listedPullRequestOf(pr))), args.ingestFactoryEvent);
249
+ if (nextCursor === null) break;
250
+ }
251
+ }
252
+ /**
253
+ * Build the GitHub routes as Mastra `apiRoutes`. When the feature is disabled,
254
+ * returns only the `status` route so the SPA can detect the disabled state.
255
+ */
256
+ function buildGithubRoutes(options) {
257
+ const routes = [];
258
+ const { auth, sandbox, users, storage, github, stateSigner, controller, memorySettings, emitAudit, sessionRetirement, workItems } = options;
259
+ const diagnostics = () => getGithubFeatureDiagnostics({
260
+ github,
261
+ auth,
262
+ appDbConfigured: storage !== void 0,
263
+ stateSigner,
264
+ sandbox
265
+ });
266
+ routes.push(registerApiRoute("/web/github/status", {
267
+ method: "GET",
268
+ requiresAuth: false,
269
+ handler: async (c) => {
270
+ if (!isGithubFeatureEnabled({
271
+ github,
272
+ auth
273
+ }) || !github || !stateSigner) return c.json({
274
+ enabled: false,
275
+ connected: false,
276
+ installations: [],
277
+ reason: "missing_config",
278
+ diagnostics: diagnostics()
279
+ });
280
+ await auth.ensureUser(loose(c));
281
+ const tenant = auth.tenant(loose(c));
282
+ if (!tenant) return c.json({
283
+ error: "unauthorized",
284
+ reason: "auth_required"
285
+ }, 401);
286
+ if (!tenant.orgId) return c.json({
287
+ enabled: true,
288
+ sandboxEnabled: !!sandbox,
289
+ organizationRequired: true,
290
+ connected: false,
291
+ installations: [],
292
+ reason: "organization_required",
293
+ diagnostics: diagnostics()
294
+ });
295
+ const rows = options.github ? await options.github.sourceControlStorage.installations.list({ orgId: tenant.orgId }) : [];
296
+ const connected = rows.length > 0;
297
+ return c.json({
298
+ enabled: true,
299
+ sandboxEnabled: !!sandbox,
300
+ connected,
301
+ installations: rows.map((r) => ({
302
+ installationId: Number(r.externalId),
303
+ accountLogin: r.accountName,
304
+ accountType: r.accountType
305
+ })),
306
+ reason: connected ? "ready" : "not_connected",
307
+ diagnostics: diagnostics()
308
+ });
309
+ }
310
+ }));
311
+ if (!isGithubFeatureEnabled({
312
+ github,
313
+ auth
314
+ }) || !github || !stateSigner) return routes;
315
+ const signState = (orgId, userId) => stateSigner.sign(orgId, userId);
316
+ const verifyState = (state) => stateSigner.verify(state);
317
+ routes.push(registerApiRoute("/web/github/subscriptions", {
318
+ method: "GET",
319
+ handler: async (c) => {
320
+ await auth.ensureUser(loose(c));
321
+ const tenant = auth.tenant(loose(c));
322
+ if (!tenant?.orgId) return c.json({ error: "unauthorized" }, 401);
323
+ const resourceId = c.req.query("resourceId");
324
+ const threadId = c.req.query("threadId");
325
+ const sessionScope = c.req.query("scope");
326
+ if (!resourceId || !threadId) return c.json({ error: "resourceId and threadId are required" }, 400);
327
+ const subscriptions = await listPullRequestSubscriptionsForThread({
328
+ orgId: tenant.orgId,
329
+ resourceId,
330
+ threadId,
331
+ sessionScope
332
+ }, github.integrationStorage);
333
+ return c.json({ subscriptions: subscriptions.map((subscription) => ({
334
+ id: subscription.id,
335
+ repoFullName: subscription.data.repositorySlug,
336
+ pullRequestNumber: Number(subscription.data.changeRequestId),
337
+ status: subscription.status,
338
+ url: `https://github.com/${subscription.data.repositorySlug}/pull/${subscription.data.changeRequestId}`
339
+ })) });
340
+ }
341
+ }), registerApiRoute("/web/github/webhook", {
342
+ method: "POST",
343
+ requiresAuth: false,
344
+ handler: async (c) => {
345
+ const result = await handleGithubWebhook(loose(c), {
346
+ github,
347
+ ingestFactoryEvent: options.ingestFactoryEvent,
348
+ ...options.controller ? {
349
+ controller: options.controller,
350
+ onTargetError: (subscription, error) => {
351
+ console.warn(`[GitHub Webhook] Delivery failed for subscription ${subscription.id} (${subscription.resourceId}/${subscription.threadId}).`, error);
352
+ }
353
+ } : {}
354
+ });
355
+ return c.json(result.body, result.status);
356
+ }
357
+ }));
358
+ const redirectUri = options.redirectUri ?? `${(options.baseUrl ?? "").replace(/\/$/, "")}/auth/github/callback`;
359
+ routes.push(registerApiRoute("/auth/github/connect", {
360
+ method: "GET",
361
+ requiresAuth: false,
362
+ handler: async (c) => {
363
+ const resolved = await resolveOrgTenant(loose(c), auth);
364
+ if ("response" in resolved) return resolved.response;
365
+ const state = signState(resolved.tenant.orgId, resolved.tenant.userId);
366
+ if (c.req.query("manage")) return c.redirect(github.buildInstallUrl(state));
367
+ return c.redirect(github.buildOAuthIdentifyUrl(state, redirectUri));
368
+ }
369
+ }));
370
+ routes.push(registerApiRoute("/auth/github/callback", {
371
+ method: "GET",
372
+ requiresAuth: false,
373
+ handler: async (c) => {
374
+ const resolved = await resolveOrgTenant(loose(c), auth);
375
+ if ("response" in resolved) return resolved.response;
376
+ const { orgId, userId } = resolved.tenant;
377
+ const state = c.req.query("state");
378
+ if (!state) return c.redirect(github.buildOAuthIdentifyUrl(signState(orgId, userId), redirectUri));
379
+ const stateTenant = verifyState(state);
380
+ if (!stateTenant || stateTenant.userId !== userId || stateTenant.orgId !== orgId) {
381
+ console.warn("[GitHub] Install callback rejected: state/tenant mismatch.", JSON.stringify({
382
+ stateValid: Boolean(stateTenant),
383
+ stateOrgId: stateTenant?.orgId,
384
+ stateUserId: stateTenant?.userId,
385
+ sessionOrgId: orgId,
386
+ sessionUserId: userId
387
+ }));
388
+ return c.redirect("/?github=error");
389
+ }
390
+ const code = c.req.query("code");
391
+ if (!code) return c.redirect(github.buildOAuthIdentifyUrl(signState(orgId, userId), redirectUri));
392
+ try {
393
+ const userToken = await github.exchangeOAuthCode(code, redirectUri);
394
+ const installations = await github.listUserInstallations(userToken);
395
+ if (installations.length === 0) return c.redirect(github.buildInstallUrl(signState(orgId, userId)));
396
+ for (const inst of installations) await github.sourceControlStorage.installations.upsert({
397
+ orgId,
398
+ connectedByUserId: userId,
399
+ externalId: inst.installationId.toString(),
400
+ accountName: inst.accountLogin,
401
+ accountType: inst.accountType
402
+ });
403
+ } catch (error) {
404
+ console.warn(`[GitHub] Install callback failed to persist installations for org ${orgId} / user ${userId}.`, error);
405
+ return c.redirect("/?github=error");
406
+ }
407
+ return c.redirect("/?github=connected");
408
+ }
409
+ }));
410
+ routes.push(registerApiRoute("/web/github/repos", {
411
+ method: "GET",
412
+ requiresAuth: false,
413
+ handler: async (c) => {
414
+ const resolved = await resolveOrgTenant(loose(c), auth);
415
+ if ("response" in resolved) return resolved.response;
416
+ const orgId = resolved.tenant.orgId;
417
+ const installs = await github.sourceControlStorage.installations.list({ orgId });
418
+ const query = (c.req.query("q") ?? "").toLowerCase();
419
+ const fresh = c.req.query("refresh") === "1";
420
+ const listed = await Promise.all(installs.map(async (inst) => {
421
+ try {
422
+ return {
423
+ inst,
424
+ list: await github.listInstallationRepos(Number(inst.externalId), { fresh })
425
+ };
426
+ } catch (err) {
427
+ if (err.status === 403) {
428
+ console.warn(`[Mastra Factory] skipping GitHub installation ${inst.externalId} (${inst.accountName}): ${err.message}`);
429
+ return {
430
+ inst,
431
+ list: []
432
+ };
433
+ }
434
+ if (err.status !== 404) throw err;
435
+ console.error(`[Mastra Factory] pruning stale GitHub installation ${inst.externalId} (404 from GitHub)`);
436
+ await github.sourceControlStorage.installations.delete({
437
+ orgId,
438
+ id: inst.id
439
+ });
440
+ return {
441
+ inst,
442
+ list: []
443
+ };
444
+ }
445
+ }));
446
+ const matches = [];
447
+ const seenRepositoryIds = /* @__PURE__ */ new Set();
448
+ for (const { inst, list } of listed) for (const repo of list) {
449
+ if (query && !repo.fullName.toLowerCase().includes(query)) continue;
450
+ if (seenRepositoryIds.has(repo.id)) continue;
451
+ seenRepositoryIds.add(repo.id);
452
+ matches.push({
453
+ inst,
454
+ repo
455
+ });
456
+ }
457
+ const repos = matches.map(({ inst, repo }) => ({
458
+ ...repo,
459
+ installationStorageId: inst.id,
460
+ sandboxProvider: sandbox ? "custom" : "none",
461
+ sandboxWorkdir: `~/${sanitizeSegment(repo.fullName.split("/", 2)[1] || "repo")}`
462
+ }));
463
+ return c.json({ repos });
464
+ }
465
+ }));
466
+ routes.push(registerApiRoute("/web/github/projects/:id/issues", {
467
+ method: "GET",
468
+ requiresAuth: false,
469
+ handler: async (c) => {
470
+ const loaded = await loadOrgProject({
471
+ github,
472
+ auth,
473
+ c: loose(c)
474
+ });
475
+ if ("response" in loaded) return loaded.response;
476
+ const page = parseListPage(c.req.query("page"));
477
+ if (page === null) return c.json({ error: "invalid_page" }, 400);
478
+ const label = parseIssueLabelFilter(c.req.query("label"));
479
+ if (label === null) return c.json({ error: "invalid_label" }, 400);
480
+ try {
481
+ const { issues, nextCursor } = await github.intake.listIssues({
482
+ connection: {
483
+ type: "app-installation",
484
+ installationId: Number(loaded.project.installation.externalId)
485
+ },
486
+ sourceIds: [loaded.project.repository.slug],
487
+ labels: label ? [label] : void 0,
488
+ cursor: String(page)
489
+ });
490
+ const responseIssues = issues.map((issue) => ({
491
+ repositoryId: Number(loaded.project.repository.externalId),
492
+ number: Number(issue.id),
493
+ title: issue.title,
494
+ url: issue.url,
495
+ author: issue.author,
496
+ assignee: issue.assignee,
497
+ assignees: issue.assignees,
498
+ labels: issue.labels,
499
+ comments: issue.commentCount ?? 0,
500
+ createdAt: issue.createdAt,
501
+ updatedAt: issue.updatedAt
502
+ }));
503
+ await ingestPolledEvents(responseIssues.map((issue) => polledIssueEvent(loaded.project, issue)), options.ingestFactoryEvent);
504
+ return c.json({
505
+ issues: responseIssues,
506
+ nextPage: nextCursor === null ? null : Number(nextCursor)
507
+ });
508
+ } catch (err) {
509
+ return c.json({
510
+ error: "github_fetch_failed",
511
+ message: err instanceof Error ? err.message : String(err)
512
+ }, 502);
513
+ }
514
+ }
515
+ }));
516
+ routes.push(registerApiRoute("/web/github/projects/:id/issues/:number", {
517
+ method: "GET",
518
+ requiresAuth: false,
519
+ handler: async (c) => {
520
+ const loaded = await loadOrgProject({
521
+ github,
522
+ auth,
523
+ c: loose(c)
524
+ });
525
+ if ("response" in loaded) return loaded.response;
526
+ const number = parseResourceNumber(c.req.param("number"));
527
+ if (number === null) return c.json({ error: "invalid_number" }, 400);
528
+ try {
529
+ const detail = await github.intake.getIssue({
530
+ connection: {
531
+ type: "app-installation",
532
+ installationId: Number(loaded.project.installation.externalId)
533
+ },
534
+ sourceId: loaded.project.repository.slug,
535
+ issueId: String(number)
536
+ });
537
+ if (detail === null) return c.json({ error: "issue_not_found" }, 404);
538
+ return c.json({
539
+ number: Number(detail.id),
540
+ title: detail.title,
541
+ url: detail.url,
542
+ author: detail.author,
543
+ assignee: detail.assignee,
544
+ labels: detail.labels,
545
+ comments: detail.commentCount ?? 0,
546
+ createdAt: detail.createdAt,
547
+ updatedAt: detail.updatedAt,
548
+ description: detail.description
549
+ });
550
+ } catch (err) {
551
+ return c.json({
552
+ error: "github_fetch_failed",
553
+ message: err instanceof Error ? err.message : String(err)
554
+ }, 502);
555
+ }
556
+ }
557
+ }));
558
+ routes.push(registerApiRoute("/web/github/projects/:id/prs", {
559
+ method: "GET",
560
+ requiresAuth: false,
561
+ handler: async (c) => {
562
+ const loaded = await loadOrgProject({
563
+ github,
564
+ auth,
565
+ c: loose(c)
566
+ });
567
+ if ("response" in loaded) return loaded.response;
568
+ const page = parseListPage(c.req.query("page"));
569
+ if (page === null) return c.json({ error: "invalid_page" }, 400);
570
+ try {
571
+ const { pullRequests, nextCursor } = await github.versionControl.listPullRequests({
572
+ connection: {
573
+ type: "app-installation",
574
+ installationId: Number(loaded.project.installation.externalId)
575
+ },
576
+ sourceId: loaded.project.repository.slug,
577
+ includeDrafts: false,
578
+ cursor: String(page)
579
+ });
580
+ const responsePullRequests = pullRequests.map((pr) => ({
581
+ repositoryId: Number(loaded.project.repository.externalId),
582
+ number: Number(pr.id),
583
+ title: pr.title,
584
+ url: pr.url,
585
+ author: pr.author,
586
+ assignees: pr.assignees ?? [],
587
+ requestedReviewers: pr.requestedReviewers ?? [],
588
+ labels: pr.labels ?? [],
589
+ baseBranch: pr.baseBranch,
590
+ headBranch: pr.headBranch,
591
+ createdAt: pr.createdAt,
592
+ updatedAt: pr.updatedAt
593
+ }));
594
+ await ingestPolledEvents(responsePullRequests.map((pullRequest) => listedPullRequestEvent(loaded.project, pullRequest)), options.ingestFactoryEvent);
595
+ return c.json({
596
+ pullRequests: responsePullRequests,
597
+ nextPage: nextCursor === null ? null : Number(nextCursor)
598
+ });
599
+ } catch (err) {
600
+ return c.json({
601
+ error: "github_fetch_failed",
602
+ message: err instanceof Error ? err.message : String(err)
603
+ }, 502);
604
+ }
605
+ }
606
+ }));
607
+ routes.push(registerApiRoute("/web/github/projects/:id/prs/:number", {
608
+ method: "GET",
609
+ requiresAuth: false,
610
+ handler: async (c) => {
611
+ const loaded = await loadOrgProject({
612
+ github,
613
+ auth,
614
+ c: loose(c)
615
+ });
616
+ if ("response" in loaded) return loaded.response;
617
+ const number = parseResourceNumber(c.req.param("number"));
618
+ if (number === null) return c.json({ error: "invalid_number" }, 400);
619
+ try {
620
+ const pr = await github.versionControl.getPullRequest({
621
+ connection: {
622
+ type: "app-installation",
623
+ installationId: Number(loaded.project.installation.externalId)
624
+ },
625
+ sourceId: loaded.project.repository.slug,
626
+ pullRequestId: String(number)
627
+ });
628
+ if (pr === null) return c.json({ error: "pull_request_not_found" }, 404);
629
+ return c.json({
630
+ number: Number(pr.id),
631
+ title: pr.title,
632
+ url: pr.url,
633
+ author: pr.author,
634
+ assignees: pr.assignees ?? [],
635
+ requestedReviewers: pr.requestedReviewers ?? [],
636
+ baseBranch: pr.baseBranch,
637
+ headBranch: pr.headBranch,
638
+ createdAt: pr.createdAt,
639
+ updatedAt: pr.updatedAt,
640
+ description: pr.body
641
+ });
642
+ } catch (err) {
643
+ return c.json({
644
+ error: "github_fetch_failed",
645
+ message: err instanceof Error ? err.message : String(err)
646
+ }, 502);
647
+ }
648
+ }
649
+ }));
650
+ routes.push(registerApiRoute("/web/github/projects/:id/settings", {
651
+ method: "GET",
652
+ requiresAuth: false,
653
+ handler: async (c) => {
654
+ const loaded = await loadOrgProject({
655
+ github,
656
+ auth,
657
+ c: loose(c)
658
+ });
659
+ if ("response" in loaded) return loaded.response;
660
+ return c.json({
661
+ setupCommand: loaded.project.setupCommand,
662
+ teardownCommand: loaded.project.teardownCommand
663
+ });
664
+ }
665
+ }));
666
+ routes.push(registerApiRoute("/web/github/projects/:id/settings", {
667
+ method: "POST",
668
+ requiresAuth: false,
669
+ handler: async (c) => {
670
+ const loaded = await loadOrgProject({
671
+ github,
672
+ auth,
673
+ c: loose(c)
674
+ });
675
+ if ("response" in loaded) return loaded.response;
676
+ let body;
677
+ try {
678
+ body = await c.req.json();
679
+ } catch {
680
+ return c.json({ error: "Invalid JSON body" }, 400);
681
+ }
682
+ for (const command of ["setupCommand", "teardownCommand"]) {
683
+ const value = body[command];
684
+ if (value === void 0) continue;
685
+ if (value !== null && typeof value !== "string") return c.json({ error: `Invalid ${command}` }, 400);
686
+ if (typeof value === "string" && value.length > 2e3) return c.json({ error: `${command} too long (max 2000 characters)` }, 400);
687
+ if (typeof value === "string" && /[\0-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(value)) return c.json({ error: `${command} contains control characters` }, 400);
688
+ }
689
+ const normalizeCommand = (value) => {
690
+ if (value === void 0) return void 0;
691
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
692
+ };
693
+ const setupCommand = normalizeCommand(body.setupCommand);
694
+ const teardownCommand = normalizeCommand(body.teardownCommand);
695
+ await github.sourceControlStorage.projectRepositories.update({
696
+ orgId: loaded.project.installation.orgId,
697
+ id: loaded.project.id,
698
+ input: {
699
+ ...setupCommand !== void 0 ? { setupCommand } : {},
700
+ ...teardownCommand !== void 0 ? { teardownCommand } : {}
701
+ }
702
+ });
703
+ return c.json({
704
+ setupCommand: setupCommand === void 0 ? loaded.project.setupCommand : setupCommand,
705
+ teardownCommand: teardownCommand === void 0 ? loaded.project.teardownCommand : teardownCommand
706
+ });
707
+ }
708
+ }));
709
+ const parsePatKind = (value) => {
710
+ if (value === void 0 || value === null || value === "default") return "default";
711
+ if (value === "reviewer") return "reviewer";
712
+ return null;
713
+ };
714
+ routes.push(registerApiRoute("/web/github/pat", {
715
+ method: "GET",
716
+ requiresAuth: false,
717
+ handler: async (c) => {
718
+ const resolved = await resolveOrgTenant(loose(c), auth);
719
+ if ("response" in resolved) return resolved.response;
720
+ return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
721
+ }
722
+ }), registerApiRoute("/web/github/pat", {
723
+ method: "POST",
724
+ requiresAuth: false,
725
+ handler: async (c) => {
726
+ const resolved = await resolveOrgTenant(loose(c), auth);
727
+ if ("response" in resolved) return resolved.response;
728
+ let body;
729
+ try {
730
+ body = await c.req.json();
731
+ } catch {
732
+ return c.json({ error: "Invalid JSON body" }, 400);
733
+ }
734
+ const kind = parsePatKind(body.kind);
735
+ if (!kind) return c.json({ error: "kind must be 'default' or 'reviewer'" }, 400);
736
+ const token = typeof body.token === "string" ? body.token.trim() : "";
737
+ if (!token) return c.json({ error: "A token is required" }, 400);
738
+ if (token.length > 500) return c.json({ error: "Token too long (max 500 characters)" }, 400);
739
+ if (/\s/.test(token)) return c.json({ error: "Token must not contain whitespace" }, 400);
740
+ await setGithubPat(github.integrationStorage, resolved.tenant.orgId, token, kind);
741
+ return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
742
+ }
743
+ }), registerApiRoute("/web/github/pat", {
744
+ method: "DELETE",
745
+ requiresAuth: false,
746
+ handler: async (c) => {
747
+ const resolved = await resolveOrgTenant(loose(c), auth);
748
+ if ("response" in resolved) return resolved.response;
749
+ const kind = parsePatKind(c.req.query("kind"));
750
+ if (!kind) return c.json({ error: "kind must be 'default' or 'reviewer'" }, 400);
751
+ await clearGithubPat(github.integrationStorage, resolved.tenant.orgId, kind);
752
+ return c.json(await getGithubPatStatus(() => github.integrationStorage, resolved.tenant.orgId));
753
+ }
754
+ }));
755
+ routes.push(...buildProjectGitRoutes({
756
+ github,
757
+ auth,
758
+ sandbox,
759
+ users,
760
+ controller,
761
+ memorySettings,
762
+ emitAudit,
763
+ sessionRetirement,
764
+ workItems
765
+ }));
766
+ return routes;
767
+ }
768
+ /**
769
+ * Load the org-owned project for a read-only GitHub API route. Unlike
770
+ * `loadOwnedProject`, this never touches sandbox state — the issues/PR list
771
+ * routes only need the repo + installation, so they work before a sandbox is
772
+ * ever provisioned.
773
+ */
774
+ async function loadOrgProject(options) {
775
+ const { github, auth, c } = options;
776
+ const resolved = await resolveOrgTenant(c, auth);
777
+ if ("response" in resolved) return { response: resolved.response };
778
+ const { orgId, userId } = resolved.tenant;
779
+ const projectRepositoryId = c.req.param("id");
780
+ if (!projectRepositoryId) return { response: c.json({ error: "Project repository not found" }, 404) };
781
+ const project = await resolveProjectRepository({
782
+ github,
783
+ orgId,
784
+ projectRepositoryId
785
+ });
786
+ if (!project) return { response: c.json({ error: "Project repository not found" }, 404) };
787
+ return {
788
+ project,
789
+ orgId,
790
+ userId
791
+ };
792
+ }
793
+ /** Derive a commit/author identity from the authenticated host user. */
794
+ function identityFromUser(user) {
795
+ const u = user;
796
+ return {
797
+ name: u?.name ?? null,
798
+ email: u?.email ?? null
799
+ };
800
+ }
801
+ /** Map a sandbox/setup-command error to an actionable HTTP response. */
802
+ function gitErrorResponse(c, err) {
803
+ if (err instanceof SetupCommandError) return c.json({
804
+ error: err.code,
805
+ message: err.message
806
+ }, 502);
807
+ if (err instanceof MaterializeError) return c.json({
808
+ error: err.code,
809
+ message: err.message
810
+ }, 502);
811
+ return c.json({
812
+ error: "git_failed",
813
+ message: err instanceof Error ? err.message : String(err)
814
+ }, 500);
815
+ }
816
+ /**
817
+ * Load the org-owned project for a git route. Centralizes the auth +
818
+ * org/ownership checks every git route shares: the project is scoped by
819
+ * `(id, orgId)`. Returns the tenant and project, or a ready-to-return error
820
+ * response.
821
+ */
822
+ async function loadOwnedProject(options) {
823
+ const { github, auth, sandbox, c } = options;
824
+ const resolved = await resolveOrgTenant(c, auth);
825
+ if ("response" in resolved) return { response: resolved.response };
826
+ const { orgId, userId } = resolved.tenant;
827
+ if (!sandbox) return { response: c.json({
828
+ error: "sandbox_not_configured",
829
+ message: "No sandbox provider is configured."
830
+ }, 503) };
831
+ const projectRepositoryId = c.req.param("id");
832
+ if (!projectRepositoryId) return { response: c.json({ error: "Project repository not found" }, 404) };
833
+ const project = await resolveProjectRepository({
834
+ github,
835
+ orgId,
836
+ projectRepositoryId
837
+ });
838
+ if (!project) return { response: c.json({ error: "Project repository not found" }, 404) };
839
+ return {
840
+ orgId,
841
+ userId,
842
+ project
843
+ };
844
+ }
845
+ /**
846
+ * One naming per session at a time: a second caller joins the run already in
847
+ * flight instead of paying for another model call and racing its rename.
848
+ */
849
+ function createSessionNaming() {
850
+ const inFlight = /* @__PURE__ */ new Map();
851
+ return (sessionId, run) => {
852
+ const pending = inFlight.get(sessionId);
853
+ if (pending) return pending;
854
+ const started = run().finally(() => inFlight.delete(sessionId));
855
+ inFlight.set(sessionId, started);
856
+ return started;
857
+ };
858
+ }
859
+ /**
860
+ * Name a thread with a stored model id. Resolution has to go through
861
+ * mastracode's gateway: a bare id handed to core's model router looks for a
862
+ * process env key instead of the caller's stored provider credentials.
863
+ */
864
+ function titleModel(modelId) {
865
+ return ({ requestContext }) => resolveModel(modelId, {
866
+ remapForCodexOAuth: true,
867
+ requestContext
868
+ });
869
+ }
870
+ /** A screenful of history; GitHub caps its own page at 100. */
871
+ const DEFAULT_COMMIT_PAGE = 20;
872
+ const MAX_COMMIT_PAGE = 100;
873
+ const MAX_SESSION_OWNER_PROFILES = 100;
874
+ const MAX_SESSION_OWNER_PROFILE_CACHE_ENTRIES = 500;
875
+ const SESSION_OWNER_PROFILE_TTL_MS = 5 * 6e4;
876
+ function createSessionOwnerProfileResolver(users) {
877
+ const cache = /* @__PURE__ */ new Map();
878
+ const cacheProfile = (userId, profile, expiresAt) => {
879
+ cache.delete(userId);
880
+ cache.set(userId, {
881
+ profile,
882
+ expiresAt
883
+ });
884
+ if (cache.size > MAX_SESSION_OWNER_PROFILE_CACHE_ENTRIES) {
885
+ const oldestUserId = cache.keys().next().value;
886
+ if (oldestUserId !== void 0) cache.delete(oldestUserId);
887
+ }
888
+ };
889
+ return async (userIds) => {
890
+ if (!users) return /* @__PURE__ */ new Map();
891
+ const requestedUserIds = [...new Set(userIds)].slice(0, MAX_SESSION_OWNER_PROFILES);
892
+ const profiles = /* @__PURE__ */ new Map();
893
+ const unresolvedUserIds = [];
894
+ const now = Date.now();
895
+ for (const userId of requestedUserIds) {
896
+ const cached = cache.get(userId);
897
+ if (!cached || cached.expiresAt <= now) {
898
+ cache.delete(userId);
899
+ unresolvedUserIds.push(userId);
900
+ } else if (cached.profile) profiles.set(userId, cached.profile);
901
+ }
902
+ if (unresolvedUserIds.length === 0) return profiles;
903
+ let resolvedUsers;
904
+ if (users.getUsers) try {
905
+ resolvedUsers = await users.getUsers(unresolvedUserIds);
906
+ } catch (error) {
907
+ console.warn("[GitHub Sessions] Bulk session owner profile lookup failed; falling back to individual lookups", { error: error instanceof Error ? error.message : String(error) });
908
+ resolvedUsers = (await Promise.allSettled(unresolvedUserIds.map((userId) => users.getUser(userId)))).filter((result) => result.status === "fulfilled").map((result) => result.value);
909
+ }
910
+ else resolvedUsers = (await Promise.allSettled(unresolvedUserIds.map((userId) => users.getUser(userId)))).filter((result) => result.status === "fulfilled").map((result) => result.value);
911
+ for (const user of resolvedUsers) {
912
+ if (!user) continue;
913
+ const name = user.name?.trim() || user.email?.trim();
914
+ if (!name) continue;
915
+ profiles.set(user.id, {
916
+ id: user.id,
917
+ name,
918
+ ...user.avatarUrl ? { avatarUrl: user.avatarUrl } : {}
919
+ });
920
+ }
921
+ const expiresAt = now + SESSION_OWNER_PROFILE_TTL_MS;
922
+ for (const userId of unresolvedUserIds) cacheProfile(userId, profiles.get(userId), expiresAt);
923
+ return profiles;
924
+ };
925
+ }
926
+ function buildProjectGitRoutes({ github, auth, sandbox, users, controller, memorySettings, emitAudit, sessionRetirement, workItems }) {
927
+ const nameSession = createSessionNaming();
928
+ const resolveSessionOwnerProfiles = createSessionOwnerProfileResolver(users);
929
+ return [
930
+ registerApiRoute("/web/github/projects/:id/sessions", {
931
+ method: "GET",
932
+ requiresAuth: false,
933
+ handler: async (c) => {
934
+ const resolved = await resolveOrgTenant(loose(c), auth);
935
+ if ("response" in resolved) return resolved.response;
936
+ const { orgId, userId } = resolved.tenant;
937
+ const projectRepositoryId = c.req.param("id");
938
+ const project = projectRepositoryId ? await resolveProjectRepository({
939
+ github,
940
+ orgId,
941
+ projectRepositoryId
942
+ }) : null;
943
+ if (!project) return c.json({ error: "Project repository not found" }, 404);
944
+ const sessions = await github.sourceControlStorage.sessions.list({
945
+ projectRepositoryId: project.id,
946
+ viewerUserId: userId
947
+ });
948
+ const owners = await resolveSessionOwnerProfiles(sessions.map((session) => session.userId));
949
+ return c.json({ sessions: sessions.map((session) => {
950
+ const owner = owners.get(session.userId);
951
+ return {
952
+ ...session,
953
+ ...owner ? { owner } : {}
954
+ };
955
+ }) });
956
+ }
957
+ }),
958
+ registerApiRoute("/web/github/projects/:id/sessions", {
959
+ method: "POST",
960
+ requiresAuth: false,
961
+ handler: async (c) => {
962
+ const resolved = await resolveOrgTenant(loose(c), auth);
963
+ if ("response" in resolved) return resolved.response;
964
+ const { orgId, userId } = resolved.tenant;
965
+ const projectRepositoryId = c.req.param("id");
966
+ const project = projectRepositoryId ? await resolveProjectRepository({
967
+ github,
968
+ orgId,
969
+ projectRepositoryId
970
+ }) : null;
971
+ if (!project) return c.json({ error: "Project repository not found" }, 404);
972
+ let body;
973
+ try {
974
+ body = await c.req.json();
975
+ } catch {
976
+ return c.json({ error: "Invalid JSON body" }, 400);
977
+ }
978
+ if (!isJsonObject(body)) return c.json({ error: "Invalid JSON body" }, 400);
979
+ const requestedBaseBranch = body.baseBranch;
980
+ if (requestedBaseBranch !== void 0 && typeof requestedBaseBranch !== "string") return c.json({ error: "Invalid baseBranch" }, 400);
981
+ const baseBranch = requestedBaseBranch ?? project.defaultBranch;
982
+ if (!isValidGitRef(baseBranch)) return c.json({ error: "Invalid baseBranch" }, 400);
983
+ const requestedSessionId = body.sessionId;
984
+ if (requestedSessionId !== void 0 && (typeof requestedSessionId !== "string" || !UUID_PATTERN.test(requestedSessionId))) return c.json({ error: "Invalid sessionId" }, 400);
985
+ const sessionId = requestedSessionId ?? globalThis.crypto.randomUUID();
986
+ const requestedTitle = body.title;
987
+ if (requestedTitle !== void 0 && typeof requestedTitle !== "string") return c.json({ error: "Invalid title" }, 400);
988
+ const normalizedTitle = requestedTitle === void 0 ? null : normalizeSessionTitle(requestedTitle);
989
+ const requestedBranch = body.branch;
990
+ let branch;
991
+ if (requestedBranch === void 0) branch = `${USER_SESSION_BRANCH_PREFIX}${sessionId}`;
992
+ else if (typeof requestedBranch === "string" && isValidGitRef(requestedBranch)) branch = requestedBranch;
993
+ else return c.json({ error: "Invalid branch" }, 400);
994
+ if (requestedSessionId !== void 0) {
995
+ const existing = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
996
+ if (existing) {
997
+ if (existing.projectRepositoryId !== project.id || existing.orgId !== orgId || existing.userId !== userId || existing.branch !== branch) return c.json({ error: "Session ID conflict" }, 409);
998
+ return c.json({ session: existing });
999
+ }
1000
+ }
1001
+ const session = await github.sourceControlStorage.sessions.create({
1002
+ sessionId,
1003
+ projectRepositoryId: project.id,
1004
+ factoryProjectId: project.factoryProjectId,
1005
+ orgId,
1006
+ userId,
1007
+ branch,
1008
+ baseBranch,
1009
+ title: normalizedTitle,
1010
+ visibility: "org"
1011
+ }).catch(async (error) => {
1012
+ if (!(error instanceof UniqueViolationError) || requestedSessionId === void 0) throw error;
1013
+ const conflict = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
1014
+ if (!conflict) throw error;
1015
+ return conflict;
1016
+ });
1017
+ if (requestedSessionId !== void 0 && (session.sessionId !== sessionId || session.projectRepositoryId !== project.id || session.orgId !== orgId || session.userId !== userId || session.branch !== branch)) return c.json({ error: "Session ID conflict" }, 409);
1018
+ return c.json({ session });
1019
+ }
1020
+ }),
1021
+ registerApiRoute("/web/user-sessions/:sessionId", {
1022
+ method: "GET",
1023
+ requiresAuth: false,
1024
+ handler: async (c) => {
1025
+ const resolved = await resolveOrgTenant(loose(c), auth);
1026
+ if ("response" in resolved) return resolved.response;
1027
+ const session = await github.sourceControlStorage.sessions.getBySessionId(c.req.param("sessionId"));
1028
+ if (!session || session.orgId !== resolved.tenant.orgId || session.visibility === "private" && session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
1029
+ return c.json({ session });
1030
+ }
1031
+ }),
1032
+ registerApiRoute("/web/user-sessions/:sessionId", {
1033
+ method: "DELETE",
1034
+ requiresAuth: false,
1035
+ handler: async (c) => {
1036
+ const resolved = await resolveOrgTenant(loose(c), auth);
1037
+ if ("response" in resolved) return resolved.response;
1038
+ const session = await github.sourceControlStorage.sessions.getBySessionId(c.req.param("sessionId"));
1039
+ if (!session || session.orgId !== resolved.tenant.orgId || session.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
1040
+ try {
1041
+ await waitForPendingFilesystemCapture(session.sessionId).catch((error) => {
1042
+ console.warn("[GitHub Sessions] Failed to drain filesystem capture before delete", {
1043
+ sessionId: session.sessionId,
1044
+ error
1045
+ });
1046
+ });
1047
+ await controller?.deleteSession({ resourceId: session.sessionId });
1048
+ } catch (error) {
1049
+ console.error("[GitHub Sessions] Failed to tear down live controller session", {
1050
+ sessionId: session.sessionId,
1051
+ error
1052
+ });
1053
+ }
1054
+ if (sessionRetirement) await sessionRetirement.retireSession({
1055
+ sourceControl: github.sourceControlStorage,
1056
+ ...workItems ? { workItems } : {},
1057
+ orgId: session.orgId,
1058
+ sessionId: session.sessionId,
1059
+ deleteSession: true
1060
+ });
1061
+ else {
1062
+ await workItems?.clearSessionReferences({
1063
+ orgId: session.orgId,
1064
+ sessionId: session.sessionId
1065
+ });
1066
+ await github.sourceControlStorage.sessions.delete(session.id);
1067
+ reclaimDeletedSessionSandbox({ session }).catch((error) => {
1068
+ console.error("[GitHub Sessions] Failed to reclaim sandbox for deleted session", {
1069
+ sessionId: session.sessionId,
1070
+ sandboxId: session.sandboxId,
1071
+ error
1072
+ });
1073
+ });
1074
+ }
1075
+ return c.json({ removed: true });
1076
+ }
1077
+ }),
1078
+ registerApiRoute("/web/user-sessions/:sessionId/title", {
1079
+ method: "POST",
1080
+ requiresAuth: false,
1081
+ handler: async (c) => {
1082
+ const resolved = await resolveOrgTenant(loose(c), auth);
1083
+ if ("response" in resolved) return resolved.response;
1084
+ const sessionId = c.req.param("sessionId");
1085
+ const row = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
1086
+ if (!row || row.orgId !== resolved.tenant.orgId || row.userId !== resolved.tenant.userId) return c.json({ error: "Session not found" }, 404);
1087
+ if (!controller) return c.json({ error: "Sessions are not available on this server." }, 503);
1088
+ const thread = (await controller.queryThreads({ resourceId: sessionId })).sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())[0];
1089
+ if (!thread) return c.json({ error: "This session has no conversation to name yet." }, 409);
1090
+ const stored = await memorySettings.get({
1091
+ orgId: row.orgId,
1092
+ userId: row.userId
1093
+ });
1094
+ const requestContext = new RequestContext();
1095
+ requestContext.set("user", {
1096
+ workosId: row.userId,
1097
+ organizationId: row.orgId
1098
+ });
1099
+ requestContext.set("mastra__factoryMemorySettings", stored);
1100
+ try {
1101
+ const title = await nameSession(sessionId, async () => {
1102
+ const generated = await controller.generateThreadTitle({
1103
+ threadId: thread.id,
1104
+ resourceId: sessionId,
1105
+ requestContext,
1106
+ ...stored?.observerModelId ? { model: titleModel(stored.observerModelId) } : {}
1107
+ });
1108
+ const named = generated ? normalizeSessionTitle(generated) : null;
1109
+ if (named) await github.sourceControlStorage.sessions.rename({
1110
+ sessionId,
1111
+ title: named
1112
+ });
1113
+ return named;
1114
+ });
1115
+ if (!title) return c.json({ error: "The model returned an empty title. Try again." }, 502);
1116
+ return c.json({ title });
1117
+ } catch (error) {
1118
+ return c.json({ error: error instanceof Error ? error.message : String(error) }, 500);
1119
+ }
1120
+ }
1121
+ }),
1122
+ registerApiRoute("/web/github/projects/:id/commit", {
1123
+ method: "POST",
1124
+ requiresAuth: false,
1125
+ handler: async (c) => {
1126
+ const owned = await loadOwnedProject({
1127
+ github,
1128
+ auth,
1129
+ sandbox,
1130
+ c: loose(c)
1131
+ });
1132
+ if ("response" in owned) return owned.response;
1133
+ const { userId, project } = owned;
1134
+ let body;
1135
+ try {
1136
+ body = await c.req.json();
1137
+ } catch {
1138
+ return c.json({ error: "Invalid JSON body" }, 400);
1139
+ }
1140
+ if (typeof body.message !== "string" || body.message.trim().length === 0 || body.message.length > 5e3) return c.json({ error: "Invalid message" }, 400);
1141
+ const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
1142
+ if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
1143
+ const { workdir, sandbox: sessionSandbox } = sessionWorkspace;
1144
+ try {
1145
+ return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
1146
+ const result = await commitAll(sessionSandbox, workdir, body.message, identityFromUser(await auth.ensureUser(loose(c))));
1147
+ if (result.committed) await emitAudit?.({
1148
+ context: loose(c),
1149
+ input: {
1150
+ action: "factory.git.commit",
1151
+ factoryProjectId: project.factoryProjectId,
1152
+ projectRepositoryId: project.id,
1153
+ targets: [{
1154
+ type: "session",
1155
+ id: sessionWorkspace.session.sessionId
1156
+ }],
1157
+ metadata: { sessionId: sessionWorkspace.session.sessionId }
1158
+ }
1159
+ });
1160
+ return c.json({ committed: result.committed });
1161
+ });
1162
+ } catch (err) {
1163
+ return gitErrorResponse(loose(c), err);
1164
+ }
1165
+ }
1166
+ }),
1167
+ registerApiRoute("/web/github/projects/:id/commits", {
1168
+ method: "GET",
1169
+ requiresAuth: false,
1170
+ handler: async (c) => {
1171
+ const loaded = await loadOrgProject({
1172
+ github,
1173
+ auth,
1174
+ c: loose(c)
1175
+ });
1176
+ if ("response" in loaded) return loaded.response;
1177
+ const { orgId, project } = loaded;
1178
+ const branch = c.req.query("branch") ?? project.defaultBranch;
1179
+ if (!isValidGitRef(branch)) return c.json({ error: "Invalid branch" }, 400);
1180
+ const limit = Math.min(Math.max(Math.floor(Number(c.req.query("limit") ?? DEFAULT_COMMIT_PAGE)) || DEFAULT_COMMIT_PAGE, 1), MAX_COMMIT_PAGE);
1181
+ try {
1182
+ const commits = await listRepositoryCommits(github, {
1183
+ orgId,
1184
+ project,
1185
+ branch,
1186
+ limit
1187
+ });
1188
+ return c.json({
1189
+ commits,
1190
+ branch
1191
+ });
1192
+ } catch (err) {
1193
+ return gitErrorResponse(loose(c), err);
1194
+ }
1195
+ }
1196
+ }),
1197
+ registerApiRoute("/web/github/projects/:id/push", {
1198
+ method: "POST",
1199
+ requiresAuth: false,
1200
+ handler: async (c) => {
1201
+ const owned = await loadOwnedProject({
1202
+ github,
1203
+ auth,
1204
+ sandbox,
1205
+ c: loose(c)
1206
+ });
1207
+ if ("response" in owned) return owned.response;
1208
+ const { orgId, userId, project } = owned;
1209
+ let body;
1210
+ try {
1211
+ body = await c.req.json();
1212
+ } catch {
1213
+ return c.json({ error: "Invalid JSON body" }, 400);
1214
+ }
1215
+ if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
1216
+ const branch = body.branch;
1217
+ const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
1218
+ if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
1219
+ const { workdir, sandbox: sessionSandbox } = sessionWorkspace;
1220
+ try {
1221
+ return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
1222
+ const access = await github.versionControl.getRepositoryAccess({
1223
+ orgId,
1224
+ repositoryId: project.repository.id
1225
+ });
1226
+ if (!access.authorization) throw new Error("Repository access did not include a bearer token.");
1227
+ await pushBranch(sessionSandbox, workdir, branch, access.authorization.token, project.repository.slug);
1228
+ await emitAudit?.({
1229
+ context: loose(c),
1230
+ input: {
1231
+ action: "factory.git.push",
1232
+ factoryProjectId: project.factoryProjectId,
1233
+ projectRepositoryId: project.id,
1234
+ targets: [{
1235
+ type: "branch",
1236
+ id: branch
1237
+ }],
1238
+ metadata: {
1239
+ branch,
1240
+ sessionId: sessionWorkspace.session.sessionId
1241
+ }
1242
+ }
1243
+ });
1244
+ return c.json({
1245
+ pushed: true,
1246
+ branch
1247
+ });
1248
+ });
1249
+ } catch (err) {
1250
+ return gitErrorResponse(loose(c), err);
1251
+ }
1252
+ }
1253
+ }),
1254
+ registerApiRoute("/web/github/projects/:id/pr", {
1255
+ method: "POST",
1256
+ requiresAuth: false,
1257
+ handler: async (c) => {
1258
+ const owned = await loadOwnedProject({
1259
+ github,
1260
+ auth,
1261
+ sandbox,
1262
+ c: loose(c)
1263
+ });
1264
+ if ("response" in owned) return owned.response;
1265
+ const { orgId, userId, project } = owned;
1266
+ let body;
1267
+ try {
1268
+ body = await c.req.json();
1269
+ } catch {
1270
+ return c.json({ error: "Invalid JSON body" }, 400);
1271
+ }
1272
+ if (!isValidGitRef(body.branch)) return c.json({ error: "Invalid branch" }, 400);
1273
+ const base = body.base === void 0 ? project.defaultBranch : body.base;
1274
+ if (!isValidGitRef(base)) return c.json({ error: "Invalid base" }, 400);
1275
+ if (typeof body.title !== "string" || body.title.trim().length === 0 || body.title.length > 256) return c.json({ error: "Invalid title" }, 400);
1276
+ if (body.body !== void 0 && (typeof body.body !== "string" || body.body.length > 65536)) return c.json({ error: "Invalid body" }, 400);
1277
+ const head = body.branch;
1278
+ const title = body.title;
1279
+ const prBody = body.body;
1280
+ const sessionWorkspace = await resolveSessionWorkspace(github, project.id, userId, body.sessionId);
1281
+ if (!sessionWorkspace) return c.json({ error: "Invalid sessionId" }, 400);
1282
+ try {
1283
+ return await withSessionOperationLock(sessionWorkspace.session.sessionId, async () => {
1284
+ const result = await github.versionControl.createPullRequest({
1285
+ connection: {
1286
+ type: "app-installation",
1287
+ installationId: Number(project.installation.externalId)
1288
+ },
1289
+ sourceId: project.repository.slug,
1290
+ baseBranch: base,
1291
+ headBranch: head,
1292
+ title,
1293
+ body: prBody,
1294
+ actingUserId: userId
1295
+ });
1296
+ await emitAudit?.({
1297
+ context: loose(c),
1298
+ input: {
1299
+ action: "factory.git.pr_opened",
1300
+ factoryProjectId: project.factoryProjectId,
1301
+ projectRepositoryId: project.id,
1302
+ targets: [{
1303
+ type: "pull_request",
1304
+ id: result.url,
1305
+ name: title
1306
+ }],
1307
+ metadata: {
1308
+ branch: head,
1309
+ base,
1310
+ url: result.url
1311
+ }
1312
+ }
1313
+ });
1314
+ const pullRequestNumber = pullRequestNumberFromUrl(result.url, project.repository.slug);
1315
+ if (pullRequestNumber) {
1316
+ const sessionId = sessionWorkspace.session.sessionId;
1317
+ await subscribeToPullRequest({
1318
+ orgId,
1319
+ installationExternalId: project.installation.externalId,
1320
+ projectRepositoryId: project.id,
1321
+ repositoryExternalId: project.repository.externalId,
1322
+ repositorySlug: project.repository.slug,
1323
+ changeRequestId: pullRequestNumber.toString(),
1324
+ sessionId,
1325
+ ownerId: userId,
1326
+ resourceId: sessionId,
1327
+ threadId: sessionId,
1328
+ source: "factory-pr-create",
1329
+ subscribedByUserId: userId
1330
+ }, github.integrationStorage).catch((error) => {
1331
+ console.warn(`[GitHub] Pull request ${result.url} was created but automatic subscription failed.`, error);
1332
+ });
1333
+ }
1334
+ return c.json({ url: result.url });
1335
+ });
1336
+ } catch (err) {
1337
+ return c.json({
1338
+ error: "github_pr_create_failed",
1339
+ message: err instanceof Error ? err.message : String(err)
1340
+ }, 502);
1341
+ }
1342
+ }
1343
+ })
1344
+ ];
1345
+ }
1346
+ /** Resolve the materialized workspace owned by a Factory session. */
1347
+ async function resolveSessionWorkspace(github, projectId, userId, sessionId) {
1348
+ if (typeof sessionId !== "string") return;
1349
+ const session = await github.sourceControlStorage.sessions.getBySessionId(sessionId);
1350
+ if (session?.projectRepositoryId !== projectId || session.userId !== userId) return;
1351
+ const entry = peekSessionSandbox(session.id);
1352
+ if (!entry?.workdir) return void 0;
1353
+ return {
1354
+ session,
1355
+ workdir: entry.workdir,
1356
+ sandbox: requireExec(entry.sandbox)
1357
+ };
1358
+ }
1359
+ //#endregion
1360
+ export { buildGithubRoutes, ingestLinkedRepositoryBacklog };
1361
+
1362
+ //# sourceMappingURL=routes.js.map