@mastra/factory 0.28.0-alpha.9 → 0.29.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (348) hide show
  1. package/README.md +67 -46
  2. package/dist/boards/board-writes.d.ts +3 -3
  3. package/dist/boards/board-writes.d.ts.map +1 -1
  4. package/dist/boards/board-writes.js +24 -20
  5. package/dist/boards/board-writes.js.map +1 -1
  6. package/dist/boards/project-boards.d.ts +20 -0
  7. package/dist/boards/project-boards.d.ts.map +1 -1
  8. package/dist/boards/project-boards.js +35 -11
  9. package/dist/boards/project-boards.js.map +1 -1
  10. package/dist/boards/registry.d.ts.map +1 -1
  11. package/dist/boards/registry.js +0 -3
  12. package/dist/boards/registry.js.map +1 -1
  13. package/dist/boards/reroute.d.ts +31 -0
  14. package/dist/boards/reroute.d.ts.map +1 -0
  15. package/dist/boards/reroute.js +71 -0
  16. package/dist/boards/reroute.js.map +1 -0
  17. package/dist/capabilities/version-control.d.ts +6 -1
  18. package/dist/capabilities/version-control.d.ts.map +1 -1
  19. package/dist/environment/build-runner.d.ts +13 -2
  20. package/dist/environment/build-runner.d.ts.map +1 -1
  21. package/dist/environment/build-runner.js +42 -0
  22. package/dist/environment/build-runner.js.map +1 -1
  23. package/dist/environment/build-schedule.js +1 -1
  24. package/dist/environment/build-schedule.js.map +1 -1
  25. package/dist/environment/build-workflow.d.ts +6 -4
  26. package/dist/environment/build-workflow.d.ts.map +1 -1
  27. package/dist/environment/build-workflow.js +70 -66
  28. package/dist/environment/build-workflow.js.map +1 -1
  29. package/dist/environment/build.d.ts +22 -7
  30. package/dist/environment/build.d.ts.map +1 -1
  31. package/dist/environment/build.js +73 -15
  32. package/dist/environment/build.js.map +1 -1
  33. package/dist/environment/heads.d.ts +1 -1
  34. package/dist/environment/heads.d.ts.map +1 -1
  35. package/dist/environment/heads.js +4 -1
  36. package/dist/environment/heads.js.map +1 -1
  37. package/dist/environment/repository-access.d.ts +15 -0
  38. package/dist/environment/repository-access.d.ts.map +1 -0
  39. package/dist/environment/repository-access.js +60 -0
  40. package/dist/environment/repository-access.js.map +1 -0
  41. package/dist/factory.d.ts +5 -2
  42. package/dist/factory.d.ts.map +1 -1
  43. package/dist/factory.js +40 -30
  44. package/dist/factory.js.map +1 -1
  45. package/dist/integrations/base.d.ts +8 -0
  46. package/dist/integrations/base.d.ts.map +1 -1
  47. package/dist/integrations/dependabot/default-rules.d.ts +38 -0
  48. package/dist/integrations/dependabot/default-rules.d.ts.map +1 -0
  49. package/dist/integrations/dependabot/default-rules.js +63 -0
  50. package/dist/integrations/dependabot/default-rules.js.map +1 -0
  51. package/dist/integrations/dependabot/rules.d.ts +42 -0
  52. package/dist/integrations/dependabot/rules.d.ts.map +1 -0
  53. package/dist/integrations/dependabot/rules.js +187 -0
  54. package/dist/integrations/dependabot/rules.js.map +1 -0
  55. package/dist/integrations/dependabot/sync.d.ts +76 -0
  56. package/dist/integrations/dependabot/sync.d.ts.map +1 -0
  57. package/dist/integrations/dependabot/sync.js +111 -0
  58. package/dist/integrations/dependabot/sync.js.map +1 -0
  59. package/dist/integrations/github/routes.d.ts.map +1 -1
  60. package/dist/integrations/github/routes.js +7 -2
  61. package/dist/integrations/github/routes.js.map +1 -1
  62. package/dist/integrations/github/sandbox-release.d.ts +12 -0
  63. package/dist/integrations/github/sandbox-release.d.ts.map +1 -1
  64. package/dist/integrations/github/sandbox-release.js +16 -1
  65. package/dist/integrations/github/sandbox-release.js.map +1 -1
  66. package/dist/integrations/github/sandbox.d.ts +12 -0
  67. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  68. package/dist/integrations/github/sandbox.js +22 -1
  69. package/dist/integrations/github/sandbox.js.map +1 -1
  70. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  71. package/dist/integrations/platform/connect/routes.js +4 -0
  72. package/dist/integrations/platform/connect/routes.js.map +1 -1
  73. package/dist/integrations/platform/github/event-worker.d.ts +5 -0
  74. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  75. package/dist/integrations/platform/github/event-worker.js +33 -2
  76. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  77. package/dist/integrations/platform/github/integration.d.ts +19 -1
  78. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  79. package/dist/integrations/platform/github/integration.js +183 -105
  80. package/dist/integrations/platform/github/integration.js.map +1 -1
  81. package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
  82. package/dist/integrations/platform/jira/integration.js +5 -1
  83. package/dist/integrations/platform/jira/integration.js.map +1 -1
  84. package/dist/integrations/platform/vanta/integration.d.ts +33 -0
  85. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -0
  86. package/dist/integrations/platform/vanta/integration.js +133 -0
  87. package/dist/integrations/platform/vanta/integration.js.map +1 -0
  88. package/dist/integrations/slack/integration.d.ts.map +1 -1
  89. package/dist/integrations/slack/integration.js +7 -4
  90. package/dist/integrations/slack/integration.js.map +1 -1
  91. package/dist/integrations/vanta/default-rules.d.ts +34 -0
  92. package/dist/integrations/vanta/default-rules.d.ts.map +1 -0
  93. package/dist/integrations/vanta/default-rules.js +61 -0
  94. package/dist/integrations/vanta/default-rules.js.map +1 -0
  95. package/dist/integrations/vanta/rules.d.ts +40 -0
  96. package/dist/integrations/vanta/rules.d.ts.map +1 -0
  97. package/dist/integrations/vanta/rules.js +208 -0
  98. package/dist/integrations/vanta/rules.js.map +1 -0
  99. package/dist/integrations/vanta/sync.d.ts +36 -0
  100. package/dist/integrations/vanta/sync.d.ts.map +1 -0
  101. package/dist/integrations/vanta/sync.js +73 -0
  102. package/dist/integrations/vanta/sync.js.map +1 -0
  103. package/dist/mcp/routes.d.ts.map +1 -1
  104. package/dist/mcp/routes.js +3 -5
  105. package/dist/mcp/routes.js.map +1 -1
  106. package/dist/routes/board-snapshot.d.ts +24 -1
  107. package/dist/routes/board-snapshot.d.ts.map +1 -1
  108. package/dist/routes/board-snapshot.js +75 -7
  109. package/dist/routes/board-snapshot.js.map +1 -1
  110. package/dist/routes/boards.d.ts +2 -3
  111. package/dist/routes/boards.d.ts.map +1 -1
  112. package/dist/routes/boards.js.map +1 -1
  113. package/dist/routes/contracts.d.ts +307 -0
  114. package/dist/routes/contracts.d.ts.map +1 -1
  115. package/dist/routes/contracts.js +253 -9
  116. package/dist/routes/contracts.js.map +1 -1
  117. package/dist/routes/intake-routes.d.ts +3 -0
  118. package/dist/routes/intake-routes.d.ts.map +1 -1
  119. package/dist/routes/intake-routes.js +44 -0
  120. package/dist/routes/intake-routes.js.map +1 -1
  121. package/dist/routes/knowledge.d.ts.map +1 -1
  122. package/dist/routes/knowledge.js +3 -2
  123. package/dist/routes/knowledge.js.map +1 -1
  124. package/dist/routes/projects.d.ts.map +1 -1
  125. package/dist/routes/projects.js +5 -0
  126. package/dist/routes/projects.js.map +1 -1
  127. package/dist/routes/sandbox-envs.d.ts +2 -0
  128. package/dist/routes/sandbox-envs.d.ts.map +1 -1
  129. package/dist/routes/sandbox-envs.js +3 -0
  130. package/dist/routes/sandbox-envs.js.map +1 -1
  131. package/dist/routes/source-control-sessions.d.ts +1 -1
  132. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  133. package/dist/routes/source-control-sessions.js +109 -3
  134. package/dist/routes/source-control-sessions.js.map +1 -1
  135. package/dist/routes/source-control-settings.d.ts +2 -0
  136. package/dist/routes/source-control-settings.d.ts.map +1 -1
  137. package/dist/routes/source-control-settings.js +5 -0
  138. package/dist/routes/source-control-settings.js.map +1 -1
  139. package/dist/routes/surface.d.ts +8 -1
  140. package/dist/routes/surface.d.ts.map +1 -1
  141. package/dist/routes/surface.js +74 -10
  142. package/dist/routes/surface.js.map +1 -1
  143. package/dist/routes/work-item-activity.d.ts +11 -0
  144. package/dist/routes/work-item-activity.d.ts.map +1 -0
  145. package/dist/routes/work-item-activity.js +25 -0
  146. package/dist/routes/work-item-activity.js.map +1 -0
  147. package/dist/routes/work-item-selection.d.ts +14 -0
  148. package/dist/routes/work-item-selection.d.ts.map +1 -0
  149. package/dist/routes/work-item-selection.js +44 -0
  150. package/dist/routes/work-item-selection.js.map +1 -0
  151. package/dist/routes/work-item-starters.d.ts +29 -0
  152. package/dist/routes/work-item-starters.d.ts.map +1 -0
  153. package/dist/routes/work-item-starters.js +152 -0
  154. package/dist/routes/work-item-starters.js.map +1 -0
  155. package/dist/routes/work-items.d.ts.map +1 -1
  156. package/dist/routes/work-items.js +239 -16
  157. package/dist/routes/work-items.js.map +1 -1
  158. package/dist/rules/dispatch-errors.d.ts +3 -0
  159. package/dist/rules/dispatch-errors.d.ts.map +1 -1
  160. package/dist/rules/dispatch-errors.js +9 -0
  161. package/dist/rules/dispatch-errors.js.map +1 -1
  162. package/dist/rules/dispatcher.d.ts +4 -1
  163. package/dist/rules/dispatcher.d.ts.map +1 -1
  164. package/dist/rules/dispatcher.js +122 -33
  165. package/dist/rules/dispatcher.js.map +1 -1
  166. package/dist/rules/index.d.ts +2 -2
  167. package/dist/rules/index.d.ts.map +1 -1
  168. package/dist/rules/index.js +2 -2
  169. package/dist/rules/processor.d.ts +2 -0
  170. package/dist/rules/processor.d.ts.map +1 -1
  171. package/dist/rules/processor.js +18 -4
  172. package/dist/rules/processor.js.map +1 -1
  173. package/dist/rules/start-coordinator.d.ts +6 -1
  174. package/dist/rules/start-coordinator.d.ts.map +1 -1
  175. package/dist/rules/start-coordinator.js +6 -2
  176. package/dist/rules/start-coordinator.js.map +1 -1
  177. package/dist/rules/transition-service.d.ts +20 -2
  178. package/dist/rules/transition-service.d.ts.map +1 -1
  179. package/dist/rules/transition-service.js +43 -20
  180. package/dist/rules/transition-service.js.map +1 -1
  181. package/dist/rules/types.d.ts +71 -3
  182. package/dist/rules/types.d.ts.map +1 -1
  183. package/dist/rules/types.js +10 -2
  184. package/dist/rules/types.js.map +1 -1
  185. package/dist/rules/validation.d.ts.map +1 -1
  186. package/dist/rules/validation.js +5 -0
  187. package/dist/rules/validation.js.map +1 -1
  188. package/dist/sandbox/context-sandboxes.d.ts +70 -0
  189. package/dist/sandbox/context-sandboxes.d.ts.map +1 -0
  190. package/dist/sandbox/context-sandboxes.js +120 -0
  191. package/dist/sandbox/context-sandboxes.js.map +1 -0
  192. package/dist/sandbox/session-retirement.d.ts +11 -4
  193. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  194. package/dist/sandbox/session-retirement.js +39 -13
  195. package/dist/sandbox/session-retirement.js.map +1 -1
  196. package/dist/session/factory-session.d.ts +20 -5
  197. package/dist/session/factory-session.d.ts.map +1 -1
  198. package/dist/session/factory-session.js +20 -6
  199. package/dist/session/factory-session.js.map +1 -1
  200. package/dist/session/live-sessions.d.ts +1 -1
  201. package/dist/session/live-sessions.d.ts.map +1 -1
  202. package/dist/session/live-sessions.js +12 -2
  203. package/dist/session/live-sessions.js.map +1 -1
  204. package/dist/storage/domains/audit/actions.d.ts +1 -1
  205. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  206. package/dist/storage/domains/audit/actions.js +2 -1
  207. package/dist/storage/domains/audit/actions.js.map +1 -1
  208. package/dist/storage/domains/audit/actors.d.ts.map +1 -1
  209. package/dist/storage/domains/audit/actors.js +1 -1
  210. package/dist/storage/domains/audit/actors.js.map +1 -1
  211. package/dist/storage/domains/boards/base.d.ts +25 -5
  212. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  213. package/dist/storage/domains/boards/base.js +57 -20
  214. package/dist/storage/domains/boards/base.js.map +1 -1
  215. package/dist/storage/domains/intake/base.d.ts +1 -1
  216. package/dist/storage/domains/intake/base.js +2 -2
  217. package/dist/storage/domains/intake/base.js.map +1 -1
  218. package/dist/storage/domains/projects/base.d.ts +16 -2
  219. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  220. package/dist/storage/domains/projects/base.js +32 -5
  221. package/dist/storage/domains/projects/base.js.map +1 -1
  222. package/dist/storage/domains/work-items/base.d.ts +60 -8
  223. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  224. package/dist/storage/domains/work-items/base.js +180 -18
  225. package/dist/storage/domains/work-items/base.js.map +1 -1
  226. package/dist/storage/domains/work-items/cards.d.ts +1 -0
  227. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  228. package/dist/storage/domains/work-items/cards.js +32 -8
  229. package/dist/storage/domains/work-items/cards.js.map +1 -1
  230. package/dist/storage/domains/work-items/legacy-review.d.ts +19 -1
  231. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -1
  232. package/dist/storage/domains/work-items/legacy-review.js +62 -3
  233. package/dist/storage/domains/work-items/legacy-review.js.map +1 -1
  234. package/dist/storage/domains/work-items/work-item-schema.d.ts +1 -0
  235. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  236. package/dist/storage/domains/work-items/work-item-schema.js +46 -18
  237. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  238. package/dist/tools/annotations.d.ts.map +1 -1
  239. package/dist/tools/annotations.js +4 -0
  240. package/dist/tools/annotations.js.map +1 -1
  241. package/dist/tools/approval-tools.d.ts +20 -0
  242. package/dist/tools/approval-tools.d.ts.map +1 -1
  243. package/dist/tools/approval-tools.js +79 -30
  244. package/dist/tools/approval-tools.js.map +1 -1
  245. package/dist/tools/audit-events-tool.d.ts +29 -0
  246. package/dist/tools/audit-events-tool.d.ts.map +1 -0
  247. package/dist/tools/audit-events-tool.js +180 -0
  248. package/dist/tools/audit-events-tool.js.map +1 -0
  249. package/dist/tools/index.d.ts +2 -1
  250. package/dist/tools/index.d.ts.map +1 -1
  251. package/dist/tools/index.js +2 -0
  252. package/dist/tools/index.js.map +1 -1
  253. package/dist/tools/messaging-tools.d.ts.map +1 -1
  254. package/dist/tools/messaging-tools.js +1 -1
  255. package/dist/tools/messaging-tools.js.map +1 -1
  256. package/dist/tools/permissions.d.ts.map +1 -1
  257. package/dist/tools/permissions.js +1 -0
  258. package/dist/tools/permissions.js.map +1 -1
  259. package/dist/tools/read-tools.d.ts +0 -2
  260. package/dist/tools/read-tools.d.ts.map +1 -1
  261. package/dist/tools/read-tools.js +2 -7
  262. package/dist/tools/read-tools.js.map +1 -1
  263. package/dist/tools/reports.d.ts +3 -0
  264. package/dist/tools/reports.d.ts.map +1 -1
  265. package/dist/tools/reports.js +3 -3
  266. package/dist/tools/reports.js.map +1 -1
  267. package/dist/tools/run-watch.d.ts +14 -2
  268. package/dist/tools/run-watch.d.ts.map +1 -1
  269. package/dist/tools/run-watch.js +24 -4
  270. package/dist/tools/run-watch.js.map +1 -1
  271. package/dist/tools/session-tools.d.ts.map +1 -1
  272. package/dist/tools/session-tools.js +17 -6
  273. package/dist/tools/session-tools.js.map +1 -1
  274. package/dist/tools/sessions-state-processor.js +1 -1
  275. package/dist/tools/sessions-state-processor.js.map +1 -1
  276. package/dist/tools/side-sessions.d.ts.map +1 -1
  277. package/dist/tools/side-sessions.js +1 -1
  278. package/dist/tools/side-sessions.js.map +1 -1
  279. package/dist/tools/work-item-tools.d.ts.map +1 -1
  280. package/dist/tools/work-item-tools.js +12 -2
  281. package/dist/tools/work-item-tools.js.map +1 -1
  282. package/dist/work-item-branch.d.ts +1 -1
  283. package/dist/work-item-branch.d.ts.map +1 -1
  284. package/dist/work-item-branch.js +2 -0
  285. package/dist/work-item-branch.js.map +1 -1
  286. package/dist/work-items/board-check.d.ts +11 -0
  287. package/dist/work-items/board-check.d.ts.map +1 -0
  288. package/dist/work-items/board-check.js +20 -0
  289. package/dist/work-items/board-check.js.map +1 -0
  290. package/dist/work-items/board-filter-options.d.ts +5 -0
  291. package/dist/work-items/board-filter-options.d.ts.map +1 -0
  292. package/dist/work-items/board-filter-options.js +27 -0
  293. package/dist/work-items/board-filter-options.js.map +1 -0
  294. package/dist/work-items/board-phases.d.ts +28 -0
  295. package/dist/work-items/board-phases.d.ts.map +1 -0
  296. package/dist/work-items/board-phases.js +165 -0
  297. package/dist/work-items/board-phases.js.map +1 -0
  298. package/dist/work-items/card-facts.d.ts +24 -0
  299. package/dist/work-items/card-facts.d.ts.map +1 -0
  300. package/dist/work-items/card-facts.js +75 -0
  301. package/dist/work-items/card-facts.js.map +1 -0
  302. package/dist/work-items/card-labels.d.ts +5 -0
  303. package/dist/work-items/card-labels.d.ts.map +1 -0
  304. package/dist/work-items/card-labels.js +13 -0
  305. package/dist/work-items/card-labels.js.map +1 -0
  306. package/dist/work-items/card-number.d.ts +10 -0
  307. package/dist/work-items/card-number.d.ts.map +1 -0
  308. package/dist/work-items/card-number.js +15 -0
  309. package/dist/work-items/card-number.js.map +1 -0
  310. package/dist/work-items/card-people.d.ts +25 -0
  311. package/dist/work-items/card-people.d.ts.map +1 -0
  312. package/dist/work-items/card-people.js +100 -0
  313. package/dist/work-items/card-people.js.map +1 -0
  314. package/dist/work-items/card-search-text.d.ts +4 -0
  315. package/dist/work-items/card-search-text.d.ts.map +1 -0
  316. package/dist/work-items/card-search-text.js +15 -0
  317. package/dist/work-items/card-search-text.js.map +1 -0
  318. package/dist/work-items/card-source-filters.d.ts +23 -0
  319. package/dist/work-items/card-source-filters.d.ts.map +1 -0
  320. package/dist/work-items/card-source-filters.js +25 -0
  321. package/dist/work-items/card-source-filters.js.map +1 -0
  322. package/dist/work-items/create-work-item.d.ts +0 -6
  323. package/dist/work-items/create-work-item.d.ts.map +1 -1
  324. package/dist/work-items/create-work-item.js +2 -7
  325. package/dist/work-items/create-work-item.js.map +1 -1
  326. package/dist/work-items/list-related-cards.d.ts +4 -0
  327. package/dist/work-items/list-related-cards.d.ts.map +1 -0
  328. package/dist/work-items/list-related-cards.js +24 -0
  329. package/dist/work-items/list-related-cards.js.map +1 -0
  330. package/dist/work-items/related-cards.d.ts +21 -0
  331. package/dist/work-items/related-cards.d.ts.map +1 -0
  332. package/dist/work-items/related-cards.js +45 -0
  333. package/dist/work-items/related-cards.js.map +1 -0
  334. package/dist/work-items/search-words.d.ts +5 -0
  335. package/dist/work-items/search-words.d.ts.map +1 -0
  336. package/dist/work-items/search-words.js +12 -0
  337. package/dist/work-items/search-words.js.map +1 -0
  338. package/dist/work-items/split-migration.d.ts.map +1 -1
  339. package/dist/work-items/split-migration.js +6 -2
  340. package/dist/work-items/split-migration.js.map +1 -1
  341. package/dist/workspace.d.ts +0 -1
  342. package/dist/workspace.d.ts.map +1 -1
  343. package/dist/workspace.js +140 -78
  344. package/dist/workspace.js.map +1 -1
  345. package/factory-skills/factory-build/SKILL.md +1 -1
  346. package/factory-skills/factory-self-review/SKILL.md +1 -1
  347. package/factory-skills/factory-triage/SKILL.md +4 -4
  348. package/package.json +17 -16
@@ -3,23 +3,38 @@ import { probeSchedulesAvailable } from "./build-schedule.js";
3
3
  import { ENVIRONMENT_BUILD_WORKFLOW_ID, createEnvironmentBuildWorkflow } from "./build-workflow.js";
4
4
  import { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from "./build.js";
5
5
  // src/environment/build-runner.ts
6
+ /** Longest wait between `settings` runs that find another process holding the build-start lease. */
7
+ const SETTINGS_RETRY_MAX_MS = 3e4;
6
8
  var EnvironmentBuildRunner = class {
7
9
  workflow;
8
10
  #deps;
9
11
  #getMastra;
10
12
  #logger;
11
13
  #pending = /* @__PURE__ */ new Map();
14
+ #sleep;
15
+ /** Projects with a saved change that a run of theirs skipped; that run's end builds it. */
16
+ #awaitingRun = /* @__PURE__ */ new Set();
12
17
  #scheduleAvailable = false;
13
18
  constructor(deps, options) {
14
19
  const { getMastra, logger, ...workflowOptions } = options;
15
20
  this.#deps = deps;
16
21
  this.#getMastra = getMastra;
17
22
  this.#logger = logger;
23
+ this.#sleep = workflowOptions.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
18
24
  this.workflow = createEnvironmentBuildWorkflow(deps, {
19
25
  ...workflowOptions,
20
26
  onStart: (runId, outcome) => {
21
27
  this.#pending.get(runId)?.(outcome);
22
28
  this.#pending.delete(runId);
29
+ },
30
+ onSettled: (projectId, result) => {
31
+ if (result.outcome === "started") {
32
+ this.#awaitingRun.delete(projectId);
33
+ this.onEnvironmentSaved(projectId);
34
+ return;
35
+ }
36
+ if (result.outcome === "skipped" && (result.reason === "starting" || result.reason === "in_progress")) return;
37
+ if (this.#awaitingRun.delete(projectId)) this.onEnvironmentSaved(projectId);
23
38
  }
24
39
  });
25
40
  }
@@ -72,6 +87,33 @@ var EnvironmentBuildRunner = class {
72
87
  });
73
88
  };
74
89
  /**
90
+ * A saved change to a project's environment (settings, setup commands,
91
+ * repositories, Build variables) starts a `settings` run, which builds only
92
+ * when the template inputs changed. A run skipped because another one
93
+ * holds the build-start lease or its build is running (either may have read
94
+ * the environment before this save) stays pending until that run is over.
95
+ * A lease held by another process is retried, a second apart and doubling
96
+ * up to `SETTINGS_RETRY_MAX_MS`, until it is released or lapses. Fire and
97
+ * forget: the save never waits on it or fails because of it.
98
+ */
99
+ onEnvironmentSaved = (projectId) => {
100
+ (async () => {
101
+ for (let delay = 1e3;; delay = Math.min(delay * 2, SETTINGS_RETRY_MAX_MS)) {
102
+ const outcome = await this.start(projectId, "settings");
103
+ if (outcome.outcome !== "skipped" || outcome.reason !== "starting" && outcome.reason !== "in_progress") return;
104
+ this.#awaitingRun.add(projectId);
105
+ if (outcome.reason === "in_progress") return;
106
+ await this.#sleep(delay);
107
+ if (!this.#awaitingRun.has(projectId)) return;
108
+ }
109
+ })().catch((error) => {
110
+ this.#logger?.info("environment build settings hand-off failed", {
111
+ factoryProjectId: projectId,
112
+ reason: errorReason(error)
113
+ });
114
+ });
115
+ };
116
+ /**
75
117
  * Start a run and resolve with the first step's answer; the poll step keeps
76
118
  * running in the background. Resolves `unavailable` before the host booted
77
119
  * or when the host never registered the workflow, and `failed` when the run
@@ -1 +1 @@
1
- {"version":3,"file":"build-runner.js","names":[],"sources":["../../src/environment/build-runner.ts"],"sourcesContent":["/**\n * Starts `factory-environment-build` runs on the booted `Mastra`. Every\n * trigger goes through a workflow run so the start decision and the poll are\n * recorded the same way whether a route, the scheduler or a webhook asked.\n */\n\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\nimport type { RepositoryPushEvent } from '../integrations/base.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport { probeSchedulesAvailable } from './build-schedule.js';\nimport type { ScheduleService } from './build-schedule.js';\nimport { createEnvironmentBuildWorkflow, ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\nimport type { EnvironmentBuildWorkflowOptions } from './build-workflow.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome, EnvironmentBuildTrigger } from './build.js';\nimport { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from './build.js';\n\nexport type StartEnvironmentBuild = (\n projectId: string,\n trigger: EnvironmentBuildTrigger,\n) => Promise<EnvironmentBuildOutcome>;\n\nexport interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart'> {\n /** The booted instance; `undefined` until the host finished `finalize()`. */\n getMastra: () => Mastra | undefined;\n logger?: { info: (msg: string, meta?: Record<string, unknown>) => void };\n}\n\n/** What a read of a build's status or history hands the provider. */\nexport interface EnvironmentBuildReadContext {\n ctx: FactorySandboxContext;\n settings: Record<string, unknown>;\n}\n\nexport class EnvironmentBuildRunner {\n readonly workflow;\n readonly #deps: EnvironmentBuildDeps;\n readonly #getMastra: () => Mastra | undefined;\n readonly #logger: EnvironmentBuildRunnerOptions['logger'];\n readonly #pending = new Map<string, (outcome: EnvironmentBuildOutcome) => void>();\n #scheduleAvailable = false;\n\n constructor(deps: EnvironmentBuildDeps, options: EnvironmentBuildRunnerOptions) {\n const { getMastra, logger, ...workflowOptions } = options;\n this.#deps = deps;\n this.#getMastra = getMastra;\n this.#logger = logger;\n this.workflow = createEnvironmentBuildWorkflow(deps, {\n ...workflowOptions,\n onStart: (runId, outcome) => {\n this.#pending.get(runId)?.(outcome);\n this.#pending.delete(runId);\n },\n });\n }\n\n /** The schedule service of the booted host, `undefined` before boot. */\n schedules(): ScheduleService | undefined {\n return this.#getMastra()?.schedules;\n }\n\n /** Whether the host's storage implements schedules; false until `probeSchedules()` ran. */\n get scheduleAvailable(): boolean {\n return this.#scheduleAvailable;\n }\n\n /** Probe once after the host booted; a storage without the domain disables the cron trigger. */\n async probeSchedules(): Promise<boolean> {\n const schedules = this.schedules();\n this.#scheduleAvailable = schedules ? await probeSchedulesAvailable(schedules) : false;\n return this.#scheduleAvailable;\n }\n\n /**\n * The context a status or history read hands the provider. Heads come from\n * the stored last attempt (the build being read was pinned to them), else\n * the active template, so a read never calls GitHub; before the first build\n * they are resolved live once.\n */\n async readContext(projectId: string): Promise<EnvironmentBuildReadContext | undefined> {\n const sourceControl = this.#deps.sourceControl;\n if (!sourceControl) return undefined;\n const project = await this.#deps.projects.getById({ id: projectId });\n if (!project) return undefined;\n const environment = await resolveProjectEnvironment(sourceControl.storage, project);\n const heads =\n project.lastBuildHeads ??\n project.activeTemplateHeads ??\n (await resolveEnvironmentHeads(sourceControl, project, environment));\n return {\n ctx: (\n await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n sourceControl.versionControl,\n this.#deps.sandboxEnvs,\n )\n ).ctx,\n settings: environment.settings,\n };\n }\n\n /**\n * A push to an environment repository's default branch starts a `push` run\n * when the project opted in; the run's debounce claim decides whether it\n * builds. Fire and forget: the webhook never waits on it.\n */\n readonly onRepositoryPush = (event: RepositoryPushEvent): void => {\n if (!event.projectRepository.inEnvironment) return;\n const branch = event.defaultBranch;\n if (event.ref !== `refs/heads/${branch}`) return;\n void this.#deps.projects\n .getById({ id: event.factoryProjectId })\n .then(project => (project?.buildOnPushEnabled ? this.start(project.id, 'push') : undefined))\n .catch((error: unknown) => {\n this.#logger?.info('environment build push hand-off failed', {\n factoryProjectId: event.factoryProjectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * Start a run and resolve with the first step's answer; the poll step keeps\n * running in the background. Resolves `unavailable` before the host booted\n * or when the host never registered the workflow, and `failed` when the run\n * could not be created; a caller that already saved its own change must not\n * fail on the build it merely requested.\n */\n readonly start: StartEnvironmentBuild = async (projectId, trigger) => {\n const mastra = this.#getMastra();\n if (!mastra) return { outcome: 'unavailable', reason: 'not_ready' };\n let run: Awaited<ReturnType<typeof this.workflow.createRun>>;\n try {\n run = await mastra.getWorkflow(ENVIRONMENT_BUILD_WORKFLOW_ID).createRun();\n } catch (error) {\n const reason = errorReason(error);\n this.#logger?.info('environment build run could not be created', { factoryProjectId: projectId, reason });\n return mastra.listWorkflows()[ENVIRONMENT_BUILD_WORKFLOW_ID]\n ? { outcome: 'failed', reason }\n : { outcome: 'unavailable', reason: 'no_workflow' };\n }\n const outcome = new Promise<EnvironmentBuildOutcome>(resolve => this.#pending.set(run.runId, resolve));\n run\n .start({ inputData: { projectId, trigger } })\n .then(result => {\n if (result.status !== 'success') {\n this.#logger?.info('environment build run did not succeed', {\n factoryProjectId: projectId,\n runId: run.runId,\n });\n }\n })\n .catch((error: unknown) => {\n this.#logger?.info('environment build run threw', {\n factoryProjectId: projectId,\n runId: run.runId,\n reason: errorReason(error),\n });\n })\n .finally(() => {\n // A run that failed before its first step answered must not hang the caller.\n this.#pending.get(run.runId)?.({ outcome: 'failed', reason: 'The build run ended before it started a build.' });\n this.#pending.delete(run.runId);\n });\n return outcome;\n };\n}\n"],"mappings":";;;;;AAkCA,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA;CACA;CACA,2BAAoB,IAAI,IAAwD;CAChF,qBAAqB;CAErB,YAAY,MAA4B,SAAwC;EAC9E,MAAM,EAAE,WAAW,QAAQ,GAAG,oBAAoB;EAClD,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,WAAW,+BAA+B,MAAM;GACnD,GAAG;GACH,UAAU,OAAO,YAAY;IAC3B,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,OAAO;IAClC,KAAK,SAAS,OAAO,KAAK;GAC5B;EACF,CAAC;CACH;;CAGA,YAAyC;EACvC,OAAO,KAAK,WAAW,CAAC,EAAE;CAC5B;;CAGA,IAAI,oBAA6B;EAC/B,OAAO,KAAK;CACd;;CAGA,MAAM,iBAAmC;EACvC,MAAM,YAAY,KA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S,KAAK,8CAA8C;IAAE,kBAAkB;IAAW;GAAO,CAAC;GACxG,OAAO,OAAO,cAAc,CAAC,CAAA,+BACzB;IAAE,SAAS;IAAU;GAAO,IAC5B;IAAE,SAAS;IAAe,QAAQ;GAAc;EACtD;EACA,MAAM,UAAU,IAAI,SAAiC,YAAW,KAAK,SAAS,IAAI,IAAI,OAAO,OAAO,CAAC;EACrG,IACG,MAAM,EAAE,WAAW;GAAE;GAAW;EAAQ,EAAE,CAAC,CAAC,CAC5C,MAAK,WAAU;GACd,IAAI,OAAO,WAAW,WACpB,KAAK,SAAS,KAAK,yCAAyC;IAC1D,kBAAkB;IAClB,OAAO,IAAI;GACb,CAAC;EAEL,CAAC,CAAC,CACD,OAAO,UAAmB;GACzB,KAAK,SAAS,KAAK,+BAA+B;IAChD,kBAAkB;IAClB,OAAO,IAAI;IACX,QAAQ,YAAY,KAAK;GAC3B,CAAC;EACH,CAAC,CAAC,CACD,cAAc;GAEb,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC,GAAG;IAAE,SAAS;IAAU,QAAQ;GAAiD,CAAC;GAC9G,KAAK,SAAS,OAAO,IAAI,KAAK;EAChC,CAAC;EACH,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"build-runner.js","names":[],"sources":["../../src/environment/build-runner.ts"],"sourcesContent":["/**\n * Starts `factory-environment-build` runs on the booted `Mastra`. Every\n * trigger goes through a workflow run so the start decision and the poll are\n * recorded the same way whether a route, the scheduler or a webhook asked.\n */\n\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { FactorySandboxContext } from '@mastra/core/workspace';\nimport type { RepositoryPushEvent } from '../integrations/base.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport { probeSchedulesAvailable } from './build-schedule.js';\nimport type { ScheduleService } from './build-schedule.js';\nimport { createEnvironmentBuildWorkflow, ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\nimport type { EnvironmentBuildWorkflowOptions } from './build-workflow.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome, EnvironmentBuildTrigger } from './build.js';\nimport { environmentBuildContextWithEnv, errorReason, resolveEnvironmentHeads } from './build.js';\n\n/** Longest wait between `settings` runs that find another process holding the build-start lease. */\nconst SETTINGS_RETRY_MAX_MS = 30_000;\n\nexport type StartEnvironmentBuild = (\n projectId: string,\n trigger: EnvironmentBuildTrigger,\n) => Promise<EnvironmentBuildOutcome>;\n\nexport interface EnvironmentBuildRunnerOptions extends Omit<EnvironmentBuildWorkflowOptions, 'onStart' | 'onSettled'> {\n /** The booted instance; `undefined` until the host finished `finalize()`. */\n getMastra: () => Mastra | undefined;\n logger?: { info: (msg: string, meta?: Record<string, unknown>) => void };\n}\n\n/** What a read of a build's status or history hands the provider. */\nexport interface EnvironmentBuildReadContext {\n ctx: FactorySandboxContext;\n settings: Record<string, unknown>;\n}\n\nexport class EnvironmentBuildRunner {\n readonly workflow;\n readonly #deps: EnvironmentBuildDeps;\n readonly #getMastra: () => Mastra | undefined;\n readonly #logger: EnvironmentBuildRunnerOptions['logger'];\n readonly #pending = new Map<string, (outcome: EnvironmentBuildOutcome) => void>();\n readonly #sleep: (ms: number) => Promise<void>;\n /** Projects with a saved change that a run of theirs skipped; that run's end builds it. */\n readonly #awaitingRun = new Set<string>();\n #scheduleAvailable = false;\n\n constructor(deps: EnvironmentBuildDeps, options: EnvironmentBuildRunnerOptions) {\n const { getMastra, logger, ...workflowOptions } = options;\n this.#deps = deps;\n this.#getMastra = getMastra;\n this.#logger = logger;\n this.#sleep = workflowOptions.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)));\n this.workflow = createEnvironmentBuildWorkflow(deps, {\n ...workflowOptions,\n onStart: (runId, outcome) => {\n this.#pending.get(runId)?.(outcome);\n this.#pending.delete(runId);\n },\n // Fires for every run of the registered workflow, scheduled ones included.\n // A started build always checks once more, since a save (here or in\n // another process) may have been skipped against it; a run that held the\n // lease without building hands back a save skipped meanwhile. A run that\n // was itself skipped against the lease or a running build hands back\n // nothing: the run it deferred to is still going.\n onSettled: (projectId, result) => {\n if (result.outcome === 'started') {\n this.#awaitingRun.delete(projectId);\n this.onEnvironmentSaved(projectId);\n return;\n }\n if (result.outcome === 'skipped' && (result.reason === 'starting' || result.reason === 'in_progress')) return;\n if (this.#awaitingRun.delete(projectId)) this.onEnvironmentSaved(projectId);\n },\n });\n }\n\n /** The schedule service of the booted host, `undefined` before boot. */\n schedules(): ScheduleService | undefined {\n return this.#getMastra()?.schedules;\n }\n\n /** Whether the host's storage implements schedules; false until `probeSchedules()` ran. */\n get scheduleAvailable(): boolean {\n return this.#scheduleAvailable;\n }\n\n /** Probe once after the host booted; a storage without the domain disables the cron trigger. */\n async probeSchedules(): Promise<boolean> {\n const schedules = this.schedules();\n this.#scheduleAvailable = schedules ? await probeSchedulesAvailable(schedules) : false;\n return this.#scheduleAvailable;\n }\n\n /**\n * The context a status or history read hands the provider. Heads come from\n * the stored last attempt (the build being read was pinned to them), else\n * the active template, so a read never calls GitHub; before the first build\n * they are resolved live once.\n */\n async readContext(projectId: string): Promise<EnvironmentBuildReadContext | undefined> {\n const sourceControl = this.#deps.sourceControl;\n if (!sourceControl) return undefined;\n const project = await this.#deps.projects.getById({ id: projectId });\n if (!project) return undefined;\n const environment = await resolveProjectEnvironment(sourceControl.storage, project);\n const heads =\n project.lastBuildHeads ??\n project.activeTemplateHeads ??\n (await resolveEnvironmentHeads(sourceControl, project, environment));\n return {\n ctx: (\n await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n sourceControl.versionControl,\n this.#deps.sandboxEnvs,\n )\n ).ctx,\n settings: environment.settings,\n };\n }\n\n /**\n * A push to an environment repository's default branch starts a `push` run\n * when the project opted in; the run's debounce claim decides whether it\n * builds. Fire and forget: the webhook never waits on it.\n */\n readonly onRepositoryPush = (event: RepositoryPushEvent): void => {\n if (!event.projectRepository.inEnvironment) return;\n const branch = event.defaultBranch;\n if (event.ref !== `refs/heads/${branch}`) return;\n void this.#deps.projects\n .getById({ id: event.factoryProjectId })\n .then(project => (project?.buildOnPushEnabled ? this.start(project.id, 'push') : undefined))\n .catch((error: unknown) => {\n this.#logger?.info('environment build push hand-off failed', {\n factoryProjectId: event.factoryProjectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * A saved change to a project's environment (settings, setup commands,\n * repositories, Build variables) starts a `settings` run, which builds only\n * when the template inputs changed. A run skipped because another one\n * holds the build-start lease or its build is running (either may have read\n * the environment before this save) stays pending until that run is over.\n * A lease held by another process is retried, a second apart and doubling\n * up to `SETTINGS_RETRY_MAX_MS`, until it is released or lapses. Fire and\n * forget: the save never waits on it or fails because of it.\n */\n readonly onEnvironmentSaved = (projectId: string): void => {\n void (async () => {\n for (let delay = 1000; ; delay = Math.min(delay * 2, SETTINGS_RETRY_MAX_MS)) {\n const outcome = await this.start(projectId, 'settings');\n if (outcome.outcome !== 'skipped' || (outcome.reason !== 'starting' && outcome.reason !== 'in_progress')) {\n return;\n }\n this.#awaitingRun.add(projectId);\n if (outcome.reason === 'in_progress') return;\n await this.#sleep(delay);\n // A run of this process ended meanwhile and handed the save back.\n if (!this.#awaitingRun.has(projectId)) return;\n }\n })().catch((error: unknown) => {\n this.#logger?.info('environment build settings hand-off failed', {\n factoryProjectId: projectId,\n reason: errorReason(error),\n });\n });\n };\n\n /**\n * Start a run and resolve with the first step's answer; the poll step keeps\n * running in the background. Resolves `unavailable` before the host booted\n * or when the host never registered the workflow, and `failed` when the run\n * could not be created; a caller that already saved its own change must not\n * fail on the build it merely requested.\n */\n readonly start: StartEnvironmentBuild = async (projectId, trigger) => {\n const mastra = this.#getMastra();\n if (!mastra) return { outcome: 'unavailable', reason: 'not_ready' };\n let run: Awaited<ReturnType<typeof this.workflow.createRun>>;\n try {\n run = await mastra.getWorkflow(ENVIRONMENT_BUILD_WORKFLOW_ID).createRun();\n } catch (error) {\n const reason = errorReason(error);\n this.#logger?.info('environment build run could not be created', { factoryProjectId: projectId, reason });\n return mastra.listWorkflows()[ENVIRONMENT_BUILD_WORKFLOW_ID]\n ? { outcome: 'failed', reason }\n : { outcome: 'unavailable', reason: 'no_workflow' };\n }\n const outcome = new Promise<EnvironmentBuildOutcome>(resolve => this.#pending.set(run.runId, resolve));\n run\n .start({ inputData: { projectId, trigger } })\n .then(result => {\n if (result.status !== 'success') {\n this.#logger?.info('environment build run did not succeed', {\n factoryProjectId: projectId,\n runId: run.runId,\n });\n }\n })\n .catch((error: unknown) => {\n this.#logger?.info('environment build run threw', {\n factoryProjectId: projectId,\n runId: run.runId,\n reason: errorReason(error),\n });\n })\n .finally(() => {\n // A run that failed before its first step answered must not hang the caller.\n this.#pending.get(run.runId)?.({ outcome: 'failed', reason: 'The build run ended before it started a build.' });\n this.#pending.delete(run.runId);\n });\n return outcome;\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAM,wBAAwB;AAmB9B,IAAa,yBAAb,MAAoC;CAClC;CACA;CACA;CACA;CACA,2BAAoB,IAAI,IAAwD;CAChF;;CAEA,+BAAwB,IAAI,IAAY;CACxC,qBAAqB;CAErB,YAAY,MAA4B,SAAwC;EAC9E,MAAM,EAAE,WAAW,QAAQ,GAAG,oBAAoB;EAClD,KAAK,QAAQ;EACb,KAAK,aAAa;EAClB,KAAK,UAAU;EACf,KAAK,SAAS,gBAAgB,WAAU,OAAM,IAAI,SAAc,YAAW,WAAW,SAAS,EAAE,CAAC;EAClG,KAAK,WAAW,+BAA+B,MAAM;GACnD,GAAG;GACH,UAAU,OAAO,YAAY;IAC3B,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,OAAO;IAClC,KAAK,SAAS,OAAO,KAAK;GAC5B;GAOA,YAAY,WAAW,WAAW;IAChC,IAAI,OAAO,YAAY,WAAW;KAChC,KAAK,aAAa,OAAO,SAAS;KAClC,KAAK,mBAAmB,SAAS;KACjC;IACF;IACA,IAAI,OAAO,YAAY,cAAc,OAAO,WAAW,cAAc,OAAO,WAAW,gBAAgB;IACvG,IAAI,KAAK,aAAa,OAAO,SAAS,GAAG,KA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AAkB;IAClB,OAAO,IAAI;IACX,QAAQ,YAAY,KAAK;GAC3B,CAAC;EACH,CAAC,CAAC,CACD,cAAc;GAEb,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC,GAAG;IAAE,SAAS;IAAU,QAAQ;GAAiD,CAAC;GAC9G,KAAK,SAAS,OAAO,IAAI,KAAK;EAChC,CAAC;EACH,OAAO;CACT;AACF"}
@@ -47,7 +47,7 @@ function toView(schedule) {
47
47
  };
48
48
  return {
49
49
  enabled: schedule.status === "active",
50
- cron: schedule.cron,
50
+ cron: schedule.cron ?? null,
51
51
  timezone: schedule.timezone ?? null
52
52
  };
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-schedule.js","names":[],"sources":["../../src/environment/build-schedule.ts"],"sourcesContent":["/**\n * The per-project cron that fires the `factory-environment-build` workflow,\n * kept in core `Schedules` (one row per project) rather than a factory\n * column: the scheduler owns firing, claims and the run trigger log, factory\n * only creates, pauses, resumes and reads the row.\n */\n\nimport type { AnySchedule, Schedules, WorkflowSchedule } from '@mastra/core/schedules';\nimport { validateCron } from '@mastra/core/workflows';\nimport { ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\n\nexport const SCHEDULES_UNAVAILABLE_ERROR_ID = 'SCHEDULES_NO_SCHEDULES_STORAGE';\n\n/**\n * The project's schedule id in its stored form. Core normalizes a created\n * id to `schedule_<slug>` and resolves a bare id to `agent_<slug>` on reads,\n * so factory always addresses the row by the normalized id (a project id is\n * a lower-case uuid, which slugifies to itself).\n */\nexport function scheduleIdFor(projectId: string): string {\n return `schedule_factory-environment-build-${projectId}`;\n}\n\nexport interface EnvironmentBuildSchedule {\n enabled: boolean;\n cron: string | null;\n timezone: string | null;\n}\n\nexport type ScheduleService = Pick<Schedules, 'create' | 'get' | 'list' | 'update' | 'pause' | 'resume' | 'delete'>;\n\nfunction isSchedulesUnavailable(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { id?: unknown }).id === SCHEDULES_UNAVAILABLE_ERROR_ID\n );\n}\n\n/**\n * Whether the host's storage implements the schedules domain. `mastra.schedules`\n * never throws on access; the missing store surfaces on the first call.\n */\nexport async function probeSchedulesAvailable(schedules: ScheduleService): Promise<boolean> {\n try {\n await schedules.list({ workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID });\n return true;\n } catch (error) {\n if (isSchedulesUnavailable(error)) return false;\n throw error;\n }\n}\n\n/** `undefined` when the cron parses; otherwise the validator's message. */\nexport function invalidCronMessage(cron: string, timezone?: string): string | undefined {\n try {\n validateCron(cron, timezone);\n return undefined;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n }\n}\n\nfunction isWorkflowSchedule(schedule: AnySchedule | null): schedule is WorkflowSchedule {\n return schedule !== null && schedule.agentId === undefined;\n}\n\nfunction toView(schedule: WorkflowSchedule | null): EnvironmentBuildSchedule {\n if (!schedule) return { enabled: false, cron: null, timezone: null };\n return { enabled: schedule.status === 'active', cron: schedule.cron, timezone: schedule.timezone ?? null };\n}\n\n/** The project's build schedule as the environment reports it. */\nexport async function readSchedule(schedules: ScheduleService, projectId: string): Promise<EnvironmentBuildSchedule> {\n const schedule = await schedules.get(scheduleIdFor(projectId));\n return toView(isWorkflowSchedule(schedule) ? schedule : null);\n}\n\n/**\n * Create, update, pause or resume the project's schedule so it matches\n * `input`. Disabling a project that never had a schedule creates nothing.\n */\nexport async function ensureSchedule(\n schedules: ScheduleService,\n projectId: string,\n input: { enabled: boolean; cron: string; timezone?: string },\n): Promise<EnvironmentBuildSchedule> {\n const id = scheduleIdFor(projectId);\n const existing = await schedules.get(id);\n const current = isWorkflowSchedule(existing) ? existing : null;\n if (!current) {\n if (!input.enabled) return toView(null);\n const created = await schedules.create({\n id,\n workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID,\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n inputData: { projectId, trigger: 'schedule' },\n resourceId: projectId,\n });\n return toView(created);\n }\n const timingChanged = current.cron !== input.cron || (current.timezone ?? undefined) !== input.timezone;\n let next: AnySchedule = current;\n if (timingChanged) {\n next = await schedules.update(current.id, {\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n });\n }\n if (input.enabled && next.status === 'paused') next = await schedules.resume(current.id);\n if (!input.enabled && next.status === 'active') next = await schedules.pause(current.id);\n return toView(isWorkflowSchedule(next) ? next : null);\n}\n"],"mappings":";;;AAWA,MAAa,iCAAiC;;;;;;;AAQ9C,SAAgB,cAAc,WAA2B;CACvD,OAAO,sCAAsC;AAC/C;AAUA,SAAS,uBAAuB,OAAyB;CACvD,OACE,OAAO,UAAU,YAAY,UAAU,QAAS,MAA2B,OAAA;AAE/E;;;;;AAMA,eAAsB,wBAAwB,WAA8C;CAC1F,IAAI;EACF,MAAM,UAAU,KAAK,EAAE,YAAY,8BAA8B,CAAC;EAClE,OAAO;CACT,SAAS,OAAO;EACd,IAAI,uBAAuB,KAAK,GAAG,OAAO;EAC1C,MAAM;CACR;AACF;;AAGA,SAAgB,mBAAmB,MAAc,UAAuC;CACtF,IAAI;EACF,aAAa,MAAM,QAAQ;EAC3B;CACF,SAAS,OAAO;EACd,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC9D;AACF;AAEA,SAAS,mBAAmB,UAA4D;CACtF,OAAO,aAAa,QAAQ,SAAS,YAAY,KAAA;AACnD;AAEA,SAAS,OAAO,UAA6D;CAC3E,IAAI,CAAC,UAAU,OAAO;EAAE,SAAS;EAAO,MAAM;EAAM,UAAU;CAAK;CACnE,OAAO;EAAE,SAAS,SAAS,WAAW;EAAU,MAAM,SAAS;EAAM,UAAU,SAAS,YAAY;CAAK;AAC3G;;AAGA,eAAsB,aAAa,WAA4B,WAAsD;CACnH,MAAM,WAAW,MAAM,UAAU,IAAI,cAAc,SAAS,CAAC;CAC7D,OAAO,OAAO,mBAAmB,QAAQ,IAAI,WAAW,IAAI;AAC9D;;;;;AAMA,eAAsB,eACpB,WACA,WACA,OACmC;CACnC,MAAM,KAAK,cAAc,SAAS;CAClC,MAAM,WAAW,MAAM,UAAU,IAAI,EAAE;CACvC,MAAM,UAAU,mBAAmB,QAAQ,IAAI,WAAW;CAC1D,IAAI,CAAC,SAAS;EACZ,IAAI,CAAC,MAAM,SAAS,OAAO,OAAO,IAAI;EAStC,OAAO,OAAO,MARQ,UAAU,OAAO;GACrC;GACA,YAAY;GACZ,MAAM,MAAM;GACZ,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;GACrD,WAAW;IAAE;IAAW,SAAS;GAAW;GAC5C,YAAY;EACd,CAAC,CACoB;CACvB;CACA,MAAM,gBAAgB,QAAQ,SAAS,MAAM,SAAS,QAAQ,YAAY,KAAA,OAAe,MAAM;CAC/F,IAAI,OAAoB;CACxB,IAAI,eACF,OAAO,MAAM,UAAU,OAAO,QAAQ,IAAI;EACxC,MAAM,MAAM;EACZ,GAAI,MAAM,WAAW,EAAE,UAAU,MAAM,SAAS,IAAI,CAAC;CACvD,CAAC;CAEH,IAAI,MAAM,WAAW,KAAK,WAAW,UAAU,OAAO,MAAM,UAAU,OAAO,QAAQ,EAAE;CACvF,IAAI,CAAC,MAAM,WAAW,KAAK,WAAW,UAAU,OAAO,MAAM,UAAU,MAAM,QAAQ,EAAE;CACvF,OAAO,OAAO,mBAAmB,IAAI,IAAI,OAAO,IAAI;AACtD"}
1
+ {"version":3,"file":"build-schedule.js","names":[],"sources":["../../src/environment/build-schedule.ts"],"sourcesContent":["/**\n * The per-project cron that fires the `factory-environment-build` workflow,\n * kept in core `Schedules` (one row per project) rather than a factory\n * column: the scheduler owns firing, claims and the run trigger log, factory\n * only creates, pauses, resumes and reads the row.\n */\n\nimport type { AnySchedule, Schedules, WorkflowSchedule } from '@mastra/core/schedules';\nimport { validateCron } from '@mastra/core/workflows';\nimport { ENVIRONMENT_BUILD_WORKFLOW_ID } from './build-workflow.js';\n\nexport const SCHEDULES_UNAVAILABLE_ERROR_ID = 'SCHEDULES_NO_SCHEDULES_STORAGE';\n\n/**\n * The project's schedule id in its stored form. Core normalizes a created\n * id to `schedule_<slug>` and resolves a bare id to `agent_<slug>` on reads,\n * so factory always addresses the row by the normalized id (a project id is\n * a lower-case uuid, which slugifies to itself).\n */\nexport function scheduleIdFor(projectId: string): string {\n return `schedule_factory-environment-build-${projectId}`;\n}\n\nexport interface EnvironmentBuildSchedule {\n enabled: boolean;\n cron: string | null;\n timezone: string | null;\n}\n\nexport type ScheduleService = Pick<Schedules, 'create' | 'get' | 'list' | 'update' | 'pause' | 'resume' | 'delete'>;\n\nfunction isSchedulesUnavailable(error: unknown): boolean {\n return (\n typeof error === 'object' && error !== null && (error as { id?: unknown }).id === SCHEDULES_UNAVAILABLE_ERROR_ID\n );\n}\n\n/**\n * Whether the host's storage implements the schedules domain. `mastra.schedules`\n * never throws on access; the missing store surfaces on the first call.\n */\nexport async function probeSchedulesAvailable(schedules: ScheduleService): Promise<boolean> {\n try {\n await schedules.list({ workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID });\n return true;\n } catch (error) {\n if (isSchedulesUnavailable(error)) return false;\n throw error;\n }\n}\n\n/** `undefined` when the cron parses; otherwise the validator's message. */\nexport function invalidCronMessage(cron: string, timezone?: string): string | undefined {\n try {\n validateCron(cron, timezone);\n return undefined;\n } catch (error) {\n return error instanceof Error ? error.message : String(error);\n }\n}\n\nfunction isWorkflowSchedule(schedule: AnySchedule | null): schedule is WorkflowSchedule {\n return schedule !== null && schedule.agentId === undefined;\n}\n\nfunction toView(schedule: WorkflowSchedule | null): EnvironmentBuildSchedule {\n if (!schedule) return { enabled: false, cron: null, timezone: null };\n return { enabled: schedule.status === 'active', cron: schedule.cron ?? null, timezone: schedule.timezone ?? null };\n}\n\n/** The project's build schedule as the environment reports it. */\nexport async function readSchedule(schedules: ScheduleService, projectId: string): Promise<EnvironmentBuildSchedule> {\n const schedule = await schedules.get(scheduleIdFor(projectId));\n return toView(isWorkflowSchedule(schedule) ? schedule : null);\n}\n\n/**\n * Create, update, pause or resume the project's schedule so it matches\n * `input`. Disabling a project that never had a schedule creates nothing.\n */\nexport async function ensureSchedule(\n schedules: ScheduleService,\n projectId: string,\n input: { enabled: boolean; cron: string; timezone?: string },\n): Promise<EnvironmentBuildSchedule> {\n const id = scheduleIdFor(projectId);\n const existing = await schedules.get(id);\n const current = isWorkflowSchedule(existing) ? existing : null;\n if (!current) {\n if (!input.enabled) return toView(null);\n const created = await schedules.create({\n id,\n workflowId: ENVIRONMENT_BUILD_WORKFLOW_ID,\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n inputData: { projectId, trigger: 'schedule' },\n resourceId: projectId,\n });\n return toView(created);\n }\n const timingChanged = current.cron !== input.cron || (current.timezone ?? undefined) !== input.timezone;\n let next: AnySchedule = current;\n if (timingChanged) {\n next = await schedules.update(current.id, {\n cron: input.cron,\n ...(input.timezone ? { timezone: input.timezone } : {}),\n });\n }\n if (input.enabled && next.status === 'paused') next = await schedules.resume(current.id);\n if (!input.enabled && next.status === 'active') next = await schedules.pause(current.id);\n return toView(isWorkflowSchedule(next) ? next : null);\n}\n"],"mappings":";;;AAWA,MAAa,iCAAiC;;;;;;;AAQ9C,SAAgB,cAAc,WAA2B;CACvD,OAAO,sCAAsC;AAC/C;AAUA,SAAS,uBAAuB,OAAyB;CACvD,OACE,OAAO,UAAU,YAAY,UAAU,QAAS,MAA2B,OAAA;AAE/E;;;;;AAMA,eAAsB,wBAAwB,WAA8C;CAC1F,IAAI;EACF,MAAM,UAAU,KAAK,EAAE,YAAY,8BAA8B,CAAC;EAClE,OAAO;CACT,SAAS,OAAO;EACd,IAAI,uBAAuB,KAAK,GAAG,OAAO;EAC1C,MAAM;CACR;AACF;;AAGA,SAAgB,mBAAmB,MAAc,UAAuC;CACtF,IAAI;EACF,aAAa,MAAM,QAAQ;EAC3B;CACF,SAAS,OAAO;EACd,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC9D;AACF;AAEA,SAAS,mBAA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QAAQ,EAAE;CACvF,OAAO,OAAO,mBAAmB,IAAI,IAAI,OAAO,IAAI;AACtD"}
@@ -3,20 +3,20 @@
3
3
  * build (`runEnvironmentBuild`), step two polls the provider until the build
4
4
  * settles and pins the active template on the project row. Registered by
5
5
  * `MastraFactory.prepare()` only when the sandbox has `builds`, and driven by
6
- * the Build now route, the per-project cron schedule and the GitHub push
7
- * hand-off. Saving settings never starts it.
6
+ * the Build now route, the per-project cron schedule, the GitHub push
7
+ * hand-off and saved template inputs.
8
8
  */
9
9
  import { z } from 'zod';
10
10
  import type { EnvironmentBuildDeps, EnvironmentBuildOutcome } from './build.js';
11
11
  export declare const ENVIRONMENT_BUILD_WORKFLOW_ID = "factory-environment-build";
12
12
  export declare const DEFAULT_BUILD_POLL_MS = 15000;
13
- export declare const MAX_BUILD_WAIT_MS: number;
14
13
  export declare const environmentBuildInputSchema: z.ZodObject<{
15
14
  projectId: z.ZodString;
16
15
  trigger: z.ZodEnum<{
17
16
  manual: "manual";
18
17
  push: "push";
19
18
  schedule: "schedule";
19
+ settings: "settings";
20
20
  }>;
21
21
  }, z.core.$strip>;
22
22
  export declare const environmentBuildOutputSchema: z.ZodObject<{
@@ -42,10 +42,12 @@ export interface EnvironmentBuildWorkflowOptions {
42
42
  maxWaitMs?: number;
43
43
  /** Called with the first step's answer so a caller can return it without waiting for the poll. */
44
44
  onStart?: (runId: string, outcome: EnvironmentBuildOutcome) => void;
45
+ /** Called once a run is over, whoever started it (a route, the scheduler or a hand-off). */
46
+ onSettled?: (projectId: string, result: EnvironmentBuildWorkflowResult) => void;
45
47
  }
46
48
  export declare function createEnvironmentBuildWorkflow(deps: EnvironmentBuildDeps, options?: EnvironmentBuildWorkflowOptions): import("@mastra/core/workflows").Workflow<import("@mastra/core/workflows").DefaultEngineType, import("@mastra/core/workflows").Step<string, unknown, unknown, unknown, unknown, unknown, any, unknown>[], "factory-environment-build", unknown, {
47
49
  projectId: string;
48
- trigger: "manual" | "push" | "schedule";
50
+ trigger: "manual" | "push" | "schedule" | "settings";
49
51
  }, {
50
52
  outcome: "failed" | "skipped" | "started" | "unavailable";
51
53
  buildId?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"build-workflow.d.ts","sourceRoot":"","sources":["../../src/environment/build-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AACzE,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,iBAAiB,QAAc,CAAC;AAE7C,eAAO,MAAM,2BAA2B;;;;;;;iBAGtC,CAAC;AAWH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;iBAOvC,CAAC;AAEH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAE1F,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACrE;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,+BAAoC;;;;;;;;;;;;;;;eA0F9C"}
1
+ {"version":3,"file":"build-workflow.d.ts","sourceRoot":"","sources":["../../src/environment/build-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AACzE,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,eAAO,MAAM,2BAA2B;;;;;;;;iBAGtC,CAAC;AAWH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;iBAOvC,CAAC;AAEH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAE1F,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IACpE,4FAA4F;IAC5F,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,8BAA8B,KAAK,IAAI,CAAC;CACjF;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE,+BAAoC;;;;;;;;;;;;;;;eAmG9C"}
@@ -9,12 +9,11 @@ import { createStep, createWorkflow } from "@mastra/core/workflows";
9
9
  * build (`runEnvironmentBuild`), step two polls the provider until the build
10
10
  * settles and pins the active template on the project row. Registered by
11
11
  * `MastraFactory.prepare()` only when the sandbox has `builds`, and driven by
12
- * the Build now route, the per-project cron schedule and the GitHub push
13
- * hand-off. Saving settings never starts it.
12
+ * the Build now route, the per-project cron schedule, the GitHub push
13
+ * hand-off and saved template inputs.
14
14
  */
15
15
  const ENVIRONMENT_BUILD_WORKFLOW_ID = "factory-environment-build";
16
16
  const DEFAULT_BUILD_POLL_MS = 15e3;
17
- const MAX_BUILD_WAIT_MS = 18e5;
18
17
  const environmentBuildInputSchema = z.object({
19
18
  projectId: z.string().min(1),
20
19
  trigger: z.enum(ENVIRONMENT_BUILD_TRIGGERS)
@@ -67,75 +66,80 @@ function createEnvironmentBuildWorkflow(deps, options = {}) {
67
66
  };
68
67
  }
69
68
  });
70
- const awaitBuild = createStep({
71
- id: "await-build",
72
- inputSchema: startOutputSchema,
73
- outputSchema: environmentBuildOutputSchema,
74
- execute: async ({ inputData }) => {
75
- const { projectId, heads, ...result } = inputData;
76
- if (result.outcome !== "started" || !result.buildId || !heads) return result;
77
- const builds = deps.sandbox?.builds;
78
- const project = await deps.projects.getById({ id: projectId });
79
- if (!builds || !deps.sourceControl || !project) return {
80
- ...result,
81
- status: "unknown"
82
- };
83
- const environment = await resolveProjectEnvironment(deps.sourceControl.storage, project);
84
- const { ctx } = await environmentBuildContextWithEnv(project, environment, heads, deps.sourceControl.versionControl, deps.sandboxEnvs);
85
- const startedAt = now().getTime();
86
- try {
87
- for (;;) {
88
- const build = await builds.get(ctx, environment.settings, result.buildId);
89
- if (build.status === "ready") {
90
- const templateId = build.templateId ?? result.templateId ?? result.buildId;
91
- const pinned = await deps.projects.pinActiveTemplate({
92
- id: project.id,
93
- buildId: result.buildId,
94
- templateId,
95
- heads
96
- });
97
- deps.logger?.info(pinned ? "environment build ready" : "environment build ready but superseded", {
98
- factoryProjectId: project.id,
99
- templateId
100
- });
101
- return {
102
- ...result,
103
- templateId,
104
- status: "ready"
105
- };
106
- }
107
- if (build.status === "failed" || build.status === "unknown") {
108
- deps.logger?.info("environment build did not complete", {
109
- factoryProjectId: project.id,
110
- buildId: result.buildId,
111
- status: build.status,
112
- ...build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}
113
- });
114
- return {
115
- ...result,
116
- status: build.status,
117
- ...build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}
118
- };
119
- }
120
- if (now().getTime() - startedAt >= maxWaitMs) return {
69
+ const pollUntilSettled = async (inputData) => {
70
+ const { projectId, heads, ...result } = inputData;
71
+ if (result.outcome !== "started" || !result.buildId || !heads) return result;
72
+ const builds = deps.sandbox?.builds;
73
+ const project = await deps.projects.getById({ id: projectId });
74
+ if (!builds || !deps.sourceControl || !project) return {
75
+ ...result,
76
+ status: "unknown"
77
+ };
78
+ const environment = await resolveProjectEnvironment(deps.sourceControl.storage, project);
79
+ const { ctx } = await environmentBuildContextWithEnv(project, environment, heads, deps.sourceControl.versionControl, deps.sandboxEnvs);
80
+ const startedAt = now().getTime();
81
+ try {
82
+ for (;;) {
83
+ const build = await builds.get(ctx, environment.settings, result.buildId);
84
+ if (build.status === "ready") {
85
+ const templateId = build.templateId ?? result.templateId ?? result.buildId;
86
+ const pinned = await deps.projects.pinActiveTemplate({
87
+ id: project.id,
88
+ buildId: result.buildId,
89
+ templateId,
90
+ heads
91
+ });
92
+ deps.logger?.info(pinned ? "environment build ready" : "environment build ready but superseded", {
93
+ factoryProjectId: project.id,
94
+ templateId
95
+ });
96
+ return {
97
+ ...result,
98
+ templateId,
99
+ status: "ready"
100
+ };
101
+ }
102
+ if (build.status === "failed" || build.status === "unknown") {
103
+ deps.logger?.info("environment build did not complete", {
104
+ factoryProjectId: project.id,
105
+ buildId: result.buildId,
106
+ status: build.status,
107
+ ...build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}
108
+ });
109
+ return {
121
110
  ...result,
122
- status: "unknown",
123
- reason: "Build wait timed out."
111
+ status: build.status,
112
+ ...build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}
124
113
  };
125
- await sleep(pollMs);
126
114
  }
127
- } catch (error) {
128
- const reason = maskSandboxEnvValues(errorReason(error), ctx.buildEnv);
129
- deps.logger?.info("environment build status read failed", {
130
- factoryProjectId: project.id,
131
- reason
132
- });
133
- return {
115
+ if (now().getTime() - startedAt >= maxWaitMs) return {
134
116
  ...result,
135
117
  status: "unknown",
136
- reason
118
+ reason: "Build wait timed out."
137
119
  };
120
+ await sleep(pollMs);
138
121
  }
122
+ } catch (error) {
123
+ const reason = maskSandboxEnvValues(errorReason(error), ctx.buildEnv);
124
+ deps.logger?.info("environment build status read failed", {
125
+ factoryProjectId: project.id,
126
+ reason
127
+ });
128
+ return {
129
+ ...result,
130
+ status: "unknown",
131
+ reason
132
+ };
133
+ }
134
+ };
135
+ const awaitBuild = createStep({
136
+ id: "await-build",
137
+ inputSchema: startOutputSchema,
138
+ outputSchema: environmentBuildOutputSchema,
139
+ execute: async ({ inputData }) => {
140
+ const settled = await pollUntilSettled(inputData);
141
+ options.onSettled?.(inputData.projectId, settled);
142
+ return settled;
139
143
  }
140
144
  });
141
145
  return createWorkflow({
@@ -144,6 +148,6 @@ function createEnvironmentBuildWorkflow(deps, options = {}) {
144
148
  outputSchema: environmentBuildOutputSchema
145
149
  }).then(start).then(awaitBuild).commit();
146
150
  }
147
- export { DEFAULT_BUILD_POLL_MS, ENVIRONMENT_BUILD_WORKFLOW_ID, MAX_BUILD_WAIT_MS, createEnvironmentBuildWorkflow, environmentBuildInputSchema, environmentBuildOutputSchema };
151
+ export { DEFAULT_BUILD_POLL_MS, ENVIRONMENT_BUILD_WORKFLOW_ID, createEnvironmentBuildWorkflow, environmentBuildInputSchema, environmentBuildOutputSchema };
148
152
 
149
153
  //# sourceMappingURL=build-workflow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-workflow.js","names":[],"sources":["../../src/environment/build-workflow.ts"],"sourcesContent":["/**\n * The `factory-environment-build` workflow: step one decides and starts a\n * build (`runEnvironmentBuild`), step two polls the provider until the build\n * settles and pins the active template on the project row. Registered by\n * `MastraFactory.prepare()` only when the sandbox has `builds`, and driven by\n * the Build now route, the per-project cron schedule and the GitHub push\n * hand-off. Saving settings never starts it.\n */\n\nimport { createStep, createWorkflow } from '@mastra/core/workflows';\nimport { z } from 'zod';\nimport { maskSandboxEnvValues } from '../sandbox/sandbox-env.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport {\n ENVIRONMENT_BUILD_TRIGGERS,\n environmentBuildContextWithEnv,\n errorReason,\n redactCredentials,\n runEnvironmentBuild,\n} from './build.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome } from './build.js';\n\nexport const ENVIRONMENT_BUILD_WORKFLOW_ID = 'factory-environment-build';\nexport const DEFAULT_BUILD_POLL_MS = 15_000;\nexport const MAX_BUILD_WAIT_MS = 30 * 60_000;\n\nexport const environmentBuildInputSchema = z.object({\n projectId: z.string().min(1),\n trigger: z.enum(ENVIRONMENT_BUILD_TRIGGERS),\n});\n\nconst startOutputSchema = z.object({\n projectId: z.string(),\n outcome: z.enum(['started', 'skipped', 'unavailable', 'failed']),\n buildId: z.string().optional(),\n templateId: z.string().optional(),\n reason: z.string().optional(),\n heads: z.record(z.string(), z.string()).optional(),\n});\n\nexport const environmentBuildOutputSchema = z.object({\n outcome: z.enum(['started', 'skipped', 'unavailable', 'failed']),\n buildId: z.string().optional(),\n templateId: z.string().optional(),\n reason: z.string().optional(),\n /** Where the started build ended: `ready`, `failed`, or `unknown` when the provider lost it or the wait ran out. */\n status: z.enum(['ready', 'failed', 'unknown']).optional(),\n});\n\nexport type EnvironmentBuildWorkflowResult = z.infer<typeof environmentBuildOutputSchema>;\n\nexport interface EnvironmentBuildWorkflowOptions {\n sleep?: (ms: number) => Promise<void>;\n pollMs?: number;\n maxWaitMs?: number;\n /** Called with the first step's answer so a caller can return it without waiting for the poll. */\n onStart?: (runId: string, outcome: EnvironmentBuildOutcome) => void;\n}\n\nexport function createEnvironmentBuildWorkflow(\n deps: EnvironmentBuildDeps,\n options: EnvironmentBuildWorkflowOptions = {},\n) {\n const sleep = options.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)));\n const pollMs = options.pollMs ?? DEFAULT_BUILD_POLL_MS;\n const maxWaitMs = options.maxWaitMs ?? MAX_BUILD_WAIT_MS;\n const now = deps.now ?? (() => new Date());\n\n const start = createStep({\n id: 'start',\n inputSchema: environmentBuildInputSchema,\n outputSchema: startOutputSchema,\n execute: async ({ inputData, runId }) => {\n const outcome = await runEnvironmentBuild(deps, inputData);\n options.onStart?.(runId, outcome);\n return { projectId: inputData.projectId, ...outcome };\n },\n });\n\n const awaitBuild = createStep({\n id: 'await-build',\n inputSchema: startOutputSchema,\n outputSchema: environmentBuildOutputSchema,\n execute: async ({ inputData }): Promise<EnvironmentBuildWorkflowResult> => {\n const { projectId, heads, ...result } = inputData;\n if (result.outcome !== 'started' || !result.buildId || !heads) return result;\n const builds = deps.sandbox?.builds;\n const project = await deps.projects.getById({ id: projectId });\n if (!builds || !deps.sourceControl || !project) return { ...result, status: 'unknown' };\n const environment = await resolveProjectEnvironment(deps.sourceControl.storage, project);\n const { ctx } = await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n deps.sourceControl.versionControl,\n deps.sandboxEnvs,\n );\n const startedAt = now().getTime();\n try {\n for (;;) {\n const build = await builds.get(ctx, environment.settings, result.buildId);\n if (build.status === 'ready') {\n const templateId = build.templateId ?? result.templateId ?? result.buildId;\n // A newer run may have replaced `last_build_id` while this one\n // polled; the pin is skipped then so the stale image never wins.\n const pinned = await deps.projects.pinActiveTemplate({\n id: project.id,\n buildId: result.buildId,\n templateId,\n heads,\n });\n deps.logger?.info(pinned ? 'environment build ready' : 'environment build ready but superseded', {\n factoryProjectId: project.id,\n templateId,\n });\n return { ...result, templateId, status: 'ready' };\n }\n if (build.status === 'failed' || build.status === 'unknown') {\n deps.logger?.info('environment build did not complete', {\n factoryProjectId: project.id,\n buildId: result.buildId,\n status: build.status,\n ...(build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}),\n });\n return {\n ...result,\n status: build.status,\n ...(build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}),\n };\n }\n if (now().getTime() - startedAt >= maxWaitMs) {\n return { ...result, status: 'unknown', reason: 'Build wait timed out.' };\n }\n await sleep(pollMs);\n }\n } catch (error) {\n const reason = maskSandboxEnvValues(errorReason(error), ctx.buildEnv);\n deps.logger?.info('environment build status read failed', { factoryProjectId: project.id, reason });\n return { ...result, status: 'unknown', reason };\n }\n },\n });\n\n return createWorkflow({\n id: ENVIRONMENT_BUILD_WORKFLOW_ID,\n inputSchema: environmentBuildInputSchema,\n outputSchema: environmentBuildOutputSchema,\n })\n .then(start)\n .then(awaitBuild)\n .commit();\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAa,gCAAgC;AAC7C,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;AAEjC,MAAa,8BAA8B,EAAE,OAAO;CAClD,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,SAAS,EAAE,KAAK,0BAA0B;AAC5C,CAAC;AAED,MAAM,oBAAoB,EAAE,OAAO;CACjC,WAAW,EAAE,OAAO;CACpB,SAAS,EAAE,KAAK;EAAC;EAAW;EAAW;EAAe;CAAQ,CAAC;CAC/D,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;AACnD,CAAC;AAED,MAAa,+BAA+B,EAAE,OAAO;CACnD,SAAS,EAAE,KAAK;EAAC;EAAW;EAAW;EAAe;CAAQ,CAAC;CAC/D,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;;CAE5B,QAAQ,EAAE,KAAK;EAAC;EAAS;EAAU;CAAS,CAAC,CAAC,CAAC,SAAS;AAC1D,CAAC;AAYD,SAAgB,+BACd,MACA,UAA2C,CAAC,GAC5C;CACA,MAAM,QAAQ,QAAQ,WAAU,OAAM,IAAI,SAAc,YAAW,WAAW,SAAS,EAAE,C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A4B,0CAA0C;OAC/F,kBAAkB,QAAQ;OAC1B;MACF,CAAC;MACD,OAAO;OAAE,GAAG;OAAQ;OAAY,QAAQ;MAAQ;KAClD;KACA,IAAI,MAAM,WAAW,YAAY,MAAM,WAAW,WAAW;MAC3D,KAAK,QAAQ,KAAK,sCAAsC;OACtD,kBAAkB,QAAQ;OAC1B,SAAS,OAAO;OAChB,QAAQ,MAAM;OACd,GAAI,MAAM,QAAQ,EAAE,QAAQ,qBAAqB,kBAAkB,MAAM,KAAK,GAAG,IAAI,QAAQ,EAAE,IAAI,CAAC;MACtG,CAAC;MACD,OAAO;OACL,GAAG;OACH,QAAQ,MAAM;OACd,GAAI,MAAM,QAAQ,EAAE,QAAQ,qBAAqB,kBAAkB,MAAM,KAAK,GAAG,IAAI,QAAQ,EAAE,IAAI,CAAC;MACtG;KACF;KACA,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,aAAa,WACjC,OAAO;MAAE,GAAG;MAAQ,QAAQ;MAAW,QAAQ;KAAwB;KAEzE,MAAM,MAAM,MAAM;IACpB;GACF,SAAS,OAAO;IACd,MAAM,SAAS,qBAAqB,YAAY,KAAK,GAAG,IAAI,QAAQ;IACpE,KAAK,QAAQ,KAAK,wCAAwC;KAAE,kBAAkB,QAAQ;KAAI;IAAO,CAAC;IAClG,OAAO;KAAE,GAAG;KAAQ,QAAQ;KAAW;IAAO;GAChD;EACF;CACF,CAAC;CAED,OAAO,eAAe;EACpB,IAAI;EACJ,aAAa;EACb,cAAc;CAChB,CAAC,CAAC,CACC,KAAK,KAAK,CAAC,CACX,KAAK,UAAU,CAAC,CAChB,OAAO;AACZ"}
1
+ {"version":3,"file":"build-workflow.js","names":[],"sources":["../../src/environment/build-workflow.ts"],"sourcesContent":["/**\n * The `factory-environment-build` workflow: step one decides and starts a\n * build (`runEnvironmentBuild`), step two polls the provider until the build\n * settles and pins the active template on the project row. Registered by\n * `MastraFactory.prepare()` only when the sandbox has `builds`, and driven by\n * the Build now route, the per-project cron schedule, the GitHub push\n * hand-off and saved template inputs.\n */\n\nimport { createStep, createWorkflow } from '@mastra/core/workflows';\nimport { z } from 'zod';\nimport { maskSandboxEnvValues } from '../sandbox/sandbox-env.js';\nimport { resolveProjectEnvironment } from '../workspace.js';\nimport {\n ENVIRONMENT_BUILD_TRIGGERS,\n environmentBuildContextWithEnv,\n errorReason,\n MAX_BUILD_WAIT_MS,\n redactCredentials,\n runEnvironmentBuild,\n} from './build.js';\nimport type { EnvironmentBuildDeps, EnvironmentBuildOutcome } from './build.js';\n\nexport const ENVIRONMENT_BUILD_WORKFLOW_ID = 'factory-environment-build';\nexport const DEFAULT_BUILD_POLL_MS = 15_000;\n\nexport const environmentBuildInputSchema = z.object({\n projectId: z.string().min(1),\n trigger: z.enum(ENVIRONMENT_BUILD_TRIGGERS),\n});\n\nconst startOutputSchema = z.object({\n projectId: z.string(),\n outcome: z.enum(['started', 'skipped', 'unavailable', 'failed']),\n buildId: z.string().optional(),\n templateId: z.string().optional(),\n reason: z.string().optional(),\n heads: z.record(z.string(), z.string()).optional(),\n});\n\nexport const environmentBuildOutputSchema = z.object({\n outcome: z.enum(['started', 'skipped', 'unavailable', 'failed']),\n buildId: z.string().optional(),\n templateId: z.string().optional(),\n reason: z.string().optional(),\n /** Where the started build ended: `ready`, `failed`, or `unknown` when the provider lost it or the wait ran out. */\n status: z.enum(['ready', 'failed', 'unknown']).optional(),\n});\n\nexport type EnvironmentBuildWorkflowResult = z.infer<typeof environmentBuildOutputSchema>;\n\nexport interface EnvironmentBuildWorkflowOptions {\n sleep?: (ms: number) => Promise<void>;\n pollMs?: number;\n maxWaitMs?: number;\n /** Called with the first step's answer so a caller can return it without waiting for the poll. */\n onStart?: (runId: string, outcome: EnvironmentBuildOutcome) => void;\n /** Called once a run is over, whoever started it (a route, the scheduler or a hand-off). */\n onSettled?: (projectId: string, result: EnvironmentBuildWorkflowResult) => void;\n}\n\nexport function createEnvironmentBuildWorkflow(\n deps: EnvironmentBuildDeps,\n options: EnvironmentBuildWorkflowOptions = {},\n) {\n const sleep = options.sleep ?? (ms => new Promise<void>(resolve => setTimeout(resolve, ms)));\n const pollMs = options.pollMs ?? DEFAULT_BUILD_POLL_MS;\n const maxWaitMs = options.maxWaitMs ?? MAX_BUILD_WAIT_MS;\n const now = deps.now ?? (() => new Date());\n\n const start = createStep({\n id: 'start',\n inputSchema: environmentBuildInputSchema,\n outputSchema: startOutputSchema,\n execute: async ({ inputData, runId }) => {\n const outcome = await runEnvironmentBuild(deps, inputData);\n options.onStart?.(runId, outcome);\n return { projectId: inputData.projectId, ...outcome };\n },\n });\n\n // Polls a started build until it settles and pins its template.\n const pollUntilSettled = async (\n inputData: z.infer<typeof startOutputSchema>,\n ): Promise<EnvironmentBuildWorkflowResult> => {\n const { projectId, heads, ...result } = inputData;\n if (result.outcome !== 'started' || !result.buildId || !heads) return result;\n const builds = deps.sandbox?.builds;\n const project = await deps.projects.getById({ id: projectId });\n if (!builds || !deps.sourceControl || !project) return { ...result, status: 'unknown' };\n const environment = await resolveProjectEnvironment(deps.sourceControl.storage, project);\n const { ctx } = await environmentBuildContextWithEnv(\n project,\n environment,\n heads,\n deps.sourceControl.versionControl,\n deps.sandboxEnvs,\n );\n const startedAt = now().getTime();\n try {\n for (;;) {\n const build = await builds.get(ctx, environment.settings, result.buildId);\n if (build.status === 'ready') {\n const templateId = build.templateId ?? result.templateId ?? result.buildId;\n // A newer run may have replaced `last_build_id` while this one\n // polled; the pin is skipped then so the stale image never wins.\n const pinned = await deps.projects.pinActiveTemplate({\n id: project.id,\n buildId: result.buildId,\n templateId,\n heads,\n });\n deps.logger?.info(pinned ? 'environment build ready' : 'environment build ready but superseded', {\n factoryProjectId: project.id,\n templateId,\n });\n return { ...result, templateId, status: 'ready' };\n }\n if (build.status === 'failed' || build.status === 'unknown') {\n deps.logger?.info('environment build did not complete', {\n factoryProjectId: project.id,\n buildId: result.buildId,\n status: build.status,\n ...(build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}),\n });\n return {\n ...result,\n status: build.status,\n ...(build.error ? { reason: maskSandboxEnvValues(redactCredentials(build.error), ctx.buildEnv) } : {}),\n };\n }\n if (now().getTime() - startedAt >= maxWaitMs) {\n return { ...result, status: 'unknown', reason: 'Build wait timed out.' };\n }\n await sleep(pollMs);\n }\n } catch (error) {\n const reason = maskSandboxEnvValues(errorReason(error), ctx.buildEnv);\n deps.logger?.info('environment build status read failed', { factoryProjectId: project.id, reason });\n return { ...result, status: 'unknown', reason };\n }\n };\n\n const awaitBuild = createStep({\n id: 'await-build',\n inputSchema: startOutputSchema,\n outputSchema: environmentBuildOutputSchema,\n execute: async ({ inputData }): Promise<EnvironmentBuildWorkflowResult> => {\n const settled = await pollUntilSettled(inputData);\n options.onSettled?.(inputData.projectId, settled);\n return settled;\n },\n });\n\n return createWorkflow({\n id: ENVIRONMENT_BUILD_WORKFLOW_ID,\n inputSchema: environmentBuildInputSchema,\n outputSchema: environmentBuildOutputSchema,\n })\n .then(start)\n .then(awaitBuild)\n .commit();\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAa,gCAAgC;AAC7C,MAAa,wBAAwB;AAErC,MAAa,8BAA8B,EAAE,OAAO;CAClD,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAC3B,SAAS,EAAE,KAAK,0BAA0B;AAC5C,CAAC;AAED,MAAM,oBAAoB,EAAE,OAAO;CACjC,WAAW,EAAE,OAAO;CACpB,SAAS,EAAE,KAAK;EAAC;EAAW;EAAW;EAAe;CAAQ,CAAC;CAC/D,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;AACnD,CAAC;AAED,MAAa,+BAA+B,EAAE,OAAO;CACnD,SAAS,EAAE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;EACJ,aAAa;EACb,cAAc;EACd,SAAS,OAAO,EAAE,gBAAyD;GACzE,MAAM,UAAU,MAAM,iBAAiB,SAAS;GAChD,QAAQ,YAAY,UAAU,WAAW,OAAO;GAChD,OAAO;EACT;CACF,CAAC;CAED,OAAO,eAAe;EACpB,IAAI;EACJ,aAAa;EACb,cAAc;CAChB,CAAC,CAAC,CACC,KAAK,KAAK,CAAC,CACX,KAAK,UAAU,CAAC,CAChB,OAAO;AACZ"}
@@ -13,11 +13,12 @@ import type { SandboxEnvStore } from '../storage/domains/sandbox-envs/base.js';
13
13
  import type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js';
14
14
  import type { SessionEnvironment } from '../workspace.js';
15
15
  import type { EnvironmentHeads } from './heads.js';
16
- export declare const ENVIRONMENT_BUILD_TRIGGERS: readonly ['manual', 'schedule', 'push'];
16
+ /** `settings`: a saved change to the environment; builds only when the template inputs changed. */
17
+ export declare const ENVIRONMENT_BUILD_TRIGGERS: readonly ['manual', 'schedule', 'push', 'settings'];
17
18
  export type EnvironmentBuildTrigger = (typeof ENVIRONMENT_BUILD_TRIGGERS)[number];
18
19
  export interface EnvironmentBuildSourceControl {
19
20
  storage: Pick<SourceControlStorageHandle, 'projectRepositories' | 'repositories'>;
20
- versionControl: Pick<VersionControl, 'getRepositoryAccess'>;
21
+ versionControl: Pick<VersionControl, 'getRepositoryAccess' | 'getRepositoriesAccess'>;
21
22
  }
22
23
  export interface EnvironmentBuildDeps {
23
24
  /** The factory's normalized sandbox; builds are unavailable without its `builds`. */
@@ -40,7 +41,7 @@ export interface EnvironmentBuildOutcome {
40
41
  outcome: 'started' | 'skipped' | 'unavailable' | 'failed';
41
42
  buildId?: string;
42
43
  templateId?: string;
43
- /** 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. */
44
+ /** 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_template` (a `settings` run before the first build), `no_environment`, `no_builds`, `no_source_control`; why a run failed: `not_recorded`, `superseded`, or an error. */
44
45
  reason?: string;
45
46
  /** The heads the started build pins; the workflow stores them once the build is ready. */
46
47
  heads?: EnvironmentHeads;
@@ -60,13 +61,13 @@ export declare function errorReason(error: unknown): string;
60
61
  * session id, with heads served from `heads` so the provider never resolves
61
62
  * them itself.
62
63
  */
63
- export declare function environmentBuildContext(project: Pick<FactoryProject, 'id' | 'orgId' | 'name'>, environment: SessionEnvironment, heads: EnvironmentHeads, versionControl: Pick<VersionControl, 'getRepositoryAccess'>): FactorySandboxContext;
64
+ export declare function environmentBuildContext(project: Pick<FactoryProject, 'id' | 'orgId' | 'name'>, environment: SessionEnvironment, heads: EnvironmentHeads, versionControl: Pick<VersionControl, 'getRepositoryAccess' | 'getRepositoriesAccess'>): FactorySandboxContext;
64
65
  /**
65
66
  * {@link environmentBuildContext} with the Factory's Build variables, plus the
66
67
  * build revision for {@link environmentBuildInputs}. Every build path (start,
67
68
  * status read, poll) goes through this so all of them name the same template.
68
69
  */
69
- export declare function environmentBuildContextWithEnv(project: Pick<FactoryProject, 'id' | 'orgId' | 'name'>, environment: SessionEnvironment, heads: EnvironmentHeads, versionControl: Pick<VersionControl, 'getRepositoryAccess'>, sandboxEnvs: Pick<SandboxEnvStore, 'resolve'> | undefined): Promise<{
70
+ export declare function environmentBuildContextWithEnv(project: Pick<FactoryProject, 'id' | 'orgId' | 'name'>, environment: SessionEnvironment, heads: EnvironmentHeads, versionControl: Pick<VersionControl, 'getRepositoryAccess' | 'getRepositoriesAccess'>, sandboxEnvs: Pick<SandboxEnvStore, 'resolve'> | undefined): Promise<{
70
71
  ctx: FactorySandboxContext;
71
72
  buildEnvRevision: string | undefined;
72
73
  }>;
@@ -91,6 +92,15 @@ export declare function resolveEnvironmentHeads(sourceControl: EnvironmentBuildS
91
92
  * its run died or stalled.
92
93
  */
93
94
  export declare const BUILD_START_LEASE_MS: number;
95
+ /** How long the build workflow polls a started build before it gives up on it. */
96
+ export declare const MAX_BUILD_WAIT_MS: number;
97
+ /**
98
+ * How long after a lapsed lease a provider that cannot list builds keeps every
99
+ * trigger from building. The lapsed run started its build, if it did, before
100
+ * its lease expired, so by now that build has outlived the workflow's own wait
101
+ * and is treated as failed.
102
+ */
103
+ export declare const UNRESOLVED_BUILD_START_TIMEOUT_MS: number;
94
104
  /**
95
105
  * Start a build for `projectId` when `trigger` calls for one. Every trigger
96
106
  * takes the project's build-start lease before reading build state and renews
@@ -101,13 +111,18 @@ export declare const BUILD_START_LEASE_MS: number;
101
111
  * build is ready and neither a head nor any other template input changed;
102
112
  * `manual` otherwise always builds. A `push` that would build then takes the
103
113
  * leading-edge debounce claim, so only a push that starts a build opens the
104
- * window. Saving settings never builds.
114
+ * window. `settings` (a saved environment change) builds only once the
115
+ * project has a template and the template inputs differ from the last
116
+ * build's, whatever the heads; it skips as `no_template` before the first
117
+ * build, and saving the same inputs twice skips as `unchanged`.
105
118
  *
106
119
  * Taking over a lapsed lease leaves the start uncertain: the lapsed run may
107
120
  * have started a build it never recorded. The mark persists until resolved.
108
121
  * While it stands, a provider that lists builds is asked for a running one
109
122
  * (and every trigger skips as `in_progress` on it); with a provider that
110
- * cannot list, every trigger skips as `unresolved`.
123
+ * cannot list, every trigger skips as `unresolved` until
124
+ * `UNRESOLVED_BUILD_START_TIMEOUT_MS` after the lapse, when the run gives
125
+ * up on that build as failed, clears the mark and carries on.
111
126
  *
112
127
  * The result is written as the lease is released, and only while this run
113
128
  * still holds it. A failed `builds.start` clears the last build id, so a later
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/environment/build.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,c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