@agent-native/core 0.134.1 → 0.135.1

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 (463) hide show
  1. package/corpus/README.md +3 -3
  2. package/corpus/core/CHANGELOG.md +113 -0
  3. package/corpus/core/package.json +3 -2
  4. package/corpus/core/src/automations/service.ts +41 -4
  5. package/corpus/core/src/cli/mcp-config-writers.ts +27 -21
  6. package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +187 -85
  7. package/corpus/core/src/client/agent-page/AutomationDetailsDialog.tsx +208 -0
  8. package/corpus/core/src/client/agent-page/AutomationScheduleDialog.tsx +180 -0
  9. package/corpus/core/src/client/agent-page/TimezoneSelect.tsx +241 -0
  10. package/corpus/core/src/client/agent-page/use-jobs.ts +50 -10
  11. package/corpus/core/src/client/org/OrgSwitcher.tsx +26 -0
  12. package/corpus/core/src/client/settings/AccountSettingsCard.tsx +35 -31
  13. package/corpus/core/src/client/settings/SchedulingTimezoneField.tsx +71 -0
  14. package/corpus/core/src/client/settings/SettingsRow.tsx +113 -0
  15. package/corpus/core/src/client/settings/agent-settings-search.ts +2 -1
  16. package/corpus/core/src/client/settings/index.ts +6 -0
  17. package/corpus/core/src/integrations/identity.ts +2 -12
  18. package/corpus/core/src/jobs/actions/list-automation-runs.ts +33 -0
  19. package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +27 -6
  20. package/corpus/core/src/jobs/actions/manage-recurring-job.ts +41 -9
  21. package/corpus/core/src/jobs/background-automation-runner.ts +88 -0
  22. package/corpus/core/src/jobs/cron.ts +52 -6
  23. package/corpus/core/src/jobs/frontmatter.ts +20 -0
  24. package/corpus/core/src/jobs/run-history.ts +242 -0
  25. package/corpus/core/src/jobs/scheduler.ts +73 -18
  26. package/corpus/core/src/jobs/tools.ts +54 -6
  27. package/corpus/core/src/localization/actions/get-localization-preference.ts +2 -2
  28. package/corpus/core/src/localization/actions/set-localization-preference.ts +49 -11
  29. package/corpus/core/src/localization/default-messages.ts +27 -0
  30. package/corpus/core/src/localization/shared.ts +39 -6
  31. package/corpus/core/src/localization/user-timezone.ts +36 -0
  32. package/corpus/core/src/org/app-roles-handlers.ts +1 -9
  33. package/corpus/core/src/org/index.ts +2 -0
  34. package/corpus/core/src/org/membership.ts +18 -0
  35. package/corpus/core/src/review/actions/create-review-comment.ts +4 -1
  36. package/corpus/core/src/review/actions/reply-review-comment.ts +4 -1
  37. package/corpus/core/src/review/index.ts +5 -0
  38. package/corpus/core/src/review/notifications.ts +163 -0
  39. package/corpus/core/src/review/types.ts +7 -0
  40. package/corpus/core/src/server/action-discovery.ts +4 -0
  41. package/corpus/core/src/server/activity-notifications.ts +174 -0
  42. package/corpus/core/src/server/app-name.ts +31 -0
  43. package/corpus/core/src/server/better-auth-instance.ts +4 -4
  44. package/corpus/core/src/server/email-templates.ts +70 -14
  45. package/corpus/core/src/server/email.ts +66 -3
  46. package/corpus/core/src/server/index.ts +10 -0
  47. package/corpus/core/src/sharing/access.ts +44 -2
  48. package/corpus/core/src/sharing/index.ts +5 -0
  49. package/corpus/core/src/sharing/recipients.ts +67 -0
  50. package/corpus/core/src/triggers/actions/list-automations.ts +27 -8
  51. package/corpus/core/src/triggers/actions/manage-automation.ts +17 -6
  52. package/corpus/core/src/triggers/actions.ts +16 -4
  53. package/corpus/core/src/triggers/dispatcher.ts +44 -30
  54. package/corpus/core/src/triggers/routes.ts +19 -6
  55. package/corpus/core/src/vitest-config.ts +68 -0
  56. package/corpus/core/vitest.config.ts +5 -0
  57. package/corpus/templates/analytics/app/pages/Settings.tsx +37 -53
  58. package/corpus/templates/analytics/changelog/2026-08-01-new-error-alerts-now-reach-you-by-email-and-a-scheduled-dash.md +6 -0
  59. package/corpus/templates/analytics/server/jobs/dashboard-report.ts +43 -0
  60. package/corpus/templates/analytics/server/lib/error-capture.ts +5 -1
  61. package/corpus/templates/analytics/vitest.config.ts +16 -12
  62. package/corpus/templates/assets/actions/refresh-generation-run.ts +3 -0
  63. package/corpus/templates/assets/app/components/ui/switch.tsx +1 -0
  64. package/corpus/templates/assets/app/hooks/use-assets-prefs.ts +55 -0
  65. package/corpus/templates/assets/app/i18n-data.ts +30 -0
  66. package/corpus/templates/assets/app/routes/settings.tsx +58 -55
  67. package/corpus/templates/assets/changelog/2026-08-01-get-an-email-when-a-generation-you-started-finishes-or-fails.md +6 -0
  68. package/corpus/templates/assets/server/lib/generation-run-notifications.ts +89 -0
  69. package/corpus/templates/assets/server/lib/video-runs.ts +8 -1
  70. package/corpus/templates/assets/server/routes/_agent-native/assets/user-prefs.get.ts +17 -0
  71. package/corpus/templates/assets/server/routes/_agent-native/assets/user-prefs.put.ts +36 -0
  72. package/corpus/templates/assets/shared/assets-user-prefs.ts +10 -0
  73. package/corpus/templates/assets/vitest.config.ts +16 -12
  74. package/corpus/templates/brain/app/routes/settings.tsx +15 -15
  75. package/corpus/templates/brain/vitest.config.ts +16 -12
  76. package/corpus/templates/calendar/app/pages/Settings.tsx +32 -40
  77. package/corpus/templates/calendar/changelog/2026-08-01-language-and-appearance-now-sit-together-in-one-preferences-.md +6 -0
  78. package/corpus/templates/calendar/vitest.config.ts +16 -12
  79. package/corpus/templates/chat/app/routes/settings.tsx +14 -22
  80. package/corpus/templates/chat/vitest.config.ts +9 -0
  81. package/corpus/templates/clips/.agents/skills/video-editing/SKILL.md +31 -0
  82. package/corpus/templates/clips/AGENTS.md +1 -0
  83. package/corpus/templates/clips/actions/add-comment.ts +12 -1
  84. package/corpus/templates/clips/actions/create-meeting.ts +2 -2
  85. package/corpus/templates/clips/actions/create-recording.ts +2 -2
  86. package/corpus/templates/clips/actions/finalize-recording.ts +42 -6
  87. package/corpus/templates/clips/actions/generate-filmstrip.ts +154 -0
  88. package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
  89. package/corpus/templates/clips/actions/import-loom-recording.ts +2 -2
  90. package/corpus/templates/clips/actions/lib/ensure-recording-filmstrip.ts +258 -0
  91. package/corpus/templates/clips/actions/lib/ensure-seekable-video.ts +11 -3
  92. package/corpus/templates/clips/actions/react-to-comment.ts +13 -0
  93. package/corpus/templates/clips/actions/react-to-recording.ts +10 -1
  94. package/corpus/templates/clips/actions/reply-to-comment.ts +12 -1
  95. package/corpus/templates/clips/actions/stitch-recordings.ts +2 -2
  96. package/corpus/templates/clips/app/components/editor/editor-layout.tsx +152 -23
  97. package/corpus/templates/clips/app/components/editor/waveform.tsx +237 -75
  98. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +23 -1
  99. package/corpus/templates/clips/app/components/settings/ai-setup-section.tsx +441 -0
  100. package/corpus/templates/clips/app/components/settings/slack-section.tsx +329 -0
  101. package/corpus/templates/clips/app/components/settings/types.ts +14 -0
  102. package/corpus/templates/clips/app/components/settings/video-storage-section.tsx +443 -0
  103. package/corpus/templates/clips/app/hooks/use-secret-status.ts +69 -0
  104. package/corpus/templates/clips/app/i18n/en-US.ts +9 -1
  105. package/corpus/templates/clips/app/lib/video-filmstrip.ts +262 -0
  106. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +165 -1351
  107. package/corpus/templates/clips/changelog/2026-07-27-saved-clips-now-resume-from-the-last-uploaded-byte-after-an-.md +6 -0
  108. package/corpus/templates/clips/changelog/2026-07-31-editor-timeline-now-shows-video-frames-behind-the-waveform-g.md +6 -0
  109. package/corpus/templates/clips/changelog/2026-07-31-email-notifications-now-go-out-when-someone-comments-on-or-r.md +6 -0
  110. package/corpus/templates/clips/changelog/2026-07-31-you-can-now-set-a-default-visibility-for-new-recordings-in-s.md +6 -0
  111. package/corpus/templates/clips/changelog/2026-08-01-email-notifications-for-comments-and-reactions-now-actually-.md +6 -0
  112. package/corpus/templates/clips/changelog/2026-08-03-the-desktop-app-now-opens-directly-beneath-its-tray-icon-on-.md +6 -0
  113. package/corpus/templates/clips/chrome-extension/package.json +1 -0
  114. package/corpus/templates/clips/chrome-extension/vitest.config.ts +9 -0
  115. package/corpus/templates/clips/desktop/package.json +1 -0
  116. package/corpus/templates/clips/desktop/src/app.tsx +17 -1
  117. package/corpus/templates/clips/desktop/src/lib/recorder.ts +331 -36
  118. package/corpus/templates/clips/desktop/src/lib/upload-recovery.ts +129 -0
  119. package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +815 -15
  120. package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +61 -11
  121. package/corpus/templates/clips/desktop/vitest.config.ts +9 -0
  122. package/corpus/templates/clips/server/db/schema.ts +17 -0
  123. package/corpus/templates/clips/server/jobs/media-verification.ts +4 -0
  124. package/corpus/templates/clips/server/lib/activity-notifications.ts +185 -0
  125. package/corpus/templates/clips/server/lib/recording-media-cleanup.ts +2 -0
  126. package/corpus/templates/clips/server/lib/recording-upload-state.ts +46 -9
  127. package/corpus/templates/clips/server/lib/recordings.ts +24 -0
  128. package/corpus/templates/clips/server/lib/resumable-session.ts +10 -4
  129. package/corpus/templates/clips/server/lib/transactional-email-templates.ts +109 -0
  130. package/corpus/templates/clips/server/lib/upload-interruption.ts +8 -0
  131. package/corpus/templates/clips/server/lib/upload-lease.ts +50 -4
  132. package/corpus/templates/clips/server/lib/video-filmstrip-sprite.ts +207 -0
  133. package/corpus/templates/clips/server/lib/video-remux.ts +13 -4
  134. package/corpus/templates/clips/server/plugins/db.ts +16 -0
  135. package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +4 -0
  136. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +123 -36
  137. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +159 -29
  138. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +197 -0
  139. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +193 -39
  140. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/resume.get.ts +191 -12
  141. package/corpus/templates/clips/shared/clips-ai-prefs.ts +6 -0
  142. package/corpus/templates/clips/shared/feature-flags.ts +12 -0
  143. package/corpus/templates/clips/shared/recording-core.ts +4 -0
  144. package/corpus/templates/clips/vitest.config.ts +23 -19
  145. package/corpus/templates/content/actions/_database-utils.ts +113 -4
  146. package/corpus/templates/content/actions/add-comment.ts +15 -1
  147. package/corpus/templates/content/actions/get-document.ts +84 -3
  148. package/corpus/templates/content/actions/list-documents.ts +1 -0
  149. package/corpus/templates/content/app/components/editor/BuilderBodySyncingNotice.tsx +9 -2
  150. package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +34 -15
  151. package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +55 -13
  152. package/corpus/templates/content/app/components/editor/body-hydration.ts +12 -6
  153. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +2 -3
  154. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +5 -12
  155. package/corpus/templates/content/app/components/ui/switch.tsx +1 -0
  156. package/corpus/templates/content/app/hooks/use-content-database.ts +16 -27
  157. package/corpus/templates/content/app/hooks/use-content-prefs.ts +55 -0
  158. package/corpus/templates/content/app/hooks/use-create-page.ts +3 -6
  159. package/corpus/templates/content/app/hooks/use-document-properties.ts +9 -16
  160. package/corpus/templates/content/app/hooks/use-document-versions.ts +3 -3
  161. package/corpus/templates/content/app/hooks/use-documents.ts +85 -29
  162. package/corpus/templates/content/app/hooks/use-notion.ts +15 -13
  163. package/corpus/templates/content/app/i18n-data.ts +72 -1
  164. package/corpus/templates/content/app/lib/document-query.ts +36 -0
  165. package/corpus/templates/content/app/routes/_app.settings.tsx +47 -18
  166. package/corpus/templates/content/changelog/2026-07-30-breadcrumb-menus-now-hide-internal-system-pages.md +6 -0
  167. package/corpus/templates/content/changelog/2026-08-01-get-an-email-when-someone-comments-on-replies-in-or-mentions.md +6 -0
  168. package/corpus/templates/content/changelog/2026-08-02-pages-opened-from-a-database-now-keep-that-database-s-fields.md +6 -0
  169. package/corpus/templates/content/server/lib/comment-notifications.ts +146 -0
  170. package/corpus/templates/content/server/lib/document-context.ts +11 -6
  171. package/corpus/templates/content/server/routes/_agent-native/content/user-prefs.get.ts +17 -0
  172. package/corpus/templates/content/server/routes/_agent-native/content/user-prefs.put.ts +36 -0
  173. package/corpus/templates/content/shared/api.ts +8 -0
  174. package/corpus/templates/content/shared/content-user-prefs.ts +11 -0
  175. package/corpus/templates/content/vitest.config.ts +20 -16
  176. package/corpus/templates/crm/app/routes/settings.tsx +14 -22
  177. package/corpus/templates/crm/vitest.config.ts +8 -4
  178. package/corpus/templates/design/app/routes/settings.tsx +14 -22
  179. package/corpus/templates/design/changelog/2026-08-01-review-comments-replies-and-mentions-now-send-an-email-to-th.md +6 -0
  180. package/corpus/templates/design/vitest.config.ts +18 -12
  181. package/corpus/templates/dispatch/app/routes/settings.tsx +26 -40
  182. package/corpus/templates/dispatch/vitest.config.ts +11 -7
  183. package/corpus/templates/factory/app/routes/settings.tsx +14 -22
  184. package/corpus/templates/factory/vitest.config.ts +9 -0
  185. package/corpus/templates/forms/app/routes/_app.settings.tsx +14 -22
  186. package/corpus/templates/forms/vitest.config.ts +27 -23
  187. package/corpus/templates/macros/app/routes/settings.tsx +14 -22
  188. package/corpus/templates/macros/vitest.config.ts +16 -12
  189. package/corpus/templates/mail/app/pages/SettingsPage.tsx +14 -16
  190. package/corpus/templates/mail/vitest.config.ts +16 -12
  191. package/corpus/templates/plan/app/routes/settings.tsx +30 -44
  192. package/corpus/templates/plan/vitest.config.ts +24 -20
  193. package/corpus/templates/slides/actions/add-slide-comment.ts +12 -1
  194. package/corpus/templates/slides/app/components/ui/switch.tsx +1 -0
  195. package/corpus/templates/slides/app/hooks/use-slides-prefs.ts +55 -0
  196. package/corpus/templates/slides/app/i18n/en-US.ts +4 -0
  197. package/corpus/templates/slides/app/routes/settings.tsx +45 -22
  198. package/corpus/templates/slides/changelog/2026-08-01-get-an-email-when-someone-comments-on-or-replies-in-your-dec.md +6 -0
  199. package/corpus/templates/slides/server/lib/comment-notifications.ts +182 -0
  200. package/corpus/templates/slides/server/routes/_agent-native/slides/user-prefs.get.ts +16 -0
  201. package/corpus/templates/slides/server/routes/_agent-native/slides/user-prefs.put.ts +36 -0
  202. package/corpus/templates/slides/shared/slides-user-prefs.ts +11 -0
  203. package/corpus/templates/slides/vitest.config.ts +17 -13
  204. package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +2 -0
  205. package/corpus/templates/tasks/app/routes/settings.tsx +14 -22
  206. package/corpus/templates/tasks/vitest.config.ts +17 -13
  207. package/corpus/toolkit/CHANGELOG.md +9 -0
  208. package/corpus/toolkit/package.json +1 -1
  209. package/corpus/toolkit/vitest.config.ts +3 -0
  210. package/dist/automations/service.d.ts +2 -0
  211. package/dist/automations/service.d.ts.map +1 -1
  212. package/dist/automations/service.js +29 -4
  213. package/dist/automations/service.js.map +1 -1
  214. package/dist/cli/mcp-config-writers.d.ts.map +1 -1
  215. package/dist/cli/mcp-config-writers.js +24 -23
  216. package/dist/cli/mcp-config-writers.js.map +1 -1
  217. package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -1
  218. package/dist/client/agent-page/AgentJobsTab.js +86 -29
  219. package/dist/client/agent-page/AgentJobsTab.js.map +1 -1
  220. package/dist/client/agent-page/AutomationDetailsDialog.d.ts +21 -0
  221. package/dist/client/agent-page/AutomationDetailsDialog.d.ts.map +1 -0
  222. package/dist/client/agent-page/AutomationDetailsDialog.js +33 -0
  223. package/dist/client/agent-page/AutomationDetailsDialog.js.map +1 -0
  224. package/dist/client/agent-page/AutomationScheduleDialog.d.ts +15 -0
  225. package/dist/client/agent-page/AutomationScheduleDialog.d.ts.map +1 -0
  226. package/dist/client/agent-page/AutomationScheduleDialog.js +46 -0
  227. package/dist/client/agent-page/AutomationScheduleDialog.js.map +1 -0
  228. package/dist/client/agent-page/TimezoneSelect.d.ts +17 -0
  229. package/dist/client/agent-page/TimezoneSelect.d.ts.map +1 -0
  230. package/dist/client/agent-page/TimezoneSelect.js +107 -0
  231. package/dist/client/agent-page/TimezoneSelect.js.map +1 -0
  232. package/dist/client/agent-page/use-jobs.d.ts +20 -7
  233. package/dist/client/agent-page/use-jobs.d.ts.map +1 -1
  234. package/dist/client/agent-page/use-jobs.js +24 -4
  235. package/dist/client/agent-page/use-jobs.js.map +1 -1
  236. package/dist/client/org/OrgSwitcher.d.ts +8 -1
  237. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  238. package/dist/client/org/OrgSwitcher.js +8 -2
  239. package/dist/client/org/OrgSwitcher.js.map +1 -1
  240. package/dist/client/settings/AccountSettingsCard.d.ts.map +1 -1
  241. package/dist/client/settings/AccountSettingsCard.js +10 -9
  242. package/dist/client/settings/AccountSettingsCard.js.map +1 -1
  243. package/dist/client/settings/SchedulingTimezoneField.d.ts +10 -0
  244. package/dist/client/settings/SchedulingTimezoneField.d.ts.map +1 -0
  245. package/dist/client/settings/SchedulingTimezoneField.js +30 -0
  246. package/dist/client/settings/SchedulingTimezoneField.js.map +1 -0
  247. package/dist/client/settings/SettingsRow.d.ts +36 -0
  248. package/dist/client/settings/SettingsRow.d.ts.map +1 -0
  249. package/dist/client/settings/SettingsRow.js +15 -0
  250. package/dist/client/settings/SettingsRow.js.map +1 -0
  251. package/dist/client/settings/agent-settings-search.d.ts.map +1 -1
  252. package/dist/client/settings/agent-settings-search.js +1 -1
  253. package/dist/client/settings/agent-settings-search.js.map +1 -1
  254. package/dist/client/settings/index.d.ts +1 -0
  255. package/dist/client/settings/index.d.ts.map +1 -1
  256. package/dist/client/settings/index.js +1 -0
  257. package/dist/client/settings/index.js.map +1 -1
  258. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  259. package/dist/integrations/identity.d.ts.map +1 -1
  260. package/dist/integrations/identity.js +2 -11
  261. package/dist/integrations/identity.js.map +1 -1
  262. package/dist/jobs/actions/list-automation-runs.d.ts +8 -0
  263. package/dist/jobs/actions/list-automation-runs.d.ts.map +1 -0
  264. package/dist/jobs/actions/list-automation-runs.js +29 -0
  265. package/dist/jobs/actions/list-automation-runs.js.map +1 -0
  266. package/dist/jobs/actions/list-recurring-jobs.d.ts +2 -0
  267. package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -1
  268. package/dist/jobs/actions/list-recurring-jobs.js +20 -7
  269. package/dist/jobs/actions/list-recurring-jobs.js.map +1 -1
  270. package/dist/jobs/actions/manage-recurring-job.d.ts +2 -0
  271. package/dist/jobs/actions/manage-recurring-job.js +30 -9
  272. package/dist/jobs/actions/manage-recurring-job.js.map +1 -1
  273. package/dist/jobs/background-automation-runner.d.ts.map +1 -1
  274. package/dist/jobs/background-automation-runner.js +60 -0
  275. package/dist/jobs/background-automation-runner.js.map +1 -1
  276. package/dist/jobs/cron.d.ts +16 -2
  277. package/dist/jobs/cron.d.ts.map +1 -1
  278. package/dist/jobs/cron.js +43 -6
  279. package/dist/jobs/cron.js.map +1 -1
  280. package/dist/jobs/frontmatter.d.ts +12 -0
  281. package/dist/jobs/frontmatter.d.ts.map +1 -1
  282. package/dist/jobs/frontmatter.js +8 -0
  283. package/dist/jobs/frontmatter.js.map +1 -1
  284. package/dist/jobs/run-history.d.ts +56 -0
  285. package/dist/jobs/run-history.d.ts.map +1 -0
  286. package/dist/jobs/run-history.js +169 -0
  287. package/dist/jobs/run-history.js.map +1 -0
  288. package/dist/jobs/scheduler.d.ts.map +1 -1
  289. package/dist/jobs/scheduler.js +51 -18
  290. package/dist/jobs/scheduler.js.map +1 -1
  291. package/dist/jobs/tools.d.ts.map +1 -1
  292. package/dist/jobs/tools.js +37 -6
  293. package/dist/jobs/tools.js.map +1 -1
  294. package/dist/localization/actions/get-localization-preference.d.ts +1 -2
  295. package/dist/localization/actions/get-localization-preference.d.ts.map +1 -1
  296. package/dist/localization/actions/get-localization-preference.js.map +1 -1
  297. package/dist/localization/actions/set-localization-preference.d.ts +3 -3
  298. package/dist/localization/actions/set-localization-preference.d.ts.map +1 -1
  299. package/dist/localization/actions/set-localization-preference.js +33 -8
  300. package/dist/localization/actions/set-localization-preference.js.map +1 -1
  301. package/dist/localization/default-messages.d.ts +25 -0
  302. package/dist/localization/default-messages.d.ts.map +1 -1
  303. package/dist/localization/default-messages.js +25 -0
  304. package/dist/localization/default-messages.js.map +1 -1
  305. package/dist/localization/shared.d.ts +16 -1
  306. package/dist/localization/shared.d.ts.map +1 -1
  307. package/dist/localization/shared.js +22 -4
  308. package/dist/localization/shared.js.map +1 -1
  309. package/dist/localization/user-timezone.d.ts +11 -0
  310. package/dist/localization/user-timezone.d.ts.map +1 -0
  311. package/dist/localization/user-timezone.js +31 -0
  312. package/dist/localization/user-timezone.js.map +1 -0
  313. package/dist/notifications/routes.d.ts +4 -4
  314. package/dist/observability/routes.d.ts +3 -3
  315. package/dist/org/app-roles-handlers.d.ts.map +1 -1
  316. package/dist/org/app-roles-handlers.js +1 -8
  317. package/dist/org/app-roles-handlers.js.map +1 -1
  318. package/dist/org/index.d.ts +1 -0
  319. package/dist/org/index.d.ts.map +1 -1
  320. package/dist/org/index.js +1 -0
  321. package/dist/org/index.js.map +1 -1
  322. package/dist/org/membership.d.ts +6 -0
  323. package/dist/org/membership.d.ts.map +1 -0
  324. package/dist/org/membership.js +16 -0
  325. package/dist/org/membership.js.map +1 -0
  326. package/dist/progress/routes.d.ts +1 -1
  327. package/dist/provider-api/actions/custom-provider-registration.d.ts +13 -13
  328. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  329. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  330. package/dist/review/actions/create-review-comment.d.ts +32 -1
  331. package/dist/review/actions/create-review-comment.d.ts.map +1 -1
  332. package/dist/review/actions/create-review-comment.js +3 -1
  333. package/dist/review/actions/create-review-comment.js.map +1 -1
  334. package/dist/review/actions/reply-review-comment.d.ts +32 -1
  335. package/dist/review/actions/reply-review-comment.d.ts.map +1 -1
  336. package/dist/review/actions/reply-review-comment.js +3 -1
  337. package/dist/review/actions/reply-review-comment.js.map +1 -1
  338. package/dist/review/index.d.ts +1 -0
  339. package/dist/review/index.d.ts.map +1 -1
  340. package/dist/review/index.js +1 -0
  341. package/dist/review/index.js.map +1 -1
  342. package/dist/review/notifications.d.ts +24 -0
  343. package/dist/review/notifications.d.ts.map +1 -0
  344. package/dist/review/notifications.js +123 -0
  345. package/dist/review/notifications.js.map +1 -0
  346. package/dist/review/types.d.ts +5 -0
  347. package/dist/review/types.d.ts.map +1 -1
  348. package/dist/review/types.js.map +1 -1
  349. package/dist/server/action-discovery.d.ts.map +1 -1
  350. package/dist/server/action-discovery.js +4 -0
  351. package/dist/server/action-discovery.js.map +1 -1
  352. package/dist/server/activity-notifications.d.ts +61 -0
  353. package/dist/server/activity-notifications.d.ts.map +1 -0
  354. package/dist/server/activity-notifications.js +103 -0
  355. package/dist/server/activity-notifications.js.map +1 -0
  356. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  357. package/dist/server/app-name.d.ts +18 -0
  358. package/dist/server/app-name.d.ts.map +1 -1
  359. package/dist/server/app-name.js +31 -0
  360. package/dist/server/app-name.js.map +1 -1
  361. package/dist/server/better-auth-instance.js +4 -4
  362. package/dist/server/better-auth-instance.js.map +1 -1
  363. package/dist/server/email-templates.d.ts +12 -0
  364. package/dist/server/email-templates.d.ts.map +1 -1
  365. package/dist/server/email-templates.js +57 -14
  366. package/dist/server/email-templates.js.map +1 -1
  367. package/dist/server/email.d.ts +12 -0
  368. package/dist/server/email.d.ts.map +1 -1
  369. package/dist/server/email.js +52 -5
  370. package/dist/server/email.js.map +1 -1
  371. package/dist/server/index.d.ts +1 -0
  372. package/dist/server/index.d.ts.map +1 -1
  373. package/dist/server/index.js +1 -0
  374. package/dist/server/index.js.map +1 -1
  375. package/dist/server/transcribe-voice.d.ts +1 -1
  376. package/dist/sharing/access.d.ts.map +1 -1
  377. package/dist/sharing/access.js +32 -2
  378. package/dist/sharing/access.js.map +1 -1
  379. package/dist/sharing/index.d.ts +1 -0
  380. package/dist/sharing/index.d.ts.map +1 -1
  381. package/dist/sharing/index.js +1 -0
  382. package/dist/sharing/index.js.map +1 -1
  383. package/dist/sharing/recipients.d.ts +31 -0
  384. package/dist/sharing/recipients.d.ts.map +1 -0
  385. package/dist/sharing/recipients.js +40 -0
  386. package/dist/sharing/recipients.js.map +1 -0
  387. package/dist/templates/chat/app/routes/settings.tsx +14 -22
  388. package/dist/templates/chat/vitest.config.ts +9 -0
  389. package/dist/triggers/actions/list-automations.d.ts +2 -0
  390. package/dist/triggers/actions/list-automations.d.ts.map +1 -1
  391. package/dist/triggers/actions/list-automations.js +19 -8
  392. package/dist/triggers/actions/list-automations.js.map +1 -1
  393. package/dist/triggers/actions/manage-automation.d.ts +6 -0
  394. package/dist/triggers/actions/manage-automation.js +12 -6
  395. package/dist/triggers/actions/manage-automation.js.map +1 -1
  396. package/dist/triggers/actions.d.ts.map +1 -1
  397. package/dist/triggers/actions.js +15 -4
  398. package/dist/triggers/actions.js.map +1 -1
  399. package/dist/triggers/dispatcher.d.ts.map +1 -1
  400. package/dist/triggers/dispatcher.js +19 -17
  401. package/dist/triggers/dispatcher.js.map +1 -1
  402. package/dist/triggers/routes.d.ts.map +1 -1
  403. package/dist/triggers/routes.js +6 -6
  404. package/dist/triggers/routes.js.map +1 -1
  405. package/dist/vitest-config.d.ts +10 -0
  406. package/dist/vitest-config.d.ts.map +1 -0
  407. package/dist/vitest-config.js +55 -0
  408. package/dist/vitest-config.js.map +1 -0
  409. package/package.json +5 -4
  410. package/src/automations/service.ts +41 -4
  411. package/src/cli/mcp-config-writers.ts +27 -21
  412. package/src/client/agent-page/AgentJobsTab.tsx +187 -85
  413. package/src/client/agent-page/AutomationDetailsDialog.tsx +208 -0
  414. package/src/client/agent-page/AutomationScheduleDialog.tsx +180 -0
  415. package/src/client/agent-page/TimezoneSelect.tsx +241 -0
  416. package/src/client/agent-page/use-jobs.ts +50 -10
  417. package/src/client/org/OrgSwitcher.tsx +26 -0
  418. package/src/client/settings/AccountSettingsCard.tsx +35 -31
  419. package/src/client/settings/SchedulingTimezoneField.tsx +71 -0
  420. package/src/client/settings/SettingsRow.tsx +113 -0
  421. package/src/client/settings/agent-settings-search.ts +2 -1
  422. package/src/client/settings/index.ts +6 -0
  423. package/src/integrations/identity.ts +2 -12
  424. package/src/jobs/actions/list-automation-runs.ts +33 -0
  425. package/src/jobs/actions/list-recurring-jobs.ts +27 -6
  426. package/src/jobs/actions/manage-recurring-job.ts +41 -9
  427. package/src/jobs/background-automation-runner.ts +88 -0
  428. package/src/jobs/cron.ts +52 -6
  429. package/src/jobs/frontmatter.ts +20 -0
  430. package/src/jobs/run-history.ts +242 -0
  431. package/src/jobs/scheduler.ts +73 -18
  432. package/src/jobs/tools.ts +54 -6
  433. package/src/localization/actions/get-localization-preference.ts +2 -2
  434. package/src/localization/actions/set-localization-preference.ts +49 -11
  435. package/src/localization/default-messages.ts +27 -0
  436. package/src/localization/shared.ts +39 -6
  437. package/src/localization/user-timezone.ts +36 -0
  438. package/src/org/app-roles-handlers.ts +1 -9
  439. package/src/org/index.ts +2 -0
  440. package/src/org/membership.ts +18 -0
  441. package/src/review/actions/create-review-comment.ts +4 -1
  442. package/src/review/actions/reply-review-comment.ts +4 -1
  443. package/src/review/index.ts +5 -0
  444. package/src/review/notifications.ts +163 -0
  445. package/src/review/types.ts +7 -0
  446. package/src/server/action-discovery.ts +4 -0
  447. package/src/server/activity-notifications.ts +174 -0
  448. package/src/server/app-name.ts +31 -0
  449. package/src/server/better-auth-instance.ts +4 -4
  450. package/src/server/email-templates.ts +70 -14
  451. package/src/server/email.ts +66 -3
  452. package/src/server/index.ts +10 -0
  453. package/src/sharing/access.ts +44 -2
  454. package/src/sharing/index.ts +5 -0
  455. package/src/sharing/recipients.ts +67 -0
  456. package/src/templates/chat/app/routes/settings.tsx +14 -22
  457. package/src/templates/chat/vitest.config.ts +9 -0
  458. package/src/triggers/actions/list-automations.ts +27 -8
  459. package/src/triggers/actions/manage-automation.ts +17 -6
  460. package/src/triggers/actions.ts +16 -4
  461. package/src/triggers/dispatcher.ts +44 -30
  462. package/src/triggers/routes.ts +19 -6
  463. package/src/vitest-config.ts +68 -0
@@ -16,19 +16,19 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
16
16
  error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- count?: undefined;
20
19
  updated: number;
21
20
  error?: undefined;
22
21
  ok?: undefined;
23
- } | {
24
22
  count?: undefined;
23
+ } | {
25
24
  updated?: undefined;
26
25
  error: string;
27
26
  ok?: undefined;
28
- } | {
29
27
  count?: undefined;
28
+ } | {
30
29
  updated?: undefined;
31
- error?: undefined;
32
30
  ok: boolean;
31
+ error?: undefined;
32
+ count?: undefined;
33
33
  }>>;
34
34
  //# sourceMappingURL=routes.d.ts.map
@@ -41,16 +41,16 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
+ error?: undefined;
44
45
  summary: import("./types.js").TraceSummary;
45
46
  spans: import("./types.js").TraceSpan[];
46
47
  id?: undefined;
47
- error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
50
+ error?: undefined;
50
51
  summary?: undefined;
51
52
  spans?: undefined;
52
53
  id: string;
53
- error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
56
  summary?: undefined;
@@ -59,10 +59,10 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
59
59
  error: any;
60
60
  ok?: undefined;
61
61
  } | {
62
+ error?: undefined;
62
63
  summary?: undefined;
63
64
  spans?: undefined;
64
65
  id?: undefined;
65
- error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
68
68
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-roles-handlers.d.ts","sourceRoot":"","sources":["../../src/org/app-roles-handlers.ts"],"names":[],"mappings":"AAwDA;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;GA4B/B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;GAqD5B,CAAC"}
1
+ {"version":3,"file":"app-roles-handlers.d.ts","sourceRoot":"","sources":["../../src/org/app-roles-handlers.ts"],"names":[],"mappings":"AAgDA;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;GA4B/B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;GAqD5B,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { defineEventHandler, getRequestURL, createError, } from "h3";
2
- import { getDbExec } from "../db/client.js";
3
2
  import { readBody } from "../server/h3-helpers.js";
4
3
  import { getRegisteredAppRoles, listAppMemberRoles, setAppMemberRole, } from "./app-roles.js";
5
4
  import { getOrgContext } from "./context.js";
5
+ import { isOrgMember } from "./membership.js";
6
6
  import { canManageOrg } from "./permissions.js";
7
7
  /**
8
8
  * Resolve the descriptor a request is talking about.
@@ -31,13 +31,6 @@ function extractMemberEmail(event) {
31
31
  const match = path.match(/^\/([^/]+)\/?$/) ?? path.match(/\/app-roles\/([^/]+)\/?$/);
32
32
  return match?.[1] ? decodeURIComponent(match[1]) : undefined;
33
33
  }
34
- async function isOrgMember(orgId, email) {
35
- const { rows } = await getDbExec().execute({
36
- sql: `SELECT 1 FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,
37
- args: [orgId, email.trim().toLowerCase()],
38
- });
39
- return rows.length > 0;
40
- }
41
34
  /**
42
35
  * GET /_agent-native/org/app-roles?appId=X — the app's vocabulary plus every
43
36
  * assignment in the active org, and the caller's own resolved role.
@@ -1 +1 @@
1
- {"version":3,"file":"app-roles-handlers.js","sourceRoot":"","sources":["../../src/org/app-roles-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,WAAW,GAEZ,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,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SACtD,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,6EAA6E;IAC7E,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC3C,MAAM,WAAW,CAAC;YAChB,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,mCAAmC;SAC7C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,gBAAgB,CAAC;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK;QACL,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QACzC,SAAS,EAAE,GAAG,CAAC,KAAK;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,KAAK;QACL,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;KAC1C,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import {\n defineEventHandler,\n getRequestURL,\n createError,\n type H3Event,\n} from \"h3\";\n\nimport { getDbExec } from \"../db/client.js\";\nimport { readBody } from \"../server/h3-helpers.js\";\nimport {\n getRegisteredAppRoles,\n listAppMemberRoles,\n setAppMemberRole,\n type AppRolesDescriptor,\n} from \"./app-roles.js\";\nimport { getOrgContext } from \"./context.js\";\nimport { canManageOrg } from \"./permissions.js\";\n\n/**\n * Resolve the descriptor a request is talking about.\n *\n * The `appId` arrives from the client but can only ever select among\n * descriptors the server already declared through `defineAppRoles`; an\n * unregistered id is a 404, never an implicit new app. That keeps the trusted\n * vocabulary in app source while still letting one workspace host several apps.\n */\nfunction requireDescriptor(appId: string | null): AppRolesDescriptor<string> {\n if (!appId?.trim()) {\n throw createError({ statusCode: 400, message: \"appId is required\" });\n }\n const descriptor = getRegisteredAppRoles(appId.trim());\n if (!descriptor) {\n throw createError({\n statusCode: 404,\n message: `No app roles registered for \"${appId}\"`,\n });\n }\n return descriptor;\n}\n\n/** Extract the :email tail. The mount prefix is stripped before we see it. */\nfunction extractMemberEmail(event: H3Event): string | undefined {\n const path = getRequestURL(event).pathname;\n const match =\n path.match(/^\\/([^/]+)\\/?$/) ?? path.match(/\\/app-roles\\/([^/]+)\\/?$/);\n return match?.[1] ? decodeURIComponent(match[1]) : undefined;\n}\n\nasync function isOrgMember(orgId: string, email: string): Promise<boolean> {\n const { rows } = await getDbExec().execute({\n sql: `SELECT 1 FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,\n args: [orgId, email.trim().toLowerCase()],\n });\n return rows.length > 0;\n}\n\n/**\n * GET /_agent-native/org/app-roles?appId=X — the app's vocabulary plus every\n * assignment in the active org, and the caller's own resolved role.\n */\nexport const listAppRolesHandler = defineEventHandler(\n async (event: H3Event) => {\n const url = getRequestURL(event);\n const descriptor = requireDescriptor(url.searchParams.get(\"appId\"));\n const ctx = await getOrgContext(event);\n\n const base = {\n appId: descriptor.appId,\n roles: descriptor.roles,\n defaultRole: descriptor.defaultRole ?? null,\n roleLabels: descriptor.roleLabels ?? {},\n canManage: canManageOrg(ctx.role),\n };\n if (!ctx.orgId) return { ...base, assignments: [], myRole: null };\n\n const assignments = await listAppMemberRoles(descriptor.appId, ctx.orgId);\n const mine = assignments.find(\n (a) => a.email.toLowerCase() === ctx.email.toLowerCase(),\n );\n return {\n ...base,\n assignments,\n // The caller's own role, for progressive disclosure only. Every guarded\n // operation re-resolves this server-side; a client that lies about it gains\n // nothing but a differently-shaped UI.\n myRole: mine && descriptor.roles.includes(mine.role) ? mine.role : null,\n };\n },\n);\n\n/**\n * PUT /_agent-native/org/app-roles/:email — assign or clear an app role.\n * Body: `{ appId, role }`, where `role: null` clears the assignment.\n *\n * Org owner/admin only. App roles never confer the right to manage app roles:\n * that would let an app admin escalate inside a team they cannot otherwise\n * administer, and it is the org roster this overlay hangs off.\n */\nexport const setAppRoleHandler = defineEventHandler(async (event: H3Event) => {\n const ctx = await getOrgContext(event);\n if (!ctx.email) {\n throw createError({ statusCode: 401, message: \"Authentication required\" });\n }\n if (!ctx.orgId) {\n throw createError({ statusCode: 400, message: \"No active organization\" });\n }\n if (!canManageOrg(ctx.role)) {\n throw createError({\n statusCode: 403,\n message: \"Organization admin role required\",\n });\n }\n\n const body = await readBody(event);\n const descriptor = requireDescriptor(body?.appId ?? null);\n\n const email = extractMemberEmail(event);\n if (!email) {\n throw createError({ statusCode: 400, message: \"Member email is required\" });\n }\n\n const role = body?.role ?? null;\n if (role !== null && !descriptor.roles.includes(String(role))) {\n throw createError({\n statusCode: 400,\n message: `Unknown ${descriptor.appId} role \"${role}\"`,\n });\n }\n\n // Assignments hang off membership. Writing one for a non-member would leave a\n // row that resolves to nothing and reappears if that person is ever invited.\n if (!(await isOrgMember(ctx.orgId, email))) {\n throw createError({\n statusCode: 404,\n message: \"Not a member of this organization\",\n });\n }\n\n await setAppMemberRole({\n appId: descriptor.appId,\n orgId: ctx.orgId,\n email,\n role: role === null ? null : String(role),\n updatedBy: ctx.email,\n });\n\n return {\n appId: descriptor.appId,\n email,\n role: role === null ? null : String(role),\n };\n});\n"]}
1
+ {"version":3,"file":"app-roles-handlers.js","sourceRoot":"","sources":["../../src/org/app-roles-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,WAAW,GAEZ,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB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AAC,KAAK;QAChB,KAAK;QACL,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QACzC,SAAS,EAAE,GAAG,CAAC,KAAK;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,KAAK;QACL,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;KAC1C,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import {\n defineEventHandler,\n getRequestURL,\n createError,\n type H3Event,\n} from \"h3\";\n\nimport { readBody } from \"../server/h3-helpers.js\";\nimport {\n getRegisteredAppRoles,\n listAppMemberRoles,\n setAppMemberRole,\n type AppRolesDescriptor,\n} from \"./app-roles.js\";\nimport { getOrgContext } from \"./context.js\";\nimport { isOrgMember } from \"./membership.js\";\nimport { canManageOrg } from \"./permissions.js\";\n\n/**\n * Resolve the descriptor a request is talking about.\n *\n * The `appId` arrives from the client but can only ever select among\n * descriptors the server already declared through `defineAppRoles`; an\n * unregistered id is a 404, never an implicit new app. That keeps the trusted\n * vocabulary in app source while still letting one workspace host several apps.\n */\nfunction requireDescriptor(appId: string | null): AppRolesDescriptor<string> {\n if (!appId?.trim()) {\n throw createError({ statusCode: 400, message: \"appId is required\" });\n }\n const descriptor = getRegisteredAppRoles(appId.trim());\n if (!descriptor) {\n throw createError({\n statusCode: 404,\n message: `No app roles registered for \"${appId}\"`,\n });\n }\n return descriptor;\n}\n\n/** Extract the :email tail. The mount prefix is stripped before we see it. */\nfunction extractMemberEmail(event: H3Event): string | undefined {\n const path = getRequestURL(event).pathname;\n const match =\n path.match(/^\\/([^/]+)\\/?$/) ?? path.match(/\\/app-roles\\/([^/]+)\\/?$/);\n return match?.[1] ? decodeURIComponent(match[1]) : undefined;\n}\n\n/**\n * GET /_agent-native/org/app-roles?appId=X — the app's vocabulary plus every\n * assignment in the active org, and the caller's own resolved role.\n */\nexport const listAppRolesHandler = defineEventHandler(\n async (event: H3Event) => {\n const url = getRequestURL(event);\n const descriptor = requireDescriptor(url.searchParams.get(\"appId\"));\n const ctx = await getOrgContext(event);\n\n const base = {\n appId: descriptor.appId,\n roles: descriptor.roles,\n defaultRole: descriptor.defaultRole ?? null,\n roleLabels: descriptor.roleLabels ?? {},\n canManage: canManageOrg(ctx.role),\n };\n if (!ctx.orgId) return { ...base, assignments: [], myRole: null };\n\n const assignments = await listAppMemberRoles(descriptor.appId, ctx.orgId);\n const mine = assignments.find(\n (a) => a.email.toLowerCase() === ctx.email.toLowerCase(),\n );\n return {\n ...base,\n assignments,\n // The caller's own role, for progressive disclosure only. Every guarded\n // operation re-resolves this server-side; a client that lies about it gains\n // nothing but a differently-shaped UI.\n myRole: mine && descriptor.roles.includes(mine.role) ? mine.role : null,\n };\n },\n);\n\n/**\n * PUT /_agent-native/org/app-roles/:email — assign or clear an app role.\n * Body: `{ appId, role }`, where `role: null` clears the assignment.\n *\n * Org owner/admin only. App roles never confer the right to manage app roles:\n * that would let an app admin escalate inside a team they cannot otherwise\n * administer, and it is the org roster this overlay hangs off.\n */\nexport const setAppRoleHandler = defineEventHandler(async (event: H3Event) => {\n const ctx = await getOrgContext(event);\n if (!ctx.email) {\n throw createError({ statusCode: 401, message: \"Authentication required\" });\n }\n if (!ctx.orgId) {\n throw createError({ statusCode: 400, message: \"No active organization\" });\n }\n if (!canManageOrg(ctx.role)) {\n throw createError({\n statusCode: 403,\n message: \"Organization admin role required\",\n });\n }\n\n const body = await readBody(event);\n const descriptor = requireDescriptor(body?.appId ?? null);\n\n const email = extractMemberEmail(event);\n if (!email) {\n throw createError({ statusCode: 400, message: \"Member email is required\" });\n }\n\n const role = body?.role ?? null;\n if (role !== null && !descriptor.roles.includes(String(role))) {\n throw createError({\n statusCode: 400,\n message: `Unknown ${descriptor.appId} role \"${role}\"`,\n });\n }\n\n // Assignments hang off membership. Writing one for a non-member would leave a\n // row that resolves to nothing and reappears if that person is ever invited.\n if (!(await isOrgMember(ctx.orgId, email))) {\n throw createError({\n statusCode: 404,\n message: \"Not a member of this organization\",\n });\n }\n\n await setAppMemberRole({\n appId: descriptor.appId,\n orgId: ctx.orgId,\n email,\n role: role === null ? null : String(role),\n updatedBy: ctx.email,\n });\n\n return {\n appId: descriptor.appId,\n email,\n role: role === null ? null : String(role),\n };\n});\n"]}
@@ -14,4 +14,5 @@ export { organizations, orgMembers, orgInvitations, appMemberRoles, } from "./sc
14
14
  export { getMyOrgHandler, createOrgHandler, updateOrgHandler, switchOrgHandler, listMembersHandler, removeMemberHandler, changeMemberRoleHandler, listInvitationsHandler, createInvitationHandler, acceptInvitationHandler, setA2ASecretHandler, syncA2ASecretHandler, receiveA2ASecretHandler, } from "./handlers.js";
15
15
  export { listAppRolesHandler, setAppRoleHandler, } from "./app-roles-handlers.js";
16
16
  export { isFreeEmailProvider } from "./free-email-providers.js";
17
+ export { isOrgMember } from "./membership.js";
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/org/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIhE,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/org/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,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vitations, appMemberRoles, } from "./sc
15
15
  export { getMyOrgHandler, createOrgHandler, updateOrgHandler, switchOrgHandler, listMembersHandler, removeMemberHandler, changeMemberRoleHandler, listInvitationsHandler, createInvitationHandler, acceptInvitationHandler, setA2ASecretHandler, syncA2ASecretHandler, receiveA2ASecretHandler, } from "./handlers.js";
16
16
  export { listAppRolesHandler, setAppRoleHandler, } from "./app-roles-handlers.js";
17
17
  export { isFreeEmailProvider } from "./free-email-providers.js";
18
+ export { isOrgMember } from "./membership.js";
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/org/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAYjC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,2EAA2E;AAC3E,wDAAwD;AACxD,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,8EAA8E;AAC9E,qDAAqD;AACrD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Public API for the org module.\n\nexport type {\n OrgRole,\n OrgContext,\n OrgSummary,\n OrgInvitationSummary,\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n} from \"./types.js\";\n\nexport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n orgRoleAtLeast,\n orgRoleRank,\n} from \"./permissions.js\";\n\nexport {\n getOrgContext,\n getOrgDomain,\n getOrgA2ASecret,\n getA2ASecretByDomain,\n resolveOrgByDomain,\n resolveOrgIdForEmail,\n createOrganization,\n} from \"./context.js\";\n\nexport {\n implicitServiceOrgRole,\n parseServiceIdentityEmail,\n} from \"./service-identity.js\";\n\nexport { acceptPendingInvitationsForEmail } from \"./accept-pending.js\";\nexport type { AcceptPendingResult } from \"./accept-pending.js\";\n\nexport { autoJoinDomainMatchingOrgs } from \"./auto-join-domain.js\";\nexport type { AutoJoinDomainResult } from \"./auto-join-domain.js\";\n\nexport {\n defineAppRoles,\n getRegisteredAppRoles,\n listRegisteredAppRoles,\n listAppMemberRoles,\n resolveAppRole,\n setAppMemberRole,\n} from \"./app-roles.js\";\nexport type {\n AppRoles,\n AppRolesDescriptor,\n AppRoleCaller,\n AppRoleLookup,\n AppMemberRoleRow,\n} from \"./app-roles.js\";\n\nexport { ORG_MIGRATIONS } from \"./migrations.js\";\n\nexport { createOrgPlugin, defaultOrgPlugin } from \"./plugin.js\";\n\n// Drizzle schema (re-exported so templates can write typed queries against\n// org tables without redefining the schema themselves).\nexport {\n organizations,\n orgMembers,\n orgInvitations,\n appMemberRoles,\n} from \"./schema.js\";\n\n// Individual handlers — exported so templates can compose a custom org plugin\n// while still using the framework-provided handlers.\nexport {\n getMyOrgHandler,\n createOrgHandler,\n updateOrgHandler,\n switchOrgHandler,\n listMembersHandler,\n removeMemberHandler,\n changeMemberRoleHandler,\n listInvitationsHandler,\n createInvitationHandler,\n acceptInvitationHandler,\n setA2ASecretHandler,\n syncA2ASecretHandler,\n receiveA2ASecretHandler,\n} from \"./handlers.js\";\n\nexport {\n listAppRolesHandler,\n setAppRoleHandler,\n} from \"./app-roles-handlers.js\";\n\nexport { isFreeEmailProvider } from \"./free-email-providers.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/org/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAYjC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,2EAA2E;AAC3E,wDAAwD;AACxD,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,8EAA8E;AAC9E,qDAAqD;AACrD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Public API for the org module.\n\nexport type {\n OrgRole,\n OrgContext,\n OrgSummary,\n OrgInvitationSummary,\n OrgInfo,\n OrgMember,\n OrgPendingInvitation,\n} from \"./types.js\";\n\nexport {\n canInviteOrgMembers,\n canManageOrg,\n canManageOrgDomain,\n orgRoleAtLeast,\n orgRoleRank,\n} from \"./permissions.js\";\n\nexport {\n getOrgContext,\n getOrgDomain,\n getOrgA2ASecret,\n getA2ASecretByDomain,\n resolveOrgByDomain,\n resolveOrgIdForEmail,\n createOrganization,\n} from \"./context.js\";\n\nexport {\n implicitServiceOrgRole,\n parseServiceIdentityEmail,\n} from \"./service-identity.js\";\n\nexport { acceptPendingInvitationsForEmail } from \"./accept-pending.js\";\nexport type { AcceptPendingResult } from \"./accept-pending.js\";\n\nexport { autoJoinDomainMatchingOrgs } from \"./auto-join-domain.js\";\nexport type { AutoJoinDomainResult } from \"./auto-join-domain.js\";\n\nexport {\n defineAppRoles,\n getRegisteredAppRoles,\n listRegisteredAppRoles,\n listAppMemberRoles,\n resolveAppRole,\n setAppMemberRole,\n} from \"./app-roles.js\";\nexport type {\n AppRoles,\n AppRolesDescriptor,\n AppRoleCaller,\n AppRoleLookup,\n AppMemberRoleRow,\n} from \"./app-roles.js\";\n\nexport { ORG_MIGRATIONS } from \"./migrations.js\";\n\nexport { createOrgPlugin, defaultOrgPlugin } from \"./plugin.js\";\n\n// Drizzle schema (re-exported so templates can write typed queries against\n// org tables without redefining the schema themselves).\nexport {\n organizations,\n orgMembers,\n orgInvitations,\n appMemberRoles,\n} from \"./schema.js\";\n\n// Individual handlers — exported so templates can compose a custom org plugin\n// while still using the framework-provided handlers.\nexport {\n getMyOrgHandler,\n createOrgHandler,\n updateOrgHandler,\n switchOrgHandler,\n listMembersHandler,\n removeMemberHandler,\n changeMemberRoleHandler,\n listInvitationsHandler,\n createInvitationHandler,\n acceptInvitationHandler,\n setA2ASecretHandler,\n syncA2ASecretHandler,\n receiveA2ASecretHandler,\n} from \"./handlers.js\";\n\nexport {\n listAppRolesHandler,\n setAppRoleHandler,\n} from \"./app-roles-handlers.js\";\n\nexport { isFreeEmailProvider } from \"./free-email-providers.js\";\n\nexport { isOrgMember } from \"./membership.js\";\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * One resolver for "is this email in this org". Two private copies of this
3
+ * query already existed; a third would be the one that drifts.
4
+ */
5
+ export declare function isOrgMember(orgId: string, email: string): Promise<boolean>;
6
+ //# sourceMappingURL=membership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../../src/org/membership.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,OAAO,CAAC,CAQlB"}
@@ -0,0 +1,16 @@
1
+ import { getDbExec } from "../db/client.js";
2
+ /**
3
+ * One resolver for "is this email in this org". Two private copies of this
4
+ * query already existed; a third would be the one that drifts.
5
+ */
6
+ export async function isOrgMember(orgId, email) {
7
+ const normalized = email.trim().toLowerCase();
8
+ if (!orgId || !normalized)
9
+ return false;
10
+ const { rows } = await getDbExec().execute({
11
+ sql: `SELECT 1 FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,
12
+ args: [orgId, normalized],
13
+ });
14
+ return rows.length > 0;
15
+ }
16
+ //# sourceMappingURL=membership.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership.js","sourceRoot":"","sources":["../../src/org/membership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAa,EACb,KAAa;IAEb,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,EAAE,CAAC,OAAO,CAAC;QACzC,GAAG,EAAE,yEAAyE;QAC9E,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;KAC1B,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import { getDbExec } from \"../db/client.js\";\n\n/**\n * One resolver for \"is this email in this org\". Two private copies of this\n * query already existed; a third would be the one that drifts.\n */\nexport async function isOrgMember(\n orgId: string,\n email: string,\n): Promise<boolean> {\n const normalized = email.trim().toLowerCase();\n if (!orgId || !normalized) return false;\n const { rows } = await getDbExec().execute({\n sql: `SELECT 1 FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,\n args: [orgId, normalized],\n });\n return rows.length > 0;\n}\n"]}
@@ -15,7 +15,7 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- ok: boolean;
19
18
  error?: undefined;
19
+ ok: boolean;
20
20
  }>>;
21
21
  //# sourceMappingURL=routes.d.ts.map
@@ -75,10 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- deleted?: undefined;
78
+ message?: undefined;
79
79
  id?: undefined;
80
- provider?: undefined;
81
80
  found?: undefined;
81
+ deleted?: undefined;
82
82
  providers: {
83
83
  id: string;
84
84
  label: string;
@@ -89,45 +89,45 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
89
89
  updatedAt: number;
90
90
  }[];
91
91
  count: number;
92
+ provider?: undefined;
92
93
  registered?: undefined;
93
94
  label?: undefined;
94
- message?: undefined;
95
95
  } | {
96
- deleted?: undefined;
97
- count?: undefined;
96
+ message?: undefined;
98
97
  id?: undefined;
98
+ deleted?: undefined;
99
99
  providers?: undefined;
100
+ count?: undefined;
100
101
  found: boolean;
101
102
  provider: import("../custom-registry.js").CustomProviderConfig;
102
103
  registered?: undefined;
103
104
  label?: undefined;
104
- message?: undefined;
105
105
  } | {
106
+ message?: undefined;
106
107
  deleted?: undefined;
108
+ providers?: undefined;
107
109
  count?: undefined;
108
110
  provider?: undefined;
109
- providers?: undefined;
110
111
  found: boolean;
111
112
  id: string;
112
113
  registered?: undefined;
113
114
  label?: undefined;
114
- message?: undefined;
115
115
  } | {
116
- count?: undefined;
117
- provider?: undefined;
116
+ message?: undefined;
118
117
  found?: undefined;
119
118
  providers?: undefined;
119
+ count?: undefined;
120
+ provider?: undefined;
120
121
  deleted: boolean;
121
122
  id: string;
122
123
  registered?: undefined;
123
124
  label?: undefined;
124
- message?: undefined;
125
125
  } | {
126
+ found?: undefined;
126
127
  deleted?: undefined;
128
+ providers?: undefined;
127
129
  count?: undefined;
128
130
  provider?: undefined;
129
- found?: undefined;
130
- providers?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -312,6 +312,7 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
314
  id?: undefined;
315
+ provider?: undefined;
315
316
  deleted?: undefined;
316
317
  found?: undefined;
317
318
  providers: {
@@ -324,14 +325,13 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
324
325
  updatedAt: number;
325
326
  }[];
326
327
  count: number;
327
- provider?: undefined;
328
328
  registered?: undefined;
329
329
  label?: undefined;
330
330
  message?: undefined;
331
331
  } | {
332
+ count?: undefined;
332
333
  id?: undefined;
333
334
  deleted?: undefined;
334
- count?: undefined;
335
335
  providers?: undefined;
336
336
  found: boolean;
337
337
  provider: import("../custom-registry.js").CustomProviderConfig;
@@ -339,31 +339,31 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
339
339
  label?: undefined;
340
340
  message?: undefined;
341
341
  } | {
342
- deleted?: undefined;
343
342
  count?: undefined;
344
- providers?: undefined;
345
343
  provider?: undefined;
344
+ deleted?: undefined;
345
+ providers?: undefined;
346
346
  found: boolean;
347
347
  id: string;
348
348
  registered?: undefined;
349
349
  label?: undefined;
350
350
  message?: undefined;
351
351
  } | {
352
- found?: undefined;
353
352
  count?: undefined;
354
- providers?: undefined;
355
353
  provider?: undefined;
354
+ found?: undefined;
355
+ providers?: undefined;
356
356
  deleted: boolean;
357
357
  id: string;
358
358
  registered?: undefined;
359
359
  label?: undefined;
360
360
  message?: undefined;
361
361
  } | {
362
+ count?: undefined;
363
+ provider?: undefined;
362
364
  deleted?: undefined;
363
365
  found?: undefined;
364
- count?: undefined;
365
366
  providers?: undefined;
366
- provider?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -73,7 +73,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
73
73
  offset?: unknown;
74
74
  limit?: unknown;
75
75
  }, {
76
- deleted?: undefined;
77
76
  jobs: {
78
77
  id: string;
79
78
  name: string;
@@ -84,6 +83,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
84
83
  updatedAt: string;
85
84
  }[];
86
85
  total: number;
86
+ deleted?: undefined;
87
87
  jobId?: undefined;
88
88
  } | {
89
89
  jobs?: undefined;
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
91
91
  deleted: boolean;
92
92
  jobId: string;
93
93
  } | {
94
- deleted?: undefined;
95
94
  jobs?: undefined;
96
95
  total?: undefined;
96
+ deleted?: undefined;
97
97
  jobId?: undefined;
98
98
  hits: Record<string, unknown>[];
99
99
  offset: number;
@@ -1,3 +1,4 @@
1
+ import type { ReviewActorKind, ReviewCommentKind } from "../types.js";
1
2
  declare const _default: import("../../action.js").ActionDefinition<{
2
3
  resourceType: string;
3
4
  resourceId: string;
@@ -13,6 +14,36 @@ declare const _default: import("../../action.js").ActionDefinition<{
13
14
  id?: string;
14
15
  }[];
15
16
  metadata?: Record<string, unknown>;
16
- }, import("../types.js").ReviewComment>;
17
+ }, {
18
+ id: string;
19
+ resourceType: string;
20
+ resourceId: string;
21
+ threadId: string;
22
+ parentCommentId: string | null;
23
+ targetId: string | null;
24
+ kind: ReviewCommentKind;
25
+ status: import("../types.js").ReviewCommentStatus;
26
+ anchor: unknown | null;
27
+ body: string;
28
+ authorEmail: string | null;
29
+ authorName: string | null;
30
+ createdBy: ReviewActorKind;
31
+ resolutionTarget: import("../types.js").ReviewResolutionTarget | null;
32
+ mentions: import("../types.js").ReviewMention[];
33
+ ownerEmail: string | null;
34
+ orgId: string | null;
35
+ visibility: import("../../sharing/schema.js").Visibility;
36
+ resolvedBy: string | null;
37
+ resolvedAt: string | null;
38
+ consumedAt: string | null;
39
+ deletedBy: string | null;
40
+ deletedAt: string | null;
41
+ createdAt: string;
42
+ updatedAt: string;
43
+ metadata: Record<string, unknown> | null;
44
+ resolutionNote?: string | null;
45
+ canDelete?: boolean;
46
+ notified: import("../../server/activity-notifications.js").ActivityNotificationResult;
47
+ }>;
17
48
  export default _default;
18
49
  //# sourceMappingURL=create-review-comment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-review-comment.d.ts","sourceRoot":"","sources":["../../../src/review/actions/create-review-comment.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"create-review-comment.d.ts","sourceRoot":"","sources":["../../../src/review/actions/create-review-comment.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAElB,MAAM,aAAa,CAAC"}
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { defineAction } from "../../action.js";
3
3
  import { reviewAuthorNameFromContext } from "../identity.js";
4
4
  import { extractReviewMentions, normalizeReviewMentions } from "../mentions.js";
5
+ import { notifyReviewComment } from "../notifications.js";
5
6
  import { assertReviewableResourceAccess, normalizeReviewVisibility, } from "../registry.js";
6
7
  import { insertReviewComment } from "../store.js";
7
8
  const mentionSchema = z.object({
@@ -41,7 +42,7 @@ export default defineAction({
41
42
  ...extractReviewMentions(args.body),
42
43
  ]);
43
44
  const resolutionTarget = args.resolutionTarget ?? (mentions.length > 0 ? "human" : "agent");
44
- return insertReviewComment({
45
+ const comment = await insertReviewComment({
45
46
  resourceType: args.resourceType,
46
47
  resourceId: args.resourceId,
47
48
  targetId: args.targetId ?? null,
@@ -58,6 +59,7 @@ export default defineAction({
58
59
  visibility: normalizeReviewVisibility(access.visibility),
59
60
  metadata: args.metadata,
60
61
  });
62
+ return { ...comment, notified: await notifyReviewComment(comment) };
61
63
  },
62
64
  audit: {
63
65
  target: (args, result) => {
@@ -1 +1 @@
1
- {"version":3,"file":"create-review-comment.js","sourceRoot":"","sources":["../../../src/review/actions/create-review-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOlD,MAAM,aAA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M,CAAC,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,IAAI;YAC/C,UAAU,EAAE,yBAAyB,CAAC,MAAM,CAAC,UAAU,CAAC;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;IACL,CAAC;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAIf,CAAC;YACF,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,YAAY;gBACvB,EAAE,EAAE,IAAI,CAAC,UAAU;gBACnB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAC3B,GAAsC;IAEtC,MAAM,MAAM,GAAG,OAAO,GAAG,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { reviewAuthorNameFromContext } from \"../identity.js\";\nimport { extractReviewMentions, normalizeReviewMentions } from \"../mentions.js\";\nimport {\n assertReviewableResourceAccess,\n normalizeReviewVisibility,\n} from \"../registry.js\";\nimport { insertReviewComment } from \"../store.js\";\nimport type {\n ReviewActorKind,\n ReviewCommentKind,\n ReviewResourceContext,\n} from \"../types.js\";\n\nconst mentionSchema = z.object({\n label: z.string().min(1),\n email: z.string().email().nullable().optional(),\n id: z.string().nullable().optional(),\n});\n\nconst schema = z.object({\n resourceType: z.string().min(1),\n resourceId: z.string().min(1),\n targetId: z.string().nullable().optional(),\n kind: z\n .enum([\n \"comment\",\n \"annotation\",\n \"correction\",\n \"question\",\n \"decision\",\n \"review\",\n ])\n .optional(),\n anchor: z.unknown().nullable().optional(),\n body: z.string().min(1),\n authorName: z.string().nullable().optional(),\n resolutionTarget: z.enum([\"agent\", \"human\"]).nullable().optional(),\n mentions: z.array(mentionSchema).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport default defineAction({\n description:\n \"Create an inline comment, annotation, or review thread for a resource.\",\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 \"viewer\",\n );\n const mentions = normalizeReviewMentions([\n ...normalizeReviewMentions(args.mentions),\n ...extractReviewMentions(args.body),\n ]);\n const resolutionTarget =\n args.resolutionTarget ?? (mentions.length > 0 ? \"human\" : \"agent\");\n\n return insertReviewComment({\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n targetId: args.targetId ?? null,\n kind: (args.kind ?? \"comment\") as ReviewCommentKind,\n anchor: args.anchor ?? null,\n body: args.body,\n authorEmail: actionCtx?.userEmail ?? null,\n authorName: args.authorName ?? reviewAuthorNameFromContext(actionCtx),\n createdBy: actorKindFromContext(actionCtx),\n resolutionTarget,\n mentions,\n ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,\n orgId: access.orgId ?? actionCtx?.orgId ?? null,\n visibility: normalizeReviewVisibility(access.visibility),\n metadata: args.metadata,\n });\n },\n audit: {\n target: (args, result) => {\n const comment = 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: comment.ownerEmail,\n orgId: comment.orgId,\n visibility: comment.visibility,\n };\n },\n },\n});\n\nfunction actorKindFromContext(\n ctx: ReviewResourceContext | undefined,\n): ReviewActorKind {\n const caller = typeof ctx?.caller === \"string\" ? ctx.caller : \"\";\n if (caller === \"agent\" || caller === \"tool\") {\n return \"agent\";\n }\n return ctx?.userEmail ? \"human\" : \"system\";\n}\n"]}
1
+ {"version":3,"file":"create-review-comment.js","sourceRoot":"","sources":["../../../src/review/actions/create-review-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOlD,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC/C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAEH,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,QAAQ,EAAE,CAAC,QAAQ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OAAO,CAAC,UAAU;aAC/B,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAC3B,GAAsC;IAEtC,MAAM,MAAM,GAAG,OAAO,GAAG,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { reviewAuthorNameFromContext } from \"../identity.js\";\nimport { extractReviewMentions, normalizeReviewMentions } from \"../mentions.js\";\nimport { notifyReviewComment } from \"../notifications.js\";\nimport {\n assertReviewableResourceAccess,\n normalizeReviewVisibility,\n} from \"../registry.js\";\nimport { insertReviewComment } from \"../store.js\";\nimport type {\n ReviewActorKind,\n ReviewCommentKind,\n ReviewResourceContext,\n} from \"../types.js\";\n\nconst mentionSchema = z.object({\n label: z.string().min(1),\n email: z.string().email().nullable().optional(),\n id: z.string().nullable().optional(),\n});\n\nconst schema = z.object({\n resourceType: z.string().min(1),\n resourceId: z.string().min(1),\n targetId: z.string().nullable().optional(),\n kind: z\n .enum([\n \"comment\",\n \"annotation\",\n \"correction\",\n \"question\",\n \"decision\",\n \"review\",\n ])\n .optional(),\n anchor: z.unknown().nullable().optional(),\n body: z.string().min(1),\n authorName: z.string().nullable().optional(),\n resolutionTarget: z.enum([\"agent\", \"human\"]).nullable().optional(),\n mentions: z.array(mentionSchema).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport default defineAction({\n description:\n \"Create an inline comment, annotation, or review thread for a resource.\",\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 \"viewer\",\n );\n const mentions = normalizeReviewMentions([\n ...normalizeReviewMentions(args.mentions),\n ...extractReviewMentions(args.body),\n ]);\n const resolutionTarget =\n args.resolutionTarget ?? (mentions.length > 0 ? \"human\" : \"agent\");\n\n const comment = await insertReviewComment({\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n targetId: args.targetId ?? null,\n kind: (args.kind ?? \"comment\") as ReviewCommentKind,\n anchor: args.anchor ?? null,\n body: args.body,\n authorEmail: actionCtx?.userEmail ?? null,\n authorName: args.authorName ?? reviewAuthorNameFromContext(actionCtx),\n createdBy: actorKindFromContext(actionCtx),\n resolutionTarget,\n mentions,\n ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,\n orgId: access.orgId ?? actionCtx?.orgId ?? null,\n visibility: normalizeReviewVisibility(access.visibility),\n metadata: args.metadata,\n });\n\n return { ...comment, notified: await notifyReviewComment(comment) };\n },\n audit: {\n target: (args, result) => {\n const comment = 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: comment.ownerEmail,\n orgId: comment.orgId,\n visibility: comment.visibility,\n };\n },\n },\n});\n\nfunction actorKindFromContext(\n ctx: ReviewResourceContext | undefined,\n): ReviewActorKind {\n const caller = typeof ctx?.caller === \"string\" ? ctx.caller : \"\";\n if (caller === \"agent\" || caller === \"tool\") {\n return \"agent\";\n }\n return ctx?.userEmail ? \"human\" : \"system\";\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { ReviewActorKind } from "../types.js";
1
2
  declare const _default: import("../../action.js").ActionDefinition<{
2
3
  resourceType: string;
3
4
  resourceId: string;
@@ -11,6 +12,36 @@ declare const _default: import("../../action.js").ActionDefinition<{
11
12
  id?: string;
12
13
  }[];
13
14
  metadata?: Record<string, unknown>;
14
- }, import("../types.js").ReviewComment>;
15
+ }, {
16
+ id: string;
17
+ resourceType: string;
18
+ resourceId: string;
19
+ threadId: string;
20
+ parentCommentId: string | null;
21
+ targetId: string | null;
22
+ kind: import("../types.js").ReviewCommentKind;
23
+ status: import("../types.js").ReviewCommentStatus;
24
+ anchor: unknown | null;
25
+ body: string;
26
+ authorEmail: string | null;
27
+ authorName: string | null;
28
+ createdBy: ReviewActorKind;
29
+ resolutionTarget: import("../types.js").ReviewResolutionTarget | null;
30
+ mentions: import("../types.js").ReviewMention[];
31
+ ownerEmail: string | null;
32
+ orgId: string | null;
33
+ visibility: import("../../sharing/schema.js").Visibility;
34
+ resolvedBy: string | null;
35
+ resolvedAt: string | null;
36
+ consumedAt: string | null;
37
+ deletedBy: string | null;
38
+ deletedAt: string | null;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ metadata: Record<string, unknown> | null;
42
+ resolutionNote?: string | null;
43
+ canDelete?: boolean;
44
+ notified: import("../../server/activity-notifications.js").ActivityNotificationResult;
45
+ }>;
15
46
  export default _default;
16
47
  //# sourceMappingURL=reply-review-comment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reply-review-comment.d.ts","sourceRoot":"","sources":["../../../src/review/actions/reply-review-comment.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"reply-review-comment.d.ts","sourceRoot":"","sources":["../../../src/review/actions/reply-review-comment.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,aAAa,CAAC"}
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { defineAction } from "../../action.js";
3
3
  import { reviewAuthorNameFromContext } from "../identity.js";
4
4
  import { extractReviewMentions, normalizeReviewMentions } from "../mentions.js";
5
+ import { notifyReviewComment } from "../notifications.js";
5
6
  import { assertReviewableResourceAccess, normalizeReviewVisibility, } from "../registry.js";
6
7
  import { getReviewCommentById, insertReviewReply } from "../store.js";
7
8
  const mentionSchema = z.object({
@@ -45,7 +46,7 @@ export default defineAction({
45
46
  ...extractReviewMentions(args.body),
46
47
  ]);
47
48
  const routeTarget = args.resolutionTarget ?? (mentions.length > 0 ? "human" : null);
48
- return insertReviewReply({
49
+ const reply = await insertReviewReply({
49
50
  resourceType: args.resourceType,
50
51
  resourceId: args.resourceId,
51
52
  threadId: parent.threadId,
@@ -67,6 +68,7 @@ export default defineAction({
67
68
  resourceType: args.resourceType,
68
69
  resourceId: args.resourceId,
69
70
  });
71
+ return { ...reply, notified: await notifyReviewComment(reply) };
70
72
  },
71
73
  audit: {
72
74
  target: (args, result) => {
@@ -1 +1 @@
1
- {"version":3,"file":"reply-review-comment.js","sourceRoot":"","sources":["../../../src/review/actions/reply-review-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGtE,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC/C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,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AC/C,UAAU,EAAE,yBAAyB,CAAC,MAAM,CAAC,UAAU,CAAC;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,EACD,WAAW,EACX;YACE,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CACF,CAAC;IACJ,CAAC;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAIf,CAAC;YACF,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,YAAY;gBACvB,EAAE,EAAE,IAAI,CAAC,UAAU;gBACnB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAC3B,GAAsC;IAEtC,MAAM,MAAM,GAAG,OAAO,GAAG,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { reviewAuthorNameFromContext } from \"../identity.js\";\nimport { extractReviewMentions, normalizeReviewMentions } from \"../mentions.js\";\nimport {\n assertReviewableResourceAccess,\n normalizeReviewVisibility,\n} from \"../registry.js\";\nimport { getReviewCommentById, insertReviewReply } from \"../store.js\";\nimport type { ReviewActorKind, ReviewResourceContext } from \"../types.js\";\n\nconst mentionSchema = z.object({\n label: z.string().min(1),\n email: z.string().email().nullable().optional(),\n id: z.string().nullable().optional(),\n});\n\nconst schema = z.object({\n resourceType: z.string().min(1),\n resourceId: z.string().min(1),\n commentId: z.string().min(1),\n body: z.string().min(1),\n authorName: z.string().nullable().optional(),\n resolutionTarget: z.enum([\"agent\", \"human\"]).nullable().optional(),\n mentions: z.array(mentionSchema).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport default defineAction({\n description: \"Reply to an existing review comment thread.\",\n schema,\n run: async (args, ctx) => {\n const actionCtx = ctx as ReviewResourceContext | undefined;\n const scope = {\n userEmail: actionCtx?.userEmail ?? null,\n orgId: actionCtx?.orgId ?? null,\n };\n const access = await assertReviewableResourceAccess(\n args.resourceType,\n args.resourceId,\n actionCtx,\n \"viewer\",\n );\n const parent = await getReviewCommentById(args.commentId, scope, {\n bypassScope: true,\n });\n if (\n !parent ||\n parent.resourceType !== args.resourceType ||\n parent.resourceId !== args.resourceId\n ) {\n throw new Error(\"Review comment not found\");\n }\n if (parent.status !== \"open\") {\n throw new Error(\"Review thread is not open\");\n }\n const mentions = normalizeReviewMentions([\n ...normalizeReviewMentions(args.mentions),\n ...extractReviewMentions(args.body),\n ]);\n\n const routeTarget =\n args.resolutionTarget ?? (mentions.length > 0 ? \"human\" : null);\n return insertReviewReply(\n {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n threadId: parent.threadId,\n parentCommentId: parent.id,\n targetId: parent.targetId,\n kind: parent.kind,\n anchor: parent.anchor,\n body: args.body,\n authorEmail: actionCtx?.userEmail ?? null,\n authorName: args.authorName ?? reviewAuthorNameFromContext(actionCtx),\n createdBy: actorKindFromContext(actionCtx),\n resolutionTarget: null,\n mentions,\n ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,\n orgId: access.orgId ?? actionCtx?.orgId ?? null,\n visibility: normalizeReviewVisibility(access.visibility),\n metadata: args.metadata,\n },\n routeTarget,\n {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n },\n );\n },\n audit: {\n target: (args, result) => {\n const comment = 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: comment.ownerEmail,\n orgId: comment.orgId,\n visibility: comment.visibility,\n };\n },\n },\n});\n\nfunction actorKindFromContext(\n ctx: ReviewResourceContext | undefined,\n): ReviewActorKind {\n const caller = typeof ctx?.caller === \"string\" ? ctx.caller : \"\";\n if (caller === \"agent\" || caller === \"tool\") {\n return \"agent\";\n }\n return ctx?.userEmail ? \"human\" : \"system\";\n}\n"]}
1
+ {"version":3,"file":"reply-review-comment.js","sourceRoot":"","sources":["../../../src/review/actions/reply-review-comment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGtE,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC/C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAA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IAAI,IAAI;YAC7D,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,IAAI;YAC/C,UAAU,EAAE,yBAAyB,CAAC,MAAM,CAAC,UAAU,CAAC;YACxD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,EACD,WAAW,EACX;YACE,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CACF,CAAC;QAEF,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;IAClE,CAAC;IACD,KAAK,EAAE;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACvB,MAAM,OAAO,GAAG,MAIf,CAAC;YACF,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,YAAY;gBACvB,EAAE,EAAE,IAAI,CAAC,UAAU;gBACnB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC;QACJ,CAAC;KACF;CACF,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAC3B,GAAsC;IAEtC,MAAM,MAAM,GAAG,OAAO,GAAG,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7C,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { defineAction } from \"../../action.js\";\nimport { reviewAuthorNameFromContext } from \"../identity.js\";\nimport { extractReviewMentions, normalizeReviewMentions } from \"../mentions.js\";\nimport { notifyReviewComment } from \"../notifications.js\";\nimport {\n assertReviewableResourceAccess,\n normalizeReviewVisibility,\n} from \"../registry.js\";\nimport { getReviewCommentById, insertReviewReply } from \"../store.js\";\nimport type { ReviewActorKind, ReviewResourceContext } from \"../types.js\";\n\nconst mentionSchema = z.object({\n label: z.string().min(1),\n email: z.string().email().nullable().optional(),\n id: z.string().nullable().optional(),\n});\n\nconst schema = z.object({\n resourceType: z.string().min(1),\n resourceId: z.string().min(1),\n commentId: z.string().min(1),\n body: z.string().min(1),\n authorName: z.string().nullable().optional(),\n resolutionTarget: z.enum([\"agent\", \"human\"]).nullable().optional(),\n mentions: z.array(mentionSchema).optional(),\n metadata: z.record(z.string(), z.unknown()).optional(),\n});\n\nexport default defineAction({\n description: \"Reply to an existing review comment thread.\",\n schema,\n run: async (args, ctx) => {\n const actionCtx = ctx as ReviewResourceContext | undefined;\n const scope = {\n userEmail: actionCtx?.userEmail ?? null,\n orgId: actionCtx?.orgId ?? null,\n };\n const access = await assertReviewableResourceAccess(\n args.resourceType,\n args.resourceId,\n actionCtx,\n \"viewer\",\n );\n const parent = await getReviewCommentById(args.commentId, scope, {\n bypassScope: true,\n });\n if (\n !parent ||\n parent.resourceType !== args.resourceType ||\n parent.resourceId !== args.resourceId\n ) {\n throw new Error(\"Review comment not found\");\n }\n if (parent.status !== \"open\") {\n throw new Error(\"Review thread is not open\");\n }\n const mentions = normalizeReviewMentions([\n ...normalizeReviewMentions(args.mentions),\n ...extractReviewMentions(args.body),\n ]);\n\n const routeTarget =\n args.resolutionTarget ?? (mentions.length > 0 ? \"human\" : null);\n const reply = await insertReviewReply(\n {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n threadId: parent.threadId,\n parentCommentId: parent.id,\n targetId: parent.targetId,\n kind: parent.kind,\n anchor: parent.anchor,\n body: args.body,\n authorEmail: actionCtx?.userEmail ?? null,\n authorName: args.authorName ?? reviewAuthorNameFromContext(actionCtx),\n createdBy: actorKindFromContext(actionCtx),\n resolutionTarget: null,\n mentions,\n ownerEmail: access.ownerEmail ?? actionCtx?.userEmail ?? null,\n orgId: access.orgId ?? actionCtx?.orgId ?? null,\n visibility: normalizeReviewVisibility(access.visibility),\n metadata: args.metadata,\n },\n routeTarget,\n {\n resourceType: args.resourceType,\n resourceId: args.resourceId,\n },\n );\n\n return { ...reply, notified: await notifyReviewComment(reply) };\n },\n audit: {\n target: (args, result) => {\n const comment = 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: comment.ownerEmail,\n orgId: comment.orgId,\n visibility: comment.visibility,\n };\n },\n },\n});\n\nfunction actorKindFromContext(\n ctx: ReviewResourceContext | undefined,\n): ReviewActorKind {\n const caller = typeof ctx?.caller === \"string\" ? ctx.caller : \"\";\n if (caller === \"agent\" || caller === \"tool\") {\n return \"agent\";\n }\n return ctx?.userEmail ? \"human\" : \"system\";\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  export type { ReviewActorKind, ReviewComment, ReviewCommentKind, ReviewCommentStatus, ReviewMention, ReviewResolutionTarget, ReviewResourceAccess, ReviewResourceContext, ReviewResourceRole, ReviewScope, ReviewStatus, ReviewStatusEntry, ReviewableResourceRegistration, } from "./types.js";
2
2
  export { redactPublicReviewCommentIdentity, redactPublicReviewStatusIdentity, reviewAuthorNameFromContext, shouldRedactReviewIdentity, } from "./identity.js";
3
3
  export { extractReviewMentions, normalizeReviewMentions } from "./mentions.js";
4
+ export { notifyReviewComment, REVIEW_NOTIFICATION_PREFS_KEY, type ReviewNotificationResult, } from "./notifications.js";
4
5
  export { __resetReviewableResourcesForTests, assertReviewableResourceAccess, getReviewableResource, listReviewableResources, registerReviewableResource, resolveReviewableResourceAccess, } from "./registry.js";
5
6
  export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, getReviewThreadSummary, getReviewThreadRoot, queryReviewComments, routeReviewThread, sendReviewThreadToAgent, } from "./store.js";
6
7
  export type { GetReviewThreadSummaryInput, ReviewThreadSummary, } from "./store.js";
@@ -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,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
+ {"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,mBAAmB,EACnB,6BAA6B,EAC7B,KAAK,wBAAwB,GAC9B,MAAM,oBAAoB,CAAC;AAC5B,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,5 +1,6 @@
1
1
  export { redactPublicReviewCommentIdentity, redactPublicReviewStatusIdentity, reviewAuthorNameFromContext, shouldRedactReviewIdentity, } from "./identity.js";
2
2
  export { extractReviewMentions, normalizeReviewMentions } from "./mentions.js";
3
+ export { notifyReviewComment, REVIEW_NOTIFICATION_PREFS_KEY, } from "./notifications.js";
3
4
  export { __resetReviewableResourcesForTests, assertReviewableResourceAccess, getReviewableResource, listReviewableResources, registerReviewableResource, resolveReviewableResourceAccess, } from "./registry.js";
4
5
  export { __resetReviewInitForTests, ensureReviewTables, getReviewCommentById, getReviewStatus, getReviewThreadSummary, getReviewThreadRoot, queryReviewComments, routeReviewThread, sendReviewThreadToAgent, } from "./store.js";
5
6
  //# sourceMappingURL=index.js.map