@mastra/factory 0.28.0-alpha.1 → 0.28.0-alpha.3

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 (399) hide show
  1. package/README.md +244 -123
  2. package/dist/boards/board-events.d.ts +23 -3
  3. package/dist/boards/board-events.d.ts.map +1 -1
  4. package/dist/boards/board-events.js +44 -7
  5. package/dist/boards/board-events.js.map +1 -1
  6. package/dist/boards/board-writes.d.ts +1 -1
  7. package/dist/boards/board-writes.d.ts.map +1 -1
  8. package/dist/boards/board-writes.js +16 -1
  9. package/dist/boards/board-writes.js.map +1 -1
  10. package/dist/boards/card-facts.d.ts +1 -1
  11. package/dist/boards/card-facts.d.ts.map +1 -1
  12. package/dist/boards/card-facts.js +4 -0
  13. package/dist/boards/card-facts.js.map +1 -1
  14. package/dist/boards/default-board.d.ts +7 -0
  15. package/dist/boards/default-board.d.ts.map +1 -0
  16. package/dist/boards/default-board.js +10 -0
  17. package/dist/boards/default-board.js.map +1 -0
  18. package/dist/boards/define-board.d.ts +39 -17
  19. package/dist/boards/define-board.d.ts.map +1 -1
  20. package/dist/boards/define-board.js +64 -42
  21. package/dist/boards/define-board.js.map +1 -1
  22. package/dist/boards/index.d.ts +5 -8
  23. package/dist/boards/index.d.ts.map +1 -1
  24. package/dist/boards/index.js +5 -19
  25. package/dist/boards/intake-routing.d.ts +27 -5
  26. package/dist/boards/intake-routing.d.ts.map +1 -1
  27. package/dist/boards/intake-routing.js +69 -16
  28. package/dist/boards/intake-routing.js.map +1 -1
  29. package/dist/boards/legacy-plan-role.d.ts.map +1 -1
  30. package/dist/boards/legacy-plan-role.js +7 -2
  31. package/dist/boards/legacy-plan-role.js.map +1 -1
  32. package/dist/boards/phase-automation.d.ts +7 -0
  33. package/dist/boards/phase-automation.d.ts.map +1 -1
  34. package/dist/boards/phase-automation.js +16 -5
  35. package/dist/boards/phase-automation.js.map +1 -1
  36. package/dist/boards/phase-runner.d.ts +18 -10
  37. package/dist/boards/phase-runner.d.ts.map +1 -1
  38. package/dist/boards/phase-runner.js +39 -34
  39. package/dist/boards/phase-runner.js.map +1 -1
  40. package/dist/boards/project-boards.d.ts +9 -6
  41. package/dist/boards/project-boards.d.ts.map +1 -1
  42. package/dist/boards/project-boards.js +56 -18
  43. package/dist/boards/project-boards.js.map +1 -1
  44. package/dist/boards/registry.d.ts.map +1 -1
  45. package/dist/boards/registry.js +3 -1
  46. package/dist/boards/registry.js.map +1 -1
  47. package/dist/boards/relocate.d.ts +1 -1
  48. package/dist/boards/relocate.d.ts.map +1 -1
  49. package/dist/boards/relocate.js +3 -2
  50. package/dist/boards/relocate.js.map +1 -1
  51. package/dist/boards/review.d.ts +5 -2
  52. package/dist/boards/review.d.ts.map +1 -1
  53. package/dist/boards/review.js +12 -11
  54. package/dist/boards/review.js.map +1 -1
  55. package/dist/boards/semantics.d.ts +159 -20
  56. package/dist/boards/semantics.d.ts.map +1 -1
  57. package/dist/boards/semantics.js +256 -23
  58. package/dist/boards/semantics.js.map +1 -1
  59. package/dist/boards/stored-board.d.ts +32 -18
  60. package/dist/boards/stored-board.d.ts.map +1 -1
  61. package/dist/boards/stored-board.js +31 -97
  62. package/dist/boards/stored-board.js.map +1 -1
  63. package/dist/boards/work-migrations.d.ts +19 -0
  64. package/dist/boards/work-migrations.d.ts.map +1 -0
  65. package/dist/boards/work-migrations.js +257 -0
  66. package/dist/boards/work-migrations.js.map +1 -0
  67. package/dist/boards/work-routes.d.ts +53 -0
  68. package/dist/boards/work-routes.d.ts.map +1 -0
  69. package/dist/boards/work-routes.js +256 -0
  70. package/dist/boards/work-routes.js.map +1 -0
  71. package/dist/boards/work.d.ts +8 -19
  72. package/dist/boards/work.d.ts.map +1 -1
  73. package/dist/boards/work.js +38 -270
  74. package/dist/boards/work.js.map +1 -1
  75. package/dist/factory.d.ts +3 -3
  76. package/dist/factory.d.ts.map +1 -1
  77. package/dist/factory.js +58 -30
  78. package/dist/factory.js.map +1 -1
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -3
  82. package/dist/integrations/base.d.ts +6 -2
  83. package/dist/integrations/base.d.ts.map +1 -1
  84. package/dist/integrations/closing-references.d.ts +15 -0
  85. package/dist/integrations/closing-references.d.ts.map +1 -0
  86. package/dist/integrations/closing-references.js +69 -0
  87. package/dist/integrations/closing-references.js.map +1 -0
  88. package/dist/integrations/github/default-rules.d.ts +15 -66
  89. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  90. package/dist/integrations/github/default-rules.js +129 -71
  91. package/dist/integrations/github/default-rules.js.map +1 -1
  92. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
  93. package/dist/integrations/github/issue-reconciler.js +3 -1
  94. package/dist/integrations/github/issue-reconciler.js.map +1 -1
  95. package/dist/integrations/github/pull-request-source.d.ts +8 -0
  96. package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
  97. package/dist/integrations/github/pull-request-source.js +17 -0
  98. package/dist/integrations/github/pull-request-source.js.map +1 -0
  99. package/dist/integrations/github/review-status-reporter.d.ts.map +1 -1
  100. package/dist/integrations/github/review-status-reporter.js +7 -3
  101. package/dist/integrations/github/review-status-reporter.js.map +1 -1
  102. package/dist/integrations/github/routes.js +1 -1
  103. package/dist/integrations/github/rules.d.ts +13 -2
  104. package/dist/integrations/github/rules.d.ts.map +1 -1
  105. package/dist/integrations/github/rules.js +202 -34
  106. package/dist/integrations/github/rules.js.map +1 -1
  107. package/dist/integrations/github/session-subscriptions.js +2 -2
  108. package/dist/integrations/github/session-subscriptions.js.map +1 -1
  109. package/dist/integrations/github/token-refresh.d.ts +2 -1
  110. package/dist/integrations/github/token-refresh.d.ts.map +1 -1
  111. package/dist/integrations/github/token-refresh.js.map +1 -1
  112. package/dist/integrations/gitlab/agent-tools.js +1 -1
  113. package/dist/integrations/gitlab/default-rules.d.ts +73 -31
  114. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  115. package/dist/integrations/gitlab/default-rules.js +106 -43
  116. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  117. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
  118. package/dist/integrations/gitlab/issue-reconciler.js +2 -1
  119. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
  120. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
  121. package/dist/integrations/gitlab/merge-request-reconciler.js +11 -4
  122. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
  123. package/dist/integrations/gitlab/rules.d.ts +6 -1
  124. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  125. package/dist/integrations/gitlab/rules.js +116 -23
  126. package/dist/integrations/gitlab/rules.js.map +1 -1
  127. package/dist/integrations/gitlab/session-subscriptions.js +1 -1
  128. package/dist/integrations/incidentio/agent-tools.js +1 -1
  129. package/dist/integrations/incidentio/default-rules.js +3 -3
  130. package/dist/integrations/incidentio/default-rules.js.map +1 -1
  131. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
  132. package/dist/integrations/incidentio/issue-reconciler.js +2 -1
  133. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
  134. package/dist/integrations/incidentio/rules.d.ts +3 -1
  135. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  136. package/dist/integrations/incidentio/rules.js +14 -11
  137. package/dist/integrations/incidentio/rules.js.map +1 -1
  138. package/dist/integrations/jira/agent-tools.js +1 -1
  139. package/dist/integrations/jira/default-rules.js +3 -3
  140. package/dist/integrations/jira/default-rules.js.map +1 -1
  141. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
  142. package/dist/integrations/jira/issue-reconciler.js +2 -1
  143. package/dist/integrations/jira/issue-reconciler.js.map +1 -1
  144. package/dist/integrations/jira/rules.d.ts +3 -1
  145. package/dist/integrations/jira/rules.d.ts.map +1 -1
  146. package/dist/integrations/jira/rules.js +14 -11
  147. package/dist/integrations/jira/rules.js.map +1 -1
  148. package/dist/integrations/linear/agent-tools.d.ts +9 -1
  149. package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
  150. package/dist/integrations/linear/agent-tools.js +80 -2
  151. package/dist/integrations/linear/agent-tools.js.map +1 -1
  152. package/dist/integrations/linear/default-rules.js +3 -3
  153. package/dist/integrations/linear/default-rules.js.map +1 -1
  154. package/dist/integrations/linear/integration.d.ts +4 -1
  155. package/dist/integrations/linear/integration.d.ts.map +1 -1
  156. package/dist/integrations/linear/integration.js +21 -1
  157. package/dist/integrations/linear/integration.js.map +1 -1
  158. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  159. package/dist/integrations/linear/issue-reconciler.js +2 -1
  160. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  161. package/dist/integrations/linear/routes.d.ts +2 -1
  162. package/dist/integrations/linear/routes.d.ts.map +1 -1
  163. package/dist/integrations/linear/routes.js +4 -3
  164. package/dist/integrations/linear/routes.js.map +1 -1
  165. package/dist/integrations/linear/rules.d.ts +3 -1
  166. package/dist/integrations/linear/rules.d.ts.map +1 -1
  167. package/dist/integrations/linear/rules.js +15 -12
  168. package/dist/integrations/linear/rules.js.map +1 -1
  169. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  170. package/dist/integrations/platform/github/integration.js +33 -21
  171. package/dist/integrations/platform/github/integration.js.map +1 -1
  172. package/dist/integrations/platform/jira/agent-tools.js +1 -1
  173. package/dist/integrations/platform/linear/integration.d.ts +1 -1
  174. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  175. package/dist/integrations/platform/linear/integration.js +6 -5
  176. package/dist/integrations/platform/linear/integration.js.map +1 -1
  177. package/dist/integrations/slack/chat-tools.js +1 -1
  178. package/dist/integrations/slack/reply-tool.js +1 -1
  179. package/dist/integrations/slack/share-file-tool.js +1 -1
  180. package/dist/integrations/slack/slack.d.ts +10 -4
  181. package/dist/integrations/slack/slack.d.ts.map +1 -1
  182. package/dist/integrations/slack/slack.js +19 -9
  183. package/dist/integrations/slack/slack.js.map +1 -1
  184. package/dist/links.d.ts.map +1 -1
  185. package/dist/links.js +3 -2
  186. package/dist/links.js.map +1 -1
  187. package/dist/mcp/routes.js +2 -2
  188. package/dist/routes/attention-parked.d.ts +1 -0
  189. package/dist/routes/attention-parked.d.ts.map +1 -1
  190. package/dist/routes/attention-parked.js +1 -1
  191. package/dist/routes/attention-parked.js.map +1 -1
  192. package/dist/routes/automation-runs.d.ts +4 -0
  193. package/dist/routes/automation-runs.d.ts.map +1 -1
  194. package/dist/routes/automation-runs.js +15 -0
  195. package/dist/routes/automation-runs.js.map +1 -1
  196. package/dist/routes/boards.d.ts +1 -1
  197. package/dist/routes/boards.d.ts.map +1 -1
  198. package/dist/routes/boards.js +1 -17
  199. package/dist/routes/boards.js.map +1 -1
  200. package/dist/routes/config.d.ts +4 -0
  201. package/dist/routes/config.d.ts.map +1 -1
  202. package/dist/routes/config.js +15 -0
  203. package/dist/routes/config.js.map +1 -1
  204. package/dist/routes/contracts.d.ts +125 -14
  205. package/dist/routes/contracts.d.ts.map +1 -1
  206. package/dist/routes/contracts.js +34 -15
  207. package/dist/routes/contracts.js.map +1 -1
  208. package/dist/routes/fs.d.ts +4 -0
  209. package/dist/routes/fs.d.ts.map +1 -1
  210. package/dist/routes/fs.js +8 -4
  211. package/dist/routes/fs.js.map +1 -1
  212. package/dist/routes/intake-routes.d.ts.map +1 -1
  213. package/dist/routes/intake-routes.js.map +1 -1
  214. package/dist/routes/intake.d.ts.map +1 -1
  215. package/dist/routes/intake.js +1 -0
  216. package/dist/routes/intake.js.map +1 -1
  217. package/dist/routes/projects.d.ts.map +1 -1
  218. package/dist/routes/projects.js +8 -2
  219. package/dist/routes/projects.js.map +1 -1
  220. package/dist/routes/provider-credentials.d.ts.map +1 -1
  221. package/dist/routes/provider-credentials.js +10 -5
  222. package/dist/routes/provider-credentials.js.map +1 -1
  223. package/dist/routes/running-packages.d.ts +13 -0
  224. package/dist/routes/running-packages.d.ts.map +1 -0
  225. package/dist/routes/running-packages.js +45 -0
  226. package/dist/routes/running-packages.js.map +1 -0
  227. package/dist/routes/surface.d.ts +10 -1
  228. package/dist/routes/surface.d.ts.map +1 -1
  229. package/dist/routes/surface.js +104 -35
  230. package/dist/routes/surface.js.map +1 -1
  231. package/dist/routes/work-items.d.ts.map +1 -1
  232. package/dist/routes/work-items.js +23 -3
  233. package/dist/routes/work-items.js.map +1 -1
  234. package/dist/rules/binding-context.d.ts.map +1 -1
  235. package/dist/rules/binding-context.js +1 -0
  236. package/dist/rules/binding-context.js.map +1 -1
  237. package/dist/rules/dispatcher.d.ts +0 -1
  238. package/dist/rules/dispatcher.d.ts.map +1 -1
  239. package/dist/rules/dispatcher.js +340 -42
  240. package/dist/rules/dispatcher.js.map +1 -1
  241. package/dist/rules/event-rules.d.ts +33 -2
  242. package/dist/rules/event-rules.d.ts.map +1 -1
  243. package/dist/rules/event-rules.js +46 -11
  244. package/dist/rules/event-rules.js.map +1 -1
  245. package/dist/rules/index.d.ts +2 -4
  246. package/dist/rules/index.d.ts.map +1 -1
  247. package/dist/rules/index.js +2 -3
  248. package/dist/rules/phase-goal.d.ts +54 -0
  249. package/dist/rules/phase-goal.d.ts.map +1 -0
  250. package/dist/rules/phase-goal.js +70 -0
  251. package/dist/rules/phase-goal.js.map +1 -0
  252. package/dist/rules/phase-tools.d.ts +11 -0
  253. package/dist/rules/phase-tools.d.ts.map +1 -0
  254. package/dist/rules/phase-tools.js +19 -0
  255. package/dist/rules/phase-tools.js.map +1 -0
  256. package/dist/rules/processor.d.ts.map +1 -1
  257. package/dist/rules/processor.js +112 -11
  258. package/dist/rules/processor.js.map +1 -1
  259. package/dist/rules/review-source-tool.d.ts +4 -1
  260. package/dist/rules/review-source-tool.d.ts.map +1 -1
  261. package/dist/rules/review-source-tool.js +24 -4
  262. package/dist/rules/review-source-tool.js.map +1 -1
  263. package/dist/rules/rule-group.d.ts +1 -1
  264. package/dist/rules/rule-group.d.ts.map +1 -1
  265. package/dist/rules/rule-group.js +2 -1
  266. package/dist/rules/rule-group.js.map +1 -1
  267. package/dist/rules/start-coordinator.d.ts +5 -1
  268. package/dist/rules/start-coordinator.d.ts.map +1 -1
  269. package/dist/rules/start-coordinator.js +9 -3
  270. package/dist/rules/start-coordinator.js.map +1 -1
  271. package/dist/rules/tools.d.ts.map +1 -1
  272. package/dist/rules/tools.js +39 -28
  273. package/dist/rules/tools.js.map +1 -1
  274. package/dist/rules/transition-service.d.ts +2 -7
  275. package/dist/rules/transition-service.d.ts.map +1 -1
  276. package/dist/rules/transition-service.js +61 -54
  277. package/dist/rules/transition-service.js.map +1 -1
  278. package/dist/rules/types.d.ts +83 -29
  279. package/dist/rules/types.d.ts.map +1 -1
  280. package/dist/rules/types.js +5 -41
  281. package/dist/rules/types.js.map +1 -1
  282. package/dist/rules/validation.d.ts.map +1 -1
  283. package/dist/rules/validation.js +32 -2
  284. package/dist/rules/validation.js.map +1 -1
  285. package/dist/secret-encryption.d.ts +21 -0
  286. package/dist/secret-encryption.d.ts.map +1 -1
  287. package/dist/secret-encryption.js +31 -4
  288. package/dist/secret-encryption.js.map +1 -1
  289. package/dist/session/self-review-gate.d.ts +6 -2
  290. package/dist/session/self-review-gate.d.ts.map +1 -1
  291. package/dist/session/self-review-gate.js +8 -4
  292. package/dist/session/self-review-gate.js.map +1 -1
  293. package/dist/session/session-threads.d.ts +2 -3
  294. package/dist/session/session-threads.d.ts.map +1 -1
  295. package/dist/session/session-threads.js.map +1 -1
  296. package/dist/session/source-control-tools.js +1 -1
  297. package/dist/session/work-item-state-processor.d.ts +27 -0
  298. package/dist/session/work-item-state-processor.d.ts.map +1 -0
  299. package/dist/session/work-item-state-processor.js +288 -0
  300. package/dist/session/work-item-state-processor.js.map +1 -0
  301. package/dist/storage/domains/boards/base.d.ts +44 -27
  302. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  303. package/dist/storage/domains/boards/base.js +76 -121
  304. package/dist/storage/domains/boards/base.js.map +1 -1
  305. package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
  306. package/dist/storage/domains/boards/schemas.js +12 -0
  307. package/dist/storage/domains/boards/schemas.js.map +1 -1
  308. package/dist/storage/domains/work-items/base.d.ts +32 -2
  309. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  310. package/dist/storage/domains/work-items/base.js +109 -26
  311. package/dist/storage/domains/work-items/base.js.map +1 -1
  312. package/dist/storage/domains/work-items/cards.d.ts +24 -2
  313. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  314. package/dist/storage/domains/work-items/cards.js +118 -8
  315. package/dist/storage/domains/work-items/cards.js.map +1 -1
  316. package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
  317. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
  318. package/dist/storage/domains/work-items/legacy-review.js +95 -0
  319. package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
  320. package/dist/storage/domains/work-items/metrics.d.ts +12 -4
  321. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
  322. package/dist/storage/domains/work-items/metrics.js +14 -32
  323. package/dist/storage/domains/work-items/metrics.js.map +1 -1
  324. package/dist/storage/domains/work-items/work-item-schema.d.ts +2 -0
  325. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  326. package/dist/storage/domains/work-items/work-item-schema.js +5 -0
  327. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  328. package/dist/tools/approval-tools.d.ts.map +1 -1
  329. package/dist/tools/approval-tools.js +28 -9
  330. package/dist/tools/approval-tools.js.map +1 -1
  331. package/dist/tools/index.d.ts +1 -1
  332. package/dist/tools/index.js +1 -1
  333. package/dist/tools/index.js.map +1 -1
  334. package/dist/tools/messaging-tools.d.ts +3 -0
  335. package/dist/tools/messaging-tools.d.ts.map +1 -1
  336. package/dist/tools/messaging-tools.js +2 -1
  337. package/dist/tools/messaging-tools.js.map +1 -1
  338. package/dist/tools/read-tools.d.ts +8 -2
  339. package/dist/tools/read-tools.d.ts.map +1 -1
  340. package/dist/tools/read-tools.js +83 -23
  341. package/dist/tools/read-tools.js.map +1 -1
  342. package/dist/tools/reports.d.ts +1 -0
  343. package/dist/tools/reports.d.ts.map +1 -1
  344. package/dist/tools/reports.js +2 -1
  345. package/dist/tools/reports.js.map +1 -1
  346. package/dist/tools/run-watch.d.ts +1 -1
  347. package/dist/tools/run-watch.d.ts.map +1 -1
  348. package/dist/tools/run-watch.js +1 -0
  349. package/dist/tools/run-watch.js.map +1 -1
  350. package/dist/tools/sandbox-tools.js +1 -1
  351. package/dist/tools/session-tools.js +1 -1
  352. package/dist/tools/sessions-state-processor.d.ts +2 -0
  353. package/dist/tools/sessions-state-processor.d.ts.map +1 -1
  354. package/dist/tools/sessions-state-processor.js +4 -2
  355. package/dist/tools/sessions-state-processor.js.map +1 -1
  356. package/dist/tools/side-sessions.d.ts +2 -0
  357. package/dist/tools/side-sessions.d.ts.map +1 -1
  358. package/dist/tools/side-sessions.js +2 -1
  359. package/dist/tools/side-sessions.js.map +1 -1
  360. package/dist/tools/work-item-tools.js +3 -3
  361. package/dist/tools/work-item-tools.js.map +1 -1
  362. package/dist/work-item-branch.d.ts +13 -0
  363. package/dist/work-item-branch.d.ts.map +1 -1
  364. package/dist/work-item-branch.js +16 -1
  365. package/dist/work-item-branch.js.map +1 -1
  366. package/dist/work-items/create-work-item.d.ts +6 -0
  367. package/dist/work-items/create-work-item.d.ts.map +1 -1
  368. package/dist/work-items/create-work-item.js +25 -1
  369. package/dist/work-items/create-work-item.js.map +1 -1
  370. package/dist/work-items/split-migration.d.ts.map +1 -1
  371. package/dist/work-items/split-migration.js +1 -0
  372. package/dist/work-items/split-migration.js.map +1 -1
  373. package/dist/workspace.d.ts.map +1 -1
  374. package/dist/workspace.js +53 -10
  375. package/dist/workspace.js.map +1 -1
  376. package/factory-skills/configure-factory-rules/SKILL.md +11 -9
  377. package/factory-skills/factory-build/SKILL.md +64 -0
  378. package/factory-skills/factory-gitlab-rereview/SKILL.md +1 -1
  379. package/factory-skills/factory-gitlab-review/SKILL.md +2 -2
  380. package/factory-skills/factory-plan/SKILL.md +8 -10
  381. package/factory-skills/factory-rereview/SKILL.md +3 -3
  382. package/factory-skills/factory-review/SKILL.md +14 -4
  383. package/factory-skills/factory-self-review/SKILL.md +31 -11
  384. package/factory-skills/factory-triage/SKILL.md +25 -10
  385. package/package.json +9 -9
  386. package/dist/boards/index.js.map +0 -1
  387. package/dist/boards/pull-request-review.d.ts +0 -14
  388. package/dist/boards/pull-request-review.d.ts.map +0 -1
  389. package/dist/boards/pull-request-review.js +0 -81
  390. package/dist/boards/pull-request-review.js.map +0 -1
  391. package/dist/boards/work-tool-rules.d.ts +0 -8
  392. package/dist/boards/work-tool-rules.d.ts.map +0 -1
  393. package/dist/boards/work-tool-rules.js +0 -19
  394. package/dist/boards/work-tool-rules.js.map +0 -1
  395. package/dist/rules/resolve.d.ts +0 -15
  396. package/dist/rules/resolve.d.ts.map +0 -1
  397. package/dist/rules/resolve.js +0 -22
  398. package/dist/rules/resolve.js.map +0 -1
  399. package/factory-skills/factory-complete-issue/SKILL.md +0 -24
@@ -1,7 +1,6 @@
1
1
  import { cardRuleGroupSchema, evaluateRuleGroup } from "../rules/rule-group.js";
2
- import { FACTORY_GITHUB_EVENTS, FACTORY_GITLAB_EVENTS, FACTORY_INCIDENTIO_EVENTS, FACTORY_JIRA_EVENTS, FACTORY_LINEAR_EVENTS, FACTORY_RULE_SOURCES } from "../rules/types.js";
2
+ import { FACTORY_GITHUB_EVENTS, FACTORY_GITLAB_EVENTS, FACTORY_INCIDENTIO_EVENTS, FACTORY_JIRA_EVENTS, FACTORY_LINEAR_EVENTS } from "../rules/types.js";
3
3
  import { IDENTIFIER_RE, SKILL_NAME_RE, isBoardIdentifier } from "../rules/validation.js";
4
- import { addInstructions, startSkill } from "./phase-runner.js";
5
4
  import { CODE_AGENT_ID } from "@mastra/code-sdk/constants";
6
5
  // src/boards/define-board.ts
7
6
  const BOARD_EVENT_NAMES = {
@@ -15,6 +14,14 @@ const BOARD_EVENT_NAMES = {
15
14
  const FACTORY_AGENT_ID = CODE_AGENT_ID;
16
15
  /** The session context a working phase runs in when it names none. */
17
16
  const DEFAULT_PHASE_CONTEXT = "work";
17
+ /**
18
+ * Seat review runs sit in. Review skills load only in it, it is the only seat granted the verdict
19
+ * tool, and its sessions check out code the author wrote, so they never trust that checkout's
20
+ * instruction files. A runner context, not a phase key: any board's phases may run in it.
21
+ */
22
+ const REVIEW_CONTEXT = "review";
23
+ /** Factory tools a working phase grants the session that works the card there. */
24
+ const FACTORY_PHASE_TOOLS = ["factory_record_review_verdict", "factory_review_source"];
18
25
  var BoardDefinitionError = class extends Error {
19
26
  name = "BoardDefinitionError";
20
27
  };
@@ -29,12 +36,16 @@ function validateBoardIdentifier(value, label) {
29
36
  const MAX_NAME_LENGTH = 128;
30
37
  const MAX_DESCRIPTION_LENGTH = 2e3;
31
38
  const MAX_INSTRUCTIONS_LENGTH = 1e3;
39
+ const MAX_GOAL_OBJECTIVE_LENGTH = 2e3;
40
+ const MAX_GOAL_RUNS = 50;
32
41
  const RUNNER_KEYS = /* @__PURE__ */ new Set([
33
42
  "agentId",
34
43
  "skill",
35
44
  "context",
36
- "instructions"
45
+ "instructions",
46
+ "goal"
37
47
  ]);
48
+ const GOAL_KEYS = /* @__PURE__ */ new Set(["objective", "maxRuns"]);
38
49
  const EXIT_TOOL_KEYS = /* @__PURE__ */ new Set([
39
50
  "id",
40
51
  "autoApprove",
@@ -44,9 +55,17 @@ const WORKING_ONLY_FIELDS = [
44
55
  "runner",
45
56
  "autoStart",
46
57
  "autoStartWhen",
47
- "exitTool"
58
+ "exitTool",
59
+ "tools"
48
60
  ];
49
61
  const MOVE_TOOL = "factory_transition_work_item";
62
+ function resolvePhaseTools(label, value) {
63
+ if (value === void 0) return void 0;
64
+ if (!Array.isArray(value)) throw new BoardDefinitionError(`${label} tools must be a list of Factory tool names.`);
65
+ for (const tool of value) if (!FACTORY_PHASE_TOOLS.includes(tool)) throw new BoardDefinitionError(`${label} tools: ${String(tool)} is not a Factory phase tool.`);
66
+ const tools = [...new Set(value)];
67
+ return tools.length ? Object.freeze(tools) : void 0;
68
+ }
50
69
  /** `name`, falling back to the deprecated `title`; both may be set only to the same text. */
51
70
  function resolveName(name, title, label) {
52
71
  if (name !== void 0 && title !== void 0 && name !== title) throw new BoardDefinitionError(`${label} sets both name and title; drop the deprecated title.`);
@@ -70,7 +89,7 @@ function isContext(value) {
70
89
  }
71
90
  function resolveRunner(phaseId, phase) {
72
91
  const runner = phase.runner ?? {};
73
- if (!isPlainObject(runner) || Object.keys(runner).some((key) => !RUNNER_KEYS.has(key))) throw new BoardDefinitionError(`Phase "${phaseId}" runner may only set agentId, skill, context and instructions.`);
92
+ if (!isPlainObject(runner) || Object.keys(runner).some((key) => !RUNNER_KEYS.has(key))) throw new BoardDefinitionError(`Phase "${phaseId}" runner may only set agentId, skill, context, instructions and goal.`);
74
93
  const role = phase.role;
75
94
  if (role !== void 0 && runner.context !== void 0 && role !== runner.context) throw new BoardDefinitionError(`Phase "${phaseId}" sets both role and runner.context; drop the deprecated role.`);
76
95
  const context = runner.context ?? role ?? "work";
@@ -80,11 +99,26 @@ function resolveRunner(phaseId, phase) {
80
99
  const skill = runner.skill;
81
100
  if (skill !== void 0 && (typeof skill !== "string" || skill.length > 128 || !SKILL_NAME_RE.test(skill))) throw new BoardDefinitionError(`Phase "${phaseId}" runner.skill must be a skill name.`);
82
101
  const instructions = optionalText(runner.instructions, `Phase "${phaseId}" runner.instructions`, MAX_INSTRUCTIONS_LENGTH);
102
+ const goal = resolveGoal(phaseId, runner.goal);
103
+ if (goal !== void 0 && skill === void 0) throw new BoardDefinitionError(`Phase "${phaseId}" runner.goal needs runner.skill: the skill's run pursues the goal.`);
83
104
  return Object.freeze({
84
105
  agentId,
85
106
  context,
86
107
  ...skill !== void 0 ? { skill } : {},
87
- ...instructions !== void 0 ? { instructions } : {}
108
+ ...instructions !== void 0 ? { instructions } : {},
109
+ ...goal !== void 0 ? { goal } : {}
110
+ });
111
+ }
112
+ function resolveGoal(phaseId, value) {
113
+ if (value === void 0) return void 0;
114
+ if (!isPlainObject(value) || Object.keys(value).some((key) => !GOAL_KEYS.has(key))) throw new BoardDefinitionError(`Phase "${phaseId}" runner.goal may only set objective and maxRuns.`);
115
+ const objective = optionalText(value.objective, `Phase "${phaseId}" runner.goal.objective`, MAX_GOAL_OBJECTIVE_LENGTH);
116
+ if (objective === void 0) throw new BoardDefinitionError(`Phase "${phaseId}" runner.goal must state an objective.`);
117
+ const maxRuns = value.maxRuns;
118
+ if (maxRuns !== void 0 && (typeof maxRuns !== "number" || !Number.isInteger(maxRuns) || maxRuns < 1 || maxRuns > MAX_GOAL_RUNS)) throw new BoardDefinitionError(`Phase "${phaseId}" runner.goal.maxRuns must be a whole number from 1 to ${MAX_GOAL_RUNS}.`);
119
+ return Object.freeze({
120
+ objective,
121
+ ...maxRuns !== void 0 ? { maxRuns } : {}
88
122
  });
89
123
  }
90
124
  function resolveExitTool(phaseId, value) {
@@ -160,13 +194,6 @@ function validateEventRules(events) {
160
194
  }
161
195
  return Object.freeze(frozen);
162
196
  }
163
- /** The phase's `onEnter` handlers, with its runner's skill for other sources and its instructions on every run. */
164
- function phaseEnterHandlers(declared, runner) {
165
- const handlers = { ...declared };
166
- if (runner.skill) for (const source of FACTORY_RULE_SOURCES) handlers[source] ??= startSkill(runner.skill, runner.context);
167
- if (runner.instructions) for (const source of Object.keys(handlers)) handlers[source] = addInstructions(handlers[source], runner.instructions);
168
- return Object.keys(handlers).length > 0 ? handlers : void 0;
169
- }
170
197
  const warnedBoards = /* @__PURE__ */ new Set();
171
198
  /**
172
199
  * Deprecated fields a board declaration still relies on; `defineBoard()` maps each to its
@@ -181,15 +208,26 @@ function deprecatedFields(config) {
181
208
  if (phase.title !== void 0 && phase.name === void 0) found.push(`phases.${phaseId}.title → name`);
182
209
  if (phase.next !== void 0 && !phase.nextPhases?.includes(phase.next)) found.push(`phases.${phaseId}.next → nextPhases`);
183
210
  if (phase.role !== void 0 && phase.runner?.context === void 0) found.push(`phases.${phaseId}.role → runner.context`);
211
+ if (phase.outcomes !== void 0) found.push(`phases.${phaseId}.outcomes → nextPhases`);
184
212
  }
185
213
  return found;
186
214
  }
215
+ /** Fields a board declaration still passes that Factory no longer reads. */
216
+ function ignoredFields(config) {
217
+ const found = [];
218
+ for (const [phaseId, phase] of Object.entries(config.phases)) for (const field of ["onEnter", "onExit"]) if (phase[field] !== void 0) found.push(`phases.${phaseId}.${field}`);
219
+ return found;
220
+ }
187
221
  function warnDeprecatedFields(config) {
188
222
  if (warnedBoards.has(config.id)) return;
189
223
  const found = deprecatedFields(config);
190
- if (found.length === 0) return;
224
+ const ignored = ignoredFields(config);
225
+ if (found.length === 0 && ignored.length === 0) return;
191
226
  warnedBoards.add(config.id);
192
- console.warn(`[Mastra Factory] Board "${config.id}" uses deprecated fields: ${found.join(", ")}. They still work but will be removed in a future release.`);
227
+ const warnings = [];
228
+ if (found.length > 0) warnings.push(`uses deprecated fields: ${found.join(", ")}. They still work but will be removed in a future release.`);
229
+ if (ignored.length > 0) warnings.push(`declares ${ignored.join(", ")}, which are ignored; use runner.skill to start a phase's run.`);
230
+ console.warn(`[Mastra Factory] Board "${config.id}" ${warnings.join(" It also ")}`);
193
231
  }
194
232
  /** Marks a board an app declared with the deprecated `defineBoard()`; a copy does not carry it. */
195
233
  const DEFINED_BOARD = Symbol("DefinedBoard");
@@ -209,10 +247,7 @@ function defineBoard(config) {
209
247
  function isDefinedBoard(board) {
210
248
  return DEFINED_BOARD in board;
211
249
  }
212
- /**
213
- * The declaration a board was built from. A resolved board's `onEnter` handlers already carry its
214
- * runner's skill and instructions, so a board with other runner fields is rebuilt from this.
215
- */
250
+ /** The declaration a board was built from, so a stored definition can reuse its code behaviour. */
216
251
  const BOARD_DECLARATION = Symbol("BoardDeclaration");
217
252
  /** On a board built from a stored definition, the code board that gave it its behaviour. */
218
253
  const CODE_BOARD = Symbol("CodeBoard");
@@ -249,16 +284,13 @@ function buildBoard(config, defined, codeBoard) {
249
284
  warnDeprecatedFields(config);
250
285
  const sourceClosed = validateSourceClosed(config.sourceClosed, config.phases);
251
286
  const transitions = Object.fromEntries(Object.entries(config.phases).map(([phaseId, phase]) => {
252
- if (phase.next !== void 0 && phase.outcomes) throw new BoardDefinitionError(`Phase "${phaseId}" cannot define both next and outcomes.`);
253
287
  if (phase.nextPhases !== void 0 && !Array.isArray(phase.nextPhases)) throw new BoardDefinitionError(`Phase "${phaseId}" nextPhases must be a list of phases.`);
254
- const targets = phase.next !== void 0 ? [Object.freeze({
255
- outcome: null,
256
- to: phase.next
257
- })] : Object.entries(phase.outcomes ?? {}).map(([outcome, to]) => Object.freeze({
258
- outcome,
259
- to
260
- }));
261
- for (const to of phase.nextPhases ?? []) if (!targets.some((target) => target.to === to)) targets.push(Object.freeze({
288
+ const targets = [];
289
+ for (const to of [
290
+ ...phase.next !== void 0 ? [phase.next] : [],
291
+ ...Object.values(phase.outcomes ?? {}),
292
+ ...phase.nextPhases ?? []
293
+ ]) if (!targets.some((target) => target.to === to)) targets.push(Object.freeze({
262
294
  outcome: null,
263
295
  to
264
296
  }));
@@ -274,8 +306,8 @@ function buildBoard(config, defined, codeBoard) {
274
306
  const autoStartWhen = ruleGroup(working?.autoStartWhen, `${label} autoStartWhen`);
275
307
  if (autoStartWhen && working?.autoStart !== true) throw new BoardDefinitionError(`${label} autoStartWhen needs autoStart.`);
276
308
  const exitTool = resolveExitTool(phaseId, working?.exitTool);
309
+ const tools = resolvePhaseTools(label, working?.tools);
277
310
  if (exitTool && nextPhases.length === 0) throw new BoardDefinitionError(`${label} exit tool needs a next phase to move the card to.`);
278
- const onEnter = runner ? phaseEnterHandlers(phase.onEnter, runner) : phase.onEnter;
279
311
  const name = resolveName(phase.name, phase.title, label);
280
312
  const description = optionalText(phase.description, `${label} description`, MAX_DESCRIPTION_LENGTH);
281
313
  return [phaseId, Object.freeze({
@@ -285,7 +317,6 @@ function buildBoard(config, defined, codeBoard) {
285
317
  kind: phase.kind,
286
318
  nextPhases,
287
319
  ...phase.next !== void 0 ? { next: phase.next } : {},
288
- ...phase.outcomes ? { outcomes: Object.freeze({ ...phase.outcomes }) } : {},
289
320
  ...runner ? {
290
321
  runner,
291
322
  role: runner.context
@@ -293,18 +324,9 @@ function buildBoard(config, defined, codeBoard) {
293
324
  ...working?.autoStart ? { autoStart: true } : {},
294
325
  ...autoStartWhen ? { autoStartWhen } : {},
295
326
  ...exitTool ? { exitTool } : {},
296
- ...onEnter ? { onEnter: Object.freeze({ ...onEnter }) } : {},
297
- ...phase.onExit ? { onExit: Object.freeze({ ...phase.onExit }) } : {}
327
+ ...tools ? { tools } : {}
298
328
  })];
299
329
  })));
300
- const rules = Object.freeze(Object.fromEntries(Object.entries(phases).flatMap(([phaseId, phase]) => {
301
- const sources = /* @__PURE__ */ new Set([...Object.keys(phase.onEnter ?? {}), ...Object.keys(phase.onExit ?? {})]);
302
- if (sources.size === 0) return [];
303
- return [[phaseId, Object.freeze(Object.fromEntries([...sources].map((source) => [source, Object.freeze({
304
- ...phase.onEnter?.[source] ? { onEnter: phase.onEnter[source] } : {},
305
- ...phase.onExit?.[source] ? { onExit: phase.onExit[source] } : {}
306
- })])))]];
307
- })));
308
330
  const kinds = /* @__PURE__ */ new Map();
309
331
  const roles = /* @__PURE__ */ new Map();
310
332
  const phaseByRole = /* @__PURE__ */ new Map();
@@ -322,12 +344,12 @@ function buildBoard(config, defined, codeBoard) {
322
344
  initialPhase: config.initialPhase,
323
345
  phases,
324
346
  transitions: Object.freeze(transitions),
325
- rules: Object.freeze(rules),
326
347
  tools,
327
348
  events,
328
349
  ...config.transitionPolicy ? { transitionPolicy: config.transitionPolicy } : {},
329
350
  ...sourceClosed ? { sourceClosed } : {},
330
351
  allowsTransition(from, to) {
352
+ if (!kinds.has(from) || !kinds.has(to)) return false;
331
353
  return from === to || transitions[from]?.some((transition) => transition.to === to) === true;
332
354
  },
333
355
  phaseKind: (phase) => kinds.get(phase),
@@ -347,6 +369,6 @@ function buildBoard(config, defined, codeBoard) {
347
369
  if (codeBoard) Object.defineProperty(board, CODE_BOARD, { value: codeBoardOf(codeBoard) });
348
370
  return Object.freeze(board);
349
371
  }
350
- export { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, codeBoardOf, compileBoardDefinition, declarationOf, defineBoard, isDefinedBoard };
372
+ export { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, FACTORY_PHASE_TOOLS, REVIEW_CONTEXT, codeBoardOf, compileBoardDefinition, declarationOf, defineBoard, isDefinedBoard };
351
373
 
352
374
  //# sourceMappingURL=define-board.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"define-board.js","names":[],"sources":["../../src/boards/define-board.ts"],"sourcesContent":["import { CODE_AGENT_ID } from '@mastra/code-sdk/constants';\nimport { cardRuleGroupSchema, evaluateRuleGroup } from '../rules/rule-group.js';\nimport type { RuleFacts, RuleGroup } from '../rules/rule-group.js';\nimport {\n FACTORY_GITHUB_EVENTS,\n FACTORY_RULE_SOURCES,\n FACTORY_GITLAB_EVENTS,\n FACTORY_INCIDENTIO_EVENTS,\n FACTORY_JIRA_EVENTS,\n FACTORY_LINEAR_EVENTS,\n} from '../rules/types.js';\nimport type {\n FactoryGithubEventName,\n FactoryGithubRuleContext,\n FactoryGitLabEventName,\n FactoryGitLabRuleContext,\n FactoryIncidentioEventName,\n FactoryIncidentioRuleContext,\n FactoryJiraEventName,\n FactoryJiraRuleContext,\n FactoryLinearEventName,\n FactoryLinearRuleContext,\n FactoryRuleHandler,\n FactoryRuleSource,\n FactoryStageRuleContext,\n FactoryToolResultRuleContext,\n} from '../rules/types.js';\nimport {\n IDENTIFIER_RE,\n isBoardIdentifier,\n MAX_ROLE_LENGTH,\n MAX_SKILL_NAME_LENGTH,\n MAX_TOOL_NAME_LENGTH,\n SKILL_NAME_RE,\n} from '../rules/validation.js';\nimport { addInstructions, startSkill } from './phase-runner.js';\nimport type { BoardTransitionPolicy } from './transition-policy.js';\n\ntype BoardPhaseHandlers = Partial<Record<FactoryRuleSource, FactoryRuleHandler<FactoryStageRuleContext>>>;\ntype ReadonlyBoardPhaseHandlers = Readonly<BoardPhaseHandlers>;\n\n/** Runs when an agent seated on this board completes the named tool. */\nexport type BoardToolResultRuleHandler = FactoryRuleHandler<FactoryToolResultRuleContext>;\nexport type BoardToolRule = { readonly onResult: BoardToolResultRuleHandler };\nexport type BoardToolRules = Readonly<Record<string, BoardToolRule>>;\n\n/**\n * A board's handler for one integration event. `null` switches the integration default off\n * for cards on this board only.\n */\ntype BoardEventHandlerMap<EventName extends string, Context> = Readonly<\n Partial<Record<EventName, FactoryRuleHandler<Context> | null>>\n>;\n\n/**\n * How cards on this board react to integration events, keyed by integration then event.\n * Consulted for events bound to a card on this board, after any handler the deployment set\n * explicitly on the integration and before the integration default.\n */\nexport interface BoardEventRules {\n readonly github?: BoardEventHandlerMap<FactoryGithubEventName, FactoryGithubRuleContext>;\n readonly gitlab?: BoardEventHandlerMap<FactoryGitLabEventName, FactoryGitLabRuleContext>;\n readonly linear?: BoardEventHandlerMap<FactoryLinearEventName, FactoryLinearRuleContext>;\n readonly jira?: BoardEventHandlerMap<FactoryJiraEventName, FactoryJiraRuleContext>;\n readonly incidentio?: BoardEventHandlerMap<FactoryIncidentioEventName, FactoryIncidentioRuleContext>;\n}\nexport type BoardEventIntegration = keyof BoardEventRules;\n\nconst BOARD_EVENT_NAMES: Readonly<Record<BoardEventIntegration, readonly string[]>> = {\n github: FACTORY_GITHUB_EVENTS,\n gitlab: FACTORY_GITLAB_EVENTS,\n linear: FACTORY_LINEAR_EVENTS,\n jira: FACTORY_JIRA_EVENTS,\n incidentio: FACTORY_INCIDENTIO_EVENTS,\n};\n\ntype ReadonlyFactoryBoardRules = Readonly<\n Record<\n string,\n Readonly<\n Partial<\n Record<\n FactoryRuleSource,\n Readonly<{\n onEnter?: FactoryRuleHandler<FactoryStageRuleContext>;\n onExit?: FactoryRuleHandler<FactoryStageRuleContext>;\n }>\n >\n >\n >\n >\n>;\n\n/**\n * What a phase means to the runtime.\n * - `resting`: nobody is seated; a card waits for a person or an event.\n * - `working`: an agent in the phase's context carries the card; a person's move in arms autonomy.\n * - `terminal`: the card is finished; sessions stop and held resources are released.\n */\nexport type BoardPhaseKind = 'resting' | 'working' | 'terminal';\n\n/** The agent Factory runs every phase with. */\nexport const FACTORY_AGENT_ID = CODE_AGENT_ID;\n\n/** The session context a working phase runs in when it names none. */\nexport const DEFAULT_PHASE_CONTEXT = 'work';\n\n/** Who runs a working phase, and with what. */\nexport interface BoardPhaseRunner {\n /** Must be `code-agent`, the agent Factory runs; omitted means that agent. */\n readonly agentId?: string;\n /** Skill started when a card enters the phase from a source with no `onEnter` handler. */\n readonly skill?: string;\n /**\n * The session the phase runs in. Phases naming the same context share one session per card;\n * a different context gets its own. Defaults to `work`.\n */\n readonly context?: string;\n /** Appended to every run the phase starts. */\n readonly instructions?: string;\n}\n\n/**\n * The tool whose successful call ends a working phase. The agent then moves the card itself with\n * `factory_transition_work_item`, to one of the phase's `nextPhases`.\n */\nexport interface BoardPhaseExitTool {\n readonly id: string;\n /**\n * Answer the approval the tool waits for without a person. Factory sessions run other tools\n * without asking, so today this applies to `submit_plan`. Defaults to false.\n */\n readonly autoApprove?: boolean;\n /** With `autoApprove`, only cards this matches are approved without a person. */\n readonly autoApproveWhen?: RuleGroup;\n}\n\ntype BoardPhaseBase<PhaseId extends string> = {\n readonly name?: string;\n /** @deprecated Use `name`. */\n readonly title?: string;\n readonly description?: string;\n /** Phases a card may move to from here. */\n readonly nextPhases?: readonly PhaseId[];\n /** @deprecated List the phase in `nextPhases`. */\n readonly next?: PhaseId;\n /** Named moves rules can choose by outcome; each target is also an allowed next phase. */\n readonly outcomes?: Readonly<Record<string, PhaseId>>;\n readonly onEnter?: ReadonlyBoardPhaseHandlers;\n readonly onExit?: ReadonlyBoardPhaseHandlers;\n};\n\ntype WorkingPhaseFields = {\n readonly runner?: BoardPhaseRunner;\n /** @deprecated Use `runner.context`. */\n readonly role?: string;\n /** Runs start without anyone approving them, even with the project's auto-run off. */\n readonly autoStart?: boolean;\n /** With `autoStart`, only cards this matches start on their own. */\n readonly autoStartWhen?: RuleGroup;\n /** A bare tool name is shorthand for `{ id }`, with nothing approved on a person's behalf. */\n readonly exitTool?: string | BoardPhaseExitTool;\n};\n\ntype NonWorkingPhaseFields = {\n readonly runner?: never;\n readonly role?: never;\n readonly autoStart?: never;\n readonly autoStartWhen?: never;\n readonly exitTool?: never;\n};\n\n/** A phase as a board declares it. */\nexport type BoardPhaseDefinition<PhaseId extends string> =\n | (BoardPhaseBase<PhaseId> & NonWorkingPhaseFields & { readonly kind: 'resting' })\n | (BoardPhaseBase<PhaseId> & WorkingPhaseFields & { readonly kind: 'working' })\n | (BoardPhaseBase<PhaseId> & NonWorkingPhaseFields & { readonly kind: 'terminal' });\n\ntype ResolvedPhaseBase<PhaseId extends string> = {\n readonly name: string;\n /** @deprecated Use `name`; kept equal to it for code written against older Factory versions. */\n readonly title: string;\n readonly description?: string;\n /** Every phase a card may move to from here, including outcome targets. */\n readonly nextPhases: readonly PhaseId[];\n /** @deprecated Use `nextPhases`; set when the phase declared `next`. */\n readonly next?: PhaseId;\n readonly outcomes?: Readonly<Record<string, PhaseId>>;\n readonly onEnter?: ReadonlyBoardPhaseHandlers;\n readonly onExit?: ReadonlyBoardPhaseHandlers;\n};\n\n/**\n * A phase as the board resolved it: deprecated fields are replaced by their new names, so\n * only the new structure leaves `defineBoard()`, and a resolved phase can be declared again.\n */\nexport type BoardPhase<PhaseId extends string> =\n | (ResolvedPhaseBase<PhaseId> & { readonly kind: 'resting' })\n | (ResolvedPhaseBase<PhaseId> & {\n readonly kind: 'working';\n readonly runner: Readonly<BoardPhaseRunner & { agentId: string; context: string }>;\n /** @deprecated Use `runner.context`; kept equal to it. */\n readonly role: string;\n readonly autoStart?: boolean;\n readonly autoStartWhen?: RuleGroup;\n readonly exitTool?: Readonly<{ id: string; autoApprove: boolean; autoApproveWhen?: RuleGroup }>;\n })\n | (ResolvedPhaseBase<PhaseId> & { readonly kind: 'terminal' });\n\ntype ResolvedRunner = Extract<BoardPhase<string>, { kind: 'working' }>['runner'];\ntype ResolvedExitTool = Extract<BoardPhase<string>, { kind: 'working' }>['exitTool'];\n\nexport interface BoardTransition<PhaseId extends string> {\n readonly outcome: string | null;\n readonly to: PhaseId;\n}\n\n/**\n * Terminal phases a card moves to when its tracked source (issue or follow-up) closes.\n * `completed` is used when the source was completed, `canceled` when it was canceled or not planned.\n */\nexport type BoardSourceClosed<PhaseId extends string> = Readonly<{ completed: PhaseId; canceled: PhaseId }>;\n\nexport interface BoardDefinition<BoardId extends string, PhaseId extends string> {\n readonly id: BoardId;\n readonly name: string;\n /** @deprecated Use `name`; kept equal to it for code written against older Factory versions. */\n readonly title: string;\n readonly description?: string;\n readonly initialPhase: PhaseId;\n readonly phases: Readonly<Record<PhaseId, BoardPhase<PhaseId>>>;\n readonly transitions: Readonly<Record<PhaseId, readonly BoardTransition<PhaseId>[]>>;\n readonly rules: ReadonlyFactoryBoardRules;\n /** Tool-result rules keyed by tool name; empty when the board declares none. */\n readonly tools: BoardToolRules;\n /** Integration event handlers for cards on this board; empty when the board declares none. */\n readonly events: BoardEventRules;\n /** @deprecated Express the flow with each phase's `nextPhases` and `exitTool`; still enforced when set. */\n readonly transitionPolicy?: BoardTransitionPolicy;\n /** Where source-closed rules move a card; absent when the board opts out of auto-closing. */\n readonly sourceClosed?: BoardSourceClosed<PhaseId>;\n allowsTransition(from: PhaseId, to: PhaseId): boolean;\n /** Declared kind of a phase, or undefined when the board has no such phase. */\n phaseKind(phase: string): BoardPhaseKind | undefined;\n isWorking(phase: string): boolean;\n isTerminal(phase: string): boolean;\n /** Session context of a working phase; undefined for resting/terminal/unknown phases. */\n roleForPhase(phase: string): string | undefined;\n /** First working phase, in declaration order, running in `role`'s context. */\n phaseForRole(role: string): PhaseId | undefined;\n /**\n * Whether the phase's runs start without anyone approving them, for a card with these facts\n * (`cardRuleFacts`). A phase with a start condition never starts on its own without facts.\n */\n startsAutomatically(phase: string, facts?: RuleFacts): boolean;\n}\n\ntype BoardConfig<BoardId extends string, Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>> = {\n id: BoardId;\n name?: string;\n /** @deprecated Use `name`. */\n title?: string;\n description?: string;\n initialPhase: keyof Phases & string;\n phases: Phases;\n tools?: Record<string, BoardToolRule>;\n events?: BoardEventRules;\n /** @deprecated Express the flow with each phase's `nextPhases` and `exitTool`; still enforced when set. */\n transitionPolicy?: BoardTransitionPolicy;\n sourceClosed?: { completed: keyof Phases & string; canceled: keyof Phases & string };\n};\n\nexport class BoardDefinitionError extends Error {\n override name = 'BoardDefinitionError';\n}\n\nconst PHASE_KINDS: ReadonlySet<string> = new Set<BoardPhaseKind>(['resting', 'working', 'terminal']);\n\nfunction validateBoardIdentifier(value: unknown, label: string): void {\n if (!isBoardIdentifier(value)) {\n throw new BoardDefinitionError(`${label} must be a valid board identifier.`);\n }\n}\n\nconst MAX_NAME_LENGTH = 128;\nconst MAX_DESCRIPTION_LENGTH = 2_000;\nconst MAX_INSTRUCTIONS_LENGTH = 1_000;\nconst RUNNER_KEYS: ReadonlySet<string> = new Set(['agentId', 'skill', 'context', 'instructions']);\nconst EXIT_TOOL_KEYS: ReadonlySet<string> = new Set(['id', 'autoApprove', 'autoApproveWhen']);\nconst WORKING_ONLY_FIELDS = ['runner', 'autoStart', 'autoStartWhen', 'exitTool'] as const;\nconst MOVE_TOOL = 'factory_transition_work_item';\n\n/** `name`, falling back to the deprecated `title`; both may be set only to the same text. */\nfunction resolveName(name: unknown, title: unknown, label: string): string {\n if (name !== undefined && title !== undefined && name !== title) {\n throw new BoardDefinitionError(`${label} sets both name and title; drop the deprecated title.`);\n }\n const value = name ?? title;\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > MAX_NAME_LENGTH) {\n throw new BoardDefinitionError(`${label} must declare a name.`);\n }\n return value;\n}\n\nfunction optionalText(value: unknown, label: string, max: number): string | undefined {\n if (value === undefined) return undefined;\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > max) {\n throw new BoardDefinitionError(`${label} must be non-empty text of at most ${max} characters.`);\n }\n return value;\n}\n\nfunction ruleGroup(value: unknown, label: string): RuleGroup | undefined {\n if (value === undefined) return undefined;\n const parsed = cardRuleGroupSchema.safeParse(value);\n if (!parsed.success) {\n throw new BoardDefinitionError(`${label} is not a valid condition: ${parsed.error.issues[0]?.message}`);\n }\n return parsed.data;\n}\n\nfunction isContext(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0 && value.length <= MAX_ROLE_LENGTH && IDENTIFIER_RE.test(value);\n}\n\nfunction resolveRunner(phaseId: string, phase: BoardPhaseDefinition<string>): ResolvedRunner {\n const runner: unknown = phase.runner ?? {};\n if (!isPlainObject(runner) || Object.keys(runner).some(key => !RUNNER_KEYS.has(key))) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" runner may only set agentId, skill, context and instructions.`);\n }\n const role: unknown = phase.role;\n if (role !== undefined && runner.context !== undefined && role !== runner.context) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" sets both role and runner.context; drop the deprecated role.`);\n }\n const context = runner.context ?? role ?? DEFAULT_PHASE_CONTEXT;\n if (!isContext(context)) throw new BoardDefinitionError(`Working phase \"${phaseId}\" must declare a valid context.`);\n const agentId = runner.agentId ?? FACTORY_AGENT_ID;\n if (agentId !== FACTORY_AGENT_ID) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" names unknown agent \"${String(agentId)}\"; Factory runs \"${FACTORY_AGENT_ID}\".`,\n );\n }\n const skill = runner.skill;\n if (\n skill !== undefined &&\n (typeof skill !== 'string' || skill.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_RE.test(skill))\n ) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" runner.skill must be a skill name.`);\n }\n const instructions = optionalText(\n runner.instructions,\n `Phase \"${phaseId}\" runner.instructions`,\n MAX_INSTRUCTIONS_LENGTH,\n );\n return Object.freeze({\n agentId,\n context,\n ...(skill !== undefined ? { skill } : {}),\n ...(instructions !== undefined ? { instructions } : {}),\n });\n}\n\nfunction resolveExitTool(phaseId: string, value: unknown): ResolvedExitTool {\n if (value === undefined) return undefined;\n const declared = typeof value === 'string' ? { id: value } : value;\n if (!isPlainObject(declared) || Object.keys(declared).some(key => !EXIT_TOOL_KEYS.has(key))) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" exitTool must be a tool name or { id, autoApprove, autoApproveWhen }.`,\n );\n }\n const { id, autoApprove = false } = declared;\n if (typeof id !== 'string' || id.length === 0 || id.length > MAX_TOOL_NAME_LENGTH || !IDENTIFIER_RE.test(id)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool has an invalid tool name.`);\n }\n if (id === MOVE_TOOL) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" cannot end with ${MOVE_TOOL}: that tool already moves the card.`,\n );\n }\n if (typeof autoApprove !== 'boolean') {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool.autoApprove must be a boolean.`);\n }\n const autoApproveWhen = ruleGroup(declared.autoApproveWhen, `Phase \"${phaseId}\" exitTool.autoApproveWhen`);\n if (autoApproveWhen && !autoApprove) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool.autoApproveWhen needs autoApprove.`);\n }\n return Object.freeze({ id, autoApprove, ...(autoApproveWhen ? { autoApproveWhen } : {}) });\n}\n\nfunction validatePhaseSemantics(phaseId: string, phase: BoardPhaseDefinition<string>): void {\n if (!PHASE_KINDS.has(phase.kind as string)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" must declare kind 'resting', 'working', or 'terminal'.`);\n }\n if (phase.kind === 'working') return;\n if ((phase as { role?: unknown }).role !== undefined) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" is ${phase.kind} and cannot declare a role.`);\n }\n for (const field of WORKING_ONLY_FIELDS) {\n if ((phase as Record<string, unknown>)[field] !== undefined) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" is ${phase.kind} and cannot declare ${field}.`);\n }\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction validateToolRules(tools: unknown): BoardToolRules {\n if (tools === undefined) return Object.freeze({});\n if (!isPlainObject(tools)) throw new BoardDefinitionError('Board tools must be a plain object.');\n const frozen: Record<string, BoardToolRule> = {};\n for (const [toolName, leaf] of Object.entries(tools)) {\n if (toolName.length === 0 || toolName.length > MAX_TOOL_NAME_LENGTH || !IDENTIFIER_RE.test(toolName)) {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" has an invalid tool name.`);\n }\n if (!isPlainObject(leaf) || Object.keys(leaf).some(key => key !== 'onResult')) {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" must be an object with only onResult.`);\n }\n if (typeof leaf.onResult !== 'function') {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" must declare an onResult function.`);\n }\n frozen[toolName] = Object.freeze({ onResult: leaf.onResult as BoardToolResultRuleHandler });\n }\n return Object.freeze(frozen);\n}\n\nfunction validateSourceClosed(\n sourceClosed: unknown,\n phases: Readonly<Record<string, BoardPhaseDefinition<string>>>,\n): BoardSourceClosed<string> | undefined {\n if (sourceClosed === undefined) return undefined;\n if (!isPlainObject(sourceClosed)) throw new BoardDefinitionError('Board sourceClosed must be a plain object.');\n const keys = Object.keys(sourceClosed);\n if (keys.length !== 2 || !keys.includes('completed') || !keys.includes('canceled')) {\n throw new BoardDefinitionError('Board sourceClosed must declare exactly completed and canceled.');\n }\n for (const key of ['completed', 'canceled'] as const) {\n const phase = sourceClosed[key];\n if (typeof phase !== 'string' || !Object.hasOwn(phases, phase) || phases[phase]!.kind !== 'terminal') {\n throw new BoardDefinitionError(`Board sourceClosed.${key} \"${String(phase)}\" must name a terminal phase.`);\n }\n }\n return Object.freeze({ completed: sourceClosed.completed as string, canceled: sourceClosed.canceled as string });\n}\n\nfunction validateEventRules(events: unknown): BoardEventRules {\n if (events === undefined) return Object.freeze({});\n if (!isPlainObject(events)) throw new BoardDefinitionError('Board events must be a plain object.');\n const frozen: Record<string, Readonly<Record<string, unknown>>> = {};\n for (const [integration, handlers] of Object.entries(events)) {\n const known = Object.hasOwn(BOARD_EVENT_NAMES, integration)\n ? BOARD_EVENT_NAMES[integration as BoardEventIntegration]\n : undefined;\n if (!known) throw new BoardDefinitionError(`Board events name unknown integration \"${integration}\".`);\n if (handlers === undefined) continue;\n if (!isPlainObject(handlers)) {\n throw new BoardDefinitionError(`Board events for \"${integration}\" must be a plain object.`);\n }\n const entries: Record<string, unknown> = {};\n for (const [event, handler] of Object.entries(handlers)) {\n if (!known.includes(event)) {\n throw new BoardDefinitionError(`Board events for \"${integration}\" name unknown event \"${event}\".`);\n }\n if (handler === undefined) continue;\n if (handler !== null && typeof handler !== 'function') {\n throw new BoardDefinitionError(`Board event handler \"${integration}.${event}\" must be a function or null.`);\n }\n entries[event] = handler;\n }\n frozen[integration] = Object.freeze(entries);\n }\n return Object.freeze(frozen) as BoardEventRules;\n}\n\n/** The phase's `onEnter` handlers, with its runner's skill for other sources and its instructions on every run. */\nfunction phaseEnterHandlers(\n declared: ReadonlyBoardPhaseHandlers | undefined,\n runner: ResolvedRunner,\n): ReadonlyBoardPhaseHandlers | undefined {\n const handlers: BoardPhaseHandlers = { ...declared };\n if (runner.skill) {\n for (const source of FACTORY_RULE_SOURCES) handlers[source] ??= startSkill(runner.skill, runner.context);\n }\n if (runner.instructions) {\n for (const source of Object.keys(handlers) as FactoryRuleSource[]) {\n handlers[source] = addInstructions(handlers[source]!, runner.instructions);\n }\n }\n return Object.keys(handlers).length > 0 ? handlers : undefined;\n}\n\nconst warnedBoards = new Set<string>();\n\ntype DeclaredBoard = {\n readonly id: string;\n readonly name?: string;\n readonly title?: string;\n readonly transitionPolicy?: BoardTransitionPolicy;\n readonly phases: Readonly<Record<string, BoardPhaseDefinition<string>>>;\n};\n\n/**\n * Deprecated fields a board declaration still relies on; `defineBoard()` maps each to its\n * replacement. A deprecated field next to its replacement adds nothing, so it is not reported:\n * that is how a resolved board, which carries both, is declared again.\n */\nfunction deprecatedFields(config: DeclaredBoard): string[] {\n const found: string[] = [];\n if (config.title !== undefined && config.name === undefined) found.push('title → name');\n if (config.transitionPolicy !== undefined) found.push('transitionPolicy → phases.*.nextPhases and exitTool');\n for (const [phaseId, phase] of Object.entries(config.phases)) {\n if (phase.title !== undefined && phase.name === undefined) found.push(`phases.${phaseId}.title → name`);\n if (phase.next !== undefined && !phase.nextPhases?.includes(phase.next)) {\n found.push(`phases.${phaseId}.next → nextPhases`);\n }\n if (phase.role !== undefined && phase.runner?.context === undefined) {\n found.push(`phases.${phaseId}.role → runner.context`);\n }\n }\n return found;\n}\n\nfunction warnDeprecatedFields(config: DeclaredBoard): void {\n if (warnedBoards.has(config.id)) return;\n const found = deprecatedFields(config);\n if (found.length === 0) return;\n warnedBoards.add(config.id);\n console.warn(\n `[Mastra Factory] Board \"${config.id}\" uses deprecated fields: ${found.join(', ')}. ` +\n 'They still work but will be removed in a future release.',\n );\n}\n\n/** Marks a board an app declared with the deprecated `defineBoard()`; a copy does not carry it. */\nconst DEFINED_BOARD = Symbol('DefinedBoard');\n\n/**\n * Declares a board in code.\n *\n * @deprecated Write the board's definition into projects with `factory.upsertBoard()`, or manage\n * it through the boards API\n * (`/web/factory/projects/:id/boards`, README \"Stored boards\"); removal is tracked in\n * mastra-ai/mastra#28920. A board defined here still works: each project stores it once and is\n * served from its row, with the code behaviour it declares.\n */\nexport function defineBoard<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(config: BoardConfig<BoardId, Phases>): BoardDefinition<BoardId, keyof Phases & string> {\n return buildBoard(config, true);\n}\n\n/** Whether an app declared the board with the deprecated `defineBoard()`. */\nexport function isDefinedBoard(board: object): boolean {\n return DEFINED_BOARD in board;\n}\n\n/** A board declaration as `defineBoard()` takes it, with any phase keys. */\nexport type AnyBoardConfig = BoardConfig<string, Record<string, BoardPhaseDefinition<string>>>;\n\n/**\n * The declaration a board was built from. A resolved board's `onEnter` handlers already carry its\n * runner's skill and instructions, so a board with other runner fields is rebuilt from this.\n */\nconst BOARD_DECLARATION = Symbol('BoardDeclaration');\n\n/** On a board built from a stored definition, the code board that gave it its behaviour. */\nconst CODE_BOARD = Symbol('CodeBoard');\n\n/** The declaration a board was built from; undefined for an object that was not built as a board. */\nexport function declarationOf(board: object): AnyBoardConfig | undefined {\n return (board as { [BOARD_DECLARATION]?: AnyBoardConfig })[BOARD_DECLARATION];\n}\n\n/** The code board a board takes its behaviour from: itself unless it was built from a stored definition. */\nexport function codeBoardOf<Board extends object>(board: Board): Board {\n return (board as { [CODE_BOARD]?: Board })[CODE_BOARD] ?? board;\n}\n\n/**\n * Validates and resolves a board declaration. Factory's own boards use this directly. A board\n * built from a stored definition names the code board whose behaviour it carries.\n */\nexport function compileBoardDefinition<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(config: BoardConfig<BoardId, Phases>, codeBoard?: object): BoardDefinition<BoardId, keyof Phases & string> {\n return buildBoard(config, false, codeBoard);\n}\n\nfunction buildBoard<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(\n config: BoardConfig<BoardId, Phases>,\n defined: boolean,\n codeBoard?: object,\n): BoardDefinition<BoardId, keyof Phases & string> {\n type PhaseId = keyof Phases & string;\n validateBoardIdentifier(config.id, 'Board id');\n const boardName = resolveName(config.name, config.title, `Board \"${config.id}\"`);\n const boardDescription = optionalText(config.description, `Board \"${config.id}\" description`, MAX_DESCRIPTION_LENGTH);\n if (config.transitionPolicy !== undefined && typeof config.transitionPolicy !== 'function') {\n throw new BoardDefinitionError('Board transitionPolicy must be a function.');\n }\n const tools = validateToolRules(config.tools);\n const events = validateEventRules(config.events);\n const phaseIds = new Set(Object.keys(config.phases));\n if (phaseIds.size === 0) throw new BoardDefinitionError('A board must define at least one phase.');\n if (!phaseIds.has(config.initialPhase)) {\n throw new BoardDefinitionError(`Initial phase \"${config.initialPhase}\" is not defined.`);\n }\n for (const [phaseId, phase] of Object.entries(config.phases)) {\n validateBoardIdentifier(phaseId, 'Phase id');\n validatePhaseSemantics(phaseId, phase);\n }\n if (config.phases[config.initialPhase]!.kind !== 'resting') {\n throw new BoardDefinitionError(`Initial phase \"${config.initialPhase}\" must be a resting phase.`);\n }\n warnDeprecatedFields(config);\n const sourceClosed = validateSourceClosed(config.sourceClosed, config.phases) as\n | BoardSourceClosed<PhaseId>\n | undefined;\n\n const transitions = Object.fromEntries(\n Object.entries(config.phases).map(([phaseId, phase]) => {\n if (phase.next !== undefined && phase.outcomes) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" cannot define both next and outcomes.`);\n }\n if (phase.nextPhases !== undefined && !Array.isArray(phase.nextPhases)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" nextPhases must be a list of phases.`);\n }\n const targets: BoardTransition<string>[] =\n phase.next !== undefined\n ? [Object.freeze({ outcome: null, to: phase.next })]\n : Object.entries(phase.outcomes ?? {}).map(([outcome, to]) => Object.freeze({ outcome, to }));\n for (const to of phase.nextPhases ?? []) {\n if (!targets.some(target => target.to === to)) targets.push(Object.freeze({ outcome: null, to }));\n }\n for (const { to } of targets) {\n if (!phaseIds.has(to)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" targets undefined phase \"${to}\".`);\n }\n }\n return [phaseId, Object.freeze(targets)];\n }),\n ) as Record<PhaseId, readonly BoardTransition<PhaseId>[]>;\n\n const phases = Object.freeze(\n Object.fromEntries(\n Object.entries(config.phases).map(([phaseId, phase]) => {\n const label = `Phase \"${phaseId}\"`;\n const nextPhases = Object.freeze([\n ...new Set([...(phase.nextPhases ?? []), ...transitions[phaseId as PhaseId]!.map(({ to }) => to)]),\n ]);\n const runner = phase.kind === 'working' ? resolveRunner(phaseId, phase) : undefined;\n const working = phase.kind === 'working' ? phase : undefined;\n if (working?.autoStart !== undefined && typeof working.autoStart !== 'boolean') {\n throw new BoardDefinitionError(`${label} autoStart must be a boolean.`);\n }\n const autoStartWhen = ruleGroup(working?.autoStartWhen, `${label} autoStartWhen`);\n if (autoStartWhen && working?.autoStart !== true) {\n throw new BoardDefinitionError(`${label} autoStartWhen needs autoStart.`);\n }\n const exitTool = resolveExitTool(phaseId, working?.exitTool);\n if (exitTool && nextPhases.length === 0) {\n throw new BoardDefinitionError(`${label} exit tool needs a next phase to move the card to.`);\n }\n const onEnter = runner ? phaseEnterHandlers(phase.onEnter, runner) : phase.onEnter;\n const name = resolveName(phase.name, phase.title, label);\n const description = optionalText(phase.description, `${label} description`, MAX_DESCRIPTION_LENGTH);\n return [\n phaseId,\n Object.freeze({\n name,\n title: name,\n ...(description !== undefined ? { description } : {}),\n kind: phase.kind,\n nextPhases,\n ...(phase.next !== undefined ? { next: phase.next } : {}),\n ...(phase.outcomes ? { outcomes: Object.freeze({ ...phase.outcomes }) } : {}),\n ...(runner ? { runner, role: runner.context } : {}),\n ...(working?.autoStart ? { autoStart: true } : {}),\n ...(autoStartWhen ? { autoStartWhen } : {}),\n ...(exitTool ? { exitTool } : {}),\n ...(onEnter ? { onEnter: Object.freeze({ ...onEnter }) } : {}),\n ...(phase.onExit ? { onExit: Object.freeze({ ...phase.onExit }) } : {}),\n }),\n ];\n }),\n ),\n ) as Readonly<Record<PhaseId, BoardPhase<PhaseId>>>;\n const rules = Object.freeze(\n Object.fromEntries(\n (Object.entries(phases) as [PhaseId, BoardPhase<PhaseId>][]).flatMap(([phaseId, phase]) => {\n const sources = new Set([...Object.keys(phase.onEnter ?? {}), ...Object.keys(phase.onExit ?? {})]);\n if (sources.size === 0) return [];\n return [\n [\n phaseId,\n Object.freeze(\n Object.fromEntries(\n [...sources].map(source => [\n source,\n Object.freeze({\n ...(phase.onEnter?.[source as FactoryRuleSource]\n ? { onEnter: phase.onEnter[source as FactoryRuleSource] }\n : {}),\n ...(phase.onExit?.[source as FactoryRuleSource]\n ? { onExit: phase.onExit[source as FactoryRuleSource] }\n : {}),\n }),\n ]),\n ),\n ),\n ],\n ];\n }),\n ),\n ) as ReadonlyFactoryBoardRules;\n\n const kinds = new Map<string, BoardPhaseKind>();\n const roles = new Map<string, string>();\n const phaseByRole = new Map<string, PhaseId>();\n for (const [phaseId, phase] of Object.entries(phases) as [PhaseId, BoardPhase<PhaseId>][]) {\n kinds.set(phaseId, phase.kind);\n if (phase.kind !== 'working') continue;\n roles.set(phaseId, phase.runner.context);\n if (!phaseByRole.has(phase.runner.context)) phaseByRole.set(phase.runner.context, phaseId);\n }\n\n const board = {\n id: config.id,\n name: boardName,\n title: boardName,\n ...(boardDescription !== undefined ? { description: boardDescription } : {}),\n initialPhase: config.initialPhase,\n phases,\n transitions: Object.freeze(transitions),\n rules: Object.freeze(rules),\n tools,\n events,\n ...(config.transitionPolicy ? { transitionPolicy: config.transitionPolicy } : {}),\n ...(sourceClosed ? { sourceClosed } : {}),\n allowsTransition(from: PhaseId, to: PhaseId) {\n return from === to || transitions[from]?.some(transition => transition.to === to) === true;\n },\n phaseKind: (phase: string) => kinds.get(phase),\n isWorking: (phase: string) => kinds.get(phase) === 'working',\n isTerminal: (phase: string) => kinds.get(phase) === 'terminal',\n roleForPhase: (phase: string) => roles.get(phase),\n phaseForRole: (role: string) => phaseByRole.get(role),\n startsAutomatically: (phase: string, facts?: RuleFacts) => {\n const definition = phases[phase as PhaseId] as BoardPhase<PhaseId> | undefined;\n if (definition?.kind !== 'working' || definition.autoStart !== true) return false;\n if (!definition.autoStartWhen) return true;\n return facts !== undefined && evaluateRuleGroup(definition.autoStartWhen, facts);\n },\n };\n if (defined) Object.defineProperty(board, DEFINED_BOARD, { value: true });\n Object.defineProperty(board, BOARD_DECLARATION, { value: config });\n if (codeBoard) Object.defineProperty(board, CODE_BOARD, { value: codeBoardOf(codeBoard) });\n return Object.freeze(board);\n}\n"],"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AAY,IAAI,MAAM,OAAO,SAAS,OAAO;CAC3F;CAEA,MAAM,QAAQ;EACZ,IAAI,OAAO;EACX,MAAM;EACN,OAAO;EACP,GAAI,qBAAqB,KAAA,IAAY,EAAE,aAAa,iBAAiB,IAAI,CAAC;EAC1E,cAAc,OAAO;EACrB;EACA,aAAa,OAAO,OAAO,WAAW;EACtC,OAAO,OAAO,OAAO,KAAK;EAC1B;EACA;EACA,GAAI,OAAO,mBAAmB,EAAE,kBAAkB,OAAO,iBAAiB,IAAI,CAAC;EAC/E,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;EACvC,iBAAiB,MAAe,IAAa;GAC3C,OAAO,SAAS,MAAM,YAAY,KAAK,EAAE,MAAK,eAAc,WAAW,OAAO,EAAE,MAAM;EACxF;EACA,YAAY,UAAkB,MAAM,IAAI,KAAK;EAC7C,YAAY,UAAkB,MAAM,IAAI,KAAK,MAAM;EACnD,aAAa,UAAkB,MAAM,IAAI,KAAK,MAAM;EACpD,eAAe,UAAkB,MAAM,IAAI,KAAK;EAChD,eAAe,SAAiB,YAAY,IAAI,IAAI;EACpD,sBAAsB,OAAe,UAAsB;GACzD,MAAM,aAAa,OAAO;GAC1B,IAAI,YAAY,SAAS,aAAa,WAAW,cAAc,MAAM,OAAO;GAC5E,IAAI,CAAC,WAAW,eAAe,OAAO;GACtC,OAAO,UAAU,KAAA,KAAa,kBAAkB,WAAW,eAAe,KAAK;EACjF;CACF;CACA,IAAI,SAAS,OAAO,eAAe,OAAO,eAAe,EAAE,OAAO,KAAK,CAAC;CACxE,OAAO,eAAe,OAAO,mBAAmB,EAAE,OAAO,OAAO,CAAC;CACjE,IAAI,WAAW,OAAO,eAAe,OAAO,YAAY,EAAE,OAAO,YAAY,SAAS,EAAE,CAAC;CACzF,OAAO,OAAO,OAAO,KAAK;AAC5B"}
1
+ {"version":3,"file":"define-board.js","names":[],"sources":["../../src/boards/define-board.ts"],"sourcesContent":["import { CODE_AGENT_ID } from '@mastra/code-sdk/constants';\nimport { cardRuleGroupSchema, evaluateRuleGroup } from '../rules/rule-group.js';\nimport type { RuleFacts, RuleGroup } from '../rules/rule-group.js';\nimport {\n FACTORY_GITHUB_EVENTS,\n FACTORY_GITLAB_EVENTS,\n FACTORY_INCIDENTIO_EVENTS,\n FACTORY_JIRA_EVENTS,\n FACTORY_LINEAR_EVENTS,\n} from '../rules/types.js';\nimport type {\n FactoryGithubEventName,\n FactoryGithubRuleContext,\n FactoryGitLabEventName,\n FactoryGitLabRuleContext,\n FactoryIncidentioEventName,\n FactoryIncidentioRuleContext,\n FactoryJiraEventName,\n FactoryJiraRuleContext,\n FactoryLinearEventName,\n FactoryLinearRuleContext,\n FactoryRuleHandler,\n FactoryToolResultRuleContext,\n} from '../rules/types.js';\nimport {\n IDENTIFIER_RE,\n isBoardIdentifier,\n MAX_ROLE_LENGTH,\n MAX_SKILL_NAME_LENGTH,\n MAX_TOOL_NAME_LENGTH,\n SKILL_NAME_RE,\n} from '../rules/validation.js';\nimport type { BoardTransitionPolicy } from './transition-policy.js';\n\n/** Runs when an agent seated on this board completes the named tool. */\nexport type BoardToolResultRuleHandler = FactoryRuleHandler<FactoryToolResultRuleContext>;\nexport type BoardToolRule = { readonly onResult: BoardToolResultRuleHandler };\nexport type BoardToolRules = Readonly<Record<string, BoardToolRule>>;\n\n/**\n * A board's handler for one integration event. `null` switches the integration default off\n * for cards on this board only.\n */\ntype BoardEventHandlerMap<EventName extends string, Context> = Readonly<\n Partial<Record<EventName, FactoryRuleHandler<Context> | null>>\n>;\n\n/**\n * How cards on this board react to integration events, keyed by integration then event.\n * Consulted for events bound to a card on this board, after any handler the deployment set\n * explicitly on the integration and before the integration default.\n */\nexport interface BoardEventRules {\n readonly github?: BoardEventHandlerMap<FactoryGithubEventName, FactoryGithubRuleContext>;\n readonly gitlab?: BoardEventHandlerMap<FactoryGitLabEventName, FactoryGitLabRuleContext>;\n readonly linear?: BoardEventHandlerMap<FactoryLinearEventName, FactoryLinearRuleContext>;\n readonly jira?: BoardEventHandlerMap<FactoryJiraEventName, FactoryJiraRuleContext>;\n readonly incidentio?: BoardEventHandlerMap<FactoryIncidentioEventName, FactoryIncidentioRuleContext>;\n}\nexport type BoardEventIntegration = keyof BoardEventRules;\n\nconst BOARD_EVENT_NAMES: Readonly<Record<BoardEventIntegration, readonly string[]>> = {\n github: FACTORY_GITHUB_EVENTS,\n gitlab: FACTORY_GITLAB_EVENTS,\n linear: FACTORY_LINEAR_EVENTS,\n jira: FACTORY_JIRA_EVENTS,\n incidentio: FACTORY_INCIDENTIO_EVENTS,\n};\n\n/**\n * What a phase means to the runtime.\n * - `resting`: nobody is seated; a card waits for a person or an event.\n * - `working`: an agent in the phase's context carries the card; a person's move in arms autonomy.\n * - `terminal`: the card is finished; sessions stop and held resources are released.\n */\nexport type BoardPhaseKind = 'resting' | 'working' | 'terminal';\n\n/** The agent Factory runs every phase with. */\nexport const FACTORY_AGENT_ID = CODE_AGENT_ID;\n\n/** The session context a working phase runs in when it names none. */\nexport const DEFAULT_PHASE_CONTEXT = 'work';\n/**\n * Seat review runs sit in. Review skills load only in it, it is the only seat granted the verdict\n * tool, and its sessions check out code the author wrote, so they never trust that checkout's\n * instruction files. A runner context, not a phase key: any board's phases may run in it.\n */\nexport const REVIEW_CONTEXT = 'review';\n\n/** Who runs a working phase, and with what. */\nexport interface BoardPhaseRunner {\n /** Must be `code-agent`, the agent Factory runs; omitted means that agent. */\n readonly agentId?: string;\n /** Skill started when a card enters the phase. Without one, entering the phase starts no run. */\n readonly skill?: string;\n /**\n * The session the phase runs in. Phases naming the same context share one session per card;\n * a different context gets its own. Defaults to `work`.\n */\n readonly context?: string;\n /** Appended to every run the phase starts. */\n readonly instructions?: string;\n /**\n * Pursue the phase's work as a goal: the run's thread holds `objective` and the agent's goal\n * judge keeps it working until the objective is met. The judge sees only this text and the\n * latest messages, so it must say when the work is done.\n */\n readonly goal?: BoardPhaseGoal;\n}\n\n/** The objective a phase's runs pursue, judged in-loop until met. */\nexport interface BoardPhaseGoal {\n readonly objective: string;\n /** Judged turns before the goal pauses for a person; defaults to the agent's setting. */\n readonly maxRuns?: number;\n}\n\n/**\n * The tool whose successful call ends a working phase. The agent then moves the card itself with\n * `factory_transition_work_item`, to one of the phase's `nextPhases`.\n */\nexport interface BoardPhaseExitTool {\n readonly id: string;\n /**\n * Answer the approval the tool waits for without a person. Factory sessions run other tools\n * without asking, so today this applies to `submit_plan`. Defaults to false.\n */\n readonly autoApprove?: boolean;\n /** With `autoApprove`, only cards this matches are approved without a person. */\n readonly autoApproveWhen?: RuleGroup;\n}\n\n/** Factory tools a working phase grants the session that works the card there. */\nexport const FACTORY_PHASE_TOOLS = ['factory_record_review_verdict', 'factory_review_source'] as const;\nexport type FactoryPhaseTool = (typeof FACTORY_PHASE_TOOLS)[number];\n\ntype BoardPhaseBase<PhaseId extends string> = {\n readonly name?: string;\n /** @deprecated Use `name`. */\n readonly title?: string;\n readonly description?: string;\n /** Phases a card may move to from here. */\n readonly nextPhases?: readonly PhaseId[];\n /** @deprecated List the phase in `nextPhases`. */\n readonly next?: PhaseId;\n /** @deprecated Ignored apart from its targets, which are allowed next phases; list them in `nextPhases`. */\n readonly outcomes?: Readonly<Record<string, PhaseId>>;\n /** @deprecated Ignored; a phase starts its run from `runner.skill`. */\n readonly onEnter?: Readonly<Record<string, unknown>>;\n /** @deprecated Ignored; a phase starts its run from `runner.skill`. */\n readonly onExit?: Readonly<Record<string, unknown>>;\n};\n\ntype WorkingPhaseFields = {\n readonly runner?: BoardPhaseRunner;\n /** @deprecated Use `runner.context`. */\n readonly role?: string;\n /** Runs start without anyone approving them, even with the project's auto-run off. */\n readonly autoStart?: boolean;\n /** With `autoStart`, only cards this matches start on their own. */\n readonly autoStartWhen?: RuleGroup;\n /** A bare tool name is shorthand for `{ id }`, with nothing approved on a person's behalf. */\n readonly exitTool?: string | BoardPhaseExitTool;\n /**\n * Factory tools the session working the card here gets, on top of the move tool. Only the\n * session whose context is the phase's `runner.context` gets them, and only while the card\n * is in this phase.\n */\n readonly tools?: readonly FactoryPhaseTool[];\n};\n\ntype NonWorkingPhaseFields = {\n readonly runner?: never;\n readonly role?: never;\n readonly autoStart?: never;\n readonly autoStartWhen?: never;\n readonly exitTool?: never;\n readonly tools?: never;\n};\n\n/** A phase as a board declares it. */\nexport type BoardPhaseDefinition<PhaseId extends string> =\n | (BoardPhaseBase<PhaseId> & NonWorkingPhaseFields & { readonly kind: 'resting' })\n | (BoardPhaseBase<PhaseId> & WorkingPhaseFields & { readonly kind: 'working' })\n | (BoardPhaseBase<PhaseId> & NonWorkingPhaseFields & { readonly kind: 'terminal' });\n\ntype ResolvedPhaseBase<PhaseId extends string> = {\n readonly name: string;\n /** @deprecated Use `name`; kept equal to it for code written against older Factory versions. */\n readonly title: string;\n readonly description?: string;\n /** Every phase a card may move to from here. */\n readonly nextPhases: readonly PhaseId[];\n /** @deprecated Use `nextPhases`; set when the phase declared `next`. */\n readonly next?: PhaseId;\n};\n\n/**\n * A phase as the board resolved it: deprecated fields are replaced by their new names, so\n * only the new structure leaves `defineBoard()`, and a resolved phase can be declared again.\n */\nexport type BoardPhase<PhaseId extends string> =\n | (ResolvedPhaseBase<PhaseId> & { readonly kind: 'resting' })\n | (ResolvedPhaseBase<PhaseId> & {\n readonly kind: 'working';\n readonly runner: Readonly<BoardPhaseRunner & { agentId: string; context: string }>;\n /** @deprecated Use `runner.context`; kept equal to it. */\n readonly role: string;\n readonly autoStart?: boolean;\n readonly autoStartWhen?: RuleGroup;\n readonly exitTool?: Readonly<{ id: string; autoApprove: boolean; autoApproveWhen?: RuleGroup }>;\n readonly tools?: readonly FactoryPhaseTool[];\n })\n | (ResolvedPhaseBase<PhaseId> & { readonly kind: 'terminal' });\n\ntype ResolvedRunner = Extract<BoardPhase<string>, { kind: 'working' }>['runner'];\ntype ResolvedExitTool = Extract<BoardPhase<string>, { kind: 'working' }>['exitTool'];\n\nexport interface BoardTransition<PhaseId extends string> {\n /** Always null: boards no longer name their moves. */\n readonly outcome: null;\n readonly to: PhaseId;\n}\n\n/**\n * Terminal phases a card moves to when its tracked source (issue or follow-up) closes.\n * `completed` is used when the source was completed, `canceled` when it was canceled or not planned.\n */\nexport type BoardSourceClosed<PhaseId extends string> = Readonly<{ completed: PhaseId; canceled: PhaseId }>;\n\nexport interface BoardDefinition<BoardId extends string, PhaseId extends string> {\n readonly id: BoardId;\n readonly name: string;\n /** @deprecated Use `name`; kept equal to it for code written against older Factory versions. */\n readonly title: string;\n readonly description?: string;\n readonly initialPhase: PhaseId;\n readonly phases: Readonly<Record<PhaseId, BoardPhase<PhaseId>>>;\n readonly transitions: Readonly<Record<PhaseId, readonly BoardTransition<PhaseId>[]>>;\n /** Tool-result rules keyed by tool name; empty when the board declares none. */\n readonly tools: BoardToolRules;\n /** Integration event handlers for cards on this board; empty when the board declares none. */\n readonly events: BoardEventRules;\n /** @deprecated Express the flow with each phase's `nextPhases` and `exitTool`; still enforced when set. */\n readonly transitionPolicy?: BoardTransitionPolicy;\n /** Where source-closed rules move a card; absent when the board opts out of auto-closing. */\n readonly sourceClosed?: BoardSourceClosed<PhaseId>;\n allowsTransition(from: PhaseId, to: PhaseId): boolean;\n /** Declared kind of a phase, or undefined when the board has no such phase. */\n phaseKind(phase: string): BoardPhaseKind | undefined;\n isWorking(phase: string): boolean;\n isTerminal(phase: string): boolean;\n /** Session context of a working phase; undefined for resting/terminal/unknown phases. */\n roleForPhase(phase: string): string | undefined;\n /** First working phase, in declaration order, running in `role`'s context. */\n phaseForRole(role: string): PhaseId | undefined;\n /**\n * Whether the phase's runs start without anyone approving them, for a card with these facts\n * (`cardRuleFacts`). A phase with a start condition never starts on its own without facts.\n */\n startsAutomatically(phase: string, facts?: RuleFacts): boolean;\n}\n\ntype BoardConfig<BoardId extends string, Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>> = {\n id: BoardId;\n name?: string;\n /** @deprecated Use `name`. */\n title?: string;\n description?: string;\n initialPhase: keyof Phases & string;\n phases: Phases;\n tools?: Record<string, BoardToolRule>;\n events?: BoardEventRules;\n /** @deprecated Express the flow with each phase's `nextPhases` and `exitTool`; still enforced when set. */\n transitionPolicy?: BoardTransitionPolicy;\n sourceClosed?: { completed: keyof Phases & string; canceled: keyof Phases & string };\n};\n\nexport class BoardDefinitionError extends Error {\n override name = 'BoardDefinitionError';\n}\n\nconst PHASE_KINDS: ReadonlySet<string> = new Set<BoardPhaseKind>(['resting', 'working', 'terminal']);\n\nfunction validateBoardIdentifier(value: unknown, label: string): void {\n if (!isBoardIdentifier(value)) {\n throw new BoardDefinitionError(`${label} must be a valid board identifier.`);\n }\n}\n\nconst MAX_NAME_LENGTH = 128;\nconst MAX_DESCRIPTION_LENGTH = 2_000;\nconst MAX_INSTRUCTIONS_LENGTH = 1_000;\nconst MAX_GOAL_OBJECTIVE_LENGTH = 2_000;\nconst MAX_GOAL_RUNS = 50;\nconst RUNNER_KEYS: ReadonlySet<string> = new Set(['agentId', 'skill', 'context', 'instructions', 'goal']);\nconst GOAL_KEYS: ReadonlySet<string> = new Set(['objective', 'maxRuns']);\nconst EXIT_TOOL_KEYS: ReadonlySet<string> = new Set(['id', 'autoApprove', 'autoApproveWhen']);\nconst WORKING_ONLY_FIELDS = ['runner', 'autoStart', 'autoStartWhen', 'exitTool', 'tools'] as const;\nconst MOVE_TOOL = 'factory_transition_work_item';\n\nfunction resolvePhaseTools(label: string, value: unknown): readonly FactoryPhaseTool[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new BoardDefinitionError(`${label} tools must be a list of Factory tool names.`);\n for (const tool of value) {\n if (!(FACTORY_PHASE_TOOLS as readonly unknown[]).includes(tool)) {\n throw new BoardDefinitionError(`${label} tools: ${String(tool)} is not a Factory phase tool.`);\n }\n }\n const tools = [...new Set(value as FactoryPhaseTool[])];\n return tools.length ? Object.freeze(tools) : undefined;\n}\n\n/** `name`, falling back to the deprecated `title`; both may be set only to the same text. */\nfunction resolveName(name: unknown, title: unknown, label: string): string {\n if (name !== undefined && title !== undefined && name !== title) {\n throw new BoardDefinitionError(`${label} sets both name and title; drop the deprecated title.`);\n }\n const value = name ?? title;\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > MAX_NAME_LENGTH) {\n throw new BoardDefinitionError(`${label} must declare a name.`);\n }\n return value;\n}\n\nfunction optionalText(value: unknown, label: string, max: number): string | undefined {\n if (value === undefined) return undefined;\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > max) {\n throw new BoardDefinitionError(`${label} must be non-empty text of at most ${max} characters.`);\n }\n return value;\n}\n\nfunction ruleGroup(value: unknown, label: string): RuleGroup | undefined {\n if (value === undefined) return undefined;\n const parsed = cardRuleGroupSchema.safeParse(value);\n if (!parsed.success) {\n throw new BoardDefinitionError(`${label} is not a valid condition: ${parsed.error.issues[0]?.message}`);\n }\n return parsed.data;\n}\n\nfunction isContext(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0 && value.length <= MAX_ROLE_LENGTH && IDENTIFIER_RE.test(value);\n}\n\nfunction resolveRunner(phaseId: string, phase: BoardPhaseDefinition<string>): ResolvedRunner {\n const runner: unknown = phase.runner ?? {};\n if (!isPlainObject(runner) || Object.keys(runner).some(key => !RUNNER_KEYS.has(key))) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" runner may only set agentId, skill, context, instructions and goal.`,\n );\n }\n const role: unknown = phase.role;\n if (role !== undefined && runner.context !== undefined && role !== runner.context) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" sets both role and runner.context; drop the deprecated role.`);\n }\n const context = runner.context ?? role ?? DEFAULT_PHASE_CONTEXT;\n if (!isContext(context)) throw new BoardDefinitionError(`Working phase \"${phaseId}\" must declare a valid context.`);\n const agentId = runner.agentId ?? FACTORY_AGENT_ID;\n if (agentId !== FACTORY_AGENT_ID) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" names unknown agent \"${String(agentId)}\"; Factory runs \"${FACTORY_AGENT_ID}\".`,\n );\n }\n const skill = runner.skill;\n if (\n skill !== undefined &&\n (typeof skill !== 'string' || skill.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_RE.test(skill))\n ) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" runner.skill must be a skill name.`);\n }\n const instructions = optionalText(\n runner.instructions,\n `Phase \"${phaseId}\" runner.instructions`,\n MAX_INSTRUCTIONS_LENGTH,\n );\n const goal = resolveGoal(phaseId, runner.goal);\n if (goal !== undefined && skill === undefined) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" runner.goal needs runner.skill: the skill's run pursues the goal.`,\n );\n }\n return Object.freeze({\n agentId,\n context,\n ...(skill !== undefined ? { skill } : {}),\n ...(instructions !== undefined ? { instructions } : {}),\n ...(goal !== undefined ? { goal } : {}),\n });\n}\n\nfunction resolveGoal(phaseId: string, value: unknown): BoardPhaseGoal | undefined {\n if (value === undefined) return undefined;\n if (!isPlainObject(value) || Object.keys(value).some(key => !GOAL_KEYS.has(key))) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" runner.goal may only set objective and maxRuns.`);\n }\n const objective = optionalText(\n value.objective,\n `Phase \"${phaseId}\" runner.goal.objective`,\n MAX_GOAL_OBJECTIVE_LENGTH,\n );\n if (objective === undefined) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" runner.goal must state an objective.`);\n }\n const maxRuns = value.maxRuns;\n if (\n maxRuns !== undefined &&\n (typeof maxRuns !== 'number' || !Number.isInteger(maxRuns) || maxRuns < 1 || maxRuns > MAX_GOAL_RUNS)\n ) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" runner.goal.maxRuns must be a whole number from 1 to ${MAX_GOAL_RUNS}.`,\n );\n }\n return Object.freeze({ objective, ...(maxRuns !== undefined ? { maxRuns } : {}) });\n}\n\nfunction resolveExitTool(phaseId: string, value: unknown): ResolvedExitTool {\n if (value === undefined) return undefined;\n const declared = typeof value === 'string' ? { id: value } : value;\n if (!isPlainObject(declared) || Object.keys(declared).some(key => !EXIT_TOOL_KEYS.has(key))) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" exitTool must be a tool name or { id, autoApprove, autoApproveWhen }.`,\n );\n }\n const { id, autoApprove = false } = declared;\n if (typeof id !== 'string' || id.length === 0 || id.length > MAX_TOOL_NAME_LENGTH || !IDENTIFIER_RE.test(id)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool has an invalid tool name.`);\n }\n if (id === MOVE_TOOL) {\n throw new BoardDefinitionError(\n `Phase \"${phaseId}\" cannot end with ${MOVE_TOOL}: that tool already moves the card.`,\n );\n }\n if (typeof autoApprove !== 'boolean') {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool.autoApprove must be a boolean.`);\n }\n const autoApproveWhen = ruleGroup(declared.autoApproveWhen, `Phase \"${phaseId}\" exitTool.autoApproveWhen`);\n if (autoApproveWhen && !autoApprove) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" exitTool.autoApproveWhen needs autoApprove.`);\n }\n return Object.freeze({ id, autoApprove, ...(autoApproveWhen ? { autoApproveWhen } : {}) });\n}\n\nfunction validatePhaseSemantics(phaseId: string, phase: BoardPhaseDefinition<string>): void {\n if (!PHASE_KINDS.has(phase.kind as string)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" must declare kind 'resting', 'working', or 'terminal'.`);\n }\n if (phase.kind === 'working') return;\n if ((phase as { role?: unknown }).role !== undefined) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" is ${phase.kind} and cannot declare a role.`);\n }\n for (const field of WORKING_ONLY_FIELDS) {\n if ((phase as Record<string, unknown>)[field] !== undefined) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" is ${phase.kind} and cannot declare ${field}.`);\n }\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction validateToolRules(tools: unknown): BoardToolRules {\n if (tools === undefined) return Object.freeze({});\n if (!isPlainObject(tools)) throw new BoardDefinitionError('Board tools must be a plain object.');\n const frozen: Record<string, BoardToolRule> = {};\n for (const [toolName, leaf] of Object.entries(tools)) {\n if (toolName.length === 0 || toolName.length > MAX_TOOL_NAME_LENGTH || !IDENTIFIER_RE.test(toolName)) {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" has an invalid tool name.`);\n }\n if (!isPlainObject(leaf) || Object.keys(leaf).some(key => key !== 'onResult')) {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" must be an object with only onResult.`);\n }\n if (typeof leaf.onResult !== 'function') {\n throw new BoardDefinitionError(`Tool rule \"${toolName}\" must declare an onResult function.`);\n }\n frozen[toolName] = Object.freeze({ onResult: leaf.onResult as BoardToolResultRuleHandler });\n }\n return Object.freeze(frozen);\n}\n\nfunction validateSourceClosed(\n sourceClosed: unknown,\n phases: Readonly<Record<string, BoardPhaseDefinition<string>>>,\n): BoardSourceClosed<string> | undefined {\n if (sourceClosed === undefined) return undefined;\n if (!isPlainObject(sourceClosed)) throw new BoardDefinitionError('Board sourceClosed must be a plain object.');\n const keys = Object.keys(sourceClosed);\n if (keys.length !== 2 || !keys.includes('completed') || !keys.includes('canceled')) {\n throw new BoardDefinitionError('Board sourceClosed must declare exactly completed and canceled.');\n }\n for (const key of ['completed', 'canceled'] as const) {\n const phase = sourceClosed[key];\n if (typeof phase !== 'string' || !Object.hasOwn(phases, phase) || phases[phase]!.kind !== 'terminal') {\n throw new BoardDefinitionError(`Board sourceClosed.${key} \"${String(phase)}\" must name a terminal phase.`);\n }\n }\n return Object.freeze({ completed: sourceClosed.completed as string, canceled: sourceClosed.canceled as string });\n}\n\nfunction validateEventRules(events: unknown): BoardEventRules {\n if (events === undefined) return Object.freeze({});\n if (!isPlainObject(events)) throw new BoardDefinitionError('Board events must be a plain object.');\n const frozen: Record<string, Readonly<Record<string, unknown>>> = {};\n for (const [integration, handlers] of Object.entries(events)) {\n const known = Object.hasOwn(BOARD_EVENT_NAMES, integration)\n ? BOARD_EVENT_NAMES[integration as BoardEventIntegration]\n : undefined;\n if (!known) throw new BoardDefinitionError(`Board events name unknown integration \"${integration}\".`);\n if (handlers === undefined) continue;\n if (!isPlainObject(handlers)) {\n throw new BoardDefinitionError(`Board events for \"${integration}\" must be a plain object.`);\n }\n const entries: Record<string, unknown> = {};\n for (const [event, handler] of Object.entries(handlers)) {\n if (!known.includes(event)) {\n throw new BoardDefinitionError(`Board events for \"${integration}\" name unknown event \"${event}\".`);\n }\n if (handler === undefined) continue;\n if (handler !== null && typeof handler !== 'function') {\n throw new BoardDefinitionError(`Board event handler \"${integration}.${event}\" must be a function or null.`);\n }\n entries[event] = handler;\n }\n frozen[integration] = Object.freeze(entries);\n }\n return Object.freeze(frozen) as BoardEventRules;\n}\n\nconst warnedBoards = new Set<string>();\n\ntype DeclaredBoard = {\n readonly id: string;\n readonly name?: string;\n readonly title?: string;\n readonly transitionPolicy?: BoardTransitionPolicy;\n readonly phases: Readonly<Record<string, BoardPhaseDefinition<string>>>;\n};\n\n/**\n * Deprecated fields a board declaration still relies on; `defineBoard()` maps each to its\n * replacement. A deprecated field next to its replacement adds nothing, so it is not reported:\n * that is how a resolved board, which carries both, is declared again.\n */\nfunction deprecatedFields(config: DeclaredBoard): string[] {\n const found: string[] = [];\n if (config.title !== undefined && config.name === undefined) found.push('title → name');\n if (config.transitionPolicy !== undefined) found.push('transitionPolicy → phases.*.nextPhases and exitTool');\n for (const [phaseId, phase] of Object.entries(config.phases)) {\n if (phase.title !== undefined && phase.name === undefined) found.push(`phases.${phaseId}.title → name`);\n if (phase.next !== undefined && !phase.nextPhases?.includes(phase.next)) {\n found.push(`phases.${phaseId}.next → nextPhases`);\n }\n if (phase.role !== undefined && phase.runner?.context === undefined) {\n found.push(`phases.${phaseId}.role → runner.context`);\n }\n if (phase.outcomes !== undefined) found.push(`phases.${phaseId}.outcomes → nextPhases`);\n }\n return found;\n}\n\n/** Fields a board declaration still passes that Factory no longer reads. */\nfunction ignoredFields(config: DeclaredBoard): string[] {\n const found: string[] = [];\n for (const [phaseId, phase] of Object.entries(config.phases)) {\n for (const field of ['onEnter', 'onExit'] as const) {\n if (phase[field] !== undefined) found.push(`phases.${phaseId}.${field}`);\n }\n }\n return found;\n}\n\nfunction warnDeprecatedFields(config: DeclaredBoard): void {\n if (warnedBoards.has(config.id)) return;\n const found = deprecatedFields(config);\n const ignored = ignoredFields(config);\n if (found.length === 0 && ignored.length === 0) return;\n warnedBoards.add(config.id);\n const warnings: string[] = [];\n if (found.length > 0) {\n warnings.push(\n `uses deprecated fields: ${found.join(', ')}. They still work but will be removed in a future release.`,\n );\n }\n if (ignored.length > 0) {\n warnings.push(`declares ${ignored.join(', ')}, which are ignored; use runner.skill to start a phase's run.`);\n }\n console.warn(`[Mastra Factory] Board \"${config.id}\" ${warnings.join(' It also ')}`);\n}\n\n/** Marks a board an app declared with the deprecated `defineBoard()`; a copy does not carry it. */\nconst DEFINED_BOARD = Symbol('DefinedBoard');\n\n/**\n * Declares a board in code.\n *\n * @deprecated Write the board's definition into projects with `factory.upsertBoard()`, or manage\n * it through the boards API\n * (`/web/factory/projects/:id/boards`, README \"Stored boards\"); removal is tracked in\n * mastra-ai/mastra#28920. A board defined here still works: each project stores it once and is\n * served from its row, with the code behaviour it declares.\n */\nexport function defineBoard<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(config: BoardConfig<BoardId, Phases>): BoardDefinition<BoardId, keyof Phases & string> {\n return buildBoard(config, true);\n}\n\n/** Whether an app declared the board with the deprecated `defineBoard()`. */\nexport function isDefinedBoard(board: object): boolean {\n return DEFINED_BOARD in board;\n}\n\n/** A board declaration as `defineBoard()` takes it, with any phase keys. */\nexport type AnyBoardConfig = BoardConfig<string, Record<string, BoardPhaseDefinition<string>>>;\n\n/** The declaration a board was built from, so a stored definition can reuse its code behaviour. */\nconst BOARD_DECLARATION = Symbol('BoardDeclaration');\n\n/** On a board built from a stored definition, the code board that gave it its behaviour. */\nconst CODE_BOARD = Symbol('CodeBoard');\n\n/** The declaration a board was built from; undefined for an object that was not built as a board. */\nexport function declarationOf(board: object): AnyBoardConfig | undefined {\n return (board as { [BOARD_DECLARATION]?: AnyBoardConfig })[BOARD_DECLARATION];\n}\n\n/** The code board a board takes its behaviour from: itself unless it was built from a stored definition. */\nexport function codeBoardOf<Board extends object>(board: Board): Board {\n return (board as { [CODE_BOARD]?: Board })[CODE_BOARD] ?? board;\n}\n\n/**\n * Validates and resolves a board declaration. Factory's own boards use this directly. A board\n * built from a stored definition names the code board whose behaviour it carries.\n */\nexport function compileBoardDefinition<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(config: BoardConfig<BoardId, Phases>, codeBoard?: object): BoardDefinition<BoardId, keyof Phases & string> {\n return buildBoard(config, false, codeBoard);\n}\n\nfunction buildBoard<\n const BoardId extends string,\n const Phases extends Record<string, BoardPhaseDefinition<keyof Phases & string>>,\n>(\n config: BoardConfig<BoardId, Phases>,\n defined: boolean,\n codeBoard?: object,\n): BoardDefinition<BoardId, keyof Phases & string> {\n type PhaseId = keyof Phases & string;\n validateBoardIdentifier(config.id, 'Board id');\n const boardName = resolveName(config.name, config.title, `Board \"${config.id}\"`);\n const boardDescription = optionalText(config.description, `Board \"${config.id}\" description`, MAX_DESCRIPTION_LENGTH);\n if (config.transitionPolicy !== undefined && typeof config.transitionPolicy !== 'function') {\n throw new BoardDefinitionError('Board transitionPolicy must be a function.');\n }\n const tools = validateToolRules(config.tools);\n const events = validateEventRules(config.events);\n const phaseIds = new Set(Object.keys(config.phases));\n if (phaseIds.size === 0) throw new BoardDefinitionError('A board must define at least one phase.');\n if (!phaseIds.has(config.initialPhase)) {\n throw new BoardDefinitionError(`Initial phase \"${config.initialPhase}\" is not defined.`);\n }\n for (const [phaseId, phase] of Object.entries(config.phases)) {\n validateBoardIdentifier(phaseId, 'Phase id');\n validatePhaseSemantics(phaseId, phase);\n }\n if (config.phases[config.initialPhase]!.kind !== 'resting') {\n throw new BoardDefinitionError(`Initial phase \"${config.initialPhase}\" must be a resting phase.`);\n }\n warnDeprecatedFields(config);\n const sourceClosed = validateSourceClosed(config.sourceClosed, config.phases) as\n | BoardSourceClosed<PhaseId>\n | undefined;\n\n const transitions = Object.fromEntries(\n Object.entries(config.phases).map(([phaseId, phase]) => {\n if (phase.nextPhases !== undefined && !Array.isArray(phase.nextPhases)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" nextPhases must be a list of phases.`);\n }\n const targets: BoardTransition<string>[] = [];\n // A deprecated `outcomes` map still names moves the board allows.\n for (const to of [\n ...(phase.next !== undefined ? [phase.next] : []),\n ...Object.values(phase.outcomes ?? {}),\n ...(phase.nextPhases ?? []),\n ]) {\n if (!targets.some(target => target.to === to)) targets.push(Object.freeze({ outcome: null, to }));\n }\n for (const { to } of targets) {\n if (!phaseIds.has(to)) {\n throw new BoardDefinitionError(`Phase \"${phaseId}\" targets undefined phase \"${to}\".`);\n }\n }\n return [phaseId, Object.freeze(targets)];\n }),\n ) as Record<PhaseId, readonly BoardTransition<PhaseId>[]>;\n\n const phases = Object.freeze(\n Object.fromEntries(\n Object.entries(config.phases).map(([phaseId, phase]) => {\n const label = `Phase \"${phaseId}\"`;\n const nextPhases = Object.freeze([\n ...new Set([...(phase.nextPhases ?? []), ...transitions[phaseId as PhaseId]!.map(({ to }) => to)]),\n ]);\n const runner = phase.kind === 'working' ? resolveRunner(phaseId, phase) : undefined;\n const working = phase.kind === 'working' ? phase : undefined;\n if (working?.autoStart !== undefined && typeof working.autoStart !== 'boolean') {\n throw new BoardDefinitionError(`${label} autoStart must be a boolean.`);\n }\n const autoStartWhen = ruleGroup(working?.autoStartWhen, `${label} autoStartWhen`);\n if (autoStartWhen && working?.autoStart !== true) {\n throw new BoardDefinitionError(`${label} autoStartWhen needs autoStart.`);\n }\n const exitTool = resolveExitTool(phaseId, working?.exitTool);\n const tools = resolvePhaseTools(label, working?.tools);\n if (exitTool && nextPhases.length === 0) {\n throw new BoardDefinitionError(`${label} exit tool needs a next phase to move the card to.`);\n }\n const name = resolveName(phase.name, phase.title, label);\n const description = optionalText(phase.description, `${label} description`, MAX_DESCRIPTION_LENGTH);\n return [\n phaseId,\n Object.freeze({\n name,\n title: name,\n ...(description !== undefined ? { description } : {}),\n kind: phase.kind,\n nextPhases,\n ...(phase.next !== undefined ? { next: phase.next } : {}),\n ...(runner ? { runner, role: runner.context } : {}),\n ...(working?.autoStart ? { autoStart: true } : {}),\n ...(autoStartWhen ? { autoStartWhen } : {}),\n ...(exitTool ? { exitTool } : {}),\n ...(tools ? { tools } : {}),\n }),\n ];\n }),\n ),\n ) as Readonly<Record<PhaseId, BoardPhase<PhaseId>>>;\n\n const kinds = new Map<string, BoardPhaseKind>();\n const roles = new Map<string, string>();\n const phaseByRole = new Map<string, PhaseId>();\n for (const [phaseId, phase] of Object.entries(phases) as [PhaseId, BoardPhase<PhaseId>][]) {\n kinds.set(phaseId, phase.kind);\n if (phase.kind !== 'working') continue;\n roles.set(phaseId, phase.runner.context);\n if (!phaseByRole.has(phase.runner.context)) phaseByRole.set(phase.runner.context, phaseId);\n }\n\n const board = {\n id: config.id,\n name: boardName,\n title: boardName,\n ...(boardDescription !== undefined ? { description: boardDescription } : {}),\n initialPhase: config.initialPhase,\n phases,\n transitions: Object.freeze(transitions),\n tools,\n events,\n ...(config.transitionPolicy ? { transitionPolicy: config.transitionPolicy } : {}),\n ...(sourceClosed ? { sourceClosed } : {}),\n allowsTransition(from: PhaseId, to: PhaseId) {\n if (!kinds.has(from) || !kinds.has(to)) return false;\n return from === to || transitions[from]?.some(transition => transition.to === to) === true;\n },\n phaseKind: (phase: string) => kinds.get(phase),\n isWorking: (phase: string) => kinds.get(phase) === 'working',\n isTerminal: (phase: string) => kinds.get(phase) === 'terminal',\n roleForPhase: (phase: string) => roles.get(phase),\n phaseForRole: (role: string) => phaseByRole.get(role),\n startsAutomatically: (phase: string, facts?: RuleFacts) => {\n const definition = phases[phase as PhaseId] as BoardPhase<PhaseId> | undefined;\n if (definition?.kind !== 'working' || definition.autoStart !== true) return false;\n if (!definition.autoStartWhen) return true;\n return facts !== undefined && evaluateRuleGroup(definition.autoStartWhen, facts);\n },\n };\n if (defined) Object.defineProperty(board, DEFINED_BOARD, { value: true });\n Object.defineProperty(board, BOARD_DECLARATION, { value: config });\n if (codeBoard) Object.defineProperty(board, CODE_BOARD, { value: codeBoardOf(codeBoard) });\n return Object.freeze(board);\n}\n"],"mappings":";;;;;AA6DA,MAAM,oBAAgF;CACpF,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,YAAY;AACd;;AAWA,MAAa,mBAAmB;;AAGhC,MAAa,wBAAwB;;;;;;AAMrC,MAAa,iBAAiB;;AA8C9B,MAAa,sBAAsB,CAAC,iCAAiC,uBAAuB;AAiJ5F,IAAa,uBAAb,cAA0C,MAAM;CAC9C,OAAgB;AAClB;AAEA,MAAM,8BAAmC,IAAI,IAAoB;CAAC;CAAW;CAAW;AAAU,CAAC;AAEnG,SAAS,wBAAwB,OAAgB,OAAqB;CACpE,IAAI,CAAC,kBAAkB,KAAK,GAC1B,MAAM,IAAI,qBAAqB,GAAG,MAAM,mCAAmC;AAE/E;AAEA,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,4BAA4B;AAClC,MAAM,gBAAgB;AACtB,MAAM,8BAAmC,IAAI,IAAI;CAAC;CAAW;CAAS;CAAW;CAAgB;AAAM,CAAC;AACxG,MAAM,4BAAiC,IAAI,IAAI,CAAC,aAAa,SAAS,CAAC;AACvE,MAAM,iCAAsC,IAAI,IAAI;CAAC;CAAM;CAAe;AAAiB,CAAC;AAC5F,MAAM,sBAAsB;CAAC;CAAU;CAAa;CAAiB;CAAY;AAAO;AACxF,MAAM,YAAY;AAElB,SAAS,kBAAkB,OAAe,OAAyD;CACjG,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,IAAI,CAAC,MAAM,QA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AI,CAAC;EACvC,iBAAiB,MAAe,IAAa;GAC3C,IAAI,CAAC,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,IAAI,EAAE,GAAG,OAAO;GAC/C,OAAO,SAAS,MAAM,YAAY,KAAK,EAAE,MAAK,eAAc,WAAW,OAAO,EAAE,MAAM;EACxF;EACA,YAAY,UAAkB,MAAM,IAAI,KAAK;EAC7C,YAAY,UAAkB,MAAM,IAAI,KAAK,MAAM;EACnD,aAAa,UAAkB,MAAM,IAAI,KAAK,MAAM;EACpD,eAAe,UAAkB,MAAM,IAAI,KAAK;EAChD,eAAe,SAAiB,YAAY,IAAI,IAAI;EACpD,sBAAsB,OAAe,UAAsB;GACzD,MAAM,aAAa,OAAO;GAC1B,IAAI,YAAY,SAAS,aAAa,WAAW,cAAc,MAAM,OAAO;GAC5E,IAAI,CAAC,WAAW,eAAe,OAAO;GACtC,OAAO,UAAU,KAAA,KAAa,kBAAkB,WAAW,eAAe,KAAK;EACjF;CACF;CACA,IAAI,SAAS,OAAO,eAAe,OAAO,eAAe,EAAE,OAAO,KAAK,CAAC;CACxE,OAAO,eAAe,OAAO,mBAAmB,EAAE,OAAO,OAAO,CAAC;CACjE,IAAI,WAAW,OAAO,eAAe,OAAO,YAAY,EAAE,OAAO,YAAY,SAAS,EAAE,CAAC;CACzF,OAAO,OAAO,OAAO,KAAK;AAC5B"}
@@ -1,15 +1,12 @@
1
- export { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, defineBoard, FACTORY_AGENT_ID } from './define-board.js';
1
+ export { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, defineBoard, FACTORY_AGENT_ID, REVIEW_CONTEXT, } from './define-board.js';
2
+ export { DEFAULT_BOARD_ID } from './default-board.js';
2
3
  export { cardRuleFacts } from './card-facts.js';
3
- export type { BoardDefinition, BoardEventIntegration, BoardEventRules, BoardPhase, BoardPhaseDefinition, BoardPhaseExitTool, BoardPhaseKind, BoardPhaseRunner, BoardSourceClosed, BoardToolResultRuleHandler, BoardToolRule, BoardToolRules, BoardTransition, } from './define-board.js';
4
- export { boardEventHandlers, boardForWorkItem, eventBoardId, isPullRequestCard, isTerminalWorkItem, pullRequestReviewPhase, resolveBoardClosure, reviewsPullRequest, resolveBoardToolRule, rulePhaseContext, rulePhaseField, resolvePhaseSemantics, withBoardClosure, workItemPhaseSemantics, } from './semantics.js';
5
- export type { PhaseSemantics } from './semantics.js';
4
+ export type { BoardDefinition, BoardEventIntegration, BoardEventRules, BoardPhase, BoardPhaseDefinition, BoardPhaseExitTool, BoardPhaseKind, BoardPhaseGoal, BoardPhaseRunner, FactoryPhaseTool, BoardSourceClosed, BoardToolResultRuleHandler, BoardToolRule, BoardToolRules, BoardTransition, } from './define-board.js';
5
+ export { boardEventHandlers, awaitsAcceptance, boardFlow, boardPhaseOutcomes, boardForWorkItem, cardBoardFlow, boundChangeRequestNumber, eventBoardId, cardOwnsBranch, hasPullRequest, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, reviewedChangeRequest, reviewedPullRequest, sourceExternalId, reviewsPullRequest, resolveBoardToolRule, rulePhaseContext, rulePhaseField, resolvePhaseSemantics, withBoardClosure, withBoardFlow, intakeTarget, withIntakeTarget, workItemPhaseSemantics, } from './semantics.js';
6
+ export type { PhaseSemantics, ReviewedChangeRequest } from './semantics.js';
6
7
  export type { BoardTransitionPolicy, BoardTransitionPolicyContext, BoardTransitionPolicyResult, } from './transition-policy.js';
7
8
  export { createBoardRegistry, defaultBoards } from './registry.js';
8
9
  export type { BoardRegistry, InstalledBoard } from './registry.js';
9
- export { reviewBoard } from './review.js';
10
- export type { ReviewBoardPhase } from './review.js';
11
10
  export { workBoard } from './work.js';
12
11
  export type { WorkBoardPhase } from './work.js';
13
- export declare function builtInBoard(board: 'work' | 'review'): import("./define-board.js").BoardDefinition<"review", "canceled" | "done" | "intake" | "review"> | import("./define-board.js").BoardDefinition<"work", "canceled" | "done" | "execute" | "intake" | "planning" | "pr-review" | "review" | "triage">;
14
- export declare function allowsBuiltInBoardTransition(board: 'work' | 'review', from: string, to: string): boolean;
15
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAInE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,uPAEpD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAKxG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/boards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EAClB,2BAA2B,EAC3B,gCAAgC,EAChC,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -1,21 +1,7 @@
1
- import { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, defineBoard } from "./define-board.js";
1
+ import { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, REVIEW_CONTEXT, defineBoard } from "./define-board.js";
2
+ import { DEFAULT_BOARD_ID } from "./default-board.js";
2
3
  import { cardRuleFacts } from "./card-facts.js";
3
- import { boardEventHandlers, boardForWorkItem, eventBoardId, isPullRequestCard, isTerminalWorkItem, pullRequestReviewPhase, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewsPullRequest, rulePhaseContext, rulePhaseField, withBoardClosure, workItemPhaseSemantics } from "./semantics.js";
4
+ import { awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, eventBoardId, hasPullRequest, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workItemPhaseSemantics } from "./semantics.js";
4
5
  import { createBoardRegistry, defaultBoards } from "./registry.js";
5
- import { isReviewBoardPhase, reviewBoard } from "./review.js";
6
- import { isWorkBoardPhase, workBoard } from "./work.js";
7
- // src/boards/index.ts
8
- const builtInBoards = {
9
- work: workBoard,
10
- review: reviewBoard
11
- };
12
- function builtInBoard(board) {
13
- return builtInBoards[board];
14
- }
15
- function allowsBuiltInBoardTransition(board, from, to) {
16
- if (board === "work") return isWorkBoardPhase(from) && isWorkBoardPhase(to) && workBoard.allowsTransition(from, to);
17
- return isReviewBoardPhase(from) && isReviewBoardPhase(to) && reviewBoard.allowsTransition(from, to);
18
- }
19
- export { BoardDefinitionError, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, allowsBuiltInBoardTransition, boardEventHandlers, boardForWorkItem, builtInBoard, cardRuleFacts, createBoardRegistry, defaultBoards, defineBoard, eventBoardId, isPullRequestCard, isTerminalWorkItem, pullRequestReviewPhase, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewBoard, reviewsPullRequest, rulePhaseContext, rulePhaseField, withBoardClosure, workBoard, workItemPhaseSemantics };
20
-
21
- //# sourceMappingURL=index.js.map
6
+ import { workBoard } from "./work.js";
7
+ export { BoardDefinitionError, DEFAULT_BOARD_ID, DEFAULT_PHASE_CONTEXT, FACTORY_AGENT_ID, REVIEW_CONTEXT, awaitsAcceptance, boardEventHandlers, boardFlow, boardForWorkItem, boardPhaseOutcomes, boundChangeRequestNumber, cardBoardFlow, cardOwnsBranch, cardRuleFacts, createBoardRegistry, defaultBoards, defineBoard, eventBoardId, hasPullRequest, intakeTarget, isPullRequestCard, isPullRequestReviewPhase, isTerminalWorkItem, newestOpenPullRequestNumber, newestOwnedOpenPullRequestNumber, pullRequestSourceNumber, pullRequestSources, resolveBoardClosure, resolveBoardToolRule, resolvePhaseSemantics, reviewedChangeRequest, reviewedPullRequest, reviewsPullRequest, rulePhaseContext, rulePhaseField, sourceExternalId, withBoardClosure, withBoardFlow, withIntakeTarget, workBoard, workItemPhaseSemantics };
@@ -17,7 +17,7 @@ export declare const INTAKE_ROUTE_METADATA_KEY = "intakeRouteId";
17
17
  /** Whether an intake route chose this card's board when it arrived. */
18
18
  export declare function placedByIntakeRoute(item: Pick<Card, 'metadata'>): boolean;
19
19
  export type IntakeTargetProblem = {
20
- code: 'unknown_board' | 'unknown_phase' | 'terminal_phase' | 'unreachable_phase';
20
+ code: 'unknown_board' | 'unknown_phase' | 'terminal_phase' | 'unreachable_phase' | 'join_on_event';
21
21
  message: string;
22
22
  };
23
23
  /**
@@ -29,14 +29,36 @@ export declare function intakeTargetProblem(registry: BoardRegistry, route: {
29
29
  target: {
30
30
  boardKey: string;
31
31
  phaseKey?: string | null;
32
+ joinClosedIssue?: boolean;
32
33
  };
33
34
  on: readonly string[];
34
35
  }): IntakeTargetProblem | undefined;
35
36
  /**
36
- * Where a new card lands: the first enabled route that places new cards, whose condition matches the card and whose
37
- * board is installed and can hold it. A route without a phase, or whose phase has since gone,
38
- * lands the card in the board's initial phase. Undefined leaves today's placement alone.
37
+ * What an intake route can test about the issue a pull request closes: whether there is one with
38
+ * a card, that card's phase, and whether a pull request already sits on it. `closedIssue` is the
39
+ * card the provider rules found, read fresh; undefined when the pull request closes none.
39
40
  */
41
+ export declare function closedIssueRuleFacts(closedIssue: Pick<Card, 'stages' | 'workItem'> | undefined): RuleFacts;
42
+ export type IntakeRouteResolution = {
43
+ type: 'place';
44
+ board: string;
45
+ phase: string;
46
+ routeId: string;
47
+ } | {
48
+ type: 'join';
49
+ phase: string | null;
50
+ routeId: string;
51
+ };
52
+ /**
53
+ * What happens to an arrival: the first enabled route that places new cards, whose condition matches it and whose
54
+ * target can take it. A placing route lands a new card on an installed board; one without a
55
+ * phase, or whose phase has since gone, lands it in the board's initial phase. A joining route
56
+ * matches only a pull request whose closed issue's card (`closedIssue`) is on the route's board;
57
+ * the pull request joins that card, which moves to the route's phase when set. Undefined leaves
58
+ * today's placement alone.
59
+ */
60
+ export declare function resolveIntakeRoute(routes: readonly IntakeRoute[], facts: RuleFacts, registry: BoardRegistry, closedIssue?: Pick<Card, 'board'>): IntakeRouteResolution | undefined;
61
+ /** Where a new card lands, by {@link resolveIntakeRoute}, for an arrival no route can join to a card. */
40
62
  export declare function resolveIntakePlacement(routes: readonly IntakeRoute[], facts: RuleFacts, registry: BoardRegistry): {
41
63
  board: string;
42
64
  phase: string;
@@ -52,7 +74,7 @@ export declare function routesHandleEvent(routes: readonly Pick<IntakeRoute, 'on
52
74
  * hold it there. A route without a phase moves the card to its board's first phase. Undefined
53
75
  * leaves the card where it is.
54
76
  */
55
- export declare function resolveEventRoute(routes: readonly EventRoute[], event: BoardEventFacts, cardFacts: RuleFacts, board: InstalledBoard): {
77
+ export declare function resolveEventRoute(routes: readonly EventRoute[], event: BoardEventFacts, cardFacts: RuleFacts, board: InstalledBoard, carriesPullRequest?: boolean): {
56
78
  phase: string;
57
79
  routeId: string;
58
80
  allowWorkingPhase: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"intake-routing.d.ts","sourceRoot":"","sources":["../../src/boards/intake-routing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACtG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,iDAAiD;AACjD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;AAE/E,KAAK,WAAW,GAAG,IAAI,CAAC,uBAAuB,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC;AAC9F,KAAK,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;AA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