@mastra/factory 0.29.0-alpha.4 → 0.29.0-alpha.6

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 (401) hide show
  1. package/README.md +172 -89
  2. package/dist/boards/board-events.d.ts +89 -9
  3. package/dist/boards/board-events.d.ts.map +1 -1
  4. package/dist/boards/board-events.js +176 -13
  5. package/dist/boards/board-events.js.map +1 -1
  6. package/dist/boards/board-writes.d.ts.map +1 -1
  7. package/dist/boards/board-writes.js +14 -1
  8. package/dist/boards/board-writes.js.map +1 -1
  9. package/dist/boards/busy-card.d.ts +11 -0
  10. package/dist/boards/busy-card.d.ts.map +1 -0
  11. package/dist/boards/busy-card.js +15 -0
  12. package/dist/boards/busy-card.js.map +1 -0
  13. package/dist/boards/card-facts.d.ts.map +1 -1
  14. package/dist/boards/card-facts.js +18 -4
  15. package/dist/boards/card-facts.js.map +1 -1
  16. package/dist/boards/index.d.ts +2 -1
  17. package/dist/boards/index.d.ts.map +1 -1
  18. package/dist/boards/index.js +3 -2
  19. package/dist/boards/intake-dry-run.d.ts +109 -0
  20. package/dist/boards/intake-dry-run.d.ts.map +1 -0
  21. package/dist/boards/intake-dry-run.js +158 -0
  22. package/dist/boards/intake-dry-run.js.map +1 -0
  23. package/dist/boards/intake-lookup.d.ts +32 -0
  24. package/dist/boards/intake-lookup.d.ts.map +1 -0
  25. package/dist/boards/intake-lookup.js +12 -0
  26. package/dist/boards/intake-lookup.js.map +1 -0
  27. package/dist/boards/intake-order.d.ts +32 -0
  28. package/dist/boards/intake-order.d.ts.map +1 -0
  29. package/dist/boards/intake-order.js +60 -0
  30. package/dist/boards/intake-order.js.map +1 -0
  31. package/dist/boards/intake-routing.d.ts +246 -35
  32. package/dist/boards/intake-routing.d.ts.map +1 -1
  33. package/dist/boards/intake-routing.js +437 -52
  34. package/dist/boards/intake-routing.js.map +1 -1
  35. package/dist/boards/reroute.d.ts +7 -3
  36. package/dist/boards/reroute.d.ts.map +1 -1
  37. package/dist/boards/reroute.js +21 -4
  38. package/dist/boards/reroute.js.map +1 -1
  39. package/dist/boards/semantics.d.ts +8 -28
  40. package/dist/boards/semantics.d.ts.map +1 -1
  41. package/dist/boards/semantics.js +14 -40
  42. package/dist/boards/semantics.js.map +1 -1
  43. package/dist/boards/work-routes.d.ts +31 -11
  44. package/dist/boards/work-routes.d.ts.map +1 -1
  45. package/dist/boards/work-routes.js +104 -20
  46. package/dist/boards/work-routes.js.map +1 -1
  47. package/dist/factory.d.ts +37 -1
  48. package/dist/factory.d.ts.map +1 -1
  49. package/dist/factory.js +127 -48
  50. package/dist/factory.js.map +1 -1
  51. package/dist/integrations/base.d.ts +9 -0
  52. package/dist/integrations/base.d.ts.map +1 -1
  53. package/dist/integrations/dependabot/rules.js +1 -1
  54. package/dist/integrations/dependabot/rules.js.map +1 -1
  55. package/dist/integrations/github/default-rules.d.ts +22 -1
  56. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  57. package/dist/integrations/github/default-rules.js +23 -5
  58. package/dist/integrations/github/default-rules.js.map +1 -1
  59. package/dist/integrations/github/intake-lookup.d.ts +16 -0
  60. package/dist/integrations/github/intake-lookup.d.ts.map +1 -0
  61. package/dist/integrations/github/intake-lookup.js +76 -0
  62. package/dist/integrations/github/intake-lookup.js.map +1 -0
  63. package/dist/integrations/github/integration.d.ts +19 -5
  64. package/dist/integrations/github/integration.d.ts.map +1 -1
  65. package/dist/integrations/github/integration.js +21 -6
  66. package/dist/integrations/github/integration.js.map +1 -1
  67. package/dist/integrations/github/issue-intake.d.ts +15 -0
  68. package/dist/integrations/github/issue-intake.d.ts.map +1 -0
  69. package/dist/integrations/github/issue-intake.js +50 -0
  70. package/dist/integrations/github/issue-intake.js.map +1 -0
  71. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
  72. package/dist/integrations/github/issue-reconciler.js +10 -1
  73. package/dist/integrations/github/issue-reconciler.js.map +1 -1
  74. package/dist/integrations/github/review-status-reporter.js +1 -1
  75. package/dist/integrations/github/routes.d.ts.map +1 -1
  76. package/dist/integrations/github/routes.js +14 -2
  77. package/dist/integrations/github/routes.js.map +1 -1
  78. package/dist/integrations/github/rules.d.ts +14 -1
  79. package/dist/integrations/github/rules.d.ts.map +1 -1
  80. package/dist/integrations/github/rules.js +221 -30
  81. package/dist/integrations/github/rules.js.map +1 -1
  82. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  83. package/dist/integrations/github/sandbox.js +30 -4
  84. package/dist/integrations/github/sandbox.js.map +1 -1
  85. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  86. package/dist/integrations/gitlab/default-rules.js +19 -3
  87. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  88. package/dist/integrations/gitlab/intake-lookup.d.ts +17 -0
  89. package/dist/integrations/gitlab/intake-lookup.d.ts.map +1 -0
  90. package/dist/integrations/gitlab/intake-lookup.js +85 -0
  91. package/dist/integrations/gitlab/intake-lookup.js.map +1 -0
  92. package/dist/integrations/gitlab/integration.d.ts +5 -0
  93. package/dist/integrations/gitlab/integration.d.ts.map +1 -1
  94. package/dist/integrations/gitlab/integration.js +21 -1
  95. package/dist/integrations/gitlab/integration.js.map +1 -1
  96. package/dist/integrations/gitlab/rules.d.ts +20 -0
  97. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  98. package/dist/integrations/gitlab/rules.js +108 -12
  99. package/dist/integrations/gitlab/rules.js.map +1 -1
  100. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  101. package/dist/integrations/incidentio/rules.js +14 -4
  102. package/dist/integrations/incidentio/rules.js.map +1 -1
  103. package/dist/integrations/jira/rules.d.ts.map +1 -1
  104. package/dist/integrations/jira/rules.js +12 -2
  105. package/dist/integrations/jira/rules.js.map +1 -1
  106. package/dist/integrations/linear/rules.d.ts.map +1 -1
  107. package/dist/integrations/linear/rules.js +13 -2
  108. package/dist/integrations/linear/rules.js.map +1 -1
  109. package/dist/integrations/platform/connect/routes.d.ts +43 -1
  110. package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
  111. package/dist/integrations/platform/connect/routes.js +82 -7
  112. package/dist/integrations/platform/connect/routes.js.map +1 -1
  113. package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
  114. package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
  115. package/dist/integrations/platform/connect/session-tools.js +28 -10
  116. package/dist/integrations/platform/connect/session-tools.js.map +1 -1
  117. package/dist/integrations/platform/github/event-worker.js +9 -1
  118. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  119. package/dist/integrations/platform/github/integration.d.ts +6 -6
  120. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  121. package/dist/integrations/platform/github/integration.js +22 -3
  122. package/dist/integrations/platform/github/integration.js.map +1 -1
  123. package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
  124. package/dist/integrations/platform/vanta/integration.js +3 -3
  125. package/dist/integrations/platform/vanta/integration.js.map +1 -1
  126. package/dist/integrations/pull-request-head.d.ts +1 -1
  127. package/dist/integrations/pull-request-head.d.ts.map +1 -1
  128. package/dist/integrations/pull-request-head.js +5 -0
  129. package/dist/integrations/pull-request-head.js.map +1 -1
  130. package/dist/integrations/vanta/rules.js +1 -1
  131. package/dist/integrations/vanta/rules.js.map +1 -1
  132. package/dist/integrations/vanta/sync.d.ts +9 -0
  133. package/dist/integrations/vanta/sync.d.ts.map +1 -1
  134. package/dist/integrations/vanta/sync.js +10 -1
  135. package/dist/integrations/vanta/sync.js.map +1 -1
  136. package/dist/routes/board-snapshot.d.ts +13 -6
  137. package/dist/routes/board-snapshot.d.ts.map +1 -1
  138. package/dist/routes/board-snapshot.js +42 -20
  139. package/dist/routes/board-snapshot.js.map +1 -1
  140. package/dist/routes/boards.js.map +1 -1
  141. package/dist/routes/config.d.ts +17 -2
  142. package/dist/routes/config.d.ts.map +1 -1
  143. package/dist/routes/config.js +247 -77
  144. package/dist/routes/config.js.map +1 -1
  145. package/dist/routes/contracts.d.ts +1294 -7
  146. package/dist/routes/contracts.d.ts.map +1 -1
  147. package/dist/routes/contracts.js +603 -20
  148. package/dist/routes/contracts.js.map +1 -1
  149. package/dist/routes/custom-endpoint-url.d.ts +8 -0
  150. package/dist/routes/custom-endpoint-url.d.ts.map +1 -0
  151. package/dist/routes/custom-endpoint-url.js +45 -0
  152. package/dist/routes/custom-endpoint-url.js.map +1 -0
  153. package/dist/routes/custom-provider-source.d.ts +24 -8
  154. package/dist/routes/custom-provider-source.d.ts.map +1 -1
  155. package/dist/routes/custom-provider-source.js +93 -43
  156. package/dist/routes/custom-provider-source.js.map +1 -1
  157. package/dist/routes/intake-check.d.ts +92 -0
  158. package/dist/routes/intake-check.d.ts.map +1 -0
  159. package/dist/routes/intake-check.js +322 -0
  160. package/dist/routes/intake-check.js.map +1 -0
  161. package/dist/routes/intake-routes.d.ts +10 -2
  162. package/dist/routes/intake-routes.d.ts.map +1 -1
  163. package/dist/routes/intake-routes.js +292 -11
  164. package/dist/routes/intake-routes.js.map +1 -1
  165. package/dist/routes/intake.d.ts +6 -0
  166. package/dist/routes/intake.d.ts.map +1 -1
  167. package/dist/routes/intake.js +20 -0
  168. package/dist/routes/intake.js.map +1 -1
  169. package/dist/routes/mastra-gateway.d.ts.map +1 -1
  170. package/dist/routes/mastra-gateway.js +3 -2
  171. package/dist/routes/mastra-gateway.js.map +1 -1
  172. package/dist/routes/project-sessions.d.ts +61 -0
  173. package/dist/routes/project-sessions.d.ts.map +1 -0
  174. package/dist/routes/project-sessions.js +135 -0
  175. package/dist/routes/project-sessions.js.map +1 -0
  176. package/dist/routes/projects.d.ts +6 -1
  177. package/dist/routes/projects.d.ts.map +1 -1
  178. package/dist/routes/projects.js +19 -3
  179. package/dist/routes/projects.js.map +1 -1
  180. package/dist/routes/provider-credentials.d.ts +10 -1
  181. package/dist/routes/provider-credentials.d.ts.map +1 -1
  182. package/dist/routes/provider-credentials.js +13 -16
  183. package/dist/routes/provider-credentials.js.map +1 -1
  184. package/dist/routes/run-queue.d.ts +6 -6
  185. package/dist/routes/run-queue.d.ts.map +1 -1
  186. package/dist/routes/run-queue.js +28 -8
  187. package/dist/routes/run-queue.js.map +1 -1
  188. package/dist/routes/session-rows.d.ts +30 -0
  189. package/dist/routes/session-rows.d.ts.map +1 -0
  190. package/dist/routes/session-rows.js +94 -0
  191. package/dist/routes/session-rows.js.map +1 -0
  192. package/dist/routes/source-control-sessions.d.ts +4 -5
  193. package/dist/routes/source-control-sessions.d.ts.map +1 -1
  194. package/dist/routes/source-control-sessions.js +8 -87
  195. package/dist/routes/source-control-sessions.js.map +1 -1
  196. package/dist/routes/surface.d.ts +16 -1
  197. package/dist/routes/surface.d.ts.map +1 -1
  198. package/dist/routes/surface.js +41 -30
  199. package/dist/routes/surface.js.map +1 -1
  200. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  201. package/dist/routes/tenant-credentials.js +4 -4
  202. package/dist/routes/tenant-credentials.js.map +1 -1
  203. package/dist/routes/work-item-starters.d.ts +1 -0
  204. package/dist/routes/work-item-starters.d.ts.map +1 -1
  205. package/dist/routes/work-item-starters.js +14 -2
  206. package/dist/routes/work-item-starters.js.map +1 -1
  207. package/dist/routes/work-items.d.ts +22 -3
  208. package/dist/routes/work-items.d.ts.map +1 -1
  209. package/dist/routes/work-items.js +124 -48
  210. package/dist/routes/work-items.js.map +1 -1
  211. package/dist/rules/binding-context.d.ts +5 -0
  212. package/dist/rules/binding-context.d.ts.map +1 -1
  213. package/dist/rules/binding-context.js +51 -5
  214. package/dist/rules/binding-context.js.map +1 -1
  215. package/dist/rules/dispatch-errors.js +1 -1
  216. package/dist/rules/dispatch-errors.js.map +1 -1
  217. package/dist/rules/dispatcher.d.ts +39 -7
  218. package/dist/rules/dispatcher.d.ts.map +1 -1
  219. package/dist/rules/dispatcher.js +363 -123
  220. package/dist/rules/dispatcher.js.map +1 -1
  221. package/dist/rules/event-rules.d.ts +69 -1
  222. package/dist/rules/event-rules.d.ts.map +1 -1
  223. package/dist/rules/event-rules.js +151 -5
  224. package/dist/rules/event-rules.js.map +1 -1
  225. package/dist/rules/review-source-tool.js +1 -1
  226. package/dist/rules/rule-group.d.ts +18 -1
  227. package/dist/rules/rule-group.d.ts.map +1 -1
  228. package/dist/rules/rule-group.js +52 -8
  229. package/dist/rules/rule-group.js.map +1 -1
  230. package/dist/rules/run-bearing.d.ts +8 -0
  231. package/dist/rules/run-bearing.d.ts.map +1 -0
  232. package/dist/rules/run-bearing.js +11 -0
  233. package/dist/rules/run-bearing.js.map +1 -0
  234. package/dist/rules/start-coordinator.d.ts +2 -3
  235. package/dist/rules/start-coordinator.d.ts.map +1 -1
  236. package/dist/rules/start-coordinator.js +25 -38
  237. package/dist/rules/start-coordinator.js.map +1 -1
  238. package/dist/rules/tools.js +2 -1
  239. package/dist/rules/tools.js.map +1 -1
  240. package/dist/rules/transition-service.d.ts +16 -0
  241. package/dist/rules/transition-service.d.ts.map +1 -1
  242. package/dist/rules/transition-service.js +34 -10
  243. package/dist/rules/transition-service.js.map +1 -1
  244. package/dist/rules/types.d.ts +18 -5
  245. package/dist/rules/types.d.ts.map +1 -1
  246. package/dist/rules/types.js +2 -1
  247. package/dist/rules/types.js.map +1 -1
  248. package/dist/rules/update-fold.d.ts +32 -0
  249. package/dist/rules/update-fold.d.ts.map +1 -0
  250. package/dist/rules/update-fold.js +60 -0
  251. package/dist/rules/update-fold.js.map +1 -0
  252. package/dist/rules/validation.d.ts.map +1 -1
  253. package/dist/rules/validation.js +54 -6
  254. package/dist/rules/validation.js.map +1 -1
  255. package/dist/sandbox/session-retirement.d.ts +6 -0
  256. package/dist/sandbox/session-retirement.d.ts.map +1 -1
  257. package/dist/sandbox/session-retirement.js +17 -0
  258. package/dist/sandbox/session-retirement.js.map +1 -1
  259. package/dist/session/factory-session.d.ts.map +1 -1
  260. package/dist/session/factory-session.js +2 -1
  261. package/dist/session/factory-session.js.map +1 -1
  262. package/dist/session/live-sessions.d.ts +6 -1
  263. package/dist/session/live-sessions.d.ts.map +1 -1
  264. package/dist/session/live-sessions.js +4 -0
  265. package/dist/session/live-sessions.js.map +1 -1
  266. package/dist/session/resource-migration.d.ts.map +1 -1
  267. package/dist/session/resource-migration.js +2 -3
  268. package/dist/session/resource-migration.js.map +1 -1
  269. package/dist/session/run-audit.d.ts +10 -1
  270. package/dist/session/run-audit.d.ts.map +1 -1
  271. package/dist/session/run-audit.js +9 -1
  272. package/dist/session/run-audit.js.map +1 -1
  273. package/dist/session/self-review-gate.d.ts +26 -2
  274. package/dist/session/self-review-gate.d.ts.map +1 -1
  275. package/dist/session/self-review-gate.js +60 -10
  276. package/dist/session/self-review-gate.js.map +1 -1
  277. package/dist/session/session-row-query.d.ts +25 -0
  278. package/dist/session/session-row-query.d.ts.map +1 -0
  279. package/dist/session/session-row-query.js +47 -0
  280. package/dist/session/session-row-query.js.map +1 -0
  281. package/dist/session/session-row-status.d.ts +16 -0
  282. package/dist/session/session-row-status.d.ts.map +1 -0
  283. package/dist/session/session-row-status.js +14 -0
  284. package/dist/session/session-row-status.js.map +1 -0
  285. package/dist/session/session-row-view.d.ts +13 -0
  286. package/dist/session/session-row-view.d.ts.map +1 -0
  287. package/dist/session/session-row-view.js +118 -0
  288. package/dist/session/session-row-view.js.map +1 -0
  289. package/dist/session/session-rows.d.ts +60 -0
  290. package/dist/session/session-rows.d.ts.map +1 -0
  291. package/dist/session/session-rows.js +307 -0
  292. package/dist/session/session-rows.js.map +1 -0
  293. package/dist/session/session-threads.d.ts.map +1 -1
  294. package/dist/session/session-threads.js +1 -0
  295. package/dist/session/session-threads.js.map +1 -1
  296. package/dist/session/session-unloader.d.ts +101 -0
  297. package/dist/session/session-unloader.d.ts.map +1 -0
  298. package/dist/session/session-unloader.js +278 -0
  299. package/dist/session/session-unloader.js.map +1 -0
  300. package/dist/session/source-control-tools.d.ts +14 -7
  301. package/dist/session/source-control-tools.d.ts.map +1 -1
  302. package/dist/session/source-control-tools.js +10 -2
  303. package/dist/session/source-control-tools.js.map +1 -1
  304. package/dist/session/work-item-repository.d.ts +49 -1
  305. package/dist/session/work-item-repository.d.ts.map +1 -1
  306. package/dist/session/work-item-repository.js +118 -15
  307. package/dist/session/work-item-repository.js.map +1 -1
  308. package/dist/session/work-item-state-processor.d.ts.map +1 -1
  309. package/dist/session/work-item-state-processor.js +44 -8
  310. package/dist/session/work-item-state-processor.js.map +1 -1
  311. package/dist/session-list-changes.d.ts +9 -0
  312. package/dist/session-list-changes.d.ts.map +1 -0
  313. package/dist/session-list-changes.js +54 -0
  314. package/dist/session-list-changes.js.map +1 -0
  315. package/dist/storage/announced-lists.d.ts +14 -0
  316. package/dist/storage/announced-lists.d.ts.map +1 -0
  317. package/dist/storage/announced-lists.js +78 -0
  318. package/dist/storage/announced-lists.js.map +1 -0
  319. package/dist/storage/domains/audit/actions.d.ts +2 -1
  320. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  321. package/dist/storage/domains/audit/actions.js +3 -1
  322. package/dist/storage/domains/audit/actions.js.map +1 -1
  323. package/dist/storage/domains/boards/base.d.ts +163 -15
  324. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  325. package/dist/storage/domains/boards/base.js +440 -48
  326. package/dist/storage/domains/boards/base.js.map +1 -1
  327. package/dist/storage/domains/boards/schemas.d.ts +6 -0
  328. package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
  329. package/dist/storage/domains/boards/schemas.js +95 -1
  330. package/dist/storage/domains/boards/schemas.js.map +1 -1
  331. package/dist/storage/domains/custom-providers/base.d.ts +62 -19
  332. package/dist/storage/domains/custom-providers/base.d.ts.map +1 -1
  333. package/dist/storage/domains/custom-providers/base.js +131 -100
  334. package/dist/storage/domains/custom-providers/base.js.map +1 -1
  335. package/dist/storage/domains/intake/base.d.ts +25 -7
  336. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  337. package/dist/storage/domains/intake/base.js +83 -19
  338. package/dist/storage/domains/intake/base.js.map +1 -1
  339. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  340. package/dist/storage/domains/projects/base.js +19 -10
  341. package/dist/storage/domains/projects/base.js.map +1 -1
  342. package/dist/storage/domains/source-control/base.d.ts +8 -0
  343. package/dist/storage/domains/source-control/base.d.ts.map +1 -1
  344. package/dist/storage/domains/source-control/base.js +110 -61
  345. package/dist/storage/domains/source-control/base.js.map +1 -1
  346. package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
  347. package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
  348. package/dist/storage/domains/source-control/inmemory.js +8 -5
  349. package/dist/storage/domains/source-control/inmemory.js.map +1 -1
  350. package/dist/storage/domains/work-items/base.d.ts +57 -18
  351. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  352. package/dist/storage/domains/work-items/base.js +168 -83
  353. package/dist/storage/domains/work-items/base.js.map +1 -1
  354. package/dist/storage/domains/work-items/cards.d.ts +3 -2
  355. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  356. package/dist/storage/domains/work-items/cards.js +4 -2
  357. package/dist/storage/domains/work-items/cards.js.map +1 -1
  358. package/dist/tools/audit-events-tool.d.ts +2 -2
  359. package/dist/tools/read-tools.d.ts +9 -5
  360. package/dist/tools/read-tools.d.ts.map +1 -1
  361. package/dist/tools/read-tools.js +61 -54
  362. package/dist/tools/read-tools.js.map +1 -1
  363. package/dist/tools/session-tools.d.ts +0 -13
  364. package/dist/tools/session-tools.d.ts.map +1 -1
  365. package/dist/tools/session-tools.js +128 -341
  366. package/dist/tools/session-tools.js.map +1 -1
  367. package/dist/tools/work-item-tools.d.ts +3 -0
  368. package/dist/tools/work-item-tools.d.ts.map +1 -1
  369. package/dist/tools/work-item-tools.js +99 -27
  370. package/dist/tools/work-item-tools.js.map +1 -1
  371. package/dist/work-item-branch.d.ts +4 -0
  372. package/dist/work-item-branch.d.ts.map +1 -1
  373. package/dist/work-item-branch.js +7 -1
  374. package/dist/work-item-branch.js.map +1 -1
  375. package/dist/work-items/card-context-sessions.d.ts +50 -0
  376. package/dist/work-items/card-context-sessions.d.ts.map +1 -0
  377. package/dist/work-items/card-context-sessions.js +84 -0
  378. package/dist/work-items/card-context-sessions.js.map +1 -0
  379. package/dist/work-items/card-reference.d.ts +21 -0
  380. package/dist/work-items/card-reference.d.ts.map +1 -0
  381. package/dist/work-items/card-reference.js +58 -0
  382. package/dist/work-items/card-reference.js.map +1 -0
  383. package/dist/work-items/change-requests.d.ts +87 -0
  384. package/dist/work-items/change-requests.d.ts.map +1 -0
  385. package/dist/work-items/change-requests.js +134 -0
  386. package/dist/work-items/change-requests.js.map +1 -0
  387. package/dist/work-items/create-work-item.d.ts +7 -2
  388. package/dist/work-items/create-work-item.d.ts.map +1 -1
  389. package/dist/work-items/create-work-item.js +44 -13
  390. package/dist/work-items/create-work-item.js.map +1 -1
  391. package/dist/work-items/list-related-cards.d.ts.map +1 -1
  392. package/dist/work-items/list-related-cards.js +1 -1
  393. package/dist/work-items/list-related-cards.js.map +1 -1
  394. package/dist/work-items/providers/github.d.ts.map +1 -1
  395. package/dist/work-items/providers/github.js +1 -0
  396. package/dist/work-items/providers/github.js.map +1 -1
  397. package/factory-skills/factory-build/SKILL.md +1 -1
  398. package/factory-skills/factory-plan/SKILL.md +5 -3
  399. package/factory-skills/factory-self-review/SKILL.md +2 -0
  400. package/factory-skills/factory-triage/SKILL.md +1 -1
  401. package/package.json +10 -10
@@ -1,9 +1,11 @@
1
- import { INTAKE_ROUTE_RULE_FIELDS, STATUS_EVENTS, routeEventsProblem } from "../boards/board-events.js";
1
+ import { CLOSE_REASONS, INTAKE_ROUTE_RULE_FIELDS, ROUTE_EVENTS, STATUS_EVENTS, routeEventsProblem } from "../boards/board-events.js";
2
2
  import { storedBoardDefinitionSchema, storedBoardInputSchema, storedPhaseInputSchema } from "../boards/stored-board.js";
3
3
  import { cardRuleGroupSchema, ruleGroupSchema } from "../rules/rule-group.js";
4
4
  import { BOARD_IDENTIFIER_RE } from "../rules/validation.js";
5
+ import { SESSION_ROW_GROUP_BYS, SESSION_ROW_SORTS, SESSION_ROW_STATUSES, SESSION_ROW_UPDATED_WITHIN, sessionRowOwnerSchema } from "../session/session-row-query.js";
5
6
  import "../storage/domains/boards/base.js";
6
7
  import { FACTORY_MODEL_SCOPES } from "../storage/domains/projects/base.js";
8
+ import { PULL_REQUEST_STATUSES } from "../work-items/change-requests.js";
7
9
  import { validateSkillContent } from "@mastra/core/skills";
8
10
  import { z } from "zod";
9
11
  import { THINKING_LEVEL_VALUES } from "@mastra/code-sdk/thinking";
@@ -80,7 +82,12 @@ const intakeRouteTargetSchema = z.object({
80
82
  * File a pull request on the card of the issue it closes (on `boardKey`) instead of a new card;
81
83
  * that card moves to `phaseKey` when its board allows it. Matches no other arrival.
82
84
  */
83
- joinClosedIssue: z.boolean().optional()
85
+ joinClosedIssue: z.boolean().optional(),
86
+ /**
87
+ * On a route moving existing cards on later events, the board the card moves to, at `phaseKey`;
88
+ * `boardKey` stays the board whose cards the route moves. Unset keeps the card on `boardKey`.
89
+ */
90
+ moveToBoardKey: boardIdentifierSchema.nullable().optional()
84
91
  }).strict();
85
92
  const intakeRouteWhenSchema = ruleGroupSchema(INTAKE_ROUTE_RULE_FIELDS);
86
93
  const intakeRouteFields = {
@@ -90,8 +97,12 @@ const intakeRouteFields = {
90
97
  when: intakeRouteWhenSchema.nullable(),
91
98
  /** Where matching cards land. */
92
99
  target: intakeRouteTargetSchema,
93
- /** The status events the route handles. `work_item.created` places new cards; the others move existing ones. */
94
- on: z.array(z.enum(STATUS_EVENTS, { error: (issue) => routeEventsProblem([String(issue.input)], null) ?? void 0 })).superRefine((on, ctx) => {
100
+ /**
101
+ * The events the route handles. `work_item.opened` files new issues and `pull_request.opened` new
102
+ * pull requests with no card (and moves the card of an issue whose pull request opens); the others
103
+ * move existing cards. `work_item.created`, the legacy event, files both and is kept as written.
104
+ */
105
+ on: z.array(z.enum(ROUTE_EVENTS, { error: (issue) => routeEventsProblem([String(issue.input)], null) ?? void 0 })).superRefine((on, ctx) => {
95
106
  const problem = routeEventsProblem(on, null);
96
107
  if (problem) ctx.addIssue({
97
108
  code: "custom",
@@ -104,7 +115,9 @@ const intakeRouteInputSchema = z.object({
104
115
  enabled: intakeRouteFields.enabled.default(true),
105
116
  when: intakeRouteFields.when.default(null),
106
117
  target: intakeRouteFields.target,
107
- on: intakeRouteFields.on.optional()
118
+ on: intakeRouteFields.on.optional(),
119
+ /** Restores a route read with `pullRequestOpenedMovesOnly` as it was: moving cards on `pull_request.opened`, filing none. */
120
+ pullRequestOpenedMovesOnly: z.literal(true).optional()
108
121
  }).strict();
109
122
  /** Changes the named fields; send the `revision` you read so a concurrent edit is not overwritten. */
110
123
  const intakeRoutePatchSchema = z.object({
@@ -115,9 +128,17 @@ const intakeRoutePatchSchema = z.object({
115
128
  on: intakeRouteFields.on.optional(),
116
129
  expectedRevision: boardRevisionSchema
117
130
  }).strict().refine(({ expectedRevision: _revision, ...fields }) => Object.values(fields).some((value) => value !== void 0), { message: "Change at least one field." });
118
- const intakeRouteReorderBodySchema = z.object({
119
- /** Every route of the project, once each, in the new order. */
120
- ids: z.array(uuidSchema).min(1).max(100).refine((ids) => new Set(ids).size === ids.length, { message: "Each route may appear only once." }) }).strict();
131
+ /** Bounds a whole-project reorder, which names every rule of every board. */
132
+ const MAX_PROJECT_INTAKE_ROUTES = 1e4;
133
+ const intakeRouteReorderBodySchema = z.object({
134
+ /** Reorders only this board's rules, within the places they hold; omitted, the whole project's. */
135
+ boardKey: z.string().min(1).max(128).optional(),
136
+ /** Every rule of the board (or of the project), once each, in the new order. */
137
+ ids: z.array(uuidSchema).min(1).max(MAX_PROJECT_INTAKE_ROUTES).refine((ids) => new Set(ids).size === ids.length, { message: "Each route may appear only once." })
138
+ }).strict().refine(({ boardKey, ids }) => boardKey === void 0 || ids.length <= 100, {
139
+ message: `A board has at most 100 intake rules.`,
140
+ path: ["ids"]
141
+ });
121
142
  const intakeRouteSchema = z.object({
122
143
  id: z.string(),
123
144
  name: z.string(),
@@ -128,9 +149,15 @@ const intakeRouteSchema = z.object({
128
149
  target: z.object({
129
150
  boardKey: z.string(),
130
151
  phaseKey: z.string().nullable(),
131
- joinClosedIssue: z.boolean()
152
+ joinClosedIssue: z.boolean(),
153
+ moveToBoardKey: z.string().nullable()
132
154
  }),
133
- on: z.array(z.enum(STATUS_EVENTS)),
155
+ on: z.array(z.enum(ROUTE_EVENTS)),
156
+ /**
157
+ * True on a route stored by 0.28 naming `pull_request.opened`: there it only moves a card, and
158
+ * files no pull request, through every edit. Add a route to file pull requests.
159
+ */
160
+ pullRequestOpenedMovesOnly: z.literal(true).optional(),
134
161
  /** Send it back as `expectedRevision` when editing or deleting. */
135
162
  revision: z.number().int(),
136
163
  createdBy: z.string(),
@@ -158,6 +185,333 @@ const intakeRerouteApplyResponseSchema = z.object({
158
185
  moved: z.number().int(),
159
186
  skipped: z.number().int()
160
187
  });
188
+ const intakeRouteListQuerySchema = z.object({
189
+ /** Lists only this board's rules, in their order. */
190
+ boardKey: z.string().min(1).max(128).optional() }).strict();
191
+ const intakeOrderResponseSchema = z.object({
192
+ /** Every board of the project, in the order intake asks them. */
193
+ boards: z.array(z.object({
194
+ boardKey: z.string(),
195
+ name: z.string()
196
+ })),
197
+ /**
198
+ * `derived` follows the rule list until an admin sets the order; then it is `explicit`. A project
199
+ * created with intake order has its own order from the start, so it is `explicit` from the start.
200
+ */
201
+ origin: z.enum(["derived", "explicit"]),
202
+ /** Which evaluator places the project's new items now: `route-list` (the old one) or `intake-order`. */
203
+ evaluator: z.enum(["route-list", "intake-order"]),
204
+ /**
205
+ * What decided `evaluator`: the Factory's `intake.evaluator` option or `FACTORY_INTAKE_EVALUATOR`
206
+ * (forced on every project), the project's own setting, or none (a project from before the
207
+ * setting, on `route-list`).
208
+ */
209
+ evaluatorSource: z.enum([
210
+ "option",
211
+ "env",
212
+ "project",
213
+ "legacy"
214
+ ]),
215
+ /** The project's own setting, used unless one is forced; null for a project from before the setting. */
216
+ projectEvaluator: z.enum(["route-list", "intake-order"]).nullable(),
217
+ /** Both evaluators run over the project's newest 200 items against this order, worked out on each read. */
218
+ comparison: z.object({
219
+ compared: z.number().int(),
220
+ differing: z.number().int(),
221
+ notRouted: z.number().int()
222
+ }),
223
+ /** Whether the caller may change the order. */
224
+ canEdit: z.boolean()
225
+ });
226
+ const intakeOrderBodySchema = z.object({
227
+ /** Every board of the project, once each, in the new order. */
228
+ boardKeys: z.array(z.string().min(1).max(128)).min(1).max(MAX_PROJECT_INTAKE_ROUTES).refine((keys) => new Set(keys).size === keys.length, { message: "Each board may appear only once." }).optional(),
229
+ /** Switches the project's evaluator; a forced one still wins until it is unset. */
230
+ evaluator: z.enum(["route-list", "intake-order"]).optional()
231
+ }).strict().refine((body) => body.boardKeys !== void 0 || body.evaluator !== void 0, { message: "Name the boardKeys, the evaluator, or both." });
232
+ const intakeDecisionSchema = z.object({
233
+ id: z.string(),
234
+ outcome: z.enum([
235
+ "placed",
236
+ "not_routed",
237
+ "rule_skipped",
238
+ "rule_retired"
239
+ ]),
240
+ evaluator: z.enum(["route-list", "intake-order"]),
241
+ boardKey: z.string().nullable(),
242
+ routeId: z.string().nullable(),
243
+ /** Why no board took it. */
244
+ reason: z.string().nullable(),
245
+ sourceKey: z.string().nullable(),
246
+ title: z.string(),
247
+ url: z.string().nullable(),
248
+ decidedAt: z.string()
249
+ });
250
+ const intakeNotRoutedQuerySchema = z.object({
251
+ limit: z.coerce.number().int().min(1).max(100).optional(),
252
+ /** The `nextCursor` of the page before. */
253
+ cursor: z.string().min(1).max(200).optional()
254
+ }).strict();
255
+ const intakeNotRoutedResponseSchema = z.object({
256
+ /** Oldest first. */
257
+ notRouted: z.array(intakeDecisionSchema),
258
+ /** Pass as `cursor` for the next page; null on the last. */
259
+ nextCursor: z.string().nullable(),
260
+ /** Whether the caller may route an item again. */
261
+ canEdit: z.boolean()
262
+ });
263
+ const intakeSkippedResponseSchema = z.object({
264
+ /** Card-move rules that matched but whose target couldn't take the card, in the last 30 days. */
265
+ skipped: z.array(z.object({
266
+ routeId: z.string(),
267
+ count: z.number().int(),
268
+ latest: intakeDecisionSchema
269
+ })) });
270
+ const intakeDecisionPathSchema = z.object({
271
+ id: uuidSchema,
272
+ decisionId: uuidSchema
273
+ });
274
+ const intakeRouteAgainResponseSchema = z.object({
275
+ /** The item is queued to be filed here; the card appears once the dispatcher files it. */
276
+ status: z.literal("queued"),
277
+ boardKey: z.string(),
278
+ phaseKey: z.string(),
279
+ routeId: z.string()
280
+ });
281
+ /** A board's rules as edited, not saved yet: they stand in for all of that board's rules. */
282
+ const intakeDraftBoardSchema = z.object({
283
+ boardKey: z.string().min(1).max(128),
284
+ routes: z.array(z.object({
285
+ /** The saved rule this edits, so its counts line up; omitted for a new rule. */
286
+ id: uuidSchema.optional(),
287
+ name: intakeRouteFields.name,
288
+ enabled: intakeRouteFields.enabled.default(true),
289
+ when: intakeRouteFields.when.default(null),
290
+ target: z.object({
291
+ phaseKey: z.string().min(1).max(128).nullable().optional(),
292
+ /** On a card-move rule: the board the card moves to; unset keeps it on this board. */
293
+ moveToBoardKey: intakeRouteTargetSchema.shape.moveToBoardKey,
294
+ /** On a pull request rule: join the card of the issue it closes, as the saved rule does. */
295
+ joinClosedIssue: z.boolean().optional()
296
+ }).strict(),
297
+ on: intakeRouteFields.on.optional()
298
+ }).strict()).max(100)
299
+ }).strict();
300
+ const intakeDraftFields = {
301
+ /** Unsaved rules, board by board; boards not named run their saved rules. */
302
+ boards: z.array(intakeDraftBoardSchema).max(MAX_PROJECT_INTAKE_ROUTES).refine((boards) => new Set(boards.map((board) => board.boardKey)).size === boards.length, { message: "Each board may appear only once." }).optional(),
303
+ /** An unsaved intake order; omitted, the saved one. */
304
+ order: intakeOrderBodySchema.shape.boardKeys.optional()
305
+ };
306
+ const intakeDryRunBodySchema = z.object(intakeDraftFields).strict();
307
+ const intakePlacementSchema = z.object({
308
+ boardKey: z.string(),
309
+ routeId: z.string(),
310
+ phase: z.string()
311
+ });
312
+ const intakeKeysByBoardSchema = z.array(z.object({
313
+ boardKey: z.string(),
314
+ keys: z.array(z.string())
315
+ }));
316
+ const intakeDryRunResponseSchema = z.object({
317
+ /**
318
+ * The evaluator that files this project's items. Both endpoints always answer as `intake-order`;
319
+ * under `route-list` filing can land items elsewhere, such as on the default board.
320
+ */
321
+ evaluator: z.enum(["route-list", "intake-order"]),
322
+ /** How many of the project's newest items (at most 200) were decided, from their stored facts. */
323
+ sampled: z.number().int(),
324
+ /** Every board in intake order, with what it and each of its rules would take. */
325
+ boards: z.array(z.object({
326
+ boardKey: z.string(),
327
+ name: z.string(),
328
+ /** Keys of the items the board would take. */
329
+ takes: z.array(z.string()),
330
+ /** Items its rules matched that another board took first, by that board. */
331
+ lostTo: intakeKeysByBoardSchema,
332
+ rules: z.array(z.object({
333
+ /** A rule not saved yet reads `draft:<boardKey>:<index>`. */
334
+ routeId: z.string(),
335
+ name: z.string().nullable(),
336
+ enabled: z.boolean(),
337
+ takes: z.array(z.string()),
338
+ /** Items it matched but an earlier rule took, by the board that took them. */
339
+ lost: intakeKeysByBoardSchema,
340
+ /** Cards it actually filed in the last 30 days. */
341
+ filed: z.number().int()
342
+ }))
343
+ })),
344
+ /** Keys of the items no board would take. */
345
+ notRouted: z.array(z.string()),
346
+ /** With unsaved rules or order: how many items land somewhere other than the saved ones put them. */
347
+ changed: z.number().int().optional(),
348
+ items: z.array(z.object({
349
+ key: z.string(),
350
+ /** The card's id, or the Not routed decision's. */
351
+ id: z.string(),
352
+ kind: z.enum(["card", "not_routed"]),
353
+ title: z.string(),
354
+ url: z.string().nullable(),
355
+ placement: intakePlacementSchema.nullable(),
356
+ /** Every rule that matched and could take it, in the order intake asked them; the first won. */
357
+ matched: z.array(z.object({
358
+ boardKey: z.string(),
359
+ routeId: z.string()
360
+ })),
361
+ /** With unsaved rules or order: where the saved ones put it. */
362
+ before: intakePlacementSchema.nullable().optional()
363
+ })),
364
+ /** Whether the caller may run unsaved rules or order. */
365
+ canEdit: z.boolean()
366
+ });
367
+ /** The most labels or assignees one test event may name on each side. */
368
+ const MAX_TEST_EVENT_NAMES = 100;
369
+ const itemChangeSchema = z.object({
370
+ added: z.array(z.string().min(1).max(500)).max(MAX_TEST_EVENT_NAMES).default([]),
371
+ removed: z.array(z.string().min(1).max(500)).max(MAX_TEST_EVENT_NAMES).default([])
372
+ }).strict();
373
+ /** A status event as card-move rules read it. */
374
+ const intakeTestEventSchema = z.object({
375
+ type: z.enum(STATUS_EVENTS),
376
+ /** On `work_item.closed`. */
377
+ reason: z.enum(CLOSE_REASONS).optional(),
378
+ /** On an update: the labels and assignees it changed. */
379
+ labels: itemChangeSchema.optional(),
380
+ assignees: itemChangeSchema.optional(),
381
+ /** On a pull request event: whether that pull request's author is trusted. */
382
+ pullRequestTrusted: z.boolean().optional()
383
+ }).strict();
384
+ const intakeTestBodySchema = z.object({
385
+ ...intakeDraftFields,
386
+ /** An issue or pull request URL; one the Factory has never seen is fetched once, read-only, from a linked source. */
387
+ url: z.string().trim().url().max(2e3).optional(),
388
+ /** A recent item: a card's id, or a Not routed decision's. */
389
+ itemId: uuidSchema.optional(),
390
+ /** A status event to try on the item's card, as if it had just happened; its recent events are replayed either way. */
391
+ event: intakeTestEventSchema.optional()
392
+ }).strict().refine((body) => body.url === void 0 !== (body.itemId === void 0), { message: "Send either a url or an itemId." });
393
+ const failedConditionSchema = z.object({
394
+ field: z.string(),
395
+ operator: z.string(),
396
+ value: z.unknown().optional(),
397
+ /** The item's value for the field; null when it has none. */
398
+ actual: z.unknown()
399
+ });
400
+ const intakeTestResponseSchema = z.object({
401
+ item: z.object({
402
+ title: z.string(),
403
+ url: z.string().nullable(),
404
+ /** `card` and `not_routed` are items the Factory has; `fetched` was read from its provider for this test. */
405
+ kind: z.enum([
406
+ "card",
407
+ "not_routed",
408
+ "fetched"
409
+ ]),
410
+ id: z.string().nullable()
411
+ }),
412
+ placement: intakePlacementSchema.nullable(),
413
+ /** Why no board takes it. */
414
+ reason: z.string().nullable(),
415
+ /** What this answer leaves out, such as a fetched pull request joining an existing card instead. */
416
+ note: z.string().nullable(),
417
+ /**
418
+ * The evaluator that files this project's items. Both endpoints always answer as `intake-order`;
419
+ * under `route-list` filing can land items elsewhere, such as on the default board.
420
+ */
421
+ evaluator: z.enum(["route-list", "intake-order"]),
422
+ /** Every board in intake order and every placing rule on it, with what it answered. */
423
+ boards: z.array(z.object({
424
+ boardKey: z.string(),
425
+ name: z.string(),
426
+ rules: z.array(z.object({
427
+ routeId: z.string(),
428
+ name: z.string().nullable(),
429
+ phase: z.string(),
430
+ /** `took` decides; `lost` matched after the rule that took it; `phase_refuses` matched but its phase can't hold the item. */
431
+ outcome: z.enum([
432
+ "took",
433
+ "lost",
434
+ "no_match",
435
+ "phase_refuses",
436
+ "disabled"
437
+ ]),
438
+ /** With `no_match`: the conditions it failed on. */
439
+ failed: z.array(failedConditionSchema).optional(),
440
+ /** With `lost`: the rule that took it. */
441
+ to: z.object({
442
+ boardKey: z.string(),
443
+ routeId: z.string()
444
+ }).optional()
445
+ }))
446
+ })),
447
+ /** On a card: where it is now, and the intake rule that filed it, if one did. */
448
+ current: z.object({
449
+ boardKey: z.string(),
450
+ phase: z.string().nullable(),
451
+ routeId: z.string().nullable()
452
+ }).nullable(),
453
+ /**
454
+ * On a card: the event sent in the request, then its recent status events newest first, each
455
+ * replayed against today's rules (or the draft) and the card as it is now.
456
+ */
457
+ moves: z.array(z.object({
458
+ /** The stored event's decision; null for the event sent in the request. */
459
+ decisionId: z.string().nullable(),
460
+ at: z.string().nullable(),
461
+ event: z.object({
462
+ type: z.enum(STATUS_EVENTS),
463
+ reason: z.enum(CLOSE_REASONS).optional(),
464
+ labels: z.object({
465
+ added: z.array(z.string()),
466
+ removed: z.array(z.string())
467
+ }).optional(),
468
+ assignees: z.object({
469
+ added: z.array(z.string()),
470
+ removed: z.array(z.string())
471
+ }).optional(),
472
+ pullRequestTrusted: z.boolean().optional()
473
+ }),
474
+ /**
475
+ * `moves` to `to`; `stays` where it is; `rule_default` leaves it to the integration's own move
476
+ * (to `phase`, when there is one) because no rule takes it; `ignored` when the event can't move
477
+ * a card in its state, with `reason`; `unknown` when an update burst reaches back past the
478
+ * history read, with `reason`.
479
+ */
480
+ outcome: z.enum([
481
+ "moves",
482
+ "stays",
483
+ "rule_default",
484
+ "ignored",
485
+ "unknown"
486
+ ]),
487
+ to: z.object({
488
+ boardKey: z.string(),
489
+ phase: z.string(),
490
+ routeId: z.string()
491
+ }).nullable(),
492
+ phase: z.string().nullable(),
493
+ reason: z.string().nullable(),
494
+ /** Every rule on the card's board that handles the event, top to bottom. */
495
+ rules: z.array(z.object({
496
+ routeId: z.string(),
497
+ name: z.string().nullable(),
498
+ /** `skipped` matched but its target board or phase can't take the card, with `reason`. */
499
+ outcome: z.enum([
500
+ "took",
501
+ "lost",
502
+ "no_match",
503
+ "skipped",
504
+ "disabled"
505
+ ]),
506
+ failed: z.array(failedConditionSchema).optional(),
507
+ to: z.object({
508
+ boardKey: z.string(),
509
+ routeId: z.string()
510
+ }).optional(),
511
+ reason: z.string().optional()
512
+ }))
513
+ }))
514
+ });
161
515
  const workItemPathSchema = z.object({ id: uuidSchema });
162
516
  const transitionPathSchema = z.object({
163
517
  id: uuidSchema,
@@ -201,6 +555,12 @@ const runQueueEntrySchema = z.object({
201
555
  "sendMessage",
202
556
  "signalActivity"
203
557
  ]),
558
+ /**
559
+ * `interactive`: a reply a person sent on the card's pull request or issue,
560
+ * claimed ahead of automated runs into its own reserve of slots.
561
+ * `automated`: everything else.
562
+ */
563
+ lane: z.enum(["automated", "interactive"]),
204
564
  role: z.string().nullable(),
205
565
  /** The skill an `invokeSkill` run starts; `null` for a prompt run and for messages and activity. */
206
566
  skillName: z.string().nullable(),
@@ -218,14 +578,29 @@ const runQueueResponseSchema = z.object({
218
578
  /** This server process's run slots; `null` when it runs no dispatcher. Other servers keep their own. */
219
579
  slots: z.object({
220
580
  scope: z.literal("server"),
581
+ /** Automated run slots, including any a person's reply borrowed once its reserve was full. */
221
582
  inUse: z.number().int(),
222
- cap: z.number().int()
583
+ cap: z.number().int(),
584
+ /** Slots kept for people's replies, on top of `cap`. */
585
+ interactive: z.object({
586
+ inUse: z.number().int(),
587
+ cap: z.number().int()
588
+ })
223
589
  }).nullable(),
224
590
  /** The project's runs holding a slot on any server. */
225
591
  running: z.number().int(),
226
592
  claimed: z.array(runQueueEntrySchema),
227
- /** Every waiting run, though `queued` lists at most the oldest 50. */
593
+ /** Every waiting run, though `queued` lists at most 50. */
228
594
  queuedCount: z.number().int(),
595
+ /** `queuedCount` split by lane. */
596
+ queuedByLane: z.object({
597
+ automated: z.number().int(),
598
+ interactive: z.number().int()
599
+ }),
600
+ /**
601
+ * Waiting replies, then automated runs, each oldest first: interactive runs are claimed before
602
+ * automated ones. `position` counts within the run's lane.
603
+ */
229
604
  queued: z.array(runQueueEntrySchema.extend({ position: z.number().int().positive() }))
230
605
  });
231
606
  const createProjectBodySchema = z.object({
@@ -474,6 +849,14 @@ const workItemListQuerySchema = z.object({
474
849
  since: void 0
475
850
  } : query);
476
851
  const countSchema = z.number().int().nonnegative();
852
+ const workItemSessionRepositoryResponseSchema = z.discriminatedUnion("status", [z.object({
853
+ status: z.literal("resolved"),
854
+ projectRepositoryId: z.string(),
855
+ slug: z.string()
856
+ }), z.object({
857
+ status: z.literal("unlinked"),
858
+ hint: z.string()
859
+ })]);
477
860
  /** What the draft page's starter buttons count on the project's default board. */
478
861
  const workItemStartersResponseSchema = z.object({
479
862
  failed: countSchema,
@@ -584,10 +967,7 @@ places: z.array(z.object({
584
967
  /** Cards of the board that match the view, each counted once: a card in two phases is one. */
585
968
  matchingTotal: countSchema,
586
969
  /** With `cards=true`: the body of every card named in `phases`, `item` and `related`, each with its `version`. */
587
- workItems: z.array(cardSchema.extend({ version: z.string() })).optional(),
588
- /** Among the named cards. */
589
- runningSessionIds: z.array(z.string()),
590
- parkedSessionIds: z.array(z.string())
970
+ workItems: z.array(cardSchema.extend({ version: z.string() })).optional()
591
971
  });
592
972
  /** What the board's filter menus offer, read over every card of the project. */
593
973
  const workItemFilterOptionsResponseSchema = z.object({
@@ -608,6 +988,124 @@ const workItemFilterOptionsResponseSchema = z.object({
608
988
  /** The Factory users who created a card, moved one or started a session on one, sorted. */
609
989
  actorIds: z.array(z.string())
610
990
  });
991
+ /** `<group key>:<count>`: how many rows of one group to list. Group keys hold colons, so the count follows the last. */
992
+ const sessionRowWindowSchema = z.string().transform((entry) => {
993
+ const colon = entry.lastIndexOf(":");
994
+ return [entry.slice(0, Math.max(colon, 0)), entry.slice(colon + 1)];
995
+ }).pipe(z.tuple([z.string().min(1).max(512), z.string().regex(/^[1-9]\d{0,2}$/).transform(Number).pipe(z.number().max(500))]));
996
+ const sessionIdQuerySchema = z.string().min(1).max(512);
997
+ const sessionRowsQuerySchema = z.object({
998
+ sort: z.enum(SESSION_ROW_SORTS).default("activity"),
999
+ groupBy: z.enum(SESSION_ROW_GROUP_BYS).default("none"),
1000
+ /** `all`, `mine`, or `owner:<user id>`. */
1001
+ owner: sessionRowOwnerSchema.default("all"),
1002
+ status: z.enum(SESSION_ROW_STATUSES).optional(),
1003
+ updated: z.enum(SESSION_ROW_UPDATED_WITHIN).optional(),
1004
+ /** `true` lists a card's other sessions under its row. */
1005
+ children: z.enum(["true"]).optional(),
1006
+ /** Repeatable. Sessions listed before every other one of their group. */
1007
+ pin: z.array(sessionIdQuerySchema).max(100).default([]).transform((ids) => new Set(ids)),
1008
+ /** The session the reader has open: its group lists it however deep it lies. */
1009
+ open: sessionIdQuerySchema.optional(),
1010
+ /** Repeatable `<group key>:<count>`: lists that group's first `count` rows instead of `SESSION_ROW_WINDOW`. */
1011
+ window: z.array(sessionRowWindowSchema).max(64).default([]).refine((windows) => new Set(windows.map(([group]) => group)).size === windows.length, { message: "Send one window per group" }).transform((windows) => new Map(windows))
1012
+ });
1013
+ const sessionRowStatusSchema = z.enum(SESSION_ROW_STATUSES);
1014
+ const changeRequestSchema = z.object({
1015
+ url: z.string().optional(),
1016
+ provider: z.enum(["github", "gitlab"]),
1017
+ number: z.number().optional(),
1018
+ status: z.enum(PULL_REQUEST_STATUSES).optional(),
1019
+ draft: z.boolean(),
1020
+ syncedAt: z.number().optional()
1021
+ });
1022
+ const sessionRowFields = {
1023
+ session: z.object({
1024
+ id: z.string(),
1025
+ sessionId: z.string(),
1026
+ projectRepositoryId: z.string().nullable(),
1027
+ userId: z.string(),
1028
+ branch: z.string(),
1029
+ title: z.string().nullable(),
1030
+ visibility: z.enum(["org", "private"]),
1031
+ createdAt: z.string(),
1032
+ owner: z.object({
1033
+ id: z.string(),
1034
+ name: z.string(),
1035
+ avatarUrl: z.string().optional()
1036
+ }).optional()
1037
+ }),
1038
+ /** `factory` for a session the Factory runs on a card's branch, `user` for one a person or Slack started. */
1039
+ origin: z.enum(["factory", "user"]),
1040
+ board: z.string().optional(),
1041
+ status: sessionRowStatusSchema,
1042
+ /** The status of the card's whole row: its most urgent session's. */
1043
+ cardStatus: sessionRowStatusSchema.optional(),
1044
+ pinned: z.boolean(),
1045
+ /** The card's last change for a card's session, else the session's. */
1046
+ updatedAt: z.string(),
1047
+ card: z.object({
1048
+ id: z.string(),
1049
+ title: z.string(),
1050
+ workItemUrl: z.string().nullable(),
1051
+ externalSource: z.object({
1052
+ integrationId: z.string(),
1053
+ type: z.string(),
1054
+ externalId: z.string(),
1055
+ workspaceId: z.string().optional(),
1056
+ url: z.string().optional()
1057
+ }).nullable()
1058
+ }).optional(),
1059
+ itemId: z.string().optional(),
1060
+ threadId: z.string().optional(),
1061
+ pullRequest: changeRequestSchema.optional(),
1062
+ cardSessionIds: z.array(z.string()).optional(),
1063
+ phaseLabel: z.string().optional(),
1064
+ runByFactory: z.literal(true).optional(),
1065
+ /** A followed card's session waiting on a person. */
1066
+ waitingSessionId: z.string().optional()
1067
+ };
1068
+ const sessionRowSchema = z.object({
1069
+ ...sessionRowFields,
1070
+ /** With `children=true`: the card's other sessions. */
1071
+ childRows: z.array(z.object(sessionRowFields)).optional()
1072
+ });
1073
+ const sessionRowsResponseSchema = z.object({
1074
+ /** Rows of the project, whatever the filters. */
1075
+ total: countSchema,
1076
+ matching: countSchema,
1077
+ groups: z.array(z.object({
1078
+ /** `board:<id>`, `user`, `slack`, `status:<status>`, `owner:<user id>` or `all`. */
1079
+ key: z.string(),
1080
+ /** Rows of this group that match the filters. */
1081
+ total: countSchema,
1082
+ openIndex: countSchema.optional(),
1083
+ /** The first of them in the view's order, keeping the open session. */
1084
+ rows: z.array(sessionRowSchema)
1085
+ })),
1086
+ /** Boards some row belongs to, whatever the filters. */
1087
+ boards: z.array(z.string()),
1088
+ /** People who own some row, whatever the filters. */
1089
+ owners: z.array(z.object({
1090
+ userId: z.string(),
1091
+ name: z.string().optional(),
1092
+ avatarUrl: z.string().optional()
1093
+ }))
1094
+ });
1095
+ const sessionActivityResponseSchema = z.object({
1096
+ runningSessionIds: z.array(z.string()),
1097
+ /** Sessions of a card, or of the reader, whose run waits on a person's answer. */
1098
+ parkedSessionIds: z.array(z.string()),
1099
+ /** The status of each card's sidebar row, by card id, for the cards neither idle nor done. */
1100
+ cardStatuses: z.record(z.string(), sessionRowStatusSchema),
1101
+ /** Cards one of whose sessions is running or parked on a person: no rival run may start on them. */
1102
+ sessionHeldCardIds: z.array(z.string()),
1103
+ /** Cards in `cardStatuses` working, and waiting on a person. */
1104
+ cards: z.object({
1105
+ working: countSchema,
1106
+ waiting: countSchema
1107
+ })
1108
+ });
611
1109
  const sessionsSchema = z.record(z.string().min(1).max(64), sessionSchema);
612
1110
  const metadataSchema = z.union([z.record(z.string(), z.unknown()), z.null()]).refine((value) => {
613
1111
  try {
@@ -1076,6 +1574,7 @@ const FACTORY_ROUTE_CONTRACTS = {
1076
1574
  path: "/web/factory/projects/:id/intake-routes",
1077
1575
  description: "List a Factory project's intake routes in evaluation order",
1078
1576
  pathSchema: projectPathSchema,
1577
+ querySchema: intakeRouteListQuerySchema,
1079
1578
  responseSchema: intakeRouteListResponseSchema
1080
1579
  },
1081
1580
  intakeRouteGet: {
@@ -1131,17 +1630,68 @@ const FACTORY_ROUTE_CONTRACTS = {
1131
1630
  bodySchema: intakeRouteReorderBodySchema,
1132
1631
  responseSchema: intakeRouteListResponseSchema
1133
1632
  },
1633
+ intakeOrderGet: {
1634
+ method: "GET",
1635
+ path: "/web/factory/projects/:id/intake-order",
1636
+ description: "The order a Factory project's boards are asked to take a new item, and the evaluator in use",
1637
+ pathSchema: projectPathSchema,
1638
+ responseSchema: intakeOrderResponseSchema
1639
+ },
1640
+ intakeOrderUpdate: {
1641
+ method: "PUT",
1642
+ path: "/web/factory/projects/:id/intake-order",
1643
+ description: "Set the order a Factory project's boards are asked to take a new item, or its evaluator",
1644
+ pathSchema: projectPathSchema,
1645
+ bodySchema: intakeOrderBodySchema,
1646
+ responseSchema: intakeOrderResponseSchema
1647
+ },
1648
+ intakeNotRoutedList: {
1649
+ method: "GET",
1650
+ path: "/web/factory/projects/:id/intake/not-routed",
1651
+ description: "Items no board's intake rules took, oldest first, a page at a time",
1652
+ pathSchema: projectPathSchema,
1653
+ querySchema: intakeNotRoutedQuerySchema,
1654
+ responseSchema: intakeNotRoutedResponseSchema
1655
+ },
1656
+ intakeRouteAgain: {
1657
+ method: "POST",
1658
+ path: "/web/factory/projects/:id/intake/not-routed/:decisionId/route-again",
1659
+ description: "Run intake again for an item no board took, filing it where the rules now say",
1660
+ pathSchema: intakeDecisionPathSchema,
1661
+ responseSchema: intakeRouteAgainResponseSchema
1662
+ },
1663
+ intakeSkippedList: {
1664
+ method: "GET",
1665
+ path: "/web/factory/projects/:id/intake/skipped",
1666
+ description: "How often each card-move rule was skipped in the last 30 days, with its newest skip",
1667
+ pathSchema: projectPathSchema,
1668
+ responseSchema: intakeSkippedResponseSchema
1669
+ },
1670
+ intakeDryRun: {
1671
+ method: "POST",
1672
+ path: "/web/factory/projects/:id/intake/dry-run",
1673
+ description: "Run a Factory project's intake rules, saved or unsaved, over its newest 200 items without filing anything",
1674
+ pathSchema: projectPathSchema,
1675
+ bodySchema: intakeDryRunBodySchema,
1676
+ responseSchema: intakeDryRunResponseSchema
1677
+ },
1678
+ intakeTest: {
1679
+ method: "POST",
1680
+ path: "/web/factory/projects/:id/intake/test",
1681
+ description: "Show where intake would file one item, and what every rule answered, without filing it",
1682
+ pathSchema: projectPathSchema,
1683
+ bodySchema: intakeTestBodySchema,
1684
+ responseSchema: intakeTestResponseSchema
1685
+ },
1134
1686
  workItemList: {
1135
1687
  method: "GET",
1136
1688
  path: "/web/factory/projects/:id/work-items",
1137
- description: "List Factory work items and running sessions",
1689
+ description: "List Factory work items",
1138
1690
  pathSchema: projectPathSchema,
1139
1691
  querySchema: workItemListQuerySchema,
1140
1692
  responseSchema: z.object({
1141
1693
  /** Every listed card, or with `removedIds` only the cards changed since the `since` sent. */
1142
1694
  workItems: z.array(cardSchema),
1143
- runningSessionIds: z.array(z.string()),
1144
- parkedSessionIds: z.array(z.string()),
1145
1695
  /** With `started=false`: how many cards matched, of which `workItems` holds the first `limit`. */
1146
1696
  total: z.number().int().nonnegative().optional(),
1147
1697
  /** Names this read of the whole board. Absent when the next read must list it whole again. */
@@ -1174,6 +1724,21 @@ const FACTORY_ROUTE_CONTRACTS = {
1174
1724
  pathSchema: projectPathSchema,
1175
1725
  responseSchema: workItemFilterOptionsResponseSchema
1176
1726
  },
1727
+ sessionRows: {
1728
+ method: "GET",
1729
+ path: "/web/factory/projects/:id/session-rows",
1730
+ description: "List the sidebar's session rows of a view, grouped and in order, with how many match",
1731
+ pathSchema: projectPathSchema,
1732
+ querySchema: sessionRowsQuerySchema,
1733
+ responseSchema: sessionRowsResponseSchema
1734
+ },
1735
+ sessionActivity: {
1736
+ method: "GET",
1737
+ path: "/web/factory/projects/:id/session-activity",
1738
+ description: "List which of a project's sessions are running or waiting on a person, and each card's status",
1739
+ pathSchema: projectPathSchema,
1740
+ responseSchema: sessionActivityResponseSchema
1741
+ },
1177
1742
  workItemCreate: {
1178
1743
  method: "POST",
1179
1744
  path: "/web/factory/projects/:id/work-items",
@@ -1205,6 +1770,24 @@ const FACTORY_ROUTE_CONTRACTS = {
1205
1770
  bodySchema: transitionBodySchema,
1206
1771
  responseSchema: entitySchema
1207
1772
  },
1773
+ workItemWorkingPullRequest: {
1774
+ method: "PUT",
1775
+ path: "/web/factory/projects/:id/work-items/:workItemId/working-pull-request",
1776
+ description: "Make one of the pull requests linked to a card the one its sessions work on. The only way an outside author's pull request becomes a card's working pull request.",
1777
+ pathSchema: transitionPathSchema,
1778
+ bodySchema: z.object({
1779
+ pullRequest: z.number().int().positive(),
1780
+ expectedRevision: z.number().int().nonnegative()
1781
+ }),
1782
+ responseSchema: workItemResponseSchema
1783
+ },
1784
+ workItemSessionRepository: {
1785
+ method: "GET",
1786
+ path: "/web/factory/projects/:id/work-items/:workItemId/session-repository",
1787
+ description: "The repository a session on the card is filed under, resolved as the card's runs resolve it",
1788
+ pathSchema: transitionPathSchema,
1789
+ responseSchema: workItemSessionRepositoryResponseSchema
1790
+ },
1208
1791
  workItemStart: {
1209
1792
  method: "POST",
1210
1793
  path: "/web/factory/projects/:id/runs/start",
@@ -1340,6 +1923,6 @@ const FACTORY_ROUTE_CONTRACTS = {
1340
1923
  responseSchema: skillResponseSchema
1341
1924
  }
1342
1925
  };
1343
- export { BOARD_PHASES_SORTS, FACTORY_ROUTE_CONTRACTS, MAX_SANDBOX_ENV_VALUE_LENGTH, MAX_SKILL_OVERRIDE_LENGTH, RESERVED_SANDBOX_ENV_NAMES, THINKING_LEVELS, UUID_PATTERN, attentionQuerySchema, automationRunStartBodySchema, boardDeleteQuerySchema, boardPhasesQuerySchema, boardPhasesResponseSchema, boardResetBodySchema, createProjectBodySchema, createWorkItemBodySchema, decisionQuerySchema, environmentBuildResponseSchema, environmentBuildSchema, environmentBuildStartResponseSchema, environmentBuildTriggersSchema, environmentBuildsResponseSchema, environmentLastBuildSchema, environmentSandboxSchema, intakeRouteInputSchema, intakeRoutePatchSchema, intakeRouteReorderBodySchema, metricsQuerySchema, projectEnvironmentResponseSchema, projectListRepositorySchema, replaceBoardBodySchema, runQueueResponseSchema, sandboxEnvAppliesToSchema, sandboxEnvNameSchema, sandboxEnvSetBodySchema, sandboxEnvUpdateBodySchema, skillOverrideBodySchema, skillOverrideSaveRequestSchema, startWorkItemBodySchema, transitionBodySchema, updateProjectBodySchema, updateProjectEnvironmentBodySchema, updateWorkItemBodySchema, workItemActivityQuerySchema, workItemActivityResponseSchema, workItemFilterOptionsResponseSchema, workItemStartersResponseSchema };
1926
+ export { BOARD_PHASES_SORTS, FACTORY_ROUTE_CONTRACTS, MAX_SANDBOX_ENV_VALUE_LENGTH, MAX_SKILL_OVERRIDE_LENGTH, RESERVED_SANDBOX_ENV_NAMES, THINKING_LEVELS, UUID_PATTERN, attentionQuerySchema, automationRunStartBodySchema, boardDeleteQuerySchema, boardPhasesQuerySchema, boardPhasesResponseSchema, boardResetBodySchema, createProjectBodySchema, createWorkItemBodySchema, decisionQuerySchema, environmentBuildResponseSchema, environmentBuildSchema, environmentBuildStartResponseSchema, environmentBuildTriggersSchema, environmentBuildsResponseSchema, environmentLastBuildSchema, environmentSandboxSchema, intakeDryRunBodySchema, intakeOrderBodySchema, intakeRouteInputSchema, intakeRoutePatchSchema, intakeRouteReorderBodySchema, intakeTestBodySchema, metricsQuerySchema, projectEnvironmentResponseSchema, projectListRepositorySchema, replaceBoardBodySchema, runQueueResponseSchema, sandboxEnvAppliesToSchema, sandboxEnvNameSchema, sandboxEnvSetBodySchema, sandboxEnvUpdateBodySchema, sessionActivityResponseSchema, sessionRowsQuerySchema, sessionRowsResponseSchema, skillOverrideBodySchema, skillOverrideSaveRequestSchema, startWorkItemBodySchema, transitionBodySchema, updateProjectBodySchema, updateProjectEnvironmentBodySchema, updateWorkItemBodySchema, workItemActivityQuerySchema, workItemActivityResponseSchema, workItemFilterOptionsResponseSchema, workItemSessionRepositoryResponseSchema, workItemStartersResponseSchema };
1344
1927
 
1345
1928
  //# sourceMappingURL=contracts.js.map