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

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 (232) hide show
  1. package/README.md +110 -56
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +7 -1
  4. package/dist/auth.js.map +1 -1
  5. package/dist/boards/board-events.d.ts +1 -1
  6. package/dist/boards/board-events.d.ts.map +1 -1
  7. package/dist/boards/card-facts.d.ts +3 -1
  8. package/dist/boards/card-facts.d.ts.map +1 -1
  9. package/dist/boards/card-facts.js +26 -4
  10. package/dist/boards/card-facts.js.map +1 -1
  11. package/dist/boards/default-board.d.ts +2 -2
  12. package/dist/boards/default-board.js +2 -2
  13. package/dist/boards/default-board.js.map +1 -1
  14. package/dist/boards/define-board.d.ts +1 -1
  15. package/dist/boards/define-board.d.ts.map +1 -1
  16. package/dist/boards/define-board.js.map +1 -1
  17. package/dist/boards/intake-routing.d.ts +3 -5
  18. package/dist/boards/intake-routing.d.ts.map +1 -1
  19. package/dist/boards/intake-routing.js +3 -4
  20. package/dist/boards/intake-routing.js.map +1 -1
  21. package/dist/boards/project-boards.d.ts +18 -1
  22. package/dist/boards/project-boards.d.ts.map +1 -1
  23. package/dist/boards/project-boards.js +40 -3
  24. package/dist/boards/project-boards.js.map +1 -1
  25. package/dist/boards/semantics.d.ts +4 -4
  26. package/dist/boards/semantics.d.ts.map +1 -1
  27. package/dist/boards/semantics.js +8 -10
  28. package/dist/boards/semantics.js.map +1 -1
  29. package/dist/boards/work-migrations.d.ts +24 -1
  30. package/dist/boards/work-migrations.d.ts.map +1 -1
  31. package/dist/boards/work-migrations.js +97 -2
  32. package/dist/boards/work-migrations.js.map +1 -1
  33. package/dist/boards/work-routes.d.ts +6 -1
  34. package/dist/boards/work-routes.d.ts.map +1 -1
  35. package/dist/boards/work-routes.js +20 -6
  36. package/dist/boards/work-routes.js.map +1 -1
  37. package/dist/factory.d.ts +23 -0
  38. package/dist/factory.d.ts.map +1 -1
  39. package/dist/factory.js +62 -59
  40. package/dist/factory.js.map +1 -1
  41. package/dist/feed-events.d.ts +3 -2
  42. package/dist/feed-events.d.ts.map +1 -1
  43. package/dist/feed-events.js +3 -2
  44. package/dist/feed-events.js.map +1 -1
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +2 -1
  48. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  49. package/dist/integrations/github/default-rules.js +3 -5
  50. package/dist/integrations/github/default-rules.js.map +1 -1
  51. package/dist/integrations/github/rules.d.ts +0 -6
  52. package/dist/integrations/github/rules.d.ts.map +1 -1
  53. package/dist/integrations/github/rules.js +23 -70
  54. package/dist/integrations/github/rules.js.map +1 -1
  55. package/dist/integrations/gitlab/routes.d.ts.map +1 -1
  56. package/dist/integrations/gitlab/routes.js +1 -3
  57. package/dist/integrations/gitlab/routes.js.map +1 -1
  58. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  59. package/dist/integrations/gitlab/rules.js +4 -9
  60. package/dist/integrations/gitlab/rules.js.map +1 -1
  61. package/dist/integrations/incidentio/agent-tools.js +5 -5
  62. package/dist/integrations/incidentio/agent-tools.js.map +1 -1
  63. package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
  64. package/dist/integrations/incidentio/default-rules.js.map +1 -1
  65. package/dist/integrations/incidentio/routes.d.ts +2 -2
  66. package/dist/integrations/incidentio/routes.d.ts.map +1 -1
  67. package/dist/integrations/incidentio/routes.js +10 -13
  68. package/dist/integrations/incidentio/routes.js.map +1 -1
  69. package/dist/integrations/incidentio/rules.d.ts +1 -3
  70. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  71. package/dist/integrations/incidentio/rules.js +1 -3
  72. package/dist/integrations/incidentio/rules.js.map +1 -1
  73. package/dist/integrations/jira/binding-scope.d.ts +5 -6
  74. package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
  75. package/dist/integrations/jira/binding-scope.js +9 -11
  76. package/dist/integrations/jira/binding-scope.js.map +1 -1
  77. package/dist/integrations/jira/default-rules.d.ts.map +1 -1
  78. package/dist/integrations/jira/default-rules.js.map +1 -1
  79. package/dist/integrations/jira/routes.d.ts.map +1 -1
  80. package/dist/integrations/jira/routes.js +3 -5
  81. package/dist/integrations/jira/routes.js.map +1 -1
  82. package/dist/integrations/jira/rules.d.ts +1 -3
  83. package/dist/integrations/jira/rules.d.ts.map +1 -1
  84. package/dist/integrations/jira/rules.js +1 -3
  85. package/dist/integrations/jira/rules.js.map +1 -1
  86. package/dist/integrations/linear/default-rules.d.ts.map +1 -1
  87. package/dist/integrations/linear/default-rules.js.map +1 -1
  88. package/dist/integrations/linear/routes.d.ts.map +1 -1
  89. package/dist/integrations/linear/routes.js +11 -14
  90. package/dist/integrations/linear/routes.js.map +1 -1
  91. package/dist/integrations/linear/rules.d.ts +1 -3
  92. package/dist/integrations/linear/rules.d.ts.map +1 -1
  93. package/dist/integrations/linear/rules.js +1 -3
  94. package/dist/integrations/linear/rules.js.map +1 -1
  95. package/dist/integrations/platform/connect/session-tools.d.ts +5 -0
  96. package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
  97. package/dist/integrations/platform/connect/session-tools.js +5 -0
  98. package/dist/integrations/platform/connect/session-tools.js.map +1 -1
  99. package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
  100. package/dist/integrations/platform/jira/routes.js +3 -5
  101. package/dist/integrations/platform/jira/routes.js.map +1 -1
  102. package/dist/integrations/slack/run-error-card.js +1 -0
  103. package/dist/integrations/slack/run-error-card.js.map +1 -1
  104. package/dist/provider-display-name.d.ts.map +1 -1
  105. package/dist/provider-display-name.js +1 -0
  106. package/dist/provider-display-name.js.map +1 -1
  107. package/dist/routes/automation-runs.d.ts +1 -1
  108. package/dist/routes/automation-runs.js.map +1 -1
  109. package/dist/routes/config.d.ts +7 -1
  110. package/dist/routes/config.d.ts.map +1 -1
  111. package/dist/routes/config.js +105 -22
  112. package/dist/routes/config.js.map +1 -1
  113. package/dist/routes/contracts.d.ts +3 -10
  114. package/dist/routes/contracts.d.ts.map +1 -1
  115. package/dist/routes/contracts.js +11 -9
  116. package/dist/routes/contracts.js.map +1 -1
  117. package/dist/routes/intake-routes.d.ts.map +1 -1
  118. package/dist/routes/intake-routes.js +6 -1
  119. package/dist/routes/intake-routes.js.map +1 -1
  120. package/dist/routes/intake.d.ts +0 -23
  121. package/dist/routes/intake.d.ts.map +1 -1
  122. package/dist/routes/intake.js +13 -310
  123. package/dist/routes/intake.js.map +1 -1
  124. package/dist/routes/mastra-gateway.d.ts +19 -0
  125. package/dist/routes/mastra-gateway.d.ts.map +1 -0
  126. package/dist/routes/mastra-gateway.js +120 -0
  127. package/dist/routes/mastra-gateway.js.map +1 -0
  128. package/dist/routes/projects.d.ts.map +1 -1
  129. package/dist/routes/projects.js +1 -1
  130. package/dist/routes/projects.js.map +1 -1
  131. package/dist/routes/provider-credentials.d.ts +6 -1
  132. package/dist/routes/provider-credentials.d.ts.map +1 -1
  133. package/dist/routes/provider-credentials.js +32 -2
  134. package/dist/routes/provider-credentials.js.map +1 -1
  135. package/dist/routes/route.d.ts +6 -0
  136. package/dist/routes/route.d.ts.map +1 -1
  137. package/dist/routes/route.js.map +1 -1
  138. package/dist/routes/surface.d.ts.map +1 -1
  139. package/dist/routes/surface.js +0 -2
  140. package/dist/routes/surface.js.map +1 -1
  141. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  142. package/dist/routes/tenant-credentials.js +5 -1
  143. package/dist/routes/tenant-credentials.js.map +1 -1
  144. package/dist/rules/dispatcher.d.ts +0 -5
  145. package/dist/rules/dispatcher.d.ts.map +1 -1
  146. package/dist/rules/dispatcher.js +18 -22
  147. package/dist/rules/dispatcher.js.map +1 -1
  148. package/dist/rules/rule-group.d.ts +1 -1
  149. package/dist/rules/rule-group.d.ts.map +1 -1
  150. package/dist/rules/rule-group.js +13 -5
  151. package/dist/rules/rule-group.js.map +1 -1
  152. package/dist/rules/transition-service.d.ts +2 -3
  153. package/dist/rules/transition-service.d.ts.map +1 -1
  154. package/dist/rules/transition-service.js +0 -1
  155. package/dist/rules/transition-service.js.map +1 -1
  156. package/dist/rules/types.d.ts +7 -11
  157. package/dist/rules/types.d.ts.map +1 -1
  158. package/dist/rules/types.js.map +1 -1
  159. package/dist/run-error.d.ts +1 -1
  160. package/dist/run-error.d.ts.map +1 -1
  161. package/dist/run-error.js +38 -5
  162. package/dist/run-error.js.map +1 -1
  163. package/dist/session/live-sessions.d.ts +11 -4
  164. package/dist/session/live-sessions.d.ts.map +1 -1
  165. package/dist/session/live-sessions.js +31 -10
  166. package/dist/session/live-sessions.js.map +1 -1
  167. package/dist/session/self-review-gate.d.ts +0 -2
  168. package/dist/session/self-review-gate.d.ts.map +1 -1
  169. package/dist/session/self-review-gate.js +1 -8
  170. package/dist/session/self-review-gate.js.map +1 -1
  171. package/dist/session/source-control-tools.d.ts +39 -13
  172. package/dist/session/source-control-tools.d.ts.map +1 -1
  173. package/dist/session/source-control-tools.js +54 -60
  174. package/dist/session/source-control-tools.js.map +1 -1
  175. package/dist/session/work-item-state-processor.d.ts +1 -4
  176. package/dist/session/work-item-state-processor.d.ts.map +1 -1
  177. package/dist/session/work-item-state-processor.js +5 -18
  178. package/dist/session/work-item-state-processor.js.map +1 -1
  179. package/dist/storage/domains/boards/base.d.ts +30 -8
  180. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  181. package/dist/storage/domains/boards/base.js +43 -25
  182. package/dist/storage/domains/boards/base.js.map +1 -1
  183. package/dist/storage/domains/boards/schemas.js.map +1 -1
  184. package/dist/storage/domains/comments/base.d.ts.map +1 -1
  185. package/dist/storage/domains/comments/base.js +2 -2
  186. package/dist/storage/domains/comments/base.js.map +1 -1
  187. package/dist/storage/domains/comments/routes.d.ts.map +1 -1
  188. package/dist/storage/domains/comments/routes.js +4 -2
  189. package/dist/storage/domains/comments/routes.js.map +1 -1
  190. package/dist/storage/domains/intake/base.d.ts +5 -45
  191. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  192. package/dist/storage/domains/intake/base.js +11 -89
  193. package/dist/storage/domains/intake/base.js.map +1 -1
  194. package/dist/storage/domains/projects/base.d.ts +17 -9
  195. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  196. package/dist/storage/domains/projects/base.js +15 -7
  197. package/dist/storage/domains/projects/base.js.map +1 -1
  198. package/dist/storage/domains/work-items/base.d.ts +13 -11
  199. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  200. package/dist/storage/domains/work-items/base.js +37 -33
  201. package/dist/storage/domains/work-items/base.js.map +1 -1
  202. package/dist/storage/domains/work-items/board-version.d.ts +6 -2
  203. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
  204. package/dist/storage/domains/work-items/board-version.js +20 -9
  205. package/dist/storage/domains/work-items/board-version.js.map +1 -1
  206. package/dist/work-items/providers/base.d.ts +4 -1
  207. package/dist/work-items/providers/base.d.ts.map +1 -1
  208. package/dist/work-items/providers/base.js +6 -1
  209. package/dist/work-items/providers/base.js.map +1 -1
  210. package/dist/work-items/providers/github.d.ts.map +1 -1
  211. package/dist/work-items/providers/github.js +2 -1
  212. package/dist/work-items/providers/github.js.map +1 -1
  213. package/dist/work-items/providers/gitlab.d.ts.map +1 -1
  214. package/dist/work-items/providers/gitlab.js +2 -1
  215. package/dist/work-items/providers/gitlab.js.map +1 -1
  216. package/dist/work-items/providers/jira.d.ts.map +1 -1
  217. package/dist/work-items/providers/jira.js +3 -2
  218. package/dist/work-items/providers/jira.js.map +1 -1
  219. package/dist/work-items/providers/linear.d.ts.map +1 -1
  220. package/dist/work-items/providers/linear.js +3 -2
  221. package/dist/work-items/providers/linear.js.map +1 -1
  222. package/dist/work-items/providers/types.d.ts +6 -0
  223. package/dist/work-items/providers/types.d.ts.map +1 -1
  224. package/factory-skills/configure-factory-rules/SKILL.md +2 -2
  225. package/factory-skills/factory-build/SKILL.md +5 -5
  226. package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
  227. package/factory-skills/factory-gitlab-review/SKILL.md +5 -5
  228. package/factory-skills/factory-rereview/SKILL.md +69 -23
  229. package/factory-skills/factory-review/SKILL.md +69 -23
  230. package/factory-skills/factory-self-review/SKILL.md +5 -6
  231. package/factory-skills/factory-triage/SKILL.md +8 -20
  232. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"work-migrations.js","names":[],"sources":["../../src/boards/work-migrations.ts"],"sourcesContent":["import type {\n StoredBoardInput,\n StoredBoardMigration,\n StoredBoardRecord,\n StoredPhaseInput,\n StoredPhaseRecord,\n} from '../storage/domains/boards/base.js';\nimport { boardDefinitionOf } from './stored-board.js';\nimport { OWN_CARD_HAND_OFF, workBoard } from './work.js';\n\nconst MIGRATED_FIELDS = ['runner', 'exitTool', 'tools', 'autoStart', 'autoStartWhen', 'nextPhases'] as const;\ntype MigratedField = (typeof MIGRATED_FIELDS)[number];\n\nconst PHASE_DEFAULTS = { exitTool: [null], tools: [null], autoStart: [null], autoStartWhen: [null] } as const;\n\n/**\n * What Factory stored for Work's working phases before they had runners: the seed of #29317, and\n * #29346's for the `nextPhases` it changed. Frozen: a value listed here is one a project can only\n * hold because Factory wrote it, so the migration may replace it.\n */\nconst OLD_WORK_SEED: Readonly<Record<string, Readonly<Record<MigratedField, readonly unknown[]>>>> = {\n triage: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'triage' }],\n nextPhases: [['intake', 'planning', 'done', 'canceled']],\n },\n planning: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n exitTool: [{ id: 'submit_plan', autoApprove: false }],\n nextPhases: [['execute', 'triage', 'intake', 'done', 'canceled']],\n },\n execute: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [['review', 'planning', 'done', 'canceled']],\n },\n review: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [\n ['execute', 'intake', 'done', 'canceled'],\n ['execute', 'intake', 'pr-review', 'done', 'canceled'],\n ],\n },\n 'pr-review': {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [\n ['intake', 'done', 'canceled'],\n ['intake', 'planning', 'execute', 'done', 'canceled'],\n ],\n },\n};\n\n/** Building's goal while Work still had its self-review phase. */\nconst SELF_REVIEW_BUILD_OBJECTIVE =\n 'Build the plan approved in Planning for this work item. Done when every step of that plan is implemented on ' +\n \"the work branch; the plan's verification gates (the tests, typecheck and lint it names, else the narrowest \" +\n 'relevant ones) were run on the final head and passed; the branch is pushed; and the card was moved on with ' +\n \"factory_transition_work_item out of Building (to Review or PR review as the builder's hand-off says, or back to \" +\n \"Planning if the plan proved wrong); the builder's latest message names the move and the pushed head. \" +\n OWN_CARD_HAND_OFF +\n ' Continue while any of that is missing. Waiting only when the agent asked a person a question it cannot ' +\n 'answer from the repository.';\n\n/**\n * The Work seed this migration fills from: Work as it was while it had its self-review phase.\n * Only projects stored before then hold the old defaults it replaces, and their rows still have\n * that phase, so they get its runner rather than today's seed, which has no such phase.\n */\nexport function workSeedWithSelfReview(): StoredBoardInput {\n const seed = boardDefinitionOf(workBoard);\n const phases = seed.phases.flatMap((phase): StoredPhaseInput[] => {\n if (phase.key !== 'execute') return [phase];\n const goal = phase.runner?.goal && { ...phase.runner.goal, objective: SELF_REVIEW_BUILD_OBJECTIVE };\n return [\n {\n ...phase,\n runner: { ...phase.runner, ...(goal ? { goal } : {}) },\n nextPhases: ['review', 'pr-review', 'planning', 'done', 'canceled'],\n },\n {\n key: 'review',\n name: 'Review',\n kind: 'working',\n runner: { skill: 'factory-self-review', context: 'review' },\n autoStart: true,\n autoStartWhen: { operator: 'AND', conditions: [{ field: 'item.pullRequest', operator: 'not_exists' }] },\n tools: ['factory_record_review_verdict'],\n nextPhases: ['execute', 'intake', 'pr-review', 'done', 'canceled'],\n },\n ];\n });\n return { ...seed, phases };\n}\n\n/** Stable JSON with sorted keys; an unset field, `null`, `false` and no tools all read the same. */\nfunction canonical(field: MigratedField, value: unknown): string {\n if (value === undefined || value === null || value === false) return 'null';\n if (field === 'tools' && Array.isArray(value) && value.length === 0) return 'null';\n return JSON.stringify(sorted(value));\n}\n\nfunction sorted(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sorted);\n if (value === null || typeof value !== 'object') return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => [key, sorted(entry)]),\n );\n}\n\nfunction toInput({ position: _position, ...phase }: StoredPhaseRecord): StoredPhaseInput {\n return phase;\n}\n\n/** Whether Factory may write the new value over the stored one: the stored one is still an old default. */\nfunction stillOldDefault(phaseKey: string, field: MigratedField, stored: unknown): boolean {\n const old = OLD_WORK_SEED[phaseKey]?.[field] ?? [];\n const current = canonical(field, stored);\n return old.some(value => canonical(field, value) === current);\n}\n\n/**\n * Gives a project's stored Work board the phase runners, goal, automatic starts and phase tools\n * of Factory's Work seed, field by field: only a field that still holds the value Factory\n * stored before is filled, so every field a person edited stays as they left it. A phase the\n * row lacks, or holds as another kind, is left alone, as is a move to a phase the row lacks.\n */\ntype StoredRunner = StoredPhaseInput['runner'];\n\n/**\n * The seed's runner parts a stored runner still lacks or holds at the old default: `context` when\n * it is the old seed's, `skill` and `goal` when unset (the old seed set neither). Instructions and\n * any part a person set stay as they are.\n */\nfunction migrateRunner(\n phaseKey: string,\n stored: StoredRunner,\n target: StoredRunner,\n): { value: NonNullable<StoredRunner>; filled: string[] } | undefined {\n if (!target) return undefined;\n const value: NonNullable<StoredRunner> = { ...(stored ?? {}) };\n const filled: string[] = [];\n const oldContexts = (OLD_WORK_SEED[phaseKey]?.runner ?? []).map(old => (old as { context?: string }).context);\n if (\n target.context !== undefined &&\n value.context !== target.context &&\n (value.context === undefined || oldContexts.includes(value.context))\n ) {\n value.context = target.context;\n filled.push('context');\n }\n if (target.skill !== undefined && value.skill === undefined) {\n value.skill = target.skill;\n filled.push('skill');\n }\n if (target.goal !== undefined && value.goal === undefined) {\n value.goal = target.goal;\n filled.push('goal');\n }\n return filled.length > 0 ? { value, filled } : undefined;\n}\n\nexport function migrateWorkPhaseRunners(\n board: StoredBoardRecord,\n seed = workSeedWithSelfReview(),\n): { board: { name: string; description: string | null; phases: StoredPhaseInput[] }; filled: string[] } | undefined {\n const phaseKeys = new Set(board.phases.map(phase => phase.key));\n const filled: string[] = [];\n const phases = board.phases.map(record => {\n const phase = toInput(record);\n const target = seed.phases.find(candidate => candidate.key === phase.key);\n if (!target || target.kind !== phase.kind || !OLD_WORK_SEED[phase.key]) return phase;\n const next: StoredPhaseInput = { ...phase };\n // The runner is migrated part by part: a person who only wrote instructions (the one part the\n // old seed left editable) still gets the skill, goal and context, and keeps the instructions.\n const runner = migrateRunner(phase.key, phase.runner, target.runner);\n if (runner) {\n next.runner = runner.value;\n filled.push(...runner.filled.map(part => `${phase.key}.runner.${part}`));\n }\n for (const field of MIGRATED_FIELDS) {\n if (field === 'runner') continue;\n const value = target[field] ?? null;\n if (canonical(field, value) === canonical(field, phase[field])) continue;\n if (!stillOldDefault(phase.key, field, phase[field])) continue;\n if (field === 'nextPhases' && !(value as string[]).every(key => phaseKeys.has(key))) continue;\n Object.assign(next, { [field]: value });\n filled.push(`${phase.key}.${field}`);\n }\n const moves = next.nextPhases ?? [...phaseKeys].filter(key => key !== phase.key);\n const revert = (field: MigratedField) => {\n if (!filled.includes(`${phase.key}.${field}`)) return;\n Object.assign(next, { [field]: phase[field] });\n filled.splice(filled.indexOf(`${phase.key}.${field}`), 1);\n };\n // The seed's goal is done only once the card moved on along the seed's moves (Building to PR\n // review, say): a phase whose moves a person narrowed runs the skill without the goal, rather\n // than judging a goal it may never meet.\n const seedMoves = (target.nextPhases ?? []).filter(key => phaseKeys.has(key));\n if (\n filled.includes(`${phase.key}.runner.goal`) &&\n next.runner?.goal &&\n !seedMoves.every(key => moves.includes(key))\n ) {\n const { goal: _goal, ...runner } = next.runner;\n next.runner = runner;\n }\n // Auto-start and Factory tools serve the seed's skill; a phase running another skill keeps its own.\n if (next.runner?.skill !== target.runner?.skill || next.runner?.context !== target.runner?.context) {\n for (const field of ['tools', 'autoStart', 'autoStartWhen'] as const) revert(field);\n }\n if (filled.includes(`${phase.key}.runner.goal`) && !next.runner?.goal) {\n filled.splice(filled.indexOf(`${phase.key}.runner.goal`), 1);\n }\n return next;\n });\n if (filled.length === 0) return undefined;\n return { board: { name: board.name, description: board.description, phases }, filled };\n}\n\nexport const WORK_PHASE_RUNNERS_MIGRATION: StoredBoardMigration = {\n key: 'work-phase-runners-v1',\n boardKey: workBoard.id,\n migrate: board => migrateWorkPhaseRunners(board),\n};\n\n/** The board migrations each project gets once, in order. */\nexport const BOARD_MIGRATIONS: readonly StoredBoardMigration[] = [WORK_PHASE_RUNNERS_MIGRATION];\n"],"mappings":";;;AAUA,MAAM,kBAAkB;CAAC;CAAU;CAAY;CAAS;CAAa;CAAiB;AAAY;AAGlG,MAAM,iBAAiB;CAAE,UAAU,CAAC,IAAI;CAAG,OAAO,CAAC,IAAI;CAAG,WAAW,CAAC,IAAI;CAAG,eAAe,CAAC,IAAI;AAAE;;;;;;AAOnG,MAAM,gBAA+F;CACnG,QAAQ;EACN,GAAG;EACH,QAAQ,CAAC,EAAE,SAAS,SAAS,CAAC;EAC9B,YAAY,CAAC;GAAC;GAAU;GAAY;GAAQ;EAAU,CAAC;CACzD;CACA,UAAU;EACR,GAAG;EACH,QAAQ,CAAC,EAAE,SAAS,OAAO,CAAC;EAC5B,UAAU,CAAC;GAAE,IAAI;GAAe,aAAa;EAAM,CAAC;EACpD,YAAY,CAAC;GAAC;GAAW;GAAU;GAAU;GAAQ;EAAU,CAAC;CAClE;CACA,SAAS;EACP,GAAG;EACH,QAAQ,CAAC,EAAE,SAAS,OAAO,CAAC;EAC5B,YAAY,CAAC;GAAC;GAAU;GAAY;GAAQ;EAAU,CAAC;CACzD;CACA,QAAQ;EACN,GAAG;EACH,QAAQ,CAAC,EAAE,SAAS,OAAO,CAAC;EAC5B,Y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GACvC,IAAI,CAAC,OAAO,SAAS,GAAG,MAAM,IAAI,GAAG,OAAO,GAAG;GAC/C,OAAO,OAAO,MAAM,GAAG,QAAQ,MAAM,OAAO,CAAC;GAC7C,OAAO,OAAO,OAAO,QAAQ,GAAG,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC;EAC1D;EAIA,MAAM,aAAa,OAAO,cAAc,CAAC,EAAA,CAAG,QAAO,QAAO,UAAU,IAAI,GAAG,CAAC;EAC5E,IACE,OAAO,SAAS,GAAG,MAAM,IAAI,aAAa,KAC1C,KAAK,QAAQ,QACb,CAAC,UAAU,OAAM,QAAO,MAAM,SAAS,GAAG,CAAC,GAC3C;GACA,MAAM,EAAE,MAAM,OAAO,GAAG,WAAW,KAAK;GACxC,KAAK,SAAS;EAChB;EAEA,IAAI,KAAK,QAAQ,UAAU,OAAO,QAAQ,SAAS,KAAK,QAAQ,YAAY,OAAO,QAAQ,SACzF,KAAK,MAAM,SAAS;GAAC;GAAS;GAAa;EAAe,GAAY,OAAO,KAAK;EAEpF,IAAI,OAAO,SAAS,GAAG,MAAM,IAAI,aAAa,KAAK,CAAC,KAAK,QAAQ,MAC/D,OAAO,OAAO,OAAO,QAAQ,GAAG,MAAM,IAAI,aAAa,GAAG,CAAC;EAE7D,OAAO;CACT,CAAC;CACD,IAAI,OAAO,WAAW,GAAG,OAAO,KAAA;CAChC,OAAO;EAAE,OAAO;GAAE,MAAM,MAAM;GAAM,aAAa,MAAM;GAAa;EAAO;EAAG;CAAO;AACvF;AAEA,MAAa,+BAAqD;CAChE,KAAK;CACL,UAAU,UAAU;CACpB,UAAS,UAAS,wBAAwB,KAAK;AACjD;;AAGA,MAAa,mBAAoD,CAAC,4BAA4B"}
1
+ {"version":3,"file":"work-migrations.js","names":[],"sources":["../../src/boards/work-migrations.ts"],"sourcesContent":["import type {\n BoardMigrationContext,\n StoredBoardInput,\n StoredBoardMigration,\n StoredBoardRecord,\n StoredPhaseInput,\n StoredPhaseRecord,\n} from '../storage/domains/boards/base.js';\nimport { REVIEW_CONTEXT } from './define-board.js';\nimport type { FactoryPhaseTool } from './define-board.js';\nimport { boardDefinitionOf } from './stored-board.js';\nimport { OWN_CARD_HAND_OFF, workBoard } from './work.js';\n\nconst MIGRATED_FIELDS = ['runner', 'exitTool', 'tools', 'autoStart', 'autoStartWhen', 'nextPhases'] as const;\ntype MigratedField = (typeof MIGRATED_FIELDS)[number];\n\nconst PHASE_DEFAULTS = { exitTool: [null], tools: [null], autoStart: [null], autoStartWhen: [null] } as const;\n\n/**\n * What Factory stored for Work's working phases before they had runners: the seed of #29317, and\n * #29346's for the `nextPhases` it changed. Frozen: a value listed here is one a project can only\n * hold because Factory wrote it, so the migration may replace it.\n */\nconst OLD_WORK_SEED: Readonly<Record<string, Readonly<Record<MigratedField, readonly unknown[]>>>> = {\n triage: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'triage' }],\n nextPhases: [['intake', 'planning', 'done', 'canceled']],\n },\n planning: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n exitTool: [{ id: 'submit_plan', autoApprove: false }],\n nextPhases: [['execute', 'triage', 'intake', 'done', 'canceled']],\n },\n execute: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [['review', 'planning', 'done', 'canceled']],\n },\n review: {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [\n ['execute', 'intake', 'done', 'canceled'],\n ['execute', 'intake', 'pr-review', 'done', 'canceled'],\n ],\n },\n 'pr-review': {\n ...PHASE_DEFAULTS,\n runner: [{ context: 'work' }],\n nextPhases: [\n ['intake', 'done', 'canceled'],\n ['intake', 'planning', 'execute', 'done', 'canceled'],\n ],\n },\n};\n\n/** Building's goal while Work still had its self-review phase. */\nconst SELF_REVIEW_BUILD_OBJECTIVE =\n 'Build the plan approved in Planning for this work item. Done when every step of that plan is implemented on ' +\n \"the work branch; the plan's verification gates (the tests, typecheck and lint it names, else the narrowest \" +\n 'relevant ones) were run on the final head and passed; the branch is pushed; and the card was moved on with ' +\n \"factory_transition_work_item out of Building (to Review or PR review as the builder's hand-off says, or back to \" +\n \"Planning if the plan proved wrong); the builder's latest message names the move and the pushed head. \" +\n OWN_CARD_HAND_OFF +\n ' Continue while any of that is missing. Waiting only when the agent asked a person a question it cannot ' +\n 'answer from the repository.';\n\n/**\n * The Work seed this migration fills from: Work as it was while it had its self-review phase.\n * Only projects stored before then hold the old defaults it replaces, and their rows still have\n * that phase, so they get its runner rather than today's seed, which has no such phase.\n */\nexport function workSeedWithSelfReview(): StoredBoardInput {\n const seed = boardDefinitionOf(workBoard);\n const phases = seed.phases.flatMap((phase): StoredPhaseInput[] => {\n if (phase.key !== 'execute') return [phase];\n const goal = phase.runner?.goal && { ...phase.runner.goal, objective: SELF_REVIEW_BUILD_OBJECTIVE };\n return [\n {\n ...phase,\n runner: { ...phase.runner, ...(goal ? { goal } : {}) },\n nextPhases: ['review', 'pr-review', 'planning', 'done', 'canceled'],\n },\n {\n key: 'review',\n name: 'Review',\n kind: 'working',\n runner: { skill: 'factory-self-review', context: 'review' },\n autoStart: true,\n autoStartWhen: { operator: 'AND', conditions: [{ field: 'item.pullRequest', operator: 'not_exists' }] },\n tools: ['factory_record_review_verdict'],\n nextPhases: ['execute', 'intake', 'pr-review', 'done', 'canceled'],\n },\n ];\n });\n return { ...seed, phases };\n}\n\n/** Stable JSON with sorted keys; an unset field, `null`, `false` and no tools all read the same. */\nfunction canonical(field: MigratedField, value: unknown): string {\n if (value === undefined || value === null || value === false) return 'null';\n if (field === 'tools' && Array.isArray(value) && value.length === 0) return 'null';\n return JSON.stringify(sorted(value));\n}\n\nfunction sorted(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sorted);\n if (value === null || typeof value !== 'object') return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => [key, sorted(entry)]),\n );\n}\n\nfunction toInput({ position: _position, ...phase }: StoredPhaseRecord): StoredPhaseInput {\n return phase;\n}\n\n/** Whether Factory may write the new value over the stored one: the stored one is still an old default. */\nfunction stillOldDefault(phaseKey: string, field: MigratedField, stored: unknown): boolean {\n const old = OLD_WORK_SEED[phaseKey]?.[field] ?? [];\n const current = canonical(field, stored);\n return old.some(value => canonical(field, value) === current);\n}\n\n/**\n * Gives a project's stored Work board the phase runners, goal, automatic starts and phase tools\n * of Factory's Work seed, field by field: only a field that still holds the value Factory\n * stored before is filled, so every field a person edited stays as they left it. A phase the\n * row lacks, or holds as another kind, is left alone, as is a move to a phase the row lacks.\n */\ntype StoredRunner = StoredPhaseInput['runner'];\n\n/**\n * The seed's runner parts a stored runner still lacks or holds at the old default: `context` when\n * it is the old seed's, `skill` and `goal` when unset (the old seed set neither). Instructions and\n * any part a person set stay as they are.\n */\nfunction migrateRunner(\n phaseKey: string,\n stored: StoredRunner,\n target: StoredRunner,\n): { value: NonNullable<StoredRunner>; filled: string[] } | undefined {\n if (!target) return undefined;\n const value: NonNullable<StoredRunner> = { ...(stored ?? {}) };\n const filled: string[] = [];\n const oldContexts = (OLD_WORK_SEED[phaseKey]?.runner ?? []).map(old => (old as { context?: string }).context);\n if (\n target.context !== undefined &&\n value.context !== target.context &&\n (value.context === undefined || oldContexts.includes(value.context))\n ) {\n value.context = target.context;\n filled.push('context');\n }\n if (target.skill !== undefined && value.skill === undefined) {\n value.skill = target.skill;\n filled.push('skill');\n }\n if (target.goal !== undefined && value.goal === undefined) {\n value.goal = target.goal;\n filled.push('goal');\n }\n return filled.length > 0 ? { value, filled } : undefined;\n}\n\nexport function migrateWorkPhaseRunners(\n board: StoredBoardRecord,\n seed = workSeedWithSelfReview(),\n): { board: { name: string; description: string | null; phases: StoredPhaseInput[] }; filled: string[] } | undefined {\n const phaseKeys = new Set(board.phases.map(phase => phase.key));\n const filled: string[] = [];\n const phases = board.phases.map(record => {\n const phase = toInput(record);\n const target = seed.phases.find(candidate => candidate.key === phase.key);\n if (!target || target.kind !== phase.kind || !OLD_WORK_SEED[phase.key]) return phase;\n const next: StoredPhaseInput = { ...phase };\n // The runner is migrated part by part: a person who only wrote instructions (the one part the\n // old seed left editable) still gets the skill, goal and context, and keeps the instructions.\n const runner = migrateRunner(phase.key, phase.runner, target.runner);\n if (runner) {\n next.runner = runner.value;\n filled.push(...runner.filled.map(part => `${phase.key}.runner.${part}`));\n }\n for (const field of MIGRATED_FIELDS) {\n if (field === 'runner') continue;\n const value = target[field] ?? null;\n if (canonical(field, value) === canonical(field, phase[field])) continue;\n if (!stillOldDefault(phase.key, field, phase[field])) continue;\n if (field === 'nextPhases' && !(value as string[]).every(key => phaseKeys.has(key))) continue;\n Object.assign(next, { [field]: value });\n filled.push(`${phase.key}.${field}`);\n }\n const moves = next.nextPhases ?? [...phaseKeys].filter(key => key !== phase.key);\n const revert = (field: MigratedField) => {\n if (!filled.includes(`${phase.key}.${field}`)) return;\n Object.assign(next, { [field]: phase[field] });\n filled.splice(filled.indexOf(`${phase.key}.${field}`), 1);\n };\n // The seed's goal is done only once the card moved on along the seed's moves (Building to PR\n // review, say): a phase whose moves a person narrowed runs the skill without the goal, rather\n // than judging a goal it may never meet.\n const seedMoves = (target.nextPhases ?? []).filter(key => phaseKeys.has(key));\n if (\n filled.includes(`${phase.key}.runner.goal`) &&\n next.runner?.goal &&\n !seedMoves.every(key => moves.includes(key))\n ) {\n const { goal: _goal, ...runner } = next.runner;\n next.runner = runner;\n }\n // Auto-start and Factory tools serve the seed's skill; a phase running another skill keeps its own.\n if (next.runner?.skill !== target.runner?.skill || next.runner?.context !== target.runner?.context) {\n for (const field of ['tools', 'autoStart', 'autoStartWhen'] as const) revert(field);\n }\n if (filled.includes(`${phase.key}.runner.goal`) && !next.runner?.goal) {\n filled.splice(filled.indexOf(`${phase.key}.runner.goal`), 1);\n }\n return next;\n });\n if (filled.length === 0) return undefined;\n return { board: { name: board.name, description: board.description, phases }, filled };\n}\n\nexport const WORK_PHASE_RUNNERS_MIGRATION: StoredBoardMigration = {\n key: 'work-phase-runners-v1',\n boardKey: workBoard.id,\n migrate: board => migrateWorkPhaseRunners(board),\n};\n\n/**\n * The board's review phases as {@link boardFlow} finds them: `pullRequestReview` is the first\n * review-seat phase granting `factory_review_source`; `selfReview` the first other one granting\n * `factory_record_review_verdict` and not `factory_review_source`; `build` the last other working\n * phase that moves into self-review.\n */\nfunction reviewPhases(board: StoredBoardRecord) {\n const grants = (phase: StoredPhaseRecord, tool: FactoryPhaseTool) =>\n phase.kind === 'working' && phase.runner?.context === REVIEW_CONTEXT && (phase.tools ?? []).includes(tool);\n const pullRequestReview = board.phases.find(phase => grants(phase, 'factory_review_source'));\n const selfReview = board.phases.find(\n phase =>\n phase !== pullRequestReview &&\n grants(phase, 'factory_record_review_verdict') &&\n !grants(phase, 'factory_review_source'),\n );\n const build = selfReview\n ? board.phases.findLast(\n phase =>\n phase.kind === 'working' &&\n phase !== pullRequestReview &&\n phase !== selfReview &&\n (phase.nextPhases ?? []).includes(selfReview.key),\n )\n : undefined;\n return { pullRequestReview, selfReview, build };\n}\n\n/**\n * Carries a project's retired self-review switch into its boards: with the switch off, a card went\n * past any board's self-review phase, so the phase goes, with every move into it. A board is left\n * as it is, with a warning, when its code board declares the phase (without it the board would run\n * without its code rules), when cards sit in the phase (removing it would strand them), when its\n * build phase could only reach the pull request review through it, or when it is another phase's\n * only move.\n */\nexport function migrateSelfReviewSwitch(\n board: StoredBoardRecord,\n context: BoardMigrationContext,\n): { board: Omit<StoredBoardInput, 'key'>; filled: string[] } | undefined {\n if (!context.retiredSettings || context.retiredSettings.selfReviewEnabled) return undefined;\n const { pullRequestReview, selfReview, build } = reviewPhases(board);\n if (!selfReview) return undefined;\n const phase = selfReview.key;\n const keep = (reason: string) => {\n context.warn(\n `Board \"${board.key}\" keeps its self-review phase \"${phase}\": ${reason}. The project's self-review ` +\n 'setting was off; remove the phase to keep skipping self-review.',\n );\n return undefined;\n };\n if (context.codePhases(board.key)?.has(phase)) return keep('its code declares it, so remove it in code first');\n // Without the cards it could strand some in the phase: the project's next load runs it again.\n if (!context.occupiedPhases) throw new Error(\"the project's cards can't be read yet\");\n if (context.occupiedPhases.get(board.key)?.has(phase)) return keep('cards sit in it, move them first');\n if (build && !(pullRequestReview && (build.nextPhases ?? []).includes(pullRequestReview.key))) {\n return keep(`\"${build.key}\" can't move to a pull request review without it, add that move first`);\n }\n const stranded = board.phases.find(\n record => record.key !== phase && record.nextPhases?.length && record.nextPhases.every(key => key === phase),\n );\n if (stranded) return keep(`it is the only move out of \"${stranded.key}\", give that phase another move first`);\n const phases = board.phases\n .filter(record => record.key !== phase)\n .map(record => {\n const next = toInput(record);\n if (next.nextPhases) next.nextPhases = next.nextPhases.filter(key => key !== phase);\n return next;\n });\n return { board: { name: board.name, description: board.description, phases }, filled: [`${phase} removed`] };\n}\n\n/**\n * Carries a project's retired auto-run switch into its boards: with it on, every run started\n * without a person, so every working phase starts on its own, for every card (`autoStartWhen`\n * cleared). With it off a run started on its own only where the phase said so, as it does now.\n */\nexport function migrateAutoRunSwitch(\n board: StoredBoardRecord,\n context: BoardMigrationContext,\n): { board: Omit<StoredBoardInput, 'key'>; filled: string[] } | undefined {\n if (!context.retiredSettings?.autoRunEnabled) return undefined;\n const filled: string[] = [];\n const phases = board.phases.map(record => {\n const phase = toInput(record);\n if (phase.kind !== 'working' || (phase.autoStart && !phase.autoStartWhen)) return phase;\n filled.push(`${phase.key}.autoStart`);\n return { ...phase, autoStart: true, autoStartWhen: null };\n });\n if (filled.length === 0) return undefined;\n return { board: { name: board.name, description: board.description, phases }, filled };\n}\n\nexport const SELF_REVIEW_MIGRATION: StoredBoardMigration = {\n key: 'self-review-switch-v1',\n boardKey: null,\n migrate: migrateSelfReviewSwitch,\n};\n\nexport const AUTO_RUN_MIGRATION: StoredBoardMigration = {\n key: 'auto-run-switch-v1',\n boardKey: null,\n migrate: migrateAutoRunSwitch,\n};\n\n/** The board migrations each project gets once, in order. */\nexport const BOARD_MIGRATIONS: readonly Stored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AM,SAAmB,CAAC;CAC1B,MAAM,SAAS,MAAM,OAAO,KAAI,WAAU;EACxC,MAAM,QAAQ,QAAQ,MAAM;EAC5B,IAAI,MAAM,SAAS,aAAc,MAAM,aAAa,CAAC,MAAM,eAAgB,OAAO;EAClF,OAAO,KAAK,GAAG,MAAM,IAAI,WAAW;EACpC,OAAO;GAAE,GAAG;GAAO,WAAW;GAAM,eAAe;EAAK;CAC1D,CAAC;CACD,IAAI,OAAO,WAAW,GAAG,OAAO,KAAA;CAChC,OAAO;EAAE,OAAO;GAAE,MAAM,MAAM;GAAM,aAAa,MAAM;GAAa;EAAO;EAAG;CAAO;AACvF;AAEA,MAAa,wBAA8C;CACzD,KAAK;CACL,UAAU;CACV,SAAS;AACX;AAEA,MAAa,qBAA2C;CACtD,KAAK;CACL,UAAU;CACV,SAAS;AACX;;AAGA,MAAa,mBAAoD;CAC/D;CACA;CACA;AACF"}
@@ -39,11 +39,16 @@ export declare const PULL_REQUEST_REVIEW_REQUESTED_ROUTE: StoredIntakeRouteInput
39
39
  * own, so it is tried first.
40
40
  */
41
41
  export declare const CLOSES_ISSUE_INTAKE_ROUTE: StoredIntakeRouteInput;
42
+ /**
43
+ * Every new card no route before it placed lands in Work › Intake. It is the project's default
44
+ * board as a stored route: point it at another board to send new cards there instead.
45
+ */
46
+ export declare const CATCH_ALL_INTAKE_ROUTE: StoredIntakeRouteInput;
42
47
  /**
43
48
  * The routes Factory adds to a project, in order, each under a key that never changes. A project
44
49
  * gets each one once: a new project gets them all, a project set up earlier gets a route added
45
50
  * since at the end of its list (or at the start, for a `first` one), and a route an admin deleted
46
- * stays deleted.
51
+ * stays deleted. The catch-all stays last: a default added after it would never place a new card.
47
52
  */
48
53
  export declare const DEFAULT_INTAKE_ROUTES: readonly {
49
54
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"work-routes.d.ts","sourceRoot":"","sources":["../../src/boards/work-routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,E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AqB,EAAE,sBAKnC,CAAC;AAEF,2GAA2G;AAC3G,eAAO,MAAM,cAAc,EAAE,sBAI5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,sBAIvC,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,yBAAyB,EAAE,sBAKvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,sBAK7C,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,EAAE,sBAIxC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,mCAAmC,EAAE,sBAIjD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,sBAavC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,sBAIpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,sBAAsB,CAAC;IAAC,KAAK,CAAC,EAAE,IAAI,CAAA;CAAE,EAaxG,CAAC"}
@@ -141,8 +141,7 @@ const PULL_REQUEST_UPDATED_ROUTE = {
141
141
  target: {
142
142
  boardKey: "work",
143
143
  phaseKey: "pr-review"
144
- },
145
- allowWorkingPhase: true
144
+ }
146
145
  };
147
146
  /** A maintainer asking Factory to review a pull request again sends it to Review. */
148
147
  const PULL_REQUEST_REVIEW_REQUESTED_ROUTE = {
@@ -151,8 +150,7 @@ const PULL_REQUEST_REVIEW_REQUESTED_ROUTE = {
151
150
  target: {
152
151
  boardKey: "work",
153
152
  phaseKey: "pr-review"
154
- },
155
- allowWorkingPhase: true
153
+ }
156
154
  };
157
155
  /**
158
156
  * A pull request from someone with write access that closes an issue nobody has started work on
@@ -199,10 +197,22 @@ const CLOSES_ISSUE_INTAKE_ROUTE = {
199
197
  }
200
198
  };
201
199
  /**
200
+ * Every new card no route before it placed lands in Work › Intake. It is the project's default
201
+ * board as a stored route: point it at another board to send new cards there instead.
202
+ */
203
+ const CATCH_ALL_INTAKE_ROUTE = {
204
+ name: "Everything else goes to Work › Intake",
205
+ when: null,
206
+ target: {
207
+ boardKey: "work",
208
+ phaseKey: "intake"
209
+ }
210
+ };
211
+ /**
202
212
  * The routes Factory adds to a project, in order, each under a key that never changes. A project
203
213
  * gets each one once: a new project gets them all, a project set up earlier gets a route added
204
214
  * since at the end of its list (or at the start, for a `first` one), and a route an admin deleted
205
- * stays deleted.
215
+ * stays deleted. The catch-all stays last: a default added after it would never place a new card.
206
216
  */
207
217
  const DEFAULT_INTAKE_ROUTES = [
208
218
  {
@@ -249,8 +259,12 @@ const DEFAULT_INTAKE_ROUTES = [
249
259
  {
250
260
  key: "pull-request-review-requested",
251
261
  route: PULL_REQUEST_REVIEW_REQUESTED_ROUTE
262
+ },
263
+ {
264
+ key: "everything-else",
265
+ route: CATCH_ALL_INTAKE_ROUTE
252
266
  }
253
267
  ];
254
- export { CLOSED_CANCELED_ROUTE, CLOSED_COMPLETED_ROUTE, CLOSES_ISSUE_INTAKE_ROUTE, DEFAULT_INTAKE_ROUTE, DEFAULT_INTAKE_ROUTES, PULL_REQUEST_CLOSED_ISSUE_ROUTE, PULL_REQUEST_CLOSED_ROUTE, PULL_REQUEST_INTAKE_ROUTE, PULL_REQUEST_MERGED_ROUTE, PULL_REQUEST_REVIEW_REQUESTED_ROUTE, PULL_REQUEST_UPDATED_ROUTE, REOPENED_ROUTE };
268
+ export { CATCH_ALL_INTAKE_ROUTE, CLOSED_CANCELED_ROUTE, CLOSED_COMPLETED_ROUTE, CLOSES_ISSUE_INTAKE_ROUTE, DEFAULT_INTAKE_ROUTE, DEFAULT_INTAKE_ROUTES, PULL_REQUEST_CLOSED_ISSUE_ROUTE, PULL_REQUEST_CLOSED_ROUTE, PULL_REQUEST_INTAKE_ROUTE, PULL_REQUEST_MERGED_ROUTE, PULL_REQUEST_REVIEW_REQUESTED_ROUTE, PULL_REQUEST_UPDATED_ROUTE, REOPENED_ROUTE };
255
269
 
256
270
  //# sourceMappingURL=work-routes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"work-routes.js","names":[],"sources":["../../src/boards/work-routes.ts"],"sourcesContent":["import type { StoredIntakeRouteInput } from '../storage/domains/boards/base.js';\n\n// The routes every project starts with. Work is the default board, so they name its phases;\n// they are stored routes like any other, which admins edit, retarget or delete.\n\n/**\n * The route every project starts with: a GitHub or GitLab card whose author is outside the\n * write-access circle lands in Work › Intake, where nothing starts until a person moves it.\n * It is a stored route like any other, so admins can see, edit, disable or delete it.\n */\nexport const DEFAULT_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Outside authors wait in Intake',\n when: {\n operator: 'AND',\n conditions: [\n { field: 'source.integration', operator: 'in', value: ['github', 'gitlab'] },\n { field: 'author.trusted', operator: 'equals', value: false },\n ],\n },\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/**\n * Pull requests are reviewed in Work › Review. It comes after `DEFAULT_INTAKE_ROUTE`, so a\n * pull request from outside the write-access circle still waits in Intake for a person.\n */\nexport const PULL_REQUEST_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests go to Review',\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n};\n\n/** A Work card whose issue was closed as done goes to Done. */\nexport const CLOSED_COMPLETED_ROUTE: StoredIntakeRouteInput = {\n name: 'Closed issues go to Done',\n on: ['work_item.closed'],\n when: { operator: 'AND', conditions: [{ field: 'event.reason', operator: 'equals', value: 'completed' }] },\n target: { boardKey: 'work', phaseKey: 'done' },\n};\n\n/** A Work card whose issue was closed as not planned, or as a duplicate, goes to Canceled. */\nexport const CLOSED_CANCELED_ROUTE: StoredIntakeRouteInput = {\n name: 'Issues closed as not planned go to Canceled',\n on: ['work_item.closed'],\n when: { operator: 'AND', conditions: [{ field: 'event.reason', operator: 'equals', value: 'canceled' }] },\n target: { boardKey: 'work', phaseKey: 'canceled' },\n};\n\n/** A finished Work card whose issue was reopened goes back to Intake, where a person picks it up again. */\nexport const REOPENED_ROUTE: StoredIntakeRouteInput = {\n name: 'Reopened issues go back to Intake',\n on: ['work_item.reopened'],\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/**\n * A merged pull request finishes its Work card: the pull request's own card, or the issue card\n * whose session opened it (unless that card still has another pull request out).\n */\nexport const PULL_REQUEST_MERGED_ROUTE: StoredIntakeRouteInput = {\n name: 'Merged pull requests go to Done',\n on: ['pull_request.merged'],\n target: { boardKey: 'work', phaseKey: 'done' },\n};\n\n/** A pull request's own Work card goes to Canceled when the pull request is closed unmerged. */\nexport const PULL_REQUEST_CLOSED_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests closed unmerged go to Canceled',\n on: ['pull_request.closed'],\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'canceled' },\n};\n\n/**\n * An issue card in Review whose last open pull request was closed unmerged goes back to\n * Intake: the issue is still open.\n */\nexport const PULL_REQUEST_CLOSED_ISSUE_ROUTE: StoredIntakeRouteInput = {\n name: 'Issues whose pull request closed unmerged go back to Intake',\n on: ['pull_request.closed'],\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'not_equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/** A push to a pull request in review restarts its review in Review. */\nexport const PULL_REQUEST_UPDATED_ROUTE: StoredIntakeRouteInput = {\n name: 'Pushes to a reviewed pull request re-review it',\n on: ['pull_request.synchronized'],\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n allowWorkingPhase: true,\n};\n\n/** A maintainer asking Factory to review a pull request again sends it to Review. */\nexport const PULL_REQUEST_REVIEW_REQUESTED_ROUTE: StoredIntakeRouteInput = {\n name: 'Requested reviews go to Review',\n on: ['pull_request.review_requested'],\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n allowWorkingPhase: true,\n};\n\n/**\n * A pull request from someone with write access that closes an issue nobody has started work on\n * joins that issue's card, which goes to Review. Once the issue has left Intake, the pull request\n * gets its own card in Review instead; projects can widen the phases. Its condition stands on its\n * own, so it is tried first.\n */\nexport const CLOSES_ISSUE_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests that close a waiting issue join its card',\n when: {\n operator: 'AND',\n conditions: [\n { field: 'source.kind', operator: 'equals', value: 'pull_request' },\n { field: 'author.trusted', operator: 'equals', value: true },\n { field: 'pullRequest.closesIssue', operator: 'equals', value: true },\n { field: 'closedIssue.phase', operator: 'in', value: ['intake'] },\n { field: 'closedIssue.hasPullRequest', operator: 'equals', value: false },\n ],\n },\n target: { boardKey: 'work', phaseKey: 'pr-review', joinClosedIssue: true },\n};\n\n/**\n * The routes Factory adds to a project, in order, each under a key that never changes. A project\n * gets each one once: a new project gets them all, a project set up earlier gets a route added\n * since at the end of its list (or at the start, for a `first` one), and a route an admin deleted\n * stays deleted.\n */\nexport const DEFAULT_INTAKE_ROUTES: readonly { key: string; route: StoredIntakeRouteInput; first?: true }[] = [\n { key: 'closes-issue', route: CLOSES_ISSUE_INTAKE_ROUTE, first: true },\n { key: 'outside-authors', route: DEFAULT_INTAKE_ROUTE },\n { key: 'pull-requests', route: PULL_REQUEST_INTAKE_ROUTE },\n { key: 'closed-completed', route: CLOSED_COMPLETED_ROUTE },\n { key: 'closed-canceled', route: CLOSED_CANCELED_ROUTE },\n { key: 'reopened', route: REOPENED_ROUTE },\n { key: 'pull-request-merged', route: PULL_REQUEST_MERGED_ROUTE },\n { key: 'pull-request-closed', route: PULL_REQUEST_CLOSED_ROUTE },\n { key: 'pull-request-closed-issue', route: PULL_REQUEST_CLOSED_ISSUE_ROUTE },\n { key: 'pull-request-updated', route: PULL_REQUEST_UPDATED_ROUTE },\n { key: 'pull-request-review-requested', route: PULL_REQUEST_REVIEW_REQUESTED_ROUTE },\n];\n"],"mappings":";;;;;;AAUA,MAAa,uBA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K;EAAuB,OAAO;CAA0B;CAC/D;EAAE,KAAK;EAA6B,OAAO;CAAgC;CAC3E;EAAE,KAAK;EAAwB,OAAO;CAA2B;CACjE;EAAE,KAAK;EAAiC,OAAO;CAAoC;AACrF"}
1
+ {"version":3,"file":"work-routes.js","names":[],"sources":["../../src/boards/work-routes.ts"],"sourcesContent":["import type { StoredIntakeRouteInput } from '../storage/domains/boards/base.js';\n\n// The routes every project starts with. Work is the default board, so they name its phases;\n// they are stored routes like any other, which admins edit, retarget or delete.\n\n/**\n * The route every project starts with: a GitHub or GitLab card whose author is outside the\n * write-access circle lands in Work › Intake, where nothing starts until a person moves it.\n * It is a stored route like any other, so admins can see, edit, disable or delete it.\n */\nexport const DEFAULT_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Outside authors wait in Intake',\n when: {\n operator: 'AND',\n conditions: [\n { field: 'source.integration', operator: 'in', value: ['github', 'gitlab'] },\n { field: 'author.trusted', operator: 'equals', value: false },\n ],\n },\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/**\n * Pull requests are reviewed in Work › Review. It comes after `DEFAULT_INTAKE_ROUTE`, so a\n * pull request from outside the write-access circle still waits in Intake for a person.\n */\nexport const PULL_REQUEST_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests go to Review',\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n};\n\n/** A Work card whose issue was closed as done goes to Done. */\nexport const CLOSED_COMPLETED_ROUTE: StoredIntakeRouteInput = {\n name: 'Closed issues go to Done',\n on: ['work_item.closed'],\n when: { operator: 'AND', conditions: [{ field: 'event.reason', operator: 'equals', value: 'completed' }] },\n target: { boardKey: 'work', phaseKey: 'done' },\n};\n\n/** A Work card whose issue was closed as not planned, or as a duplicate, goes to Canceled. */\nexport const CLOSED_CANCELED_ROUTE: StoredIntakeRouteInput = {\n name: 'Issues closed as not planned go to Canceled',\n on: ['work_item.closed'],\n when: { operator: 'AND', conditions: [{ field: 'event.reason', operator: 'equals', value: 'canceled' }] },\n target: { boardKey: 'work', phaseKey: 'canceled' },\n};\n\n/** A finished Work card whose issue was reopened goes back to Intake, where a person picks it up again. */\nexport const REOPENED_ROUTE: StoredIntakeRouteInput = {\n name: 'Reopened issues go back to Intake',\n on: ['work_item.reopened'],\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/**\n * A merged pull request finishes its Work card: the pull request's own card, or the issue card\n * whose session opened it (unless that card still has another pull request out).\n */\nexport const PULL_REQUEST_MERGED_ROUTE: StoredIntakeRouteInput = {\n name: 'Merged pull requests go to Done',\n on: ['pull_request.merged'],\n target: { boardKey: 'work', phaseKey: 'done' },\n};\n\n/** A pull request's own Work card goes to Canceled when the pull request is closed unmerged. */\nexport const PULL_REQUEST_CLOSED_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests closed unmerged go to Canceled',\n on: ['pull_request.closed'],\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'canceled' },\n};\n\n/**\n * An issue card in Review whose last open pull request was closed unmerged goes back to\n * Intake: the issue is still open.\n */\nexport const PULL_REQUEST_CLOSED_ISSUE_ROUTE: StoredIntakeRouteInput = {\n name: 'Issues whose pull request closed unmerged go back to Intake',\n on: ['pull_request.closed'],\n when: { operator: 'AND', conditions: [{ field: 'source.kind', operator: 'not_equals', value: 'pull_request' }] },\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/** A push to a pull request in review restarts its review in Review. */\nexport const PULL_REQUEST_UPDATED_ROUTE: StoredIntakeRouteInput = {\n name: 'Pushes to a reviewed pull request re-review it',\n on: ['pull_request.synchronized'],\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n};\n\n/** A maintainer asking Factory to review a pull request again sends it to Review. */\nexport const PULL_REQUEST_REVIEW_REQUESTED_ROUTE: StoredIntakeRouteInput = {\n name: 'Requested reviews go to Review',\n on: ['pull_request.review_requested'],\n target: { boardKey: 'work', phaseKey: 'pr-review' },\n};\n\n/**\n * A pull request from someone with write access that closes an issue nobody has started work on\n * joins that issue's card, which goes to Review. Once the issue has left Intake, the pull request\n * gets its own card in Review instead; projects can widen the phases. Its condition stands on its\n * own, so it is tried first.\n */\nexport const CLOSES_ISSUE_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Pull requests that close a waiting issue join its card',\n when: {\n operator: 'AND',\n conditions: [\n { field: 'source.kind', operator: 'equals', value: 'pull_request' },\n { field: 'author.trusted', operator: 'equals', value: true },\n { field: 'pullRequest.closesIssue', operator: 'equals', value: true },\n { field: 'closedIssue.phase', operator: 'in', value: ['intake'] },\n { field: 'closedIssue.hasPullRequest', operator: 'equals', value: false },\n ],\n },\n target: { boardKey: 'work', phaseKey: 'pr-review', joinClosedIssue: true },\n};\n\n/**\n * Every new card no route before it placed lands in Work › Intake. It is the project's default\n * board as a stored route: point it at another board to send new cards there instead.\n */\nexport const CATCH_ALL_INTAKE_ROUTE: StoredIntakeRouteInput = {\n name: 'Everything else goes to Work › Intake',\n when: null,\n target: { boardKey: 'work', phaseKey: 'intake' },\n};\n\n/**\n * The routes Factory adds to a project, in order, each under a key that never changes. A project\n * gets each one once: a new project gets them all, a project set up earlier gets a route added\n * since at the end of its list (or at the start, for a `first` one), and a route an admin deleted\n * stays deleted. The catch-all stays last: a default added after it would never place a new card.\n */\nexport const DEFAULT_INTAKE_ROUTES: readonly { key: string; route: StoredIntakeRouteInput; first?: true }[] = [\n { key: 'closes-issue', route: CLOSES_ISSUE_INTAKE_ROUTE, first: true },\n { key: 'outside-authors', route: DEFAULT_INTAKE_ROUTE },\n { key: 'pull-requests', route: PULL_REQUEST_INTAKE_ROUTE },\n { key: 'closed-completed', route: CLOSED_COMPLETED_ROUTE },\n { key: 'closed-canceled', route: CLOSED_CANCELED_ROUTE },\n { key: 'reopened', route: REOPENED_ROUTE },\n { key: 'pull-request-merged', route: PULL_REQUEST_MERGED_ROUTE },\n { key: 'pull-request-closed', route: PULL_REQUEST_CLOSED_ROUTE },\n { key: 'pull-request-closed-issue', route: PULL_REQUEST_CLOSED_ISSUE_ROUTE },\n { key: 'pull-request-updated', route: PULL_REQUEST_UPDATED_ROUTE },\n { key: 'pull-request-review-requested', route: PULL_REQUEST_REVIEW_REQUESTED_ROUTE },\n { key: 'everything-else', route: CATCH_ALL_INTAKE_ROUTE },\n];\n"],"mappings":";;;;;;AAUA,MAAa,uBAA+C;CAC1D,MAAM;CACN,MAAM;EACJ,UAAU;EACV,YAAY,CACV;GAAE,OAAO;GAAsB,UAAU;GAAM,OAAO,CAAC,UAAU,QAAQ;EAAE,GAC3E;GAAE,OAAO;GAAkB,UAAU;GAAU,OAAO;EAAM,CAC9D;CACF;CACA,QAAQ;EAAE,UAAU;EAAQ,UAAU;CAAS;AACjD;;;;;AAMA,MAAa,4BAAoD;CAC/D,MAAM;CACN,MAAM;EAAE,UAAU;EAAO,YAAY,CAAC;GAAE,OAAO;GAAe,UAAU;GAAU,OAAO;EAAe,CAAC;CAAE;CAC3G,QAAQ;EAAE,UAAU;EAAQ,UAAU;CAAY;AACpD;;AAGA,MAAa,yBAAiD;CAC5D,MAAM;CACN,IAAI,CAAC,kBAAkB;CACvB,MAAM;EAAE,UAAU;EAAO,YAAY,CAAC;GAAE,OAAO;GAAgB,UAAU;GAAU,OAAO;EAAY,CAAC;CAAE;CACzG,QAAQ;EAAE,UAAU;EAAQ,UAAU;CAAO;AAC/C;;AAGA,MAAa,wBAAgD;CAC3D,MAAM;CACN,IAAI,CAAC,kBAAkB;CACvB,MAAM;EAAE,UAAU;EAAO,YAAY,CAAC;GAAE,OAAO;GAAgB,UAAU;GAAU,OAAO;EAAW,CAAC;CAAE;CACxG,QAAQ;EAAE,UAAU;EAAQ,UAAU;CAAW;AACnD;;AAGA,MAAa,iBAAyC;CACpD,MAAM;CACN,IAAI,CAAC,oBAAoB;CACzB,QAAQ;EAAE,UAAU;EAA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MAAM;CACN,QAAQ;EAAE,UAAU;EAAQ,UAAU;CAAS;AACjD;;;;;;;AAQA,MAAa,wBAAiG;CAC5G;EAAE,KAAK;EAAgB,OAAO;EAA2B,OAAO;CAAK;CACrE;EAAE,KAAK;EAAmB,OAAO;CAAqB;CACtD;EAAE,KAAK;EAAiB,OAAO;CAA0B;CACzD;EAAE,KAAK;EAAoB,OAAO;CAAuB;CACzD;EAAE,KAAK;EAAmB,OAAO;CAAsB;CACvD;EAAE,KAAK;EAAY,OAAO;CAAe;CACzC;EAAE,KAAK;EAAuB,OAAO;CAA0B;CAC/D;EAAE,KAAK;EAAuB,OAAO;CAA0B;CAC/D;EAAE,KAAK;EAA6B,OAAO;CAAgC;CAC3E;EAAE,KAAK;EAAwB,OAAO;CAA2B;CACjE;EAAE,KAAK;EAAiC,OAAO;CAAoC;CACnF;EAAE,KAAK;EAAmB,OAAO;CAAuB;AAC1D"}
package/dist/factory.d.ts CHANGED
@@ -35,6 +35,7 @@ import type { GithubRuleOverrides } from './integrations/github/default-rules.js
35
35
  import type { FactoryMcpConfig } from './mcp/routes.js';
36
36
  import type { MastraFactorySandboxOption } from './sandbox/session-sandbox.js';
37
37
  import type { FactorySecretEncryption } from './secret-encryption.js';
38
+ import type { ReviewedChangeRequest } from './session/source-control-tools.js';
38
39
  import type { StoredBoardInput, StoredBoardScope } from './storage/domains/boards/base.js';
39
40
  import type { FactorySandboxStart } from './workspace.js';
40
41
  /** Constructor args for the `new Mastra(...)` literal in the deploy entry. */
@@ -297,6 +298,28 @@ export declare class MastraFactory {
297
298
  updated: StoredBoardScope[];
298
299
  unchanged: StoredBoardScope[];
299
300
  }>;
301
+ /**
302
+ * The change request the run behind `requestContext` reviews, for a tool you
303
+ * pass through `tools`. `undefined` unless the run is a Review run bound to a
304
+ * change request; throws when that change request is no longer open.
305
+ *
306
+ * ```typescript
307
+ * const factory = new MastraFactory({
308
+ * tools: {
309
+ * publish_test_check: createTool({
310
+ * id: 'publish_test_check',
311
+ * inputSchema: z.object({ headSha: z.string(), status: z.enum(['success', 'failure']), summary: z.string() }),
312
+ * execute: async (input, { requestContext }) => {
313
+ * const reviewed = await factory.reviewedChangeRequest(requestContext!);
314
+ * if (!reviewed) throw new Error('Only a Review run can publish a test check.');
315
+ * return reviewed.publishCommitCheck({ ...input, name: 'Review / tests', title: input.summary });
316
+ * },
317
+ * }),
318
+ * },
319
+ * });
320
+ * ```
321
+ */
322
+ reviewedChangeRequest(requestContext: RequestContext): Promise<ReviewedChangeRequest | undefined>;
300
323
  /**
301
324
  * Resolve feature readiness, wire every dependency explicitly, and assemble
302
325
  * everything needed to construct the server-owned Mastra. Returns the args
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,KAAK,EAAiC,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAkB,yBAAyB,EAAoB,MAAM,wBAAwB,CAAC;AAqB1G,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOvE,OAAO,KAAK,EAA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;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB9B;IAED,oGAAoG;IAC9F,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAmC9B;CACF"}
package/dist/factory.js CHANGED
@@ -2,7 +2,7 @@ import { buildAuthDisabledRoutes, buildAuthRoutes, createFactoryAuthGate, create
2
2
  import { BoardWriteError, BoardWrites } from "./boards/board-writes.js";
3
3
  import { isDefinedBoard } from "./boards/define-board.js";
4
4
  import "./boards/index.js";
5
- import { ProjectBoardCache, toBoardSource } from "./boards/project-boards.js";
5
+ import { ProjectBoardCache, occupiedPhasesOf, toBoardSource } from "./boards/project-boards.js";
6
6
  import { publishDispatchWake, subscribeDispatchWakes } from "./dispatch-wake.js";
7
7
  import { EnvironmentBuildRunner } from "./environment/build-runner.js";
8
8
  import { ENVIRONMENT_BUILD_WORKFLOW_ID } from "./environment/build-workflow.js";
@@ -38,8 +38,8 @@ import { FactoryTransitionService } from "./rules/transition-service.js";
38
38
  import { assertFactoryConfigVersion } from "./rules/validation.js";
39
39
  import { CallbackFactorySandbox } from "./sandbox/callback-factory-sandbox.js";
40
40
  import { isValidGitRef } from "./sandbox/git-ref.js";
41
- import { LocalFactorySandbox } from "./sandbox/local-factory-sandbox.js";
42
41
  import { resolveFactoryToolScope } from "./tools/scope.js";
42
+ import { LocalFactorySandbox } from "./sandbox/local-factory-sandbox.js";
43
43
  import { SessionRetirementCoordinator } from "./sandbox/session-retirement.js";
44
44
  import { peekSessionSandbox } from "./sandbox/session-sandbox.js";
45
45
  import { createPlaintextFactorySecretEncryption } from "./secret-encryption.js";
@@ -49,11 +49,11 @@ import { hydrateSessionDefaultModel } from "./session/default-model-hydration.js
49
49
  import { environmentSlugs, resolveSessionRepositories } from "./session/environment-repositories.js";
50
50
  import { FactoryEnvironmentStateProcessor } from "./session/environment-state-processor.js";
51
51
  import { createSourceControlSessionLookup } from "./session/factory-session.js";
52
- import { observeSessionFilesystem } from "./session/filesystem-capture.js";
53
52
  import { applyFactoryToolPermissions } from "./tools/permissions.js";
53
+ import { observeSessionFilesystem } from "./session/filesystem-capture.js";
54
54
  import { observeSessionFirstExec } from "./session/first-exec-capture.js";
55
55
  import { observeSessionFirstMessage } from "./session/first-message-capture.js";
56
- import { LiveSessions } from "./session/live-sessions.js";
56
+ import { liveSessionsTouchingTheFeed } from "./session/live-sessions.js";
57
57
  import { hydrateSessionMemorySettings } from "./session/memory-settings-hydration.js";
58
58
  import { hasResolvedOrg } from "./session/org-seed.js";
59
59
  import { FactoryReplyCredentialProcessor } from "./session/reply-credential-processor.js";
@@ -61,7 +61,7 @@ import { migrateSessionResources, privatizeOwnerResourceSessions } from "./sessi
61
61
  import { observeSessionRunEnd } from "./session/run-audit.js";
62
62
  import { selfReviewApprovedHead } from "./session/self-review-gate.js";
63
63
  import { sessionMemoryResourceId, sessionStampCounts } from "./session/session-threads.js";
64
- import { createSourceControlTools } from "./session/source-control-tools.js";
64
+ import { createSourceControlTools, resolveReviewedChangeRequest } from "./session/source-control-tools.js";
65
65
  import { resolveFactoryThinkingLevel } from "./session/thinking-default.js";
66
66
  import { observeSessionThreadStamp } from "./session/thread-session-stamp.js";
67
67
  import { observeSessionThreadTitle } from "./session/thread-title-mirror.js";
@@ -99,11 +99,11 @@ import { createFactorySandboxTools } from "./tools/sandbox-tools.js";
99
99
  import { FactorySessionsStateProcessor } from "./tools/sessions-state-processor.js";
100
100
  import { backfillUntilDone } from "./work-items/split-backfill.js";
101
101
  import { FACTORY_PLANS_DIR, FactoryWorkspaceRegistry, createWorkspaceFactory } from "./workspace.js";
102
+ import { MastraAuthStudio } from "@mastra/auth-studio";
102
103
  import { RequestContext } from "@mastra/core/request-context";
103
104
  import { hasAuthInit, isUserProvider } from "@mastra/core/server";
104
105
  import { EventEmitterPubSub } from "@mastra/core/events";
105
106
  import { existsSync } from "fs";
106
- import { MastraAuthStudio } from "@mastra/auth-studio";
107
107
  import { prepareAgentControllerMount } from "@mastra/code-sdk";
108
108
  import { getDynamicMemory } from "@mastra/code-sdk/agents/memory";
109
109
  import { getGlobalMcpPath } from "@mastra/code-sdk/mcp/config";
@@ -194,18 +194,6 @@ function warnIgnoredMcpConfig() {
194
194
  function buildDefaultStudioAuth() {
195
195
  return new MastraAuthStudio();
196
196
  }
197
- /** A session parking or being answered is inbox news, so the registry bumps the project's feed. */
198
- function liveSessionsTouchingTheFeed(controller, eventBus) {
199
- const liveSessions = new LiveSessions(controller);
200
- liveSessions.onParkedChanged((session) => {
201
- const { factoryOrgId, factoryProjectId } = session.state.get();
202
- if (factoryOrgId && factoryProjectId) touchFeed(eventBus, {
203
- orgId: factoryOrgId,
204
- factoryProjectId
205
- });
206
- });
207
- return liveSessions;
208
- }
209
197
  let warnedDefinedBoards = false;
210
198
  /** Warns once per process when the app declares boards in code; Factory's own boards never warn. */
211
199
  function warnDefinedBoards(boards) {
@@ -266,6 +254,7 @@ var MastraFactory = class {
266
254
  #sessionResourceMigration;
267
255
  #workItemSplitBackfill;
268
256
  #prepareStartedAt;
257
+ #reviewedChangeRequest;
269
258
  #preparing = false;
270
259
  constructor(config) {
271
260
  if (!config?.storage) throw new Error("MastraFactory: 'storage' is required. Pass a FactoryStorage backend — e.g. new PgFactoryStorage({ connectionString }) from '@mastra/pg' for deployments, or new LibSQLFactoryStorage({ url }) from '@mastra/libsql' for local dev.");
@@ -359,6 +348,31 @@ var MastraFactory = class {
359
348
  return result;
360
349
  }
361
350
  /**
351
+ * The change request the run behind `requestContext` reviews, for a tool you
352
+ * pass through `tools`. `undefined` unless the run is a Review run bound to a
353
+ * change request; throws when that change request is no longer open.
354
+ *
355
+ * ```typescript
356
+ * const factory = new MastraFactory({
357
+ * tools: {
358
+ * publish_test_check: createTool({
359
+ * id: 'publish_test_check',
360
+ * inputSchema: z.object({ headSha: z.string(), status: z.enum(['success', 'failure']), summary: z.string() }),
361
+ * execute: async (input, { requestContext }) => {
362
+ * const reviewed = await factory.reviewedChangeRequest(requestContext!);
363
+ * if (!reviewed) throw new Error('Only a Review run can publish a test check.');
364
+ * return reviewed.publishCommitCheck({ ...input, name: 'Review / tests', title: input.summary });
365
+ * },
366
+ * }),
367
+ * },
368
+ * });
369
+ * ```
370
+ */
371
+ async reviewedChangeRequest(requestContext) {
372
+ if (!this.#reviewedChangeRequest) throw new Error("MastraFactory.reviewedChangeRequest() needs prepare() first.");
373
+ return this.#reviewedChangeRequest(requestContext);
374
+ }
375
+ /**
362
376
  * Resolve feature readiness, wire every dependency explicitly, and assemble
363
377
  * everything needed to construct the server-owned Mastra. Returns the args
364
378
  * for the `new Mastra(...)` literal that must live in the entry file.
@@ -422,7 +436,7 @@ var MastraFactory = class {
422
436
  const intakeStorage = storage.registerDomain(new IntakeStorage());
423
437
  const auditStorage = storage.registerDomain(new AuditStorage());
424
438
  const workItemsStorage = storage.registerDomain(new WorkItemsStorage());
425
- workItemsStorage.onAttentionChanged((scope) => touchFeed(eventBus, scope));
439
+ workItemsStorage.onBoardChanged((scope) => touchFeed(eventBus, scope));
426
440
  workItemsStorage.onClaimableWork(() => publishDispatchWake(eventBus, this.#dispatchWakeOrigin));
427
441
  this.#unsubscribeDispatchWakes = subscribeDispatchWakes(eventBus, this.#dispatchWakeOrigin, () => this.#dispatcher?.wake()).catch((error) => {
428
442
  console.warn(`[factory] subscribing to dispatcher wakes failed; other replicas' work waits for this replica's own wakes: ${error instanceof Error ? error.message : error}`);
@@ -509,7 +523,10 @@ var MastraFactory = class {
509
523
  storage: storedBoardsStorage,
510
524
  projects: factoryProjectsStorage,
511
525
  codeSkills: this.#skills,
512
- ...storage.isDomainReady("work-items") ? { reviewBoardInUse: (scope) => workItemsStorage.reviewBoardInUse(scope) } : {}
526
+ ...storage.isDomainReady("work-items") ? {
527
+ reviewBoardInUse: (scope) => workItemsStorage.reviewBoardInUse(scope),
528
+ occupiedPhases: occupiedPhasesOf(workItemsStorage)
529
+ } : {}
513
530
  });
514
531
  this.#projectBoards = projectBoards;
515
532
  this.#boardStore = {
@@ -923,8 +940,7 @@ var MastraFactory = class {
923
940
  }) : void 0;
924
941
  const workItemProcessor = workItemsReady ? new FactoryWorkItemStateProcessor({
925
942
  storage: workItemsStorage,
926
- boards,
927
- projects: factoryProjectsStorage
943
+ boards
928
944
  }) : void 0;
929
945
  for (const { integration } of integrationRegistrations) if (integration.requiresStableStateSigner && !stateSigner.stable) throw new Error(`MastraFactory: integration '${integration.id}' signs OAuth state and requires a replica-stable state secret, but none is configured. Set 'stateSecret' on the factory config.`);
930
946
  const mastraStorageBackend = (() => {
@@ -940,6 +956,24 @@ var MastraFactory = class {
940
956
  versionControl: integration.versionControl,
941
957
  storage: sourceControlStorage.forIntegration(integration.id)
942
958
  }] : []);
959
+ this.#reviewedChangeRequest = (requestContext) => resolveReviewedChangeRequest({
960
+ requestContext,
961
+ providers: sourceControlToolProviders,
962
+ boundChangeRequestId: async () => {
963
+ const resolution = await resolveFactorySessionAddress({
964
+ requestContext,
965
+ storage: workItemsStorage
966
+ });
967
+ if (!resolution) return void 0;
968
+ const binding = resolution.binding ?? await workItemsStorage.findActiveRunBinding(resolution.address);
969
+ if (binding?.role !== "review") return void 0;
970
+ const item = await workItemsStorage.get({
971
+ orgId: binding.orgId,
972
+ id: binding.workItemId
973
+ });
974
+ return item ? boundChangeRequestNumber(await toBoardSource(boards).load(binding), item) : void 0;
975
+ }
976
+ });
943
977
  const connectToolsProjectId = this.#config.tools === void 0 ? platformConnectProjectId() : void 0;
944
978
  const sessionTools = this.#config.tools ?? (connectToolsProjectId ? platformConnectTools(connectToolsProjectId) : void 0);
945
979
  const warnedConfiguredToolClashes = /* @__PURE__ */ new Set();
@@ -1126,35 +1160,11 @@ var MastraFactory = class {
1126
1160
  requestContext,
1127
1161
  providers: sourceControlToolProviders,
1128
1162
  audit: auditDomain,
1129
- testChecksEnabled: async ({ orgId, factoryProjectId }) => {
1130
- await factoryProjectsStorage.ensureReady();
1131
- return (await factoryProjectsStorage.get({
1132
- orgId,
1133
- id: factoryProjectId
1134
- }))?.reviewTestChecksEnabled ?? false;
1135
- },
1136
- ...workItemsStorage ? {
1137
- selfReviewApprovedHead: () => selfReviewApprovedHead({
1138
- requestContext,
1139
- workItems: workItemsStorage,
1140
- projects: factoryProjectsStorage,
1141
- boards
1142
- }),
1143
- boundChangeRequestId: async () => {
1144
- const resolution = await resolveFactorySessionAddress({
1145
- requestContext,
1146
- storage: workItemsStorage
1147
- });
1148
- if (!resolution) return void 0;
1149
- const binding = resolution.binding ?? await workItemsStorage.findActiveRunBinding(resolution.address);
1150
- if (binding?.role !== "review") return void 0;
1151
- const item = await workItemsStorage.get({
1152
- orgId: binding.orgId,
1153
- id: binding.workItemId
1154
- });
1155
- return item ? boundChangeRequestNumber(await toBoardSource(boards).load(binding), item) : void 0;
1156
- }
1157
- } : {}
1163
+ ...workItemsStorage ? { selfReviewApprovedHead: () => selfReviewApprovedHead({
1164
+ requestContext,
1165
+ workItems: workItemsStorage,
1166
+ boards
1167
+ }) } : {}
1158
1168
  }));
1159
1169
  if (workItemsStorage && transitionService) {
1160
1170
  mergeTools("factory", await createFactoryTransitionTools({
@@ -1275,7 +1285,7 @@ var MastraFactory = class {
1275
1285
  ...assembleFactoryApiRoutes({
1276
1286
  controllerId: CONTROLLER_ID,
1277
1287
  controller,
1278
- liveSessions: liveSessions = liveSessionsTouchingTheFeed(controller, eventBus),
1288
+ liveSessions: liveSessions = liveSessionsTouchingTheFeed(controller, eventBus, sourceControlSessions),
1279
1289
  auth: routeAuth,
1280
1290
  ...auth && isUserProvider(auth) ? { users: auth } : {},
1281
1291
  authStorage,
@@ -1323,13 +1333,6 @@ var MastraFactory = class {
1323
1333
  boards,
1324
1334
  ...this.#projectBoards ? { intakeRoutes: storedBoardsStorage } : {},
1325
1335
  maxInFlight: this.#config.dispatcher?.maxInFlight,
1326
- isAutoRunEnabled: async ({ orgId, factoryProjectId }) => {
1327
- await factoryProjectsStorage.ensureReady();
1328
- return (await factoryProjectsStorage.get({
1329
- orgId,
1330
- id: factoryProjectId
1331
- }))?.autoRunEnabled ?? false;
1332
- },
1333
1336
  factoryProjectExists: async ({ orgId, factoryProjectId }) => {
1334
1337
  await factoryProjectsStorage.ensureReady();
1335
1338
  return await factoryProjectsStorage.get({