@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,344 @@
1
+ import { headsChanged, recordedHeadResolver, resolveCurrentHeads } from "./heads.js";
2
+ import { environmentSandboxContext, resolveProjectEnvironment } from "../workspace.js";
3
+ import { createHash, randomUUID } from "crypto";
4
+ //#region src/environment/build.ts
5
+ /**
6
+ * One proactive environment build: decide whether a trigger should build,
7
+ * hand the sandbox's `builds` capability a context identical to a session's,
8
+ * and record the started build on the project row. Polling the build to its
9
+ * end and pinning the active template is the workflow's second step
10
+ * (`build-workflow.ts`), so a request that only needs the start answer never
11
+ * waits on the provider.
12
+ */
13
+ const ENVIRONMENT_BUILD_TRIGGERS = [
14
+ "manual",
15
+ "schedule",
16
+ "push"
17
+ ];
18
+ /** The synthetic session id a project's build runs under; never a session. */
19
+ function environmentBuildSessionId(projectId) {
20
+ return `environment-build:${projectId}`;
21
+ }
22
+ /**
23
+ * A build or setup error may echo a clone URL or a token; strip URL userinfo
24
+ * and GitHub token shapes before the message is stored, logged or shown.
25
+ */
26
+ function redactCredentials(message) {
27
+ return message.replace(/\/\/[^/\s@]+@/g, "//***@").replace(/\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]+/g, "***");
28
+ }
29
+ /** An error's message with credentials redacted, safe to log, store or return. */
30
+ function errorReason(error) {
31
+ return redactCredentials(error instanceof Error ? error.message : String(error));
32
+ }
33
+ /**
34
+ * The context an environment build (or a read of its status) hands the
35
+ * provider: the same list form a session boots with, under the build's own
36
+ * session id, with heads served from `heads` so the provider never resolves
37
+ * them itself.
38
+ */
39
+ function environmentBuildContext(project, environment, heads, versionControl) {
40
+ return {
41
+ sessionId: environmentBuildSessionId(project.id),
42
+ ...environmentSandboxContext(environment, {
43
+ orgId: project.orgId,
44
+ getRepositoryAccess: (args) => versionControl.getRepositoryAccess(args),
45
+ resolveHead: recordedHeadResolver(heads)
46
+ })
47
+ };
48
+ }
49
+ /**
50
+ * Fingerprint of everything a build bakes into the template besides the
51
+ * repository heads: provider settings, the repositories and their order,
52
+ * their setup commands, the workspace setup command and the working
53
+ * directory. A schedule or push skips a ready build only while this matches.
54
+ */
55
+ function environmentBuildInputs(environment) {
56
+ const inputs = {
57
+ settings: environment.settings,
58
+ workspaceSetupCommand: environment.workspaceSetupCommand ?? null,
59
+ workingDirectory: environment.workingDirectory ?? null,
60
+ repos: environment.repos.map((repo) => ({
61
+ repositoryId: repo.repositoryId,
62
+ templateBranch: repo.templateBranch,
63
+ setupCommand: repo.setupCommand ?? null
64
+ }))
65
+ };
66
+ return createHash("sha256").update(JSON.stringify(inputs)).digest("hex");
67
+ }
68
+ /**
69
+ * The current head of every environment repository's template branch, keyed
70
+ * by slug. The template clones the repository default branch (a link's own
71
+ * branch is the session's base, checked out after boot), so that is the
72
+ * branch a build pins; sessions let the provider resolve the same head.
73
+ */
74
+ async function resolveEnvironmentHeads(sourceControl, project, environment) {
75
+ return resolveCurrentHeads(sourceControl, {
76
+ orgId: project.orgId,
77
+ repositories: environment.repos.map((repo) => ({
78
+ id: repo.repositoryId,
79
+ slug: repo.slug,
80
+ branch: repo.templateBranch
81
+ }))
82
+ });
83
+ }
84
+ /**
85
+ * How long a build-start lease lasts without renewal. The run holding it
86
+ * renews it every third of that while it works, so a lease lapses only when
87
+ * its run died or stalled.
88
+ */
89
+ const BUILD_START_LEASE_MS = 10 * 6e4;
90
+ /** Tries at recording a started build before the run leaves its lease to lapse. */
91
+ const RECORD_ATTEMPTS = 5;
92
+ /**
93
+ * Start a build for `projectId` when `trigger` calls for one. Every trigger
94
+ * takes the project's build-start lease before reading build state and renews
95
+ * it until the started build is recorded, so overlapping manual, scheduled and
96
+ * push runs never both start a build, however long the provider takes; a run
97
+ * that finds the lease held skips as `starting`. Every trigger skips while the
98
+ * last build is still running; `schedule` and `push` also skip when the last
99
+ * build is ready and neither a head nor any other template input changed;
100
+ * `manual` otherwise always builds. A `push` that would build then takes the
101
+ * leading-edge debounce claim, so only a push that starts a build opens the
102
+ * window. Saving settings never builds.
103
+ *
104
+ * Taking over a lapsed lease leaves the start uncertain: the lapsed run may
105
+ * have started a build it never recorded. The mark persists until resolved.
106
+ * While it stands, a provider that lists builds is asked for a running one
107
+ * (and every trigger skips as `in_progress` on it); with a provider that
108
+ * cannot list, every trigger skips as `unresolved`.
109
+ *
110
+ * The result is written as the lease is released, and only while this run
111
+ * still holds it. A failed `builds.start` clears the last build id, so a later
112
+ * `schedule` or `push` cannot mistake the previous ready build for the current
113
+ * template; any other error keeps a running build's id. A started build whose
114
+ * recording keeps failing yields `failed` (`not_recorded`) with the lease left
115
+ * to lapse rather than released, and a run that lost its lease while the
116
+ * provider started yields `failed` (`superseded`); neither is polled or pinned.
117
+ */
118
+ async function runEnvironmentBuild(deps, input) {
119
+ const builds = deps.sandbox?.builds;
120
+ if (!builds) return {
121
+ outcome: "unavailable",
122
+ reason: "no_builds"
123
+ };
124
+ if (!deps.sourceControl) return {
125
+ outcome: "unavailable",
126
+ reason: "no_source_control"
127
+ };
128
+ const sourceControl = deps.sourceControl;
129
+ const initial = await deps.projects.getById({ id: input.projectId });
130
+ if (!initial) return {
131
+ outcome: "skipped",
132
+ reason: "no_environment"
133
+ };
134
+ const now = deps.now ?? (() => /* @__PURE__ */ new Date());
135
+ const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
136
+ const pushDebounced = (project, at) => project.lastPushBuildAt !== null && at.getTime() - project.lastPushBuildAt.getTime() < project.buildPushDebounceMinutes * 6e4;
137
+ if (input.trigger === "push" && pushDebounced(initial, now())) return {
138
+ outcome: "skipped",
139
+ reason: "debounced"
140
+ };
141
+ const token = randomUUID();
142
+ const lease = {
143
+ id: initial.id,
144
+ token,
145
+ leaseMs: BUILD_START_LEASE_MS
146
+ };
147
+ const claim = await deps.projects.claimBuildStart({
148
+ ...lease,
149
+ now: now()
150
+ });
151
+ if (!claim.claimed) return {
152
+ outcome: "skipped",
153
+ reason: "starting"
154
+ };
155
+ let held = true;
156
+ const renewal = setInterval(() => {
157
+ deps.projects.renewBuildStart({
158
+ ...lease,
159
+ now: now()
160
+ }).then((renewed) => {
161
+ if (!renewed) held = false;
162
+ }, () => {});
163
+ }, deps.leaseRenewMs ?? 6e5 / 3);
164
+ renewal.unref?.();
165
+ const attempted = { lastBuildAttemptedAt: now() };
166
+ let resolved = false;
167
+ const release = (changes = {}) => deps.projects.releaseBuildStart({
168
+ id: initial.id,
169
+ token,
170
+ changes,
171
+ resolved,
172
+ now: now()
173
+ });
174
+ const failed = async (error, changes) => {
175
+ const reason = errorReason(error);
176
+ await release(changes);
177
+ deps.logger?.info("environment build failed", {
178
+ factoryProjectId: initial.id,
179
+ trigger: input.trigger,
180
+ reason
181
+ });
182
+ return {
183
+ outcome: "failed",
184
+ reason
185
+ };
186
+ };
187
+ try {
188
+ let project;
189
+ let environment;
190
+ let heads;
191
+ let ctx;
192
+ let buildInputs;
193
+ try {
194
+ project = await deps.projects.getById({ id: initial.id }) ?? initial;
195
+ environment = await resolveProjectEnvironment(sourceControl.storage, project);
196
+ if (environment.repos.length === 0) {
197
+ await release();
198
+ return {
199
+ outcome: "skipped",
200
+ reason: "no_environment"
201
+ };
202
+ }
203
+ heads = await resolveEnvironmentHeads(sourceControl, project, environment);
204
+ ctx = environmentBuildContext(project, environment, heads, sourceControl.versionControl);
205
+ buildInputs = environmentBuildInputs(environment);
206
+ if (claim.uncertain) if (builds.list) {
207
+ const running = (await builds.list(ctx, environment.settings)).find((build) => build.status === "pending" || build.status === "building");
208
+ if (running) {
209
+ await release();
210
+ return {
211
+ outcome: "skipped",
212
+ reason: "in_progress",
213
+ buildId: running.buildId
214
+ };
215
+ }
216
+ resolved = true;
217
+ } else {
218
+ await release();
219
+ return {
220
+ outcome: "skipped",
221
+ reason: "unresolved"
222
+ };
223
+ }
224
+ if (project.lastBuildId) {
225
+ const last = await builds.get(ctx, environment.settings, project.lastBuildId);
226
+ if (last.status === "pending" || last.status === "building") {
227
+ await release();
228
+ return {
229
+ outcome: "skipped",
230
+ reason: "in_progress",
231
+ buildId: project.lastBuildId
232
+ };
233
+ }
234
+ let pinnedHeads = project.activeTemplateHeads;
235
+ const lastTemplateId = last.templateId ?? project.lastBuildId;
236
+ if (last.status === "ready" && project.lastBuildHeads && project.activeTemplateId !== lastTemplateId) {
237
+ if (await deps.projects.pinActiveTemplate({
238
+ id: project.id,
239
+ buildId: project.lastBuildId,
240
+ templateId: lastTemplateId,
241
+ heads: project.lastBuildHeads
242
+ })) pinnedHeads = project.lastBuildHeads;
243
+ }
244
+ if ((input.trigger === "schedule" || input.trigger === "push") && last.status === "ready" && !headsChanged(pinnedHeads, heads) && project.lastBuildInputs === buildInputs) {
245
+ await release();
246
+ return {
247
+ outcome: "skipped",
248
+ reason: "unchanged"
249
+ };
250
+ }
251
+ }
252
+ } catch (error) {
253
+ return await failed(error, attempted);
254
+ }
255
+ if (!held) return {
256
+ outcome: "skipped",
257
+ reason: "starting"
258
+ };
259
+ if (input.trigger === "push") {
260
+ let claimed;
261
+ try {
262
+ claimed = await deps.projects.claimBuildAttempt({
263
+ id: project.id,
264
+ debounceMinutes: project.buildPushDebounceMinutes,
265
+ now: now()
266
+ });
267
+ } catch (error) {
268
+ return await failed(error, {});
269
+ }
270
+ if (!claimed) {
271
+ await release();
272
+ return {
273
+ outcome: "skipped",
274
+ reason: "debounced"
275
+ };
276
+ }
277
+ }
278
+ let started;
279
+ try {
280
+ started = await builds.start(ctx, environment.settings);
281
+ } catch (error) {
282
+ return await failed(error, {
283
+ lastBuildId: null,
284
+ lastBuildHeads: null,
285
+ lastBuildInputs: null,
286
+ ...attempted
287
+ });
288
+ }
289
+ const log = {
290
+ factoryProjectId: project.id,
291
+ trigger: input.trigger,
292
+ buildId: started.buildId
293
+ };
294
+ const changes = {
295
+ lastBuildId: started.buildId,
296
+ lastBuildHeads: heads,
297
+ lastBuildInputs: buildInputs,
298
+ ...attempted
299
+ };
300
+ let recorded;
301
+ for (let attempt = 1; recorded === void 0; attempt++) try {
302
+ recorded = await release(changes);
303
+ } catch (error) {
304
+ if (attempt >= RECORD_ATTEMPTS) {
305
+ deps.logger?.info("environment build started but not recorded", {
306
+ ...log,
307
+ reason: errorReason(error)
308
+ });
309
+ return {
310
+ outcome: "failed",
311
+ reason: "not_recorded",
312
+ buildId: started.buildId
313
+ };
314
+ }
315
+ await sleep(1e3 * 2 ** (attempt - 1));
316
+ }
317
+ if (!recorded) {
318
+ deps.logger?.info("environment build superseded", log);
319
+ return {
320
+ outcome: "failed",
321
+ reason: "superseded",
322
+ buildId: started.buildId
323
+ };
324
+ }
325
+ try {
326
+ deps.logger?.info("environment build started", {
327
+ ...log,
328
+ templateId: started.templateId
329
+ });
330
+ } catch {}
331
+ return {
332
+ outcome: "started",
333
+ buildId: started.buildId,
334
+ ...started.templateId ? { templateId: started.templateId } : {},
335
+ heads
336
+ };
337
+ } finally {
338
+ clearInterval(renewal);
339
+ }
340
+ }
341
+ //#endregion
342
+ export { BUILD_START_LEASE_MS, ENVIRONMENT_BUILD_TRIGGERS, environmentBuildContext, environmentBuildInputs, environmentBuildSessionId, errorReason, redactCredentials, resolveEnvironmentHeads, runEnvironmentBuild };
343
+
344
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","names":[],"sources":["../../src/environment/build.ts"],"sourcesContent":["/**\n * One proactive environment build: decide whether a trigger should build,\n * hand the sandbox's `builds` capability a context identical to a session's,\n * and record the started build on the project row. Polling the build to its\n * end and pinning the active template is the workflow's second step\n * (`build-workflow.ts`), so a request that only needs the start answer never\n * waits on the provider.\n */\n\nimport { createHash, randomUUID } from 'node:crypto';\n\nimport type { FactorySandbox, FactorySandboxContext } from '@mastra/core/workspace';\nimport type { VersionControl } from '../capabilities/version-control.js';\nimport type { FactoryProject, FactoryProjectsStorage } from '../storage/domains/projects/base.js';\nimport type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';\nimport { environmentSandboxContext, resolveProjectEnvironment } from '../workspace.js';\nimport type { SessionEnvironment } from '../workspace.js';\nimport { headsChanged, recordedHeadResolver, resolveCurrentHeads } from './heads.js';\nimport type { EnvironmentHeads } from './heads.js';\n\nexport const ENVIRONMENT_BUILD_TRIGGERS = ['manual', 'schedule', 'push'] as const;\nexport type EnvironmentBuildTrigger = (typeof ENVIRONMENT_BUILD_TRIGGERS)[number];\n\nexport interface EnvironmentBuildSourceControl {\n storage: Pick<SourceControlStorageHandle, 'projectRepositories' | 'repositories'>;\n versionControl: Pick<VersionControl, 'getRepositoryAccess'>;\n}\n\nexport interface EnvironmentBuildDeps {\n /** The factory's normalized sandbox; builds are unavailable without its `builds`. */\n sandbox: FactorySandbox | undefined;\n projects: Pick<\n FactoryProjectsStorage,\n 'getById' | 'claimBuildAttempt' | 'claimBuildStart' | 'renewBuildStart' | 'releaseBuildStart' | 'pinActiveTemplate'\n >;\n /** Absent when the factory has no source-control integration to resolve heads with. */\n sourceControl: EnvironmentBuildSourceControl | undefined;\n logger?: { info: (msg: string, meta?: Record<string, unknown>) => void };\n now?: () => Date;\n /** How often a run renews its build-start lease; a third of `BUILD_START_LEASE_MS` by default. */\n leaseRenewMs?: number;\n /** Waits between tries at recording a started build. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface EnvironmentBuildOutcome {\n outcome: 'started' | 'skipped' | 'unavailable' | 'failed';\n buildId?: string;\n templateId?: string;\n /** Why nothing started: `debounced`, `starting` (another run is starting a build), `in_progress`, `unchanged`, `unresolved` (a lapsed run may have started a build the provider cannot list), `no_environment`, `no_builds`, `no_source_control`; why a run failed: `not_recorded`, `superseded`, or an error. */\n reason?: string;\n /** The heads the started build pins; the workflow stores them once the build is ready. */\n heads?: EnvironmentHeads;\n}\n\n/** The synthetic session id a project's build runs under; never a session. */\nexport function environmentBuildSessionId(projectId: string): string {\n return `environment-build:${projectId}`;\n}\n\n/**\n * A build or setup error may echo a clone URL or a token; strip URL userinfo\n * and GitHub token shapes before the message is stored, logged or shown.\n */\nexport function redactCredentials(message: string): string {\n return message.replace(/\\/\\/[^/\\s@]+@/g, '//***@').replace(/\\b(?:gh[pousr]|github_pat)_[A-Za-z0-9_]+/g, '***');\n}\n\n/** An error's message with credentials redacted, safe to log, store or return. */\nexport function errorReason(error: unknown): string {\n return redactCredentials(error instanceof Error ? error.message : String(error));\n}\n\n/**\n * The context an environment build (or a read of its status) hands the\n * provider: the same list form a session boots with, under the build's own\n * session id, with heads served from `heads` so the provider never resolves\n * them itself.\n */\nexport function environmentBuildContext(\n project: Pick<FactoryProject, 'id' | 'orgId'>,\n environment: SessionEnvironment,\n heads: EnvironmentHeads,\n versionControl: Pick<VersionControl, 'getRepositoryAccess'>,\n): FactorySandboxContext {\n return {\n sessionId: environmentBuildSessionId(project.id),\n ...environmentSandboxContext(environment, {\n orgId: project.orgId,\n getRepositoryAccess: args => versionControl.getRepositoryAccess(args),\n resolveHead: recordedHeadResolver(heads),\n }),\n };\n}\n\n/**\n * Fingerprint of everything a build bakes into the template besides the\n * repository heads: provider settings, the repositories and their order,\n * their setup commands, the workspace setup command and the working\n * directory. A schedule or push skips a ready build only while this matches.\n */\nexport function environmentBuildInputs(environment: SessionEnvironment): string {\n const inputs = {\n settings: environment.settings,\n workspaceSetupCommand: environment.workspaceSetupCommand ?? null,\n workingDirectory: environment.workingDirectory ?? null,\n repos: environment.repos.map(repo => ({\n repositoryId: repo.repositoryId,\n templateBranch: repo.templateBranch,\n setupCommand: repo.setupCommand ?? null,\n })),\n };\n return createHash('sha256').update(JSON.stringify(inputs)).digest('hex');\n}\n\n/**\n * The current head of every environment repository's template branch, keyed\n * by slug. The template clones the repository default branch (a link's own\n * branch is the session's base, checked out after boot), so that is the\n * branch a build pins; sessions let the provider resolve the same head.\n */\nexport async function resolveEnvironmentHeads(\n sourceControl: EnvironmentBuildSourceControl,\n project: Pick<FactoryProject, 'orgId'>,\n environment: SessionEnvironment,\n): Promise<EnvironmentHeads> {\n return resolveCurrentHeads(sourceControl, {\n orgId: project.orgId,\n repositories: environment.repos.map(repo => ({\n id: repo.repositoryId,\n slug: repo.slug,\n branch: repo.templateBranch,\n })),\n });\n}\n\n/**\n * How long a build-start lease lasts without renewal. The run holding it\n * renews it every third of that while it works, so a lease lapses only when\n * its run died or stalled.\n */\nexport const BUILD_START_LEASE_MS = 10 * 60_000;\n\n/** Tries at recording a started build before the run leaves its lease to lapse. */\nconst RECORD_ATTEMPTS = 5;\n\n/**\n * Start a build for `projectId` when `trigger` calls for one. Every trigger\n * takes the project's build-start lease before reading build state and renews\n * it until the started build is recorded, so overlapping manual, scheduled and\n * push runs never both start a build, however long the provider takes; a run\n * that finds the lease held skips as `starting`. Every trigger skips while the\n * last build is still running; `schedule` and `push` also skip when the last\n * build is ready and neither a head nor any other template input changed;\n * `manual` otherwise always builds. A `push` that would build then takes the\n * leading-edge debounce claim, so only a push that starts a build opens the\n * window. Saving settings never builds.\n *\n * Taking over a lapsed lease leaves the start uncertain: the lapsed run may\n * have started a build it never recorded. The mark persists until resolved.\n * While it stands, a provider that lists builds is asked for a running one\n * (and every trigger skips as `in_progress` on it); with a provider that\n * cannot list, every trigger skips as `unresolved`.\n *\n * The result is written as the lease is released, and only while this run\n * still holds it. A failed `builds.start` clears the last build id, so a later\n * `schedule` or `push` cannot mistake the previous ready build for the current\n * template; any other error keeps a running build's id. A started build whose\n * recording keeps failing yields `failed` (`not_recorded`) with the lease left\n * to lapse rather than released, and a run that lost its lease while the\n * provider started yields `failed` (`superseded`); neither is polled or pinned.\n */\nexport async function runEnvironmentBuild(\n deps: EnvironmentBuildDeps,\n input: { projectId: string; trigger: EnvironmentBuildTrigger },\n): Promise<EnvironmentBuildOutcome> {\n const builds = deps.sandbox?.builds;\n if (!builds) return { outcome: 'unavailable', reason: 'no_builds' };\n if (!deps.sourceControl) return { outcome: 'unavailable', reason: 'no_source_control' };\n const sourceControl = deps.sourceControl;\n const initial = await deps.projects.getById({ id: input.projectId });\n if (!initial) return { outcome: 'skipped', reason: 'no_environment' };\n const now = deps.now ?? (() => new Date());\n const sleep = deps.sleep ?? ((ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms)));\n\n const pushDebounced = (project: FactoryProject, at: Date) =>\n project.lastPushBuildAt !== null &&\n at.getTime() - project.lastPushBuildAt.getTime() < project.buildPushDebounceMinutes * 60_000;\n if (input.trigger === 'push' && pushDebounced(initial, now())) return { outcome: 'skipped', reason: 'debounced' };\n\n const token = randomUUID();\n const lease = { id: initial.id, token, leaseMs: BUILD_START_LEASE_MS };\n const claim = await deps.projects.claimBuildStart({ ...lease, now: now() });\n if (!claim.claimed) return { outcome: 'skipped', reason: 'starting' };\n let held = true;\n const renewal = setInterval(\n () => {\n deps.projects.renewBuildStart({ ...lease, now: now() }).then(\n renewed => {\n if (!renewed) held = false;\n },\n // A failed renewal is retried on the next tick; the lease outlasts two misses.\n () => {},\n );\n },\n deps.leaseRenewMs ?? BUILD_START_LEASE_MS / 3,\n );\n renewal.unref?.();\n\n const attempted = { lastBuildAttemptedAt: now() };\n // Set once this run has reconciled an uncertain start, or builds past it.\n let resolved = false;\n const release = (changes: Parameters<EnvironmentBuildDeps['projects']['releaseBuildStart']>[0]['changes'] = {}) =>\n deps.projects.releaseBuildStart({ id: initial.id, token, changes, resolved, now: now() });\n const failed = async (error: unknown, changes: Parameters<typeof release>[0]) => {\n const reason = errorReason(error);\n await release(changes);\n deps.logger?.info('environment build failed', { factoryProjectId: initial.id, trigger: input.trigger, reason });\n return { outcome: 'failed', reason } satisfies EnvironmentBuildOutcome;\n };\n\n try {\n let project: FactoryProject;\n let environment: SessionEnvironment;\n let heads: EnvironmentHeads;\n let ctx: FactorySandboxContext;\n let buildInputs: string;\n try {\n // Read build state only once this run holds the lease, so a run that\n // finished while this one waited has already recorded its build.\n project = (await deps.projects.getById({ id: initial.id })) ?? initial;\n environment = await resolveProjectEnvironment(sourceControl.storage, project);\n if (environment.repos.length === 0) {\n await release();\n return { outcome: 'skipped', reason: 'no_environment' };\n }\n heads = await resolveEnvironmentHeads(sourceControl, project, environment);\n ctx = environmentBuildContext(project, environment, heads, sourceControl.versionControl);\n buildInputs = environmentBuildInputs(environment);\n\n if (claim.uncertain) {\n // A run whose lease lapsed may have reached the provider before it\n // died; a build it left running is never raced by a second one. The\n // mark stays until that build is gone, since its inputs are unknown.\n if (builds.list) {\n const listed = await builds.list(ctx, environment.settings);\n const running = listed.find(build => build.status === 'pending' || build.status === 'building');\n if (running) {\n await release();\n return { outcome: 'skipped', reason: 'in_progress', buildId: running.buildId };\n }\n resolved = true;\n } else {\n // Without history the earlier start can never be reconciled, so no\n // trigger starts another build beside it.\n await release();\n return { outcome: 'skipped', reason: 'unresolved' };\n }\n }\n\n if (project.lastBuildId) {\n const last = await builds.get(ctx, environment.settings, project.lastBuildId);\n // Two runs polling one template fight over it (each poll resubmits its\n // own definition and the provider cancels the other), so a running\n // build is never joined by a second one, whatever asked.\n if (last.status === 'pending' || last.status === 'building') {\n await release();\n return { outcome: 'skipped', reason: 'in_progress', buildId: project.lastBuildId };\n }\n // A ready build whose poll ran out or died with its host was never\n // pinned; pin it now so the skip below compares against what it built.\n let pinnedHeads = project.activeTemplateHeads;\n const lastTemplateId = last.templateId ?? project.lastBuildId;\n if (last.status === 'ready' && project.lastBuildHeads && project.activeTemplateId !== lastTemplateId) {\n const pinned = await deps.projects.pinActiveTemplate({\n id: project.id,\n buildId: project.lastBuildId,\n templateId: lastTemplateId,\n heads: project.lastBuildHeads,\n });\n if (pinned) pinnedHeads = project.lastBuildHeads;\n }\n if (\n (input.trigger === 'schedule' || input.trigger === 'push') &&\n last.status === 'ready' &&\n !headsChanged(pinnedHeads, heads) &&\n project.lastBuildInputs === buildInputs\n ) {\n await release();\n return { outcome: 'skipped', reason: 'unchanged' };\n }\n }\n } catch (error) {\n return await failed(error, attempted);\n }\n\n // A run that lost its lease while reading must not start beside its successor.\n if (!held) return { outcome: 'skipped', reason: 'starting' };\n\n if (input.trigger === 'push') {\n // Claimed only now, so a push that skipped above never closes the window.\n let claimed: boolean;\n try {\n claimed = await deps.projects.claimBuildAttempt({\n id: project.id,\n debounceMinutes: project.buildPushDebounceMinutes,\n now: now(),\n });\n } catch (error) {\n return await failed(error, {});\n }\n if (!claimed) {\n await release();\n return { outcome: 'skipped', reason: 'debounced' };\n }\n }\n\n let started: Awaited<ReturnType<typeof builds.start>>;\n try {\n started = await builds.start(ctx, environment.settings);\n } catch (error) {\n // Only a failed start clears the last build: the previous one no longer\n // describes the template this project wants.\n return await failed(error, { lastBuildId: null, lastBuildHeads: null, lastBuildInputs: null, ...attempted });\n }\n\n // The provider has started the build: from here on, no error clears it.\n const log = { factoryProjectId: project.id, trigger: input.trigger, buildId: started.buildId };\n const changes = { lastBuildId: started.buildId, lastBuildHeads: heads, lastBuildInputs: buildInputs, ...attempted };\n let recorded: boolean | undefined;\n for (let attempt = 1; recorded === undefined; attempt++) {\n try {\n recorded = await release(changes);\n } catch (error) {\n if (attempt >= RECORD_ATTEMPTS) {\n // Keep the lease: it lapses once renewal stops, and the run that\n // takes it over looks for this build at the provider first.\n deps.logger?.info('environment build started but not recorded', { ...log, reason: errorReason(error) });\n return { outcome: 'failed', reason: 'not_recorded', buildId: started.buildId };\n }\n await sleep(1000 * 2 ** (attempt - 1));\n }\n }\n if (!recorded) {\n // A newer run took the lease while the provider started this build; the\n // project tracks that run's build, so this one is never polled or pinned.\n deps.logger?.info('environment build superseded', log);\n return { outcome: 'failed', reason: 'superseded', buildId: started.buildId };\n }\n try {\n deps.logger?.info('environment build started', { ...log, templateId: started.templateId });\n } catch {\n // Logging never turns a recorded build into a failure.\n }\n return {\n outcome: 'started',\n buildId: started.buildId,\n ...(started.templateId ? { templateId: started.templateId } : {}),\n heads,\n };\n } finally {\n clearInterval(renewal);\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Which commit each environment repository pins to.
3
+ *
4
+ * The repo templates key `resolveHead` by clone URL; the factory records heads
5
+ * by repository slug. These helpers translate between the two and decide
6
+ * whether a set of current heads differs from the recorded one.
7
+ */
8
+ import type { VersionControl } from '../capabilities/version-control.js';
9
+ export type EnvironmentHeads = Record<string, string>;
10
+ /** `owner/repo` from a clone URL in any common spelling, lower-cased, `.git` stripped; undefined when unparseable. */
11
+ export declare function cloneUrlSlug(cloneUrl: string): string | undefined;
12
+ /** The environment slug a clone URL names, in the environment's own spelling; undefined when none matches. */
13
+ export declare function matchEnvironmentSlug(cloneUrl: string, slugs: Iterable<string>): string | undefined;
14
+ /**
15
+ * A `resolveHead` that answers from recorded heads only: the template pins to
16
+ * what the last build used, so its identity moves when a build does. A URL
17
+ * outside the recorded set resolves undefined and the template falls back to
18
+ * its own lookup for that repository.
19
+ */
20
+ export declare function recordedHeadResolver(heads: EnvironmentHeads): (cloneUrl: string) => Promise<string | undefined>;
21
+ /** True when any repository's current head differs from the recorded one, or either side names a repository the other lacks. */
22
+ export declare function headsChanged(recorded: EnvironmentHeads | null, current: EnvironmentHeads): boolean;
23
+ export interface HeadRepository {
24
+ id: string;
25
+ slug: string;
26
+ /** The ref the environment pins: the link's branch, else the repository default. */
27
+ branch: string;
28
+ }
29
+ /** Current head of every repository's pinned ref, keyed by slug. Throws when any lookup fails. */
30
+ export declare function resolveCurrentHeads(github: {
31
+ versionControl: Pick<VersionControl, 'getRepositoryAccess'>;
32
+ }, input: {
33
+ orgId: string;
34
+ repositories: HeadRepository[];
35
+ }): Promise<EnvironmentHeads>;
36
+ //# sourceMappingURL=heads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heads.d.ts","sourceRoot":"","sources":["../../src/environment/heads.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD,sHAAsH;AACtH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkBjE;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAOlG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAM/G;AAED,gIAAgI;AAChI,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAMlG;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,kGAAkG;AAClG,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAA;CAAE,EACvE,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,cAAc,EAAE,CAAA;CAAE,GACvD,OAAO,CAAC,gBAAgB,CAAC,CAU3B"}
@@ -0,0 +1,60 @@
1
+ import { getBranchHead } from "../integrations/github/commits.js";
2
+ //#region src/environment/heads.ts
3
+ /** `owner/repo` from a clone URL in any common spelling, lower-cased, `.git` stripped; undefined when unparseable. */
4
+ function cloneUrlSlug(cloneUrl) {
5
+ let path;
6
+ const scp = /^[^@/]+@[^:/]+:(.+)$/.exec(cloneUrl.trim());
7
+ if (scp) path = scp[1];
8
+ else try {
9
+ path = new URL(cloneUrl.trim()).pathname;
10
+ } catch {
11
+ return;
12
+ }
13
+ const parts = path.replace(/\.git$/i, "").split("/").filter(Boolean);
14
+ if (parts.length < 2) return void 0;
15
+ return `${parts[parts.length - 2]}/${parts[parts.length - 1]}`.toLowerCase();
16
+ }
17
+ /** The environment slug a clone URL names, in the environment's own spelling; undefined when none matches. */
18
+ function matchEnvironmentSlug(cloneUrl, slugs) {
19
+ const wanted = cloneUrlSlug(cloneUrl);
20
+ if (!wanted) return void 0;
21
+ for (const slug of slugs) if (slug.toLowerCase() === wanted) return slug;
22
+ }
23
+ /**
24
+ * A `resolveHead` that answers from recorded heads only: the template pins to
25
+ * what the last build used, so its identity moves when a build does. A URL
26
+ * outside the recorded set resolves undefined and the template falls back to
27
+ * its own lookup for that repository.
28
+ */
29
+ function recordedHeadResolver(heads) {
30
+ const slugs = Object.keys(heads);
31
+ return async (cloneUrl) => {
32
+ const slug = matchEnvironmentSlug(cloneUrl, slugs);
33
+ return slug ? heads[slug] : void 0;
34
+ };
35
+ }
36
+ /** True when any repository's current head differs from the recorded one, or either side names a repository the other lacks. */
37
+ function headsChanged(recorded, current) {
38
+ if (!recorded) return true;
39
+ const recordedKeys = Object.keys(recorded);
40
+ const currentKeys = Object.keys(current);
41
+ if (recordedKeys.length !== currentKeys.length) return true;
42
+ return currentKeys.some((slug) => recorded[slug] !== current[slug]);
43
+ }
44
+ /** Current head of every repository's pinned ref, keyed by slug. Throws when any lookup fails. */
45
+ async function resolveCurrentHeads(github, input) {
46
+ const heads = {};
47
+ for (const repository of input.repositories) heads[repository.slug] = await getBranchHead(github, {
48
+ orgId: input.orgId,
49
+ repository: {
50
+ id: repository.id,
51
+ slug: repository.slug
52
+ },
53
+ branch: repository.branch
54
+ });
55
+ return heads;
56
+ }
57
+ //#endregion
58
+ export { cloneUrlSlug, headsChanged, matchEnvironmentSlug, recordedHeadResolver, resolveCurrentHeads };
59
+
60
+ //# sourceMappingURL=heads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heads.js","names":[],"sources":["../../src/environment/heads.ts"],"sourcesContent":["/**\n * Which commit each environment repository pins to.\n *\n * The repo templates key `resolveHead` by clone URL; the factory records heads\n * by repository slug. These helpers translate between the two and decide\n * whether a set of current heads differs from the recorded one.\n */\n\nimport type { VersionControl } from '../capabilities/version-control.js';\nimport { getBranchHead } from '../integrations/github/commits.js';\n\nexport type EnvironmentHeads = Record<string, string>;\n\n/** `owner/repo` from a clone URL in any common spelling, lower-cased, `.git` stripped; undefined when unparseable. */\nexport function cloneUrlSlug(cloneUrl: string): string | undefined {\n let path: string;\n const scp = /^[^@/]+@[^:/]+:(.+)$/.exec(cloneUrl.trim());\n if (scp) {\n path = scp[1]!;\n } else {\n try {\n path = new URL(cloneUrl.trim()).pathname;\n } catch {\n return undefined;\n }\n }\n const parts = path\n .replace(/\\.git$/i, '')\n .split('/')\n .filter(Boolean);\n if (parts.length < 2) return undefined;\n return `${parts[parts.length - 2]}/${parts[parts.length - 1]}`.toLowerCase();\n}\n\n/** The environment slug a clone URL names, in the environment's own spelling; undefined when none matches. */\nexport function matchEnvironmentSlug(cloneUrl: string, slugs: Iterable<string>): string | undefined {\n const wanted = cloneUrlSlug(cloneUrl);\n if (!wanted) return undefined;\n for (const slug of slugs) {\n if (slug.toLowerCase() === wanted) return slug;\n }\n return undefined;\n}\n\n/**\n * A `resolveHead` that answers from recorded heads only: the template pins to\n * what the last build used, so its identity moves when a build does. A URL\n * outside the recorded set resolves undefined and the template falls back to\n * its own lookup for that repository.\n */\nexport function recordedHeadResolver(heads: EnvironmentHeads): (cloneUrl: string) => Promise<string | undefined> {\n const slugs = Object.keys(heads);\n return async cloneUrl => {\n const slug = matchEnvironmentSlug(cloneUrl, slugs);\n return slug ? heads[slug] : undefined;\n };\n}\n\n/** True when any repository's current head differs from the recorded one, or either side names a repository the other lacks. */\nexport function headsChanged(recorded: EnvironmentHeads | null, current: EnvironmentHeads): boolean {\n if (!recorded) return true;\n const recordedKeys = Object.keys(recorded);\n const currentKeys = Object.keys(current);\n if (recordedKeys.length !== currentKeys.length) return true;\n return currentKeys.some(slug => recorded[slug] !== current[slug]);\n}\n\nexport interface HeadRepository {\n id: string;\n slug: string;\n /** The ref the environment pins: the link's branch, else the repository default. */\n branch: string;\n}\n\n/** Current head of every repository's pinned ref, keyed by slug. Throws when any lookup fails. */\nexport async function resolveCurrentHeads(\n github: { versionControl: Pick<VersionControl, 'getRepositoryAccess'> },\n input: { orgId: string; repositories: HeadRepository[] },\n): Promise<EnvironmentHeads> {\n const heads: EnvironmentHeads = {};\n for (const repository of input.repositories) {\n heads[repository.slug] = await getBranchHead(github, {\n orgId: input.orgId,\n repository: { id: repository.id, slug: repository.slug },\n branch: repository.branch,\n });\n }\n return heads;\n}\n"],"mappings":";;;AAcA,SAAgB,aAAa,UAAsC;CACjE,IAAI;CACJ,MAAM,MAAM,uBAAuB,KAAK,SAAS,KAAK,CAAC;CACvD,IAAI,KACF,OAAO,IAAI;MAEX,IAAI;EACF,OAAO,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC,CAAC;CAClC,QAAQ;EACN;CACF;CAEF,MAAM,QAAQ,KACX,QAAQ,WAAW,EAAE,CAAC,CACtB,MAAM,GAAG,CAAC,CACV,OAAO,OAAO;CACjB,IAAI,MAAM,SAAS,GAAG,OAAO,KAAA;CAC7B,OAAO,GAAG,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,MAAM,SAAS,KAAK,YAAY;AAC7E;;AAGA,SAAgB,qBAAqB,UAAkB,OAA6C;CAClG,MAAM,SAAS,aAAa,QAAQ;CACpC,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,YAAY,MAAM,QAAQ,OAAO;AAG9C;;;;;;;AAQA,SAAgB,qBAAqB,OAA4E;CAC/G,MAAM,QAAQ,OAAO,KAAK,KAAK;CAC/B,OAAO,OAAM,aAAY;EACvB,MAAM,OAAO,qBAAqB,UAAU,KAAK;EACjD,OAAO,OAAO,MAAM,QAAQ,KAAA;CAC9B;AACF;;AAGA,SAAgB,aAAa,UAAmC,SAAoC;CAClG,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,eAAe,OAAO,KAAK,QAAQ;CACzC,MAAM,cAAc,OAAO,KAAK,OAAO;CACvC,IAAI,aAAa,WAAW,YAAY,QAAQ,OAAO;CACvD,OAAO,YAAY,MAAK,SAAQ,SAAS,UAAU,QAAQ,KAAK;AAClE;;AAUA,eAAsB,oBACpB,QACA,OAC2B;CAC3B,MAAM,QAA0B,CAAC;CACjC,KAAK,MAAM,cAAc,MAAM,cAC7B,MAAM,WAAW,QAAQ,MAAM,cAAc,QAAQ;EACnD,OAAO,MAAM;EACb,YAAY;GAAE,IAAI,WAAW;GAAI,MAAM,WAAW;EAAK;EACvD,QAAQ,WAAW;CACrB,CAAC;CAEH,OAAO;AACT"}