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

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 (662) hide show
  1. package/README.md +363 -162
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js +12 -6
  4. package/dist/auth.js.map +1 -1
  5. package/dist/boards/board-events.d.ts +23 -3
  6. package/dist/boards/board-events.d.ts.map +1 -1
  7. package/dist/boards/board-events.js +44 -7
  8. package/dist/boards/board-events.js.map +1 -1
  9. package/dist/boards/board-writes.d.ts +2 -2
  10. package/dist/boards/board-writes.d.ts.map +1 -1
  11. package/dist/boards/board-writes.js +23 -9
  12. package/dist/boards/board-writes.js.map +1 -1
  13. package/dist/boards/card-facts.d.ts +3 -1
  14. package/dist/boards/card-facts.d.ts.map +1 -1
  15. package/dist/boards/card-facts.js +30 -4
  16. package/dist/boards/card-facts.js.map +1 -1
  17. package/dist/boards/default-board.d.ts +7 -0
  18. package/dist/boards/default-board.d.ts.map +1 -0
  19. package/dist/boards/default-board.js +10 -0
  20. package/dist/boards/default-board.js.map +1 -0
  21. package/dist/boards/define-board.d.ts +40 -18
  22. package/dist/boards/define-board.d.ts.map +1 -1
  23. package/dist/boards/define-board.js +64 -42
  24. package/dist/boards/define-board.js.map +1 -1
  25. package/dist/boards/index.d.ts +6 -9
  26. package/dist/boards/index.d.ts.map +1 -1
  27. package/dist/boards/index.js +6 -20
  28. package/dist/boards/intake-routing.d.ts +29 -9
  29. package/dist/boards/intake-routing.d.ts.map +1 -1
  30. package/dist/boards/intake-routing.js +72 -20
  31. package/dist/boards/intake-routing.js.map +1 -1
  32. package/dist/boards/legacy-plan-role.d.ts.map +1 -1
  33. package/dist/boards/legacy-plan-role.js +7 -2
  34. package/dist/boards/legacy-plan-role.js.map +1 -1
  35. package/dist/boards/phase-automation.d.ts +7 -0
  36. package/dist/boards/phase-automation.d.ts.map +1 -1
  37. package/dist/boards/phase-automation.js +16 -5
  38. package/dist/boards/phase-automation.js.map +1 -1
  39. package/dist/boards/phase-runner.d.ts +18 -10
  40. package/dist/boards/phase-runner.d.ts.map +1 -1
  41. package/dist/boards/phase-runner.js +39 -34
  42. package/dist/boards/phase-runner.js.map +1 -1
  43. package/dist/boards/project-boards.d.ts +57 -11
  44. package/dist/boards/project-boards.d.ts.map +1 -1
  45. package/dist/boards/project-boards.js +161 -34
  46. package/dist/boards/project-boards.js.map +1 -1
  47. package/dist/boards/registry.d.ts +7 -1
  48. package/dist/boards/registry.d.ts.map +1 -1
  49. package/dist/boards/registry.js +19 -4
  50. package/dist/boards/registry.js.map +1 -1
  51. package/dist/boards/relocate.d.ts +1 -1
  52. package/dist/boards/relocate.d.ts.map +1 -1
  53. package/dist/boards/relocate.js +3 -2
  54. package/dist/boards/relocate.js.map +1 -1
  55. package/dist/boards/review.d.ts +5 -2
  56. package/dist/boards/review.d.ts.map +1 -1
  57. package/dist/boards/review.js +12 -11
  58. package/dist/boards/review.js.map +1 -1
  59. package/dist/boards/semantics.d.ts +160 -20
  60. package/dist/boards/semantics.d.ts.map +1 -1
  61. package/dist/boards/semantics.js +255 -23
  62. package/dist/boards/semantics.js.map +1 -1
  63. package/dist/boards/stored-board.d.ts +32 -18
  64. package/dist/boards/stored-board.d.ts.map +1 -1
  65. package/dist/boards/stored-board.js +31 -97
  66. package/dist/boards/stored-board.js.map +1 -1
  67. package/dist/boards/work-migrations.d.ts +43 -0
  68. package/dist/boards/work-migrations.d.ts.map +1 -0
  69. package/dist/boards/work-migrations.js +353 -0
  70. package/dist/boards/work-migrations.js.map +1 -0
  71. package/dist/boards/work-routes.d.ts +58 -0
  72. package/dist/boards/work-routes.d.ts.map +1 -0
  73. package/dist/boards/work-routes.js +270 -0
  74. package/dist/boards/work-routes.js.map +1 -0
  75. package/dist/boards/work-seeds.d.ts +9 -0
  76. package/dist/boards/work-seeds.d.ts.map +1 -0
  77. package/dist/boards/work-seeds.js +56 -0
  78. package/dist/boards/work-seeds.js.map +1 -0
  79. package/dist/boards/work.d.ts +8 -19
  80. package/dist/boards/work.d.ts.map +1 -1
  81. package/dist/boards/work.js +33 -281
  82. package/dist/boards/work.js.map +1 -1
  83. package/dist/capabilities/version-control.d.ts +6 -1
  84. package/dist/capabilities/version-control.d.ts.map +1 -1
  85. package/dist/environment/build-runner.d.ts.map +1 -1
  86. package/dist/environment/build-runner.js +2 -2
  87. package/dist/environment/build-runner.js.map +1 -1
  88. package/dist/environment/build-schedule.js +1 -1
  89. package/dist/environment/build-schedule.js.map +1 -1
  90. package/dist/environment/build-workflow.d.ts.map +1 -1
  91. package/dist/environment/build-workflow.js +6 -5
  92. package/dist/environment/build-workflow.js.map +1 -1
  93. package/dist/environment/build.d.ts +17 -4
  94. package/dist/environment/build.d.ts.map +1 -1
  95. package/dist/environment/build.js +35 -10
  96. package/dist/environment/build.js.map +1 -1
  97. package/dist/environment/heads.d.ts +1 -1
  98. package/dist/environment/heads.d.ts.map +1 -1
  99. package/dist/environment/heads.js +4 -1
  100. package/dist/environment/heads.js.map +1 -1
  101. package/dist/environment/repository-access.d.ts +13 -0
  102. package/dist/environment/repository-access.d.ts.map +1 -0
  103. package/dist/environment/repository-access.js +55 -0
  104. package/dist/environment/repository-access.js.map +1 -0
  105. package/dist/factory.d.ts +34 -7
  106. package/dist/factory.d.ts.map +1 -1
  107. package/dist/factory.js +161 -133
  108. package/dist/factory.js.map +1 -1
  109. package/dist/feed-events.d.ts +4 -4
  110. package/dist/feed-events.d.ts.map +1 -1
  111. package/dist/feed-events.js +6 -6
  112. package/dist/feed-events.js.map +1 -1
  113. package/dist/index.d.ts +7 -2
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +5 -3
  116. package/dist/integrations/base.d.ts +6 -13
  117. package/dist/integrations/base.d.ts.map +1 -1
  118. package/dist/integrations/closing-references.d.ts +15 -0
  119. package/dist/integrations/closing-references.d.ts.map +1 -0
  120. package/dist/integrations/closing-references.js +69 -0
  121. package/dist/integrations/closing-references.js.map +1 -0
  122. package/dist/integrations/github/default-rules.d.ts +15 -66
  123. package/dist/integrations/github/default-rules.d.ts.map +1 -1
  124. package/dist/integrations/github/default-rules.js +129 -73
  125. package/dist/integrations/github/default-rules.js.map +1 -1
  126. package/dist/integrations/github/integration.d.ts.map +1 -1
  127. package/dist/integrations/github/integration.js +7 -3
  128. package/dist/integrations/github/integration.js.map +1 -1
  129. package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
  130. package/dist/integrations/github/issue-reconciler.js +5 -3
  131. package/dist/integrations/github/issue-reconciler.js.map +1 -1
  132. package/dist/integrations/github/provenance.js +1 -1
  133. package/dist/integrations/github/provenance.js.map +1 -1
  134. package/dist/integrations/github/pull-request-source.d.ts +8 -0
  135. package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
  136. package/dist/integrations/github/pull-request-source.js +17 -0
  137. package/dist/integrations/github/pull-request-source.js.map +1 -0
  138. package/dist/integrations/github/reconcile-worker.d.ts +5 -1
  139. package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
  140. package/dist/integrations/github/reconcile-worker.js +39 -6
  141. package/dist/integrations/github/reconcile-worker.js.map +1 -1
  142. package/dist/integrations/github/review-status-reporter.d.ts.map +1 -1
  143. package/dist/integrations/github/review-status-reporter.js +7 -3
  144. package/dist/integrations/github/review-status-reporter.js.map +1 -1
  145. package/dist/integrations/github/routes.d.ts +4 -3
  146. package/dist/integrations/github/routes.d.ts.map +1 -1
  147. package/dist/integrations/github/routes.js +10 -87
  148. package/dist/integrations/github/routes.js.map +1 -1
  149. package/dist/integrations/github/rules.d.ts +79 -7
  150. package/dist/integrations/github/rules.d.ts.map +1 -1
  151. package/dist/integrations/github/rules.js +426 -102
  152. package/dist/integrations/github/rules.js.map +1 -1
  153. package/dist/integrations/github/sandbox.d.ts +10 -2
  154. package/dist/integrations/github/sandbox.d.ts.map +1 -1
  155. package/dist/integrations/github/sandbox.js +20 -4
  156. package/dist/integrations/github/sandbox.js.map +1 -1
  157. package/dist/integrations/github/session-subscriptions.js +2 -2
  158. package/dist/integrations/github/session-subscriptions.js.map +1 -1
  159. package/dist/integrations/github/token-refresh.d.ts +2 -1
  160. package/dist/integrations/github/token-refresh.d.ts.map +1 -1
  161. package/dist/integrations/github/token-refresh.js.map +1 -1
  162. package/dist/integrations/gitlab/agent-tools.js +1 -1
  163. package/dist/integrations/gitlab/default-rules.d.ts +73 -31
  164. package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
  165. package/dist/integrations/gitlab/default-rules.js +106 -43
  166. package/dist/integrations/gitlab/default-rules.js.map +1 -1
  167. package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
  168. package/dist/integrations/gitlab/issue-reconciler.js +2 -1
  169. package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
  170. package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
  171. package/dist/integrations/gitlab/merge-request-reconciler.js +12 -5
  172. package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
  173. package/dist/integrations/gitlab/routes.d.ts.map +1 -1
  174. package/dist/integrations/gitlab/routes.js +1 -3
  175. package/dist/integrations/gitlab/routes.js.map +1 -1
  176. package/dist/integrations/gitlab/rules.d.ts +6 -1
  177. package/dist/integrations/gitlab/rules.d.ts.map +1 -1
  178. package/dist/integrations/gitlab/rules.js +119 -30
  179. package/dist/integrations/gitlab/rules.js.map +1 -1
  180. package/dist/integrations/gitlab/session-subscriptions.js +1 -1
  181. package/dist/integrations/incidentio/agent-tools.js +6 -6
  182. package/dist/integrations/incidentio/agent-tools.js.map +1 -1
  183. package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
  184. package/dist/integrations/incidentio/default-rules.js +3 -3
  185. package/dist/integrations/incidentio/default-rules.js.map +1 -1
  186. package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
  187. package/dist/integrations/incidentio/issue-reconciler.js +2 -1
  188. package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
  189. package/dist/integrations/incidentio/routes.d.ts +2 -2
  190. package/dist/integrations/incidentio/routes.d.ts.map +1 -1
  191. package/dist/integrations/incidentio/routes.js +10 -13
  192. package/dist/integrations/incidentio/routes.js.map +1 -1
  193. package/dist/integrations/incidentio/rules.d.ts +4 -4
  194. package/dist/integrations/incidentio/rules.d.ts.map +1 -1
  195. package/dist/integrations/incidentio/rules.js +18 -14
  196. package/dist/integrations/incidentio/rules.js.map +1 -1
  197. package/dist/integrations/issue-reconciler.js +1 -1
  198. package/dist/integrations/issue-reconciler.js.map +1 -1
  199. package/dist/integrations/jira/agent-tools.js +1 -1
  200. package/dist/integrations/jira/binding-scope.d.ts +5 -6
  201. package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
  202. package/dist/integrations/jira/binding-scope.js +9 -11
  203. package/dist/integrations/jira/binding-scope.js.map +1 -1
  204. package/dist/integrations/jira/default-rules.d.ts.map +1 -1
  205. package/dist/integrations/jira/default-rules.js +3 -3
  206. package/dist/integrations/jira/default-rules.js.map +1 -1
  207. package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
  208. package/dist/integrations/jira/issue-reconciler.js +2 -1
  209. package/dist/integrations/jira/issue-reconciler.js.map +1 -1
  210. package/dist/integrations/jira/routes.d.ts.map +1 -1
  211. package/dist/integrations/jira/routes.js +3 -5
  212. package/dist/integrations/jira/routes.js.map +1 -1
  213. package/dist/integrations/jira/rules.d.ts +4 -4
  214. package/dist/integrations/jira/rules.d.ts.map +1 -1
  215. package/dist/integrations/jira/rules.js +18 -14
  216. package/dist/integrations/jira/rules.js.map +1 -1
  217. package/dist/integrations/linear/agent-tools.d.ts +9 -1
  218. package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
  219. package/dist/integrations/linear/agent-tools.js +81 -3
  220. package/dist/integrations/linear/agent-tools.js.map +1 -1
  221. package/dist/integrations/linear/default-rules.d.ts.map +1 -1
  222. package/dist/integrations/linear/default-rules.js +3 -3
  223. package/dist/integrations/linear/default-rules.js.map +1 -1
  224. package/dist/integrations/linear/integration.d.ts +4 -1
  225. package/dist/integrations/linear/integration.d.ts.map +1 -1
  226. package/dist/integrations/linear/integration.js +21 -1
  227. package/dist/integrations/linear/integration.js.map +1 -1
  228. package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
  229. package/dist/integrations/linear/issue-reconciler.js +2 -1
  230. package/dist/integrations/linear/issue-reconciler.js.map +1 -1
  231. package/dist/integrations/linear/routes.d.ts +2 -1
  232. package/dist/integrations/linear/routes.d.ts.map +1 -1
  233. package/dist/integrations/linear/routes.js +15 -17
  234. package/dist/integrations/linear/routes.js.map +1 -1
  235. package/dist/integrations/linear/rules.d.ts +4 -4
  236. package/dist/integrations/linear/rules.d.ts.map +1 -1
  237. package/dist/integrations/linear/rules.js +16 -15
  238. package/dist/integrations/linear/rules.js.map +1 -1
  239. package/dist/integrations/platform/connect/session-tools.d.ts +5 -0
  240. package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -1
  241. package/dist/integrations/platform/connect/session-tools.js +5 -0
  242. package/dist/integrations/platform/connect/session-tools.js.map +1 -1
  243. package/dist/integrations/platform/github/event-worker.d.ts +4 -1
  244. package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
  245. package/dist/integrations/platform/github/event-worker.js +39 -3
  246. package/dist/integrations/platform/github/event-worker.js.map +1 -1
  247. package/dist/integrations/platform/github/integration.d.ts +8 -0
  248. package/dist/integrations/platform/github/integration.d.ts.map +1 -1
  249. package/dist/integrations/platform/github/integration.js +143 -93
  250. package/dist/integrations/platform/github/integration.js.map +1 -1
  251. package/dist/integrations/platform/jira/agent-tools.js +1 -1
  252. package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
  253. package/dist/integrations/platform/jira/routes.js +3 -5
  254. package/dist/integrations/platform/jira/routes.js.map +1 -1
  255. package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
  256. package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
  257. package/dist/integrations/platform/linear/event-worker.js +1 -1
  258. package/dist/integrations/platform/linear/event-worker.js.map +1 -1
  259. package/dist/integrations/platform/linear/integration.d.ts +1 -1
  260. package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
  261. package/dist/integrations/platform/linear/integration.js +6 -5
  262. package/dist/integrations/platform/linear/integration.js.map +1 -1
  263. package/dist/integrations/slack/chat-tools.js +1 -1
  264. package/dist/integrations/slack/integration.d.ts +0 -2
  265. package/dist/integrations/slack/integration.d.ts.map +1 -1
  266. package/dist/integrations/slack/integration.js +7 -9
  267. package/dist/integrations/slack/integration.js.map +1 -1
  268. package/dist/integrations/slack/reply-tool.js +1 -1
  269. package/dist/integrations/slack/run-error-card.js +1 -0
  270. package/dist/integrations/slack/run-error-card.js.map +1 -1
  271. package/dist/integrations/slack/share-file-tool.js +1 -1
  272. package/dist/integrations/slack/slack.d.ts +13 -22
  273. package/dist/integrations/slack/slack.d.ts.map +1 -1
  274. package/dist/integrations/slack/slack.js +22 -83
  275. package/dist/integrations/slack/slack.js.map +1 -1
  276. package/dist/links.d.ts +1 -2
  277. package/dist/links.d.ts.map +1 -1
  278. package/dist/links.js +4 -4
  279. package/dist/links.js.map +1 -1
  280. package/dist/mcp/routes.js +3 -3
  281. package/dist/mcp/routes.js.map +1 -1
  282. package/dist/provider-display-name.d.ts.map +1 -1
  283. package/dist/provider-display-name.js +1 -0
  284. package/dist/provider-display-name.js.map +1 -1
  285. package/dist/routes/attention-parked.d.ts +1 -0
  286. package/dist/routes/attention-parked.d.ts.map +1 -1
  287. package/dist/routes/attention-parked.js +2 -2
  288. package/dist/routes/attention-parked.js.map +1 -1
  289. package/dist/routes/attention-providers.d.ts +0 -25
  290. package/dist/routes/attention-providers.d.ts.map +1 -1
  291. package/dist/routes/attention-providers.js +2 -150
  292. package/dist/routes/attention-providers.js.map +1 -1
  293. package/dist/routes/attention.d.ts +0 -2
  294. package/dist/routes/attention.d.ts.map +1 -1
  295. package/dist/routes/attention.js +2 -13
  296. package/dist/routes/attention.js.map +1 -1
  297. package/dist/routes/automation-runs.d.ts +5 -1
  298. package/dist/routes/automation-runs.d.ts.map +1 -1
  299. package/dist/routes/automation-runs.js +15 -0
  300. package/dist/routes/automation-runs.js.map +1 -1
  301. package/dist/routes/board-snapshot.d.ts +21 -0
  302. package/dist/routes/board-snapshot.d.ts.map +1 -0
  303. package/dist/routes/board-snapshot.js +58 -0
  304. package/dist/routes/board-snapshot.js.map +1 -0
  305. package/dist/routes/boards.d.ts +2 -2
  306. package/dist/routes/boards.d.ts.map +1 -1
  307. package/dist/routes/boards.js +1 -17
  308. package/dist/routes/boards.js.map +1 -1
  309. package/dist/routes/config.d.ts +11 -1
  310. package/dist/routes/config.d.ts.map +1 -1
  311. package/dist/routes/config.js +120 -22
  312. package/dist/routes/config.js.map +1 -1
  313. package/dist/routes/contracts.d.ts +257 -51
  314. package/dist/routes/contracts.d.ts.map +1 -1
  315. package/dist/routes/contracts.js +131 -40
  316. package/dist/routes/contracts.js.map +1 -1
  317. package/dist/routes/feed-events.d.ts +15 -0
  318. package/dist/routes/feed-events.d.ts.map +1 -0
  319. package/dist/routes/feed-events.js +68 -0
  320. package/dist/routes/feed-events.js.map +1 -0
  321. package/dist/routes/fs.d.ts +4 -0
  322. package/dist/routes/fs.d.ts.map +1 -1
  323. package/dist/routes/fs.js +8 -4
  324. package/dist/routes/fs.js.map +1 -1
  325. package/dist/routes/intake-routes.d.ts.map +1 -1
  326. package/dist/routes/intake-routes.js +6 -1
  327. package/dist/routes/intake-routes.js.map +1 -1
  328. package/dist/routes/intake.d.ts +0 -23
  329. package/dist/routes/intake.d.ts.map +1 -1
  330. package/dist/routes/intake.js +13 -309
  331. package/dist/routes/intake.js.map +1 -1
  332. package/dist/routes/knowledge.js +1 -1
  333. package/dist/routes/mastra-gateway.d.ts +19 -0
  334. package/dist/routes/mastra-gateway.d.ts.map +1 -0
  335. package/dist/routes/mastra-gateway.js +120 -0
  336. package/dist/routes/mastra-gateway.js.map +1 -0
  337. package/dist/routes/projects.d.ts +1 -1
  338. package/dist/routes/projects.d.ts.map +1 -1
  339. package/dist/routes/projects.js +74 -58
  340. package/dist/routes/projects.js.map +1 -1
  341. package/dist/routes/provider-credentials.d.ts +6 -1
  342. package/dist/routes/provider-credentials.d.ts.map +1 -1
  343. package/dist/routes/provider-credentials.js +42 -7
  344. package/dist/routes/provider-credentials.js.map +1 -1
  345. package/dist/routes/route.d.ts +6 -0
  346. package/dist/routes/route.d.ts.map +1 -1
  347. package/dist/routes/route.js.map +1 -1
  348. package/dist/routes/running-packages.d.ts +13 -0
  349. package/dist/routes/running-packages.d.ts.map +1 -0
  350. package/dist/routes/running-packages.js +45 -0
  351. package/dist/routes/running-packages.js.map +1 -0
  352. package/dist/routes/sandbox-envs.d.ts +26 -0
  353. package/dist/routes/sandbox-envs.d.ts.map +1 -0
  354. package/dist/routes/sandbox-envs.js +180 -0
  355. package/dist/routes/sandbox-envs.js.map +1 -0
  356. package/dist/routes/session-access.d.ts.map +1 -1
  357. package/dist/routes/session-access.js +12 -3
  358. package/dist/routes/session-access.js.map +1 -1
  359. package/dist/routes/surface.d.ts +10 -8
  360. package/dist/routes/surface.d.ts.map +1 -1
  361. package/dist/routes/surface.js +105 -42
  362. package/dist/routes/surface.js.map +1 -1
  363. package/dist/routes/tenant-credentials.d.ts.map +1 -1
  364. package/dist/routes/tenant-credentials.js +5 -1
  365. package/dist/routes/tenant-credentials.js.map +1 -1
  366. package/dist/routes/work-items.d.ts +0 -3
  367. package/dist/routes/work-items.d.ts.map +1 -1
  368. package/dist/routes/work-items.js +94 -12
  369. package/dist/routes/work-items.js.map +1 -1
  370. package/dist/rules/binding-context.d.ts.map +1 -1
  371. package/dist/rules/binding-context.js +1 -0
  372. package/dist/rules/binding-context.js.map +1 -1
  373. package/dist/rules/dispatcher.d.ts +0 -9
  374. package/dist/rules/dispatcher.d.ts.map +1 -1
  375. package/dist/rules/dispatcher.js +362 -69
  376. package/dist/rules/dispatcher.js.map +1 -1
  377. package/dist/rules/event-rules.d.ts +33 -2
  378. package/dist/rules/event-rules.d.ts.map +1 -1
  379. package/dist/rules/event-rules.js +46 -11
  380. package/dist/rules/event-rules.js.map +1 -1
  381. package/dist/rules/index.d.ts +2 -4
  382. package/dist/rules/index.d.ts.map +1 -1
  383. package/dist/rules/index.js +2 -3
  384. package/dist/rules/phase-goal.d.ts +54 -0
  385. package/dist/rules/phase-goal.d.ts.map +1 -0
  386. package/dist/rules/phase-goal.js +70 -0
  387. package/dist/rules/phase-goal.js.map +1 -0
  388. package/dist/rules/phase-tools.d.ts +11 -0
  389. package/dist/rules/phase-tools.d.ts.map +1 -0
  390. package/dist/rules/phase-tools.js +19 -0
  391. package/dist/rules/phase-tools.js.map +1 -0
  392. package/dist/rules/processor.d.ts.map +1 -1
  393. package/dist/rules/processor.js +116 -15
  394. package/dist/rules/processor.js.map +1 -1
  395. package/dist/rules/review-source-tool.d.ts +4 -1
  396. package/dist/rules/review-source-tool.d.ts.map +1 -1
  397. package/dist/rules/review-source-tool.js +24 -4
  398. package/dist/rules/review-source-tool.js.map +1 -1
  399. package/dist/rules/rule-group.d.ts +1 -1
  400. package/dist/rules/rule-group.d.ts.map +1 -1
  401. package/dist/rules/rule-group.js +15 -6
  402. package/dist/rules/rule-group.js.map +1 -1
  403. package/dist/rules/start-coordinator.d.ts +5 -1
  404. package/dist/rules/start-coordinator.d.ts.map +1 -1
  405. package/dist/rules/start-coordinator.js +9 -3
  406. package/dist/rules/start-coordinator.js.map +1 -1
  407. package/dist/rules/tools.d.ts.map +1 -1
  408. package/dist/rules/tools.js +39 -28
  409. package/dist/rules/tools.js.map +1 -1
  410. package/dist/rules/transition-service.d.ts +4 -10
  411. package/dist/rules/transition-service.d.ts.map +1 -1
  412. package/dist/rules/transition-service.js +61 -55
  413. package/dist/rules/transition-service.js.map +1 -1
  414. package/dist/rules/types.d.ts +86 -36
  415. package/dist/rules/types.d.ts.map +1 -1
  416. package/dist/rules/types.js +5 -41
  417. package/dist/rules/types.js.map +1 -1
  418. package/dist/rules/validation.d.ts.map +1 -1
  419. package/dist/rules/validation.js +32 -2
  420. package/dist/rules/validation.js.map +1 -1
  421. package/dist/run-error.d.ts +1 -1
  422. package/dist/run-error.d.ts.map +1 -1
  423. package/dist/run-error.js +38 -5
  424. package/dist/run-error.js.map +1 -1
  425. package/dist/sandbox/sandbox-env-cache.d.ts +33 -0
  426. package/dist/sandbox/sandbox-env-cache.d.ts.map +1 -0
  427. package/dist/sandbox/sandbox-env-cache.js +140 -0
  428. package/dist/sandbox/sandbox-env-cache.js.map +1 -0
  429. package/dist/sandbox/sandbox-env.d.ts +77 -0
  430. package/dist/sandbox/sandbox-env.d.ts.map +1 -0
  431. package/dist/sandbox/sandbox-env.js +130 -0
  432. package/dist/sandbox/sandbox-env.js.map +1 -0
  433. package/dist/secret-encryption.d.ts +21 -0
  434. package/dist/secret-encryption.d.ts.map +1 -1
  435. package/dist/secret-encryption.js +31 -4
  436. package/dist/secret-encryption.js.map +1 -1
  437. package/dist/session/live-sessions.d.ts +11 -4
  438. package/dist/session/live-sessions.d.ts.map +1 -1
  439. package/dist/session/live-sessions.js +41 -10
  440. package/dist/session/live-sessions.js.map +1 -1
  441. package/dist/session/self-review-gate.d.ts +6 -4
  442. package/dist/session/self-review-gate.d.ts.map +1 -1
  443. package/dist/session/self-review-gate.js +9 -12
  444. package/dist/session/self-review-gate.js.map +1 -1
  445. package/dist/session/session-threads.d.ts +2 -3
  446. package/dist/session/session-threads.d.ts.map +1 -1
  447. package/dist/session/session-threads.js.map +1 -1
  448. package/dist/session/source-control-tools.d.ts +39 -13
  449. package/dist/session/source-control-tools.d.ts.map +1 -1
  450. package/dist/session/source-control-tools.js +55 -61
  451. package/dist/session/source-control-tools.js.map +1 -1
  452. package/dist/session/work-item-state-processor.d.ts +24 -0
  453. package/dist/session/work-item-state-processor.d.ts.map +1 -0
  454. package/dist/session/work-item-state-processor.js +275 -0
  455. package/dist/session/work-item-state-processor.js.map +1 -0
  456. package/dist/storage/domains/audit/actions.d.ts +2 -1
  457. package/dist/storage/domains/audit/actions.d.ts.map +1 -1
  458. package/dist/storage/domains/audit/actions.js +5 -4
  459. package/dist/storage/domains/audit/actions.js.map +1 -1
  460. package/dist/storage/domains/boards/base.d.ts +85 -32
  461. package/dist/storage/domains/boards/base.d.ts.map +1 -1
  462. package/dist/storage/domains/boards/base.js +120 -131
  463. package/dist/storage/domains/boards/base.js.map +1 -1
  464. package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
  465. package/dist/storage/domains/boards/schemas.js +12 -0
  466. package/dist/storage/domains/boards/schemas.js.map +1 -1
  467. package/dist/storage/domains/channel-identity/base.d.ts +0 -4
  468. package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
  469. package/dist/storage/domains/channel-identity/base.js +0 -7
  470. package/dist/storage/domains/channel-identity/base.js.map +1 -1
  471. package/dist/storage/domains/intake/base.d.ts +5 -45
  472. package/dist/storage/domains/intake/base.d.ts.map +1 -1
  473. package/dist/storage/domains/intake/base.js +11 -89
  474. package/dist/storage/domains/intake/base.js.map +1 -1
  475. package/dist/storage/domains/projects/base.d.ts +17 -9
  476. package/dist/storage/domains/projects/base.d.ts.map +1 -1
  477. package/dist/storage/domains/projects/base.js +15 -7
  478. package/dist/storage/domains/projects/base.js.map +1 -1
  479. package/dist/storage/domains/sandbox-envs/base.d.ts +70 -0
  480. package/dist/storage/domains/sandbox-envs/base.d.ts.map +1 -0
  481. package/dist/storage/domains/sandbox-envs/base.js +227 -0
  482. package/dist/storage/domains/sandbox-envs/base.js.map +1 -0
  483. package/dist/storage/domains/work-items/base.d.ts +62 -22
  484. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  485. package/dist/storage/domains/work-items/base.js +231 -146
  486. package/dist/storage/domains/work-items/base.js.map +1 -1
  487. package/dist/storage/domains/work-items/board-version.d.ts +6 -2
  488. package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
  489. package/dist/storage/domains/work-items/board-version.js +20 -9
  490. package/dist/storage/domains/work-items/board-version.js.map +1 -1
  491. package/dist/storage/domains/work-items/cards.d.ts +28 -5
  492. package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
  493. package/dist/storage/domains/work-items/cards.js +156 -23
  494. package/dist/storage/domains/work-items/cards.js.map +1 -1
  495. package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
  496. package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
  497. package/dist/storage/domains/work-items/legacy-review.js +109 -0
  498. package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
  499. package/dist/storage/domains/work-items/metrics.d.ts +12 -4
  500. package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
  501. package/dist/storage/domains/work-items/metrics.js +14 -32
  502. package/dist/storage/domains/work-items/metrics.js.map +1 -1
  503. package/dist/storage/domains/work-items/work-item-schema.d.ts +4 -2
  504. package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
  505. package/dist/storage/domains/work-items/work-item-schema.js +59 -26
  506. package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
  507. package/dist/tools/approval-tools.d.ts.map +1 -1
  508. package/dist/tools/approval-tools.js +28 -9
  509. package/dist/tools/approval-tools.js.map +1 -1
  510. package/dist/tools/index.d.ts +1 -1
  511. package/dist/tools/index.js +1 -1
  512. package/dist/tools/index.js.map +1 -1
  513. package/dist/tools/messaging-tools.d.ts +3 -0
  514. package/dist/tools/messaging-tools.d.ts.map +1 -1
  515. package/dist/tools/messaging-tools.js +2 -1
  516. package/dist/tools/messaging-tools.js.map +1 -1
  517. package/dist/tools/read-tools.d.ts +8 -4
  518. package/dist/tools/read-tools.d.ts.map +1 -1
  519. package/dist/tools/read-tools.js +86 -37
  520. package/dist/tools/read-tools.js.map +1 -1
  521. package/dist/tools/reports.d.ts +1 -0
  522. package/dist/tools/reports.d.ts.map +1 -1
  523. package/dist/tools/reports.js +2 -1
  524. package/dist/tools/reports.js.map +1 -1
  525. package/dist/tools/run-watch.d.ts +1 -1
  526. package/dist/tools/run-watch.d.ts.map +1 -1
  527. package/dist/tools/run-watch.js +1 -0
  528. package/dist/tools/run-watch.js.map +1 -1
  529. package/dist/tools/sandbox-tools.js +1 -1
  530. package/dist/tools/session-tools.js +1 -1
  531. package/dist/tools/sessions-state-processor.d.ts +2 -0
  532. package/dist/tools/sessions-state-processor.d.ts.map +1 -1
  533. package/dist/tools/sessions-state-processor.js +4 -2
  534. package/dist/tools/sessions-state-processor.js.map +1 -1
  535. package/dist/tools/side-sessions.d.ts +2 -0
  536. package/dist/tools/side-sessions.d.ts.map +1 -1
  537. package/dist/tools/side-sessions.js +2 -1
  538. package/dist/tools/side-sessions.js.map +1 -1
  539. package/dist/tools/work-item-tools.d.ts +0 -3
  540. package/dist/tools/work-item-tools.d.ts.map +1 -1
  541. package/dist/tools/work-item-tools.js +10 -20
  542. package/dist/tools/work-item-tools.js.map +1 -1
  543. package/dist/work-item-branch.d.ts +13 -0
  544. package/dist/work-item-branch.d.ts.map +1 -1
  545. package/dist/work-item-branch.js +16 -1
  546. package/dist/work-item-branch.js.map +1 -1
  547. package/dist/work-items/create-work-item.d.ts +6 -0
  548. package/dist/work-items/create-work-item.d.ts.map +1 -1
  549. package/dist/work-items/create-work-item.js +28 -3
  550. package/dist/work-items/create-work-item.js.map +1 -1
  551. package/dist/work-items/description-context.d.ts +5 -0
  552. package/dist/work-items/description-context.d.ts.map +1 -0
  553. package/dist/work-items/description-context.js +17 -0
  554. package/dist/work-items/description-context.js.map +1 -0
  555. package/dist/work-items/providers/base.d.ts +4 -1
  556. package/dist/work-items/providers/base.d.ts.map +1 -1
  557. package/dist/work-items/providers/base.js +6 -1
  558. package/dist/work-items/providers/base.js.map +1 -1
  559. package/dist/work-items/providers/github.d.ts.map +1 -1
  560. package/dist/work-items/providers/github.js +2 -1
  561. package/dist/work-items/providers/github.js.map +1 -1
  562. package/dist/work-items/providers/gitlab.d.ts.map +1 -1
  563. package/dist/work-items/providers/gitlab.js +2 -1
  564. package/dist/work-items/providers/gitlab.js.map +1 -1
  565. package/dist/work-items/providers/jira.d.ts.map +1 -1
  566. package/dist/work-items/providers/jira.js +3 -2
  567. package/dist/work-items/providers/jira.js.map +1 -1
  568. package/dist/work-items/providers/linear.d.ts.map +1 -1
  569. package/dist/work-items/providers/linear.js +3 -2
  570. package/dist/work-items/providers/linear.js.map +1 -1
  571. package/dist/work-items/providers/types.d.ts +6 -0
  572. package/dist/work-items/providers/types.d.ts.map +1 -1
  573. package/dist/work-items/related-cards.d.ts +21 -0
  574. package/dist/work-items/related-cards.d.ts.map +1 -0
  575. package/dist/work-items/related-cards.js +45 -0
  576. package/dist/work-items/related-cards.js.map +1 -0
  577. package/dist/work-items/split-migration.d.ts.map +1 -1
  578. package/dist/work-items/split-migration.js +8 -8
  579. package/dist/work-items/split-migration.js.map +1 -1
  580. package/dist/workspace.d.ts +3 -1
  581. package/dist/workspace.d.ts.map +1 -1
  582. package/dist/workspace.js +122 -45
  583. package/dist/workspace.js.map +1 -1
  584. package/factory-skills/configure-factory-rules/SKILL.md +13 -11
  585. package/factory-skills/factory-build/SKILL.md +64 -0
  586. package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
  587. package/factory-skills/factory-gitlab-review/SKILL.md +6 -6
  588. package/factory-skills/factory-plan/SKILL.md +8 -10
  589. package/factory-skills/factory-rereview/SKILL.md +74 -28
  590. package/factory-skills/factory-review/SKILL.md +85 -29
  591. package/factory-skills/factory-self-review/SKILL.md +32 -13
  592. package/factory-skills/factory-triage/SKILL.md +36 -32
  593. package/package.json +12 -12
  594. package/dist/boards/index.js.map +0 -1
  595. package/dist/boards/pull-request-review.d.ts +0 -14
  596. package/dist/boards/pull-request-review.d.ts.map +0 -1
  597. package/dist/boards/pull-request-review.js +0 -81
  598. package/dist/boards/pull-request-review.js.map +0 -1
  599. package/dist/boards/work-tool-rules.d.ts +0 -8
  600. package/dist/boards/work-tool-rules.d.ts.map +0 -1
  601. package/dist/boards/work-tool-rules.js +0 -19
  602. package/dist/boards/work-tool-rules.js.map +0 -1
  603. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +0 -8
  604. package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +0 -1
  605. package/dist/integrations/slack/emoji-shortcodes.generated.js +0 -1984
  606. package/dist/integrations/slack/emoji-shortcodes.generated.js.map +0 -1
  607. package/dist/integrations/slack/emoji.d.ts +0 -3
  608. package/dist/integrations/slack/emoji.d.ts.map +0 -1
  609. package/dist/integrations/slack/emoji.js +0 -11
  610. package/dist/integrations/slack/emoji.js.map +0 -1
  611. package/dist/integrations/slack/feed-publisher.d.ts +0 -26
  612. package/dist/integrations/slack/feed-publisher.d.ts.map +0 -1
  613. package/dist/integrations/slack/feed-publisher.js +0 -43
  614. package/dist/integrations/slack/feed-publisher.js.map +0 -1
  615. package/dist/routes/attention-activity.d.ts +0 -23
  616. package/dist/routes/attention-activity.d.ts.map +0 -1
  617. package/dist/routes/attention-activity.js +0 -154
  618. package/dist/routes/attention-activity.js.map +0 -1
  619. package/dist/rules/resolve.d.ts +0 -15
  620. package/dist/rules/resolve.d.ts.map +0 -1
  621. package/dist/rules/resolve.js +0 -22
  622. package/dist/rules/resolve.js.map +0 -1
  623. package/dist/storage/domains/comments/activity.d.ts +0 -40
  624. package/dist/storage/domains/comments/activity.d.ts.map +0 -1
  625. package/dist/storage/domains/comments/activity.js +0 -93
  626. package/dist/storage/domains/comments/activity.js.map +0 -1
  627. package/dist/storage/domains/comments/actor.d.ts +0 -51
  628. package/dist/storage/domains/comments/actor.d.ts.map +0 -1
  629. package/dist/storage/domains/comments/actor.js +0 -37
  630. package/dist/storage/domains/comments/actor.js.map +0 -1
  631. package/dist/storage/domains/comments/base.d.ts +0 -245
  632. package/dist/storage/domains/comments/base.d.ts.map +0 -1
  633. package/dist/storage/domains/comments/base.js +0 -539
  634. package/dist/storage/domains/comments/base.js.map +0 -1
  635. package/dist/storage/domains/comments/domain.d.ts +0 -135
  636. package/dist/storage/domains/comments/domain.d.ts.map +0 -1
  637. package/dist/storage/domains/comments/domain.js +0 -284
  638. package/dist/storage/domains/comments/domain.js.map +0 -1
  639. package/dist/storage/domains/comments/feed-context.d.ts +0 -22
  640. package/dist/storage/domains/comments/feed-context.d.ts.map +0 -1
  641. package/dist/storage/domains/comments/feed-context.js +0 -88
  642. package/dist/storage/domains/comments/feed-context.js.map +0 -1
  643. package/dist/storage/domains/comments/feed-sync.d.ts +0 -21
  644. package/dist/storage/domains/comments/feed-sync.d.ts.map +0 -1
  645. package/dist/storage/domains/comments/feed-sync.js +0 -1
  646. package/dist/storage/domains/comments/parse.d.ts +0 -23
  647. package/dist/storage/domains/comments/parse.d.ts.map +0 -1
  648. package/dist/storage/domains/comments/parse.js +0 -89
  649. package/dist/storage/domains/comments/parse.js.map +0 -1
  650. package/dist/storage/domains/comments/routes.d.ts +0 -24
  651. package/dist/storage/domains/comments/routes.d.ts.map +0 -1
  652. package/dist/storage/domains/comments/routes.js +0 -299
  653. package/dist/storage/domains/comments/routes.js.map +0 -1
  654. package/dist/storage/domains/comments/schema.d.ts +0 -5
  655. package/dist/storage/domains/comments/schema.d.ts.map +0 -1
  656. package/dist/storage/domains/comments/schema.js +0 -178
  657. package/dist/storage/domains/comments/schema.js.map +0 -1
  658. package/dist/storage/domains/comments/wire.d.ts +0 -40
  659. package/dist/storage/domains/comments/wire.d.ts.map +0 -1
  660. package/dist/storage/domains/comments/wire.js +0 -36
  661. package/dist/storage/domains/comments/wire.js.map +0 -1
  662. package/factory-skills/factory-complete-issue/SKILL.md +0 -24
@@ -1,6 +1,7 @@
1
1
  import { closeReason } from "../../boards/board-events.js";
2
2
  import "../../boards/index.js";
3
- import { boardEventHandlers, boardForWorkItem, eventBoardId, rulePhaseField, withBoardClosure } from "../../boards/semantics.js";
3
+ import { boardEventHandlers, boardForWorkItem, eventBoardId, rulePhaseField, withBoardClosure, withIntakeTarget } from "../../boards/semantics.js";
4
+ import { toBoardSource } from "../../boards/project-boards.js";
4
5
  import { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from "../../rules/event-rules.js";
5
6
  import { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from "../../rules/validation.js";
6
7
  // src/integrations/jira/rules.ts
@@ -32,6 +33,10 @@ var JiraRules = class {
32
33
  constructor(options) {
33
34
  this.options = options;
34
35
  }
36
+ /** The project's boards, loaded at the start of {@link ingest}. */
37
+ #boards(scope) {
38
+ return toBoardSource(this.options.boards).forProject(scope);
39
+ }
35
40
  async ingest(input) {
36
41
  if (!await this.options.projects.get({
37
42
  orgId: input.orgId,
@@ -40,6 +45,7 @@ var JiraRules = class {
40
45
  status: "missing",
41
46
  ingested: 0
42
47
  };
48
+ await toBoardSource(this.options.boards).load(input);
43
49
  await this.options.storage.copyLegacyCards({
44
50
  orgId: input.orgId,
45
51
  factoryProjectId: input.factoryProjectId,
@@ -49,13 +55,16 @@ var JiraRules = class {
49
55
  externalId: issue.id
50
56
  }))
51
57
  });
52
- const items = await this.options.storage.list({
58
+ const items = await this.options.storage.listShared({
53
59
  orgId: input.orgId,
54
60
  factoryProjectId: input.factoryProjectId
55
61
  });
56
62
  const itemsBySourceKey = new Map(items.map((item) => [item.externalSource?.externalId, item]));
57
63
  const statuses = [];
58
- for (const issue of input.issues) statuses.push(await this.#ingestIssue(input, issue, itemsBySourceKey.get(issue.id)));
64
+ for (const issue of input.issues) {
65
+ const relatedItem = itemsBySourceKey.get(issue.id);
66
+ statuses.push(await this.#ingestIssue(input, issue, relatedItem && structuredClone(relatedItem)));
67
+ }
59
68
  if (statuses.some((status) => status === "committed")) return {
60
69
  status: "committed",
61
70
  ingested: statuses.length
@@ -78,8 +87,6 @@ var JiraRules = class {
78
87
  const isClosed = issue.stateType === "completed" || issue.stateType === "canceled";
79
88
  if (isClosed && !relatedItem) return "missing";
80
89
  const event = isClosed ? "issueClosed" : "issueObserved";
81
- const boundBoardId = issue.sourceId ? input.intakeBoards?.[issue.sourceId] : void 0;
82
- const boundBoard = boundBoardId ? this.options.boards.get(boundBoardId) : void 0;
83
90
  const context = {
84
91
  tenant: {
85
92
  orgId: input.orgId,
@@ -108,20 +115,17 @@ var JiraRules = class {
108
115
  },
109
116
  board: boardForWorkItem(relatedItem),
110
117
  itemRevision: relatedItem.revision,
111
- ...withBoardClosure(this.options.boards, relatedItem),
112
- ...rulePhaseField(this.options.boards, relatedItem)
118
+ ...withBoardClosure(this.#boards(input), relatedItem),
119
+ ...rulePhaseField(this.#boards(input), relatedItem)
113
120
  } : {},
114
- ...boundBoard ? { intake: {
115
- board: boundBoard.id,
116
- initialPhase: boundBoard.initialPhase
117
- } } : {},
121
+ ...withIntakeTarget(this.#boards(input)),
118
122
  event,
119
123
  issue
120
124
  };
121
125
  const boardEvent = boardEventFor(context);
122
126
  if (boardEvent) context.boardEvent = boardEvent;
123
- const ownedByDeployment = deploymentOwnsEvent(this.options.jiraRules, boardEventHandlers(this.options.boards, eventBoardId(context), "jira"), context.event);
124
- const rule = selectEventRule(this.options.jiraRules, boardEventHandlers(this.options.boards, eventBoardId(context), "jira"), context.event);
127
+ const ownedByDeployment = deploymentOwnsEvent(this.options.jiraRules, boardEventHandlers(this.#boards(input), eventBoardId(context), "jira"), context.event);
128
+ const rule = selectEventRule(this.options.jiraRules, boardEventHandlers(this.#boards(input), eventBoardId(context), "jira"), context.event);
125
129
  let decision = void 0;
126
130
  let decisions = [];
127
131
  let outcome = { status: "accepted" };
@@ -133,7 +137,7 @@ var JiraRules = class {
133
137
  reason: decision.reason
134
138
  };
135
139
  else if (decision) decisions = validateFactoryRuleDecisions([decision]).map((entry) => {
136
- assertFactoryDecisionTarget(entry, this.options.boards, relatedItem ? boardForWorkItem(relatedItem) : void 0);
140
+ assertFactoryDecisionTarget(entry, this.#boards(input), relatedItem ? boardForWorkItem(relatedItem) : void 0);
137
141
  return { ...entry };
138
142
  });
139
143
  } catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","names":[],"sources":["../../../src/integrations/jira/rules.ts"],"sourcesContent":["import { closeReason } from '../../boards/board-events.js';\nimport type { BoardEventFacts } from '../../boards/board-events.js';\nimport {\n boardEventHandlers,\n boardForWorkItem,\n eventBoardId,\n rulePhaseField,\n withBoardClosure,\n} from '../../boards/index.js';\nimport type { BoardRegistry } from '../../boards/index.js';\nimport { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from '../../rules/event-rules.js';\nimport type { FactoryJiraRuleContext, FactoryRuleDecision } from '../../rules/types.js';\nimport { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from '../../rules/validation.js';\nimport type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';\nimport type { Card, WorkItemsStorage } from '../../storage/domains/work-items/base.js';\nimport type { IntegrationContext } from '../base.js';\nimport type { JiraEventRules } from './default-rules.js';\n\nconst RULE_TIMEOUT_MS = 5_000;\n\nasync function withRuleTimeout<T>(promise: Promise<T>): Promise<T> {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timeout = setTimeout(() => reject(new Error('FACTORY_RULE_TIMEOUT')), RULE_TIMEOUT_MS);\n }),\n ]);\n } finally {\n if (timeout) clearTimeout(timeout);\n }\n}\n\nconst MAX_STALE_RULE_ATTEMPTS = 3;\n\nexport interface JiraIssueIngress {\n /** Stable issue reference — direct Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n /** Display name of the Jira reporter, when available. */\n author: string | null;\n /** Jira project key the issue belongs to, when available. */\n project: string | null;\n /** Jira site host the issue was read from, when available. */\n site: string | null;\n labels: string[];\n createdAt: string;\n updatedAt: string;\n /** Jira source the issue was read from; resolves the bound board via `intakeBoards`. */\n sourceId?: string | null;\n}\n\nexport interface JiraRulesOptions {\n projects: Pick<FactoryProjectsStorage, 'get'>;\n storage: WorkItemsStorage;\n configVersion: string;\n boards: BoardRegistry;\n jiraRules: JiraEventRules;\n}\n\nexport interface JiraRulesIngress {\n orgId: string;\n userId: string;\n factoryProjectId: string;\n issues: JiraIssueIngress[];\n /** Board id per bound Jira source id, from the project's intake bindings. */\n intakeBoards?: Readonly<Record<string, string>>;\n}\n\ntype IngressStatus = 'committed' | 'replayed' | 'missing';\n\n/**\n * The status change a Jira sync reports: a issue seen for the first time is created, and a\n * completed or canceled one is closed for that reason. Later sightings of an open issue report none.\n */\nexport function boardEventFor(context: Pick<FactoryJiraRuleContext, 'event' | 'issue' | 'item'>): BoardEventFacts | undefined {\n if (context.event === 'issueClosed') {\n return { type: 'work_item.closed', reason: closeReason(context.issue.stateType === 'canceled') };\n }\n return context.item ? undefined : { type: 'work_item.created' };\n}\n\nexport class JiraRules {\n constructor(private readonly options: JiraRulesOptions) {}\n\n async ingest(input: JiraRulesIngress): Promise<{ status: IngressStatus; ingested: number }> {\n const project = await this.options.projects.get({ orgId: input.orgId, id: input.factoryProjectId });\n if (!project) return { status: 'missing', ingested: 0 };\n\n // A finished card may still be only in the legacy table; copy it so the issue finds it.\n await this.options.storage.copyLegacyCards({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n sources: input.issues.map(issue => ({ integrationId: 'jira', type: 'issue', externalId: issue.id })),\n });\n const items = await this.options.storage.list({ orgId: input.orgId, factoryProjectId: input.factoryProjectId });\n const itemsBySourceKey = new Map(items.map(item => [item.externalSource?.externalId, item]));\n const statuses: IngressStatus[] = [];\n for (const issue of input.issues) {\n // One card per Jira issue per project; other projects may file their own.\n statuses.push(await this.#ingestIssue(input, issue, itemsBySourceKey.get(issue.id)));\n }\n if (statuses.some(status => status === 'committed')) return { status: 'committed', ingested: statuses.length };\n if (statuses.some(status => status === 'replayed')) return { status: 'replayed', ingested: statuses.length };\n return { status: 'missing', ingested: statuses.length };\n }\n\n async #ingestIssue(\n input: JiraRulesIngress,\n issue: JiraIssueIngress,\n relatedItem: Card | undefined,\n attempt = 1,\n ): Promise<IngressStatus> {\n const ingressId = `jira:${issue.id}:${issue.updatedAt}`;\n const actor = { type: 'human' as const, id: input.userId };\n\n // Closed issues without existing work items should not create new ones.\n const isClosed = issue.stateType === 'completed' || issue.stateType === 'canceled';\n if (isClosed && !relatedItem) {\n return 'missing';\n }\n\n const event = isClosed ? 'issueClosed' : 'issueObserved';\n const boundBoardId = issue.sourceId ? input.intakeBoards?.[issue.sourceId] : undefined;\n const boundBoard = boundBoardId ? this.options.boards.get(boundBoardId) : undefined;\n const context: FactoryJiraRuleContext = {\n tenant: { orgId: input.orgId, projectId: input.factoryProjectId },\n actor,\n ingress: { type: 'jira', id: ingressId },\n cause: `jira.${event}`,\n causalChain: [],\n configVersion: this.options.configVersion,\n ...(relatedItem\n ? {\n item: {\n id: relatedItem.id,\n source: 'jira-issue',\n sourceKey: relatedItem.externalSource?.externalId ?? null,\n parentWorkItemId: relatedItem.parentWorkItemId,\n title: relatedItem.title,\n url: relatedItem.externalSource?.url ?? null,\n stages: relatedItem.stages,\n workItem: relatedItem.workItem,\n acceptedAt: relatedItem.acceptedAt,\n metadata: relatedItem.metadata,\n },\n board: boardForWorkItem(relatedItem),\n itemRevision: relatedItem.revision,\n ...withBoardClosure(this.options.boards, relatedItem),\n ...rulePhaseField(this.options.boards, relatedItem),\n }\n : {}),\n ...(boundBoard ? { intake: { board: boundBoard.id, initialPhase: boundBoard.initialPhase } } : {}),\n event,\n issue,\n };\n const boardEvent = boardEventFor(context);\n if (boardEvent) context.boardEvent = boardEvent;\n\n const ownedByDeployment = deploymentOwnsEvent(\n this.options.jiraRules,\n boardEventHandlers(this.options.boards, eventBoardId(context), 'jira'),\n context.event,\n );\n const rule = selectEventRule(\n this.options.jiraRules,\n boardEventHandlers(this.options.boards, eventBoardId(context), 'jira'),\n context.event,\n );\n let decision: FactoryRuleDecision | void = undefined;\n let decisions: Record<string, unknown>[] = [];\n let outcome: { status: 'accepted' | 'rejected'; code?: string; reason?: string } = { status: 'accepted' };\n try {\n decision = rule ? await withRuleTimeout(Promise.resolve(rule(Object.freeze(context)))) : undefined;\n if (decision?.type === 'reject') {\n outcome = { status: 'rejected', code: decision.code, reason: decision.reason };\n } else if (decision) {\n decisions = validateFactoryRuleDecisions([decision]).map(entry => {\n assertFactoryDecisionTarget(\n entry,\n this.options.boards,\n relatedItem ? boardForWorkItem(relatedItem) : undefined,\n );\n return { ...entry };\n });\n }\n } catch (error) {\n const timedOut = error instanceof Error && error.message === 'FACTORY_RULE_TIMEOUT';\n outcome = {\n status: 'rejected',\n code: timedOut ? 'timeout' : 'rule_error',\n reason: timedOut\n ? 'Factory rule evaluation timed out.'\n : error instanceof Error\n ? error.message.slice(0, 2_000)\n : 'Factory Jira rule failed.',\n };\n }\n if (ownedByDeployment) decisions = decisions.map(withoutRouteEvent);\n if (!decision && !ownedByDeployment && outcome.status === 'accepted') {\n const routed = await routeEventDecision(context, this.options.storage, {\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n });\n if (routed) decisions = [{ ...routed }];\n }\n\n const committed = await this.options.storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: relatedItem?.id ?? null,\n ingress: { identity: ingressId, triggerType: 'jira.issueObserved' },\n configVersion: this.options.configVersion,\n expectedRevision: relatedItem?.revision ?? null,\n actor,\n outcome,\n decisions,\n causalChain: [],\n now: new Date(),\n });\n if (committed.status === 'stale') {\n // Nothing was persisted: re-read the item and evaluate again at its fresh revision.\n if (attempt >= MAX_STALE_RULE_ATTEMPTS) {\n throw new Error(`Factory Jira rule evaluation for ${ingressId} kept losing revision races.`);\n }\n const fresh = relatedItem ? await this.options.storage.get({ orgId: input.orgId, id: relatedItem.id }) : null;\n if (relatedItem && !fresh) return 'missing';\n return this.#ingestIssue(input, issue, fresh ?? undefined, attempt + 1);\n }\n return committed.status;\n }\n}\n\nexport function attachJiraRules(\n jira: { readonly rules: JiraEventRules },\n context: IntegrationContext,\n): ((input: JiraRulesIngress) => Promise<unknown>) | undefined {\n if (!context.runtime) return undefined;\n const rules = new JiraRules({\n projects: context.storage.projects,\n storage: context.runtime.workItems,\n configVersion: context.runtime.configVersion,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IAAI,CAAC,YAAY,CAAC,qBAAqB,QAAQ,WAAW,YAAY;GACpE,MAAM,SAAS,MAAM,mBAAmB,SAAS,KAAK,QAAQ,SAAS;IACrE,OAAO,MAAM;IACb,kBAAkB,MAAM;GAC1B,CAAC;GACD,IAAI,QAAQ,YAAY,CAAC,EAAE,GAAG,OAAO,CAAC;EACxC;EAEA,MAAM,YAAY,MAAM,KAAK,QAAQ,QAAQ,qBAAqB;GAChE,OAAO,MAAM;GACb,kBAAkB,MAAM;GACxB,YAAY,aAAa,MAAM;GAC/B,SAAS;IAAE,UAAU;IAAW,aAAa;GAAqB;GAClE,eAAe,KAAK,QAAQ;GAC5B,kBAAkB,aAAa,YAAY;GAC3C;GACA;GACA;GACA,aAAa,CAAC;GACd,qBAAK,IAAI,KAAK;EAChB,CAAC;EACD,IAAI,UAAU,WAAW,SAAS;GAEhC,IAAI,WAAW,yBACb,MAAM,IAAI,MAAM,oCAAoC,UAAU,6BAA6B;GAE7F,MAAM,QAAQ,cAAc,MAAM,KAAK,QAAQ,QAAQ,IAAI;IAAE,OAAO,MAAM;IAAO,IAAI,YAAY;GAAG,CAAC,IAAI;GACzG,IAAI,eAAe,CAAC,OAAO,OAAO;GAClC,OAAO,KAAK,aAAa,OAAO,OAAO,SAAS,KAAA,GAAW,UAAU,CAAC;EACxE;EACA,OAAO,UAAU;CACnB;AACF;AAEA,SAAgB,gBACd,MACA,SAC6D;CAC7D,IAAI,CAAC,QAAQ,SAAS,OAAO,KAAA;CAC7B,MAAM,QAAQ,IAAI,UAAU;EAC1B,UAAU,QAAQ,QAAQ;EAC1B,SAAS,QAAQ,QAAQ;EACzB,eAAe,QAAQ,QAAQ;EAC/B,QAAQ,QAAQ,QAAQ;EACxB,WAAW,KAAK;CAClB,CAAC;CACD,QAAO,UAAS,MAAM,OAAO,KAAK;AACpC"}
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../../../src/integrations/jira/rules.ts"],"sourcesContent":["import { closeReason } from '../../boards/board-events.js';\nimport type { BoardEventFacts } from '../../boards/board-events.js';\nimport {\n boardEventHandlers,\n boardForWorkItem,\n eventBoardId,\n rulePhaseField,\n withBoardClosure,\n withIntakeTarget,\n} from '../../boards/index.js';\nimport type { BoardRegistry } from '../../boards/index.js';\nimport { toBoardSource } from '../../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../../boards/project-boards.js';\nimport { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from '../../rules/event-rules.js';\nimport type { FactoryJiraRuleContext, FactoryRuleDecision } from '../../rules/types.js';\nimport { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from '../../rules/validation.js';\nimport type { StoredBoardScope } from '../../storage/domains/boards/base.js';\nimport type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';\nimport type { Card, WorkItemsStorage } from '../../storage/domains/work-items/base.js';\nimport type { IntegrationContext } from '../base.js';\nimport type { JiraEventRules } from './default-rules.js';\n\nconst RULE_TIMEOUT_MS = 5_000;\n\nasync function withRuleTimeout<T>(promise: Promise<T>): Promise<T> {\n let timeout: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timeout = setTimeout(() => reject(new Error('FACTORY_RULE_TIMEOUT')), RULE_TIMEOUT_MS);\n }),\n ]);\n } finally {\n if (timeout) clearTimeout(timeout);\n }\n}\n\nconst MAX_STALE_RULE_ATTEMPTS = 3;\n\nexport interface JiraIssueIngress {\n /** Stable issue reference — direct Jira id or the Platform-encoded issue reference. */\n id: string;\n identifier: string;\n title: string;\n url: string;\n state: string;\n stateType: string;\n priorityLabel: string;\n assignee: string | null;\n /** Display name of the Jira reporter, when available. */\n author: string | null;\n /** Jira project key the issue belongs to, when available. */\n project: string | null;\n /** Jira site host the issue was read from, when available. */\n site: string | null;\n labels: string[];\n createdAt: string;\n updatedAt: string;\n /** Jira source the issue was read from. */\n sourceId?: string | null;\n}\n\nexport interface JiraRulesOptions {\n projects: Pick<FactoryProjectsStorage, 'get'>;\n storage: WorkItemsStorage;\n configVersion: string;\n /** The code boards, or the per-project source so a project's stored boards run its cards. */\n boards: BoardRegistry | ProjectBoardSource;\n jiraRules: JiraEventRules;\n}\n\nexport interface JiraRulesIngress {\n orgId: string;\n userId: string;\n factoryProjectId: string;\n issues: JiraIssueIngress[];\n}\n\ntype IngressStatus = 'committed' | 'replayed' | 'missing';\n\n/**\n * The status change a Jira sync reports: a issue seen for the first time is created, and a\n * completed or canceled one is closed for that reason. Later sightings of an open issue report none.\n */\nexport function boardEventFor(context: Pick<FactoryJiraRuleContext, 'event' | 'issue' | 'item'>): BoardEventFacts | undefined {\n if (context.event === 'issueClosed') {\n return { type: 'work_item.closed', reason: closeReason(context.issue.stateType === 'canceled') };\n }\n return context.item ? undefined : { type: 'work_item.created' };\n}\n\nexport class JiraRules {\n constructor(private readonly options: JiraRulesOptions) {}\n\n /** The project's boards, loaded at the start of {@link ingest}. */\n #boards(scope: StoredBoardScope): BoardRegistry {\n return toBoardSource(this.options.boards).forProject(scope);\n }\n\n async ingest(input: JiraRulesIngress): Promise<{ status: IngressStatus; ingested: number }> {\n const project = await this.options.projects.get({ orgId: input.orgId, id: input.factoryProjectId });\n if (!project) return { status: 'missing', ingested: 0 };\n await toBoardSource(this.options.boards).load(input);\n\n // A finished card may still be only in the legacy table; copy it so the issue finds it.\n await this.options.storage.copyLegacyCards({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n sources: input.issues.map(issue => ({ integrationId: 'jira', type: 'issue', externalId: issue.id })),\n });\n // The shared list is the cache itself: only the card handed on to rules is cloned.\n const items = await this.options.storage.listShared({ orgId: input.orgId, factoryProjectId: input.factoryProjectId });\n const itemsBySourceKey = new Map(items.map(item => [item.externalSource?.externalId, item]));\n const statuses: IngressStatus[] = [];\n for (const issue of input.issues) {\n // One card per Jira issue per project; other projects may file their own.\n const relatedItem = itemsBySourceKey.get(issue.id);\n statuses.push(await this.#ingestIssue(input, issue, relatedItem && structuredClone(relatedItem)));\n }\n if (statuses.some(status => status === 'committed')) return { status: 'committed', ingested: statuses.length };\n if (statuses.some(status => status === 'replayed')) return { status: 'replayed', ingested: statuses.length };\n return { status: 'missing', ingested: statuses.length };\n }\n\n async #ingestIssue(\n input: JiraRulesIngress,\n issue: JiraIssueIngress,\n relatedItem: Card | undefined,\n attempt = 1,\n ): Promise<IngressStatus> {\n const ingressId = `jira:${issue.id}:${issue.updatedAt}`;\n const actor = { type: 'human' as const, id: input.userId };\n\n // Closed issues without existing work items should not create new ones.\n const isClosed = issue.stateType === 'completed' || issue.stateType === 'canceled';\n if (isClosed && !relatedItem) {\n return 'missing';\n }\n\n const event = isClosed ? 'issueClosed' : 'issueObserved';\n const context: FactoryJiraRuleContext = {\n tenant: { orgId: input.orgId, projectId: input.factoryProjectId },\n actor,\n ingress: { type: 'jira', id: ingressId },\n cause: `jira.${event}`,\n causalChain: [],\n configVersion: this.options.configVersion,\n ...(relatedItem\n ? {\n item: {\n id: relatedItem.id,\n source: 'jira-issue',\n sourceKey: relatedItem.externalSource?.externalId ?? null,\n parentWorkItemId: relatedItem.parentWorkItemId,\n title: relatedItem.title,\n url: relatedItem.externalSource?.url ?? null,\n stages: relatedItem.stages,\n workItem: relatedItem.workItem,\n acceptedAt: relatedItem.acceptedAt,\n metadata: relatedItem.metadata,\n },\n board: boardForWorkItem(relatedItem),\n itemRevision: relatedItem.revision,\n ...withBoardClosure(this.#boards(input), relatedItem),\n ...rulePhaseField(this.#boards(input), relatedItem),\n }\n : {}),\n ...withIntakeTarget(this.#boards(input)),\n event,\n issue,\n };\n const boardEvent = boardEventFor(context);\n if (boardEvent) context.boardEvent = boardEvent;\n\n const ownedByDeployment = deploymentOwnsEvent(\n this.options.jiraRules,\n boardEventHandlers(this.#boards(input), eventBoardId(context), 'jira'),\n context.event,\n );\n const rule = selectEventRule(\n this.options.jiraRules,\n boardEventHandlers(this.#boards(input), eventBoardId(context), 'jira'),\n context.event,\n );\n let decision: FactoryRuleDecision | void = undefined;\n let decisions: Record<string, unknown>[] = [];\n let outcome: { status: 'accepted' | 'rejected'; code?: string; reason?: string } = { status: 'accepted' };\n try {\n decision = rule ? await withRuleTimeout(Promise.resolve(rule(Object.freeze(context)))) : undefined;\n if (decision?.type === 'reject') {\n outcome = { status: 'rejected', code: decision.code, reason: decision.reason };\n } else if (decision) {\n decisions = validateFactoryRuleDecisions([decision]).map(entry => {\n assertFactoryDecisionTarget(\n entry,\n this.#boards(input),\n relatedItem ? boardForWorkItem(relatedItem) : undefined,\n );\n return { ...entry };\n });\n }\n } catch (error) {\n const timedOut = error instanceof Error && error.message === 'FACTORY_RULE_TIMEOUT';\n outcome = {\n status: 'rejected',\n code: timedOut ? 'timeout' : 'rule_error',\n reason: timedOut\n ? 'Factory rule evaluation timed out.'\n : error instanceof Error\n ? error.message.slice(0, 2_000)\n : 'Factory Jira rule failed.',\n };\n }\n if (ownedByDeployment) decisions = decisions.map(withoutRouteEvent);\n if (!decision && !ownedByDeployment && outcome.status === 'accepted') {\n const routed = await routeEventDecision(context, this.options.storage, {\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n });\n if (routed) decisions = [{ ...routed }];\n }\n\n const committed = await this.options.storage.commitRuleEvaluation({\n orgId: input.orgId,\n factoryProjectId: input.factoryProjectId,\n workItemId: relatedItem?.id ?? null,\n ingress: { identity: ingressId, triggerType: 'jira.issueObserved' },\n configVersion: this.options.configVersion,\n expectedRevision: relatedItem?.revision ?? null,\n actor,\n outcome,\n decisions,\n causalChain: [],\n now: new Date(),\n });\n if (committed.status === 'stale') {\n // Nothing was persisted: re-read the item and evaluate again at its fresh revision.\n if (attempt >= MAX_STALE_RULE_ATTEMPTS) {\n throw new Error(`Factory Jira rule evaluation for ${ingressId} kept losing revision races.`);\n }\n const fresh = relatedItem ? await this.options.storage.get({ orgId: input.orgId, id: relatedItem.id }) : null;\n if (relatedItem && !fresh) return 'missing';\n return this.#ingestIssue(input, issue, fresh ?? undefined, attempt + 1);\n }\n return committed.status;\n }\n}\n\nexport function attachJiraRules(\n jira: { readonly rules: JiraEventRules },\n context: IntegrationContext,\n): ((input: JiraRulesIngress) => Promise<unknown>) | undefined {\n if (!context.runtime) return undefined;\n const rules = new JiraRules({\n projects: context.storage.projects,\n storage: context.runtime.workItems,\n configVersion: context.runtime.configVersion,\n boards: context.runtime.boards,\n jiraRules: jira.rules,\n });\n return input => rules.ingest(input);\n}\n"],"mappings":";;;;;;;AAsBA,MAAM,kBAAkB;AAExB,eAAe,gBAAmB,SAAiC;CACjE,IAAI;CACJ,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CACxB,SACA,IAAI,SAAgB,GAAG,WAAW;GAChC,UAAU,iBAAiB,uBAAO,IAAI,MAAM,sBAAsB,CAAC,GAAG,eAAe;EACvF,CAAC,CACH,CAAC;CACH,UAAU;EACR,IAAI,SAAS,aAAa,OAAO;CACnC;AACF;AAEA,MAAM,0BAA0B;;;;;AA+ChC,SAAgB,cAAc,SAAgG;CAC5H,IAAI,QAAQ,UAAU,eACpB,OAAO;EAAE,MAAM;EAAoB,QAAQ,YAAY,QAAQ,MAAM,cAAc,UAAU;CAAE;CAEjG,OAAO,QAAQ,OAAO,KAAA,IAAY,EAAE,MAAM,oBAAoB;AAChE;AAEA,IAAa,YAAb,MAAuB;CACQ;CAA7B,YAAY,SAA4C;EAA3B,KAAA,UAAA;CAA4B;;CAGzD,QAAQ,OAAwC;EAC9C,OAAO,cAAc,KAAK,QAAQ,MAAM,CAAC,CAAC,WAAW,KAAK;CAC5D;CAEA,MAAM,OAAO,OAA+E;EAE1F,IAAI,CAAC,MADiB,KAAK,QAAQ,SAAS,IAAI;GAAE,OAAO,MAAM;GAAO,IAAI,MAAM;EAAiB,CAAC,GACpF,OAAO;GAAE,QAAQ;GAAW,UAAU;EAAE;EACtD,MAAM,cAAc,KAAK,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK;EAGnD,MAAM,KAAK,QAAQ,QAAQ,gBAAgB;GACzC,OAAO,MAAM;GACb,kBAAkB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QAAQ,QAAQ;EACzB,eAAe,QAAQ,QAAQ;EAC/B,QAAQ,QAAQ,QAAQ;EACxB,WAAW,KAAK;CAClB,CAAC;CACD,QAAO,UAAS,MAAM,OAAO,KAAK;AACpC"}
@@ -21,6 +21,14 @@ declare function createLinearCommentTool(linear: LinearIntegration, orgId: strin
21
21
  issue: string;
22
22
  body: string;
23
23
  }, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "linear_create_comment", unknown>;
24
+ declare function createLinearListProjectsTool(linear: LinearIntegration, orgId: string): import("@mastra/core/tools").Tool<{
25
+ query?: string | undefined;
26
+ }, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "linear_list_projects", unknown>;
27
+ declare function createLinearListIssuesTool(linear: LinearIntegration, orgId: string): import("@mastra/core/tools").Tool<{
28
+ source: string;
29
+ labels?: string[] | undefined;
30
+ cursor?: string | undefined;
31
+ }, unknown, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "linear_list_issues", unknown>;
24
32
  /**
25
33
  * Async `extraTools` provider: expose Linear tools only when the session's
26
34
  * project belongs to an org with an active Linear connection.
@@ -29,6 +37,6 @@ export declare function buildLinearAgentTools({ requestContext, linear, }: {
29
37
  requestContext: RequestContext;
30
38
  /** The integration instance providing the Linear API client. */
31
39
  linear: LinearIntegration;
32
- }): Promise<Record<string, ReturnType<typeof createLinearGetIssueTool> | ReturnType<typeof createLinearCommentTool>>>;
40
+ }): Promise<Record<string, ReturnType<typeof createLinearGetIssueTool> | ReturnType<typeof createLinearCommentTool> | ReturnType<typeof createLinearListProjectsTool> | ReturnType<typeof createLinearListIssuesTool>>>;
33
41
  export {};
34
42
  //# sourceMappingURL=agent-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../../src/integrations/linear/agent-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;A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AsB,qBAAqB,CAAC,EAC1C,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,gEAAgE;IAChE,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,OAAO,CACT,MAAM,CACJ,MAAM,EACJ,UAAU,CAAC,OAAO,wBAAwB,CAAC,GAC3C,UAAU,CAAC,OAAO,uBAAuB,CAAC,GAC1C,UAAU,CAAC,OAAO,4BAA4B,CAAC,GAC/C,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAChD,CACF,CA2BA"}
@@ -1,9 +1,9 @@
1
1
  import { LinearReauthRequiredError } from "./integration.js";
2
- import { z } from "zod";
3
2
  import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
4
  // src/integrations/linear/agent-tools.ts
5
5
  function createLinearGetIssueTool(linear, orgId, workspaceUrlKey) {
6
- const linkHint = workspaceUrlKey ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).` : "";
6
+ const linkHint = workspaceUrlKey ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).` : " To link an issue, use the `url` field of the fetched issue.";
7
7
  return createTool({
8
8
  id: "linear_get_issue",
9
9
  description: `Fetch a Linear issue's full details — title, description, state, assignee, labels, priority, and discussion comments. Use this whenever you're working on a Linear issue (e.g. ENG-123) to get its complete context.${linkHint}`,
@@ -35,7 +35,7 @@ function createLinearCommentTool(linear, orgId) {
35
35
  description: "Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.",
36
36
  inputSchema: z.object({
37
37
  issue: z.string().min(1).describe("The Linear issue identifier (e.g. \"ENG-123\") or issue UUID."),
38
- body: z.string().min(1).describe("The comment body, as Linear-flavored markdown.")
38
+ body: z.string().min(1).describe("The comment body, as Linear-flavored markdown. Linear does not render HTML (no <details>, <summary> or <!-- comments -->); for a collapsible section, open it with a \"+++ Section title\" line and close it with a lone \"+++\" line.")
39
39
  }),
40
40
  execute: async ({ issue, body }) => {
41
41
  const connection = await linear.loadConnection(orgId);
@@ -63,6 +63,82 @@ function createLinearCommentTool(linear, orgId) {
63
63
  }
64
64
  });
65
65
  }
66
+ function createLinearListProjectsTool(linear, orgId) {
67
+ return createTool({
68
+ id: "linear_list_projects",
69
+ description: "List the Linear projects and teams in the connected workspace, with the source id linear_list_issues needs. Use this to find a project (e.g. from a linear.app/<workspace>/project/<name-slug>-<id> URL, by matching its name; drop the trailing id from the slug) before listing its issues.",
70
+ inputSchema: z.object({ query: z.string().optional().describe("Case-insensitive text to match against project and team names.") }),
71
+ execute: async ({ query }) => {
72
+ if (!await linear.loadConnection(orgId)) return { error: "Linear is not connected for this repository. Connect Linear in Settings to list projects." };
73
+ try {
74
+ const sources = await linear.intake.listSources({
75
+ orgId,
76
+ userId: ""
77
+ });
78
+ const normalize = (text) => text.toLowerCase().replace(/[\s-]+/g, " ").trim();
79
+ const needle = normalize(query ?? "");
80
+ const matches = needle ? sources.filter((source) => normalize(source.name).includes(needle)) : sources;
81
+ return {
82
+ projects: matches.filter((source) => source.type === "project").map((source) => ({
83
+ sourceId: source.id,
84
+ name: source.name
85
+ })),
86
+ teams: matches.filter((source) => source.type === "team").map((source) => ({
87
+ sourceId: source.id,
88
+ name: source.name,
89
+ key: source.metadata?.teamKey ?? null
90
+ }))
91
+ };
92
+ } catch (err) {
93
+ if (err instanceof LinearReauthRequiredError) return { error: err.message };
94
+ return { error: `Failed to list Linear projects: ${err instanceof Error ? err.message : String(err)}` };
95
+ }
96
+ }
97
+ });
98
+ }
99
+ function createLinearListIssuesTool(linear, orgId) {
100
+ return createTool({
101
+ id: "linear_list_issues",
102
+ description: "List the open issues (triage, backlog, todo and in progress; completed and canceled are left out) in one Linear project or team, most recently updated first. Get the source id from linear_list_projects, and read an issue in full with linear_get_issue. Pass nextCursor back as cursor for the next page.",
103
+ inputSchema: z.object({
104
+ source: z.string().min(1).describe("The project or team source id returned by linear_list_projects."),
105
+ labels: z.array(z.string().trim().min(1)).optional().describe("Only return issues carrying one of these label names."),
106
+ cursor: z.string().optional().describe("The nextCursor from a previous call, to fetch the next page.")
107
+ }),
108
+ execute: async ({ source, labels, cursor }) => {
109
+ const connection = await linear.loadConnection(orgId);
110
+ if (!connection) return { error: "Linear is not connected for this repository. Connect Linear in Settings to list issues." };
111
+ try {
112
+ const accessToken = await linear.getFreshAccessToken(connection);
113
+ const page = await linear.intake.listIssues({
114
+ connection: {
115
+ type: "oauth",
116
+ accessToken
117
+ },
118
+ sourceIds: [source.trim()],
119
+ ...labels?.length ? { labels } : {},
120
+ ...cursor ? { cursor } : {}
121
+ });
122
+ return {
123
+ issues: page.issues.map((issue) => ({
124
+ identifier: issue.identifier,
125
+ title: issue.title,
126
+ url: issue.url,
127
+ state: issue.state,
128
+ priority: issue.priority,
129
+ assignee: issue.assignee,
130
+ labels: issue.labels,
131
+ updatedAt: issue.updatedAt
132
+ })),
133
+ nextCursor: page.nextCursor
134
+ };
135
+ } catch (err) {
136
+ if (err instanceof LinearReauthRequiredError) return { error: err.message };
137
+ return { error: `Failed to list Linear issues: ${err instanceof Error ? err.message : String(err)}` };
138
+ }
139
+ }
140
+ });
141
+ }
66
142
  /**
67
143
  * Async `extraTools` provider: expose Linear tools only when the session's
68
144
  * project belongs to an org with an active Linear connection.
@@ -79,6 +155,8 @@ async function buildLinearAgentTools({ requestContext, linear }) {
79
155
  if (!check.connected) return {};
80
156
  return {
81
157
  linear_get_issue: createLinearGetIssueTool(linear, orgId, check.workspaceUrlKey),
158
+ linear_list_projects: createLinearListProjectsTool(linear, orgId),
159
+ linear_list_issues: createLinearListIssuesTool(linear, orgId),
82
160
  ...check.canComment ? { linear_create_comment: createLinearCommentTool(linear, orgId) } : {}
83
161
  };
84
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.js","names":[],"sources":["../../../src/integrations/linear/agent-tools.ts"],"sourcesContent":["/**\n * Linear tools exposed to the coding agent.\n *\n * Wired into the agent through the SDK's async `extraTools` provider: on each\n * tool-set resolution we map the session's factory project to its owning org\n * and only expose the Linear tools when that org has a Linear connection.\n * Projects whose org never connected Linear (or when the\n * feature is disabled) see no Linear tools at all — the model is never shown\n * tools it can't use.\n *\n * Tenancy mirrors the Linear API routes: everything is scoped by the org that\n * owns the project, and tokens are refreshed through the integration's shared\n * connection lifecycle.\n */\n\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { LinearIntegration } from './integration.js';\nimport { LinearReauthRequiredError } from './integration.js';\n\nfunction createLinearGetIssueTool(linear: LinearIntegration, orgId: string, workspaceUrlKey: string | null) {\n // The URL pattern lets the agent link a ticket it mentions without fetching it first.\n const linkHint = workspaceUrlKey\n ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).`\n : '';\n return createTool({\n id: 'linear_get_issue',\n description: `Fetch a Linear issue's full details — title, description, state, assignee, labels, priority, and discussion comments. Use this whenever you're working on a Linear issue (e.g. ENG-123) to get its complete context.${linkHint}`,\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n }),\n execute: async ({ issue }: { issue: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to fetch issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const detail = await linear.intake.getIssue({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n });\n if (!detail) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return detail;\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to fetch Linear issue: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearCommentTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_create_comment',\n description:\n 'Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.',\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n body: z.string().min(1).describe('The comment body, as Linear-flavored markdown.'),\n }),\n execute: async ({ issue, body }: { issue: string; body: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to post comments.' };\n }\n if (!linear.canPostComments(connection)) {\n return {\n error: 'The Linear connection does not have comment permissions. Reconnect Linear in Settings to grant them.',\n };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const comment = await linear.intake.createComment({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n body,\n });\n if (!comment) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return { posted: true, url: comment.url };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to post Linear comment: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\n/**\n * Async `extraTools` provider: expose Linear tools only when the session's\n * project belongs to an org with an active Linear connection.\n */\nexport async function buildLinearAgentTools({\n requestContext,\n linear,\n}: {\n requestContext: RequestContext;\n /** The integration instance providing the Linear API client. */\n linear: LinearIntegration;\n}): Promise<Record<string, ReturnType<typeof createLinearGetIssueTool> | ReturnType<typeof createLinearCommentTool>>> {\n if (!linear.authEnabled) return {};\n\n const ctx = requestContext.get('controller') as\n AgentControllerRequestContext<{ factoryProjectId?: string }> | undefined;\n if (!ctx) return {};\n\n // Prefer the Factory recorded on the session. Factory sessions run under the\n // Factory as their resource, so the resource is the fallback; a legacy\n // session whose resource is its own id resolves to no project.\n const projectId = ctx.getState().factoryProjectId ?? ctx.resourceId;\n if (!projectId) return {};\n\n const orgId = await linear.resolveOrgId(projectId);\n if (!orgId) return {};\n const check = await linear.checkConnection(orgId);\n if (!check.connected) return {};\n\n return {\n linear_get_issue: createLinearGetIssueTool(linear, orgId, check.workspaceUrlKey),\n // Only offered when the granted OAuth scope allows posting comments —\n // connections made before `comments:create` was requested are read-only\n // until the org reconnects Linear.\n ...(check.canComment ? { linear_create_comment: createLinearCommentTool(linear, orgId) } : {}),\n };\n}\n"],"mappings":";;;;AAuBA,SAAS,yBAAyB,QAA2B,OAAe,iBAAgC;CAE1G,MAAM,WAAW,kBACb,wDAAwD,gBAAgB,+CAA+C,gBAAgB,oBACvI;CACJ,OAAO,WAAW;EAChB,IAAI;EACJ,aAAa,uNAAuN;EACpO,aAAa,EAAE,OAAO,EACpB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,+DAA6D,EACjG,CAAC;EACD,SAAS,OAAO,EAAE,YAA+B;GAC/C,MAAM,aAAa,MAAM,OAAO,eAAe,KAAK;GACpD,IAAI,CAAC,YACH,OAAO,EAAE,OAAO,2FAA2F;GAE7G,IAAI;IACF,MAAM,cAAc,MAAM,OAAO,oBAAoB,UAAU;IAC/D,MAAM,SAAS,MAAM,OAAO,OAAO,SAAS;KAC1C,YAAY;MAAE,MAAM;MAAS;KAAY;KACzC,SAAS,MAAM,KAAK;IACtB,CAAC;IACD,IAAI,CAAC,QACH,OAAO,EAAE,OAAO,iBAAiB,MAAM,oCAAoC;IAE7E,OAAO;GACT,SAAS,KAAK;IACZ,IAAI,eAAe,2BACjB,OAAO,EAAE,OAAO,IAAI,QAAQ;IAE9B,OAAO,EAAE,OAAO,iCAAiC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,IAAI;GACtG;EACF;CACF,CAAC;AACH;AAEA,SAAS,wBAAwB,QAA2B,OAAe;CACzE,OAAO,WAAW;EAChB,IAAI;EACJ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B,KAAK;CAChD,IAAI,CAAC,MAAM,WAAW,OAAO,CAAC;CAE9B,OAAO;EACL,kBAAkB,yBAAyB,QAAQ,OAAO,MAAM,eAAe;EAI/E,GAAI,MAAM,aAAa,EAAE,uBAAuB,wBAAwB,QAAQ,KAAK,EAAE,IAAI,CAAC;CAC9F;AACF"}
1
+ {"version":3,"file":"agent-tools.js","names":[],"sources":["../../../src/integrations/linear/agent-tools.ts"],"sourcesContent":["/**\n * Linear tools exposed to the coding agent.\n *\n * Wired into the agent through the SDK's async `extraTools` provider: on each\n * tool-set resolution we map the session's factory project to its owning org\n * and only expose the Linear tools when that org has a Linear connection.\n * Projects whose org never connected Linear (or when the\n * feature is disabled) see no Linear tools at all — the model is never shown\n * tools it can't use.\n *\n * Tenancy mirrors the Linear API routes: everything is scoped by the org that\n * owns the project, and tokens are refreshed through the integration's shared\n * connection lifecycle.\n */\n\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport type { LinearIntegration } from './integration.js';\nimport { LinearReauthRequiredError } from './integration.js';\n\nfunction createLinearGetIssueTool(linear: LinearIntegration, orgId: string, workspaceUrlKey: string | null) {\n // The URL pattern lets the agent link a ticket it mentions without fetching it first.\n const linkHint = workspaceUrlKey\n ? ` Issues in this workspace link as https://linear.app/${workspaceUrlKey}/issue/<identifier> (e.g. https://linear.app/${workspaceUrlKey}/issue/ENG-123).`\n : ' To link an issue, use the `url` field of the fetched issue.';\n return createTool({\n id: 'linear_get_issue',\n description: `Fetch a Linear issue's full details — title, description, state, assignee, labels, priority, and discussion comments. Use this whenever you're working on a Linear issue (e.g. ENG-123) to get its complete context.${linkHint}`,\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n }),\n execute: async ({ issue }: { issue: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to fetch issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const detail = await linear.intake.getIssue({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n });\n if (!detail) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return detail;\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to fetch Linear issue: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearCommentTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_create_comment',\n description:\n 'Post a comment on a Linear issue (e.g. to report investigation findings, link a PR, or ask a clarifying question). The comment is posted as the connected Linear integration, so make clear it comes from the agent.',\n inputSchema: z.object({\n issue: z.string().min(1).describe('The Linear issue identifier (e.g. \"ENG-123\") or issue UUID.'),\n body: z.string().min(1).describe(\n 'The comment body, as Linear-flavored markdown. Linear does not render HTML (no <details>, <summary> or <!-- comments -->); for a collapsible section, open it with a \"+++ Section title\" line and close it with a lone \"+++\" line.',\n ),\n }),\n execute: async ({ issue, body }: { issue: string; body: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to post comments.' };\n }\n if (!linear.canPostComments(connection)) {\n return {\n error: 'The Linear connection does not have comment permissions. Reconnect Linear in Settings to grant them.',\n };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const comment = await linear.intake.createComment({\n connection: { type: 'oauth', accessToken },\n issueId: issue.trim(),\n body,\n });\n if (!comment) {\n return { error: `Linear issue \"${issue}\" was not found in this workspace.` };\n }\n return { posted: true, url: comment.url };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to post Linear comment: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListProjectsTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_projects',\n description:\n 'List the Linear projects and teams in the connected workspace, with the source id linear_list_issues needs. Use this to find a project (e.g. from a linear.app/<workspace>/project/<name-slug>-<id> URL, by matching its name; drop the trailing id from the slug) before listing its issues.',\n inputSchema: z.object({\n query: z.string().optional().describe('Case-insensitive text to match against project and team names.'),\n }),\n execute: async ({ query }: { query?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list projects.' };\n }\n try {\n // Linear sources are scoped by org alone; no Linear implementation reads userId.\n const sources = await linear.intake.listSources({ orgId, userId: '' });\n // Fold hyphens into spaces so a URL slug like \"agent-browser\" matches \"Agent Browser\".\n const normalize = (text: string) =>\n text\n .toLowerCase()\n .replace(/[\\s-]+/g, ' ')\n .trim();\n const needle = normalize(query ?? '');\n const matches = needle ? sources.filter(source => normalize(source.name).includes(needle)) : sources;\n return {\n projects: matches\n .filter(source => source.type === 'project')\n .map(source => ({ sourceId: source.id, name: source.name })),\n teams: matches\n .filter(source => source.type === 'team')\n .map(source => ({ sourceId: source.id, name: source.name, key: source.metadata?.teamKey ?? null })),\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear projects: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\nfunction createLinearListIssuesTool(linear: LinearIntegration, orgId: string) {\n return createTool({\n id: 'linear_list_issues',\n description:\n 'List the open issues (triage, backlog, todo and in progress; completed and canceled are left out) in one Linear project or team, most recently updated first. Get the source id from linear_list_projects, and read an issue in full with linear_get_issue. Pass nextCursor back as cursor for the next page.',\n inputSchema: z.object({\n source: z.string().min(1).describe('The project or team source id returned by linear_list_projects.'),\n labels: z.array(z.string().trim().min(1)).optional().describe('Only return issues carrying one of these label names.'),\n cursor: z.string().optional().describe('The nextCursor from a previous call, to fetch the next page.'),\n }),\n execute: async ({ source, labels, cursor }: { source: string; labels?: string[]; cursor?: string }) => {\n const connection = await linear.loadConnection(orgId);\n if (!connection) {\n return { error: 'Linear is not connected for this repository. Connect Linear in Settings to list issues.' };\n }\n try {\n const accessToken = await linear.getFreshAccessToken(connection);\n const page = await linear.intake.listIssues({\n connection: { type: 'oauth', accessToken },\n sourceIds: [source.trim()],\n ...(labels?.length ? { labels } : {}),\n ...(cursor ? { cursor } : {}),\n });\n return {\n issues: page.issues.map(issue => ({\n identifier: issue.identifier,\n title: issue.title,\n url: issue.url,\n state: issue.state,\n priority: issue.priority,\n assignee: issue.assignee,\n labels: issue.labels,\n updatedAt: issue.updatedAt,\n })),\n nextCursor: page.nextCursor,\n };\n } catch (err) {\n if (err instanceof LinearReauthRequiredError) {\n return { error: err.message };\n }\n return { error: `Failed to list Linear issues: ${err instanceof Error ? err.message : String(err)}` };\n }\n },\n });\n}\n\n/**\n * Async `extraTools` provider: expose Linear tools only when the session's\n * project belongs to an org with an active Linear connection.\n */\nexport async function buildLinearAgentTools({\n requestContext,\n linear,\n}: {\n requestContext: RequestContext;\n /** The integration instance providing the Linear API client. */\n linear: LinearIntegration;\n}): Promise<\n Record<\n string,\n | ReturnType<typeof createLinearGetIssueTool>\n | ReturnType<typeof createLinearCommentTool>\n | ReturnType<typeof createLinearListProjectsTool>\n | ReturnType<typeof createLinearListIssuesTool>\n >\n> {\n if (!linear.authEnabled) return {};\n\n const ctx = requestContext.get('controller') as\n AgentControllerRequestContext<{ factoryProjectId?: string }> | undefined;\n if (!ctx) return {};\n\n // Prefer the Factory recorded on the session. Factory sessions run under the\n // Factory as their resource, so the resource is the fallback; a legacy\n // session whose resource is its own id resolves to no project.\n const projectId = ctx.getState().factoryProjectId ?? ctx.resourceId;\n if (!projectId) return {};\n\n const orgId = await linear.resolveOrgId(projectId);\n if (!orgId) return {};\n const check = await linear.checkConnection(orgId);\n if (!check.connected) return {};\n\n return {\n linear_get_issue: createLinearGetIssueTool(linear, orgId, check.workspaceUrlKey),\n linear_list_projects: createLinearListProjectsTool(linear, orgId),\n linear_list_issues: createLinearListIssuesTool(linear, orgId),\n // Only offered when the granted OAuth scope allows posting comments —\n // connections made before `comments:create` was requested are read-only\n // until the org reconnects Linear.\n ...(check.canComment ? { linear_create_comment: createLinearCommentTool(linear, orgId) } : {}),\n };\n}\n"],"mappings":";;;;AAuBA,SAAS,yBAAyB,QAA2B,OAAe,iBAAgC;CAE1G,MAAM,WAAW,kBACb,wDAAwD,gBAAgB,+CAA+C,gBAAgB,oBACvI;CACJ,OAAO,WAAW;EAChB,IAAI;EACJ,aAAa,uNAAuN;EACpO,aAAa,EAAE,OAAO,EACpB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,+DAA6D,EACjG,CAAC;EACD,SAAS,OAAO,EAAE,YAA+B;GAC/C,MAAM,aAAa,MAAM,OAAO,eAAe,KAAK;GACpD,IAAI,CAAC,YACH,OAAO,EAAE,OAAO,2FAA2F;GAE7G,IAAI;IACF,MAAM,cAAc,MAAM,OAAO,oBAAoB,UAAU;IAC/D,MAAM,SAAS,MAAM,OAAO,OAAO,SAAS;KAC1C,YAAY;MAAE,MAAM;MAAS;KAAY;KACzC,SAAS,MAAM,KAAK;IACtB,CAAC;IACD,IAAI,CAAC,QACH,OAAO,EAAE,OAAO,iBAAiB,MAAM,oCAAoC;IAE7E,OAAO;GACT,SAAS,KAAK;IACZ,IAAI,eAAe,2BACjB,OAAO,EAAE,OAAO,IAAI,QAAQ;IAE9B,OAAO,EAAE,OAAO,iCAAiC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,IAAI;GACtG;EACF;CACF,CAAC;AACH;AAEA,SAAS,wBAAwB,QAA2B,OAAe;CACzE,OAAO,WAAW;EAChB,IAAI;EACJ,aACE;EACF,aAAa,EAAE,OAAO;GACpB,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,+DAA6D;GAC/F,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SACpB,wOACF;EACJ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AAS,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,wEAoB3D;AAED,eAAO,MAAM,kBAAkB;;;EAGF,CAAC;AAE9B,wBAAgB,kBAAkB,CAAC,SAAS,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,CAsBpF"}
@@ -1,16 +1,16 @@
1
1
  import { closedByRoutes, recordExplicitRuleOverrides } from "../../rules/event-rules.js";
2
2
  // src/integrations/linear/default-rules.ts
3
3
  function linearIssueObserved(context) {
4
- if (context.item) return;
4
+ if (context.item || !context.intake) return;
5
5
  return {
6
6
  type: "upsertLinkedWorkItem",
7
7
  idempotencyKey: `${context.ingress.id}:issue-triage`,
8
- board: context.intake?.board ?? "work",
8
+ board: context.intake.board,
9
9
  source: "linear-issue",
10
10
  sourceKey: `linear:${context.issue.identifier}`,
11
11
  title: `${context.issue.identifier}: ${context.issue.title}`,
12
12
  url: context.issue.url,
13
- stage: context.intake?.initialPhase ?? "intake",
13
+ stage: context.intake.initialPhase,
14
14
  metadata: {
15
15
  linearIssueId: context.issue.id,
16
16
  ...context.issue.projectId ? { linearProjectId: context.issue.projectId } : {},
@@ -1 +1 @@
1
- {"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/linear/default-rules.ts"],"sourcesContent":["import { closedByRoutes, recordExplicitRuleOverrides } from '../../rules/event-rules.js';\nimport type { FactoryLinearEventName, FactoryLinearRuleContext, FactoryRuleHandler } from '../../rules/types.js';\n\nexport type LinearRuleOverrides = Partial<\n Record<FactoryLinearEventName, FactoryRuleHandler<FactoryLinearRuleContext> | null | undefined>\n>;\nexport type LinearEventRules = Readonly<\n Record<FactoryLinearEventName, FactoryRuleHandler<FactoryLinearRuleContext> | null>\n>;\n\nfunction linearIssueObserved(context: FactoryLinearRuleContext) {\n if (context.item) return;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-triage`,\n // A source bound to a custom board lands on that board's initial phase;\n // otherwise the issue waits in Work Intake.\n board: context.intake?.board ?? 'work',\n source: 'linear-issue',\n sourceKey: `linear:${context.issue.identifier}`,\n title: `${context.issue.identifier}: ${context.issue.title}`,\n url: context.issue.url,\n stage: context.intake?.initialPhase ?? 'intake',\n metadata: {\n linearIssueId: context.issue.id,\n ...(context.issue.projectId ? { linearProjectId: context.issue.projectId } : {}),\n identifier: context.issue.identifier,\n sourceCreatedAt: context.issue.createdAt,\n linearState: context.issue.state,\n linearStateType: context.issue.stateType,\n linearPriority: context.issue.priorityLabel,\n linearAssignee: context.issue.assignee,\n linearCreator: context.issue.creator,\n linearTeam: context.issue.team,\n labels: [...context.issue.labels] as string[],\n ...(context.issue.assignee ? { assignee: context.issue.assignee } : {}),\n ...(context.issue.creator ? { creator: context.issue.creator, author: context.issue.creator } : {}),\n },\n } as const;\n}\n\nfunction linearIssueClosed(context: FactoryLinearRuleContext) {\n if (!context.item || context.item.source !== 'linear-issue') return;\n // The project's intake routes decide where a closed source sends the card. The board's\n // `sourceClosed` mapping applies only when no route on the board handles closes; without\n // one the close goes to the routes alone (see `routeEventDecision`).\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n // Only terminal state types trigger close.\n const stateType = context.issue.stateType;\n if (stateType !== 'completed' && stateType !== 'canceled') return;\n const canceled = stateType === 'canceled';\n const target = canceled ? closure.canceled : closure.completed;\n return closedByRoutes(canceled, {\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: context.board,\n stage: target.phase,\n message: {\n text: `Linear issue ${context.issue.identifier} was ${canceled ? 'canceled' : 'completed'}; this ${closure.boardTitle} card was moved to ${target.title}.`,\n },\n });\n}\n\nexport const defaultLinearRules = Object.freeze({\n issueObserved: linearIssueObserved,\n issueClosed: linearIssueClosed,\n} satisfies LinearEventRules);\n\nexport function resolveLinearRules(overrides?: LinearRuleOverrides): LinearEventRules {\n if (\n overrides !== undefined &&\n (overrides === null ||\n typeof overrides !== 'object' ||\n Array.isArray(overrides) ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(overrides)))\n ) {\n throw new Error('Linear rules must be a plain object.');\n }\n const rules: Record<string, FactoryRuleHandler<FactoryLinearRuleContext> | null> = { ...defaultLinearRules };\n for (const key of Reflect.ownKeys(overrides ?? {})) {\n if (typeof key !== 'string' || !Object.hasOwn(defaultLinearRules, key)) {\n throw new Error(`Unknown Linear rule event: ${String(key)}.`);\n }\n const handler = overrides?.[key as FactoryLinearEventName];\n if (handler !== undefined && handler !== null && typeof handler !== 'function') {\n throw new Error(`Linear rule ${key} must be a function, null, or undefined.`);\n }\n if (handler !== undefined) rules[key] = handler;\n }\n return recordExplicitRuleOverrides(Object.freeze(rules) as LinearEventRules, overrides);\n}\n"],"mappings":";;AAUA,SAAS,oBAAoB,SAAmC;CAC9D,IAAI,QAAQ,MAAM;CAClB,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EAGtC,OAAO,QAAQ,QAAQ,SAAS;EAChC,QAAQ;EACR,WAAW,UAAU,QAAQ,MAAM;EACnC,OAAO,GAAG,QAAQ,MAAM,WAAW,IAAI,QAAQ,MAAM;EACrD,KAAK,QAAQ,MAAM;EACnB,OAAO,QAAQ,QAAQ,gBAAgB;EACvC,UAAU;GACR,eAAe,QAAQ,MAAM;GAC7B,GAAI,QAAQ,MAAM,YAAY,EAAE,iBAAiB,QAAQ,MAAM,UAAU,IAAI,CAAC;GAC9E,YAAY,QAAQ,MAAM;GAC1B,iBAAiB,QAAQ,MAAM;GAC/B,aAAa,QAAQ,MAAM;GAC3B,iBAAiB,QAAQ,MAAM;GAC/B,gBAAgB,QAAQ,MAAM;GAC9B,gBAAgB,QAAQ,MAAM;GAC9B,eAAe,QAAQ,MAAM;GAC7B,YAAY,QAAQ,MAAM;GAC1B,QAAQ,CAAC,GAAG,QAAQ,MAAM,MAAM;GAChC,GAAI,QAAQ,MAAM,WAAW,EAAE,UAAU,QAAQ,MAAM,SAAS,IAAI,CAAC;GACrE,GAAI,QAAQ,MAAM,UAAU;IAAE,SAAS,QAAQ,MA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e,IAAI,yCAAyC;EAE9E,IAAI,YAAY,KAAA,GAAW,MAAM,OAAO;CAC1C;CACA,OAAO,4BAA4B,OAAO,OAAO,KAAK,GAAuB,SAAS;AACxF"}
1
+ {"version":3,"file":"default-rules.js","names":[],"sources":["../../../src/integrations/linear/default-rules.ts"],"sourcesContent":["import { closedByRoutes, recordExplicitRuleOverrides } from '../../rules/event-rules.js';\nimport type { FactoryLinearEventName, FactoryLinearRuleContext, FactoryRuleHandler } from '../../rules/types.js';\n\nexport type LinearRuleOverrides = Partial<\n Record<FactoryLinearEventName, FactoryRuleHandler<FactoryLinearRuleContext> | null | undefined>\n>;\nexport type LinearEventRules = Readonly<\n Record<FactoryLinearEventName, FactoryRuleHandler<FactoryLinearRuleContext> | null>\n>;\n\nfunction linearIssueObserved(context: FactoryLinearRuleContext) {\n if (context.item || !context.intake) return;\n return {\n type: 'upsertLinkedWorkItem',\n idempotencyKey: `${context.ingress.id}:issue-triage`,\n // Filed on the default board's first phase; the project's intake routes place it from there.\n board: context.intake.board,\n source: 'linear-issue',\n sourceKey: `linear:${context.issue.identifier}`,\n title: `${context.issue.identifier}: ${context.issue.title}`,\n url: context.issue.url,\n stage: context.intake.initialPhase,\n metadata: {\n linearIssueId: context.issue.id,\n ...(context.issue.projectId ? { linearProjectId: context.issue.projectId } : {}),\n identifier: context.issue.identifier,\n sourceCreatedAt: context.issue.createdAt,\n linearState: context.issue.state,\n linearStateType: context.issue.stateType,\n linearPriority: context.issue.priorityLabel,\n linearAssignee: context.issue.assignee,\n linearCreator: context.issue.creator,\n linearTeam: context.issue.team,\n labels: [...context.issue.labels] as string[],\n ...(context.issue.assignee ? { assignee: context.issue.assignee } : {}),\n ...(context.issue.creator ? { creator: context.issue.creator, author: context.issue.creator } : {}),\n },\n } as const;\n}\n\nfunction linearIssueClosed(context: FactoryLinearRuleContext) {\n if (!context.item || context.item.source !== 'linear-issue') return;\n // The project's intake routes decide where a closed source sends the card. The board's\n // `sourceClosed` mapping applies only when no route on the board handles closes; without\n // one the close goes to the routes alone (see `routeEventDecision`).\n const closure = context.boardClosure;\n if (!context.board || !closure || closure.itemTerminal) return;\n // Only terminal state types trigger close.\n const stateType = context.issue.stateType;\n if (stateType !== 'completed' && stateType !== 'canceled') return;\n const canceled = stateType === 'canceled';\n const target = canceled ? closure.canceled : closure.completed;\n return closedByRoutes(canceled, {\n idempotencyKey: `${context.ingress.id}:issue-closed`,\n board: context.board,\n stage: target.phase,\n message: {\n text: `Linear issue ${context.issue.identifier} was ${canceled ? 'canceled' : 'completed'}; this ${closure.boardTitle} card was moved to ${target.title}.`,\n },\n });\n}\n\nexport const defaultLinearRules = Object.freeze({\n issueObserved: linearIssueObserved,\n issueClosed: linearIssueClosed,\n} satisfies LinearEventRules);\n\nexport function resolveLinearRules(overrides?: LinearRuleOverrides): LinearEventRules {\n if (\n overrides !== undefined &&\n (overrides === null ||\n typeof overrides !== 'object' ||\n Array.isArray(overrides) ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(overrides)))\n ) {\n throw new Error('Linear rules must be a plain object.');\n }\n const rules: Record<string, FactoryRuleHandler<FactoryLinearRuleContext> | null> = { ...defaultLinearRules };\n for (const key of Reflect.ownKeys(overrides ?? {})) {\n if (typeof key !== 'string' || !Object.hasOwn(defaultLinearRules, key)) {\n throw new Error(`Unknown Linear rule event: ${String(key)}.`);\n }\n const handler = overrides?.[key as FactoryLinearEventName];\n if (handler !== undefined && handler !== null && typeof handler !== 'function') {\n throw new Error(`Linear rule ${key} must be a function, null, or undefined.`);\n }\n if (handler !== undefined) rules[key] = handler;\n }\n return recordExplicitRuleOverrides(Object.freeze(rules) as LinearEventRules, overrides);\n}\n"],"mappings":";;AAUA,SAAS,oBAAoB,SAAmC;CAC9D,IAAI,QAAQ,QAAQ,CAAC,QAAQ,QAAQ;CACrC,OAAO;EACL,MAAM;EACN,gBAAgB,GAAG,QAAQ,QAAQ,GAAG;EAEtC,OAAO,QAAQ,OAAO;EACtB,QAAQ;EACR,WAAW,UA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ACF,CAAC;AACH;AAEA,MAAa,qBAAqB,OAAO,OAAO;CAC9C,eAAe;CACf,aAAa;AACf,CAA4B;AAE5B,SAAgB,mBAAmB,WAAmD;CACpF,IACE,cAAc,KAAA,MACb,cAAc,QACb,OAAO,cAAc,YACrB,MAAM,QAAQ,SAAS,KACvB,CAAC,CAAC,OAAO,WAAW,IAAI,CAAC,CAAC,SAAS,OAAO,eAAe,SAAS,CAAC,IAErE,MAAM,IAAI,MAAM,sCAAsC;CAExD,MAAM,QAA6E,EAAE,GAAG,mBAAmB;CAC3G,KAAK,MAAM,OAAO,QAAQ,QAAQ,aAAa,CAAC,CAAC,GAAG;EAClD,IAAI,OAAO,QAAQ,YAAY,CAAC,OAAO,OAAO,oBAAoB,GAAG,GACnE,MAAM,IAAI,MAAM,8BAA8B,OAAO,GAAG,EAAE,EAAE;EAE9D,MAAM,UAAU,YAAY;EAC5B,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,OAAO,YAAY,YAClE,MAAM,IAAI,MAAM,eAAe,IAAI,yCAAyC;EAE9E,IAAI,YAAY,KAAA,GAAW,MAAM,OAAO;CAC1C;CACA,OAAO,4BAA4B,OAAO,OAAO,KAAK,GAAuB,SAAS;AACxF"}
@@ -133,7 +133,10 @@ export interface LinearConnectionCheck {
133
133
  connected: boolean;
134
134
  /** Whether the granted OAuth scope allows posting issue comments. */
135
135
  canComment: boolean;
136
- /** Linear workspace slug, for `https://linear.app/<urlKey>/issue/<ID>` links. */
136
+ /**
137
+ * Linear workspace slug, for `https://linear.app/<urlKey>/issue/<ID>` links.
138
+ * Null when unknown or when several workspaces are connected.
139
+ */
137
140
  workspaceUrlKey: string | null;
138
141
  checkedAt: number;
139
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/integrations/linear/integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8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MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CA+B1D;IAED,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,OAAO,CAIpG;IAED;;;;;;;;OAQG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,MAAM,CAAC,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,eAAe,CAAC,CAgE1B;IAgCD;;;;;OAKG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA+DnC;IAED;;;;;OAKG;IACG,kBAAkB,CACtB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAyBtC;IAID,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,YAAY,EAAE,CAY/C;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE,CAY1C;IAED;;;OAGG;IACG,UAAU,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEpF;IAED,sEAAsE;IACtE,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIrC;CACF"}
1
+ {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/integrations/linear/integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,O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IZE = 50;
14
14
  const LINEAR_TEAMS_PAGE_SIZE = 100;
15
15
  const LINEAR_TEAMS_MAX_PAGES = 20;
16
+ const LINEAR_PROJECTS_PAGE_SIZE = 100;
17
+ const LINEAR_PROJECTS_MAX_PAGES = 20;
16
18
  /** Hard stop for comment pagination so a misbehaving cursor can't loop forever. */
17
19
  const ISSUE_COMMENTS_MAX_PAGES = 20;
18
20
  /** Refresh this many ms before the recorded expiry to absorb clock skew. */
@@ -506,7 +508,24 @@ var LinearIntegration = class {
506
508
  }
507
509
  /** List the workspace's projects (for the Settings intake-source picker). */
508
510
  async listProjects(accessToken) {
509
- return (await linearGraphql(accessToken, `query { projects(first: 100) { nodes { id name state teams(first: 10) { nodes { id key name } } } } }`)).projects.nodes.map((node) => ({
511
+ const projects = [];
512
+ let after;
513
+ for (let page = 0; page < LINEAR_PROJECTS_MAX_PAGES; page += 1) {
514
+ const data = await linearGraphql(accessToken, `query Projects($first: Int!, $after: String) {
515
+ projects(first: $first, after: $after) {
516
+ nodes { id name state teams(first: 10) { nodes { id key name } } }
517
+ pageInfo { hasNextPage endCursor }
518
+ }
519
+ }`, {
520
+ first: LINEAR_PROJECTS_PAGE_SIZE,
521
+ ...after ? { after } : {}
522
+ });
523
+ projects.push(...data.projects.nodes);
524
+ if (!data.projects.pageInfo.hasNextPage || !data.projects.pageInfo.endCursor) break;
525
+ if (data.projects.pageInfo.endCursor === after) throw invalidLinearCursor();
526
+ after = data.projects.pageInfo.endCursor;
527
+ }
528
+ return projects.map((node) => ({
510
529
  id: node.id,
511
530
  name: node.name,
512
531
  state: node.state,
@@ -593,6 +612,7 @@ var LinearIntegration = class {
593
612
  ...teamIds?.length ? { teamIds } : {},
594
613
  ...normalizedLabels.length > 0 ? { labels: normalizedLabels } : {}
595
614
  })).issues;
615
+ if (pageInfo.hasNextPage && after && pageInfo.endCursor === after) throw invalidLinearCursor();
596
616
  return {
597
617
  issues: nodes.map((node) => ({
598
618
  id: node.id,