@agent-native/core 0.100.2 → 0.101.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +83 -0
  3. package/corpus/core/docs/content/locales/ar-SA/pr-visual-recap.mdx +48 -30
  4. package/corpus/core/docs/content/locales/ar-SA/template-plan.mdx +7 -0
  5. package/corpus/core/docs/content/locales/de-DE/pr-visual-recap.mdx +48 -30
  6. package/corpus/core/docs/content/locales/de-DE/template-plan.mdx +7 -0
  7. package/corpus/core/docs/content/locales/es-ES/pr-visual-recap.mdx +48 -30
  8. package/corpus/core/docs/content/locales/es-ES/template-plan.mdx +14 -0
  9. package/corpus/core/docs/content/locales/fr-FR/pr-visual-recap.mdx +48 -30
  10. package/corpus/core/docs/content/locales/fr-FR/template-plan.mdx +7 -0
  11. package/corpus/core/docs/content/locales/hi-IN/pr-visual-recap.mdx +48 -30
  12. package/corpus/core/docs/content/locales/hi-IN/template-plan.mdx +7 -0
  13. package/corpus/core/docs/content/locales/ja-JP/pr-visual-recap.mdx +48 -30
  14. package/corpus/core/docs/content/locales/ja-JP/template-plan.mdx +7 -0
  15. package/corpus/core/docs/content/locales/ko-KR/pr-visual-recap.mdx +48 -30
  16. package/corpus/core/docs/content/locales/ko-KR/template-plan.mdx +7 -0
  17. package/corpus/core/docs/content/locales/pt-BR/pr-visual-recap.mdx +48 -30
  18. package/corpus/core/docs/content/locales/pt-BR/template-plan.mdx +14 -0
  19. package/corpus/core/docs/content/locales/zh-CN/pr-visual-recap.mdx +48 -30
  20. package/corpus/core/docs/content/locales/zh-CN/template-plan.mdx +7 -0
  21. package/corpus/core/docs/content/locales/zh-TW/pr-visual-recap.mdx +48 -30
  22. package/corpus/core/docs/content/locales/zh-TW/template-plan.mdx +7 -0
  23. package/corpus/core/docs/content/pr-visual-recap.mdx +50 -32
  24. package/corpus/core/docs/content/template-plan.mdx +14 -0
  25. package/corpus/core/docs/content/toolkit-comments-review.mdx +16 -2
  26. package/corpus/core/package.json +4 -1
  27. package/corpus/core/src/a2a/index.ts +2 -1
  28. package/corpus/core/src/a2a/server.ts +34 -9
  29. package/corpus/core/src/agent/production-agent.ts +56 -10
  30. package/corpus/core/src/cli/create.ts +47 -19
  31. package/corpus/core/src/cli/pr-visual-recap-workflow.ts +2 -3
  32. package/corpus/core/src/cli/recap.ts +3 -4932
  33. package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +6 -4
  34. package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +7 -1
  35. package/corpus/core/src/client/AgentPanel.tsx +19 -17
  36. package/corpus/core/src/client/analytics.ts +8 -1
  37. package/corpus/core/src/client/chat/markdown-renderer.tsx +54 -8
  38. package/corpus/core/src/client/chat/message-components.tsx +8 -2
  39. package/corpus/core/src/client/clipboard.ts +28 -1
  40. package/corpus/core/src/client/guided-questions.tsx +4 -0
  41. package/corpus/core/src/client/i18n.tsx +2 -1
  42. package/corpus/core/src/client/index.ts +4 -0
  43. package/corpus/core/src/client/review/ReviewCommentComposer.tsx +108 -0
  44. package/corpus/core/src/client/review/ReviewThreadPanel.tsx +482 -150
  45. package/corpus/core/src/client/review/index.ts +8 -0
  46. package/corpus/core/src/client/review/use-review.ts +35 -1
  47. package/corpus/core/src/client/use-agent-chat-context.ts +3 -2
  48. package/corpus/core/src/credentials/index.ts +41 -8
  49. package/corpus/core/src/extensions/fetch-tool.ts +33 -3
  50. package/corpus/core/src/notifications/channels.ts +20 -6
  51. package/corpus/core/src/review/actions/create-review-comment.ts +2 -1
  52. package/corpus/core/src/review/actions/get-review-feedback.ts +6 -11
  53. package/corpus/core/src/review/actions/list-review-comments.ts +38 -4
  54. package/corpus/core/src/review/actions/reply-review-comment.ts +33 -22
  55. package/corpus/core/src/review/actions/resolve-review-thread.ts +29 -2
  56. package/corpus/core/src/review/actions/send-review-thread-to-agent.ts +62 -0
  57. package/corpus/core/src/review/identity.ts +101 -0
  58. package/corpus/core/src/review/index.ts +14 -0
  59. package/corpus/core/src/review/store.ts +315 -8
  60. package/corpus/core/src/review/types.ts +4 -0
  61. package/corpus/core/src/secrets/crypto.ts +26 -10
  62. package/corpus/core/src/secrets/storage.ts +16 -3
  63. package/corpus/core/src/server/action-discovery.ts +4 -0
  64. package/corpus/core/src/server/action-routes.ts +125 -4
  65. package/corpus/core/src/server/agent-chat/plugin-options.ts +16 -0
  66. package/corpus/core/src/server/agent-chat-plugin.ts +61 -7
  67. package/corpus/core/src/server/derived-secret.ts +5 -1
  68. package/corpus/core/src/server/index.ts +8 -0
  69. package/corpus/core/src/vite/action-types-plugin.ts +4 -0
  70. package/corpus/templates/analytics/changelog/2026-07-14-daily-dashboard-email-captures-authenticate-with-a-sessi.md +6 -0
  71. package/corpus/templates/analytics/changelog/2026-07-14-long-running-cross-app-analyses-now-continue-reliably-in-the.md +6 -0
  72. package/corpus/templates/analytics/server/lib/dashboard-report.ts +156 -3
  73. package/corpus/templates/analytics/server/plugins/agent-chat.ts +8 -4
  74. package/corpus/templates/assets/app/components/generation/GenerationResults.tsx +402 -142
  75. package/corpus/templates/assets/app/i18n/zh-TW.ts +1 -0
  76. package/corpus/templates/assets/app/i18n-data.ts +1 -0
  77. package/corpus/templates/assets/app/routes/library.tsx +187 -48
  78. package/corpus/templates/assets/changelog/2026-07-13-merged-the-candidates-panel-into-the-library-as-a-drafts-tab.md +6 -0
  79. package/corpus/templates/chat/app/lib/agent-page.tsx +40 -0
  80. package/corpus/templates/chat/app/routes/agent.tsx +5 -3
  81. package/corpus/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +6 -0
  82. package/corpus/templates/clips/.agents/skills/ai-video-tools/SKILL.md +5 -0
  83. package/corpus/templates/clips/AGENTS.md +4 -0
  84. package/corpus/templates/clips/actions/get-feature-flags.ts +30 -0
  85. package/corpus/templates/clips/actions/lib/transcript-preview.ts +48 -0
  86. package/corpus/templates/clips/actions/request-transcript.ts +41 -1
  87. package/corpus/templates/clips/actions/view-screen.ts +5 -9
  88. package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -1
  89. package/corpus/templates/clips/app/components/player/share-dialog.tsx +44 -81
  90. package/corpus/templates/clips/app/components/player/video-player.tsx +39 -1
  91. package/corpus/templates/clips/app/hooks/use-desktop-promo.ts +6 -12
  92. package/corpus/templates/clips/app/hooks/use-mse-video-source.ts +146 -0
  93. package/corpus/templates/clips/app/i18n/ar-SA.ts +0 -8
  94. package/corpus/templates/clips/app/i18n/de-DE.ts +0 -9
  95. package/corpus/templates/clips/app/i18n/en-US.ts +0 -8
  96. package/corpus/templates/clips/app/i18n/es-ES.ts +0 -9
  97. package/corpus/templates/clips/app/i18n/fr-FR.ts +0 -9
  98. package/corpus/templates/clips/app/i18n/hi-IN.ts +0 -8
  99. package/corpus/templates/clips/app/i18n/ja-JP.ts +0 -9
  100. package/corpus/templates/clips/app/i18n/ko-KR.ts +0 -9
  101. package/corpus/templates/clips/app/i18n/pt-BR.ts +0 -9
  102. package/corpus/templates/clips/app/i18n/zh-CN.ts +0 -7
  103. package/corpus/templates/clips/app/i18n/zh-TW.ts +0 -7
  104. package/corpus/templates/clips/app/lib/capture-install-options.ts +21 -0
  105. package/corpus/templates/clips/app/lib/fmp4.ts +271 -0
  106. package/corpus/templates/clips/app/lib/mse-video-loader.ts +585 -0
  107. package/corpus/templates/clips/app/routes/_app.dictate.tsx +0 -4
  108. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +5 -13
  109. package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +2 -37
  110. package/corpus/templates/clips/app/routes/download.tsx +3 -2
  111. package/corpus/templates/clips/changelog/2026-07-10-shared-clips-now-start-playing-instantly-instead-of-showing-.md +6 -0
  112. package/corpus/templates/clips/changelog/2026-07-14-clips-now-distinguishes-transcript-previews-from-incomplete-.md +6 -0
  113. package/corpus/templates/clips/changelog/2026-07-14-desktop-app-prompts-stay-hidden-after-you-download-the-insta.md +6 -0
  114. package/corpus/templates/clips/changelog/2026-07-14-share-dialogs-show-separate-links-for-people-and-agents.md +6 -0
  115. package/corpus/templates/clips/desktop/src/lib/recorder.ts +5 -0
  116. package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +10 -0
  117. package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -0
  118. package/corpus/templates/clips/desktop/src-tauri/src/native_screen/custom_capture.rs +2518 -0
  119. package/corpus/templates/clips/desktop/src-tauri/src/native_screen/live_upload.rs +353 -0
  120. package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +558 -67
  121. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +11 -1
  122. package/corpus/templates/clips/desktop/src-tauri/src/remote_flags.rs +188 -0
  123. package/corpus/templates/clips/desktop/src-tauri/src/whisper_speech.rs +1 -1
  124. package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +1 -0
  125. package/corpus/templates/clips/server/plugins/agent-chat.ts +5 -0
  126. package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +5 -1
  127. package/corpus/templates/clips/shared/feature-flags.ts +41 -0
  128. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +3 -0
  129. package/corpus/templates/design/.agents/skills/design-review-feedback/SKILL.md +42 -0
  130. package/corpus/templates/design/AGENTS.md +6 -0
  131. package/corpus/templates/design/README.md +1 -0
  132. package/corpus/templates/design/actions/navigate.ts +4 -4
  133. package/corpus/templates/design/actions/view-screen.ts +116 -2
  134. package/corpus/templates/design/agent-native.app-skill.json +5 -0
  135. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +52 -59
  136. package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +13 -9
  137. package/corpus/templates/design/app/components/design/EditPanel.tsx +79 -11
  138. package/corpus/templates/design/app/components/design/LayersPanel.tsx +78 -65
  139. package/corpus/templates/design/app/components/design/ReviewCommentsPanel.tsx +161 -0
  140. package/corpus/templates/design/app/components/design/ReviewStatusControl.tsx +96 -0
  141. package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +166 -0
  142. package/corpus/templates/design/app/components/layout/Layout.tsx +1 -0
  143. package/corpus/templates/design/app/components/visual-editor/ReviewCanvasPins.tsx +1077 -0
  144. package/corpus/templates/design/app/components/visual-editor/index.ts +1 -0
  145. package/corpus/templates/design/app/components/visual-editor/review-canvas-state.ts +42 -0
  146. package/corpus/templates/design/app/hooks/use-design-systems.ts +2 -2
  147. package/corpus/templates/design/app/hooks/use-navigation-state.ts +9 -6
  148. package/corpus/templates/design/app/hooks/use-question-flow.ts +7 -1
  149. package/corpus/templates/design/app/i18n/ar-SA.ts +56 -1
  150. package/corpus/templates/design/app/i18n/de-DE.ts +57 -1
  151. package/corpus/templates/design/app/i18n/en-US.ts +56 -1
  152. package/corpus/templates/design/app/i18n/es-ES.ts +56 -1
  153. package/corpus/templates/design/app/i18n/fr-FR.ts +57 -1
  154. package/corpus/templates/design/app/i18n/hi-IN.ts +56 -1
  155. package/corpus/templates/design/app/i18n/ja-JP.ts +56 -1
  156. package/corpus/templates/design/app/i18n/ko-KR.ts +56 -1
  157. package/corpus/templates/design/app/i18n/pt-BR.ts +57 -1
  158. package/corpus/templates/design/app/i18n/zh-CN.ts +56 -1
  159. package/corpus/templates/design/app/i18n/zh-TW.ts +51 -0
  160. package/corpus/templates/design/app/pages/Present.tsx +172 -14
  161. package/corpus/templates/design/app/pages/design-editor/overview-camera.ts +23 -0
  162. package/corpus/templates/design/app/pages/design-editor/tool-state.ts +10 -0
  163. package/corpus/templates/design/app/pages/present-review-state.ts +18 -0
  164. package/corpus/templates/design/app/public-routes.ts +8 -0
  165. package/corpus/templates/design/app/root.tsx +7 -6
  166. package/corpus/templates/design/changelog/2026-07-13-dragged-design-assets-now-appear-at-the-visible-drop-locatio.md +6 -0
  167. package/corpus/templates/design/changelog/2026-07-13-reviewers-can-pin-comments-on-shared-designs-and-apply-verif.md +6 -0
  168. package/corpus/templates/design/server/plugins/agent-chat.ts +10 -0
  169. package/corpus/templates/design/server/plugins/auth.ts +7 -5
  170. package/corpus/templates/design/server/plugins/review.ts +9 -0
  171. package/corpus/templates/design/shared/review-anchor.ts +83 -0
  172. package/corpus/templates/design/shared/review-summary.ts +25 -0
  173. package/corpus/templates/dispatch/changelog/2026-07-14-dispatch-now-distinguishes-connected-agents-from-locally-mou.md +6 -0
  174. package/corpus/templates/forms/.agents/skills/form-publishing/SKILL.md +2 -0
  175. package/corpus/templates/forms/AGENTS.md +4 -0
  176. package/corpus/templates/forms/actions/create-form.ts +2 -1
  177. package/corpus/templates/forms/actions/update-form.ts +5 -2
  178. package/corpus/templates/forms/app/i18n/ar-SA.ts +3 -0
  179. package/corpus/templates/forms/app/i18n/de-DE.ts +3 -0
  180. package/corpus/templates/forms/app/i18n/en-US.ts +3 -0
  181. package/corpus/templates/forms/app/i18n/es-ES.ts +3 -0
  182. package/corpus/templates/forms/app/i18n/fr-FR.ts +3 -0
  183. package/corpus/templates/forms/app/i18n/hi-IN.ts +3 -0
  184. package/corpus/templates/forms/app/i18n/ja-JP.ts +3 -0
  185. package/corpus/templates/forms/app/i18n/ko-KR.ts +3 -0
  186. package/corpus/templates/forms/app/i18n/pt-BR.ts +3 -0
  187. package/corpus/templates/forms/app/i18n/zh-CN.ts +3 -0
  188. package/corpus/templates/forms/app/i18n/zh-TW.ts +3 -0
  189. package/corpus/templates/forms/app/pages/FormBuilderPage.tsx +19 -0
  190. package/corpus/templates/forms/changelog/2026-07-14-fixed-the-ask-forms-loading-input-appearing-above-the-welcom.md +6 -0
  191. package/corpus/templates/forms/changelog/2026-07-14-form-social-previews-now-show-the-form-title-description-and.md +6 -0
  192. package/corpus/templates/forms/changelog/2026-07-14-forms-can-email-the-form-owner-when-new-responses-arrive.md +6 -0
  193. package/corpus/templates/forms/server/handlers/submissions.ts +17 -0
  194. package/corpus/templates/forms/server/lib/form-og-image.ts +64 -6
  195. package/corpus/templates/forms/server/lib/public-form-ssr.ts +6 -2
  196. package/corpus/templates/forms/server/lib/response-email.ts +65 -0
  197. package/corpus/templates/forms/server/plugins/agent-chat.ts +1 -0
  198. package/corpus/templates/forms/server/routes/api/forms/og/[...slug]/og.png.get.ts +184 -0
  199. package/corpus/templates/forms/shared/types.ts +2 -0
  200. package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +6 -4
  201. package/corpus/templates/plan/.agents/skills/visual-recap/SKILL.md +7 -1
  202. package/dist/a2a/index.d.ts +2 -1
  203. package/dist/a2a/index.d.ts.map +1 -1
  204. package/dist/a2a/index.js +1 -1
  205. package/dist/a2a/index.js.map +1 -1
  206. package/dist/a2a/server.d.ts +25 -0
  207. package/dist/a2a/server.d.ts.map +1 -1
  208. package/dist/a2a/server.js +30 -6
  209. package/dist/a2a/server.js.map +1 -1
  210. package/dist/agent/production-agent.d.ts +2 -0
  211. package/dist/agent/production-agent.d.ts.map +1 -1
  212. package/dist/agent/production-agent.js +37 -12
  213. package/dist/agent/production-agent.js.map +1 -1
  214. package/dist/cli/create.d.ts +5 -3
  215. package/dist/cli/create.d.ts.map +1 -1
  216. package/dist/cli/create.js +44 -19
  217. package/dist/cli/create.js.map +1 -1
  218. package/dist/cli/pr-visual-recap-workflow.d.ts +2 -2
  219. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  220. package/dist/cli/pr-visual-recap-workflow.js +2 -2
  221. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  222. package/dist/cli/recap.d.ts +3 -562
  223. package/dist/cli/recap.d.ts.map +1 -1
  224. package/dist/cli/recap.js +3 -3875
  225. package/dist/cli/recap.js.map +1 -1
  226. package/dist/cli/skills-content/visual-plan-skill.d.ts +1 -1
  227. package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -1
  228. package/dist/cli/skills-content/visual-plan-skill.js +6 -4
  229. package/dist/cli/skills-content/visual-plan-skill.js.map +1 -1
  230. package/dist/cli/skills-content/visual-recap-skill.d.ts +1 -1
  231. package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -1
  232. package/dist/cli/skills-content/visual-recap-skill.js +7 -1
  233. package/dist/cli/skills-content/visual-recap-skill.js.map +1 -1
  234. package/dist/client/AgentPanel.d.ts.map +1 -1
  235. package/dist/client/AgentPanel.js +3 -3
  236. package/dist/client/AgentPanel.js.map +1 -1
  237. package/dist/client/analytics.d.ts +5 -0
  238. package/dist/client/analytics.d.ts.map +1 -1
  239. package/dist/client/analytics.js +3 -1
  240. package/dist/client/analytics.js.map +1 -1
  241. package/dist/client/chat/markdown-renderer.d.ts +1 -0
  242. package/dist/client/chat/markdown-renderer.d.ts.map +1 -1
  243. package/dist/client/chat/markdown-renderer.js +36 -1
  244. package/dist/client/chat/markdown-renderer.js.map +1 -1
  245. package/dist/client/chat/message-components.d.ts.map +1 -1
  246. package/dist/client/chat/message-components.js +5 -2
  247. package/dist/client/chat/message-components.js.map +1 -1
  248. package/dist/client/clipboard.d.ts +3 -1
  249. package/dist/client/clipboard.d.ts.map +1 -1
  250. package/dist/client/clipboard.js +24 -1
  251. package/dist/client/clipboard.js.map +1 -1
  252. package/dist/client/guided-questions.d.ts +3 -1
  253. package/dist/client/guided-questions.d.ts.map +1 -1
  254. package/dist/client/guided-questions.js +2 -1
  255. package/dist/client/guided-questions.js.map +1 -1
  256. package/dist/client/i18n.d.ts.map +1 -1
  257. package/dist/client/i18n.js +3 -1
  258. package/dist/client/i18n.js.map +1 -1
  259. package/dist/client/index.d.ts +1 -1
  260. package/dist/client/index.d.ts.map +1 -1
  261. package/dist/client/index.js +1 -1
  262. package/dist/client/index.js.map +1 -1
  263. package/dist/client/review/ReviewCommentComposer.d.ts +18 -0
  264. package/dist/client/review/ReviewCommentComposer.d.ts.map +1 -0
  265. package/dist/client/review/ReviewCommentComposer.js +30 -0
  266. package/dist/client/review/ReviewCommentComposer.js.map +1 -0
  267. package/dist/client/review/ReviewThreadPanel.d.ts +28 -1
  268. package/dist/client/review/ReviewThreadPanel.d.ts.map +1 -1
  269. package/dist/client/review/ReviewThreadPanel.js +151 -39
  270. package/dist/client/review/ReviewThreadPanel.js.map +1 -1
  271. package/dist/client/review/index.d.ts +3 -2
  272. package/dist/client/review/index.d.ts.map +1 -1
  273. package/dist/client/review/index.js +2 -1
  274. package/dist/client/review/index.js.map +1 -1
  275. package/dist/client/review/use-review.d.ts +23 -0
  276. package/dist/client/review/use-review.d.ts.map +1 -1
  277. package/dist/client/review/use-review.js +3 -0
  278. package/dist/client/review/use-review.js.map +1 -1
  279. package/dist/client/use-agent-chat-context.d.ts +1 -1
  280. package/dist/client/use-agent-chat-context.d.ts.map +1 -1
  281. package/dist/client/use-agent-chat-context.js +4 -2
  282. package/dist/client/use-agent-chat-context.js.map +1 -1
  283. package/dist/collab/awareness.d.ts +2 -2
  284. package/dist/collab/awareness.d.ts.map +1 -1
  285. package/dist/collab/struct-routes.d.ts +1 -1
  286. package/dist/credentials/index.d.ts +12 -7
  287. package/dist/credentials/index.d.ts.map +1 -1
  288. package/dist/credentials/index.js +33 -8
  289. package/dist/credentials/index.js.map +1 -1
  290. package/dist/extensions/fetch-tool.d.ts +13 -1
  291. package/dist/extensions/fetch-tool.d.ts.map +1 -1
  292. package/dist/extensions/fetch-tool.js +9 -2
  293. package/dist/extensions/fetch-tool.js.map +1 -1
  294. package/dist/notifications/channels.js +20 -4
  295. package/dist/notifications/channels.js.map +1 -1
  296. package/dist/observability/routes.d.ts +5 -5
  297. package/dist/progress/routes.d.ts +1 -1
  298. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  299. package/dist/resources/handlers.d.ts +3 -3
  300. package/dist/review/actions/create-review-comment.js +2 -1
  301. package/dist/review/actions/create-review-comment.js.map +1 -1
  302. package/dist/review/actions/get-review-feedback.js +6 -11
  303. package/dist/review/actions/get-review-feedback.js.map +1 -1
  304. package/dist/review/actions/list-review-comments.d.ts +1 -0
  305. package/dist/review/actions/list-review-comments.js +25 -4
  306. package/dist/review/actions/list-review-comments.js.map +1 -1
  307. package/dist/review/actions/reply-review-comment.js +12 -5
  308. package/dist/review/actions/reply-review-comment.js.map +1 -1
  309. package/dist/review/actions/resolve-review-thread.d.ts +3 -0
  310. package/dist/review/actions/resolve-review-thread.js +20 -3
  311. package/dist/review/actions/resolve-review-thread.js.map +1 -1
  312. package/dist/review/actions/send-review-thread-to-agent.d.ts +17 -0
  313. package/dist/review/actions/send-review-thread-to-agent.d.ts.map +1 -0
  314. package/dist/review/actions/send-review-thread-to-agent.js +49 -0
  315. package/dist/review/actions/send-review-thread-to-agent.js.map +1 -0
  316. package/dist/review/identity.d.ts +6 -0
  317. package/dist/review/identity.d.ts.map +1 -0
  318. package/dist/review/identity.js +68 -0
  319. package/dist/review/identity.js.map +1 -0
  320. package/dist/review/index.d.ts +3 -1
  321. package/dist/review/index.d.ts.map +1 -1
  322. package/dist/review/index.js +2 -1
  323. package/dist/review/index.js.map +1 -1
  324. package/dist/review/store.d.ts +36 -0
  325. package/dist/review/store.d.ts.map +1 -1
  326. package/dist/review/store.js +223 -8
  327. package/dist/review/store.js.map +1 -1
  328. package/dist/review/types.d.ts +4 -0
  329. package/dist/review/types.d.ts.map +1 -1
  330. package/dist/review/types.js.map +1 -1
  331. package/dist/secrets/crypto.d.ts +15 -7
  332. package/dist/secrets/crypto.d.ts.map +1 -1
  333. package/dist/secrets/crypto.js +23 -10
  334. package/dist/secrets/crypto.js.map +1 -1
  335. package/dist/secrets/routes.d.ts +9 -9
  336. package/dist/secrets/storage.d.ts.map +1 -1
  337. package/dist/secrets/storage.js +16 -3
  338. package/dist/secrets/storage.js.map +1 -1
  339. package/dist/server/action-discovery.d.ts.map +1 -1
  340. package/dist/server/action-discovery.js +4 -0
  341. package/dist/server/action-discovery.js.map +1 -1
  342. package/dist/server/action-routes.d.ts +45 -0
  343. package/dist/server/action-routes.d.ts.map +1 -1
  344. package/dist/server/action-routes.js +71 -5
  345. package/dist/server/action-routes.js.map +1 -1
  346. package/dist/server/agent-chat/plugin-options.d.ts +16 -0
  347. package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
  348. package/dist/server/agent-chat/plugin-options.js.map +1 -1
  349. package/dist/server/agent-chat-plugin.d.ts +20 -0
  350. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  351. package/dist/server/agent-chat-plugin.js +39 -4
  352. package/dist/server/agent-chat-plugin.js.map +1 -1
  353. package/dist/server/derived-secret.d.ts +1 -1
  354. package/dist/server/derived-secret.d.ts.map +1 -1
  355. package/dist/server/derived-secret.js.map +1 -1
  356. package/dist/server/index.d.ts +3 -1
  357. package/dist/server/index.d.ts.map +1 -1
  358. package/dist/server/index.js +2 -0
  359. package/dist/server/index.js.map +1 -1
  360. package/dist/vite/action-types-plugin.d.ts.map +1 -1
  361. package/dist/vite/action-types-plugin.js +4 -0
  362. package/dist/vite/action-types-plugin.js.map +1 -1
  363. package/docs/content/locales/ar-SA/pr-visual-recap.mdx +48 -30
  364. package/docs/content/locales/ar-SA/template-plan.mdx +7 -0
  365. package/docs/content/locales/de-DE/pr-visual-recap.mdx +48 -30
  366. package/docs/content/locales/de-DE/template-plan.mdx +7 -0
  367. package/docs/content/locales/es-ES/pr-visual-recap.mdx +48 -30
  368. package/docs/content/locales/es-ES/template-plan.mdx +14 -0
  369. package/docs/content/locales/fr-FR/pr-visual-recap.mdx +48 -30
  370. package/docs/content/locales/fr-FR/template-plan.mdx +7 -0
  371. package/docs/content/locales/hi-IN/pr-visual-recap.mdx +48 -30
  372. package/docs/content/locales/hi-IN/template-plan.mdx +7 -0
  373. package/docs/content/locales/ja-JP/pr-visual-recap.mdx +48 -30
  374. package/docs/content/locales/ja-JP/template-plan.mdx +7 -0
  375. package/docs/content/locales/ko-KR/pr-visual-recap.mdx +48 -30
  376. package/docs/content/locales/ko-KR/template-plan.mdx +7 -0
  377. package/docs/content/locales/pt-BR/pr-visual-recap.mdx +48 -30
  378. package/docs/content/locales/pt-BR/template-plan.mdx +14 -0
  379. package/docs/content/locales/zh-CN/pr-visual-recap.mdx +48 -30
  380. package/docs/content/locales/zh-CN/template-plan.mdx +7 -0
  381. package/docs/content/locales/zh-TW/pr-visual-recap.mdx +48 -30
  382. package/docs/content/locales/zh-TW/template-plan.mdx +7 -0
  383. package/docs/content/pr-visual-recap.mdx +50 -32
  384. package/docs/content/template-plan.mdx +14 -0
  385. package/docs/content/toolkit-comments-review.mdx +16 -2
  386. package/package.json +4 -1
  387. package/corpus/templates/clips/app/components/sharing/slack-share-hint.tsx +0 -68
  388. package/corpus/templates/forms/server/routes/api/forms/og/[slug]/og.png.get.ts +0 -45
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ import { defineAction } from "../../action.js";
3
+ import { assertReviewableResourceAccess } from "../registry.js";
4
+ import { sendReviewThreadToAgent } from "../store.js";
5
+ const schema = z.object({
6
+ resourceType: z.string().min(1),
7
+ resourceId: z.string().min(1),
8
+ threadId: z.string().min(1),
9
+ });
10
+ export default defineAction({
11
+ description: "Send one open review thread to the agent queue without routing other threads.",
12
+ schema,
13
+ run: async (args, ctx) => {
14
+ const actionCtx = ctx;
15
+ const access = await assertReviewableResourceAccess(args.resourceType, args.resourceId, actionCtx, "editor");
16
+ const updatedCount = await sendReviewThreadToAgent(args.threadId, {
17
+ resourceType: args.resourceType,
18
+ resourceId: args.resourceId,
19
+ });
20
+ if (updatedCount < 1) {
21
+ throw new Error("Open review thread not found");
22
+ }
23
+ return {
24
+ resourceType: args.resourceType,
25
+ resourceId: args.resourceId,
26
+ threadId: args.threadId,
27
+ resolutionTarget: "agent",
28
+ consumedAt: null,
29
+ updatedCount,
30
+ ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,
31
+ orgId: access.orgId ?? actionCtx?.orgId ?? null,
32
+ visibility: access.visibility ?? "private",
33
+ };
34
+ },
35
+ audit: {
36
+ target: (args, result) => {
37
+ const routed = result;
38
+ return {
39
+ type: args.resourceType,
40
+ id: args.resourceId,
41
+ ownerEmail: routed.ownerEmail,
42
+ orgId: routed.orgId,
43
+ visibility: routed.visibility,
44
+ };
45
+ },
46
+ summary: (args) => `Sent review thread ${args.threadId} to the agent`,
47
+ },
48
+ });
49
+ //# sourceMappingURL=send-review-thread-to-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-review-thread-to-agent.js","sourceRoot":"","sources":["../../../src/review/actions/send-review-thread-to-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC5B,CAAC,CAAC;AAEH,eAAe,YAAY,CAAC;IAC1B,WAAW,EACT,+EAA+E;IACjF,MAAM;IACN,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,GAAwC,CAAC;QAC3D,MAAM,MAAM,GAAG,MAAM,8BAA8B,CACjD,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,UAAU,EACf,SAAS,EACT,QAAQ,CACT,CAAC;QACF,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChE,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAC;QACH,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,OAAO;YACL,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,gBAAgB,EAAE,OAAgB;YAClC,UAAU,EAAE,IAAI;YAChB,YAAY;YACZ,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,SAAS,EAAE,SAAS,IAAI,IAAI;YAC7D,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,IAAI;YAC/C,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,SAAS;SAC3C,CAAC;IACJ,CAAC;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACvB,MAAM,MAAM,GAAG,MAId,CAAC;YACF,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,YAAY;gBACvB,EAAE,EAAE,IAAI,CAAC,UAAU;gBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,IAAI,CAAC,QAAQ,eAAe;KACtE;CACF,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { assertReviewableResourceAccess } from \"../registry.js\";\nimport { sendReviewThreadToAgent } from \"../store.js\";\nimport type { ReviewResourceContext } from \"../types.js\";\n\nconst schema = z.object({\n resourceType: z.string().min(1),\n resourceId: z.string().min(1),\n threadId: z.string().min(1),\n});\n\nexport default defineAction({\n description:\n \"Send one open review thread to the agent queue without routing other threads.\",\n schema,\n run: async (args, ctx) => {\n const actionCtx = ctx as ReviewResourceContext | undefined;\n const access = await assertReviewableResourceAccess(\n args.resourceType,\n args.resourceId,\n actionCtx,\n \"editor\",\n );\n const updatedCount = await sendReviewThreadToAgent(args.threadId, {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n });\n if (updatedCount < 1) {\n throw new Error(\"Open review thread not found\");\n }\n return {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n threadId: args.threadId,\n resolutionTarget: \"agent\" as const,\n consumedAt: null,\n updatedCount,\n ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,\n orgId: access.orgId ?? actionCtx?.orgId ?? null,\n visibility: access.visibility ?? \"private\",\n };\n },\n audit: {\n target: (args, result) => {\n const routed = result as {\n ownerEmail?: string | null;\n orgId?: string | null;\n visibility?: \"private\" | \"org\" | \"public\";\n };\n return {\n type: args.resourceType,\n id: args.resourceId,\n ownerEmail: routed.ownerEmail,\n orgId: routed.orgId,\n visibility: routed.visibility,\n };\n },\n summary: (args) => `Sent review thread ${args.threadId} to the agent`,\n },\n});\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ReviewComment, ReviewResourceAccess, ReviewResourceContext, ReviewStatusEntry } from "./types.js";
2
+ export declare function reviewAuthorNameFromContext(ctx: ReviewResourceContext | undefined): string | null;
3
+ export declare function shouldRedactReviewIdentity(ctx: ReviewResourceContext | undefined, access: Pick<ReviewResourceAccess, "role" | "visibility">): boolean;
4
+ export declare function redactPublicReviewCommentIdentity(comment: ReviewComment): ReviewComment;
5
+ export declare function redactPublicReviewStatusIdentity(status: ReviewStatusEntry | null): ReviewStatusEntry | null;
6
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/review/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,qBAAqB,GAAG,SAAS,GACrC,MAAM,GAAG,IAAI,CAMf;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,qBAAqB,GAAG,SAAS,EACtC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,YAAY,CAAC,GACxD,OAAO,CAKT;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,aAAa,GACrB,aAAa,CAcf;AAED,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAC/B,iBAAiB,GAAG,IAAI,CAU1B"}
@@ -0,0 +1,68 @@
1
+ export function reviewAuthorNameFromContext(ctx) {
2
+ const value = ctx?.userName;
3
+ if (typeof value !== "string")
4
+ return null;
5
+ const name = value.trim();
6
+ if (!name || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(name))
7
+ return null;
8
+ return name;
9
+ }
10
+ export function shouldRedactReviewIdentity(ctx, access) {
11
+ return (!ctx?.userEmail ||
12
+ (access.visibility === "public" && access.role === "viewer"));
13
+ }
14
+ export function redactPublicReviewCommentIdentity(comment) {
15
+ return {
16
+ ...comment,
17
+ authorEmail: null,
18
+ authorName: safeReviewDisplayName(comment.authorName),
19
+ mentions: comment.mentions.map((mention) => ({
20
+ label: safeReviewDisplayName(mention.label) ?? "Mentioned user",
21
+ })),
22
+ ownerEmail: null,
23
+ orgId: null,
24
+ resolvedBy: null,
25
+ deletedBy: null,
26
+ metadata: redactPublicReviewMetadata(comment.metadata),
27
+ };
28
+ }
29
+ export function redactPublicReviewStatusIdentity(status) {
30
+ return status
31
+ ? {
32
+ ...status,
33
+ updatedBy: null,
34
+ ownerEmail: null,
35
+ orgId: null,
36
+ metadata: redactPublicReviewMetadata(status.metadata),
37
+ }
38
+ : null;
39
+ }
40
+ function safeReviewDisplayName(value) {
41
+ const name = value?.trim();
42
+ if (!name || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(name)) {
43
+ return null;
44
+ }
45
+ return name;
46
+ }
47
+ function redactPublicReviewMetadata(metadata) {
48
+ if (!metadata) {
49
+ return null;
50
+ }
51
+ return Object.fromEntries(Object.entries(metadata).flatMap(([key, value]) => /^(authorEmail|ownerEmail|orgId|updatedBy|resolvedBy|deletedBy|email|userEmail|userId)$/i.test(key)
52
+ ? []
53
+ : [[key, redactPublicReviewMetadataValue(value)]]));
54
+ }
55
+ function redactPublicReviewMetadataValue(value) {
56
+ if (Array.isArray(value)) {
57
+ return value.map(redactPublicReviewMetadataValue);
58
+ }
59
+ if (typeof value === "object" && value !== null) {
60
+ return redactPublicReviewMetadata(value);
61
+ }
62
+ if (typeof value === "string" &&
63
+ /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim())) {
64
+ return null;
65
+ }
66
+ return value;
67
+ }
68
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/review/identity.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,2BAA2B,CACzC,GAAsC;IAEtC,MAAM,KAAK,GAAG,GAAG,EAAE,QAAQ,CAAC;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,IAAI,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,GAAsC,EACtC,MAAyD;IAEzD,OAAO,CACL,CAAC,GAAG,EAAE,SAAS;QACf,CAAC,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAC7D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,OAAsB;IAEtB,OAAO;QACL,GAAG,OAAO;QACV,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC;QACrD,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,C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AAED,SAAS,+BAA+B,CAAC,KAAc;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,0BAA0B,CAAC,KAAgC,CAAC,CAAC;IACtE,CAAC;IACD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAC/C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type {\n ReviewComment,\n ReviewResourceAccess,\n ReviewResourceContext,\n ReviewStatusEntry,\n} from \"./types.js\";\n\nexport function reviewAuthorNameFromContext(\n ctx: ReviewResourceContext | undefined,\n): string | null {\n const value = ctx?.userName;\n if (typeof value !== \"string\") return null;\n const name = value.trim();\n if (!name || /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(name)) return null;\n return name;\n}\n\nexport function shouldRedactReviewIdentity(\n ctx: ReviewResourceContext | undefined,\n access: Pick<ReviewResourceAccess, \"role\" | \"visibility\">,\n): boolean {\n return (\n !ctx?.userEmail ||\n (access.visibility === \"public\" && access.role === \"viewer\")\n );\n}\n\nexport function redactPublicReviewCommentIdentity(\n comment: ReviewComment,\n): ReviewComment {\n return {\n ...comment,\n authorEmail: null,\n authorName: safeReviewDisplayName(comment.authorName),\n mentions: comment.mentions.map((mention) => ({\n label: safeReviewDisplayName(mention.label) ?? \"Mentioned user\",\n })),\n ownerEmail: null,\n orgId: null,\n resolvedBy: null,\n deletedBy: null,\n metadata: redactPublicReviewMetadata(comment.metadata),\n };\n}\n\nexport function redactPublicReviewStatusIdentity(\n status: ReviewStatusEntry | null,\n): ReviewStatusEntry | null {\n return status\n ? {\n ...status,\n updatedBy: null,\n ownerEmail: null,\n orgId: null,\n metadata: redactPublicReviewMetadata(status.metadata),\n }\n : null;\n}\n\nfunction safeReviewDisplayName(\n value: string | null | undefined,\n): string | null {\n const name = value?.trim();\n if (!name || /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(name)) {\n return null;\n }\n return name;\n}\n\nfunction redactPublicReviewMetadata(\n metadata: Record<string, unknown> | null,\n): Record<string, unknown> | null {\n if (!metadata) {\n return null;\n }\n return Object.fromEntries(\n Object.entries(metadata).flatMap(([key, value]) =>\n /^(authorEmail|ownerEmail|orgId|updatedBy|resolvedBy|deletedBy|email|userEmail|userId)$/i.test(\n key,\n )\n ? []\n : [[key, redactPublicReviewMetadataValue(value)]],\n ),\n );\n}\n\nfunction redactPublicReviewMetadataValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(redactPublicReviewMetadataValue);\n }\n if (typeof value === \"object\" && value !== null) {\n return redactPublicReviewMetadata(value as Record<string, unknown>);\n }\n if (\n typeof value === \"string\" &&\n /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value.trim())\n ) {\n return null;\n }\n return value;\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  export type { ReviewActorKind, ReviewComment, ReviewCommentKind, ReviewCommentStatus, ReviewMention, ReviewResolutionTarget, ReviewResourceAccess, ReviewResourceContext, ReviewResourceRole, ReviewScope, ReviewStatus, ReviewStatusEntry, ReviewableResourceRegistration, } from "./types.js";
2
+ export { redactPublicReviewCommentIdentity, redactPublicReviewStatusIdentity, reviewAuthorNameFromContext, shouldRedactReviewIdentity, } from "./identity.js";
2
3
  export { extractReviewMentions, normalizeReviewMentions } from "./mentions.js";
3
4
  export { __resetReviewableResourcesForTests, assertReviewableResourceAccess, getReviewableResource, listReviewableResources, registerReviewableResource, resolveReviewableResourceAccess, } from "./registry.js";
4
- export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, queryReviewComments, } from "./store.js";
5
+ export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, getReviewThreadSummary, getReviewThreadRoot, queryReviewComments, routeReviewThread, sendReviewThreadToAgent, } from "./store.js";
6
+ export type { GetReviewThreadSummaryInput, ReviewThreadSummary, } from "./store.js";
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/review/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kCAAkC,EAClC,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/review/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kCAAkC,EAClC,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
@@ -1,4 +1,5 @@
1
+ export { redactPublicReviewCommentIdentity, redactPublicReviewStatusIdentity, reviewAuthorNameFromContext, shouldRedactReviewIdentity, } from "./identity.js";
1
2
  export { extractReviewMentions, normalizeReviewMentions } from "./mentions.js";
2
3
  export { __resetReviewableResourcesForTests, assertReviewableResourceAccess, getReviewableResource, listReviewableResources, registerReviewableResource, resolveReviewableResourceAccess, } from "./registry.js";
3
- export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, queryReviewComments, } from "./store.js";
4
+ export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, getReviewThreadSummary, getReviewThreadRoot, queryReviewComments, routeReviewThread, sendReviewThreadToAgent, } from "./store.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/review/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kCAAkC,EAClC,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,GACpB,MAAM,YAAY,CAAC","sourcesContent":["export type {\n ReviewActorKind,\n ReviewComment,\n ReviewCommentKind,\n ReviewCommentStatus,\n ReviewMention,\n ReviewResolutionTarget,\n ReviewResourceAccess,\n ReviewResourceContext,\n ReviewResourceRole,\n ReviewScope,\n ReviewStatus,\n ReviewStatusEntry,\n ReviewableResourceRegistration,\n} from \"./types.js\";\nexport { extractReviewMentions, normalizeReviewMentions } from \"./mentions.js\";\nexport {\n __resetReviewableResourcesForTests,\n assertReviewableResourceAccess,\n getReviewableResource,\n listReviewableResources,\n registerReviewableResource,\n resolveReviewableResourceAccess,\n} from \"./registry.js\";\nexport {\n __resetReviewInitForTests,\n ensureReviewTables,\n getReviewCommentById,\n getReviewStatus,\n queryReviewComments,\n} from \"./store.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/review/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EACL,kCAAkC,EAClC,8BAA8B,EAC9B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,YAAY,CAAC","sourcesContent":["export type {\n ReviewActorKind,\n ReviewComment,\n ReviewCommentKind,\n ReviewCommentStatus,\n ReviewMention,\n ReviewResolutionTarget,\n ReviewResourceAccess,\n ReviewResourceContext,\n ReviewResourceRole,\n ReviewScope,\n ReviewStatus,\n ReviewStatusEntry,\n ReviewableResourceRegistration,\n} from \"./types.js\";\nexport {\n redactPublicReviewCommentIdentity,\n redactPublicReviewStatusIdentity,\n reviewAuthorNameFromContext,\n shouldRedactReviewIdentity,\n} from \"./identity.js\";\nexport { extractReviewMentions, normalizeReviewMentions } from \"./mentions.js\";\nexport {\n __resetReviewableResourcesForTests,\n assertReviewableResourceAccess,\n getReviewableResource,\n listReviewableResources,\n registerReviewableResource,\n resolveReviewableResourceAccess,\n} from \"./registry.js\";\nexport {\n __resetReviewInitForTests,\n ensureReviewTables,\n getReviewCommentById,\n getReviewStatus,\n getReviewThreadSummary,\n getReviewThreadRoot,\n queryReviewComments,\n routeReviewThread,\n sendReviewThreadToAgent,\n} from \"./store.js\";\nexport type {\n GetReviewThreadSummaryInput,\n ReviewThreadSummary,\n} from \"./store.js\";\n"]}
@@ -27,8 +27,22 @@ export interface QueryReviewCommentsInput {
27
27
  includeResolved?: boolean;
28
28
  includeDeleted?: boolean;
29
29
  targetId?: string | null;
30
+ rootOnly?: boolean;
31
+ resolutionTargets?: readonly (ReviewResolutionTarget | null)[];
32
+ unconsumedOnly?: boolean;
30
33
  limit?: number;
31
34
  }
35
+ export interface GetReviewThreadSummaryInput {
36
+ resourceType: string;
37
+ resourceId: string;
38
+ scope: ReviewScope;
39
+ bypassScope?: boolean;
40
+ targetId?: string | null;
41
+ }
42
+ export interface ReviewThreadSummary {
43
+ openCount: number;
44
+ agentQueueCount: number;
45
+ }
32
46
  export interface UpsertReviewStatusInput {
33
47
  resourceType: string;
34
48
  resourceId: string;
@@ -42,13 +56,35 @@ export interface UpsertReviewStatusInput {
42
56
  }
43
57
  export declare function ensureReviewTables(): Promise<void>;
44
58
  export declare function insertReviewComment(input: InsertReviewCommentInput): Promise<ReviewComment>;
59
+ export declare function insertReviewReply(input: InsertReviewCommentInput & {
60
+ threadId: string;
61
+ parentCommentId: string;
62
+ }, routeTarget: ReviewResolutionTarget | null, resource: {
63
+ resourceType: string;
64
+ resourceId: string;
65
+ }): Promise<ReviewComment>;
45
66
  export declare function queryReviewComments(input: QueryReviewCommentsInput): Promise<ReviewComment[]>;
67
+ export declare function getReviewThreadSummary(input: GetReviewThreadSummaryInput): Promise<ReviewThreadSummary>;
46
68
  export declare function getReviewCommentById(id: string, scope: ReviewScope, options?: {
47
69
  bypassScope?: boolean;
48
70
  }): Promise<ReviewComment | null>;
71
+ export declare function getReviewThreadRoot(threadId: string, resource: {
72
+ resourceType: string;
73
+ resourceId: string;
74
+ }, scope: ReviewScope, options?: {
75
+ bypassScope?: boolean;
76
+ }): Promise<ReviewComment | null>;
49
77
  export declare function resolveReviewThread(threadId: string, resolvedBy?: string | null, resource?: {
50
78
  resourceType: string;
51
79
  resourceId: string;
80
+ }, resolutionNote?: string): Promise<number>;
81
+ export declare function routeReviewThread(threadId: string, resolutionTarget: ReviewResolutionTarget, resource: {
82
+ resourceType: string;
83
+ resourceId: string;
84
+ }): Promise<number>;
85
+ export declare function sendReviewThreadToAgent(threadId: string, resource: {
86
+ resourceType: string;
87
+ resourceId: string;
52
88
  }): Promise<number>;
53
89
  export declare function deleteReviewComment(id: string, deletedBy?: string | null): Promise<number>;
54
90
  export declare function consumeReviewFeedback(ids: string[], consumedAt?: string, resource?: {
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/review/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EAEjB,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,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AAC,CAYjB;AAgED,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,sBAAsB,EACxC,QAAQ,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACrD,OAAO,CAAC,MAAM,CAAC,CAQjB;AAgCD,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACrD,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EAAE,EACb,UAAU,SAA2B,EACrC,QAAQ,CAAC,EAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACtD,OAAO,CAAC,MAAM,CAAC,CAsBjB;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAkF5B;AAED,wBAAsB,eAAe,CACnC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAenC;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
@@ -55,6 +55,15 @@ export async function ensureReviewTables() {
55
55
  ON agent_review_comments (owner_email, created_at)`,
56
56
  `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_org
57
57
  ON agent_review_comments (org_id, created_at)`,
58
+ `CREATE INDEX IF NOT EXISTS idx_agent_review_comments_queue
59
+ ON agent_review_comments (
60
+ resource_type,
61
+ resource_id,
62
+ parent_comment_id,
63
+ resolution_target,
64
+ consumed_at,
65
+ created_at
66
+ )`,
58
67
  `CREATE INDEX IF NOT EXISTS idx_agent_review_statuses_resource
59
68
  ON agent_review_statuses (resource_type, resource_id)`,
60
69
  ];
@@ -65,7 +74,8 @@ export async function ensureReviewTables() {
65
74
  await ensureIndexExists("idx_agent_review_comments_thread", indexes[1]);
66
75
  await ensureIndexExists("idx_agent_review_comments_owner", indexes[2]);
67
76
  await ensureIndexExists("idx_agent_review_comments_org", indexes[3]);
68
- await ensureIndexExists("idx_agent_review_statuses_resource", indexes[4]);
77
+ await ensureIndexExists("idx_agent_review_comments_queue", indexes[4]);
78
+ await ensureIndexExists("idx_agent_review_statuses_resource", indexes[5]);
69
79
  }
70
80
  else {
71
81
  await client.execute(createCommentsSql);
@@ -79,8 +89,42 @@ export async function ensureReviewTables() {
79
89
  await reviewTablesInitPromise;
80
90
  }
81
91
  export async function insertReviewComment(input) {
92
+ await ensureReviewTables();
93
+ return insertReviewCommentWithClient(input, getDbExec());
94
+ }
95
+ export async function insertReviewReply(input, routeTarget, resource) {
82
96
  await ensureReviewTables();
83
97
  const client = getDbExec();
98
+ const insertAndRoute = async (tx) => {
99
+ if (routeTarget) {
100
+ const routedCount = await routeReviewThreadWithClient(tx, input.threadId, routeTarget, resource);
101
+ if (routedCount < 1) {
102
+ throw new Error("Open review thread not found");
103
+ }
104
+ }
105
+ return insertReviewCommentWithClient(input, tx);
106
+ };
107
+ if (client.transaction)
108
+ return client.transaction(insertAndRoute);
109
+ const reply = await insertReviewCommentWithClient(input, client);
110
+ if (!routeTarget)
111
+ return reply;
112
+ try {
113
+ const routedCount = await routeReviewThreadWithClient(client, input.threadId, routeTarget, resource);
114
+ if (routedCount < 1)
115
+ throw new Error("Open review thread not found");
116
+ return reply;
117
+ }
118
+ catch (error) {
119
+ await client.execute({
120
+ sql: `DELETE FROM agent_review_comments
121
+ WHERE id = ? AND resource_type = ? AND resource_id = ?`,
122
+ args: [reply.id, resource.resourceType, resource.resourceId],
123
+ });
124
+ throw error;
125
+ }
126
+ }
127
+ async function insertReviewCommentWithClient(input, client) {
84
128
  const id = createReviewId("comment");
85
129
  const now = new Date().toISOString();
86
130
  const comment = {
@@ -112,6 +156,9 @@ export async function insertReviewComment(input) {
112
156
  createdAt: now,
113
157
  updatedAt: now,
114
158
  metadata: input.metadata ?? null,
159
+ resolutionNote: typeof input.metadata?.resolutionNote === "string"
160
+ ? input.metadata.resolutionNote
161
+ : null,
115
162
  };
116
163
  await client.execute({
117
164
  sql: `INSERT INTO agent_review_comments (
@@ -201,16 +248,93 @@ export async function queryReviewComments(input) {
201
248
  filterParams.push(input.targetId);
202
249
  }
203
250
  }
251
+ if (input.rootOnly) {
252
+ filters.push("parent_comment_id IS NULL");
253
+ }
254
+ if (input.unconsumedOnly) {
255
+ filters.push("consumed_at IS NULL");
256
+ }
257
+ if (input.resolutionTargets !== undefined) {
258
+ const targets = Array.from(new Set(input.resolutionTargets.filter((target) => target !== null)));
259
+ const resolutionFilters = [];
260
+ if (targets.length > 0) {
261
+ resolutionFilters.push(`resolution_target IN (${targets.map(() => "?").join(", ")})`);
262
+ filterParams.push(...targets);
263
+ }
264
+ if (input.resolutionTargets.includes(null)) {
265
+ resolutionFilters.push("resolution_target IS NULL");
266
+ }
267
+ filters.push(resolutionFilters.length > 0
268
+ ? `(${resolutionFilters.join(" OR ")})`
269
+ : "1 = 0");
270
+ }
271
+ const selectSql = input.rootOnly
272
+ ? `SELECT ${commentColumns()}
273
+ FROM (
274
+ SELECT ${commentColumns()},
275
+ ROW_NUMBER() OVER (
276
+ PARTITION BY thread_id
277
+ ORDER BY created_at ASC, id ASC
278
+ ) AS review_thread_rank
279
+ FROM agent_review_comments
280
+ WHERE ${filters.join(" AND ")}
281
+ ) AS distinct_review_threads
282
+ WHERE review_thread_rank = 1`
283
+ : `SELECT ${commentColumns()}
284
+ FROM agent_review_comments
285
+ WHERE ${filters.join(" AND ")}`;
204
286
  const result = await client.execute({
205
- sql: `SELECT ${commentColumns()}
206
- FROM agent_review_comments
207
- WHERE ${filters.join(" AND ")}
208
- ORDER BY created_at ASC
287
+ sql: `${selectSql}
288
+ ORDER BY created_at ASC${input.rootOnly ? ", id ASC" : ""}
209
289
  LIMIT ?`,
210
290
  args: [...filterParams, clampLimit(input.limit)],
211
291
  });
212
292
  return (result.rows ?? []).map(mapCommentRow);
213
293
  }
294
+ export async function getReviewThreadSummary(input) {
295
+ await ensureReviewTables();
296
+ const { clause, params } = input.bypassScope
297
+ ? { clause: "1 = 1", params: [] }
298
+ : scopedReviewClause(input.scope);
299
+ const filters = [
300
+ "resource_type = ?",
301
+ "resource_id = ?",
302
+ clause,
303
+ "parent_comment_id IS NULL",
304
+ "deleted_at IS NULL",
305
+ "status = 'open'",
306
+ ];
307
+ const filterParams = [
308
+ input.resourceType,
309
+ input.resourceId,
310
+ ...params,
311
+ ];
312
+ if (input.targetId !== undefined) {
313
+ if (input.targetId === null) {
314
+ filters.push("target_id IS NULL");
315
+ }
316
+ else {
317
+ filters.push("target_id = ?");
318
+ filterParams.push(input.targetId);
319
+ }
320
+ }
321
+ const result = await getDbExec().execute({
322
+ sql: `SELECT COUNT(DISTINCT thread_id) AS open_count,
323
+ COUNT(DISTINCT CASE
324
+ WHEN (resolution_target IS NULL OR resolution_target <> 'human')
325
+ AND consumed_at IS NULL
326
+ THEN thread_id
327
+ END) AS agent_queue_count
328
+ FROM agent_review_comments
329
+ WHERE ${filters.join(" AND ")}`,
330
+ args: filterParams,
331
+ });
332
+ const row = result.rows?.[0];
333
+ return {
334
+ openCount: Number(row?.open_count ?? 0),
335
+ agentQueueCount: Number(row?.agent_queue_count ?? 0),
336
+ };
337
+ }
214
338
  export async function getReviewCommentById(id, scope, options = {}) {
215
339
  await ensureReviewTables();
216
340
  const client = getDbExec();
@@ -227,29 +351,116 @@ export async function getReviewCommentById(id, scope, options = {}) {
227
351
  const row = result.rows?.[0];
228
352
  return row ? mapCommentRow(row) : null;
229
353
  }
230
- export async function resolveReviewThread(threadId, resolvedBy, resource) {
354
+ export async function getReviewThreadRoot(threadId, resource, scope, options = {}) {
355
+ await ensureReviewTables();
356
+ const { clause, params } = options.bypassScope
357
+ ? { clause: "1 = 1", params: [] }
358
+ : scopedReviewClause(scope);
359
+ const result = await getDbExec().execute({
360
+ sql: `SELECT ${commentColumns()}
361
+ FROM agent_review_comments
362
+ WHERE thread_id = ?
363
+ AND resource_type = ?
364
+ AND resource_id = ?
365
+ AND parent_comment_id IS NULL
366
+ AND ${clause}
367
+ ORDER BY created_at ASC, id ASC
368
+ LIMIT 1`,
369
+ args: [threadId, resource.resourceType, resource.resourceId, ...params],
370
+ });
371
+ const row = result.rows?.[0];
372
+ return row ? mapCommentRow(row) : null;
373
+ }
374
+ export async function resolveReviewThread(threadId, resolvedBy, resource, resolutionNote) {
231
375
  await ensureReviewTables();
376
+ const client = getDbExec();
377
+ const resolve = (tx) => resolveReviewThreadWithClient(tx, threadId, resolvedBy, resource, resolutionNote);
378
+ return client.transaction ? client.transaction(resolve) : resolve(client);
379
+ }
380
+ async function resolveReviewThreadWithClient(client, threadId, resolvedBy, resource, resolutionNote) {
232
381
  const now = new Date().toISOString();
233
382
  const resourceClause = resource
234
383
  ? "AND resource_type = ? AND resource_id = ?"
235
384
  : "";
236
- const result = await getDbExec().execute({
385
+ let rootMetadata = null;
386
+ if (resolutionNote !== undefined) {
387
+ const root = await client.execute({
388
+ sql: `SELECT metadata_json
389
+ FROM agent_review_comments
390
+ WHERE thread_id = ?
391
+ AND parent_comment_id IS NULL
392
+ AND deleted_at IS NULL
393
+ ${resourceClause}
394
+ ORDER BY created_at ASC, id ASC
395
+ LIMIT 1`,
396
+ args: [
397
+ threadId,
398
+ ...(resource ? [resource.resourceType, resource.resourceId] : []),
399
+ ],
400
+ });
401
+ if (!root.rows?.[0]) {
402
+ return 0;
403
+ }
404
+ rootMetadata = {
405
+ ...(parseObject(root.rows[0].metadata_json) ?? {}),
406
+ resolutionNote,
407
+ };
408
+ }
409
+ const metadataAssignment = resolutionNote === undefined
410
+ ? ""
411
+ : ", metadata_json = CASE WHEN parent_comment_id IS NULL THEN ? ELSE metadata_json END";
412
+ const result = await client.execute({
237
413
  sql: `UPDATE agent_review_comments
238
414
  SET status = 'resolved',
239
415
  resolved_by = ?,
240
416
  resolved_at = ?,
241
417
  updated_at = ?
418
+ ${metadataAssignment}
242
419
  WHERE thread_id = ? AND deleted_at IS NULL ${resourceClause}`,
243
420
  args: [
244
421
  resolvedBy ?? null,
245
422
  now,
246
423
  now,
424
+ ...(resolutionNote === undefined
425
+ ? []
426
+ : [stringifyOptionalJson(rootMetadata)]),
247
427
  threadId,
248
428
  ...(resource ? [resource.resourceType, resource.resourceId] : []),
249
429
  ],
250
430
  });
251
431
  return result.rowsAffected ?? 0;
252
432
  }
433
+ export async function routeReviewThread(threadId, resolutionTarget, resource) {
434
+ await ensureReviewTables();
435
+ return routeReviewThreadWithClient(getDbExec(), threadId, resolutionTarget, resource);
436
+ }
437
+ async function routeReviewThreadWithClient(client, threadId, resolutionTarget, resource) {
438
+ const now = new Date().toISOString();
439
+ const result = await client.execute({
440
+ sql: `UPDATE agent_review_comments
441
+ SET resolution_target = ?,
442
+ consumed_at = CASE WHEN ? = 'agent' THEN NULL ELSE consumed_at END,
443
+ updated_at = ?
444
+ WHERE thread_id = ?
445
+ AND resource_type = ?
446
+ AND resource_id = ?
447
+ AND parent_comment_id IS NULL
448
+ AND status = 'open'
449
+ AND deleted_at IS NULL`,
450
+ args: [
451
+ resolutionTarget,
452
+ resolutionTarget,
453
+ now,
454
+ threadId,
455
+ resource.resourceType,
456
+ resource.resourceId,
457
+ ],
458
+ });
459
+ return result.rowsAffected ?? 0;
460
+ }
461
+ export async function sendReviewThreadToAgent(threadId, resource) {
462
+ return routeReviewThread(threadId, "agent", resource);
463
+ }
253
464
  export async function deleteReviewComment(id, deletedBy) {
254
465
  await ensureReviewTables();
255
466
  const now = new Date().toISOString();
@@ -447,6 +658,7 @@ function scopedReviewClause(scope) {
447
658
  return { clause: `(${parts.join(" OR ")})`, params };
448
659
  }
449
660
  function mapCommentRow(row) {
661
+ const metadata = parseObject(row.metadata_json);
450
662
  return {
451
663
  id: String(row.id),
452
664
  resourceType: String(row.resource_type),
@@ -473,7 +685,10 @@ function mapCommentRow(row) {
473
685
  deletedAt: nullableString(row.deleted_at),
474
686
  createdAt: String(row.created_at),
475
687
  updatedAt: String(row.updated_at),
476
- metadata: parseObject(row.metadata_json),
688
+ metadata,
689
+ resolutionNote: typeof metadata?.resolutionNote === "string"
690
+ ? metadata.resolutionNote
691
+ : null,
477
692
  };
478
693
  }
479
694
  function mapStatusRow(row) {