@agent-native/core 0.130.1 → 0.131.2

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 (909) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +57 -0
  3. package/corpus/core/docs/content/agent-surfaces.mdx +4 -4
  4. package/corpus/core/docs/content/automations.mdx +61 -12
  5. package/corpus/core/docs/content/deployment.mdx +11 -4
  6. package/corpus/core/docs/content/extensions.mdx +39 -33
  7. package/corpus/core/docs/content/recurring-jobs.mdx +41 -19
  8. package/corpus/core/docs/content/template-dispatch-operations.mdx +19 -7
  9. package/corpus/core/package.json +3 -1
  10. package/corpus/core/src/action.ts +55 -0
  11. package/corpus/core/src/agent/engine/builder-engine.ts +8 -4
  12. package/corpus/core/src/agent/production-agent.ts +175 -100
  13. package/corpus/core/src/agent/tool-search.ts +36 -0
  14. package/corpus/core/src/automations/service.ts +506 -0
  15. package/corpus/core/src/browser-context/index.ts +392 -0
  16. package/corpus/core/src/client/AgentPanel.tsx +2 -1
  17. package/corpus/core/src/client/FeedbackButton.tsx +37 -4
  18. package/corpus/core/src/client/MultiTabAssistantChat.tsx +21 -0
  19. package/corpus/core/src/client/agent-chat.ts +31 -3
  20. package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +438 -310
  21. package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +4 -4
  22. package/corpus/core/src/client/agent-page/use-jobs.ts +7 -0
  23. package/corpus/core/src/client/analytics-session.ts +13 -0
  24. package/corpus/core/src/client/extensions/ExtensionViewer.tsx +67 -0
  25. package/corpus/core/src/client/settings/AutomationsSection.tsx +27 -499
  26. package/corpus/core/src/client/settings/SettingsPanel.tsx +32 -11
  27. package/corpus/core/src/client/settings/index.ts +2 -0
  28. package/corpus/core/src/client/use-agent-chat.ts +35 -3
  29. package/corpus/core/src/client/use-chat-threads.ts +8 -25
  30. package/corpus/core/src/deploy/build.ts +2 -0
  31. package/corpus/core/src/deploy/workspace-deploy.ts +2 -0
  32. package/corpus/core/src/extensions/actions.ts +115 -3
  33. package/corpus/core/src/extensions/fetch-tool.ts +11 -0
  34. package/corpus/core/src/extensions/routes.ts +16 -1
  35. package/corpus/core/src/extensions/web-content.ts +96 -1
  36. package/corpus/core/src/integrations/computer-supervision.ts +33 -1
  37. package/corpus/core/src/integrations/index.ts +6 -0
  38. package/corpus/core/src/integrations/integration-durable-dispatch-config.ts +10 -0
  39. package/corpus/core/src/integrations/integration-durable-dispatch.ts +4 -0
  40. package/corpus/core/src/integrations/plugin.ts +94 -41
  41. package/corpus/core/src/integrations/remote-browser-actions.ts +621 -0
  42. package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +5 -7
  43. package/corpus/core/src/jobs/actions/manage-recurring-job.ts +3 -7
  44. package/corpus/core/src/jobs/background-automation-runner.ts +437 -0
  45. package/corpus/core/src/jobs/frontmatter.ts +308 -0
  46. package/corpus/core/src/jobs/scheduler.ts +89 -598
  47. package/corpus/core/src/jobs/tools.ts +22 -3
  48. package/corpus/core/src/localization/default-messages.ts +45 -45
  49. package/corpus/core/src/mcp-client/index.ts +6 -0
  50. package/corpus/core/src/notifications/actions.ts +5 -0
  51. package/corpus/core/src/progress/actions.ts +5 -0
  52. package/corpus/core/src/provider-api/actions/github-repo-files.ts +11 -0
  53. package/corpus/core/src/provider-api/actions/provider-api.ts +13 -0
  54. package/corpus/core/src/server/action-discovery.ts +7 -0
  55. package/corpus/core/src/server/agent-chat/browser-team-tools.ts +126 -3
  56. package/corpus/core/src/server/agent-chat/framework-prompts.ts +7 -11
  57. package/corpus/core/src/server/agent-chat/plugin-options.ts +3 -3
  58. package/corpus/core/src/server/agent-chat/script-entries.ts +52 -1
  59. package/corpus/core/src/server/agent-chat-plugin.ts +25 -5
  60. package/corpus/core/src/server/attribution.ts +22 -0
  61. package/corpus/core/src/server/auth.ts +20 -6
  62. package/corpus/core/src/server/better-auth-instance.ts +10 -2
  63. package/corpus/core/src/server/core-routes-plugin.ts +10 -1
  64. package/corpus/core/src/server/csrf.ts +25 -0
  65. package/corpus/core/src/server/email-template.ts +43 -13
  66. package/corpus/core/src/server/google-oauth.ts +21 -1
  67. package/corpus/core/src/server/onboarding-html.ts +18 -0
  68. package/corpus/core/src/server/prompts/framework-core-compact.ts +3 -3
  69. package/corpus/core/src/server/prompts/framework-core.ts +3 -3
  70. package/corpus/core/src/server/prompts/shared-rules.ts +3 -3
  71. package/corpus/core/src/settings/index.ts +1 -0
  72. package/corpus/core/src/shared/analytics-anonymous-id.ts +35 -0
  73. package/corpus/core/src/sharing/actions/share-resource.ts +26 -4
  74. package/corpus/core/src/sharing/index.ts +1 -0
  75. package/corpus/core/src/sharing/registry.ts +23 -0
  76. package/corpus/core/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  77. package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +26 -0
  78. package/corpus/core/src/templates/default/app/i18n/de-DE.ts +28 -0
  79. package/corpus/core/src/templates/default/app/i18n/en-US.ts +27 -0
  80. package/corpus/core/src/templates/default/app/i18n/es-ES.ts +28 -0
  81. package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +28 -0
  82. package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +25 -0
  83. package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +27 -0
  84. package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +27 -0
  85. package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +27 -0
  86. package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +24 -0
  87. package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +24 -0
  88. package/corpus/core/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  89. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  90. package/corpus/core/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
  91. package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
  92. package/corpus/core/src/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
  93. package/corpus/core/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
  94. package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
  95. package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
  96. package/corpus/core/src/tracking/providers.ts +1 -0
  97. package/corpus/core/src/tracking/registry.ts +2 -1
  98. package/corpus/core/src/tracking/types.ts +1 -0
  99. package/corpus/core/src/triggers/actions/list-automations.ts +43 -44
  100. package/corpus/core/src/triggers/actions/manage-automation.ts +17 -48
  101. package/corpus/core/src/triggers/actions.ts +218 -127
  102. package/corpus/core/src/triggers/dispatcher.ts +181 -367
  103. package/corpus/core/src/triggers/routes.ts +84 -27
  104. package/corpus/core/src/triggers/types.ts +9 -23
  105. package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  106. package/corpus/templates/analytics/actions/install-dashboard-template.ts +13 -4
  107. package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -3
  108. package/corpus/templates/analytics/actions/restore-dashboard-revision.ts +8 -3
  109. package/corpus/templates/analytics/actions/update-dashboard.ts +22 -5
  110. package/corpus/templates/analytics/app/components/dashboard/DashboardPanelSkeleton.tsx +7 -1
  111. package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +1 -82
  112. package/corpus/templates/analytics/app/components/layout/NewDashboardDialog.tsx +4 -4
  113. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +23 -13
  114. package/corpus/templates/analytics/app/global.css +21 -0
  115. package/corpus/templates/analytics/app/i18n-data.ts +165 -101
  116. package/corpus/templates/analytics/app/lib/custom-block-promotion.ts +62 -0
  117. package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +17 -2
  118. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/PanelEditorDialog.tsx +3 -1
  119. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +77 -12
  120. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/dashboard-save-queue.ts +34 -0
  121. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +42 -26
  122. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +15 -0
  123. package/corpus/templates/analytics/app/pages/analyses/AnalysisDetail.tsx +1 -1
  124. package/corpus/templates/analytics/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
  125. package/corpus/templates/analytics/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-the-dashboard.md +6 -0
  126. package/corpus/templates/analytics/changelog/2026-07-29-custom-dashboard-blocks-now-identify-one-off-agent-patches-a.md +6 -0
  127. package/corpus/templates/analytics/changelog/2026-07-29-dashboard-chart-deletions-now-save-in-order-so-removed-rows-.md +6 -0
  128. package/corpus/templates/analytics/changelog/2026-07-29-dashboard-chart-loaders-are-easier-to-see-and-animate-more-s.md +6 -0
  129. package/corpus/templates/analytics/changelog/2026-07-29-plan-mode-can-now-query-connected-analytics-sources-while-ke.md +6 -0
  130. package/corpus/templates/analytics/changelog/2026-07-29-plan-mode-can-use-clips-as-read-only-prompt-context.md +6 -0
  131. package/corpus/templates/analytics/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  132. package/corpus/templates/analytics/changelog/2026-07-29-signup-entry-pages-now-show-the-first-page-viewed-before-eac.md +6 -0
  133. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +26 -1
  134. package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +0 -33
  135. package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +13 -3
  136. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +9 -1
  137. package/corpus/templates/analytics/server/lib/first-party-analytics.ts +44 -1
  138. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +96 -16
  139. package/corpus/templates/analytics/server/plugins/agent-chat.ts +18 -27
  140. package/corpus/templates/analytics/server/plugins/core-routes.ts +1 -0
  141. package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  142. package/corpus/templates/assets/app/components/layout/Sidebar.tsx +4 -8
  143. package/corpus/templates/assets/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
  144. package/corpus/templates/assets/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-the-workspace.md +6 -0
  145. package/corpus/templates/assets/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  146. package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  147. package/corpus/templates/brain/app/components/layout/Sidebar.tsx +3 -7
  148. package/corpus/templates/brain/app/root.tsx +0 -3
  149. package/corpus/templates/brain/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
  150. package/corpus/templates/brain/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-ask-brain.md +6 -0
  151. package/corpus/templates/brain/changelog/2026-07-29-extensions-are-no-longer-shown-as-a-default-command-menu-des.md +6 -0
  152. package/corpus/templates/brain/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  153. package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  154. package/corpus/templates/calendar/.agents/skills/event-management/SKILL.md +25 -5
  155. package/corpus/templates/calendar/AGENTS.md +5 -0
  156. package/corpus/templates/calendar/actions/create-event.ts +43 -13
  157. package/corpus/templates/calendar/actions/event-action-helpers.ts +131 -1
  158. package/corpus/templates/calendar/actions/manage-event-draft.ts +65 -2
  159. package/corpus/templates/calendar/app/components/calendar/CreateEventDialog.tsx +437 -258
  160. package/corpus/templates/calendar/app/components/calendar/DayView.tsx +19 -3
  161. package/corpus/templates/calendar/app/components/calendar/MonthView.tsx +24 -0
  162. package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +15 -2
  163. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +1 -5
  164. package/corpus/templates/calendar/app/hooks/use-events.ts +44 -5
  165. package/corpus/templates/calendar/app/i18n-data.ts +50 -0
  166. package/corpus/templates/calendar/app/lib/all-day-layout.ts +9 -2
  167. package/corpus/templates/calendar/app/lib/event-form-initialization.ts +4 -8
  168. package/corpus/templates/calendar/app/lib/event-form-utils.ts +30 -8
  169. package/corpus/templates/calendar/app/lib/location-suggestions.ts +36 -0
  170. package/corpus/templates/calendar/app/lib/out-of-office.ts +87 -1
  171. package/corpus/templates/calendar/app/pages/CalendarView.tsx +68 -13
  172. package/corpus/templates/calendar/changelog/2026-07-26-out-of-office-events-now-default-to-full-days-with-a-ready.md +6 -0
  173. package/corpus/templates/calendar/changelog/2026-07-29-recent-calendar-locations-now-appear-as-address-suggestions-.md +6 -0
  174. package/corpus/templates/calendar/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  175. package/corpus/templates/calendar/server/lib/find-time.ts +29 -5
  176. package/corpus/templates/calendar/shared/api.ts +2 -0
  177. package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  178. package/corpus/templates/chat/app/components/layout/Sidebar.tsx +1 -5
  179. package/corpus/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  180. package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  181. package/corpus/templates/clips/app/components/editor/editor-toolbar.tsx +3 -1
  182. package/corpus/templates/clips/app/components/library/library-layout.tsx +2 -6
  183. package/corpus/templates/clips/app/components/meetings/day-header.tsx +1 -1
  184. package/corpus/templates/clips/app/components/meetings/transcript-bubbles.tsx +1 -22
  185. package/corpus/templates/clips/app/components/workspace/branding-editor.tsx +26 -1
  186. package/corpus/templates/clips/app/components/workspace/organization-identity-card.tsx +107 -0
  187. package/corpus/templates/clips/app/i18n/en-US.ts +3 -4
  188. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +0 -10
  189. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +23 -51
  190. package/corpus/templates/clips/app/routes/share.meeting.$meetingId.tsx +1 -8
  191. package/corpus/templates/clips/changelog/2026-07-29-clearing-all-recording-edits-no-longer-leaves-the-editor-unr.md +6 -0
  192. package/corpus/templates/clips/changelog/2026-07-29-clip-share-emails-now-open-with-who-shared-the-clip-add-a-su.md +6 -0
  193. package/corpus/templates/clips/changelog/2026-07-29-finished-meeting-pills-now-have-a-clear-close-button.md +6 -0
  194. package/corpus/templates/clips/changelog/2026-07-29-fixed-system-audio-recordings-picking-up-your-microphone-in-.md +6 -0
  195. package/corpus/templates/clips/changelog/2026-07-29-meeting-cards-no-longer-flicker-or-disappear-when-hovered-in.md +6 -0
  196. package/corpus/templates/clips/changelog/2026-07-29-organization-name-logo-brand-color-and-default-visibility-no.md +6 -0
  197. package/corpus/templates/clips/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  198. package/corpus/templates/clips/changelog/2026-07-29-the-desktop-camera-preview-now-closes-after-a-recording-fin.md +6 -0
  199. package/corpus/templates/clips/changelog/2026-07-29-transcript-lines-on-the-meeting-page-no-longer-jump-to-the-r.md +6 -0
  200. package/corpus/templates/clips/changelog/2026-07-29-when-a-meeting-wraps-up-the-recording-pill-now-shows-a-green.md +6 -0
  201. package/corpus/templates/clips/desktop/src/app.tsx +14 -15
  202. package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +6 -3
  203. package/corpus/templates/clips/desktop/src/lib/bubble-session.ts +11 -0
  204. package/corpus/templates/clips/desktop/src/lib/recorder.ts +9 -4
  205. package/corpus/templates/clips/desktop/src/lib/transcription-capture.ts +11 -0
  206. package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +112 -32
  207. package/corpus/templates/clips/desktop/src/styles.css +42 -2
  208. package/corpus/templates/clips/server/db/index.ts +6 -0
  209. package/corpus/templates/clips/server/jobs/transactional-emails.ts +47 -23
  210. package/corpus/templates/clips/server/lib/share-email-hero.ts +33 -0
  211. package/corpus/templates/clips/server/lib/transactional-email-store.ts +16 -6
  212. package/corpus/templates/clips/shared/clips-ai-prefs.ts +0 -1
  213. package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  214. package/corpus/templates/content/.agents/skills/content-product-development/SKILL.md +103 -0
  215. package/corpus/templates/content/.agents/skills/content-product-development/references/verification.md +57 -0
  216. package/corpus/templates/content/AGENTS.md +2 -0
  217. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -6
  218. package/corpus/templates/content/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  219. package/corpus/templates/content/docs/product/README.md +115 -0
  220. package/corpus/templates/content/docs/product/architecture.md +98 -0
  221. package/corpus/templates/content/docs/product/capabilities/content.access.page-database.md +76 -0
  222. package/corpus/templates/content/docs/product/capabilities/content.access.row-private.md +75 -0
  223. package/corpus/templates/content/docs/product/capabilities/content.access.safe-aggregate.md +75 -0
  224. package/corpus/templates/content/docs/product/capabilities/content.access.visibility-closure.md +79 -0
  225. package/corpus/templates/content/docs/product/capabilities/content.action.button.md +67 -0
  226. package/corpus/templates/content/docs/product/capabilities/content.agent.action-parity.md +73 -0
  227. package/corpus/templates/content/docs/product/capabilities/content.agent.audience-safe.md +91 -0
  228. package/corpus/templates/content/docs/product/capabilities/content.agent.automation.md +67 -0
  229. package/corpus/templates/content/docs/product/capabilities/content.agent.expression-authoring.md +71 -0
  230. package/corpus/templates/content/docs/product/capabilities/content.agent.presence.md +103 -0
  231. package/corpus/templates/content/docs/product/capabilities/content.agent.resource-consent.md +90 -0
  232. package/corpus/templates/content/docs/product/capabilities/content.agent.skill-catalog.md +67 -0
  233. package/corpus/templates/content/docs/product/capabilities/content.api.cms.md +70 -0
  234. package/corpus/templates/content/docs/product/capabilities/content.author.code.md +71 -0
  235. package/corpus/templates/content/docs/product/capabilities/content.author.document-editor.md +71 -0
  236. package/corpus/templates/content/docs/product/capabilities/content.author.footnotes.md +71 -0
  237. package/corpus/templates/content/docs/product/capabilities/content.author.math.md +71 -0
  238. package/corpus/templates/content/docs/product/capabilities/content.author.media.md +71 -0
  239. package/corpus/templates/content/docs/product/capabilities/content.author.mermaid.md +71 -0
  240. package/corpus/templates/content/docs/product/capabilities/content.automation.scheduled.md +67 -0
  241. package/corpus/templates/content/docs/product/capabilities/content.capture.enrich.md +75 -0
  242. package/corpus/templates/content/docs/product/capabilities/content.command.fabric.md +67 -0
  243. package/corpus/templates/content/docs/product/capabilities/content.comment.page-owned.md +75 -0
  244. package/corpus/templates/content/docs/product/capabilities/content.diff.ai-assist.md +75 -0
  245. package/corpus/templates/content/docs/product/capabilities/content.diff.filtered-review.md +79 -0
  246. package/corpus/templates/content/docs/product/capabilities/content.diff.in-place.md +80 -0
  247. package/corpus/templates/content/docs/product/capabilities/content.discussion.page.md +80 -0
  248. package/corpus/templates/content/docs/product/capabilities/content.embed.host-grant.md +70 -0
  249. package/corpus/templates/content/docs/product/capabilities/content.embed.mcp-app.md +69 -0
  250. package/corpus/templates/content/docs/product/capabilities/content.embed.surface.md +74 -0
  251. package/corpus/templates/content/docs/product/capabilities/content.event.committed.md +85 -0
  252. package/corpus/templates/content/docs/product/capabilities/content.expression.cached-result.md +71 -0
  253. package/corpus/templates/content/docs/product/capabilities/content.expression.catalog.md +71 -0
  254. package/corpus/templates/content/docs/product/capabilities/content.expression.language.md +76 -0
  255. package/corpus/templates/content/docs/product/capabilities/content.feedback.signal.md +67 -0
  256. package/corpus/templates/content/docs/product/capabilities/content.form.shared-engine.md +72 -0
  257. package/corpus/templates/content/docs/product/capabilities/content.history.queryable.md +79 -0
  258. package/corpus/templates/content/docs/product/capabilities/content.home.global.md +80 -0
  259. package/corpus/templates/content/docs/product/capabilities/content.job.durable.md +76 -0
  260. package/corpus/templates/content/docs/product/capabilities/content.knowledge.graph.md +67 -0
  261. package/corpus/templates/content/docs/product/capabilities/content.knowledge.links.md +67 -0
  262. package/corpus/templates/content/docs/product/capabilities/content.knowledge.search.md +67 -0
  263. package/corpus/templates/content/docs/product/capabilities/content.layout.responsive.md +80 -0
  264. package/corpus/templates/content/docs/product/capabilities/content.navigation.sidebar.md +86 -0
  265. package/corpus/templates/content/docs/product/capabilities/content.notification.source.md +71 -0
  266. package/corpus/templates/content/docs/product/capabilities/content.object.block.md +76 -0
  267. package/corpus/templates/content/docs/product/capabilities/content.object.blocks-field.md +79 -0
  268. package/corpus/templates/content/docs/product/capabilities/content.object.database.md +92 -0
  269. package/corpus/templates/content/docs/product/capabilities/content.object.multi-membership.md +75 -0
  270. package/corpus/templates/content/docs/product/capabilities/content.object.page.md +76 -0
  271. package/corpus/templates/content/docs/product/capabilities/content.object.reference.md +75 -0
  272. package/corpus/templates/content/docs/product/capabilities/content.object.transclusion.md +75 -0
  273. package/corpus/templates/content/docs/product/capabilities/content.organization.teams.md +71 -0
  274. package/corpus/templates/content/docs/product/capabilities/content.portability.pdf-export.md +78 -0
  275. package/corpus/templates/content/docs/product/capabilities/content.portability.roundtrip.md +154 -0
  276. package/corpus/templates/content/docs/product/capabilities/content.portability.source-representation.md +70 -0
  277. package/corpus/templates/content/docs/product/capabilities/content.portability.vault-export.md +80 -0
  278. package/corpus/templates/content/docs/product/capabilities/content.presentation.mode.md +76 -0
  279. package/corpus/templates/content/docs/product/capabilities/content.preset.catalog.md +71 -0
  280. package/corpus/templates/content/docs/product/capabilities/content.property.actor.md +75 -0
  281. package/corpus/templates/content/docs/product/capabilities/content.property.catalog.md +76 -0
  282. package/corpus/templates/content/docs/product/capabilities/content.property.constraints.md +75 -0
  283. package/corpus/templates/content/docs/product/capabilities/content.property.guarded-change.md +76 -0
  284. package/corpus/templates/content/docs/product/capabilities/content.property.location.md +71 -0
  285. package/corpus/templates/content/docs/product/capabilities/content.property.typed.md +71 -0
  286. package/corpus/templates/content/docs/product/capabilities/content.publish.public.md +75 -0
  287. package/corpus/templates/content/docs/product/capabilities/content.publish.reading.md +74 -0
  288. package/corpus/templates/content/docs/product/capabilities/content.query.object.md +114 -0
  289. package/corpus/templates/content/docs/product/capabilities/content.reader.documents.md +69 -0
  290. package/corpus/templates/content/docs/product/capabilities/content.reader.surface.md +75 -0
  291. package/corpus/templates/content/docs/product/capabilities/content.relationship.edge.md +183 -0
  292. package/corpus/templates/content/docs/product/capabilities/content.renderer.artifact-block.md +71 -0
  293. package/corpus/templates/content/docs/product/capabilities/content.renderer.custom-block.md +81 -0
  294. package/corpus/templates/content/docs/product/capabilities/content.renderer.graph.md +71 -0
  295. package/corpus/templates/content/docs/product/capabilities/content.renderer.typed.md +92 -0
  296. package/corpus/templates/content/docs/product/capabilities/content.research.annotation.md +75 -0
  297. package/corpus/templates/content/docs/product/capabilities/content.research.citation.md +70 -0
  298. package/corpus/templates/content/docs/product/capabilities/content.review.code.md +67 -0
  299. package/corpus/templates/content/docs/product/capabilities/content.revision.suggestions.md +76 -0
  300. package/corpus/templates/content/docs/product/capabilities/content.rule.deterministic.md +79 -0
  301. package/corpus/templates/content/docs/product/capabilities/content.schedule.constraints.md +81 -0
  302. package/corpus/templates/content/docs/product/capabilities/content.security.private-vault.md +71 -0
  303. package/corpus/templates/content/docs/product/capabilities/content.share.views.md +140 -0
  304. package/corpus/templates/content/docs/product/capabilities/content.source.adapters.md +154 -0
  305. package/corpus/templates/content/docs/product/capabilities/content.source.builder-codec.md +70 -0
  306. package/corpus/templates/content/docs/product/capabilities/content.source.catalog.md +149 -0
  307. package/corpus/templates/content/docs/product/capabilities/content.source.file-folder.md +71 -0
  308. package/corpus/templates/content/docs/product/capabilities/content.source.local-bridge.md +156 -0
  309. package/corpus/templates/content/docs/product/capabilities/content.source.local-project.md +70 -0
  310. package/corpus/templates/content/docs/product/capabilities/content.source.page-link.md +70 -0
  311. package/corpus/templates/content/docs/product/capabilities/content.source.row-union.md +69 -0
  312. package/corpus/templates/content/docs/product/capabilities/content.source.spaces-files.md +75 -0
  313. package/corpus/templates/content/docs/product/capabilities/content.source.sync-policy.md +161 -0
  314. package/corpus/templates/content/docs/product/capabilities/content.system.dependencies.md +80 -0
  315. package/corpus/templates/content/docs/product/capabilities/content.system.my-tasks.md +75 -0
  316. package/corpus/templates/content/docs/product/capabilities/content.system.project-status.md +77 -0
  317. package/corpus/templates/content/docs/product/capabilities/content.system.research-workspace.md +80 -0
  318. package/corpus/templates/content/docs/product/capabilities/content.system.task-project.md +76 -0
  319. package/corpus/templates/content/docs/product/capabilities/content.template.governance.md +76 -0
  320. package/corpus/templates/content/docs/product/capabilities/content.template.graph.md +76 -0
  321. package/corpus/templates/content/docs/product/capabilities/content.template.item-body.md +71 -0
  322. package/corpus/templates/content/docs/product/capabilities/content.template.update.md +71 -0
  323. package/corpus/templates/content/docs/product/capabilities/content.time.types.md +85 -0
  324. package/corpus/templates/content/docs/product/capabilities/content.version.branching.md +151 -0
  325. package/corpus/templates/content/docs/product/capabilities/content.version.field-history.md +103 -0
  326. package/corpus/templates/content/docs/product/capabilities/content.view.canvas.md +94 -0
  327. package/corpus/templates/content/docs/product/capabilities/content.view.chart.md +91 -0
  328. package/corpus/templates/content/docs/product/capabilities/content.view.dynamic-create.md +137 -0
  329. package/corpus/templates/content/docs/product/capabilities/content.view.fast-capture.md +82 -0
  330. package/corpus/templates/content/docs/product/capabilities/content.view.graph.md +95 -0
  331. package/corpus/templates/content/docs/product/capabilities/content.view.grouping-aggregation.md +83 -0
  332. package/corpus/templates/content/docs/product/capabilities/content.view.map.md +77 -0
  333. package/corpus/templates/content/docs/product/capabilities/content.view.personal-state.md +99 -0
  334. package/corpus/templates/content/docs/product/capabilities/content.view.pivot.md +76 -0
  335. package/corpus/templates/content/docs/product/capabilities/content.view.query.md +106 -0
  336. package/corpus/templates/content/docs/product/capabilities/content.view.renderer-conformance.md +77 -0
  337. package/corpus/templates/content/docs/product/capabilities/content.view.scale.md +77 -0
  338. package/corpus/templates/content/docs/product/capabilities/content.view.source-query.md +159 -0
  339. package/corpus/templates/content/docs/product/capabilities/content.view.timeline.md +86 -0
  340. package/corpus/templates/content/docs/product/capabilities/content.view.tree.md +77 -0
  341. package/corpus/templates/content/docs/product/capabilities/content.workspace.multi-scope.md +80 -0
  342. package/corpus/templates/content/docs/product/capabilities/content.workspace.session-restore.md +76 -0
  343. package/corpus/templates/content/docs/product/capabilities/content.workspace.view-instance.md +76 -0
  344. package/corpus/templates/content/docs/product/capabilities/content.workspace.working-set.md +77 -0
  345. package/corpus/templates/content/docs/product/chapters/content.chapter.capture-research.md +20 -0
  346. package/corpus/templates/content/docs/product/chapters/content.chapter.connected-sources.md +20 -0
  347. package/corpus/templates/content/docs/product/chapters/content.chapter.consensus.md +19 -0
  348. package/corpus/templates/content/docs/product/chapters/content.chapter.durable-home.md +21 -0
  349. package/corpus/templates/content/docs/product/chapters/content.chapter.publishing-portability.md +21 -0
  350. package/corpus/templates/content/docs/product/chapters/content.chapter.working-systems.md +27 -0
  351. package/corpus/templates/content/docs/product/encyclopedia.md +559 -0
  352. package/corpus/templates/content/docs/product/features/content.feature.bring-your-local-work.md +39 -0
  353. package/corpus/templates/content/docs/product/features/content.feature.build-living-dashboards.md +34 -0
  354. package/corpus/templates/content/docs/product/features/content.feature.build-new-surfaces.md +33 -0
  355. package/corpus/templates/content/docs/product/features/content.feature.capture-into-action.md +34 -0
  356. package/corpus/templates/content/docs/product/features/content.feature.cite-what-you-found.md +34 -0
  357. package/corpus/templates/content/docs/product/features/content.feature.collaborate-in-context.md +59 -0
  358. package/corpus/templates/content/docs/product/features/content.feature.collect-structured-input.md +38 -0
  359. package/corpus/templates/content/docs/product/features/content.feature.connect-your-sources.md +38 -0
  360. package/corpus/templates/content/docs/product/features/content.feature.data-that-keeps-itself-right.md +45 -0
  361. package/corpus/templates/content/docs/product/features/content.feature.durable-foundations.md +48 -0
  362. package/corpus/templates/content/docs/product/features/content.feature.evolve-systems-safely.md +38 -0
  363. package/corpus/templates/content/docs/product/features/content.feature.explore-alternatives-safely.md +39 -0
  364. package/corpus/templates/content/docs/product/features/content.feature.find-your-place-again.md +40 -0
  365. package/corpus/templates/content/docs/product/features/content.feature.keep-your-private-vault-private.md +39 -0
  366. package/corpus/templates/content/docs/product/features/content.feature.living-references.md +38 -0
  367. package/corpus/templates/content/docs/product/features/content.feature.make-the-workspace-yours.md +40 -0
  368. package/corpus/templates/content/docs/product/features/content.feature.move-without-starting-over.md +38 -0
  369. package/corpus/templates/content/docs/product/features/content.feature.plan-work-across-time.md +39 -0
  370. package/corpus/templates/content/docs/product/features/content.feature.publish-with-confidence.md +43 -0
  371. package/corpus/templates/content/docs/product/features/content.feature.put-your-organizations-know-how-to-work.md +38 -0
  372. package/corpus/templates/content/docs/product/features/content.feature.read-and-annotate-anything.md +38 -0
  373. package/corpus/templates/content/docs/product/features/content.feature.review-changes-in-place.md +39 -0
  374. package/corpus/templates/content/docs/product/features/content.feature.run-projects-your-way.md +44 -0
  375. package/corpus/templates/content/docs/product/features/content.feature.see-your-information-your-way.md +44 -0
  376. package/corpus/templates/content/docs/product/features/content.feature.share-how-your-organization-works.md +38 -0
  377. package/corpus/templates/content/docs/product/features/content.feature.sketch-connections-keep-whats-true.md +39 -0
  378. package/corpus/templates/content/docs/product/features/content.feature.take-the-whole-vault-with-you.md +39 -0
  379. package/corpus/templates/content/docs/product/features/content.feature.trust-your-connected-sources.md +40 -0
  380. package/corpus/templates/content/docs/product/features/content.feature.understand-what-your-data-says.md +39 -0
  381. package/corpus/templates/content/docs/product/features/content.feature.when-this-happens-that-follows.md +43 -0
  382. package/corpus/templates/content/docs/product/features/content.feature.work-across-every-workspace.md +37 -0
  383. package/corpus/templates/content/docs/product/features/content.feature.work-on-content-inside-another-application.md +37 -0
  384. package/corpus/templates/content/docs/product/roadmap.md +878 -0
  385. package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  386. package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +1 -7
  387. package/corpus/templates/crm/app/i18n/en-US.ts +4 -0
  388. package/corpus/templates/crm/app/routes/settings.tsx +33 -8
  389. package/corpus/templates/crm/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  390. package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  391. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +133 -63
  392. package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +19 -2
  393. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +51 -14
  394. package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +41 -26
  395. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +22 -4
  396. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +216 -116
  397. package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +21 -2
  398. package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbench.tsx +5 -1
  399. package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbenchLoader.tsx +10 -2
  400. package/corpus/templates/design/app/components/design/code-workbench/code-workbench-shell.ts +2 -0
  401. package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +60 -55
  402. package/corpus/templates/design/app/components/design/design-canvas/content-size-report.ts +88 -2
  403. package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +3 -2
  404. package/corpus/templates/design/app/components/design/types.ts +4 -0
  405. package/corpus/templates/design/app/components/layout/Sidebar.tsx +1 -5
  406. package/corpus/templates/design/app/pages/design-editor/clipboard-layer-source.ts +28 -0
  407. package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +117 -0
  408. package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +3 -1
  409. package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +120 -74
  410. package/corpus/templates/design/app/pages/design-editor/pending-structure-verification.ts +11 -0
  411. package/corpus/templates/design/app/pages/design-editor/react-semantic-handoff.ts +2 -0
  412. package/corpus/templates/design/app/pages/design-editor/source-location.ts +1 -1
  413. package/corpus/templates/design/changelog/2026-07-29-copy-rendered-ui-between-live-local-apps-and-design-files-wh.md +6 -0
  414. package/corpus/templates/design/changelog/2026-07-29-design-boards-stay-dark-and-viewport-height-content-keeps-it.md +6 -0
  415. package/corpus/templates/design/changelog/2026-07-29-design-frames-no-longer-grow-continuously-when-their-content.md +6 -0
  416. package/corpus/templates/design/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  417. package/corpus/templates/design/changelog/2026-07-29-the-code-panel-and-apply-design-update-control-now-use-clear.md +6 -0
  418. package/corpus/templates/design/changelog/2026-07-29-the-tools-panel-now-keeps-extension-creation-and-discovery-h.md +6 -0
  419. package/corpus/templates/design/shared/source-mode.ts +7 -1
  420. package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  421. package/corpus/templates/dispatch/app/i18n-data.ts +171 -0
  422. package/corpus/templates/dispatch/app/routes/browser-chat.tsx +4 -0
  423. package/corpus/templates/dispatch/app/routes/browser-connect.tsx +4 -0
  424. package/corpus/templates/dispatch/changelog/2026-07-29-browser-chat-can-securely-connect-the-agent-native-chrome-ex.md +6 -0
  425. package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  426. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +1 -6
  427. package/corpus/templates/forms/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  428. package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  429. package/corpus/templates/macros/app/components/layout/AppLayout.tsx +1 -5
  430. package/corpus/templates/macros/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  431. package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  432. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +1 -9
  433. package/corpus/templates/mail/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  434. package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  435. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +3 -7
  436. package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -2
  437. package/corpus/templates/plan/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
  438. package/corpus/templates/plan/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-ask-plan.md +6 -0
  439. package/corpus/templates/plan/changelog/2026-07-29-fixed-plan-pages-crashing-when-recent-activity-is-unavailabl.md +6 -0
  440. package/corpus/templates/plan/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  441. package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  442. package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +60 -4
  443. package/corpus/templates/slides/.agents/skills/design-systems/SKILL.md +20 -0
  444. package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +30 -1
  445. package/corpus/templates/slides/.agents/skills/slide-images/SKILL.md +3 -1
  446. package/corpus/templates/slides/AGENTS.md +22 -24
  447. package/corpus/templates/slides/actions/check-image-gen.ts +8 -2
  448. package/corpus/templates/slides/actions/create-deck.ts +4 -12
  449. package/corpus/templates/slides/actions/export-pptx.ts +25 -3
  450. package/corpus/templates/slides/actions/generate-image-api.ts +4 -2
  451. package/corpus/templates/slides/actions/generate-slides-ai.ts +1 -1
  452. package/corpus/templates/slides/actions/get-deck-reference-context.ts +136 -0
  453. package/corpus/templates/slides/actions/get-workspace-defaults.ts +55 -0
  454. package/corpus/templates/slides/actions/image-gen-status.ts +10 -1
  455. package/corpus/templates/slides/actions/import-file.ts +53 -38
  456. package/corpus/templates/slides/actions/list-decks.ts +2 -0
  457. package/corpus/templates/slides/actions/patch-deck.ts +2 -0
  458. package/corpus/templates/slides/actions/set-workspace-defaults.ts +50 -0
  459. package/corpus/templates/slides/actions/view-screen.ts +6 -0
  460. package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +1 -1
  461. package/corpus/templates/slides/app/components/deck/DeckCard.tsx +67 -3
  462. package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +40 -8
  463. package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +33 -8
  464. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +6 -2
  465. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +114 -128
  466. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +2 -1
  467. package/corpus/templates/slides/app/components/editor/ImageGenPanel.tsx +1 -1
  468. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1193 -267
  469. package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +302 -102
  470. package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +270 -0
  471. package/corpus/templates/slides/app/components/editor/slide-escape-arbiter.ts +34 -0
  472. package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +368 -0
  473. package/corpus/templates/slides/app/components/editor/slide-presence.ts +13 -0
  474. package/corpus/templates/slides/app/components/layout/AgentWorkIndicator.tsx +23 -3
  475. package/corpus/templates/slides/app/components/layout/Layout.tsx +39 -6
  476. package/corpus/templates/slides/app/components/layout/Sidebar.tsx +1 -6
  477. package/corpus/templates/slides/app/components/layout/layout-route-policy.ts +23 -0
  478. package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +0 -2
  479. package/corpus/templates/slides/app/context/DeckContext.tsx +2 -0
  480. package/corpus/templates/slides/app/global.css +60 -0
  481. package/corpus/templates/slides/app/hooks/use-agent-generating.ts +76 -5
  482. package/corpus/templates/slides/app/hooks/use-workspace-defaults.ts +26 -0
  483. package/corpus/templates/slides/app/i18n/en-US.ts +38 -3
  484. package/corpus/templates/slides/app/lib/generation-state.ts +13 -3
  485. package/corpus/templates/slides/app/lib/slide-image-replacement.ts +27 -6
  486. package/corpus/templates/slides/app/lib/text-tool-shortcut.ts +62 -0
  487. package/corpus/templates/slides/app/pages/DeckEditor.tsx +197 -83
  488. package/corpus/templates/slides/app/pages/DesignSystems.tsx +95 -0
  489. package/corpus/templates/slides/app/pages/Index.tsx +348 -53
  490. package/corpus/templates/slides/changelog/2026-07-28-pick-an-existing-deck-as-a-style-reference-when-creating-a-n.md +6 -0
  491. package/corpus/templates/slides/changelog/2026-07-29-ai-editing-status-is-now-quieter-and-only-shows-slide-presen.md +6 -0
  492. package/corpus/templates/slides/changelog/2026-07-29-design-systems-and-reference-decks-are-easier-to-choose-toge.md +6 -0
  493. package/corpus/templates/slides/changelog/2026-07-29-generated-decks-now-receive-a-concise-relevant-title-before-.md +6 -0
  494. package/corpus/templates/slides/changelog/2026-07-29-new-deck-prompts-reuse-empty-chats.md +6 -0
  495. package/corpus/templates/slides/changelog/2026-07-29-new-deck-setup-now-stays-in-the-editor-with-closable-style-a.md +6 -0
  496. package/corpus/templates/slides/changelog/2026-07-29-selected-words-and-text-runs-can-now-be-styled-independently.md +6 -0
  497. package/corpus/templates/slides/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  498. package/corpus/templates/slides/changelog/2026-07-29-slide-annotation-tools-are-clearer-and-escape-now-exits-anno.md +6 -0
  499. package/corpus/templates/slides/changelog/2026-07-29-slide-editing-now-opens-with-the-app-navigation-collapsed-fo.md +6 -0
  500. package/corpus/templates/slides/changelog/2026-07-29-slide-editing-stays-visually-clean-on-hover-without-a-canvas.md +6 -0
  501. package/corpus/templates/slides/changelog/2026-07-29-slides-now-appear-one-by-one-while-ai-builds-a-deck-with-ste.md +6 -0
  502. package/corpus/templates/slides/changelog/2026-07-29-text-boxes-now-select-move-duplicate-resize-and-style-like-a.md +6 -0
  503. package/corpus/templates/slides/changelog/2026-07-29-untitled-decks-now-use-a-clearer-this-deck-label-in-the-agen.md +6 -0
  504. package/corpus/templates/slides/server/handlers/image-providers/builder.ts +305 -0
  505. package/corpus/templates/slides/server/handlers/image-providers/index.ts +6 -3
  506. package/corpus/templates/slides/server/plugins/agent-chat.ts +1 -0
  507. package/corpus/templates/slides/server/workspace-defaults.ts +169 -0
  508. package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  509. package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +31 -8
  510. package/corpus/templates/tasks/app/i18n/en-US.ts +7 -0
  511. package/corpus/templates/tasks/app/routes/settings.tsx +25 -2
  512. package/corpus/templates/tasks/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  513. package/corpus/toolkit/CHANGELOG.md +15 -0
  514. package/corpus/toolkit/README.md +2 -2
  515. package/corpus/toolkit/package.json +1 -1
  516. package/corpus/toolkit/src/app-shell/sidebar-footer-actions.tsx +0 -3
  517. package/corpus/toolkit/src/chat-history.css +1 -0
  518. package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +35 -14
  519. package/corpus/toolkit/src/composer/PromptComposer.tsx +6 -0
  520. package/corpus/toolkit/src/composer/TiptapComposer.tsx +11 -3
  521. package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +64 -11
  522. package/dist/action.d.ts +44 -0
  523. package/dist/action.d.ts.map +1 -1
  524. package/dist/action.js +9 -0
  525. package/dist/action.js.map +1 -1
  526. package/dist/agent/engine/builder-engine.js +6 -4
  527. package/dist/agent/engine/builder-engine.js.map +1 -1
  528. package/dist/agent/production-agent.d.ts +11 -1
  529. package/dist/agent/production-agent.d.ts.map +1 -1
  530. package/dist/agent/production-agent.js +131 -90
  531. package/dist/agent/production-agent.js.map +1 -1
  532. package/dist/agent/tool-search.d.ts +4 -0
  533. package/dist/agent/tool-search.d.ts.map +1 -1
  534. package/dist/agent/tool-search.js +30 -0
  535. package/dist/agent/tool-search.js.map +1 -1
  536. package/dist/automations/service.d.ts +85 -0
  537. package/dist/automations/service.d.ts.map +1 -0
  538. package/dist/automations/service.js +332 -0
  539. package/dist/automations/service.js.map +1 -0
  540. package/dist/browser-context/index.d.ts +579 -0
  541. package/dist/browser-context/index.d.ts.map +1 -0
  542. package/dist/browser-context/index.js +331 -0
  543. package/dist/browser-context/index.js.map +1 -0
  544. package/dist/client/AgentPanel.d.ts.map +1 -1
  545. package/dist/client/AgentPanel.js +1 -1
  546. package/dist/client/AgentPanel.js.map +1 -1
  547. package/dist/client/FeedbackButton.d.ts +6 -2
  548. package/dist/client/FeedbackButton.d.ts.map +1 -1
  549. package/dist/client/FeedbackButton.js +20 -3
  550. package/dist/client/FeedbackButton.js.map +1 -1
  551. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  552. package/dist/client/MultiTabAssistantChat.js +19 -2
  553. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  554. package/dist/client/agent-chat.d.ts +15 -0
  555. package/dist/client/agent-chat.d.ts.map +1 -1
  556. package/dist/client/agent-chat.js +13 -3
  557. package/dist/client/agent-chat.js.map +1 -1
  558. package/dist/client/agent-page/AgentJobsTab.d.ts +1 -0
  559. package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -1
  560. package/dist/client/agent-page/AgentJobsTab.js +186 -98
  561. package/dist/client/agent-page/AgentJobsTab.js.map +1 -1
  562. package/dist/client/agent-page/AgentTabsPage.js +4 -4
  563. package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
  564. package/dist/client/agent-page/use-jobs.d.ts +7 -0
  565. package/dist/client/agent-page/use-jobs.d.ts.map +1 -1
  566. package/dist/client/agent-page/use-jobs.js.map +1 -1
  567. package/dist/client/analytics-session.d.ts.map +1 -1
  568. package/dist/client/analytics-session.js +13 -0
  569. package/dist/client/analytics-session.js.map +1 -1
  570. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  571. package/dist/client/extensions/ExtensionViewer.js +29 -6
  572. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  573. package/dist/client/settings/AutomationsSection.d.ts +0 -9
  574. package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
  575. package/dist/client/settings/AutomationsSection.js +9 -168
  576. package/dist/client/settings/AutomationsSection.js.map +1 -1
  577. package/dist/client/settings/SettingsPanel.d.ts +9 -1
  578. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  579. package/dist/client/settings/SettingsPanel.js +19 -11
  580. package/dist/client/settings/SettingsPanel.js.map +1 -1
  581. package/dist/client/settings/index.d.ts +1 -1
  582. package/dist/client/settings/index.d.ts.map +1 -1
  583. package/dist/client/settings/index.js +1 -1
  584. package/dist/client/settings/index.js.map +1 -1
  585. package/dist/client/use-agent-chat.d.ts.map +1 -1
  586. package/dist/client/use-agent-chat.js +20 -3
  587. package/dist/client/use-agent-chat.js.map +1 -1
  588. package/dist/client/use-chat-threads.d.ts.map +1 -1
  589. package/dist/client/use-chat-threads.js +4 -17
  590. package/dist/client/use-chat-threads.js.map +1 -1
  591. package/dist/collab/struct-routes.d.ts +1 -1
  592. package/dist/deploy/build.d.ts.map +1 -1
  593. package/dist/deploy/build.js +2 -1
  594. package/dist/deploy/build.js.map +1 -1
  595. package/dist/deploy/workspace-deploy.d.ts.map +1 -1
  596. package/dist/deploy/workspace-deploy.js +2 -1
  597. package/dist/deploy/workspace-deploy.js.map +1 -1
  598. package/dist/extensions/actions.d.ts.map +1 -1
  599. package/dist/extensions/actions.js +82 -6
  600. package/dist/extensions/actions.js.map +1 -1
  601. package/dist/extensions/fetch-tool.d.ts.map +1 -1
  602. package/dist/extensions/fetch-tool.js +11 -0
  603. package/dist/extensions/fetch-tool.js.map +1 -1
  604. package/dist/extensions/routes.d.ts +5 -1
  605. package/dist/extensions/routes.d.ts.map +1 -1
  606. package/dist/extensions/routes.js +7 -1
  607. package/dist/extensions/routes.js.map +1 -1
  608. package/dist/extensions/web-content.d.ts +1 -0
  609. package/dist/extensions/web-content.d.ts.map +1 -1
  610. package/dist/extensions/web-content.js +82 -1
  611. package/dist/extensions/web-content.js.map +1 -1
  612. package/dist/integrations/computer-supervision.d.ts.map +1 -1
  613. package/dist/integrations/computer-supervision.js +22 -1
  614. package/dist/integrations/computer-supervision.js.map +1 -1
  615. package/dist/integrations/index.d.ts +3 -2
  616. package/dist/integrations/index.d.ts.map +1 -1
  617. package/dist/integrations/index.js +3 -2
  618. package/dist/integrations/index.js.map +1 -1
  619. package/dist/integrations/integration-durable-dispatch-config.d.ts +2 -0
  620. package/dist/integrations/integration-durable-dispatch-config.d.ts.map +1 -1
  621. package/dist/integrations/integration-durable-dispatch-config.js +4 -0
  622. package/dist/integrations/integration-durable-dispatch-config.js.map +1 -1
  623. package/dist/integrations/integration-durable-dispatch.d.ts +2 -2
  624. package/dist/integrations/integration-durable-dispatch.d.ts.map +1 -1
  625. package/dist/integrations/integration-durable-dispatch.js +2 -2
  626. package/dist/integrations/integration-durable-dispatch.js.map +1 -1
  627. package/dist/integrations/plugin.d.ts.map +1 -1
  628. package/dist/integrations/plugin.js +84 -39
  629. package/dist/integrations/plugin.js.map +1 -1
  630. package/dist/integrations/remote-browser-actions.d.ts +7 -0
  631. package/dist/integrations/remote-browser-actions.d.ts.map +1 -0
  632. package/dist/integrations/remote-browser-actions.js +482 -0
  633. package/dist/integrations/remote-browser-actions.js.map +1 -0
  634. package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -1
  635. package/dist/jobs/actions/list-recurring-jobs.js +4 -6
  636. package/dist/jobs/actions/list-recurring-jobs.js.map +1 -1
  637. package/dist/jobs/actions/manage-recurring-job.js +3 -6
  638. package/dist/jobs/actions/manage-recurring-job.js.map +1 -1
  639. package/dist/jobs/background-automation-runner.d.ts +76 -0
  640. package/dist/jobs/background-automation-runner.d.ts.map +1 -0
  641. package/dist/jobs/background-automation-runner.js +288 -0
  642. package/dist/jobs/background-automation-runner.js.map +1 -0
  643. package/dist/jobs/frontmatter.d.ts +63 -0
  644. package/dist/jobs/frontmatter.d.ts.map +1 -0
  645. package/dist/jobs/frontmatter.js +216 -0
  646. package/dist/jobs/frontmatter.js.map +1 -0
  647. package/dist/jobs/scheduler.d.ts +6 -60
  648. package/dist/jobs/scheduler.d.ts.map +1 -1
  649. package/dist/jobs/scheduler.js +67 -484
  650. package/dist/jobs/scheduler.js.map +1 -1
  651. package/dist/jobs/tools.d.ts.map +1 -1
  652. package/dist/jobs/tools.js +24 -3
  653. package/dist/jobs/tools.js.map +1 -1
  654. package/dist/localization/default-messages.d.ts +28 -33
  655. package/dist/localization/default-messages.d.ts.map +1 -1
  656. package/dist/localization/default-messages.js +34 -39
  657. package/dist/localization/default-messages.js.map +1 -1
  658. package/dist/mcp-client/index.d.ts.map +1 -1
  659. package/dist/mcp-client/index.js +4 -0
  660. package/dist/mcp-client/index.js.map +1 -1
  661. package/dist/notifications/actions.d.ts.map +1 -1
  662. package/dist/notifications/actions.js +5 -0
  663. package/dist/notifications/actions.js.map +1 -1
  664. package/dist/notifications/routes.d.ts +6 -6
  665. package/dist/observability/routes.d.ts +3 -3
  666. package/dist/progress/actions.d.ts.map +1 -1
  667. package/dist/progress/actions.js +5 -0
  668. package/dist/progress/actions.js.map +1 -1
  669. package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
  670. package/dist/provider-api/actions/github-repo-files.d.ts.map +1 -1
  671. package/dist/provider-api/actions/github-repo-files.js +9 -0
  672. package/dist/provider-api/actions/github-repo-files.js.map +1 -1
  673. package/dist/provider-api/actions/provider-api.d.ts +16 -16
  674. package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
  675. package/dist/provider-api/actions/provider-api.js +14 -0
  676. package/dist/provider-api/actions/provider-api.js.map +1 -1
  677. package/dist/provider-api/corpus-jobs.d.ts +2 -2
  678. package/dist/resources/handlers.d.ts +1 -1
  679. package/dist/secrets/routes.d.ts +9 -9
  680. package/dist/server/action-discovery.d.ts.map +1 -1
  681. package/dist/server/action-discovery.js +5 -0
  682. package/dist/server/action-discovery.js.map +1 -1
  683. package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -1
  684. package/dist/server/agent-chat/browser-team-tools.js +90 -3
  685. package/dist/server/agent-chat/browser-team-tools.js.map +1 -1
  686. package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
  687. package/dist/server/agent-chat/framework-prompts.js +7 -11
  688. package/dist/server/agent-chat/framework-prompts.js.map +1 -1
  689. package/dist/server/agent-chat/plugin-options.d.ts +3 -3
  690. package/dist/server/agent-chat/plugin-options.js.map +1 -1
  691. package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
  692. package/dist/server/agent-chat/script-entries.js +43 -1
  693. package/dist/server/agent-chat/script-entries.js.map +1 -1
  694. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  695. package/dist/server/agent-chat-plugin.js +24 -5
  696. package/dist/server/agent-chat-plugin.js.map +1 -1
  697. package/dist/server/attribution.d.ts +6 -0
  698. package/dist/server/attribution.d.ts.map +1 -1
  699. package/dist/server/attribution.js +14 -14
  700. package/dist/server/attribution.js.map +1 -1
  701. package/dist/server/auth.d.ts.map +1 -1
  702. package/dist/server/auth.js +5 -2
  703. package/dist/server/auth.js.map +1 -1
  704. package/dist/server/better-auth-instance.d.ts +2 -1
  705. package/dist/server/better-auth-instance.d.ts.map +1 -1
  706. package/dist/server/better-auth-instance.js +6 -3
  707. package/dist/server/better-auth-instance.js.map +1 -1
  708. package/dist/server/core-routes-plugin.d.ts +7 -0
  709. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  710. package/dist/server/core-routes-plugin.js +3 -1
  711. package/dist/server/core-routes-plugin.js.map +1 -1
  712. package/dist/server/csrf.d.ts.map +1 -1
  713. package/dist/server/csrf.js +25 -0
  714. package/dist/server/csrf.js.map +1 -1
  715. package/dist/server/email-template.d.ts +4 -0
  716. package/dist/server/email-template.d.ts.map +1 -1
  717. package/dist/server/email-template.js +25 -8
  718. package/dist/server/email-template.js.map +1 -1
  719. package/dist/server/google-oauth.d.ts +3 -0
  720. package/dist/server/google-oauth.d.ts.map +1 -1
  721. package/dist/server/google-oauth.js +12 -1
  722. package/dist/server/google-oauth.js.map +1 -1
  723. package/dist/server/onboarding-html.d.ts.map +1 -1
  724. package/dist/server/onboarding-html.js +18 -0
  725. package/dist/server/onboarding-html.js.map +1 -1
  726. package/dist/server/prompts/framework-core-compact.js +3 -3
  727. package/dist/server/prompts/framework-core-compact.js.map +1 -1
  728. package/dist/server/prompts/framework-core.js +3 -3
  729. package/dist/server/prompts/framework-core.js.map +1 -1
  730. package/dist/server/prompts/shared-rules.js +3 -3
  731. package/dist/server/prompts/shared-rules.js.map +1 -1
  732. package/dist/server/realtime-token.d.ts +1 -1
  733. package/dist/server/transcribe-voice.d.ts +1 -1
  734. package/dist/settings/index.d.ts +1 -1
  735. package/dist/settings/index.d.ts.map +1 -1
  736. package/dist/settings/index.js +1 -1
  737. package/dist/settings/index.js.map +1 -1
  738. package/dist/shared/analytics-anonymous-id.d.ts +12 -0
  739. package/dist/shared/analytics-anonymous-id.d.ts.map +1 -0
  740. package/dist/shared/analytics-anonymous-id.js +29 -0
  741. package/dist/shared/analytics-anonymous-id.js.map +1 -0
  742. package/dist/sharing/actions/share-resource.d.ts.map +1 -1
  743. package/dist/sharing/actions/share-resource.js +23 -4
  744. package/dist/sharing/actions/share-resource.js.map +1 -1
  745. package/dist/sharing/index.d.ts +1 -1
  746. package/dist/sharing/index.d.ts.map +1 -1
  747. package/dist/sharing/index.js.map +1 -1
  748. package/dist/sharing/registry.d.ts +23 -0
  749. package/dist/sharing/registry.d.ts.map +1 -1
  750. package/dist/sharing/registry.js.map +1 -1
  751. package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  752. package/dist/templates/chat/app/components/layout/Sidebar.tsx +1 -5
  753. package/dist/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  754. package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  755. package/dist/templates/default/app/i18n/ar-SA.ts +26 -0
  756. package/dist/templates/default/app/i18n/de-DE.ts +28 -0
  757. package/dist/templates/default/app/i18n/en-US.ts +27 -0
  758. package/dist/templates/default/app/i18n/es-ES.ts +28 -0
  759. package/dist/templates/default/app/i18n/fr-FR.ts +28 -0
  760. package/dist/templates/default/app/i18n/hi-IN.ts +25 -0
  761. package/dist/templates/default/app/i18n/ja-JP.ts +27 -0
  762. package/dist/templates/default/app/i18n/ko-KR.ts +27 -0
  763. package/dist/templates/default/app/i18n/pt-BR.ts +27 -0
  764. package/dist/templates/default/app/i18n/zh-CN.ts +24 -0
  765. package/dist/templates/default/app/i18n/zh-TW.ts +24 -0
  766. package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  767. package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  768. package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
  769. package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
  770. package/dist/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
  771. package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
  772. package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
  773. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
  774. package/dist/tracking/providers.d.ts.map +1 -1
  775. package/dist/tracking/providers.js +1 -0
  776. package/dist/tracking/providers.js.map +1 -1
  777. package/dist/tracking/registry.d.ts +1 -0
  778. package/dist/tracking/registry.d.ts.map +1 -1
  779. package/dist/tracking/registry.js +1 -0
  780. package/dist/tracking/registry.js.map +1 -1
  781. package/dist/tracking/types.d.ts +1 -0
  782. package/dist/tracking/types.d.ts.map +1 -1
  783. package/dist/tracking/types.js.map +1 -1
  784. package/dist/triggers/actions/list-automations.d.ts +7 -0
  785. package/dist/triggers/actions/list-automations.d.ts.map +1 -1
  786. package/dist/triggers/actions/list-automations.js +29 -41
  787. package/dist/triggers/actions/list-automations.js.map +1 -1
  788. package/dist/triggers/actions/manage-automation.js +15 -33
  789. package/dist/triggers/actions/manage-automation.js.map +1 -1
  790. package/dist/triggers/actions.d.ts.map +1 -1
  791. package/dist/triggers/actions.js +184 -95
  792. package/dist/triggers/actions.js.map +1 -1
  793. package/dist/triggers/dispatcher.d.ts +3 -9
  794. package/dist/triggers/dispatcher.d.ts.map +1 -1
  795. package/dist/triggers/dispatcher.js +134 -304
  796. package/dist/triggers/dispatcher.js.map +1 -1
  797. package/dist/triggers/routes.d.ts.map +1 -1
  798. package/dist/triggers/routes.js +76 -17
  799. package/dist/triggers/routes.js.map +1 -1
  800. package/dist/triggers/types.d.ts +4 -23
  801. package/dist/triggers/types.d.ts.map +1 -1
  802. package/dist/triggers/types.js.map +1 -1
  803. package/docs/content/agent-surfaces.mdx +4 -4
  804. package/docs/content/automations.mdx +61 -12
  805. package/docs/content/deployment.mdx +11 -4
  806. package/docs/content/extensions.mdx +39 -33
  807. package/docs/content/recurring-jobs.mdx +41 -19
  808. package/docs/content/template-dispatch-operations.mdx +19 -7
  809. package/package.json +4 -2
  810. package/src/action.ts +55 -0
  811. package/src/agent/engine/builder-engine.ts +8 -4
  812. package/src/agent/production-agent.ts +175 -100
  813. package/src/agent/tool-search.ts +36 -0
  814. package/src/automations/service.ts +506 -0
  815. package/src/browser-context/index.ts +392 -0
  816. package/src/client/AgentPanel.tsx +2 -1
  817. package/src/client/FeedbackButton.tsx +37 -4
  818. package/src/client/MultiTabAssistantChat.tsx +21 -0
  819. package/src/client/agent-chat.ts +31 -3
  820. package/src/client/agent-page/AgentJobsTab.tsx +438 -310
  821. package/src/client/agent-page/AgentTabsPage.tsx +4 -4
  822. package/src/client/agent-page/use-jobs.ts +7 -0
  823. package/src/client/analytics-session.ts +13 -0
  824. package/src/client/extensions/ExtensionViewer.tsx +67 -0
  825. package/src/client/settings/AutomationsSection.tsx +27 -499
  826. package/src/client/settings/SettingsPanel.tsx +32 -11
  827. package/src/client/settings/index.ts +2 -0
  828. package/src/client/use-agent-chat.ts +35 -3
  829. package/src/client/use-chat-threads.ts +8 -25
  830. package/src/deploy/build.ts +2 -0
  831. package/src/deploy/workspace-deploy.ts +2 -0
  832. package/src/extensions/actions.ts +115 -3
  833. package/src/extensions/fetch-tool.ts +11 -0
  834. package/src/extensions/routes.ts +16 -1
  835. package/src/extensions/web-content.ts +96 -1
  836. package/src/integrations/computer-supervision.ts +33 -1
  837. package/src/integrations/index.ts +6 -0
  838. package/src/integrations/integration-durable-dispatch-config.ts +10 -0
  839. package/src/integrations/integration-durable-dispatch.ts +4 -0
  840. package/src/integrations/plugin.ts +94 -41
  841. package/src/integrations/remote-browser-actions.ts +621 -0
  842. package/src/jobs/actions/list-recurring-jobs.ts +5 -7
  843. package/src/jobs/actions/manage-recurring-job.ts +3 -7
  844. package/src/jobs/background-automation-runner.ts +437 -0
  845. package/src/jobs/frontmatter.ts +308 -0
  846. package/src/jobs/scheduler.ts +89 -598
  847. package/src/jobs/tools.ts +22 -3
  848. package/src/localization/default-messages.ts +45 -45
  849. package/src/mcp-client/index.ts +6 -0
  850. package/src/notifications/actions.ts +5 -0
  851. package/src/progress/actions.ts +5 -0
  852. package/src/provider-api/actions/github-repo-files.ts +11 -0
  853. package/src/provider-api/actions/provider-api.ts +13 -0
  854. package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +4 -4
  855. package/src/server/action-discovery.ts +7 -0
  856. package/src/server/agent-chat/browser-team-tools.ts +126 -3
  857. package/src/server/agent-chat/framework-prompts.ts +7 -11
  858. package/src/server/agent-chat/plugin-options.ts +3 -3
  859. package/src/server/agent-chat/script-entries.ts +52 -1
  860. package/src/server/agent-chat-plugin.ts +25 -5
  861. package/src/server/attribution.ts +22 -0
  862. package/src/server/auth.ts +20 -6
  863. package/src/server/better-auth-instance.ts +10 -2
  864. package/src/server/core-routes-plugin.ts +10 -1
  865. package/src/server/csrf.ts +25 -0
  866. package/src/server/email-template.ts +43 -13
  867. package/src/server/google-oauth.ts +21 -1
  868. package/src/server/onboarding-html.ts +18 -0
  869. package/src/server/prompts/framework-core-compact.ts +3 -3
  870. package/src/server/prompts/framework-core.ts +3 -3
  871. package/src/server/prompts/shared-rules.ts +3 -3
  872. package/src/settings/index.ts +1 -0
  873. package/src/shared/analytics-anonymous-id.ts +35 -0
  874. package/src/sharing/actions/share-resource.ts +26 -4
  875. package/src/sharing/index.ts +1 -0
  876. package/src/sharing/registry.ts +23 -0
  877. package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  878. package/src/templates/chat/app/components/layout/Sidebar.tsx +1 -5
  879. package/src/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
  880. package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  881. package/src/templates/default/app/i18n/ar-SA.ts +26 -0
  882. package/src/templates/default/app/i18n/de-DE.ts +28 -0
  883. package/src/templates/default/app/i18n/en-US.ts +27 -0
  884. package/src/templates/default/app/i18n/es-ES.ts +28 -0
  885. package/src/templates/default/app/i18n/fr-FR.ts +28 -0
  886. package/src/templates/default/app/i18n/hi-IN.ts +25 -0
  887. package/src/templates/default/app/i18n/ja-JP.ts +27 -0
  888. package/src/templates/default/app/i18n/ko-KR.ts +27 -0
  889. package/src/templates/default/app/i18n/pt-BR.ts +27 -0
  890. package/src/templates/default/app/i18n/zh-CN.ts +24 -0
  891. package/src/templates/default/app/i18n/zh-TW.ts +24 -0
  892. package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  893. package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
  894. package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
  895. package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
  896. package/src/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
  897. package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
  898. package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
  899. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
  900. package/src/tracking/providers.ts +1 -0
  901. package/src/tracking/registry.ts +2 -1
  902. package/src/tracking/types.ts +1 -0
  903. package/src/triggers/actions/list-automations.ts +43 -44
  904. package/src/triggers/actions/manage-automation.ts +17 -48
  905. package/src/triggers/actions.ts +218 -127
  906. package/src/triggers/dispatcher.ts +181 -367
  907. package/src/triggers/routes.ts +84 -27
  908. package/src/triggers/types.ts +9 -23
  909. package/corpus/templates/clips/app/routes/_app.settings.organization.tsx +0 -232
@@ -1 +1 @@
1
- {"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAuJH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,GAAE,MAAyB;;GAsB3C"}
1
+ {"version":3,"file":"csrf.d.ts","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAgLH;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,eAAe,GAAE,MAAyB;;GAsB3C"}
@@ -51,6 +51,27 @@ import { getConfiguredAppBasePath } from "./app-base-path.js";
51
51
  * markers. These are signed/authenticated through other mechanisms (HMAC,
52
52
  * JWT, internal token) so they don't need cookie-based CSRF protection.
53
53
  */
54
+ /**
55
+ * Sub-prefixes that must stay CSRF-protected even though a broader entry in
56
+ * `CSRF_ALLOWLIST_PREFIXES` covers them. Checked first, and they win.
57
+ *
58
+ * An allowlist entry is a promise that everything beneath it authenticates on
59
+ * something the browser will not attach by itself. Mount a route that calls
60
+ * `requireSessionContext` under such a prefix and that promise silently breaks:
61
+ * the route now rides the ambient `SameSite=None` session cookie with no
62
+ * first-party check, and nothing about the route's own code looks wrong.
63
+ * `/integrations/remote/*` is exactly that shape — device-token relay routes
64
+ * and cookie-authenticated control routes share one subtree.
65
+ */
66
+ const CSRF_PROTECTED_PREFIXES = [
67
+ // Remote-device relay. The device's own routes (poll/result/heartbeat)
68
+ // authenticate with a bearer token and send no cookies, so they never reach
69
+ // the check; the sibling routes (register, enqueue, computer/approvals,
70
+ // computer/commands) are session-authenticated and must not be exempt —
71
+ // approving a browser-control operation is a state change an attacker page
72
+ // must never be able to make ride the victim's cookie.
73
+ "/integrations/remote/",
74
+ ];
54
75
  const CSRF_ALLOWLIST_PREFIXES = [
55
76
  // Integration webhooks — verified by HMAC against a per-integration secret.
56
77
  "/integrations/",
@@ -142,6 +163,10 @@ function isOnAllowlist(pathname, frameworkPrefix) {
142
163
  if (!pathname.startsWith(frameworkPrefix))
143
164
  return false;
144
165
  const sub = pathname.slice(frameworkPrefix.length);
166
+ for (const protectedPrefix of CSRF_PROTECTED_PREFIXES) {
167
+ if (sub.startsWith(protectedPrefix))
168
+ return false;
169
+ }
145
170
  for (const allowed of CSRF_ALLOWLIST_PREFIXES) {
146
171
  if (sub.startsWith(allowed))
147
172
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,uBAAuB,GAAG;IAC9B,4EAA4E;IAC5E,gBAAgB;IAChB,2EAA2E;IAC3E,gEAAgE;IAChE,eAAe;IACf,qEAAqE;IACrE,4DAA4D;IAC5D,6BAA6B;IAC7B,2EAA2E;IAC3E,gEAAgE;IAChE,MAAM;IACN,sEAAsE;IACtE,0EAA0E;IAC1E,4DAA4D;IAC5D,QAAQ;IACR,8DAA8D;IAC9D,kBAAkB;IAClB,u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CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,OAAO,SAAS,CAAC;QAE1D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC1E,IAAI,CAAC,cAAc;YAAE,OAAO,SAAS,CAAC;QACtC,IAAI,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC;YAAE,OAAO,SAAS,CAAC;QAE9D,qEAAqE;QACrE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEhD,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE7C,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO;YACL,KAAK,EACH,6IAA6I;SAChJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Defense-in-depth CSRF check for framework state-changing routes.\n *\n * Threat model: action endpoints (`/_agent-native/actions/*`), extension\n * endpoints (`/_agent-native/extensions/*` and the legacy\n * `/_agent-native/tools/*` alias), and a handful of other state-changing\n * `/_agent-native/*` routes use the better-auth session cookie, which is\n * configured with `SameSite=None; Secure; Partitioned` so the iframe editor\n * (and other cross-site embeds) can authenticate. `SameSite=None` means the\n * browser ships the session cookie on top-level form POSTs from any origin —\n * which is exactly the precondition for classic cross-site request forgery.\n *\n * The browser still gates \"non-simple\" requests behind a CORS preflight, so\n * an attacker who has to send `Content-Type: application/json` is forced\n * through OPTIONS, which our CORS middleware (`create-server.ts`) rejects\n * for disallowed origins. But the simple-request bypass (`Content-Type:\n * text/plain` on a `<form enctype=\"text/plain\">` POST, or `multipart/form-data`)\n * never preflights — the browser delivers it cross-origin with cookies.\n *\n * Mitigation: this middleware rejects any state-changing\n * (`POST/PUT/PATCH/DELETE`) request to `/_agent-native/*` that\n *\n * 1. carries the auth-cookie pattern (any cookie at all is a heuristic\n * good-enough proxy — we don't want to deny anonymous fetches), AND\n * 2. is NOT clearly same-origin / first-party. We trust:\n * - `Sec-Fetch-Site: same-origin` (sent by every modern browser on\n * same-origin fetch — Chrome/Firefox/Safari/Edge all support it).\n * - `X-Agent-Native-CSRF` custom header. Custom headers force a\n * preflight, so an attacker can't add one cross-origin.\n * - `Content-Type: application/json` request body. Same logic — JSON\n * Content-Type is a non-simple request that triggers preflight.\n *\n * Why the existing CORS check isn't enough: a simple-request POST never\n * preflights, so the browser sends it through and only blocks the *response*\n * from being readable cross-origin. The state change (delete-account, write\n * SQL, etc.) happens server-side regardless. We need a server-side check that\n * proves first-party intent before running the action.\n *\n * Opt-out marker: a handful of routes legitimately accept cross-origin POSTs\n * — webhook endpoints (Slack, Telegram, email), the public A2A endpoint\n * (`/_agent-native/a2a`), the integrations process-task self-fire, and so on.\n * Those are listed in `CSRF_ALLOWLIST_PREFIXES` below; if you add a new\n * cross-origin-callable route, add it there.\n */\n\nimport {\n defineEventHandler,\n getMethod,\n getRequestHeader,\n setResponseStatus,\n} from \"h3\";\n\nimport { MCP_PUBLIC_ROUTE_PREFIX } from \"../mcp/route-paths.js\";\nimport { getConfiguredAppBasePath } from \"./app-base-path.js\";\n\n/**\n * Path prefixes (relative to the framework prefix `/_agent-native`) that are\n * allowed to receive cross-origin state-changing POSTs without first-party\n * markers. These are signed/authenticated through other mechanisms (HMAC,\n * JWT, internal token) so they don't need cookie-based CSRF protection.\n */\nconst CSRF_ALLOWLIST_PREFIXES = [\n // Integration webhooks — verified by HMAC against a per-integration secret.\n \"/integrations/\",\n // Agent Teams durable sub-agent processor self-fire — verified by the same\n // HMAC internal-token scheme as the integration/A2A processors.\n \"/agent-teams/\",\n // Durable sandbox-execution processor self-fire (run-code background\n // queue) — verified by the same HMAC internal-token scheme.\n \"/sandbox/_process-execution\",\n // A2A JSON-RPC endpoints — verified by signed JWT (when A2A_SECRET set) or\n // explicitly opt-in unauthenticated (handled at the A2A layer).\n \"/a2a\",\n // Better Auth's own login/sign-in/social-callback routes. Better Auth\n // ships its own CSRF protection (Origin/Sec-Fetch checks on its handlers)\n // and cookies are needed for the OAuth callback round-trip.\n \"/auth/\",\n // Stripe / Paddle / billing webhooks dropped in by templates.\n \"/billing/webhook\",\n // Public share endpoints — read-only and never cookie-driven, but kept\n // here so a templated POST (e.g. comment-on-public-recording) doesn't 403.\n \"/share/\",\n // OAuth callbacks (Builder, Google, Slack, Notion, Zoom). These get a\n // `code` query param via top-level navigation — they DO ride the session\n // cookie and they SHOULD validate state, but the framework can't see the\n // state token. Each callback handler is responsible for its own CSRF\n // check (signed state tokens).\n \"/oauth/\",\n // Builder's CLI-auth callback — uses the BUILDER_STATE_PARAM signed token\n // to authenticate the round-trip; framework CSRF check would block it.\n \"/builder/callback\",\n];\n\nconst STATE_CHANGING_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/**\n * Decide whether a request is \"first-party enough\" to trust as not-CSRF.\n * Any of the following make a request non-CSRF:\n *\n * - `Sec-Fetch-Site: same-origin` (or `none` for top-level navigations\n * to our own pages — but state-changing methods don't ship `none`).\n * - `X-Agent-Native-CSRF` header (any value, even \"1\"). This is a custom\n * header so the browser forces a preflight cross-origin, which our\n * CORS layer rejects for disallowed origins.\n * - `Content-Type: application/json` (case-insensitive). JSON content\n * type is a non-simple request that triggers preflight.\n *\n * We accept ANY of these — the goal is \"did the request come through a\n * channel the browser would have preflighted\", not a strict-mode token.\n *\n * NOTE: `Sec-Fetch-Site: same-site` is deliberately NOT trusted. Under a\n * shared cookie domain (COOKIE_DOMAIN / crossSubDomainCookies), the browser\n * labels a request from a SIBLING subdomain (evil.example.com → app.example.com)\n * as `same-site` even though it is cross-origin and would ride the shared\n * session cookie — a CSRF vector. Legitimate first-party clients all also send\n * `X-Agent-Native-CSRF` or `application/json`, so they still pass via those\n * paths and iframe/embed flows are unaffected.\n */\nfunction looksFirstParty(event: any): boolean {\n const sfs = getRequestHeader(event, \"sec-fetch-site\");\n if (sfs === \"same-origin\" || sfs === \"none\") {\n return true;\n }\n if (getRequestHeader(event, \"x-agent-native-csrf\")) {\n return true;\n }\n const contentType = getRequestHeader(event, \"content-type\");\n if (\n contentType &&\n typeof contentType === \"string\" &&\n contentType.toLowerCase().includes(\"application/json\")\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Returns true when the request carries any cookie. We use \"has any cookie\"\n * as a coarse heuristic for \"the browser is going to attach the session\n * cookie\" — anonymous tools (curl, server-to-server) typically don't send\n * cookies, so they bypass this check entirely.\n */\nfunction requestHasCookies(event: any): boolean {\n const cookie = getRequestHeader(event, \"cookie\");\n return typeof cookie === \"string\" && cookie.trim().length > 0;\n}\n\n/**\n * The path is the full request URL pathname (e.g.\n * `/_agent-native/actions/foo` or `/app/_agent-native/actions/foo`).\n * `frameworkPrefix` is the root framework route prefix without a trailing\n * slash, e.g. `/_agent-native`.\n */\nfunction isOnAllowlist(pathname: string, frameworkPrefix: string): boolean {\n if (!pathname.startsWith(frameworkPrefix)) return false;\n const sub = pathname.slice(frameworkPrefix.length);\n for (const allowed of CSRF_ALLOWLIST_PREFIXES) {\n if (sub.startsWith(allowed)) return true;\n }\n return false;\n}\n\nfunction matchingFrameworkPrefix(\n pathname: string,\n frameworkPrefix: string,\n): string | undefined {\n if (pathname.startsWith(frameworkPrefix)) return frameworkPrefix;\n\n if (\n pathname === MCP_PUBLIC_ROUTE_PREFIX ||\n pathname.startsWith(`${MCP_PUBLIC_ROUTE_PREFIX}/`)\n ) {\n return MCP_PUBLIC_ROUTE_PREFIX;\n }\n\n const basePath = getConfiguredAppBasePath();\n const basePathFrameworkPrefix = `${basePath}${frameworkPrefix}`;\n if (basePath && pathname.startsWith(basePathFrameworkPrefix)) {\n return basePathFrameworkPrefix;\n }\n\n const basePathMcpPrefix = `${basePath}${MCP_PUBLIC_ROUTE_PREFIX}`;\n if (\n basePath &&\n (pathname === basePathMcpPrefix ||\n pathname.startsWith(`${basePathMcpPrefix}/`))\n ) {\n return basePathMcpPrefix;\n }\n\n return undefined;\n}\n\n/**\n * Create the framework CSRF middleware.\n *\n * Mount this BEFORE any state-changing route handler. The middleware\n * - lets every non-state-changing method through (GET/HEAD/OPTIONS).\n * - lets requests without cookies through (anonymous/server tools).\n * - lets allowlisted paths through (webhooks, A2A, OAuth callbacks).\n * - lets first-party-shaped requests through (custom header, JSON\n * Content-Type, or `Sec-Fetch-Site: same-origin`).\n * - rejects everything else with 403.\n */\nexport function createCsrfMiddleware(\n frameworkPrefix: string = \"/_agent-native\",\n) {\n return defineEventHandler((event) => {\n const method = getMethod(event);\n if (!STATE_CHANGING_METHODS.has(method)) return undefined;\n\n const pathname = event.url?.pathname ?? \"\";\n const matchingPrefix = matchingFrameworkPrefix(pathname, frameworkPrefix);\n if (!matchingPrefix) return undefined;\n if (isOnAllowlist(pathname, matchingPrefix)) return undefined;\n\n // No cookie = no risk of confused-deputy CSRF on the session cookie.\n if (!requestHasCookies(event)) return undefined;\n\n if (looksFirstParty(event)) return undefined;\n\n setResponseStatus(event, 403);\n return {\n error:\n \"CSRF check failed: state-changing requests must include a same-origin marker. Set Content-Type: application/json or X-Agent-Native-CSRF: 1.\",\n };\n });\n}\n"]}
1
+ {"version":3,"file":"csrf.js","sourceRoot":"","sources":["../../src/server/csrf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D;;;;;GAKG;AACH;;;;;;;;;;;GAWG;AACH,MAAM,uBAAuB,GAAG;IAC9B,uEAAuE;IACvE,4EAA4E;IAC5E,wEAAwE;IACxE,wEAAwE;IACxE,2EAA2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AiB,GAAG,GAAG,QAAQ,GAAG,uBAAuB,EAAE,CAAC;IAClE,IACE,QAAQ;QACR,CAAC,QAAQ,KAAK,iBAAiB;YAC7B,QAAQ,CAAC,UAAU,CAAC,GAAG,iBAAiB,GAAG,CAAC,CAAC,EAC/C,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,eAAe,GAAW,gBAAgB;IAE1C,OAAO,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,OAAO,SAAS,CAAC;QAE1D,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,EAAE,QAAQ,IAAI,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAG,uBAAuB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC1E,IAAI,CAAC,cAAc;YAAE,OAAO,SAAS,CAAC;QACtC,IAAI,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC;YAAE,OAAO,SAAS,CAAC;QAE9D,qEAAqE;QACrE,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEhD,IAAI,eAAe,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE7C,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO;YACL,KAAK,EACH,6IAA6I;SAChJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Defense-in-depth CSRF check for framework state-changing routes.\n *\n * Threat model: action endpoints (`/_agent-native/actions/*`), extension\n * endpoints (`/_agent-native/extensions/*` and the legacy\n * `/_agent-native/tools/*` alias), and a handful of other state-changing\n * `/_agent-native/*` routes use the better-auth session cookie, which is\n * configured with `SameSite=None; Secure; Partitioned` so the iframe editor\n * (and other cross-site embeds) can authenticate. `SameSite=None` means the\n * browser ships the session cookie on top-level form POSTs from any origin —\n * which is exactly the precondition for classic cross-site request forgery.\n *\n * The browser still gates \"non-simple\" requests behind a CORS preflight, so\n * an attacker who has to send `Content-Type: application/json` is forced\n * through OPTIONS, which our CORS middleware (`create-server.ts`) rejects\n * for disallowed origins. But the simple-request bypass (`Content-Type:\n * text/plain` on a `<form enctype=\"text/plain\">` POST, or `multipart/form-data`)\n * never preflights — the browser delivers it cross-origin with cookies.\n *\n * Mitigation: this middleware rejects any state-changing\n * (`POST/PUT/PATCH/DELETE`) request to `/_agent-native/*` that\n *\n * 1. carries the auth-cookie pattern (any cookie at all is a heuristic\n * good-enough proxy — we don't want to deny anonymous fetches), AND\n * 2. is NOT clearly same-origin / first-party. We trust:\n * - `Sec-Fetch-Site: same-origin` (sent by every modern browser on\n * same-origin fetch — Chrome/Firefox/Safari/Edge all support it).\n * - `X-Agent-Native-CSRF` custom header. Custom headers force a\n * preflight, so an attacker can't add one cross-origin.\n * - `Content-Type: application/json` request body. Same logic — JSON\n * Content-Type is a non-simple request that triggers preflight.\n *\n * Why the existing CORS check isn't enough: a simple-request POST never\n * preflights, so the browser sends it through and only blocks the *response*\n * from being readable cross-origin. The state change (delete-account, write\n * SQL, etc.) happens server-side regardless. We need a server-side check that\n * proves first-party intent before running the action.\n *\n * Opt-out marker: a handful of routes legitimately accept cross-origin POSTs\n * — webhook endpoints (Slack, Telegram, email), the public A2A endpoint\n * (`/_agent-native/a2a`), the integrations process-task self-fire, and so on.\n * Those are listed in `CSRF_ALLOWLIST_PREFIXES` below; if you add a new\n * cross-origin-callable route, add it there.\n */\n\nimport {\n defineEventHandler,\n getMethod,\n getRequestHeader,\n setResponseStatus,\n} from \"h3\";\n\nimport { MCP_PUBLIC_ROUTE_PREFIX } from \"../mcp/route-paths.js\";\nimport { getConfiguredAppBasePath } from \"./app-base-path.js\";\n\n/**\n * Path prefixes (relative to the framework prefix `/_agent-native`) that are\n * allowed to receive cross-origin state-changing POSTs without first-party\n * markers. These are signed/authenticated through other mechanisms (HMAC,\n * JWT, internal token) so they don't need cookie-based CSRF protection.\n */\n/**\n * Sub-prefixes that must stay CSRF-protected even though a broader entry in\n * `CSRF_ALLOWLIST_PREFIXES` covers them. Checked first, and they win.\n *\n * An allowlist entry is a promise that everything beneath it authenticates on\n * something the browser will not attach by itself. Mount a route that calls\n * `requireSessionContext` under such a prefix and that promise silently breaks:\n * the route now rides the ambient `SameSite=None` session cookie with no\n * first-party check, and nothing about the route's own code looks wrong.\n * `/integrations/remote/*` is exactly that shape — device-token relay routes\n * and cookie-authenticated control routes share one subtree.\n */\nconst CSRF_PROTECTED_PREFIXES = [\n // Remote-device relay. The device's own routes (poll/result/heartbeat)\n // authenticate with a bearer token and send no cookies, so they never reach\n // the check; the sibling routes (register, enqueue, computer/approvals,\n // computer/commands) are session-authenticated and must not be exempt —\n // approving a browser-control operation is a state change an attacker page\n // must never be able to make ride the victim's cookie.\n \"/integrations/remote/\",\n];\n\nconst CSRF_ALLOWLIST_PREFIXES = [\n // Integration webhooks — verified by HMAC against a per-integration secret.\n \"/integrations/\",\n // Agent Teams durable sub-agent processor self-fire — verified by the same\n // HMAC internal-token scheme as the integration/A2A processors.\n \"/agent-teams/\",\n // Durable sandbox-execution processor self-fire (run-code background\n // queue) — verified by the same HMAC internal-token scheme.\n \"/sandbox/_process-execution\",\n // A2A JSON-RPC endpoints — verified by signed JWT (when A2A_SECRET set) or\n // explicitly opt-in unauthenticated (handled at the A2A layer).\n \"/a2a\",\n // Better Auth's own login/sign-in/social-callback routes. Better Auth\n // ships its own CSRF protection (Origin/Sec-Fetch checks on its handlers)\n // and cookies are needed for the OAuth callback round-trip.\n \"/auth/\",\n // Stripe / Paddle / billing webhooks dropped in by templates.\n \"/billing/webhook\",\n // Public share endpoints — read-only and never cookie-driven, but kept\n // here so a templated POST (e.g. comment-on-public-recording) doesn't 403.\n \"/share/\",\n // OAuth callbacks (Builder, Google, Slack, Notion, Zoom). These get a\n // `code` query param via top-level navigation — they DO ride the session\n // cookie and they SHOULD validate state, but the framework can't see the\n // state token. Each callback handler is responsible for its own CSRF\n // check (signed state tokens).\n \"/oauth/\",\n // Builder's CLI-auth callback — uses the BUILDER_STATE_PARAM signed token\n // to authenticate the round-trip; framework CSRF check would block it.\n \"/builder/callback\",\n];\n\nconst STATE_CHANGING_METHODS = new Set([\"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/**\n * Decide whether a request is \"first-party enough\" to trust as not-CSRF.\n * Any of the following make a request non-CSRF:\n *\n * - `Sec-Fetch-Site: same-origin` (or `none` for top-level navigations\n * to our own pages — but state-changing methods don't ship `none`).\n * - `X-Agent-Native-CSRF` header (any value, even \"1\"). This is a custom\n * header so the browser forces a preflight cross-origin, which our\n * CORS layer rejects for disallowed origins.\n * - `Content-Type: application/json` (case-insensitive). JSON content\n * type is a non-simple request that triggers preflight.\n *\n * We accept ANY of these — the goal is \"did the request come through a\n * channel the browser would have preflighted\", not a strict-mode token.\n *\n * NOTE: `Sec-Fetch-Site: same-site` is deliberately NOT trusted. Under a\n * shared cookie domain (COOKIE_DOMAIN / crossSubDomainCookies), the browser\n * labels a request from a SIBLING subdomain (evil.example.com → app.example.com)\n * as `same-site` even though it is cross-origin and would ride the shared\n * session cookie — a CSRF vector. Legitimate first-party clients all also send\n * `X-Agent-Native-CSRF` or `application/json`, so they still pass via those\n * paths and iframe/embed flows are unaffected.\n */\nfunction looksFirstParty(event: any): boolean {\n const sfs = getRequestHeader(event, \"sec-fetch-site\");\n if (sfs === \"same-origin\" || sfs === \"none\") {\n return true;\n }\n if (getRequestHeader(event, \"x-agent-native-csrf\")) {\n return true;\n }\n const contentType = getRequestHeader(event, \"content-type\");\n if (\n contentType &&\n typeof contentType === \"string\" &&\n contentType.toLowerCase().includes(\"application/json\")\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Returns true when the request carries any cookie. We use \"has any cookie\"\n * as a coarse heuristic for \"the browser is going to attach the session\n * cookie\" — anonymous tools (curl, server-to-server) typically don't send\n * cookies, so they bypass this check entirely.\n */\nfunction requestHasCookies(event: any): boolean {\n const cookie = getRequestHeader(event, \"cookie\");\n return typeof cookie === \"string\" && cookie.trim().length > 0;\n}\n\n/**\n * The path is the full request URL pathname (e.g.\n * `/_agent-native/actions/foo` or `/app/_agent-native/actions/foo`).\n * `frameworkPrefix` is the root framework route prefix without a trailing\n * slash, e.g. `/_agent-native`.\n */\nfunction isOnAllowlist(pathname: string, frameworkPrefix: string): boolean {\n if (!pathname.startsWith(frameworkPrefix)) return false;\n const sub = pathname.slice(frameworkPrefix.length);\n for (const protectedPrefix of CSRF_PROTECTED_PREFIXES) {\n if (sub.startsWith(protectedPrefix)) return false;\n }\n for (const allowed of CSRF_ALLOWLIST_PREFIXES) {\n if (sub.startsWith(allowed)) return true;\n }\n return false;\n}\n\nfunction matchingFrameworkPrefix(\n pathname: string,\n frameworkPrefix: string,\n): string | undefined {\n if (pathname.startsWith(frameworkPrefix)) return frameworkPrefix;\n\n if (\n pathname === MCP_PUBLIC_ROUTE_PREFIX ||\n pathname.startsWith(`${MCP_PUBLIC_ROUTE_PREFIX}/`)\n ) {\n return MCP_PUBLIC_ROUTE_PREFIX;\n }\n\n const basePath = getConfiguredAppBasePath();\n const basePathFrameworkPrefix = `${basePath}${frameworkPrefix}`;\n if (basePath && pathname.startsWith(basePathFrameworkPrefix)) {\n return basePathFrameworkPrefix;\n }\n\n const basePathMcpPrefix = `${basePath}${MCP_PUBLIC_ROUTE_PREFIX}`;\n if (\n basePath &&\n (pathname === basePathMcpPrefix ||\n pathname.startsWith(`${basePathMcpPrefix}/`))\n ) {\n return basePathMcpPrefix;\n }\n\n return undefined;\n}\n\n/**\n * Create the framework CSRF middleware.\n *\n * Mount this BEFORE any state-changing route handler. The middleware\n * - lets every non-state-changing method through (GET/HEAD/OPTIONS).\n * - lets requests without cookies through (anonymous/server tools).\n * - lets allowlisted paths through (webhooks, A2A, OAuth callbacks).\n * - lets first-party-shaped requests through (custom header, JSON\n * Content-Type, or `Sec-Fetch-Site: same-origin`).\n * - rejects everything else with 403.\n */\nexport function createCsrfMiddleware(\n frameworkPrefix: string = \"/_agent-native\",\n) {\n return defineEventHandler((event) => {\n const method = getMethod(event);\n if (!STATE_CHANGING_METHODS.has(method)) return undefined;\n\n const pathname = event.url?.pathname ?? \"\";\n const matchingPrefix = matchingFrameworkPrefix(pathname, frameworkPrefix);\n if (!matchingPrefix) return undefined;\n if (isOnAllowlist(pathname, matchingPrefix)) return undefined;\n\n // No cookie = no risk of confused-deputy CSRF on the session cookie.\n if (!requestHasCookies(event)) return undefined;\n\n if (looksFirstParty(event)) return undefined;\n\n setResponseStatus(event, 403);\n return {\n error:\n \"CSRF check failed: state-changing requests must include a same-origin marker. Set Content-Type: application/json or X-Agent-Native-CSRF: 1.\",\n };\n });\n}\n"]}
@@ -36,6 +36,8 @@ export interface RenderEmailArgs {
36
36
  paragraphs: string[];
37
37
  /** Primary call-to-action rendered as a real button. */
38
38
  cta?: EmailCta;
39
+ /** Optional second button rendered beside the primary CTA, dark-filled. */
40
+ secondaryCta?: EmailCta;
39
41
  /** A treated, copyable URL shown before or after the CTA. */
40
42
  linkBlock?: EmailLinkBlock;
41
43
  /**
@@ -44,6 +46,8 @@ export interface RenderEmailArgs {
44
46
  * by app/template code (never raw user input), and escape any dynamic values.
45
47
  */
46
48
  heroHtml?: string;
49
+ /** Body paragraphs rendered after the CTA and link block. Escaped-by-caller. */
50
+ closingParagraphs?: string[];
47
51
  /** Small muted text under the CTA (e.g. expiry note). */
48
52
  footer?: string;
49
53
  /** Optional app name shown beside the framework logo. */
@@ -1 +1 @@
1
- {"version":3,"file":"email-template.d.ts","sourceRoot":"","sources":["../../src/server/email-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,eAAO,MAAM,kCAAkC,sBAAsB,CAAC;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13 @@ export function renderEmail(args) {
70
70
  // thumbnail with a play badge). Callers are responsible for escaping any
71
71
  // dynamic values they interpolate.
72
72
  const heroHtml = args.heroHtml ?? "";
73
- const paragraphsHtml = args.paragraphs
73
+ const renderParagraphs = (paragraphs) => (paragraphs ?? [])
74
74
  .map((p) => `<p style="margin:0 0 16px 0; font-size:16px; line-height:1.6; color:#d4d4d8;">${p}</p>`)
75
75
  .join("");
76
+ const paragraphsHtml = renderParagraphs(args.paragraphs);
77
+ const closingParagraphsHtml = args.closingParagraphs?.length
78
+ ? `<div style="margin:28px 0 0 0;">${renderParagraphs(args.closingParagraphs)}</div>`
79
+ : "";
76
80
  const linkBlockHtml = args.linkBlock
77
81
  ? `
78
82
  <p style="margin:24px 0 12px 0; font-size:15px; line-height:1.6; color:#d4d4d8;">${escapeHtml(args.linkBlock.intro)}</p>
@@ -85,16 +89,20 @@ export function renderEmail(args) {
85
89
  </table>
86
90
  `
87
91
  : "";
92
+ const ctaButtonCell = (cta, background, color, border) => `
93
+ <td style="border-radius:10px; background:${background}; border:${border};">
94
+ <a href="${escapeAttr(cta.url)}"
95
+ style="display:inline-block; padding:14px 26px; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size:15px; font-weight:600; color:${color}; text-decoration:none; border-radius:10px;">
96
+ ${escapeHtml(cta.label)}
97
+ </a>
98
+ </td>`;
99
+ const secondaryCtaHtml = args.secondaryCta
100
+ ? `<td style="width:12px;">&nbsp;</td>${ctaButtonCell(args.secondaryCta, "#141417", "#fafafa", "1px solid #3f3f46")}`
101
+ : "";
88
102
  const ctaHtml = args.cta
89
103
  ? `
90
104
  <table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:24px 0 0 0;">
91
- <tr>
92
- <td style="border-radius:10px; background:${ctaBg};">
93
- <a href="${escapeAttr(args.cta.url)}"
94
- style="display:inline-block; padding:14px 26px; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size:15px; font-weight:600; color:${ctaFg}; text-decoration:none; border-radius:10px;">
95
- ${escapeHtml(args.cta.label)}
96
- </a>
97
- </td>
105
+ <tr>${ctaButtonCell(args.cta, ctaBg, ctaFg, "0")}${secondaryCtaHtml}
98
106
  </tr>
99
107
  </table>
100
108
  `
@@ -145,6 +153,7 @@ export function renderEmail(args) {
145
153
  ${args.linkBlock?.placement !== "after-cta" ? linkBlockHtml : ""}
146
154
  ${ctaHtml}
147
155
  ${args.linkBlock?.placement === "after-cta" ? linkBlockHtml : ""}
156
+ ${closingParagraphsHtml}
148
157
  ${footerHtml}
149
158
  </td>
150
159
  </tr>
@@ -170,11 +179,19 @@ export function renderEmail(args) {
170
179
  textLines.push(`${args.cta.label}: ${args.cta.url}`);
171
180
  textLines.push("");
172
181
  }
182
+ if (args.secondaryCta) {
183
+ textLines.push(`${args.secondaryCta.label}: ${args.secondaryCta.url}`);
184
+ textLines.push("");
185
+ }
173
186
  if (args.linkBlock?.placement === "after-cta") {
174
187
  textLines.push(args.linkBlock.intro);
175
188
  textLines.push(args.linkBlock.url);
176
189
  textLines.push("");
177
190
  }
191
+ for (const p of args.closingParagraphs ?? []) {
192
+ textLines.push(stripTags(p));
193
+ textLines.push("");
194
+ }
178
195
  if (args.footer) {
179
196
  textLines.push(args.footer);
180
197
  }
@@ -1 +1 @@
1
- {"version":3,"file":"email-template.js","sourceRoot":"","sources":["../../src/server/email-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;AAoDtE,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC;SACL,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAA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EAAE,CAAC;QAC9C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACrC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACnC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC;SACL,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;SAC7B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,mDAAmD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,GAAW;IAClD,OAAO,YAAY,UAAU,CAAC,GAAG,CAAC,uDAAuD,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;AACnH,CAAC","sourcesContent":["/**\n * Reusable dark-themed HTML email template.\n *\n * Email clients have limited CSS support, so everything is inlined and layout\n * uses tables for Outlook compatibility. The design mirrors the app's dark UI:\n * near-black card on neutral background, Inter typography with safe fallbacks.\n *\n * Default is monochrome (white CTA on dark). Pass `brandColor` to tint the\n * CTA button and inline links — Clips, for example, passes its purple.\n *\n * Usage:\n * const { html, text } = renderEmail({\n * preheader: \"…\",\n * heading: \"You're invited to join Acme\",\n * paragraphs: [\"Alice invited you to join…\"],\n * cta: { label: \"Accept invite\", url: \"https://…\" },\n * footer: \"If you weren't expecting this, ignore this email.\",\n * });\n */\n\nimport { getAppName } from \"./app-name.js\";\n\nexport const AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID = \"agent-native-logo\";\n\nexport interface EmailCta {\n label: string;\n url: string;\n}\n\nexport interface EmailLinkBlock {\n intro: string;\n url: string;\n placement?: \"before-cta\" | \"after-cta\";\n}\n\nexport interface RenderEmailArgs {\n /** Short preview text shown by email clients next to the subject. */\n preheader?: string;\n /** Large headline at the top of the card. */\n heading: string;\n /** Body paragraphs rendered after the heading. Plain strings — escaped. */\n paragraphs: string[];\n /** Primary call-to-action rendered as a real button. */\n cta?: EmailCta;\n /** A treated, copyable URL shown before or after the CTA. */\n linkBlock?: EmailLinkBlock;\n /**\n * Optional trusted HTML injected above the CTA — e.g. a template-owned video\n * thumbnail with a play badge. Injected verbatim, so only pass markup built\n * by app/template code (never raw user input), and escape any dynamic values.\n */\n heroHtml?: string;\n /** Small muted text under the CTA (e.g. expiry note). */\n footer?: string;\n /** Optional app name shown beside the framework logo. */\n brandName?: string;\n /**\n * Optional absolute `https://` logo URL shown in the brand header. When a\n * valid URL is provided it replaces the default embedded Agent Native logo;\n * anything else (missing, relative, non-https) falls back to that logo.\n */\n brandLogoUrl?: string;\n /**\n * Optional brand hex color for the CTA button and inline links. Defaults to\n * a monochrome near-white button with dark text.\n */\n brandColor?: string;\n}\n\nexport interface RenderedEmail {\n html: string;\n text: string;\n}\n\nfunction escapeHtml(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n}\n\nfunction escapeAttr(s: string): string {\n return escapeHtml(s);\n}\n\n/**\n * Only accept a strict `#rrggbb` hex color for `brandColor`. Anything else\n * could inject CSS into the inline `style` attribute (`red; background:url(…)`).\n */\nfunction sanitizeHexColor(input: string | undefined): string | undefined {\n if (!input) return undefined;\n return /^#[0-9a-fA-F]{6}$/.test(input) ? input : undefined;\n}\n\n/**\n * Only accept an absolute `https://` URL for the brand logo. Email clients drop\n * relative and mixed-content images, and an unvalidated string in `src` is an\n * injection surface — so anything else falls back to the embedded logo.\n */\nfunction sanitizeLogoUrl(input: string | undefined): string | undefined {\n if (!input) return undefined;\n try {\n return new URL(input).protocol === \"https:\" ? input : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function renderEmail(args: RenderEmailArgs): RenderedEmail {\n const preheader = args.preheader || \"\";\n const brand = sanitizeHexColor(args.brandColor);\n const brandName = args.brandName?.trim() || getAppName() || \"Agent Native\";\n const logoSrc =\n sanitizeLogoUrl(args.brandLogoUrl) ??\n `cid:${AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID}`;\n\n // Monochrome default: near-white button with dark text. Brand override:\n // colored button with white text.\n const ctaBg = brand ?? \"#fafafa\";\n const ctaFg = brand ? \"#ffffff\" : \"#0a0a0c\";\n const linkColor = brand ?? \"#a1a1aa\";\n\n // Trusted markup supplied by the caller (template code, not user input),\n // injected as-is so a template can own app-specific previews (e.g. a video\n // thumbnail with a play badge). Callers are responsible for escaping any\n // dynamic values they interpolate.\n const heroHtml = args.heroHtml ?? \"\";\n\n const paragraphsHtml = args.paragraphs\n .map(\n (p) =>\n `<p style=\"margin:0 0 16px 0; font-size:16px; line-height:1.6; color:#d4d4d8;\">${p}</p>`,\n )\n .join(\"\");\n\n const linkBlockHtml = args.linkBlock\n ? `\n <p style=\"margin:24px 0 12px 0; font-size:15px; line-height:1.6; color:#d4d4d8;\">${escapeHtml(args.linkBlock.intro)}</p>\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"margin:0; border:1px solid #3f3f46; border-radius:10px; background:#0a0a0c;\">\n <tr>\n <td style=\"padding:14px 16px;\">\n <a href=\"${escapeAttr(args.linkBlock.url)}\" style=\"display:block; color:#d4d4d8; font-family:'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size:13px; line-height:1.5; text-decoration:none; word-break:break-all; overflow-wrap:anywhere;\">${escapeHtml(args.linkBlock.url)}</a>\n </td>\n </tr>\n </table>\n `\n : \"\";\n\n const ctaHtml = args.cta\n ? `\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:24px 0 0 0;\">\n <tr>\n <td style=\"border-radius:10px; background:${ctaBg};\">\n <a href=\"${escapeAttr(args.cta.url)}\"\n style=\"display:inline-block; padding:14px 26px; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size:15px; font-weight:600; color:${ctaFg}; text-decoration:none; border-radius:10px;\">\n ${escapeHtml(args.cta.label)}\n </a>\n </td>\n </tr>\n </table>\n `\n : \"\";\n\n const footerHtml = args.footer\n ? `<p style=\"margin:28px 0 0 0; font-size:13px; line-height:1.5; color:#71717a;\">${escapeHtml(args.footer)}</p>`\n : \"\";\n\n const brandHeaderHtml = `\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"margin:0 0 28px 0; padding:0 0 24px 0; border-bottom:1px solid #27272a;\">\n <tr>\n <td align=\"center\">\n <img src=\"${escapeAttr(logoSrc)}\" alt=\"${escapeAttr(brandName)}\" width=\"28\" height=\"28\" style=\"display:inline-block; vertical-align:middle; width:28px; height:28px; margin:0 8px 0 0; border:0;\" />\n <span style=\"font-size:18px; line-height:28px; font-weight:600; color:#fafafa; vertical-align:middle;\">${escapeHtml(brandName)}</span>\n </td>\n </tr>\n </table>`;\n\n const html = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"dark light\" />\n <meta name=\"supported-color-schemes\" content=\"dark light\" />\n <title>${escapeHtml(args.heading)}</title>\n <style>\n @media (prefers-color-scheme: light) {\n .bg-outer { background-color: #0a0a0c !important; }\n }\n a { color: ${linkColor}; }\n </style>\n </head>\n <body style=\"margin:0; padding:0; background-color:#0a0a0c; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing:antialiased;\">\n <div style=\"display:none; max-height:0; overflow:hidden; opacity:0; color:transparent;\">\n ${escapeHtml(preheader)}\n </div>\n <table role=\"presentation\" class=\"bg-outer\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"background-color:#0a0a0c; padding:40px 16px;\">\n <tr>\n <td align=\"center\">\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"max-width:560px;\">\n <tr>\n <td style=\"background-color:#141417; border:1px solid #27272a; border-radius:16px; padding:36px 36px 32px 36px;\">\n ${brandHeaderHtml}\n <h1 style=\"margin:0 0 20px 0; font-size:24px; line-height:1.3; font-weight:600; color:#fafafa; letter-spacing:-0.02em;\">\n ${escapeHtml(args.heading)}\n </h1>\n ${paragraphsHtml}\n ${heroHtml}\n ${args.linkBlock?.placement !== \"after-cta\" ? linkBlockHtml : \"\"}\n ${ctaHtml}\n ${args.linkBlock?.placement === \"after-cta\" ? linkBlockHtml : \"\"}\n ${footerHtml}\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </body>\n</html>`;\n\n const textLines: string[] = [];\n textLines.push(args.heading);\n textLines.push(\"\");\n for (const p of args.paragraphs) {\n textLines.push(stripTags(p));\n textLines.push(\"\");\n }\n if (args.linkBlock && args.linkBlock.placement !== \"after-cta\") {\n textLines.push(args.linkBlock.intro);\n textLines.push(args.linkBlock.url);\n textLines.push(\"\");\n }\n if (args.cta) {\n textLines.push(`${args.cta.label}: ${args.cta.url}`);\n textLines.push(\"\");\n }\n if (args.linkBlock?.placement === \"after-cta\") {\n textLines.push(args.linkBlock.intro);\n textLines.push(args.linkBlock.url);\n textLines.push(\"\");\n }\n if (args.footer) {\n textLines.push(args.footer);\n }\n\n return { html, text: textLines.join(\"\\n\").trim() };\n}\n\nfunction stripTags(s: string): string {\n return s\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&nbsp;/g, \" \")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .trim();\n}\n\n/**\n * Build an inline `<strong>` tag with consistent styling for use inside\n * paragraph strings passed to `renderEmail`. Escapes the content.\n */\nexport function emailStrong(text: string): string {\n return `<strong style=\"color:#fafafa; font-weight:600;\">${escapeHtml(text)}</strong>`;\n}\n\n/**\n * Build a labelled inline link for paragraph strings passed to `renderEmail`.\n * Use this instead of rendering raw URLs in the visible email body.\n */\nexport function emailLink(label: string, url: string): string {\n return `<a href=\"${escapeAttr(url)}\" style=\"color:#a1a1aa; text-decoration:underline;\">${escapeHtml(label)}</a>`;\n}\n"]}
1
+ {"version":3,"file":"email-template.js","sourceRoot":"","sources":["../../src/server/email-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;AAwDtE,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC;SACL,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAA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C;QAC7B,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC;SACL,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;SAC7B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,mDAAmD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,GAAW;IAClD,OAAO,YAAY,UAAU,CAAC,GAAG,CAAC,uDAAuD,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;AACnH,CAAC","sourcesContent":["/**\n * Reusable dark-themed HTML email template.\n *\n * Email clients have limited CSS support, so everything is inlined and layout\n * uses tables for Outlook compatibility. The design mirrors the app's dark UI:\n * near-black card on neutral background, Inter typography with safe fallbacks.\n *\n * Default is monochrome (white CTA on dark). Pass `brandColor` to tint the\n * CTA button and inline links — Clips, for example, passes its purple.\n *\n * Usage:\n * const { html, text } = renderEmail({\n * preheader: \"…\",\n * heading: \"You're invited to join Acme\",\n * paragraphs: [\"Alice invited you to join…\"],\n * cta: { label: \"Accept invite\", url: \"https://…\" },\n * footer: \"If you weren't expecting this, ignore this email.\",\n * });\n */\n\nimport { getAppName } from \"./app-name.js\";\n\nexport const AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID = \"agent-native-logo\";\n\nexport interface EmailCta {\n label: string;\n url: string;\n}\n\nexport interface EmailLinkBlock {\n intro: string;\n url: string;\n placement?: \"before-cta\" | \"after-cta\";\n}\n\nexport interface RenderEmailArgs {\n /** Short preview text shown by email clients next to the subject. */\n preheader?: string;\n /** Large headline at the top of the card. */\n heading: string;\n /** Body paragraphs rendered after the heading. Plain strings — escaped. */\n paragraphs: string[];\n /** Primary call-to-action rendered as a real button. */\n cta?: EmailCta;\n /** Optional second button rendered beside the primary CTA, dark-filled. */\n secondaryCta?: EmailCta;\n /** A treated, copyable URL shown before or after the CTA. */\n linkBlock?: EmailLinkBlock;\n /**\n * Optional trusted HTML injected above the CTA — e.g. a template-owned video\n * thumbnail with a play badge. Injected verbatim, so only pass markup built\n * by app/template code (never raw user input), and escape any dynamic values.\n */\n heroHtml?: string;\n /** Body paragraphs rendered after the CTA and link block. Escaped-by-caller. */\n closingParagraphs?: string[];\n /** Small muted text under the CTA (e.g. expiry note). */\n footer?: string;\n /** Optional app name shown beside the framework logo. */\n brandName?: string;\n /**\n * Optional absolute `https://` logo URL shown in the brand header. When a\n * valid URL is provided it replaces the default embedded Agent Native logo;\n * anything else (missing, relative, non-https) falls back to that logo.\n */\n brandLogoUrl?: string;\n /**\n * Optional brand hex color for the CTA button and inline links. Defaults to\n * a monochrome near-white button with dark text.\n */\n brandColor?: string;\n}\n\nexport interface RenderedEmail {\n html: string;\n text: string;\n}\n\nfunction escapeHtml(s: string): string {\n return s\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n}\n\nfunction escapeAttr(s: string): string {\n return escapeHtml(s);\n}\n\n/**\n * Only accept a strict `#rrggbb` hex color for `brandColor`. Anything else\n * could inject CSS into the inline `style` attribute (`red; background:url(…)`).\n */\nfunction sanitizeHexColor(input: string | undefined): string | undefined {\n if (!input) return undefined;\n return /^#[0-9a-fA-F]{6}$/.test(input) ? input : undefined;\n}\n\n/**\n * Only accept an absolute `https://` URL for the brand logo. Email clients drop\n * relative and mixed-content images, and an unvalidated string in `src` is an\n * injection surface — so anything else falls back to the embedded logo.\n */\nfunction sanitizeLogoUrl(input: string | undefined): string | undefined {\n if (!input) return undefined;\n try {\n return new URL(input).protocol === \"https:\" ? input : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function renderEmail(args: RenderEmailArgs): RenderedEmail {\n const preheader = args.preheader || \"\";\n const brand = sanitizeHexColor(args.brandColor);\n const brandName = args.brandName?.trim() || getAppName() || \"Agent Native\";\n const logoSrc =\n sanitizeLogoUrl(args.brandLogoUrl) ??\n `cid:${AGENT_NATIVE_EMAIL_LOGO_CONTENT_ID}`;\n\n // Monochrome default: near-white button with dark text. Brand override:\n // colored button with white text.\n const ctaBg = brand ?? \"#fafafa\";\n const ctaFg = brand ? \"#ffffff\" : \"#0a0a0c\";\n const linkColor = brand ?? \"#a1a1aa\";\n\n // Trusted markup supplied by the caller (template code, not user input),\n // injected as-is so a template can own app-specific previews (e.g. a video\n // thumbnail with a play badge). Callers are responsible for escaping any\n // dynamic values they interpolate.\n const heroHtml = args.heroHtml ?? \"\";\n\n const renderParagraphs = (paragraphs: string[] | undefined): string =>\n (paragraphs ?? [])\n .map(\n (p) =>\n `<p style=\"margin:0 0 16px 0; font-size:16px; line-height:1.6; color:#d4d4d8;\">${p}</p>`,\n )\n .join(\"\");\n\n const paragraphsHtml = renderParagraphs(args.paragraphs);\n const closingParagraphsHtml = args.closingParagraphs?.length\n ? `<div style=\"margin:28px 0 0 0;\">${renderParagraphs(args.closingParagraphs)}</div>`\n : \"\";\n\n const linkBlockHtml = args.linkBlock\n ? `\n <p style=\"margin:24px 0 12px 0; font-size:15px; line-height:1.6; color:#d4d4d8;\">${escapeHtml(args.linkBlock.intro)}</p>\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"margin:0; border:1px solid #3f3f46; border-radius:10px; background:#0a0a0c;\">\n <tr>\n <td style=\"padding:14px 16px;\">\n <a href=\"${escapeAttr(args.linkBlock.url)}\" style=\"display:block; color:#d4d4d8; font-family:'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size:13px; line-height:1.5; text-decoration:none; word-break:break-all; overflow-wrap:anywhere;\">${escapeHtml(args.linkBlock.url)}</a>\n </td>\n </tr>\n </table>\n `\n : \"\";\n\n const ctaButtonCell = (\n cta: EmailCta,\n background: string,\n color: string,\n border: string,\n ): string => `\n <td style=\"border-radius:10px; background:${background}; border:${border};\">\n <a href=\"${escapeAttr(cta.url)}\"\n style=\"display:inline-block; padding:14px 26px; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size:15px; font-weight:600; color:${color}; text-decoration:none; border-radius:10px;\">\n ${escapeHtml(cta.label)}\n </a>\n </td>`;\n\n const secondaryCtaHtml = args.secondaryCta\n ? `<td style=\"width:12px;\">&nbsp;</td>${ctaButtonCell(args.secondaryCta, \"#141417\", \"#fafafa\", \"1px solid #3f3f46\")}`\n : \"\";\n\n const ctaHtml = args.cta\n ? `\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"margin:24px 0 0 0;\">\n <tr>${ctaButtonCell(args.cta, ctaBg, ctaFg, \"0\")}${secondaryCtaHtml}\n </tr>\n </table>\n `\n : \"\";\n\n const footerHtml = args.footer\n ? `<p style=\"margin:28px 0 0 0; font-size:13px; line-height:1.5; color:#71717a;\">${escapeHtml(args.footer)}</p>`\n : \"\";\n\n const brandHeaderHtml = `\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"margin:0 0 28px 0; padding:0 0 24px 0; border-bottom:1px solid #27272a;\">\n <tr>\n <td align=\"center\">\n <img src=\"${escapeAttr(logoSrc)}\" alt=\"${escapeAttr(brandName)}\" width=\"28\" height=\"28\" style=\"display:inline-block; vertical-align:middle; width:28px; height:28px; margin:0 8px 0 0; border:0;\" />\n <span style=\"font-size:18px; line-height:28px; font-weight:600; color:#fafafa; vertical-align:middle;\">${escapeHtml(brandName)}</span>\n </td>\n </tr>\n </table>`;\n\n const html = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <meta name=\"color-scheme\" content=\"dark light\" />\n <meta name=\"supported-color-schemes\" content=\"dark light\" />\n <title>${escapeHtml(args.heading)}</title>\n <style>\n @media (prefers-color-scheme: light) {\n .bg-outer { background-color: #0a0a0c !important; }\n }\n a { color: ${linkColor}; }\n </style>\n </head>\n <body style=\"margin:0; padding:0; background-color:#0a0a0c; font-family:'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing:antialiased;\">\n <div style=\"display:none; max-height:0; overflow:hidden; opacity:0; color:transparent;\">\n ${escapeHtml(preheader)}\n </div>\n <table role=\"presentation\" class=\"bg-outer\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"background-color:#0a0a0c; padding:40px 16px;\">\n <tr>\n <td align=\"center\">\n <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"max-width:560px;\">\n <tr>\n <td style=\"background-color:#141417; border:1px solid #27272a; border-radius:16px; padding:36px 36px 32px 36px;\">\n ${brandHeaderHtml}\n <h1 style=\"margin:0 0 20px 0; font-size:24px; line-height:1.3; font-weight:600; color:#fafafa; letter-spacing:-0.02em;\">\n ${escapeHtml(args.heading)}\n </h1>\n ${paragraphsHtml}\n ${heroHtml}\n ${args.linkBlock?.placement !== \"after-cta\" ? linkBlockHtml : \"\"}\n ${ctaHtml}\n ${args.linkBlock?.placement === \"after-cta\" ? linkBlockHtml : \"\"}\n ${closingParagraphsHtml}\n ${footerHtml}\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </body>\n</html>`;\n\n const textLines: string[] = [];\n textLines.push(args.heading);\n textLines.push(\"\");\n for (const p of args.paragraphs) {\n textLines.push(stripTags(p));\n textLines.push(\"\");\n }\n if (args.linkBlock && args.linkBlock.placement !== \"after-cta\") {\n textLines.push(args.linkBlock.intro);\n textLines.push(args.linkBlock.url);\n textLines.push(\"\");\n }\n if (args.cta) {\n textLines.push(`${args.cta.label}: ${args.cta.url}`);\n textLines.push(\"\");\n }\n if (args.secondaryCta) {\n textLines.push(`${args.secondaryCta.label}: ${args.secondaryCta.url}`);\n textLines.push(\"\");\n }\n if (args.linkBlock?.placement === \"after-cta\") {\n textLines.push(args.linkBlock.intro);\n textLines.push(args.linkBlock.url);\n textLines.push(\"\");\n }\n for (const p of args.closingParagraphs ?? []) {\n textLines.push(stripTags(p));\n textLines.push(\"\");\n }\n if (args.footer) {\n textLines.push(args.footer);\n }\n\n return { html, text: textLines.join(\"\\n\").trim() };\n}\n\nfunction stripTags(s: string): string {\n return s\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&nbsp;/g, \" \")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .trim();\n}\n\n/**\n * Build an inline `<strong>` tag with consistent styling for use inside\n * paragraph strings passed to `renderEmail`. Escapes the content.\n */\nexport function emailStrong(text: string): string {\n return `<strong style=\"color:#fafafa; font-weight:600;\">${escapeHtml(text)}</strong>`;\n}\n\n/**\n * Build a labelled inline link for paragraph strings passed to `renderEmail`.\n * Use this instead of rendering raw URLs in the visible email body.\n */\nexport function emailLink(label: string, url: string): string {\n return `<a href=\"${escapeAttr(url)}\" style=\"color:#a1a1aa; text-decoration:underline;\">${escapeHtml(label)}</a>`;\n}\n"]}
@@ -100,6 +100,7 @@ export interface OAuthStatePayload {
100
100
  returnUrl?: string;
101
101
  flowId?: string;
102
102
  signupAttribution?: Record<string, string | undefined>;
103
+ signupAnonymousId?: string;
103
104
  }
104
105
  /**
105
106
  * Options for the named-argument form of {@link encodeOAuthState}.
@@ -117,6 +118,7 @@ export interface EncodeOAuthStateOptions {
117
118
  returnUrl?: string;
118
119
  flowId?: string;
119
120
  signupAttribution?: Record<string, string | undefined>;
121
+ signupAnonymousId?: string;
120
122
  }
121
123
  /**
122
124
  * Encode OAuth state into a signed base64url string.
@@ -168,6 +170,7 @@ export declare function createOAuthSession(event: H3Event, email: string, opts:
168
170
  authUserId?: string;
169
171
  name?: string | null;
170
172
  attribution?: Record<string, string | undefined>;
173
+ signupAnonymousId?: string;
171
174
  };
172
175
  }): Promise<OAuthSessionResult>;
173
176
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"google-oauth.d.ts","sourceRoot":"","sources":["../../src/server/google-oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AAkEZ;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAElD;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhD;AAqED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAGxE;AA2DD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgChD;AAED,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,MAAM,CAMvC;AAED,sEAAsE;AACtE,wB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,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,CAoHpE;AAED;;;kEAGkE;AAClE,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAMxD;AAED,wBAAgB,wBAAwB,CACtC,OAAO,SAA4B,GAClC,QAAQ,CAKV"}
@@ -8,9 +8,10 @@
8
8
  */
9
9
  import crypto from "node:crypto";
10
10
  import { getHeader, getQuery, setResponseStatus, setResponseHeader, } from "h3";
11
+ import { normalizeAnalyticsAnonymousId } from "../shared/analytics-anonymous-id.js";
11
12
  import { getAppBasePathFromViteEnv } from "./app-base-path.js";
12
13
  import { getAppName } from "./app-name.js";
13
- import { signupAttributionFromCookieHeader } from "./attribution.js";
14
+ import { readAnalyticsAnonymousId, signupAttributionFromCookieHeader, } from "./attribution.js";
14
15
  import { addSession, getSession, getSessionMaxAge, hasLegacySessionForEmail, setFrameworkSessionCookie, } from "./auth.js";
15
16
  import { hasBetterAuthUserEmail, trackSignupEvent, } from "./better-auth-instance.js";
16
17
  import { getWorkspaceA2ADerivedSecret } from "./derived-secret.js";
@@ -426,6 +427,9 @@ function sanitizeStateAttribution(value) {
426
427
  }
427
428
  return Object.keys(out).length > 0 ? out : undefined;
428
429
  }
430
+ function sanitizeStateAnonymousId(value) {
431
+ return normalizeAnalyticsAnonymousId(value);
432
+ }
429
433
  export function encodeOAuthState(redirectUriOrOpts, owner, desktop, addAccount, app, returnUrl, flowId) {
430
434
  const opts = typeof redirectUriOrOpts === "string"
431
435
  ? {
@@ -459,6 +463,9 @@ export function encodeOAuthState(redirectUriOrOpts, owner, desktop, addAccount,
459
463
  payload.f = opts.flowId;
460
464
  if (opts.signupAttribution)
461
465
  payload.ft = opts.signupAttribution;
466
+ const signupAnonymousId = normalizeAnalyticsAnonymousId(opts.signupAnonymousId);
467
+ if (signupAnonymousId)
468
+ payload.ai = signupAnonymousId;
462
469
  const data = Buffer.from(JSON.stringify(payload)).toString("base64url");
463
470
  const sig = crypto
464
471
  .createHmac("sha256", getStateSigningKey())
@@ -502,6 +509,7 @@ export function decodeOAuthState(stateParam, fallbackUri) {
502
509
  returnUrl: typeof parsed.r2 === "string" ? parsed.r2 : undefined,
503
510
  flowId: parsed.f || undefined,
504
511
  signupAttribution: sanitizeStateAttribution(parsed.ft),
512
+ signupAnonymousId: sanitizeStateAnonymousId(parsed.ai),
505
513
  };
506
514
  }
507
515
  catch { }
@@ -548,12 +556,15 @@ export async function createOAuthSession(event, email, opts) {
548
556
  if (shouldTrackSignup && opts.trackSignup) {
549
557
  const attribution = opts.trackSignup.attribution ??
550
558
  signupAttributionFromCookieHeader(getHeader(event, "cookie") ?? null);
559
+ const anonymousId = opts.trackSignup.signupAnonymousId ??
560
+ readAnalyticsAnonymousId(getHeader(event, "cookie") ?? null);
551
561
  await trackSignupEvent({
552
562
  authProvider: opts.trackSignup.authProvider,
553
563
  authUserId: opts.trackSignup.authUserId,
554
564
  email,
555
565
  name: opts.trackSignup.name,
556
566
  attribution,
567
+ anonymousId,
557
568
  });
558
569
  }
559
570
  // Desktop SSO: record this session in the home-dir broker file so