@agent-native/core 0.176.1 → 0.176.2-nightly-20260831185956

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 (1037) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +4 -0
  3. package/corpus/templates/analytics/.agents/skills/secrets/SKILL.md +47 -0
  4. package/corpus/templates/analytics/AGENTS.md +13 -2
  5. package/corpus/templates/analytics/CHANGELOG.md +8 -0
  6. package/corpus/templates/analytics/actions/certify-dashboard.ts +39 -0
  7. package/corpus/templates/analytics/actions/get-sql-dashboard.ts +1 -1
  8. package/corpus/templates/analytics/actions/list-analysis-revisions.ts +4 -2
  9. package/corpus/templates/analytics/actions/list-dashboard-revisions.ts +4 -2
  10. package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +1 -0
  11. package/corpus/templates/analytics/actions/search-dashboard-references.ts +2 -1
  12. package/corpus/templates/analytics/actions/set-workspace-feature-flag.ts +2 -2
  13. package/corpus/templates/analytics/app/components/agents/FeatureFlagsFleetPanel.tsx +16 -1
  14. package/corpus/templates/analytics/app/components/layout/Layout.tsx +58 -0
  15. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +7 -19
  16. package/corpus/templates/analytics/app/global.css +0 -7
  17. package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +1 -1
  18. package/corpus/templates/analytics/app/i18n-data.ts +42 -0
  19. package/corpus/templates/analytics/app/lib/track-metric.ts +15 -0
  20. package/corpus/templates/analytics/app/pages/NotFound.tsx +1 -1
  21. package/corpus/templates/analytics/app/pages/Placeholder.tsx +1 -1
  22. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +115 -2
  23. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +8 -0
  24. package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +23 -25
  25. package/corpus/templates/analytics/app/root.tsx +5 -5
  26. package/corpus/templates/analytics/app/routes/_index.tsx +18 -20
  27. package/corpus/templates/analytics/app/routes/dashboard.tsx +1 -1
  28. package/corpus/templates/analytics/app/routes/home.tsx +39 -0
  29. package/corpus/templates/analytics/changelog/2026-08-27-show-analytics-s-own-registered-flags-in-fleet-feature-flag-.md +6 -0
  30. package/corpus/templates/analytics/changelog/2026-08-28-analytics-loading-placeholders-now-use-a-smooth-whole-surfac.md +6 -0
  31. package/corpus/templates/analytics/changelog/2026-08-28-analytics-loading-states-use-a-softer-whole-surfac.md +6 -0
  32. package/corpus/templates/analytics/changelog/2026-08-28-analytics-sidebar-horizontal-spacing-is-tighter.md +6 -0
  33. package/corpus/templates/analytics/changelog/2026-08-28-sidebar-branding-matches-the-app-text-color-with-a-tighter-m.md +6 -0
  34. package/corpus/templates/analytics/changelog/2026-08-28-sidebar-branding-uses-a-monochrome-agent-native-mark.md +6 -0
  35. package/corpus/templates/analytics/changelog/2026-08-29-analytics-loading-shine-is-more-subtle.md +6 -0
  36. package/corpus/templates/analytics/changelog/2026-08-29-chat-edits-can-be-reverted-to-saved-checkpoints.md +6 -0
  37. package/corpus/templates/analytics/changelog/2026-08-29-dashboard-certification-lives-in-the-overflow-menu.md +6 -0
  38. package/corpus/templates/analytics/changelog/2026-08-29-public-marketing-home.md +6 -0
  39. package/corpus/templates/analytics/package.json +2 -0
  40. package/corpus/templates/analytics/public/manifest.json +1 -1
  41. package/corpus/templates/analytics/server/db/schema.ts +4 -0
  42. package/corpus/templates/analytics/server/handlers/events.ts +10 -1
  43. package/corpus/templates/analytics/server/handlers/first-party-analytics.ts +9 -1
  44. package/corpus/templates/analytics/server/handlers/session-replay.ts +10 -1
  45. package/corpus/templates/analytics/server/lib/agent-readable-resource-context.ts +22 -2
  46. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +82 -7
  47. package/corpus/templates/analytics/server/lib/dashboard-certification.ts +58 -0
  48. package/corpus/templates/analytics/server/lib/dashboard-report.ts +1 -0
  49. package/corpus/templates/analytics/server/lib/dashboards-store.ts +429 -46
  50. package/corpus/templates/analytics/server/lib/workspace-feature-flags.ts +204 -32
  51. package/corpus/templates/analytics/server/plugins/agent-chat.ts +139 -0
  52. package/corpus/templates/analytics/server/plugins/auth.ts +1 -0
  53. package/corpus/templates/analytics/server/plugins/core-routes.ts +3 -2
  54. package/corpus/templates/analytics/server/plugins/db.ts +11 -0
  55. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +4 -0
  56. package/corpus/templates/assets/.agents/skills/secrets/SKILL.md +47 -0
  57. package/corpus/templates/assets/app/components/layout/Header.tsx +2 -2
  58. package/corpus/templates/assets/app/components/layout/Layout.tsx +4 -3
  59. package/corpus/templates/assets/app/components/layout/Sidebar.tsx +14 -27
  60. package/corpus/templates/assets/app/hooks/use-navigation-state.ts +2 -2
  61. package/corpus/templates/assets/app/root.tsx +29 -9
  62. package/corpus/templates/assets/app/routes/_index.tsx +15 -116
  63. package/corpus/templates/assets/app/routes/chat.$threadId.tsx +1 -1
  64. package/corpus/templates/assets/app/routes/home.tsx +137 -0
  65. package/corpus/templates/assets/app/routes/library.tsx +5 -1
  66. package/corpus/templates/assets/app/routes/settings.tsx +28 -25
  67. package/corpus/templates/assets/changelog/2026-08-26-templates-across-brand-kits.md +1 -0
  68. package/corpus/templates/assets/public/manifest.json +1 -1
  69. package/corpus/templates/assets/server/plugins/auth.ts +1 -0
  70. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +4 -0
  71. package/corpus/templates/brain/.agents/skills/secrets/SKILL.md +47 -0
  72. package/corpus/templates/brain/app/components/layout/Layout.tsx +3 -3
  73. package/corpus/templates/brain/app/components/layout/Sidebar.tsx +10 -23
  74. package/corpus/templates/brain/app/lib/brain.ts +2 -2
  75. package/corpus/templates/brain/app/root.tsx +13 -3
  76. package/corpus/templates/brain/app/routes/_index.tsx +15 -55
  77. package/corpus/templates/brain/app/routes/home.tsx +76 -0
  78. package/corpus/templates/brain/app/routes.ts +1 -0
  79. package/corpus/templates/brain/public/manifest.json +1 -1
  80. package/corpus/templates/brain/server/lib/brain-health.ts +2 -2
  81. package/corpus/templates/brain/server/plugins/auth.ts +1 -1
  82. package/corpus/templates/brain/server/plugins/core-routes.ts +2 -1
  83. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +4 -0
  84. package/corpus/templates/calendar/.agents/skills/secrets/SKILL.md +47 -0
  85. package/corpus/templates/calendar/CHANGELOG.md +12 -0
  86. package/corpus/templates/calendar/actions/event-action-helpers.ts +2 -1
  87. package/corpus/templates/calendar/actions/manage-event-draft.ts +1 -1
  88. package/corpus/templates/calendar/actions/update-event.ts +8 -1
  89. package/corpus/templates/calendar/amplify.yml +15 -0
  90. package/corpus/templates/calendar/app/components/calendar/ApolloPanel.tsx +2 -2
  91. package/corpus/templates/calendar/app/components/calendar/CreateEventDialog.tsx +102 -109
  92. package/corpus/templates/calendar/app/components/calendar/DayView.tsx +23 -10
  93. package/corpus/templates/calendar/app/components/calendar/DeleteEventDialog.tsx +2 -11
  94. package/corpus/templates/calendar/app/components/calendar/EventAttendeesSection.tsx +150 -141
  95. package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +3 -1
  96. package/corpus/templates/calendar/app/components/calendar/EventDescription.tsx +2 -2
  97. package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +359 -222
  98. package/corpus/templates/calendar/app/components/calendar/InlineEventPickers.tsx +13 -5
  99. package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +21 -9
  100. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +21 -32
  101. package/corpus/templates/calendar/app/global.css +11 -0
  102. package/corpus/templates/calendar/app/hooks/use-meeting-start-notifications.ts +10 -0
  103. package/corpus/templates/calendar/app/hooks/use-navigation-state.ts +3 -3
  104. package/corpus/templates/calendar/app/i18n-data.ts +110 -0
  105. package/corpus/templates/calendar/app/lib/calendar-timezone.ts +12 -3
  106. package/corpus/templates/calendar/app/lib/event-popover-style.ts +43 -0
  107. package/corpus/templates/calendar/app/lib/mcp-embed.ts +8 -2
  108. package/corpus/templates/calendar/app/lib/utils.ts +3 -1
  109. package/corpus/templates/calendar/app/pages/BookingPage.tsx +2 -8
  110. package/corpus/templates/calendar/app/pages/CalendarView.tsx +9 -11
  111. package/corpus/templates/calendar/app/pages/ManageBookingPage.tsx +2 -6
  112. package/corpus/templates/calendar/app/pages/NotFound.tsx +1 -1
  113. package/corpus/templates/calendar/app/pages/Settings.tsx +54 -0
  114. package/corpus/templates/calendar/app/root.tsx +9 -1
  115. package/corpus/templates/calendar/app/routes/{_app._index.tsx → _app.home.tsx} +1 -1
  116. package/corpus/templates/calendar/app/routes/_index.tsx +34 -0
  117. package/corpus/templates/calendar/app/routes/event.tsx +2 -6
  118. package/corpus/templates/calendar/changelog/2026-08-28-all-day-events-stay-in-the-compact-top-bar-in-day-and-week-v.md +6 -0
  119. package/corpus/templates/calendar/changelog/2026-08-28-calendar-organizer-note-emails-now-link-back-to-agent-native.md +6 -0
  120. package/corpus/templates/calendar/changelog/2026-08-28-calendar-shows-google-profile-photos-in-the-desktop-app.md +6 -0
  121. package/corpus/templates/calendar/changelog/2026-08-28-event-creators-can-choose-whether-a-meeting-shows-as-free-or.md +6 -0
  122. package/corpus/templates/calendar/changelog/2026-08-28-event-popovers-match-notion-calendar-s-density-a-284px-blurr.md +6 -0
  123. package/corpus/templates/calendar/changelog/2026-08-28-fixed-calendar-navigation-scheduling-permissions-and-action-.md +6 -0
  124. package/corpus/templates/calendar/changelog/2026-08-28-google-calendar-connections-use-the-registered-callback-on-m.md +6 -0
  125. package/corpus/templates/calendar/changelog/2026-08-28-sidebar-branding-matches-the-app-text-color-with-a-tighter-m.md +6 -0
  126. package/corpus/templates/calendar/changelog/2026-08-28-sidebar-branding-uses-a-monochrome-agent-native-mark.md +6 -0
  127. package/corpus/templates/calendar/changelog/2026-08-28-the-calendar-sidebar-keeps-the-settings-link-compact.md +6 -0
  128. package/corpus/templates/calendar/changelog/2026-08-28-the-calendar-sidebar-keeps-the-workspace-picker-compact.md +6 -0
  129. package/corpus/templates/calendar/changelog/2026-08-29-public-marketing-home.md +6 -0
  130. package/corpus/templates/calendar/public/manifest.json +1 -1
  131. package/corpus/templates/calendar/server/handlers/google-auth.ts +10 -2
  132. package/corpus/templates/calendar/server/lib/emails.ts +2 -1
  133. package/corpus/templates/calendar/server/lib/event-guest-notifications.ts +31 -5
  134. package/corpus/templates/calendar/server/lib/google-calendar.ts +4 -2
  135. package/corpus/templates/calendar/server/plugins/auth.ts +1 -0
  136. package/corpus/templates/calendar/server/plugins/core-routes.ts +5 -3
  137. package/corpus/templates/calendar/shared/event-permissions.ts +12 -0
  138. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -0
  139. package/corpus/templates/chat/.agents/skills/secrets/SKILL.md +47 -0
  140. package/corpus/templates/chat/AGENTS.md +5 -4
  141. package/corpus/templates/chat/app/components/layout/Header.tsx +1 -1
  142. package/corpus/templates/chat/app/components/layout/Layout.tsx +5 -4
  143. package/corpus/templates/chat/app/components/layout/Sidebar.tsx +16 -25
  144. package/corpus/templates/chat/app/hooks/use-navigation-state.ts +5 -5
  145. package/corpus/templates/chat/app/root.tsx +16 -3
  146. package/corpus/templates/chat/app/routes/_index.tsx +17 -74
  147. package/corpus/templates/chat/app/routes/chat.$threadId.tsx +1 -1
  148. package/corpus/templates/chat/app/routes/home.tsx +94 -0
  149. package/corpus/templates/chat/netlify.toml +2 -1
  150. package/corpus/templates/chat/public/manifest.json +1 -1
  151. package/corpus/templates/chat/server/plugins/auth.ts +1 -0
  152. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +4 -0
  153. package/corpus/templates/clips/.agents/skills/secrets/SKILL.md +47 -0
  154. package/corpus/templates/clips/actions/add-comment.ts +18 -1
  155. package/corpus/templates/clips/actions/get-recording-player-data.ts +2 -0
  156. package/corpus/templates/clips/actions/list-comments.ts +2 -0
  157. package/corpus/templates/clips/actions/list-notifications.ts +60 -28
  158. package/corpus/templates/clips/actions/list-recording-mention-members.ts +64 -0
  159. package/corpus/templates/clips/actions/list-recordings.ts +1 -1
  160. package/corpus/templates/clips/actions/reply-to-comment.ts +17 -1
  161. package/corpus/templates/clips/actions/update-comment.ts +36 -2
  162. package/corpus/templates/clips/app/components/library/empty-state.tsx +1 -3
  163. package/corpus/templates/clips/app/components/library/library-grid.tsx +18 -6
  164. package/corpus/templates/clips/app/components/library/library-layout.tsx +6 -58
  165. package/corpus/templates/clips/app/components/library/recording-card.tsx +101 -3
  166. package/corpus/templates/clips/app/components/library/sort-menu.tsx +2 -2
  167. package/corpus/templates/clips/app/components/player/comment-composer.tsx +284 -0
  168. package/corpus/templates/clips/app/components/player/comments-panel.tsx +162 -46
  169. package/corpus/templates/clips/app/components/player/transcript-panel.tsx +38 -133
  170. package/corpus/templates/clips/app/components/player/video-player.tsx +1 -1
  171. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +99 -20
  172. package/corpus/templates/clips/app/components/recorder/recording-toolbar.tsx +110 -116
  173. package/corpus/templates/clips/app/components/recorder/storage-setup-card.tsx +83 -60
  174. package/corpus/templates/clips/app/components/settings/ai-setup-section.tsx +17 -11
  175. package/corpus/templates/clips/app/components/settings/types.ts +5 -1
  176. package/corpus/templates/clips/app/components/settings/video-storage-section.tsx +21 -12
  177. package/corpus/templates/clips/app/global.css +0 -27
  178. package/corpus/templates/clips/app/hooks/use-desktop-promo.ts +3 -17
  179. package/corpus/templates/clips/app/hooks/use-mention-members.ts +24 -0
  180. package/corpus/templates/clips/app/hooks/use-navigation-state.ts +2 -2
  181. package/corpus/templates/clips/app/i18n/en-US.ts +15 -0
  182. package/corpus/templates/clips/app/lib/recording-backup.ts +245 -0
  183. package/corpus/templates/clips/app/lib/recording-retry.ts +189 -0
  184. package/corpus/templates/clips/app/lib/recording-status.ts +32 -0
  185. package/corpus/templates/clips/app/root.tsx +11 -2
  186. package/corpus/templates/clips/app/routes/_app.home.tsx +62 -0
  187. package/corpus/templates/clips/app/routes/_app.notifications.tsx +45 -12
  188. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +2 -0
  189. package/corpus/templates/clips/app/routes/_index.tsx +11 -40
  190. package/corpus/templates/clips/app/routes/download.tsx +148 -15
  191. package/corpus/templates/clips/app/routes/embed.$shareId.tsx +4 -3
  192. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +6 -11
  193. package/corpus/templates/clips/app/routes/record.tsx +72 -13
  194. package/corpus/templates/clips/app/routes/share.$shareId.tsx +40 -24
  195. package/corpus/templates/clips/app/routes/share.meeting.$meetingId.tsx +2 -7
  196. package/corpus/templates/clips/changelog/2026-08-28-chrome-extension-download-help.md +6 -0
  197. package/corpus/templates/clips/changelog/2026-08-28-clips-loading-skeletons-use-a-softer-whole-surface.md +6 -0
  198. package/corpus/templates/clips/changelog/2026-08-28-comment-composer-no-longer-has-an-outer-border.md +6 -0
  199. package/corpus/templates/clips/changelog/2026-08-29-clips-loading-shine-is-more-subtle.md +6 -0
  200. package/corpus/templates/clips/desktop/src/app.tsx +377 -476
  201. package/corpus/templates/clips/desktop/src/components/ui/skeleton.tsx +1 -1
  202. package/corpus/templates/clips/desktop/src/components/ui/spinner.tsx +1 -17
  203. package/corpus/templates/clips/desktop/src/lib/recorder.ts +4 -0
  204. package/corpus/templates/clips/desktop/src/overlays/countdown.tsx +0 -8
  205. package/corpus/templates/clips/desktop/src/overlays/record-pill.tsx +221 -460
  206. package/corpus/templates/clips/desktop/src/styles.css +0 -40
  207. package/corpus/templates/clips/desktop/src/tailwind.css +28 -14
  208. package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +15 -11
  209. package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +9 -0
  210. package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +192 -57
  211. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +9 -3
  212. package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +12 -0
  213. package/corpus/templates/clips/desktop/src-tauri/src/util.rs +97 -3
  214. package/corpus/templates/clips/public/manifest.json +1 -1
  215. package/corpus/templates/clips/server/db/schema.ts +1 -0
  216. package/corpus/templates/clips/server/lib/activity-notifications.ts +30 -5
  217. package/corpus/templates/clips/server/lib/comment-mentions.ts +23 -0
  218. package/corpus/templates/clips/server/lib/emails.ts +2 -2
  219. package/corpus/templates/clips/server/lib/recording-page-access.ts +16 -0
  220. package/corpus/templates/clips/server/lib/transactional-email-templates.ts +14 -7
  221. package/corpus/templates/clips/server/plugins/auth.ts +1 -0
  222. package/corpus/templates/clips/server/plugins/core-routes.ts +5 -0
  223. package/corpus/templates/clips/server/plugins/db.ts +5 -0
  224. package/corpus/templates/clips/server/routes/api/auth/google-calendar.get.ts +4 -2
  225. package/corpus/templates/clips/server/routes/api/clips-latest.json.get.ts +77 -22
  226. package/corpus/templates/clips/server/routes/api/public-recording.get.ts +11 -0
  227. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +4 -4
  228. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/resume.get.ts +1 -1
  229. package/corpus/templates/clips/shared/comment-mentions.ts +71 -0
  230. package/corpus/templates/clips/shared/prerendered-public-paths.ts +1 -1
  231. package/corpus/templates/clips/shared/recording-core.ts +5 -0
  232. package/corpus/templates/clips/shared/recording-playhead.css +207 -0
  233. package/corpus/templates/clips/shared/recording-playhead.tsx +616 -0
  234. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +4 -0
  235. package/corpus/templates/content/.agents/skills/secrets/SKILL.md +47 -0
  236. package/corpus/templates/content/CHANGELOG.md +6 -0
  237. package/corpus/templates/content/actions/_property-utils.ts +45 -9
  238. package/corpus/templates/content/actions/edit-document.ts +17 -0
  239. package/corpus/templates/content/actions/get-document.ts +31 -11
  240. package/corpus/templates/content/actions/list-document-properties.ts +30 -2
  241. package/corpus/templates/content/actions/list-document-versions.ts +49 -17
  242. package/corpus/templates/content/actions/list-documents.ts +13 -2
  243. package/corpus/templates/content/actions/restore-document-version.ts +8 -1
  244. package/corpus/templates/content/actions/update-document.ts +8 -0
  245. package/corpus/templates/content/app/components/QueryErrorState.tsx +1 -0
  246. package/corpus/templates/content/app/components/editor/DocumentBlockFields.tsx +28 -8
  247. package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +94 -61
  248. package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +24 -10
  249. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +16 -13
  250. package/corpus/templates/content/app/components/editor/database/settings.tsx +16 -13
  251. package/corpus/templates/content/app/components/layout/Layout.tsx +35 -1
  252. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +5 -18
  253. package/corpus/templates/content/app/hooks/use-document-properties.ts +5 -3
  254. package/corpus/templates/content/app/hooks/use-documents.ts +3 -1
  255. package/corpus/templates/content/app/hooks/use-navigation-state.ts +3 -3
  256. package/corpus/templates/content/app/root.tsx +9 -4
  257. package/corpus/templates/content/app/routes/{_app._index.tsx → _app.home.tsx} +12 -4
  258. package/corpus/templates/content/app/routes/_index.tsx +33 -0
  259. package/corpus/templates/content/changelog/2026-08-26-shared-page-load-failures-now-stay-visible-and-safe.md +6 -0
  260. package/corpus/templates/content/docs/product/capabilities/content.workspace.session-restore.md +2 -2
  261. package/corpus/templates/content/e2e/playwright.config.ts +1 -1
  262. package/corpus/templates/content/package.json +2 -0
  263. package/corpus/templates/content/parity/matrix.md +1 -1
  264. package/corpus/templates/content/parity/matrix.ts +1 -1
  265. package/corpus/templates/content/public/manifest.json +1 -1
  266. package/corpus/templates/content/server/db/schema.ts +1 -0
  267. package/corpus/templates/content/server/lib/document-version-context.ts +67 -0
  268. package/corpus/templates/content/server/plugins/agent-chat.ts +155 -0
  269. package/corpus/templates/content/server/plugins/auth.ts +1 -0
  270. package/corpus/templates/content/server/plugins/core-routes.ts +3 -2
  271. package/corpus/templates/content/server/plugins/db.ts +5 -0
  272. package/corpus/templates/content/shared/api.ts +6 -4
  273. package/corpus/templates/crm/.agents/skills/frontend-design/SKILL.md +4 -0
  274. package/corpus/templates/crm/.agents/skills/secrets/SKILL.md +47 -0
  275. package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +1 -1
  276. package/corpus/templates/crm/agent-native.app-skill.json +1 -1
  277. package/corpus/templates/crm/app/components/layout/CrmCommandMenu.tsx +1 -1
  278. package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +36 -1
  279. package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +3 -3
  280. package/corpus/templates/crm/app/root.tsx +28 -7
  281. package/corpus/templates/crm/app/routes/_index.tsx +28 -18
  282. package/corpus/templates/crm/app/routes/home.tsx +27 -0
  283. package/corpus/templates/crm/app/routes/setup.tsx +2 -2
  284. package/corpus/templates/crm/app/routes.ts +1 -0
  285. package/corpus/templates/crm/public/manifest.json +1 -1
  286. package/corpus/templates/crm/server/plugins/agent-chat.ts +81 -0
  287. package/corpus/templates/crm/server/plugins/auth.ts +1 -0
  288. package/corpus/templates/crm/server/plugins/core-routes.ts +2 -1
  289. package/corpus/templates/crm/server/plugins/db.ts +7 -1
  290. package/corpus/templates/crm/shared/crm-navigation.ts +3 -2
  291. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +13 -0
  292. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +4 -0
  293. package/corpus/templates/design/.agents/skills/secrets/SKILL.md +47 -0
  294. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +22 -10
  295. package/corpus/templates/design/AGENTS.md +1 -1
  296. package/corpus/templates/design/actions/add-breakpoint.ts +3 -1
  297. package/corpus/templates/design/actions/add-fusion-screens.ts +2 -0
  298. package/corpus/templates/design/actions/add-localhost-screens.ts +16 -11
  299. package/corpus/templates/design/actions/apply-a11y-fix.ts +6 -8
  300. package/corpus/templates/design/actions/apply-component-prop-edit.ts +3 -1
  301. package/corpus/templates/design/actions/apply-design-token-edit.ts +3 -1
  302. package/corpus/templates/design/actions/apply-motion-edit.ts +18 -13
  303. package/corpus/templates/design/actions/apply-shader-fill.ts +3 -1
  304. package/corpus/templates/design/actions/apply-source-edit.ts +6 -1
  305. package/corpus/templates/design/actions/apply-tweaks.ts +3 -1
  306. package/corpus/templates/design/actions/apply-visual-edit.ts +14 -9
  307. package/corpus/templates/design/actions/clone-creative-context-design.ts +6 -1
  308. package/corpus/templates/design/actions/create-component.ts +3 -1
  309. package/corpus/templates/design/actions/create-file.ts +3 -1
  310. package/corpus/templates/design/actions/delete-file.ts +3 -1
  311. package/corpus/templates/design/actions/detach-component-instance.ts +3 -1
  312. package/corpus/templates/design/actions/edit-design.ts +16 -11
  313. package/corpus/templates/design/actions/generate-design.ts +19 -14
  314. package/corpus/templates/design/actions/get-design-branch-diff.ts +26 -31
  315. package/corpus/templates/design/actions/get-design-review.ts +25 -31
  316. package/corpus/templates/design/actions/get-design-system-index-status.ts +55 -0
  317. package/corpus/templates/design/actions/get-design-system.ts +1 -1
  318. package/corpus/templates/design/actions/hydrate-figma-paste-images.ts +3 -1
  319. package/corpus/templates/design/actions/import-design-source.ts +16 -9
  320. package/corpus/templates/design/actions/import-design-tokens.ts +3 -1
  321. package/corpus/templates/design/actions/import-figma-clipboard.ts +28 -16
  322. package/corpus/templates/design/actions/import-figma-frame.ts +3 -1
  323. package/corpus/templates/design/actions/insert-asset.ts +3 -1
  324. package/corpus/templates/design/actions/insert-design-native-asset.ts +3 -1
  325. package/corpus/templates/design/actions/insert-figma-library-asset.ts +3 -1
  326. package/corpus/templates/design/actions/list-design-versions.ts +23 -0
  327. package/corpus/templates/design/actions/migrate-board-objects-to-file.ts +3 -1
  328. package/corpus/templates/design/actions/open-visual-edit.ts +23 -20
  329. package/corpus/templates/design/actions/present-design-variants.ts +7 -2
  330. package/corpus/templates/design/actions/refresh-design-system-with-builder.ts +66 -10
  331. package/corpus/templates/design/actions/remove-breakpoint.ts +3 -1
  332. package/corpus/templates/design/actions/remove-motion-timeline.ts +3 -1
  333. package/corpus/templates/design/actions/restore-design-version.ts +16 -0
  334. package/corpus/templates/design/actions/set-layout-grid.ts +94 -0
  335. package/corpus/templates/design/actions/swap-component-instance.ts +6 -1
  336. package/corpus/templates/design/actions/update-design.ts +16 -11
  337. package/corpus/templates/design/actions/update-file.ts +2 -0
  338. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +25 -0
  339. package/corpus/templates/design/app/components/design/EditPanel.tsx +36 -8
  340. package/corpus/templates/design/app/components/design/LayersPanel.tsx +6 -6
  341. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +185 -29
  342. package/corpus/templates/design/app/components/design/ReviewCommentsPanel.tsx +4 -4
  343. package/corpus/templates/design/app/components/design/ReviewPanel.tsx +1 -1
  344. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +35 -10
  345. package/corpus/templates/design/app/components/design/canvas-primitive-style.ts +16 -9
  346. package/corpus/templates/design/app/components/design/edit-panel/component-section.tsx +51 -21
  347. package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +18 -17
  348. package/corpus/templates/design/app/components/design/edit-panel/field-primitives.tsx +6 -1
  349. package/corpus/templates/design/app/components/design/edit-panel/frame-presets-panel.tsx +3 -3
  350. package/corpus/templates/design/app/components/design/edit-panel/layout-grid-properties.tsx +88 -0
  351. package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +5 -2
  352. package/corpus/templates/design/app/components/design/edit-panel/position-layout-properties.tsx +8 -4
  353. package/corpus/templates/design/app/components/design/edit-panel/typography-helpers.ts +8 -103
  354. package/corpus/templates/design/app/components/design/edit-panel/typography-properties.tsx +68 -83
  355. package/corpus/templates/design/app/components/design/editor/MakeRealDialog.tsx +35 -10
  356. package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +29 -24
  357. package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +6 -0
  358. package/corpus/templates/design/app/components/design/inspector/GlslShaderPanel.tsx +72 -71
  359. package/corpus/templates/design/app/components/design/inspector/InspectorControlPopover.tsx +1 -1
  360. package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +9 -0
  361. package/corpus/templates/design/app/components/design/multi-screen/types.ts +8 -0
  362. package/corpus/templates/design/app/components/layout/Layout.tsx +32 -0
  363. package/corpus/templates/design/app/components/layout/Sidebar.tsx +8 -21
  364. package/corpus/templates/design/app/global.css +72 -1
  365. package/corpus/templates/design/app/hooks/use-navigation-state.ts +1 -1
  366. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +32 -1
  367. package/corpus/templates/design/app/i18n-data.ts +116 -12
  368. package/corpus/templates/design/app/i18n-keyboard-shortcuts.ts +3 -1
  369. package/corpus/templates/design/app/lib/design-system-data.ts +36 -0
  370. package/corpus/templates/design/app/pages/DesignEditor.tsx +170 -34
  371. package/corpus/templates/design/app/pages/DesignSystems.tsx +126 -11
  372. package/corpus/templates/design/app/pages/Index.tsx +15 -7
  373. package/corpus/templates/design/app/pages/NotFound.tsx +1 -1
  374. package/corpus/templates/design/app/pages/Templates.tsx +18 -3
  375. package/corpus/templates/design/app/pages/VisualEdit.tsx +1 -1
  376. package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +3 -3
  377. package/corpus/templates/design/app/pages/design-editor/commands/README.md +1 -0
  378. package/corpus/templates/design/app/pages/design-editor/commands/geometry-commit.ts +2 -1
  379. package/corpus/templates/design/app/pages/design-editor/commands/set-layout-grid.ts +66 -0
  380. package/corpus/templates/design/app/pages/design-editor/design-data-geometry-utils.ts +5 -0
  381. package/corpus/templates/design/app/pages/design-editor/effects/publish-agent-selection-context.ts +9 -1
  382. package/corpus/templates/design/app/pages/design-editor/effects/resume-pending-generation.ts +39 -9
  383. package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +31 -2
  384. package/corpus/templates/design/app/pages/design-editor/geometry-persistence.ts +26 -0
  385. package/corpus/templates/design/app/pages/design-editor/intake-question-topics.ts +335 -0
  386. package/corpus/templates/design/app/pages/design-editor/nudge-intent.ts +8 -1
  387. package/corpus/templates/design/app/root.tsx +12 -2
  388. package/corpus/templates/design/app/routes/_index.tsx +14 -1
  389. package/corpus/templates/design/app/routes/home.tsx +21 -0
  390. package/corpus/templates/design/changelog/2026-08-21-builder-design-system-imports-reconcile-after-indexing.md +1 -1
  391. package/corpus/templates/design/changelog/2026-08-28-frames-can-carry-an-8px-layout-grid-that-positions-snap-to.md +6 -0
  392. package/corpus/templates/design/changelog/2026-08-28-x-and-y-are-always-whole-numbers.md +6 -0
  393. package/corpus/templates/design/public/manifest.json +1 -1
  394. package/corpus/templates/design/server/db/schema.ts +2 -0
  395. package/corpus/templates/design/server/handlers/design-system-builder-link.ts +84 -0
  396. package/corpus/templates/design/server/lib/builder-design-system-proxy.ts +9 -1
  397. package/corpus/templates/design/server/lib/design-versions.ts +1017 -0
  398. package/corpus/templates/design/server/plugins/agent-chat.ts +144 -0
  399. package/corpus/templates/design/server/plugins/auth.ts +1 -1
  400. package/corpus/templates/design/server/plugins/core-routes.ts +3 -2
  401. package/corpus/templates/design/server/plugins/db.ts +7 -0
  402. package/corpus/templates/design/server/routes/api/design-system-builder-link.get.ts +1 -0
  403. package/corpus/templates/design/shared/canvas-math.ts +106 -14
  404. package/corpus/templates/design/shared/layout-grid.ts +80 -0
  405. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +4 -0
  406. package/corpus/templates/dispatch/.agents/skills/secrets/SKILL.md +47 -0
  407. package/corpus/templates/dispatch/AGENTS.md +11 -13
  408. package/corpus/templates/dispatch/actions/list-workspace-connections.ts +10 -5
  409. package/corpus/templates/dispatch/app/i18n-data.ts +120 -0
  410. package/corpus/templates/dispatch/app/root.tsx +11 -1
  411. package/corpus/templates/dispatch/app/routes/_index.tsx +34 -7
  412. package/corpus/templates/dispatch/app/routes/home.tsx +7 -0
  413. package/corpus/templates/dispatch/package.json +1 -0
  414. package/corpus/templates/dispatch/public/manifest.json +1 -1
  415. package/corpus/templates/factory/.agents/skills/factory-graphs/SKILL.md +11 -2
  416. package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +4 -0
  417. package/corpus/templates/factory/.agents/skills/secrets/SKILL.md +47 -0
  418. package/corpus/templates/factory/.env.example +2 -14
  419. package/corpus/templates/factory/AGENTS.md +12 -11
  420. package/corpus/templates/factory/README.md +15 -17
  421. package/corpus/templates/factory/actions/{babysit-agent-native-pull-request.ts → babysit-factory-pull-request.ts} +125 -88
  422. package/corpus/templates/factory/actions/create-factory-automation.ts +161 -0
  423. package/corpus/templates/factory/actions/create-factory.ts +4 -124
  424. package/corpus/templates/factory/actions/delete-factory.ts +11 -23
  425. package/corpus/templates/factory/actions/{start-builder-for-item.ts → dispatch-factory-item.ts} +169 -57
  426. package/corpus/templates/factory/actions/get-slack-feedback-context.ts +30 -10
  427. package/corpus/templates/factory/actions/get-triage-config.ts +22 -0
  428. package/corpus/templates/factory/actions/get-triage-item.ts +49 -2
  429. package/corpus/templates/factory/actions/{govern-agent-native-pull-request.ts → govern-factory-pull-request.ts} +95 -112
  430. package/corpus/templates/factory/actions/ingest-github-observation.ts +9 -2
  431. package/corpus/templates/factory/actions/list-factory-audit.ts +85 -12
  432. package/corpus/templates/factory/actions/list-factory-automation-templates.ts +56 -0
  433. package/corpus/templates/factory/actions/list-factory-automations.ts +36 -3
  434. package/corpus/templates/factory/actions/list-factory-graph-versions.ts +37 -10
  435. package/corpus/templates/factory/actions/list-triage-items.ts +120 -15
  436. package/corpus/templates/factory/actions/poll-github-sources.ts +102 -58
  437. package/corpus/templates/factory/actions/poll-sentry-errors.ts +73 -36
  438. package/corpus/templates/factory/actions/poll-slack-channel.ts +112 -28
  439. package/corpus/templates/factory/actions/{babysit-pull-request.ts → propose-pr-babysit-status.ts} +9 -47
  440. package/corpus/templates/factory/actions/reconcile-triage-run.ts +1 -1
  441. package/corpus/templates/factory/actions/save-factory-automation.ts +131 -33
  442. package/corpus/templates/factory/actions/save-factory-graph.ts +31 -8
  443. package/corpus/templates/factory/actions/save-triage-config.ts +7 -27
  444. package/corpus/templates/factory/actions/save-triage-rule.ts +1 -1
  445. package/corpus/templates/factory/app/components/factory/CreateFactoryAutomationView.tsx +258 -0
  446. package/corpus/templates/factory/app/components/factory/FactoryAuditView.tsx +349 -106
  447. package/corpus/templates/factory/app/components/factory/FactoryAutomationFields.tsx +614 -0
  448. package/corpus/templates/factory/app/components/factory/FactoryInboxView.tsx +1136 -0
  449. package/corpus/templates/factory/app/components/factory/FactoryInspector.tsx +7 -14
  450. package/corpus/templates/factory/app/components/factory/FactorySettingsView.tsx +4 -223
  451. package/corpus/templates/factory/app/components/factory/NewFactoryForm.tsx +10 -205
  452. package/corpus/templates/factory/app/components/factory/SlackMrkdwn.tsx +100 -0
  453. package/corpus/templates/factory/app/components/factory/audit-filters.ts +30 -0
  454. package/corpus/templates/factory/app/components/factory/factory-automation-form.ts +120 -0
  455. package/corpus/templates/factory/app/components/factory/inbox-filters.ts +84 -0
  456. package/corpus/templates/factory/app/components/factory/inbox-source-url.ts +23 -0
  457. package/corpus/templates/factory/app/components/factory/slack-emoji.ts +165 -0
  458. package/corpus/templates/factory/app/components/factory/slack-mrkdwn.ts +128 -0
  459. package/corpus/templates/factory/app/components/layout/Header.tsx +1 -1
  460. package/corpus/templates/factory/app/components/layout/Layout.tsx +63 -6
  461. package/corpus/templates/factory/app/components/layout/Sidebar.tsx +13 -26
  462. package/corpus/templates/factory/app/components/triage/triage-status-pill.tsx +63 -14
  463. package/corpus/templates/factory/app/global.css +106 -0
  464. package/corpus/templates/factory/app/hooks/use-navigation-state.ts +16 -10
  465. package/corpus/templates/factory/app/i18n/en-US.ts +154 -7
  466. package/corpus/templates/factory/app/lib/factory-tab-params.ts +59 -0
  467. package/corpus/templates/factory/app/lib/safe-http-url.ts +8 -0
  468. package/corpus/templates/factory/app/root.tsx +16 -3
  469. package/corpus/templates/factory/app/routes/_index.tsx +27 -5
  470. package/corpus/templates/factory/app/routes/factory.tsx +325 -733
  471. package/corpus/templates/factory/app/routes/home.tsx +13 -0
  472. package/corpus/templates/factory/app/routes/new-factory.tsx +3 -5
  473. package/corpus/templates/factory/changelog/2026-08-26-inbox-full-screen-thread.md +6 -0
  474. package/corpus/templates/factory/changelog/2026-08-26-inbox-thread-and-audit-labels.md +6 -0
  475. package/corpus/templates/factory/changelog/2026-08-27-audit-run-list-stacks.md +6 -0
  476. package/corpus/templates/factory/changelog/2026-08-27-audit-run-names-wrap.md +6 -0
  477. package/corpus/templates/factory/changelog/2026-08-27-factory-opens-on-inbox.md +6 -0
  478. package/corpus/templates/factory/changelog/2026-08-27-github-repository-url.md +6 -0
  479. package/corpus/templates/factory/changelog/2026-08-27-inbox-filters.md +6 -0
  480. package/corpus/templates/factory/changelog/2026-08-27-polling-does-not-enable-automations.md +6 -0
  481. package/corpus/templates/factory/changelog/2026-08-27-pr-babysit-can-poll-github.md +6 -0
  482. package/corpus/templates/factory/changelog/2026-08-28-factory-automations-use-workspace-connections.md +6 -0
  483. package/corpus/templates/factory/changelog/2026-08-28-inbox-approve-and-start-removed.md +6 -0
  484. package/corpus/templates/factory/changelog/2026-08-28-pr-babysit-audit-shows-decisions.md +6 -0
  485. package/corpus/templates/factory/changelog/2026-08-28-pr-babysit-reviews-next-github-prs.md +6 -0
  486. package/corpus/templates/factory/changelog/2026-08-28-pr-babysit-sticky-out-of-scope.md +6 -0
  487. package/corpus/templates/factory/changelog/2026-08-28-pr-babysit-uses-github-evidence.md +6 -0
  488. package/corpus/templates/factory/changelog/2026-08-29-audit-filters-pagination-scroll.md +6 -0
  489. package/corpus/templates/factory/changelog/2026-08-29-create-factory-automations.md +6 -0
  490. package/corpus/templates/factory/changelog/2026-08-29-dispatch-reaction-argument.md +6 -0
  491. package/corpus/templates/factory/changelog/2026-08-29-factory-action-names-match-behavior.md +6 -0
  492. package/corpus/templates/factory/public/manifest.json +1 -1
  493. package/corpus/templates/factory/server/connectors/slack.ts +8 -6
  494. package/corpus/templates/factory/server/db/schema.ts +23 -0
  495. package/corpus/templates/factory/server/lib/audit-cursor.ts +44 -0
  496. package/corpus/templates/factory/server/lib/factory-action-names.ts +15 -0
  497. package/corpus/templates/factory/server/lib/factory-audit-report.ts +29 -9
  498. package/corpus/templates/factory/server/lib/factory-automation-caller.ts +38 -0
  499. package/corpus/templates/factory/server/lib/factory-automation-config.ts +543 -0
  500. package/corpus/templates/factory/server/lib/factory-automation-plan.ts +0 -48
  501. package/corpus/templates/factory/server/lib/factory-automation-repair.ts +2 -18
  502. package/corpus/templates/factory/server/lib/factory-poll-cursors.ts +98 -0
  503. package/corpus/templates/factory/server/lib/factory-scope.ts +8 -0
  504. package/corpus/templates/factory/server/lib/github-repository.ts +104 -0
  505. package/corpus/templates/factory/server/lib/inbox-cursor.ts +34 -0
  506. package/corpus/templates/factory/server/lib/pr-babysit-prompt.ts +33 -0
  507. package/corpus/templates/factory/server/lib/require-factory-automation.ts +58 -17
  508. package/corpus/templates/factory/server/lib/safe-http-url.ts +8 -0
  509. package/corpus/templates/factory/server/lib/slack-feedback-prompt.ts +19 -10
  510. package/corpus/templates/factory/server/lib/source-reaction.ts +37 -0
  511. package/corpus/templates/factory/server/plugins/agent-chat.ts +18 -22
  512. package/corpus/templates/factory/server/plugins/auth.ts +1 -0
  513. package/corpus/templates/factory/server/plugins/factory-migrations.ts +26 -0
  514. package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +277 -164
  515. package/corpus/templates/factory/server/plugins/integrations.ts +5 -7
  516. package/corpus/templates/factory/server/triage/github-client.ts +274 -3
  517. package/corpus/templates/factory/server/triage/github-ingestion.ts +3 -1
  518. package/corpus/templates/factory/server/triage/metadata.ts +12 -0
  519. package/corpus/templates/factory/server/triage/pr-babysit.ts +22 -21
  520. package/corpus/templates/factory/server/triage/review-skill-alignment.ts +11 -11
  521. package/corpus/templates/factory/server/triage/review-state.ts +39 -0
  522. package/corpus/templates/factory/server/triage/slack-client.ts +14 -6
  523. package/corpus/templates/factory/server/triage/slack-poller.ts +34 -65
  524. package/corpus/templates/factory/server/triage/slack-user-labels.ts +126 -0
  525. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +4 -0
  526. package/corpus/templates/forms/.agents/skills/secrets/SKILL.md +47 -0
  527. package/corpus/templates/forms/AGENTS.md +4 -3
  528. package/corpus/templates/forms/actions/response-insights.ts +4 -4
  529. package/corpus/templates/forms/actions/retry-response-deliveries.ts +26 -0
  530. package/corpus/templates/forms/app/components/layout/Sidebar.tsx +8 -33
  531. package/corpus/templates/forms/app/hooks/use-navigation-state.ts +1 -1
  532. package/corpus/templates/forms/app/lib/route-prewarm.ts +1 -1
  533. package/corpus/templates/forms/app/root.tsx +3 -2
  534. package/corpus/templates/forms/app/routes/_app.home.tsx +47 -0
  535. package/corpus/templates/forms/app/routes/_app.tsx +2 -1
  536. package/corpus/templates/forms/app/routes/_index.tsx +10 -23
  537. package/corpus/templates/forms/public/manifest.json +1 -1
  538. package/corpus/templates/forms/server/db/schema.ts +64 -17
  539. package/corpus/templates/forms/server/handlers/submissions.ts +1022 -94
  540. package/corpus/templates/forms/server/lib/integrations.ts +100 -33
  541. package/corpus/templates/forms/server/middleware/00-public-cors.ts +1 -1
  542. package/corpus/templates/forms/server/plugins/auth.ts +1 -0
  543. package/corpus/templates/forms/server/plugins/core-routes.ts +1 -0
  544. package/corpus/templates/forms/server/plugins/db.ts +40 -0
  545. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +4 -0
  546. package/corpus/templates/macros/.agents/skills/secrets/SKILL.md +47 -0
  547. package/corpus/templates/macros/actions/view-screen.ts +1 -1
  548. package/corpus/templates/macros/app/components/layout/AppLayout.tsx +9 -21
  549. package/corpus/templates/macros/app/components/layout/Header.tsx +1 -1
  550. package/corpus/templates/macros/app/root.tsx +22 -8
  551. package/corpus/templates/macros/app/routes/_index.tsx +16 -291
  552. package/corpus/templates/macros/app/routes/home.tsx +312 -0
  553. package/corpus/templates/macros/server/plugins/auth.ts +9 -7
  554. package/corpus/templates/macros/server/plugins/core-routes.ts +1 -0
  555. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +4 -0
  556. package/corpus/templates/mail/.agents/skills/inbox-automations/SKILL.md +13 -2
  557. package/corpus/templates/mail/.agents/skills/inbox-reads-and-triage/SKILL.md +1 -1
  558. package/corpus/templates/mail/.agents/skills/secrets/SKILL.md +47 -0
  559. package/corpus/templates/mail/AGENTS.md +5 -2
  560. package/corpus/templates/mail/actions/apply-ai-filter.ts +294 -0
  561. package/corpus/templates/mail/actions/create-automation.ts +1 -0
  562. package/corpus/templates/mail/actions/get-ai-filter.ts +19 -0
  563. package/corpus/templates/mail/actions/manage-automations.ts +162 -157
  564. package/corpus/templates/mail/actions/manage-email-rules.ts +3 -0
  565. package/corpus/templates/mail/actions/navigate.ts +1 -1
  566. package/corpus/templates/mail/actions/update-automation.ts +1 -0
  567. package/corpus/templates/mail/actions/update-mail-preferences.ts +1 -0
  568. package/corpus/templates/mail/app/components/email/AiFilterDialog.tsx +127 -0
  569. package/corpus/templates/mail/app/components/email/EmailList.tsx +63 -0
  570. package/corpus/templates/mail/app/components/email/EmailThread.tsx +95 -0
  571. package/corpus/templates/mail/app/components/email/MobileActionBar.tsx +35 -3
  572. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +17 -22
  573. package/corpus/templates/mail/app/components/settings/AiFilterSection.tsx +401 -0
  574. package/corpus/templates/mail/app/hooks/use-ai-filter.ts +48 -0
  575. package/corpus/templates/mail/app/hooks/use-automations.ts +1 -0
  576. package/corpus/templates/mail/app/hooks/use-emails.ts +11 -3
  577. package/corpus/templates/mail/app/i18n/en-US.ts +55 -0
  578. package/corpus/templates/mail/app/lib/automation-visibility.ts +17 -0
  579. package/corpus/templates/mail/app/pages/InboxPage.tsx +5 -2
  580. package/corpus/templates/mail/app/pages/SettingsPage.tsx +16 -8
  581. package/corpus/templates/mail/app/pages/inbox-zero.ts +1 -2
  582. package/corpus/templates/mail/app/root.tsx +20 -8
  583. package/corpus/templates/mail/app/routes/_index.tsx +16 -55
  584. package/corpus/templates/mail/app/routes/home.tsx +71 -0
  585. package/corpus/templates/mail/changelog/2026-08-28-mail-settings-show-chat-created-automations.md +6 -0
  586. package/corpus/templates/mail/public/manifest.json +1 -1
  587. package/corpus/templates/mail/server/db/schema.ts +3 -0
  588. package/corpus/templates/mail/server/handlers/emails.ts +34 -11
  589. package/corpus/templates/mail/server/handlers/google-auth.ts +1 -1
  590. package/corpus/templates/mail/server/lib/ai-filter.ts +103 -0
  591. package/corpus/templates/mail/server/lib/automation-actions.ts +14 -9
  592. package/corpus/templates/mail/server/lib/automation-engine.ts +142 -18
  593. package/corpus/templates/mail/server/lib/automations.ts +9 -0
  594. package/corpus/templates/mail/server/lib/email-state.ts +7 -2
  595. package/corpus/templates/mail/server/lib/gmail-query.ts +10 -0
  596. package/corpus/templates/mail/server/lib/google-auth.ts +5 -8
  597. package/corpus/templates/mail/server/lib/jobs.ts +1 -5
  598. package/corpus/templates/mail/server/onboarding.ts +2 -2
  599. package/corpus/templates/mail/server/plugins/agent-chat.ts +5 -2
  600. package/corpus/templates/mail/server/plugins/auth.ts +1 -0
  601. package/corpus/templates/mail/server/plugins/core-routes.ts +4 -1
  602. package/corpus/templates/mail/server/plugins/db.ts +6 -0
  603. package/corpus/templates/mail/server/routes/api/attachments.get.ts +1 -5
  604. package/corpus/templates/mail/shared/ai-filter.ts +74 -0
  605. package/corpus/templates/mail/shared/types.ts +2 -0
  606. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +4 -0
  607. package/corpus/templates/plan/.agents/skills/secrets/SKILL.md +47 -0
  608. package/corpus/templates/plan/actions/list-plan-versions.ts +20 -5
  609. package/corpus/templates/plan/agent-native.json +1 -4
  610. package/corpus/templates/plan/app/components/editor/PlanDocumentEditor.tsx +5 -2
  611. package/corpus/templates/plan/app/components/layout/Layout.tsx +41 -1
  612. package/corpus/templates/plan/app/components/layout/Sidebar.tsx +4 -16
  613. package/corpus/templates/plan/app/components/plan/PlanMarkdownEditor.tsx +7 -4
  614. package/corpus/templates/plan/app/components/plan/wireframe/Wireframe.tsx +1 -1
  615. package/corpus/templates/plan/app/components/plan/wireframe/html-artboard.css +15 -0
  616. package/corpus/templates/plan/app/components/plan/wireframe/kit/plan-wireframe-tokens.css +0 -15
  617. package/corpus/templates/plan/app/components/plan/wireframe/kit/primitives.tsx +2 -2
  618. package/corpus/templates/plan/app/hooks/use-plan-presence.ts +20 -10
  619. package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -2
  620. package/corpus/templates/plan/app/root.tsx +13 -7
  621. package/corpus/templates/plan/app/routes/_index.tsx +31 -6
  622. package/corpus/templates/plan/app/routes/chat.tsx +3 -6
  623. package/corpus/templates/plan/app/routes/home.tsx +11 -0
  624. package/corpus/templates/plan/app/routes/local-plans.$slug.tsx +2 -6
  625. package/corpus/templates/plan/app/routes/plans.$id.tsx +3 -6
  626. package/corpus/templates/plan/app/routes/plans.tsx +3 -6
  627. package/corpus/templates/plan/app/routes/recaps.$id.tsx +3 -6
  628. package/corpus/templates/plan/app/routes/recaps.tsx +3 -6
  629. package/corpus/templates/plan/changelog/2026-08-28-plan-loading-skeletons-use-a-softer-whole-surface.md +6 -0
  630. package/corpus/templates/plan/changelog/2026-08-29-plan-loading-shine-is-more-subtle.md +6 -0
  631. package/corpus/templates/plan/public/manifest.json +1 -1
  632. package/corpus/templates/plan/server/db/schema.ts +1 -0
  633. package/corpus/templates/plan/server/lib/plan-versions.ts +57 -0
  634. package/corpus/templates/plan/server/plugins/agent-chat.ts +83 -0
  635. package/corpus/templates/plan/server/plugins/core-routes.ts +1 -0
  636. package/corpus/templates/plan/server/plugins/db.ts +10 -0
  637. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +4 -0
  638. package/corpus/templates/slides/.agents/skills/secrets/SKILL.md +47 -0
  639. package/corpus/templates/slides/CHANGELOG.md +9 -0
  640. package/corpus/templates/slides/actions/_deck-write.ts +65 -0
  641. package/corpus/templates/slides/actions/add-slide.ts +44 -24
  642. package/corpus/templates/slides/actions/clone-context-slide.ts +22 -12
  643. package/corpus/templates/slides/actions/create-deck.ts +36 -21
  644. package/corpus/templates/slides/actions/delete-design-system.ts +10 -3
  645. package/corpus/templates/slides/actions/import-file.ts +9 -3
  646. package/corpus/templates/slides/actions/import-pptx.ts +11 -4
  647. package/corpus/templates/slides/actions/list-deck-versions.ts +20 -8
  648. package/corpus/templates/slides/actions/patch-deck.ts +29 -3
  649. package/corpus/templates/slides/actions/restore-deck-version.ts +37 -22
  650. package/corpus/templates/slides/actions/save-deck.ts +35 -22
  651. package/corpus/templates/slides/actions/update-deck-aspect-ratio.ts +31 -16
  652. package/corpus/templates/slides/actions/update-slide.ts +250 -37
  653. package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +10 -4
  654. package/corpus/templates/slides/app/components/editor/EditorActionCluster.tsx +2 -2
  655. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +7 -8
  656. package/corpus/templates/slides/app/components/editor/ImageOverlay.tsx +78 -12
  657. package/corpus/templates/slides/app/components/editor/SlideContextToolbar.tsx +42 -4
  658. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +381 -53
  659. package/corpus/templates/slides/app/components/editor/SlidesLayersPanel.tsx +20 -34
  660. package/corpus/templates/slides/app/components/editor/slide-style.ts +5 -0
  661. package/corpus/templates/slides/app/components/editor/style-clipboard.ts +2 -0
  662. package/corpus/templates/slides/app/components/layout/AgentWorkIndicator.tsx +18 -2
  663. package/corpus/templates/slides/app/components/layout/Header.tsx +1 -1
  664. package/corpus/templates/slides/app/components/layout/Layout.tsx +39 -10
  665. package/corpus/templates/slides/app/components/layout/Sidebar.tsx +7 -20
  666. package/corpus/templates/slides/app/components/presentation/PresenterView.tsx +35 -15
  667. package/corpus/templates/slides/app/components/presentation/present-channel.ts +12 -0
  668. package/corpus/templates/slides/app/global.css +45 -13
  669. package/corpus/templates/slides/app/hooks/use-navigation-state.ts +1 -1
  670. package/corpus/templates/slides/app/i18n/en-US.ts +11 -0
  671. package/corpus/templates/slides/app/lib/sanitize-slide-html.ts +133 -5
  672. package/corpus/templates/slides/app/lib/slide-image-replacement.ts +741 -17
  673. package/corpus/templates/slides/app/lib/validate-native-slide-html.ts +1 -0
  674. package/corpus/templates/slides/app/pages/DeckEditor.tsx +288 -95
  675. package/corpus/templates/slides/app/pages/DesignSystems.tsx +5 -5
  676. package/corpus/templates/slides/app/pages/Index.tsx +7 -7
  677. package/corpus/templates/slides/app/pages/NotFound.tsx +1 -1
  678. package/corpus/templates/slides/app/pages/SharedPresentation.tsx +1 -1
  679. package/corpus/templates/slides/app/root.tsx +4 -23
  680. package/corpus/templates/slides/app/routes/_index.tsx +18 -7
  681. package/corpus/templates/slides/app/routes/home.tsx +26 -0
  682. package/corpus/templates/slides/changelog/2026-08-27-image-fit-controls-apply-cover-crops-and-position.md +6 -0
  683. package/corpus/templates/slides/changelog/2026-08-28-image-edits-persist-while-dropped-images-finish-uploading.md +6 -0
  684. package/corpus/templates/slides/changelog/2026-08-28-shared-slides-with-a-style-block-render-again.md +6 -0
  685. package/corpus/templates/slides/changelog/2026-08-28-slides-loading-skeletons-use-a-softer-whole-surface.md +6 -0
  686. package/corpus/templates/slides/changelog/2026-08-28-standard-empty-home-layout.md +6 -0
  687. package/corpus/templates/slides/changelog/2026-08-29-chat-imports-attached-decks-on-request.md +6 -0
  688. package/corpus/templates/slides/changelog/2026-08-29-slides-loading-shine-is-more-subtle.md +6 -0
  689. package/corpus/templates/slides/package.json +3 -0
  690. package/corpus/templates/slides/public/manifest.json +1 -1
  691. package/corpus/templates/slides/server/db/schema.ts +1 -0
  692. package/corpus/templates/slides/server/handlers/google-docs-auth.ts +1 -1
  693. package/corpus/templates/slides/server/lib/chat-attachments.ts +102 -7
  694. package/corpus/templates/slides/server/lib/deck-versions.ts +77 -2
  695. package/corpus/templates/slides/server/plugins/agent-chat.ts +95 -1
  696. package/corpus/templates/slides/server/plugins/auth.ts +1 -0
  697. package/corpus/templates/slides/server/plugins/core-routes.ts +8 -1
  698. package/corpus/templates/slides/server/plugins/db.ts +5 -0
  699. package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +4 -0
  700. package/corpus/templates/tasks/.agents/skills/secrets/SKILL.md +47 -0
  701. package/corpus/templates/tasks/AGENTS.md +2 -1
  702. package/corpus/templates/tasks/README.md +3 -1
  703. package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +5 -18
  704. package/corpus/templates/tasks/app/root.tsx +19 -3
  705. package/corpus/templates/tasks/app/routes/_index.tsx +28 -14
  706. package/corpus/templates/tasks/app/routes/home.tsx +24 -0
  707. package/corpus/templates/tasks/public/manifest.json +1 -1
  708. package/corpus/templates/tasks/server/plugins/auth.ts +1 -0
  709. package/dist/a2a/client.d.ts +4 -0
  710. package/dist/a2a/client.js +15 -2
  711. package/dist/action.d.ts +3 -1
  712. package/dist/agent/engine/ai-sdk-engine.js +13 -9
  713. package/dist/agent/engine/anthropic-engine.js +2 -1
  714. package/dist/agent/engine/builder-engine.js +23 -5
  715. package/dist/agent/engine/limit-provider-tools.d.ts +3 -0
  716. package/dist/agent/engine/limit-provider-tools.js +23 -0
  717. package/dist/agent/engine/openai-compatible-endpoint.d.ts +2 -0
  718. package/dist/agent/engine/openai-compatible-endpoint.js +4 -0
  719. package/dist/agent/engine/output-tokens.d.ts +12 -6
  720. package/dist/agent/engine/output-tokens.js +42 -16
  721. package/dist/agent/engine/registry.d.ts +1 -1
  722. package/dist/agent/engine/registry.js +69 -16
  723. package/dist/agent/production-agent.js +107 -13
  724. package/dist/agent/run-manager.d.ts +9 -0
  725. package/dist/agent/run-manager.js +35 -6
  726. package/dist/agent/thread-data-builder.d.ts +6 -1
  727. package/dist/agent/thread-data-builder.js +74 -17
  728. package/dist/agent/types.d.ts +2 -0
  729. package/dist/app-config/agent.d.ts +4 -0
  730. package/dist/app-config/agent.js +44 -0
  731. package/dist/app-config/integrations.d.ts +1 -0
  732. package/dist/app-config/integrations.js +8 -0
  733. package/dist/app-config/migration.d.ts +1 -0
  734. package/dist/app-config/migration.js +4 -0
  735. package/dist/app-config/observability.d.ts +4 -1
  736. package/dist/app-config/observability.js +25 -1
  737. package/dist/app-config/schema.d.ts +9 -0
  738. package/dist/app-config/store.js +1 -0
  739. package/dist/client/AgentAskPopover.d.ts +2 -1
  740. package/dist/client/AgentAskPopover.js +2 -2
  741. package/dist/client/AgentPanel.d.ts +35 -10
  742. package/dist/client/AgentPanel.js +136 -119
  743. package/dist/client/AssistantChat.d.ts +9 -2
  744. package/dist/client/AssistantChat.js +166 -41
  745. package/dist/client/ConnectBuilderCard.js +3 -1
  746. package/dist/client/DefaultSpinner.d.ts +13 -1
  747. package/dist/client/DefaultSpinner.js +52 -46
  748. package/dist/client/FeedbackButton.d.ts +12 -0
  749. package/dist/client/FeedbackButton.js +62 -28
  750. package/dist/client/MultiTabAssistantChat.js +30 -11
  751. package/dist/client/NewWorkspaceAppFlow.js +5 -3
  752. package/dist/client/agent-chat/index.d.ts +1 -0
  753. package/dist/client/agent-chat/index.js +1 -0
  754. package/dist/client/agent-chat-adapter.js +16 -1
  755. package/dist/client/agent-chat.d.ts +9 -0
  756. package/dist/client/agent-chat.js +6 -3
  757. package/dist/client/agent-page/AgentJobsTab.d.ts +2 -1
  758. package/dist/client/agent-page/AgentJobsTab.js +8 -5
  759. package/dist/client/agent-page/AgentTabsPage.js +2 -2
  760. package/dist/client/analytics.d.ts +2 -0
  761. package/dist/client/analytics.js +86 -15
  762. package/dist/client/app-providers.js +13 -1
  763. package/dist/client/auth/AuthPage.d.ts +87 -0
  764. package/dist/client/auth/AuthPage.js +1847 -0
  765. package/dist/client/auth/ResetPasswordPage.d.ts +9 -0
  766. package/dist/client/auth/ResetPasswordPage.js +119 -0
  767. package/dist/client/auth/entry.d.ts +1 -0
  768. package/dist/client/auth/entry.js +15 -0
  769. package/dist/client/chat/message-components.d.ts +53 -0
  770. package/dist/client/chat/message-components.js +181 -11
  771. package/dist/client/chat/run-recovery.d.ts +4 -1
  772. package/dist/client/chat/run-recovery.js +30 -12
  773. package/dist/client/chat/tool-call-display.d.ts +4 -2
  774. package/dist/client/chat/tool-call-display.js +16 -11
  775. package/dist/client/chat-first.js +8 -2
  776. package/dist/client/chat-model-groups.js +11 -1
  777. package/dist/client/collab/index.d.ts +1 -1
  778. package/dist/client/components/CodeRequiredDialog.js +22 -35
  779. package/dist/client/components/icons/AgentNativeIcon.d.ts +3 -3
  780. package/dist/client/components/icons/AgentNativeIcon.js +4 -4
  781. package/dist/client/components/ui/message-scroller.js +1 -1
  782. package/dist/client/composer/runtime-adapters.js +2 -0
  783. package/dist/client/feedback-context.d.ts +1 -0
  784. package/dist/client/feedback-context.js +3 -2
  785. package/dist/client/host-bridge.d.ts +1 -0
  786. package/dist/client/index.d.ts +2 -2
  787. package/dist/client/index.js +1 -1
  788. package/dist/client/integrations/IntegrationsPanel.d.ts +2 -1
  789. package/dist/client/integrations/IntegrationsPanel.js +3 -3
  790. package/dist/client/observability/ThumbsFeedback.js +73 -10
  791. package/dist/client/onboarding/FirstRunOnboarding.js +24 -15
  792. package/dist/client/onboarding/OnboardingPanel.js +5 -3
  793. package/dist/client/onboarding/first-run-startup-gate.js +7 -1
  794. package/dist/client/resources/McpIntegrationDialog.d.ts +2 -1
  795. package/dist/client/resources/McpIntegrationDialog.js +10 -2
  796. package/dist/client/session-replay.js +10 -0
  797. package/dist/client/settings/BuilderConnectPopover.d.ts +25 -0
  798. package/dist/client/settings/BuilderConnectPopover.js +55 -0
  799. package/dist/client/settings/SettingsPanel.js +21 -7
  800. package/dist/client/settings/SettingsTabsPage.d.ts +1 -1
  801. package/dist/client/settings/SettingsTabsPage.js +42 -25
  802. package/dist/client/settings/VoiceTranscriptionSection.js +16 -22
  803. package/dist/client/settings/index.d.ts +1 -0
  804. package/dist/client/settings/index.js +1 -0
  805. package/dist/client/settings/useBuilderStatus.d.ts +7 -0
  806. package/dist/client/settings/useBuilderStatus.js +77 -21
  807. package/dist/client/setup-connections/BuilderConnectCard.js +2 -1
  808. package/dist/client/setup-connections/useBuilderConnectCardController.d.ts +3 -1
  809. package/dist/client/setup-connections/useBuilderConnectCardController.js +4 -2
  810. package/dist/client/sse-event-processor.js +8 -0
  811. package/dist/client/terminal/AgentTerminal.js +6 -7
  812. package/dist/client/transcription/BuilderTranscriptionCta.js +17 -69
  813. package/dist/client/ui/index.d.ts +1 -0
  814. package/dist/client/ui/index.js +1 -0
  815. package/dist/client/use-chat-models.js +5 -4
  816. package/dist/client/webmcp.d.ts +4 -0
  817. package/dist/client/webmcp.js +51 -4
  818. package/dist/collab/client.d.ts +13 -0
  819. package/dist/collab/client.js +96 -21
  820. package/dist/collab/struct-routes.d.ts +1 -1
  821. package/dist/dashboard-storage/index.d.ts +1 -1
  822. package/dist/dashboard-storage/schema.d.ts +19 -0
  823. package/dist/dashboard-storage/schema.js +1 -0
  824. package/dist/dashboard-storage/store.d.ts +9 -0
  825. package/dist/dashboard-storage/store.js +93 -3
  826. package/dist/deploy/build.d.ts +19 -3
  827. package/dist/deploy/build.js +262 -10
  828. package/dist/index.browser.d.ts +1 -1
  829. package/dist/index.browser.js +1 -1
  830. package/dist/index.d.ts +1 -1
  831. package/dist/index.js +1 -1
  832. package/dist/ingestion/media.js +7 -2
  833. package/dist/integrations/config-store.js +2 -4
  834. package/dist/integrations/google-docs-poller.d.ts +1 -1
  835. package/dist/integrations/google-docs-poller.js +100 -24
  836. package/dist/integrations/plugin.js +45 -15
  837. package/dist/integrations/webhook-handler.js +2 -1
  838. package/dist/jobs/background-automation-runner.js +17 -1
  839. package/dist/localization/core-messages/ar-SA.js +19 -0
  840. package/dist/localization/core-messages/de-DE.js +19 -0
  841. package/dist/localization/core-messages/en-US.d.ts +19 -0
  842. package/dist/localization/core-messages/en-US.js +19 -0
  843. package/dist/localization/core-messages/es-ES.js +19 -0
  844. package/dist/localization/core-messages/fr-FR.js +19 -0
  845. package/dist/localization/core-messages/hi-IN.js +19 -0
  846. package/dist/localization/core-messages/ja-JP.js +19 -0
  847. package/dist/localization/core-messages/ko-KR.js +19 -0
  848. package/dist/localization/core-messages/pt-BR.js +19 -0
  849. package/dist/localization/core-messages/zh-CN.js +19 -0
  850. package/dist/localization/core-messages/zh-TW.js +19 -0
  851. package/dist/localization/core-messages.d.ts +19 -0
  852. package/dist/localization/default-messages.d.ts +11 -0
  853. package/dist/localization/default-messages.js +11 -0
  854. package/dist/mcp/analytics.d.ts +103 -0
  855. package/dist/mcp/analytics.js +204 -0
  856. package/dist/mcp/build-server.d.ts +7 -0
  857. package/dist/mcp/build-server.js +132 -35
  858. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  859. package/dist/mcp/server.js +37 -8
  860. package/dist/mcp/stdio.js +1 -0
  861. package/dist/mcp-client/errors.js +30 -10
  862. package/dist/mcp-client/oauth-routes.d.ts +7 -2
  863. package/dist/mcp-client/oauth-routes.js +12 -3
  864. package/dist/mcp-client/routes.js +2 -1
  865. package/dist/notifications/routes.d.ts +1 -1
  866. package/dist/oauth-tokens/store.js +6 -3
  867. package/dist/observability/routes.d.ts +3 -3
  868. package/dist/observability/routes.js +8 -2
  869. package/dist/observability/store.d.ts +1 -1
  870. package/dist/observability/store.js +18 -3
  871. package/dist/observability/types.d.ts +1 -0
  872. package/dist/onboarding/plugin.js +16 -4
  873. package/dist/provider-api/actions/custom-provider-registration.d.ts +16 -16
  874. package/dist/provider-api/actions/provider-api.d.ts +12 -12
  875. package/dist/resources/handlers.d.ts +2 -2
  876. package/dist/secrets/routes.d.ts +9 -9
  877. package/dist/server/action-routes.d.ts +1 -6
  878. package/dist/server/action-routes.js +61 -18
  879. package/dist/server/agent-chat/plugin-options.d.ts +8 -1
  880. package/dist/server/agent-chat-plugin.d.ts +3 -0
  881. package/dist/server/agent-chat-plugin.js +49 -4
  882. package/dist/server/agent-run-context.d.ts +1 -0
  883. package/dist/server/agent-run-context.js +6 -0
  884. package/dist/server/analytics.d.ts +3 -2
  885. package/dist/server/analytics.js +18 -7
  886. package/dist/server/app-url.d.ts +5 -2
  887. package/dist/server/app-url.js +4 -3
  888. package/dist/server/auth.d.ts +25 -0
  889. package/dist/server/auth.js +168 -21
  890. package/dist/server/better-auth-instance.js +29 -4
  891. package/dist/server/better-auth-migrations.d.ts +14 -0
  892. package/dist/server/better-auth-migrations.js +5 -1
  893. package/dist/server/builder-api-auth.js +30 -6
  894. package/dist/server/builder-browser.d.ts +10 -0
  895. package/dist/server/builder-browser.js +22 -5
  896. package/dist/server/builder-design-systems.d.ts +11 -0
  897. package/dist/server/builder-design-systems.js +52 -3
  898. package/dist/server/builder-oauth.d.ts +13 -6
  899. package/dist/server/builder-oauth.js +121 -63
  900. package/dist/server/capture-error.js +3 -0
  901. package/dist/server/cookie-namespace.d.ts +1 -0
  902. package/dist/server/cookie-namespace.js +3 -0
  903. package/dist/server/core-routes-plugin.d.ts +25 -9
  904. package/dist/server/core-routes-plugin.js +180 -76
  905. package/dist/server/credential-provider.js +22 -12
  906. package/dist/server/email.d.ts +4 -0
  907. package/dist/server/email.js +13 -5
  908. package/dist/server/framework-request-handler.js +6 -3
  909. package/dist/server/google-credential-check.d.ts +7 -3
  910. package/dist/server/google-credential-check.js +71 -0
  911. package/dist/server/google-oauth-credentials.d.ts +4 -3
  912. package/dist/server/google-oauth-credentials.js +7 -8
  913. package/dist/server/google-oauth.d.ts +9 -4
  914. package/dist/server/google-oauth.js +14 -93
  915. package/dist/server/index.d.ts +1 -1
  916. package/dist/server/index.js +1 -1
  917. package/dist/server/jwks-secret-rotation.d.ts +29 -0
  918. package/dist/server/jwks-secret-rotation.js +150 -0
  919. package/dist/server/onboarding-html.d.ts +2 -14
  920. package/dist/server/onboarding-html.js +254 -2519
  921. package/dist/server/origin-allowlist.d.ts +15 -0
  922. package/dist/server/origin-allowlist.js +93 -0
  923. package/dist/server/realtime-token.d.ts +1 -1
  924. package/dist/server/release-migrations.js +48 -0
  925. package/dist/server/request-context.d.ts +2 -0
  926. package/dist/server/request-context.js +7 -2
  927. package/dist/server/self-dispatch.js +5 -0
  928. package/dist/server/sentry.js +5 -0
  929. package/dist/server/ssr-handler.js +5 -0
  930. package/dist/server/workspace-provider-oauth.d.ts +9 -0
  931. package/dist/server/workspace-provider-oauth.js +96 -31
  932. package/dist/shared/index.d.ts +2 -0
  933. package/dist/shared/index.js +2 -0
  934. package/dist/shared/loading-labels.d.ts +1 -0
  935. package/dist/shared/loading-labels.js +55 -0
  936. package/dist/shared/qa-test-email.d.ts +1 -0
  937. package/dist/shared/qa-test-email.js +42 -0
  938. package/dist/shared/route-warmup-config.js +2 -2
  939. package/dist/shared/sign-in-journey.js +1 -1
  940. package/dist/shared/ssr-auth-redirect.d.ts +8 -0
  941. package/dist/shared/ssr-auth-redirect.js +56 -0
  942. package/dist/shared/test-traffic.d.ts +8 -0
  943. package/dist/shared/test-traffic.js +11 -0
  944. package/dist/styles/agent-native.css +50 -14
  945. package/dist/styles/blocks.css +0 -6
  946. package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -0
  947. package/dist/templates/chat/.agents/skills/secrets/SKILL.md +47 -0
  948. package/dist/templates/chat/AGENTS.md +5 -4
  949. package/dist/templates/chat/app/components/layout/Header.tsx +1 -1
  950. package/dist/templates/chat/app/components/layout/Layout.tsx +5 -4
  951. package/dist/templates/chat/app/components/layout/Sidebar.tsx +16 -25
  952. package/dist/templates/chat/app/hooks/use-navigation-state.ts +5 -5
  953. package/dist/templates/chat/app/root.tsx +16 -3
  954. package/dist/templates/chat/app/routes/_index.tsx +17 -74
  955. package/dist/templates/chat/app/routes/chat.$threadId.tsx +1 -1
  956. package/dist/templates/chat/app/routes/home.tsx +94 -0
  957. package/dist/templates/chat/netlify.toml +2 -1
  958. package/dist/templates/chat/public/manifest.json +1 -1
  959. package/dist/templates/chat/server/plugins/auth.ts +1 -0
  960. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +4 -0
  961. package/dist/templates/default/.agents/skills/secrets/SKILL.md +47 -0
  962. package/dist/templates/default/AGENTS.md +10 -6
  963. package/dist/templates/default/DEVELOPING.md +8 -1
  964. package/dist/templates/default/app/hooks/use-navigation-state.ts +1 -1
  965. package/dist/templates/default/app/root.tsx +10 -3
  966. package/dist/templates/default/app/routes/_index.tsx +10 -86
  967. package/dist/templates/default/app/routes/home.tsx +94 -0
  968. package/dist/templates/default/app/routes/settings.tsx +1 -1
  969. package/dist/templates/default/public/manifest.json +1 -1
  970. package/dist/templates/default/server/plugins/auth.ts +5 -0
  971. package/dist/templates/headless/.agents/skills/secrets/SKILL.md +47 -0
  972. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +4 -0
  973. package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +47 -0
  974. package/dist/templates/workspace-root/.env.example +3 -2
  975. package/dist/terminal/pty-server.d.ts +2 -0
  976. package/dist/terminal/pty-server.js +22 -5
  977. package/dist/tracking/registry.d.ts +1 -0
  978. package/dist/tracking/registry.js +12 -0
  979. package/dist/usage/store.d.ts +1 -0
  980. package/dist/usage/store.js +16 -7
  981. package/dist/vite/client.d.ts +1 -1
  982. package/dist/vite/client.js +59 -0
  983. package/dist/workspace-connections/index.d.ts +1 -1
  984. package/dist/workspace-connections/index.js +1 -1
  985. package/dist/workspace-connections/store.d.ts +1 -0
  986. package/dist/workspace-connections/store.js +4 -0
  987. package/docs/content/aws-amplify.mdx +179 -0
  988. package/docs/content/client-agent-chat.mdx +1 -1
  989. package/docs/content/deploy-an-app.mdx +2 -1
  990. package/docs/content/deployment.mdx +14 -3
  991. package/docs/content/environment-variables.mdx +1 -0
  992. package/docs/content/template-forms-agent.mdx +65 -0
  993. package/docs/content/template-forms-developers.mdx +220 -65
  994. package/docs/content/template-forms-features.mdx +154 -0
  995. package/docs/content/template-forms-integrations.mdx +40 -0
  996. package/docs/content/template-forms.mdx +49 -36
  997. package/docs/content/template-mail-developers.mdx +3 -3
  998. package/docs/content/toolkit-settings.mdx +3 -3
  999. package/docs/content/webmcp.mdx +31 -12
  1000. package/package.json +3 -3
  1001. package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -0
  1002. package/src/templates/chat/.agents/skills/secrets/SKILL.md +47 -0
  1003. package/src/templates/chat/AGENTS.md +5 -4
  1004. package/src/templates/chat/app/components/layout/Header.tsx +1 -1
  1005. package/src/templates/chat/app/components/layout/Layout.tsx +5 -4
  1006. package/src/templates/chat/app/components/layout/Sidebar.tsx +16 -25
  1007. package/src/templates/chat/app/hooks/use-navigation-state.ts +5 -5
  1008. package/src/templates/chat/app/root.tsx +16 -3
  1009. package/src/templates/chat/app/routes/_index.tsx +17 -74
  1010. package/src/templates/chat/app/routes/chat.$threadId.tsx +1 -1
  1011. package/src/templates/chat/app/routes/home.tsx +94 -0
  1012. package/src/templates/chat/netlify.toml +2 -1
  1013. package/src/templates/chat/public/manifest.json +1 -1
  1014. package/src/templates/chat/server/plugins/auth.ts +1 -0
  1015. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +4 -0
  1016. package/src/templates/default/.agents/skills/secrets/SKILL.md +47 -0
  1017. package/src/templates/default/AGENTS.md +10 -6
  1018. package/src/templates/default/DEVELOPING.md +8 -1
  1019. package/src/templates/default/app/hooks/use-navigation-state.ts +1 -1
  1020. package/src/templates/default/app/root.tsx +10 -3
  1021. package/src/templates/default/app/routes/_index.tsx +10 -86
  1022. package/src/templates/default/app/routes/home.tsx +94 -0
  1023. package/src/templates/default/app/routes/settings.tsx +1 -1
  1024. package/src/templates/default/public/manifest.json +1 -1
  1025. package/src/templates/default/server/plugins/auth.ts +5 -0
  1026. package/src/templates/headless/.agents/skills/secrets/SKILL.md +47 -0
  1027. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +4 -0
  1028. package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +47 -0
  1029. package/src/templates/workspace-root/.env.example +3 -2
  1030. package/corpus/templates/factory/actions/approve-factory-item.ts +0 -244
  1031. package/corpus/templates/factory/app/components/factory/FactorySourceSettingsGroup.tsx +0 -33
  1032. package/corpus/templates/factory/server/routes/_agent-native/factory/builder-callback.post.ts +0 -116
  1033. package/corpus/templates/factory/server/triage/ai-services-git.ts +0 -205
  1034. package/corpus/templates/factory/server/triage/builder-executor.ts +0 -123
  1035. package/docs/content/template-forms-building-publishing.mdx +0 -135
  1036. package/docs/content/template-forms-responses.mdx +0 -120
  1037. /package/corpus/templates/clips/{server/lib → shared}/upload-interruption.ts +0 -0
@@ -0,0 +1,1847 @@
1
+ /** @jsxRuntime classic */
2
+ import { MarketingHome, Starfield } from "@agent-native/toolkit/marketing";
3
+ import { AuthForm } from "@agent-native/toolkit/onboarding";
4
+ import * as React from "react";
5
+ import { signInJourney, } from "../../shared/sign-in-journey.js";
6
+ import { isSyntheticTrafficValue } from "../../shared/test-traffic.js";
7
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
8
+ const TAB_STORAGE_KEY = "an.onboarding.tab";
9
+ const PENDING_SIGNUP_EMAIL_STORAGE_KEY = "an.onboarding.pendingSignupEmail";
10
+ const ANALYTICS_ANONYMOUS_ID_KEY = "agent-native.anonymous_id";
11
+ const ANALYTICS_SESSION_ID_KEY = "agent-native.session_id";
12
+ const FIRST_TOUCH_STORAGE_KEY = "an_attribution";
13
+ const FIRST_TOUCH_COOKIE = "an_ft";
14
+ const GOOGLE_AUTH_URL_PATH = "/_agent-native/google/auth-url";
15
+ const BUILDER_DESKTOP_RETURN_ORIGIN = "http://127.0.0.1:8080";
16
+ function normalizeEmail(value) {
17
+ return value.trim().toLowerCase();
18
+ }
19
+ function isValidEmail(value) {
20
+ return EMAIL_PATTERN.test(normalizeEmail(value));
21
+ }
22
+ function copyText(locales, defaultLocale, locale, key) {
23
+ return locales[locale]?.[key] ?? locales[defaultLocale]?.[key] ?? key;
24
+ }
25
+ function resolveLocale(value, localeOptions, defaultLocale) {
26
+ if (!value || value === "system")
27
+ return defaultLocale;
28
+ const exact = localeOptions.find((option) => option.value === value);
29
+ if (exact)
30
+ return exact.value;
31
+ try {
32
+ const canonical = Intl.getCanonicalLocales(value)[0]?.toLowerCase();
33
+ const match = localeOptions.find((option) => option.value.toLowerCase() === canonical ||
34
+ option.value.split("-")[0]?.toLowerCase() === canonical?.split("-")[0]);
35
+ return match?.value ?? defaultLocale;
36
+ }
37
+ catch {
38
+ // coercion-ok: malformed locale input falls back to the configured locale.
39
+ return defaultLocale;
40
+ }
41
+ }
42
+ function resolveSystemLocale(localeOptions, defaultLocale) {
43
+ if (typeof navigator === "undefined")
44
+ return defaultLocale;
45
+ const candidates = navigator.languages?.length
46
+ ? navigator.languages
47
+ : [navigator.language];
48
+ for (const candidate of candidates) {
49
+ const locale = resolveLocale(candidate, localeOptions, defaultLocale);
50
+ if (locale !== defaultLocale || candidate?.startsWith(defaultLocale)) {
51
+ return locale;
52
+ }
53
+ }
54
+ return defaultLocale;
55
+ }
56
+ function inferWorkspaceBasePath(pathname) {
57
+ const firstSegment = pathname.split("/").find(Boolean);
58
+ if (!firstSegment ||
59
+ ["_agent-native", "api", "sign-in", "login", "signup"].includes(firstSegment)) {
60
+ return "";
61
+ }
62
+ return `/${firstSegment}`;
63
+ }
64
+ function readStorage(key) {
65
+ try {
66
+ return window.localStorage.getItem(key) ?? "";
67
+ }
68
+ catch {
69
+ // coercion-ok: localStorage is optional; an empty value means no saved state.
70
+ return "";
71
+ }
72
+ }
73
+ function writeStorage(key, value) {
74
+ try {
75
+ window.localStorage.setItem(key, value);
76
+ }
77
+ catch {
78
+ // coercion-ok: browser storage is optional and auth has in-memory fallbacks.
79
+ }
80
+ }
81
+ function removeStorage(key) {
82
+ try {
83
+ window.localStorage.removeItem(key);
84
+ }
85
+ catch {
86
+ // coercion-ok: browser storage is optional.
87
+ }
88
+ }
89
+ function authErrorText(data, fallback) {
90
+ const candidate = data.error ?? data.message;
91
+ if (typeof candidate !== "string" || !candidate.trim())
92
+ return fallback;
93
+ const message = candidate.trim();
94
+ if (/failed query|\bselect\b.*\bfrom\b|\binsert\b.*\binto\b|\bupdate\b.*\bset\b|\bdelete\b.*\bfrom\b|\bsql\b|database|relation .* does not exist|column .* does not exist|syntax error|constraint|connection refused|econn|timeout/i.test(message)) {
95
+ return fallback;
96
+ }
97
+ return message;
98
+ }
99
+ export function shouldRetryAuthSessionProbe(response, readable) {
100
+ return !readable || response.status === 429 || response.status >= 500;
101
+ }
102
+ async function requestJson(url, init = {}) {
103
+ const response = await fetch(url, {
104
+ credentials: "include",
105
+ ...init,
106
+ });
107
+ let data = {};
108
+ let readable = false;
109
+ try {
110
+ const parsed = await response.json();
111
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
112
+ data = parsed;
113
+ readable = true;
114
+ }
115
+ }
116
+ catch {
117
+ // coercion-ok: a non-JSON response still has a status the caller can inspect.
118
+ }
119
+ return { response, data, readable };
120
+ }
121
+ function generateAnonymousId() {
122
+ try {
123
+ if (typeof crypto.randomUUID === "function")
124
+ return crypto.randomUUID();
125
+ }
126
+ catch {
127
+ // coercion-ok: the browser fallback remains usable when crypto is unavailable.
128
+ }
129
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
130
+ }
131
+ function safeAttributionValue(value) {
132
+ return typeof value === "string" ? value.trim().slice(0, 120) : "";
133
+ }
134
+ function trackAuth(app, name, properties = {}) {
135
+ if (isSyntheticTrafficValue(window.__AGENT_NATIVE_SYNTHETIC_TRAFFIC__)) {
136
+ return;
137
+ }
138
+ try {
139
+ const config = window.__AGENT_NATIVE_CONFIG__;
140
+ if (!config?.agentNativeAnalyticsPublicKey)
141
+ return;
142
+ const anonymousId = readStorage(ANALYTICS_ANONYMOUS_ID_KEY);
143
+ if (!anonymousId)
144
+ return;
145
+ const sessionId = (() => {
146
+ try {
147
+ return window.sessionStorage.getItem(ANALYTICS_SESSION_ID_KEY) ?? "";
148
+ }
149
+ catch {
150
+ // coercion-ok: analytics session storage is optional.
151
+ return "";
152
+ }
153
+ })();
154
+ const body = JSON.stringify({
155
+ publicKey: config.agentNativeAnalyticsPublicKey,
156
+ event: name,
157
+ properties: { app, ...properties },
158
+ anonymousId,
159
+ sessionId: sessionId || undefined,
160
+ timestamp: new Date().toISOString(),
161
+ });
162
+ const endpoint = config.agentNativeAnalyticsEndpoint ??
163
+ "https://analytics.agent-native.com/track";
164
+ if (navigator.sendBeacon?.(endpoint, body))
165
+ return;
166
+ void fetch(endpoint, {
167
+ method: "POST",
168
+ body,
169
+ keepalive: true,
170
+ headers: { "Content-Type": "text/plain;charset=UTF-8" },
171
+ }).catch(() => undefined);
172
+ }
173
+ catch {
174
+ // coercion-ok: analytics is best effort and cannot block authentication.
175
+ }
176
+ }
177
+ function isLoopbackHostname() {
178
+ if (typeof window === "undefined")
179
+ return false;
180
+ const hostname = window.location.hostname.toLowerCase();
181
+ return (hostname === "localhost" ||
182
+ hostname === "::1" ||
183
+ hostname === "127.0.0.1" ||
184
+ hostname.startsWith("127."));
185
+ }
186
+ function isBuilderPreviewHostname() {
187
+ if (typeof window === "undefined")
188
+ return false;
189
+ const hostname = window.location.hostname.toLowerCase();
190
+ return (hostname.endsWith(".builderio.xyz") ||
191
+ hostname.endsWith(".builderio.dev") ||
192
+ hostname.endsWith(".builder.codes") ||
193
+ hostname.endsWith(".builder.my"));
194
+ }
195
+ function isBuilderPreview() {
196
+ try {
197
+ const params = new URLSearchParams(window.location.search);
198
+ if (params.has("builder.preview") ||
199
+ params.has("builder.frameEditing") ||
200
+ params.has("__builder_editing__")) {
201
+ window.sessionStorage.setItem("__an_builder_preview_seen", "1");
202
+ return true;
203
+ }
204
+ if (window.sessionStorage.getItem("__an_builder_preview_seen") === "1") {
205
+ return true;
206
+ }
207
+ }
208
+ catch {
209
+ // coercion-ok: preview storage is optional; referrer detection remains available.
210
+ }
211
+ const referrer = document.referrer;
212
+ return /builder\.io|builder\.my|builderio\.xyz|builderio\.dev|builder\.codes/i.test(referrer);
213
+ }
214
+ export function isAgentNativeDesktop(userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent) {
215
+ return /AgentNativeDesktop/i.test(userAgent);
216
+ }
217
+ export function isElectron(userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent) {
218
+ return userAgent.includes("Electron");
219
+ }
220
+ /**
221
+ * Builder's desktop webview uses Electron without the Agent-Native marker.
222
+ * This only selects the local workspace return origin; native deep-link
223
+ * handling remains exclusive to Agent-Native Desktop.
224
+ */
225
+ export function isBuilderDesktop(userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent) {
226
+ return isElectron(userAgent) && !isAgentNativeDesktop(userAgent);
227
+ }
228
+ function isInFrame() {
229
+ try {
230
+ return window.self !== window.top;
231
+ }
232
+ catch {
233
+ // coercion-ok: cross-origin frame inspection can be denied; assume embedded.
234
+ return true;
235
+ }
236
+ }
237
+ function configuredOAuthOrigin(value, currentOrigin = typeof window === "undefined" ? "" : window.location.origin) {
238
+ if (!value)
239
+ return "";
240
+ try {
241
+ const origin = new URL(value).origin;
242
+ return origin !== currentOrigin ? origin : "";
243
+ }
244
+ catch {
245
+ // coercion-ok: malformed optional OAuth configuration uses same-origin behavior.
246
+ return "";
247
+ }
248
+ }
249
+ function builderPreviewReturnOrigin() {
250
+ if (typeof window === "undefined")
251
+ return "";
252
+ const candidates = [window.location.href, document.referrer];
253
+ try {
254
+ if (window.location.ancestorOrigins) {
255
+ for (const origin of window.location.ancestorOrigins)
256
+ candidates.push(origin);
257
+ }
258
+ }
259
+ catch {
260
+ // coercion-ok: ancestor frame metadata is optional and may be inaccessible.
261
+ }
262
+ for (const candidate of candidates) {
263
+ try {
264
+ const url = new URL(candidate);
265
+ const hostname = url.hostname.toLowerCase();
266
+ const isBuilderHost = hostname === "builderio.xyz" ||
267
+ hostname.endsWith(".builderio.xyz") ||
268
+ hostname === "builderio.dev" ||
269
+ hostname.endsWith(".builderio.dev") ||
270
+ hostname === "builder.codes" ||
271
+ hostname.endsWith(".builder.codes") ||
272
+ hostname === "builder.my" ||
273
+ hostname.endsWith(".builder.my");
274
+ if (url.protocol === "https:" && isBuilderHost)
275
+ return url.origin;
276
+ }
277
+ catch {
278
+ // coercion-ok: malformed frame metadata is ignored.
279
+ }
280
+ }
281
+ return "";
282
+ }
283
+ export function normalizeOAuthReturnPath(target, origin = typeof window === "undefined"
284
+ ? "http://agent-native.local"
285
+ : window.location.origin) {
286
+ try {
287
+ const url = new URL(target || "/", origin);
288
+ let pathname = url.pathname || "/";
289
+ if (pathname === "/dispatch/dispatch") {
290
+ pathname = "/dispatch";
291
+ }
292
+ else if (pathname.startsWith("/dispatch/")) {
293
+ const rest = pathname.slice("/dispatch/".length);
294
+ const first = rest.split("/")[0];
295
+ const dispatchRoutes = new Set([
296
+ "overview",
297
+ "apps",
298
+ "metrics",
299
+ "vault",
300
+ "integrations",
301
+ "messaging",
302
+ "workspace",
303
+ "agents",
304
+ "destinations",
305
+ "identities",
306
+ "approvals",
307
+ "audit",
308
+ "team",
309
+ "thread-debug",
310
+ "new-app",
311
+ ]);
312
+ if (first === "dispatch")
313
+ pathname = "/dispatch" + rest.slice(first.length);
314
+ else if (first && !dispatchRoutes.has(first))
315
+ pathname = "/" + rest;
316
+ }
317
+ return pathname + url.search + url.hash;
318
+ }
319
+ catch {
320
+ return target || "/";
321
+ }
322
+ }
323
+ export function resolveOAuthReturnOrigin(input) {
324
+ return (input.previewOrigin ||
325
+ input.workspaceGatewayReturnOrigin ||
326
+ (isAgentNativeDesktop(input.userAgent) || isBuilderDesktop(input.userAgent)
327
+ ? BUILDER_DESKTOP_RETURN_ORIGIN
328
+ : ""));
329
+ }
330
+ export function oauthReturnTarget(target, workspaceGatewayReturnOrigin, userAgent = typeof navigator === "undefined" ? "" : navigator.userAgent) {
331
+ const path = normalizeOAuthReturnPath(target);
332
+ const origin = resolveOAuthReturnOrigin({
333
+ previewOrigin: builderPreviewReturnOrigin(),
334
+ workspaceGatewayReturnOrigin,
335
+ userAgent,
336
+ });
337
+ return origin ? origin + path : path;
338
+ }
339
+ export function resolveGoogleAuthUrlPath(input) {
340
+ const previewOrigin = input.builderPreview
341
+ ? configuredOAuthOrigin(input.publicOAuthOrigin, input.currentOrigin)
342
+ : "";
343
+ // The public OAuth authority is rooted at the app origin even when the
344
+ // preview itself is mounted under a workspace prefix such as /dispatch.
345
+ return previewOrigin
346
+ ? `${previewOrigin}${GOOGLE_AUTH_URL_PATH}`
347
+ : `${input.runtimeAppBasePath}${GOOGLE_AUTH_URL_PATH}`;
348
+ }
349
+ function createFlowId() {
350
+ try {
351
+ if (typeof crypto.randomUUID === "function")
352
+ return crypto.randomUUID();
353
+ }
354
+ catch {
355
+ // coercion-ok: the browser fallback remains usable when crypto is unavailable.
356
+ }
357
+ return `agent-native-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
358
+ }
359
+ function createVerifier() {
360
+ try {
361
+ if (typeof crypto.randomUUID === "function") {
362
+ return crypto.randomUUID() + crypto.randomUUID();
363
+ }
364
+ if (typeof crypto.getRandomValues === "function") {
365
+ const bytes = new Uint8Array(32);
366
+ crypto.getRandomValues(bytes);
367
+ let binary = "";
368
+ for (const byte of bytes)
369
+ binary += String.fromCharCode(byte);
370
+ return btoa(binary)
371
+ .replace(/\+/g, "-")
372
+ .replace(/\//g, "_")
373
+ .replace(/=+$/, "");
374
+ }
375
+ }
376
+ catch {
377
+ // coercion-ok: no verifier is a typed failure handled by the OAuth caller.
378
+ return "";
379
+ }
380
+ return "";
381
+ }
382
+ const GOOGLE_BRAND_COLORS = {
383
+ // guard:allow-raw-color - Google brand mark must retain provider colors.
384
+ blue: "#4285F4",
385
+ // guard:allow-raw-color - Google brand mark must retain provider colors.
386
+ green: "#34A853",
387
+ // guard:allow-raw-color - Google brand mark must retain provider colors.
388
+ yellow: "#FBBC05",
389
+ // guard:allow-raw-color - Google brand mark must retain provider colors.
390
+ red: "#EA4335",
391
+ };
392
+ function googleSvg() {
393
+ return (React.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true" },
394
+ React.createElement("path", { fill: GOOGLE_BRAND_COLORS.blue, d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" }),
395
+ React.createElement("path", { fill: GOOGLE_BRAND_COLORS.green, d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }),
396
+ React.createElement("path", { fill: GOOGLE_BRAND_COLORS.yellow, d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }),
397
+ React.createElement("path", { fill: GOOGLE_BRAND_COLORS.red, d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" })));
398
+ }
399
+ function headingKeys(view) {
400
+ if (view === "login") {
401
+ return { heading: "welcomeBackTitle", subtitle: "signInSubtitle" };
402
+ }
403
+ if (view === "forgot") {
404
+ return { heading: "resetPasswordTitle", subtitle: "resetPasswordSubtitle" };
405
+ }
406
+ if (view === "verification") {
407
+ return { heading: "checkEmailTitle", subtitle: "finishAccountSubtitle" };
408
+ }
409
+ if (view === "googleOnly") {
410
+ return { heading: "signInTitle", subtitle: "googleOnlySubtitle" };
411
+ }
412
+ if (view === "magicLinkSent") {
413
+ return { heading: "magicLinkSent", subtitle: "magicLinkSentCopy" };
414
+ }
415
+ if (view === "magicLink") {
416
+ return { heading: "magicLinkTitle", subtitle: "magicLinkSubtitle" };
417
+ }
418
+ return { heading: "welcomeTitle", subtitle: "createAccountSubtitle" };
419
+ }
420
+ export function AuthPage(props) {
421
+ const { authMode, googleOnly, initialPrompt, appBasePath, workspaceRuntime, trackingApp, defaultLocale, localeStorageKey, locales, localeMetadata, localeOptions, marketing, marketingLocales, brandMarkSrc, githubUrl, showGoogle, signupLegalNotice, signupLocalModeNote, connectionLabel, docsAuthUrl, identitySsoEnabled, publicOAuthOrigin, workspaceGatewayReturnOrigin, googleAuthMode, builderPreviewLocalDevEnabled, } = props;
422
+ const [localePreference, setLocalePreference] = React.useState("system");
423
+ const [locale, setLocale] = React.useState(defaultLocale);
424
+ const [localeMenuOpen, setLocaleMenuOpen] = React.useState(false);
425
+ const [view, setView] = React.useState(props.initialView);
426
+ const [messages, setMessages] = React.useState({});
427
+ const [submitting, setSubmitting] = React.useState(null);
428
+ const [localDevAvailable, setLocalDevAvailable] = React.useState(false);
429
+ const [localDevBusy, setLocalDevBusy] = React.useState(false);
430
+ const [fullAuthOptionsVisible, setFullAuthOptionsVisible] = React.useState(true);
431
+ const [localNoteVisible, setLocalNoteVisible] = React.useState(false);
432
+ const [upgradeVisible, setUpgradeVisible] = React.useState(false);
433
+ const [magicLinkEmail, setMagicLinkEmail] = React.useState("");
434
+ const [signupEmail, setSignupEmail] = React.useState("");
435
+ const [signupPassword, setSignupPassword] = React.useState("");
436
+ const [signupPasswordConfirmation, setSignupPasswordConfirmation] = React.useState("");
437
+ const [loginEmail, setLoginEmail] = React.useState("");
438
+ const [loginPassword, setLoginPassword] = React.useState("");
439
+ const [forgotEmail, setForgotEmail] = React.useState("");
440
+ const [forgotSent, setForgotSent] = React.useState(false);
441
+ const [verificationEmail, setVerificationEmail] = React.useState("");
442
+ const [verificationResendUntil, setVerificationResendUntil] = React.useState(0);
443
+ const [googleBusy, setGoogleBusy] = React.useState(false);
444
+ const [magicLinkBusy, setMagicLinkBusy] = React.useState(false);
445
+ const [environmentVisible, setEnvironmentVisible] = React.useState(false);
446
+ const [environmentOpen, setEnvironmentOpen] = React.useState(false);
447
+ const [environmentProductionUrl, setEnvironmentProductionUrl] = React.useState("");
448
+ const [copiedLocalMode, setCopiedLocalMode] = React.useState(false);
449
+ const pendingSignupPassword = React.useRef("");
450
+ const oauthPollTimer = React.useRef(null);
451
+ const oauthPollInFlight = React.useRef(false);
452
+ const oauthPopupTimer = React.useRef(null);
453
+ const oauthPopupGraceTimer = React.useRef(null);
454
+ const oauthFlowId = React.useRef(null);
455
+ const nativeOAuthFlowId = React.useRef(null);
456
+ const nativeOAuthRequestPending = React.useRef(false);
457
+ const nativeOAuthAbandonTimer = React.useRef(null);
458
+ const verificationCheckInFlight = React.useRef(false);
459
+ const verifiedReturnHandled = React.useRef(false);
460
+ const [runtimeAppBasePath, setRuntimeAppBasePath] = React.useState(appBasePath);
461
+ const [runtimeBasePathResolved, setRuntimeBasePathResolved] = React.useState(Boolean(appBasePath || !workspaceRuntime));
462
+ React.useEffect(() => {
463
+ if (appBasePath || !workspaceRuntime) {
464
+ setRuntimeBasePathResolved(true);
465
+ return;
466
+ }
467
+ setRuntimeAppBasePath(inferWorkspaceBasePath(window.location.pathname));
468
+ setRuntimeBasePathResolved(true);
469
+ }, [appBasePath, workspaceRuntime]);
470
+ const t = React.useCallback((key) => copyText(locales, defaultLocale, locale, key), [defaultLocale, locale, locales]);
471
+ const apiPath = React.useCallback((path) => `${runtimeAppBasePath}${path}`, [runtimeAppBasePath]);
472
+ const journey = React.useCallback(() => {
473
+ if (typeof window === "undefined") {
474
+ return signInJourney({
475
+ at: `${runtimeAppBasePath}/`,
476
+ basePath: runtimeAppBasePath,
477
+ });
478
+ }
479
+ return signInJourney({
480
+ at: window.location.pathname +
481
+ window.location.search +
482
+ window.location.hash,
483
+ continuation: new URLSearchParams(window.location.search).get("c"),
484
+ legacyReturn: new URLSearchParams(window.location.search).get("return"),
485
+ basePath: runtimeAppBasePath,
486
+ });
487
+ }, [runtimeAppBasePath]);
488
+ const resumeHref = React.useCallback(() => journey().resumeHref, [journey]);
489
+ const redirectToSignedInApp = React.useCallback((target) => {
490
+ window.location.replace(target || resumeHref());
491
+ }, [resumeHref]);
492
+ const setNotice = React.useCallback((key, notice) => {
493
+ setMessages((current) => ({ ...current, [key]: notice }));
494
+ }, []);
495
+ const notice = React.useCallback((key) => {
496
+ const current = messages[key];
497
+ if (!current)
498
+ return null;
499
+ return (React.createElement("p", { className: `msg ${current.kind} show`, role: "status", "aria-live": "polite" }, current.text));
500
+ }, [messages]);
501
+ const pendingEmailStorageKey = React.useCallback(() => `${PENDING_SIGNUP_EMAIL_STORAGE_KEY}:${runtimeAppBasePath || "/"}`, [runtimeAppBasePath]);
502
+ const rememberPendingSignupEmail = React.useCallback((email) => {
503
+ if (email)
504
+ writeStorage(pendingEmailStorageKey(), normalizeEmail(email));
505
+ else
506
+ removeStorage(pendingEmailStorageKey());
507
+ }, [pendingEmailStorageKey]);
508
+ const readPendingSignupEmail = React.useCallback(() => {
509
+ const email = readStorage(pendingEmailStorageKey());
510
+ return isValidEmail(email) ? normalizeEmail(email) : "";
511
+ }, [pendingEmailStorageKey]);
512
+ React.useEffect(() => {
513
+ const stored = readStorage(localeStorageKey);
514
+ const preference = stored || "system";
515
+ const nextLocale = preference === "system"
516
+ ? resolveSystemLocale(localeOptions, defaultLocale)
517
+ : resolveLocale(preference, localeOptions, defaultLocale);
518
+ setLocalePreference(preference);
519
+ setLocale(nextLocale);
520
+ document.documentElement.lang = nextLocale;
521
+ document.documentElement.dir = localeMetadata[nextLocale]?.dir || "ltr";
522
+ document.documentElement.dataset.locale = nextLocale;
523
+ }, [defaultLocale, localeMetadata, localeOptions, localeStorageKey]);
524
+ React.useEffect(() => {
525
+ const closeMenu = (event) => {
526
+ const target = event.target;
527
+ if (target instanceof Node &&
528
+ document.querySelector(".locale-picker")?.contains(target)) {
529
+ return;
530
+ }
531
+ setLocaleMenuOpen(false);
532
+ };
533
+ const closeOnEscape = (event) => {
534
+ if (event.key === "Escape")
535
+ setLocaleMenuOpen(false);
536
+ };
537
+ document.addEventListener("click", closeMenu);
538
+ document.addEventListener("keydown", closeOnEscape);
539
+ return () => {
540
+ document.removeEventListener("click", closeMenu);
541
+ document.removeEventListener("keydown", closeOnEscape);
542
+ };
543
+ }, []);
544
+ React.useEffect(() => {
545
+ const nextTitle = marketing?.appName
546
+ ? `${marketing.appName} — ${t("pageTitleSignIn")}`
547
+ : t("pageTitleWelcome");
548
+ document.title = nextTitle;
549
+ document.documentElement.lang = locale;
550
+ document.documentElement.dir = localeMetadata[locale]?.dir || "ltr";
551
+ document.documentElement.dataset.locale = locale;
552
+ }, [locale, localeMetadata, marketing?.appName, t]);
553
+ React.useEffect(() => {
554
+ if (googleOnly)
555
+ return;
556
+ const path = window.location.pathname.replace(/\/+$/, "") || "/";
557
+ const params = new URLSearchParams(window.location.search);
558
+ const verificationError = params.get("error") === "verification_link_invalid";
559
+ if (params.get("verified") || verificationError) {
560
+ setView("login");
561
+ const rememberedEmail = readPendingSignupEmail();
562
+ if (rememberedEmail)
563
+ setLoginEmail(rememberedEmail);
564
+ if (verificationError) {
565
+ setNotice("login", {
566
+ kind: "error",
567
+ text: t("verificationLinkInvalid"),
568
+ });
569
+ }
570
+ return;
571
+ }
572
+ if (params.get("tab") === "login" || path.endsWith("/login")) {
573
+ setView("login");
574
+ return;
575
+ }
576
+ if (params.get("tab") === "signup" || path.endsWith("/signup")) {
577
+ setView("signup");
578
+ return;
579
+ }
580
+ if (authMode === "magic-link") {
581
+ setView("magicLink");
582
+ return;
583
+ }
584
+ const storedTab = readStorage(TAB_STORAGE_KEY);
585
+ if (storedTab === "login" || storedTab === "signup")
586
+ setView(storedTab);
587
+ }, [authMode, googleOnly, readPendingSignupEmail, setNotice, t]);
588
+ React.useEffect(() => {
589
+ if (!runtimeBasePathResolved)
590
+ return;
591
+ const probe = async () => {
592
+ for (let attempt = 0; attempt < 3; attempt += 1) {
593
+ let retry = false;
594
+ try {
595
+ const { response, data, readable } = await requestJson(apiPath("/_agent-native/auth/session"), {
596
+ headers: { Accept: "application/json" },
597
+ cache: "no-store",
598
+ });
599
+ if (response.ok && typeof data.email === "string" && !data.error) {
600
+ redirectToSignedInApp();
601
+ return;
602
+ }
603
+ retry = shouldRetryAuthSessionProbe(response, readable);
604
+ }
605
+ catch {
606
+ retry = true;
607
+ }
608
+ if (!retry || attempt === 2)
609
+ return;
610
+ await new Promise((resolve) => window.setTimeout(resolve, 250 * (attempt + 1)));
611
+ }
612
+ };
613
+ void probe();
614
+ }, [apiPath, redirectToSignedInApp, runtimeBasePathResolved]);
615
+ React.useEffect(() => {
616
+ let anonymousId = readStorage(ANALYTICS_ANONYMOUS_ID_KEY);
617
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(anonymousId)) {
618
+ anonymousId = generateAnonymousId();
619
+ writeStorage(ANALYTICS_ANONYMOUS_ID_KEY, anonymousId);
620
+ }
621
+ try {
622
+ document.cookie = `an_aid=${encodeURIComponent(anonymousId)}; path=/; max-age=2592000; SameSite=Lax`;
623
+ }
624
+ catch {
625
+ // coercion-ok: attribution cookies are optional for authentication.
626
+ }
627
+ try {
628
+ const existing = readStorage(FIRST_TOUCH_STORAGE_KEY);
629
+ if (!existing &&
630
+ !document.cookie
631
+ .split(";")
632
+ .some((part) => part.trim().startsWith(`${FIRST_TOUCH_COOKIE}=`))) {
633
+ const params = new URLSearchParams(window.location.search);
634
+ const attribution = {};
635
+ for (const key of [
636
+ "ref",
637
+ "via",
638
+ "utm_source",
639
+ "utm_medium",
640
+ "utm_campaign",
641
+ "utm_content",
642
+ "utm_term",
643
+ ]) {
644
+ const value = safeAttributionValue(params.get(key));
645
+ if (value)
646
+ attribution[key] = value;
647
+ }
648
+ const returnPath = signInJourney({
649
+ at: window.location.pathname,
650
+ continuation: params.get("c"),
651
+ legacyReturn: params.get("return"),
652
+ basePath: runtimeAppBasePath,
653
+ }).resumeHref;
654
+ const landingPath = safeAttributionValue(returnPath);
655
+ if (landingPath)
656
+ attribution.landing_path = landingPath;
657
+ try {
658
+ const referrer = new URL(document.referrer);
659
+ if (referrer.host !== window.location.host) {
660
+ attribution.landing_referrer = safeAttributionValue(referrer.host);
661
+ }
662
+ }
663
+ catch {
664
+ // coercion-ok: a non-URL referrer is not useful attribution.
665
+ }
666
+ attribution.landed_at = new Date().toISOString();
667
+ const json = JSON.stringify(attribution);
668
+ writeStorage(FIRST_TOUCH_STORAGE_KEY, json);
669
+ document.cookie = `${FIRST_TOUCH_COOKIE}=${encodeURIComponent(json)}; path=/; max-age=2592000; SameSite=Lax`;
670
+ }
671
+ }
672
+ catch {
673
+ // coercion-ok: attribution is best effort and never blocks authentication.
674
+ }
675
+ trackAuth(trackingApp, "auth.signup_viewed", {
676
+ surface: "signup",
677
+ auth_mode: authMode,
678
+ auth_view: view,
679
+ });
680
+ }, [authMode, runtimeAppBasePath, trackingApp]);
681
+ React.useEffect(() => {
682
+ const hostname = window.location.hostname.toLowerCase();
683
+ setLocalNoteVisible(hostname === "localhost" ||
684
+ hostname === "127.0.0.1" ||
685
+ hostname === "::1" ||
686
+ hostname.endsWith(".local"));
687
+ }, []);
688
+ const localDevAllowed = React.useMemo(() => isLoopbackHostname() ||
689
+ (builderPreviewLocalDevEnabled && isBuilderPreviewHostname()), [builderPreviewLocalDevEnabled]);
690
+ React.useEffect(() => {
691
+ if (!runtimeBasePathResolved || !localDevAllowed)
692
+ return;
693
+ let active = true;
694
+ const loadAvailability = async () => {
695
+ try {
696
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/local-dev"), {
697
+ method: "GET",
698
+ cache: "no-store",
699
+ headers: { Accept: "application/json" },
700
+ });
701
+ if (!active)
702
+ return;
703
+ const available = response.ok && data.available === true;
704
+ setLocalDevAvailable(available);
705
+ if (!available) {
706
+ setFullAuthOptionsVisible(true);
707
+ return;
708
+ }
709
+ const params = new URLSearchParams(window.location.search);
710
+ const startWithLocalDev = !params.has("tab") &&
711
+ !params.has("verified") &&
712
+ params.get("error") !== "verification_link_invalid";
713
+ setFullAuthOptionsVisible(!startWithLocalDev);
714
+ }
715
+ catch {
716
+ if (active)
717
+ setFullAuthOptionsVisible(true);
718
+ }
719
+ };
720
+ void loadAvailability();
721
+ return () => {
722
+ active = false;
723
+ };
724
+ }, [apiPath, localDevAllowed, runtimeBasePathResolved]);
725
+ React.useEffect(() => {
726
+ const params = new URLSearchParams(window.location.search);
727
+ let shouldShow = params.get("signin") === "1" || params.get("upgrade-from-local") === "1";
728
+ if (!shouldShow)
729
+ shouldShow = readStorage("an_migrate_from_local") === "1";
730
+ setUpgradeVisible(shouldShow);
731
+ }, []);
732
+ React.useEffect(() => {
733
+ if (window.parent !== window)
734
+ return;
735
+ try {
736
+ if (localDevAllowed) {
737
+ const forceUrl = new URL(window.location.href);
738
+ if (forceUrl.searchParams.get(props.betaForceQueryParam) === "true") {
739
+ window.sessionStorage.setItem(props.betaForceSessionStorageKey, "1");
740
+ }
741
+ }
742
+ const optOutUrl = new URL(window.location.href);
743
+ const optOutValue = optOutUrl.searchParams.get(props.betaOptOutQueryParam);
744
+ if (optOutValue !== null) {
745
+ const expiry = Number(optOutValue);
746
+ if (Number.isFinite(expiry) && expiry > Date.now()) {
747
+ window.localStorage.setItem(props.betaOptOutStorageKey, String(expiry));
748
+ }
749
+ optOutUrl.searchParams.delete(props.betaOptOutQueryParam);
750
+ window.history.replaceState(null, "", optOutUrl.toString());
751
+ }
752
+ }
753
+ catch {
754
+ // coercion-ok: beta controls are optional.
755
+ }
756
+ }, [localDevAllowed, props]);
757
+ React.useEffect(() => {
758
+ if (window.parent !== window)
759
+ return;
760
+ const hostname = window.location.hostname.toLowerCase().replace(/\.$/, "");
761
+ const productionHost = hostname.startsWith("beta.")
762
+ ? hostname.slice("beta.".length)
763
+ : "";
764
+ if (!productionHost ||
765
+ props.environmentBetaHosts[productionHost] !== hostname) {
766
+ return;
767
+ }
768
+ try {
769
+ const productionUrl = new URL(window.location.href);
770
+ productionUrl.protocol = "https:";
771
+ productionUrl.hostname = productionHost;
772
+ productionUrl.port = "";
773
+ productionUrl.searchParams.set(props.betaOptOutQueryParam, String(Date.now() + props.betaOptOutDurationMs));
774
+ setEnvironmentProductionUrl(productionUrl.toString());
775
+ setEnvironmentVisible(true);
776
+ }
777
+ catch {
778
+ // coercion-ok: malformed host metadata cannot produce a useful switcher.
779
+ }
780
+ }, [props]);
781
+ const stopOAuthPolling = React.useCallback(() => {
782
+ if (oauthPollTimer.current !== null) {
783
+ window.clearInterval(oauthPollTimer.current);
784
+ oauthPollTimer.current = null;
785
+ }
786
+ if (oauthPopupTimer.current !== null) {
787
+ window.clearInterval(oauthPopupTimer.current);
788
+ oauthPopupTimer.current = null;
789
+ }
790
+ if (oauthPopupGraceTimer.current !== null) {
791
+ window.clearTimeout(oauthPopupGraceTimer.current);
792
+ oauthPopupGraceTimer.current = null;
793
+ }
794
+ oauthPollInFlight.current = false;
795
+ }, []);
796
+ const clearNativeOAuthRecovery = React.useCallback(() => {
797
+ if (nativeOAuthAbandonTimer.current !== null) {
798
+ window.clearTimeout(nativeOAuthAbandonTimer.current);
799
+ nativeOAuthAbandonTimer.current = null;
800
+ }
801
+ }, []);
802
+ const stopNativeOAuth = React.useCallback(() => {
803
+ clearNativeOAuthRecovery();
804
+ nativeOAuthFlowId.current = null;
805
+ nativeOAuthRequestPending.current = false;
806
+ }, [clearNativeOAuthRecovery]);
807
+ React.useEffect(() => stopOAuthPolling, [stopOAuthPolling]);
808
+ React.useEffect(() => {
809
+ if (!isAgentNativeDesktop())
810
+ return;
811
+ const recoverAfterReturn = () => {
812
+ const flowId = nativeOAuthFlowId.current;
813
+ if (!flowId ||
814
+ nativeOAuthRequestPending.current ||
815
+ oauthPollTimer.current === null) {
816
+ return;
817
+ }
818
+ clearNativeOAuthRecovery();
819
+ nativeOAuthAbandonTimer.current = window.setTimeout(() => {
820
+ nativeOAuthAbandonTimer.current = null;
821
+ if (flowId !== nativeOAuthFlowId.current ||
822
+ nativeOAuthRequestPending.current ||
823
+ oauthPollTimer.current === null) {
824
+ return;
825
+ }
826
+ stopOAuthPolling();
827
+ nativeOAuthFlowId.current = null;
828
+ nativeOAuthRequestPending.current = false;
829
+ setGoogleBusy(false);
830
+ }, 5000);
831
+ };
832
+ const clearRecoveryWhileHidden = () => clearNativeOAuthRecovery();
833
+ const handleVisibilityChange = () => {
834
+ if (document.visibilityState === "visible")
835
+ recoverAfterReturn();
836
+ else
837
+ clearRecoveryWhileHidden();
838
+ };
839
+ window.addEventListener("focus", recoverAfterReturn);
840
+ document.addEventListener("visibilitychange", handleVisibilityChange);
841
+ return () => {
842
+ window.removeEventListener("focus", recoverAfterReturn);
843
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
844
+ clearNativeOAuthRecovery();
845
+ };
846
+ }, [clearNativeOAuthRecovery, stopOAuthPolling]);
847
+ const finishOAuthExchange = React.useCallback((target, sessionToken) => {
848
+ stopOAuthPolling();
849
+ stopNativeOAuth();
850
+ setGoogleBusy(false);
851
+ setMagicLinkBusy(false);
852
+ if (isBuilderPreview() && sessionToken) {
853
+ try {
854
+ const url = new URL(target, window.location.origin);
855
+ url.searchParams.set("_session", sessionToken);
856
+ window.location.replace(url.pathname + url.search + url.hash);
857
+ return;
858
+ }
859
+ catch {
860
+ // coercion-ok: same-origin continuation remains safe if preview parsing fails.
861
+ }
862
+ }
863
+ redirectToSignedInApp(target);
864
+ }, [redirectToSignedInApp, stopNativeOAuth, stopOAuthPolling]);
865
+ const startOAuthExchange = React.useCallback((flowId, target, verifier, kind, popup) => {
866
+ const startedAt = Date.now();
867
+ const check = async () => {
868
+ if (oauthPollInFlight.current)
869
+ return;
870
+ oauthPollInFlight.current = true;
871
+ try {
872
+ const { data } = await requestJson(`${apiPath("/_agent-native/auth/desktop-exchange")}?flow_id=${encodeURIComponent(flowId)}`, {
873
+ headers: verifier
874
+ ? { "X-Agent-Native-Desktop-Verifier": verifier }
875
+ : undefined,
876
+ });
877
+ if (flowId !== oauthFlowId.current)
878
+ return;
879
+ if (typeof data.email === "string" ||
880
+ typeof data.token === "string") {
881
+ finishOAuthExchange(target, typeof data.token === "string" ? data.token : undefined);
882
+ return;
883
+ }
884
+ if (data.error) {
885
+ stopOAuthPolling();
886
+ stopNativeOAuth();
887
+ setGoogleBusy(false);
888
+ setMagicLinkBusy(false);
889
+ if (kind === "magic-link")
890
+ setView("magicLink");
891
+ setNotice(kind, {
892
+ kind: "error",
893
+ text: authErrorText(data, kind === "magic-link"
894
+ ? t("magicLinkFailed")
895
+ : t("googleNotConfigured")),
896
+ });
897
+ return;
898
+ }
899
+ }
900
+ catch {
901
+ // coercion-ok: external OAuth completion may transiently fail while polling.
902
+ }
903
+ finally {
904
+ oauthPollInFlight.current = false;
905
+ }
906
+ if (Date.now() - startedAt > 5 * 60 * 1000) {
907
+ stopOAuthPolling();
908
+ stopNativeOAuth();
909
+ setGoogleBusy(false);
910
+ setMagicLinkBusy(false);
911
+ if (kind === "magic-link")
912
+ setView("magicLink");
913
+ setNotice(kind, {
914
+ kind: "error",
915
+ text: kind === "magic-link"
916
+ ? t("magicLinkFailed")
917
+ : t("googleNeverFinished"),
918
+ });
919
+ }
920
+ };
921
+ stopOAuthPolling();
922
+ oauthPollTimer.current = window.setInterval(() => void check(), 1000);
923
+ if (popup) {
924
+ oauthPopupTimer.current = window.setInterval(() => {
925
+ let closed = false;
926
+ try {
927
+ closed = popup.closed;
928
+ }
929
+ catch {
930
+ closed = true;
931
+ }
932
+ if (!closed)
933
+ return;
934
+ if (oauthPopupTimer.current !== null) {
935
+ window.clearInterval(oauthPopupTimer.current);
936
+ oauthPopupTimer.current = null;
937
+ }
938
+ oauthPopupGraceTimer.current = window.setTimeout(() => {
939
+ oauthPopupGraceTimer.current = null;
940
+ if (flowId !== oauthFlowId.current)
941
+ return;
942
+ void requestJson(apiPath("/_agent-native/auth/session"), {
943
+ headers: { Accept: "application/json" },
944
+ })
945
+ .then(({ response, data }) => {
946
+ if (flowId !== oauthFlowId.current)
947
+ return;
948
+ if (response.ok &&
949
+ typeof data.email === "string" &&
950
+ !data.error) {
951
+ finishOAuthExchange(target);
952
+ return;
953
+ }
954
+ stopOAuthPolling();
955
+ setGoogleBusy(false);
956
+ setNotice("google", {
957
+ kind: "error",
958
+ text: t("googlePopupHelp"),
959
+ });
960
+ })
961
+ .catch(() => {
962
+ if (flowId !== oauthFlowId.current)
963
+ return;
964
+ stopOAuthPolling();
965
+ setGoogleBusy(false);
966
+ setNotice("google", {
967
+ kind: "error",
968
+ text: t("googlePopupHelp"),
969
+ });
970
+ });
971
+ }, 5000);
972
+ }, 500);
973
+ }
974
+ window.setTimeout(() => void check(), 500);
975
+ }, [
976
+ apiPath,
977
+ finishOAuthExchange,
978
+ setNotice,
979
+ stopNativeOAuth,
980
+ stopOAuthPolling,
981
+ t,
982
+ ]);
983
+ const resolveGoogleFlow = React.useCallback(() => {
984
+ const preview = isBuilderPreview();
985
+ if (preview)
986
+ return isInFrame() ? "popup" : "redirect";
987
+ const requested = new URLSearchParams(window.location.search).get("authMode");
988
+ if (requested === "popup" || requested === "redirect")
989
+ return requested;
990
+ if (googleAuthMode === "popup" || googleAuthMode === "redirect") {
991
+ return googleAuthMode;
992
+ }
993
+ return isAgentNativeDesktop() ? "redirect" : "popup";
994
+ }, [googleAuthMode]);
995
+ const googleAuthUrlPath = React.useCallback(() => resolveGoogleAuthUrlPath({
996
+ builderPreview: isBuilderPreview(),
997
+ currentOrigin: window.location.origin,
998
+ publicOAuthOrigin,
999
+ runtimeAppBasePath,
1000
+ }), [publicOAuthOrigin, runtimeAppBasePath]);
1001
+ const startGoogle = React.useCallback(async () => {
1002
+ if (!showGoogle || googleBusy)
1003
+ return;
1004
+ setGoogleBusy(true);
1005
+ setNotice("google", null);
1006
+ try {
1007
+ window.sessionStorage.setItem("__an_signin", "1");
1008
+ }
1009
+ catch {
1010
+ // coercion-ok: analytics session storage is optional.
1011
+ }
1012
+ trackAuth(trackingApp, view === "login" ? "auth.login_clicked" : "auth.signup_clicked", {
1013
+ surface: view === "login" ? "login" : "signup",
1014
+ method: "google",
1015
+ auth_view: view,
1016
+ });
1017
+ const target = resumeHref();
1018
+ const oauthTarget = oauthReturnTarget(target, workspaceGatewayReturnOrigin);
1019
+ const flowId = createFlowId();
1020
+ oauthFlowId.current = flowId;
1021
+ const flow = resolveGoogleFlow();
1022
+ const nativeDesktop = flow === "redirect" && isAgentNativeDesktop();
1023
+ if (nativeDesktop) {
1024
+ stopNativeOAuth();
1025
+ nativeOAuthFlowId.current = flowId;
1026
+ nativeOAuthRequestPending.current = true;
1027
+ }
1028
+ else {
1029
+ stopNativeOAuth();
1030
+ }
1031
+ const authUrl = googleAuthUrlPath();
1032
+ if (flow === "redirect" && !nativeDesktop) {
1033
+ const params = new URLSearchParams({
1034
+ return: oauthTarget,
1035
+ redirect: "1",
1036
+ });
1037
+ window.location.replace(`${authUrl}?${params.toString()}`);
1038
+ return;
1039
+ }
1040
+ const verifier = createVerifier();
1041
+ if (!verifier) {
1042
+ stopNativeOAuth();
1043
+ setGoogleBusy(false);
1044
+ setNotice("google", { kind: "error", text: t("failedToConnect") });
1045
+ return;
1046
+ }
1047
+ let popup = null;
1048
+ if (flow === "popup") {
1049
+ const builderPreviewFrame = isBuilderPreview() && isInFrame();
1050
+ try {
1051
+ popup = window.open("", "_blank", "width=640,height=760");
1052
+ if (!popup) {
1053
+ if (builderPreviewFrame) {
1054
+ setGoogleBusy(false);
1055
+ setNotice("google", {
1056
+ kind: "error",
1057
+ text: t("googlePopupHelp"),
1058
+ });
1059
+ return;
1060
+ }
1061
+ const params = new URLSearchParams({
1062
+ return: oauthTarget,
1063
+ redirect: "1",
1064
+ });
1065
+ window.location.replace(`${authUrl}?${params.toString()}`);
1066
+ return;
1067
+ }
1068
+ try {
1069
+ popup.opener = null;
1070
+ }
1071
+ catch {
1072
+ // coercion-ok: some browsers expose popup.opener as read-only.
1073
+ }
1074
+ }
1075
+ catch {
1076
+ if (builderPreviewFrame) {
1077
+ setGoogleBusy(false);
1078
+ setNotice("google", {
1079
+ kind: "error",
1080
+ text: t("googlePopupHelp"),
1081
+ });
1082
+ return;
1083
+ }
1084
+ const params = new URLSearchParams({
1085
+ return: oauthTarget,
1086
+ redirect: "1",
1087
+ });
1088
+ window.location.replace(`${authUrl}?${params.toString()}`);
1089
+ return;
1090
+ }
1091
+ }
1092
+ try {
1093
+ const params = new URLSearchParams({
1094
+ return: oauthTarget,
1095
+ desktop: "1",
1096
+ flow_id: flowId,
1097
+ });
1098
+ const { response, data } = await requestJson(`${authUrl}?${params.toString()}`, {
1099
+ method: "POST",
1100
+ headers: {
1101
+ Accept: "application/json",
1102
+ "X-Agent-Native-Desktop-Verifier": verifier,
1103
+ },
1104
+ });
1105
+ if (!response.ok || typeof data.url !== "string" || !data.url) {
1106
+ throw new Error(authErrorText(data, t("failedToConnect")));
1107
+ }
1108
+ if (nativeDesktop)
1109
+ nativeOAuthRequestPending.current = false;
1110
+ startOAuthExchange(flowId, target, verifier, "google", popup);
1111
+ if (popup) {
1112
+ popup.location.href = data.url;
1113
+ }
1114
+ else {
1115
+ window.location.href = data.url;
1116
+ }
1117
+ }
1118
+ catch (error) {
1119
+ try {
1120
+ popup?.close();
1121
+ }
1122
+ catch {
1123
+ // Ignore a popup that has already closed.
1124
+ }
1125
+ stopNativeOAuth();
1126
+ setGoogleBusy(false);
1127
+ setNotice("google", {
1128
+ kind: "error",
1129
+ text: error instanceof Error ? error.message : t("failedToConnect"),
1130
+ });
1131
+ }
1132
+ }, [
1133
+ googleAuthUrlPath,
1134
+ googleBusy,
1135
+ resolveGoogleFlow,
1136
+ resumeHref,
1137
+ showGoogle,
1138
+ startOAuthExchange,
1139
+ stopNativeOAuth,
1140
+ stopOAuthPolling,
1141
+ t,
1142
+ trackingApp,
1143
+ view,
1144
+ workspaceGatewayReturnOrigin,
1145
+ ]);
1146
+ const handleLocalDev = React.useCallback(async () => {
1147
+ if (localDevBusy)
1148
+ return;
1149
+ setLocalDevBusy(true);
1150
+ setNotice("local-dev", null);
1151
+ try {
1152
+ const { response } = await requestJson(apiPath("/_agent-native/auth/local-dev"), {
1153
+ method: "POST",
1154
+ headers: { Accept: "application/json" },
1155
+ });
1156
+ if (!response.ok)
1157
+ throw new Error("local-dev-auth-failed");
1158
+ redirectToSignedInApp();
1159
+ }
1160
+ catch {
1161
+ setLocalDevBusy(false);
1162
+ setLocalDevAvailable(false);
1163
+ setFullAuthOptionsVisible(true);
1164
+ setNotice("local-dev", { kind: "error", text: t("localDevFailed") });
1165
+ }
1166
+ }, [apiPath, localDevBusy, redirectToSignedInApp, setNotice, t]);
1167
+ const showVerificationStep = React.useCallback((email, password) => {
1168
+ const normalized = normalizeEmail(email);
1169
+ pendingSignupPassword.current = password;
1170
+ setVerificationEmail(normalized);
1171
+ rememberPendingSignupEmail(normalized);
1172
+ setNotice("verification", null);
1173
+ setView("verification");
1174
+ writeStorage(TAB_STORAGE_KEY, "signup");
1175
+ }, [rememberPendingSignupEmail, setNotice]);
1176
+ const tryPendingSignupLogin = React.useCallback(async () => {
1177
+ const email = verificationEmail || readPendingSignupEmail();
1178
+ const password = pendingSignupPassword.current;
1179
+ if (!email || !password)
1180
+ return { ok: false, needsManualSignIn: true };
1181
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/login"), {
1182
+ method: "POST",
1183
+ headers: { "Content-Type": "application/json" },
1184
+ body: JSON.stringify({ email, password }),
1185
+ });
1186
+ if (response.ok) {
1187
+ removeStorage(pendingEmailStorageKey());
1188
+ redirectToSignedInApp();
1189
+ return { ok: true, needsManualSignIn: false };
1190
+ }
1191
+ const error = authErrorText(data, t("finishSignInFailed"));
1192
+ return {
1193
+ ok: false,
1194
+ needsManualSignIn: false,
1195
+ error,
1196
+ isWaitingForVerification: /not verified|verification/i.test(error),
1197
+ };
1198
+ }, [
1199
+ apiPath,
1200
+ pendingEmailStorageKey,
1201
+ readPendingSignupEmail,
1202
+ redirectToSignedInApp,
1203
+ t,
1204
+ verificationEmail,
1205
+ ]);
1206
+ const checkVerification = React.useCallback(async (fallbackText) => {
1207
+ if (verificationCheckInFlight.current)
1208
+ return;
1209
+ verificationCheckInFlight.current = true;
1210
+ setNotice("verification", {
1211
+ kind: "success",
1212
+ text: t("checkingVerification"),
1213
+ });
1214
+ try {
1215
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/session"), {
1216
+ headers: { Accept: "application/json" },
1217
+ });
1218
+ if (response.ok && typeof data.email === "string" && !data.error) {
1219
+ removeStorage(pendingEmailStorageKey());
1220
+ redirectToSignedInApp();
1221
+ return;
1222
+ }
1223
+ const loginResult = await tryPendingSignupLogin();
1224
+ if (loginResult.ok)
1225
+ return;
1226
+ if (loginResult.needsManualSignIn ||
1227
+ !loginResult.isWaitingForVerification) {
1228
+ setLoginEmail(verificationEmail || readPendingSignupEmail());
1229
+ setView("login");
1230
+ setNotice("login", {
1231
+ kind: "success",
1232
+ text: fallbackText || t("enterPasswordAfterVerification"),
1233
+ });
1234
+ return;
1235
+ }
1236
+ setNotice("verification", {
1237
+ kind: "error",
1238
+ text: fallbackText || t("stillWaitingVerification"),
1239
+ });
1240
+ }
1241
+ catch {
1242
+ setNotice("verification", {
1243
+ kind: "error",
1244
+ text: t("checkVerificationFailed"),
1245
+ });
1246
+ }
1247
+ finally {
1248
+ verificationCheckInFlight.current = false;
1249
+ }
1250
+ }, [
1251
+ apiPath,
1252
+ pendingEmailStorageKey,
1253
+ readPendingSignupEmail,
1254
+ redirectToSignedInApp,
1255
+ setNotice,
1256
+ t,
1257
+ tryPendingSignupLogin,
1258
+ verificationEmail,
1259
+ ]);
1260
+ React.useEffect(() => {
1261
+ if (!runtimeBasePathResolved ||
1262
+ googleOnly ||
1263
+ verifiedReturnHandled.current) {
1264
+ return;
1265
+ }
1266
+ const params = new URLSearchParams(window.location.search);
1267
+ if (params.get("verified") !== "1")
1268
+ return;
1269
+ verifiedReturnHandled.current = true;
1270
+ setNotice("login", {
1271
+ kind: "success",
1272
+ text: t("emailVerifiedFinishing"),
1273
+ });
1274
+ void checkVerification(t("emailVerifiedSignIn"));
1275
+ }, [checkVerification, googleOnly, runtimeBasePathResolved, setNotice, t]);
1276
+ React.useEffect(() => {
1277
+ if (view !== "verification")
1278
+ return;
1279
+ const onFocus = () => void checkVerification();
1280
+ window.addEventListener("focus", onFocus);
1281
+ document.addEventListener("visibilitychange", onFocus);
1282
+ return () => {
1283
+ window.removeEventListener("focus", onFocus);
1284
+ document.removeEventListener("visibilitychange", onFocus);
1285
+ };
1286
+ }, [checkVerification, view]);
1287
+ React.useEffect(() => {
1288
+ if (!verificationResendUntil)
1289
+ return;
1290
+ const timer = window.setInterval(() => {
1291
+ if (Date.now() >= verificationResendUntil)
1292
+ setVerificationResendUntil(0);
1293
+ }, 1000);
1294
+ return () => window.clearInterval(timer);
1295
+ }, [verificationResendUntil]);
1296
+ const handleSignup = React.useCallback(async (event) => {
1297
+ event.preventDefault();
1298
+ const email = normalizeEmail(signupEmail);
1299
+ if (!isValidEmail(email)) {
1300
+ setNotice("signup", { kind: "error", text: t("invalidEmail") });
1301
+ return;
1302
+ }
1303
+ if (signupPassword !== signupPasswordConfirmation) {
1304
+ setNotice("signup", { kind: "error", text: t("passwordsMismatch") });
1305
+ return;
1306
+ }
1307
+ setSubmitting("signup");
1308
+ setNotice("signup", null);
1309
+ trackAuth(trackingApp, "auth.signup_clicked", {
1310
+ surface: "signup",
1311
+ method: "password",
1312
+ auth_view: view,
1313
+ });
1314
+ try {
1315
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/register"), {
1316
+ method: "POST",
1317
+ headers: { "Content-Type": "application/json" },
1318
+ body: JSON.stringify({
1319
+ email,
1320
+ password: signupPassword,
1321
+ callbackURL: resumeHref(),
1322
+ }),
1323
+ });
1324
+ if (!response.ok) {
1325
+ setNotice("signup", {
1326
+ kind: "error",
1327
+ text: authErrorText(data, t("registrationFailed")),
1328
+ });
1329
+ return;
1330
+ }
1331
+ const loginResult = await requestJson(apiPath("/_agent-native/auth/login"), {
1332
+ method: "POST",
1333
+ headers: { "Content-Type": "application/json" },
1334
+ body: JSON.stringify({ email, password: signupPassword }),
1335
+ });
1336
+ if (loginResult.response.ok) {
1337
+ removeStorage(pendingEmailStorageKey());
1338
+ setNotice("signup", {
1339
+ kind: "success",
1340
+ text: t("accountCreatedSigningIn"),
1341
+ });
1342
+ redirectToSignedInApp();
1343
+ return;
1344
+ }
1345
+ const loginError = authErrorText(loginResult.data, t("registrationFailed"));
1346
+ if (loginResult.response.status === 403 &&
1347
+ /not verified|verification/i.test(loginError)) {
1348
+ showVerificationStep(email, signupPassword);
1349
+ return;
1350
+ }
1351
+ setNotice("signup", { kind: "error", text: loginError });
1352
+ }
1353
+ catch {
1354
+ setNotice("signup", {
1355
+ kind: "error",
1356
+ text: t("networkErrorDashRetry"),
1357
+ });
1358
+ }
1359
+ finally {
1360
+ setSubmitting(null);
1361
+ }
1362
+ }, [
1363
+ apiPath,
1364
+ pendingEmailStorageKey,
1365
+ redirectToSignedInApp,
1366
+ resumeHref,
1367
+ setNotice,
1368
+ showVerificationStep,
1369
+ signupEmail,
1370
+ signupPassword,
1371
+ signupPasswordConfirmation,
1372
+ t,
1373
+ trackingApp,
1374
+ view,
1375
+ ]);
1376
+ const handleLogin = React.useCallback(async (event) => {
1377
+ event.preventDefault();
1378
+ const email = normalizeEmail(loginEmail);
1379
+ if (!isValidEmail(email)) {
1380
+ setNotice("login", { kind: "error", text: t("invalidEmail") });
1381
+ return;
1382
+ }
1383
+ setSubmitting("login");
1384
+ setNotice("login", null);
1385
+ trackAuth(trackingApp, "auth.login_clicked", {
1386
+ surface: "login",
1387
+ method: "password",
1388
+ auth_view: view,
1389
+ });
1390
+ try {
1391
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/login"), {
1392
+ method: "POST",
1393
+ headers: { "Content-Type": "application/json" },
1394
+ body: JSON.stringify({ email, password: loginPassword }),
1395
+ });
1396
+ if (response.ok) {
1397
+ removeStorage(pendingEmailStorageKey());
1398
+ redirectToSignedInApp();
1399
+ return;
1400
+ }
1401
+ setNotice("login", {
1402
+ kind: "error",
1403
+ text: authErrorText(data, t("invalidLogin")),
1404
+ });
1405
+ }
1406
+ catch {
1407
+ setNotice("login", { kind: "error", text: t("networkErrorDashRetry") });
1408
+ }
1409
+ finally {
1410
+ setSubmitting(null);
1411
+ }
1412
+ }, [
1413
+ apiPath,
1414
+ loginEmail,
1415
+ loginPassword,
1416
+ pendingEmailStorageKey,
1417
+ redirectToSignedInApp,
1418
+ setNotice,
1419
+ t,
1420
+ trackingApp,
1421
+ view,
1422
+ ]);
1423
+ const handleForgot = React.useCallback(async (event) => {
1424
+ event.preventDefault();
1425
+ const email = normalizeEmail(forgotEmail);
1426
+ if (!isValidEmail(email)) {
1427
+ setNotice("forgot", { kind: "error", text: t("invalidEmail") });
1428
+ return;
1429
+ }
1430
+ setSubmitting("forgot");
1431
+ setNotice("forgot", null);
1432
+ try {
1433
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/ba/request-password-reset"), {
1434
+ method: "POST",
1435
+ headers: { "Content-Type": "application/json" },
1436
+ body: JSON.stringify({ email }),
1437
+ });
1438
+ if (response.ok) {
1439
+ setForgotSent(true);
1440
+ setNotice("forgot", { kind: "success", text: t("resetEmailSent") });
1441
+ return;
1442
+ }
1443
+ setNotice("forgot", {
1444
+ kind: "error",
1445
+ text: authErrorText(data, t("resetEmailFailed")),
1446
+ });
1447
+ }
1448
+ catch {
1449
+ setNotice("forgot", {
1450
+ kind: "error",
1451
+ text: t("networkErrorDashRetry"),
1452
+ });
1453
+ }
1454
+ finally {
1455
+ setSubmitting(null);
1456
+ }
1457
+ }, [apiPath, forgotEmail, setNotice, t]);
1458
+ const handleMagicLink = React.useCallback(async (event) => {
1459
+ event.preventDefault();
1460
+ const email = normalizeEmail(magicLinkEmail);
1461
+ if (!isValidEmail(email)) {
1462
+ setNotice("magic-link", { kind: "error", text: t("invalidEmail") });
1463
+ return;
1464
+ }
1465
+ setMagicLinkBusy(true);
1466
+ setNotice("magic-link", null);
1467
+ trackAuth(trackingApp, "auth.signup_clicked", {
1468
+ surface: "signup",
1469
+ method: "magic_link",
1470
+ auth_view: view,
1471
+ });
1472
+ const desktop = isAgentNativeDesktop();
1473
+ try {
1474
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/magic-link"), {
1475
+ method: "POST",
1476
+ headers: { "Content-Type": "application/json" },
1477
+ body: JSON.stringify({
1478
+ email,
1479
+ callbackURL: desktop
1480
+ ? apiPath("/_agent-native/auth/magic-link/desktop-callback")
1481
+ : resumeHref(),
1482
+ }),
1483
+ });
1484
+ if (!response.ok) {
1485
+ setNotice("magic-link", {
1486
+ kind: "error",
1487
+ text: authErrorText(data, t("magicLinkFailed")),
1488
+ });
1489
+ return;
1490
+ }
1491
+ setMagicLinkEmail(email);
1492
+ setView("magicLinkSent");
1493
+ if (desktop &&
1494
+ typeof data.flowId === "string" &&
1495
+ typeof data.verifier === "string") {
1496
+ oauthFlowId.current = data.flowId;
1497
+ startOAuthExchange(data.flowId, resumeHref(), data.verifier, "magic-link");
1498
+ }
1499
+ }
1500
+ catch {
1501
+ setNotice("magic-link", {
1502
+ kind: "error",
1503
+ text: t("networkErrorDashRetry"),
1504
+ });
1505
+ }
1506
+ finally {
1507
+ setMagicLinkBusy(false);
1508
+ }
1509
+ }, [
1510
+ apiPath,
1511
+ magicLinkEmail,
1512
+ resumeHref,
1513
+ setNotice,
1514
+ startOAuthExchange,
1515
+ t,
1516
+ trackingApp,
1517
+ view,
1518
+ ]);
1519
+ const resendVerification = React.useCallback(async () => {
1520
+ const email = verificationEmail || readPendingSignupEmail();
1521
+ if (!email || verificationResendUntil > Date.now())
1522
+ return;
1523
+ setNotice("verification", null);
1524
+ try {
1525
+ const { response, data } = await requestJson(apiPath("/_agent-native/auth/ba/send-verification-email"), {
1526
+ method: "POST",
1527
+ headers: { "Content-Type": "application/json" },
1528
+ body: JSON.stringify({ email, callbackURL: resumeHref() }),
1529
+ });
1530
+ if (response.ok) {
1531
+ setVerificationResendUntil(Date.now() + 60_000);
1532
+ setNotice("verification", {
1533
+ kind: "success",
1534
+ text: t("sentVerification"),
1535
+ });
1536
+ return;
1537
+ }
1538
+ setNotice("verification", {
1539
+ kind: "error",
1540
+ text: authErrorText(data, t("resendVerificationFailed")),
1541
+ });
1542
+ }
1543
+ catch {
1544
+ setNotice("verification", {
1545
+ kind: "error",
1546
+ text: t("networkErrorRetry"),
1547
+ });
1548
+ }
1549
+ }, [
1550
+ apiPath,
1551
+ readPendingSignupEmail,
1552
+ resumeHref,
1553
+ setNotice,
1554
+ t,
1555
+ verificationEmail,
1556
+ verificationResendUntil,
1557
+ ]);
1558
+ const selectLocale = React.useCallback((preference) => {
1559
+ const nextLocale = preference === "system"
1560
+ ? resolveSystemLocale(localeOptions, defaultLocale)
1561
+ : resolveLocale(preference, localeOptions, defaultLocale);
1562
+ writeStorage(localeStorageKey, preference);
1563
+ setLocalePreference(preference);
1564
+ setLocale(nextLocale);
1565
+ setLocaleMenuOpen(false);
1566
+ }, [defaultLocale, localeOptions, localeStorageKey]);
1567
+ const handlePasswordInvalid = React.useCallback((event) => {
1568
+ const input = event.currentTarget;
1569
+ if (input.validity.tooShort)
1570
+ input.setCustomValidity(t("passwordMinPlaceholder"));
1571
+ else if (input.validity.tooLong)
1572
+ input.setCustomValidity(props.passwordMaxCopy);
1573
+ }, [props.passwordMaxCopy, t]);
1574
+ const clearPasswordValidity = React.useCallback((event) => event.currentTarget.setCustomValidity(""), []);
1575
+ const copySignupLocalMode = React.useCallback(async () => {
1576
+ if (!signupLocalModeNote)
1577
+ return;
1578
+ try {
1579
+ await navigator.clipboard?.writeText(signupLocalModeNote.command);
1580
+ setCopiedLocalMode(true);
1581
+ window.setTimeout(() => setCopiedLocalMode(false), 1600);
1582
+ }
1583
+ catch {
1584
+ // coercion-ok: clipboard permission is optional.
1585
+ }
1586
+ }, [signupLocalModeNote]);
1587
+ const keys = headingKeys(view);
1588
+ const marketingCopy = marketing
1589
+ ? { ...marketing, ...(marketingLocales[locale] ?? {}) }
1590
+ : undefined;
1591
+ const cardClassName = [
1592
+ "card",
1593
+ view === "verification" ? "verifying" : "",
1594
+ view === "magicLinkSent" ? "magic-link-complete" : "",
1595
+ ]
1596
+ .filter(Boolean)
1597
+ .join(" ");
1598
+ const localModeNote = signupLocalModeNote ? (React.createElement("div", { className: "signup-local-mode-note", id: "signup-local-mode-note", "data-command": signupLocalModeNote.command },
1599
+ React.createElement("p", null, signupLocalModeNote.text),
1600
+ React.createElement("code", null, signupLocalModeNote.command),
1601
+ React.createElement("button", { type: "button", className: "copy-run-local", id: "copy-signup-local-mode", "data-copy-signup-local-mode": "true", "data-i18n": "copyCommand", onClick: () => void copySignupLocalMode() }, copiedLocalMode ? t("copied") : t("copyCommand")))) : null;
1602
+ const legalNote = signupLegalNotice ? (React.createElement("p", { className: "legal-note" },
1603
+ React.createElement("span", { "data-i18n": "legalPrefix" }, signupLegalNotice.prefix ?? t("legalPrefix")),
1604
+ " ",
1605
+ React.createElement("a", { href: signupLegalNotice.termsUrl, target: "_blank", rel: "noreferrer", "data-i18n": signupLegalNotice.termsLabel ? undefined : "legalTerms" }, signupLegalNotice.termsLabel ?? t("legalTerms")),
1606
+ " ",
1607
+ React.createElement("span", { "data-i18n": "legalConnector" }, signupLegalNotice.connector ?? t("legalConnector")),
1608
+ " ",
1609
+ React.createElement("a", { href: signupLegalNotice.privacyUrl, target: "_blank", rel: "noreferrer", "data-i18n": signupLegalNotice.privacyLabel ? undefined : "legalPrivacy" }, signupLegalNotice.privacyLabel ?? t("legalPrivacy")),
1610
+ React.createElement("span", { "data-i18n": "legalSuffix" }, signupLegalNotice.suffix ?? t("legalSuffix")))) : null;
1611
+ const signupForm = (React.createElement(AuthForm, { id: "signup-form", className: view === "signup" ? "active" : undefined, onSubmit: handleSignup, fields: [
1612
+ {
1613
+ id: "s-email",
1614
+ label: t("email"),
1615
+ labelProps: { "data-i18n": "email" },
1616
+ inputProps: {
1617
+ type: "email",
1618
+ autoComplete: "email",
1619
+ placeholder: t("emailPlaceholder"),
1620
+ required: true,
1621
+ value: signupEmail,
1622
+ onChange: (event) => setSignupEmail(event.currentTarget.value),
1623
+ },
1624
+ },
1625
+ {
1626
+ id: "s-pass",
1627
+ label: t("password"),
1628
+ labelProps: { "data-i18n": "password" },
1629
+ inputProps: {
1630
+ type: "password",
1631
+ autoComplete: "new-password",
1632
+ placeholder: t("passwordMinPlaceholder"),
1633
+ "data-i18n-placeholder": "passwordMinPlaceholder",
1634
+ required: true,
1635
+ minLength: props.passwordMinLength,
1636
+ maxLength: props.passwordMaxLength,
1637
+ value: signupPassword,
1638
+ onChange: (event) => setSignupPassword(event.currentTarget.value),
1639
+ onInvalid: handlePasswordInvalid,
1640
+ onInput: clearPasswordValidity,
1641
+ },
1642
+ },
1643
+ {
1644
+ id: "s-pass2",
1645
+ label: t("confirmPassword"),
1646
+ labelProps: { "data-i18n": "confirmPassword" },
1647
+ inputProps: {
1648
+ type: "password",
1649
+ autoComplete: "new-password",
1650
+ placeholder: t("confirmPasswordPlaceholder"),
1651
+ "data-i18n-placeholder": "confirmPasswordPlaceholder",
1652
+ required: true,
1653
+ minLength: props.passwordMinLength,
1654
+ maxLength: props.passwordMaxLength,
1655
+ value: signupPasswordConfirmation,
1656
+ onChange: (event) => setSignupPasswordConfirmation(event.currentTarget.value),
1657
+ onInvalid: handlePasswordInvalid,
1658
+ onInput: clearPasswordValidity,
1659
+ },
1660
+ },
1661
+ ], submitLabel: t("createAccount"), submitProps: {
1662
+ "data-i18n": "createAccount",
1663
+ disabled: submitting === "signup",
1664
+ }, footer: React.createElement(React.Fragment, null,
1665
+ legalNote,
1666
+ localModeNote), messageId: "s-msg", messageClassName: `msg ${messages.signup ? `${messages.signup.kind} show` : ""}`, message: messages.signup?.text }));
1667
+ const identityHref = apiPath("/_agent-native/identity/login");
1668
+ const authCard = (React.createElement("div", { className: cardClassName },
1669
+ React.createElement("h1", { id: "heading", "data-i18n": keys.heading }, t(keys.heading)),
1670
+ React.createElement("p", { id: "subtitle", className: "subtitle", "data-i18n": keys.subtitle }, t(keys.subtitle)),
1671
+ React.createElement("p", { className: `upgrade-note ${upgradeVisible ? "show" : ""}`, id: "upgrade-note", "data-upgrade-copy": t("upgradeCopy"), "data-i18n-data-upgrade-copy": "upgradeCopy" }, upgradeVisible ? t("upgradeCopy") : null),
1672
+ identitySsoEnabled ? (React.createElement("a", { className: "btn-identity-sso", id: "identity-sso-btn", href: identityHref, onClick: (event) => {
1673
+ event.preventDefault();
1674
+ const params = new URLSearchParams({ return: resumeHref() });
1675
+ window.location.href = `${identityHref}?${params.toString()}`;
1676
+ } }, "Sign in with Agent-Native")) : null,
1677
+ React.createElement("div", { className: "local-dev-signin", id: "local-dev-signin", hidden: !localDevAvailable },
1678
+ React.createElement("button", { type: "button", className: "btn-local-dev btn-primary", id: "local-dev-btn", title: t("localDevDescription"), "data-i18n": "localDevButton", "data-i18n-title": "localDevDescription", "aria-describedby": "local-dev-description", disabled: localDevBusy, onClick: () => void handleLocalDev() }, localDevBusy ? t("localDevSigningIn") : t("localDevButton")),
1679
+ React.createElement("p", { className: "local-dev-description", id: "local-dev-description" },
1680
+ React.createElement("span", { "data-i18n": "localDevDescription" }, t("localDevDescription")),
1681
+ React.createElement("a", { className: "local-dev-help", id: "local-dev-help", href: docsAuthUrl, target: "_blank", rel: "noreferrer", "aria-label": t("localDevHelp"), title: t("localDevHelp"), "data-i18n-title": "localDevHelp", "data-i18n-aria-label": "localDevHelp" },
1682
+ React.createElement("span", { className: "local-dev-help-glyph", "aria-hidden": "true" }, "?"))),
1683
+ React.createElement("button", { type: "button", className: "local-dev-full-options", id: "local-dev-full-options", hidden: fullAuthOptionsVisible, "data-i18n": "localDevFullOptions", onClick: () => setFullAuthOptionsVisible(true) }, t("localDevFullOptions")),
1684
+ notice("local-dev")),
1685
+ React.createElement("div", { id: "full-auth-options", className: "full-auth-options", hidden: !fullAuthOptionsVisible },
1686
+ googleOnly && !showGoogle ? (React.createElement("p", { className: "google-error show", id: "google-err", role: "status", "data-i18n": "googleNotConfigured" }, t("googleNotConfigured"))) : null,
1687
+ showGoogle ? (React.createElement("div", { className: "google-signin", id: "google-signin" },
1688
+ React.createElement("button", { className: `btn-google ${view === "magicLink" && isValidEmail(magicLinkEmail) ? "magic-link-secondary" : ""}`, id: "google-btn", type: "button", disabled: googleBusy, onClick: () => void startGoogle() },
1689
+ googleSvg(),
1690
+ React.createElement("span", { "data-i18n": "googleButton" }, t("googleButton"))),
1691
+ notice("google"),
1692
+ React.createElement("p", { className: "google-debug", id: "google-debug" }))) : null,
1693
+ !googleOnly && showGoogle ? (React.createElement("div", { className: "divider", id: "auth-divider", "data-i18n": "dividerOr" }, t("dividerOr"))) : null,
1694
+ !googleOnly && authMode === "magic-link" ? (React.createElement("form", { id: "magic-link-form", className: `form ${view === "magicLink" ? "active" : ""}`, onSubmit: handleMagicLink },
1695
+ React.createElement("label", { htmlFor: "m-email", "data-i18n": "email" }, t("email")),
1696
+ React.createElement("input", { id: "m-email", type: "email", autoComplete: "email", placeholder: t("emailPlaceholder"), required: true, value: magicLinkEmail, onChange: (event) => setMagicLinkEmail(event.currentTarget.value) }),
1697
+ React.createElement("button", { type: "submit", id: "magic-link-submit", className: "magic-link-submit", disabled: magicLinkBusy || !isValidEmail(magicLinkEmail), "data-i18n": "sendMagicLink" }, magicLinkBusy ? t("sending") : t("sendMagicLink")),
1698
+ notice("magic-link"),
1699
+ legalNote,
1700
+ React.createElement("p", { style: {
1701
+ marginTop: "0.75rem",
1702
+ fontSize: "0.75rem",
1703
+ textAlign: "start",
1704
+ } },
1705
+ React.createElement("button", { type: "button", className: "link-button auth-mode-link", id: "use-password-link", "data-i18n": "usePasswordInstead", onClick: () => setView("login") }, t("usePasswordInstead"))))) : null,
1706
+ authMode === "magic-link" ? (React.createElement("div", { className: `magic-link-success ${view === "magicLinkSent" ? "is-visible" : ""}`, id: "magic-link-success", "aria-live": "polite", hidden: view !== "magicLinkSent" },
1707
+ React.createElement("p", { className: "magic-link-success-copy" },
1708
+ React.createElement("span", { "data-i18n": "magicLinkSentCopy" }, t("magicLinkSentCopy")),
1709
+ " ",
1710
+ React.createElement("strong", { id: "magic-link-success-email" }, magicLinkEmail),
1711
+ "."),
1712
+ React.createElement("button", { type: "button", className: "link-button magic-link-back", id: "magic-link-back", "data-i18n": "back", onClick: () => {
1713
+ setMagicLinkEmail("");
1714
+ setView("magicLink");
1715
+ } }, t("back")))) : null,
1716
+ !googleOnly ? (React.createElement("div", { className: "tabs", id: "auth-tabs", hidden: view === "magicLink" || view === "magicLinkSent" },
1717
+ React.createElement("button", { className: `tab ${view === "signup" ? "active" : ""}`, type: "button", "data-tab": "signup", "data-i18n": "createAccount", onClick: () => {
1718
+ setView("signup");
1719
+ writeStorage(TAB_STORAGE_KEY, "signup");
1720
+ } }, t("createAccount")),
1721
+ React.createElement("button", { className: `tab ${view === "login" || view === "forgot" ? "active" : ""}`, type: "button", "data-tab": "login", "data-i18n": "signIn", onClick: () => {
1722
+ setView("login");
1723
+ writeStorage(TAB_STORAGE_KEY, "login");
1724
+ } }, t("signIn")))) : null,
1725
+ !googleOnly ? signupForm : null,
1726
+ React.createElement("div", { id: "verification-step", className: `form verification-step ${view === "verification" ? "active" : ""}`, "aria-live": "polite" },
1727
+ React.createElement("div", { className: "step-progress", "aria-label": t("signupProgress"), "data-i18n-aria-label": "signupProgress" },
1728
+ React.createElement("div", { className: "progress-step complete" },
1729
+ React.createElement("span", null, "1"),
1730
+ React.createElement("strong", { "data-i18n": "progressAccount" }, t("progressAccount"))),
1731
+ React.createElement("div", { className: "progress-step current" },
1732
+ React.createElement("span", null, "2"),
1733
+ React.createElement("strong", { "data-i18n": "progressVerify" }, t("progressVerify"))),
1734
+ React.createElement("div", { className: "progress-step" },
1735
+ React.createElement("span", null, "3"),
1736
+ React.createElement("strong", { "data-i18n": "progressStart" }, t("progressStart")))),
1737
+ React.createElement("div", { className: "verification-panel" },
1738
+ React.createElement("p", { className: "verification-kicker", "data-i18n": "verificationSent" }, t("verificationSent")),
1739
+ React.createElement("p", { className: "verification-copy" },
1740
+ React.createElement("span", { "data-i18n": "verifyCopyPrefix" }, t("verifyCopyPrefix")),
1741
+ " ",
1742
+ React.createElement("strong", { id: "verify-email" }, verificationEmail),
1743
+ React.createElement("span", { "data-i18n": "verifyCopySuffix" }, t("verifyCopySuffix"))),
1744
+ React.createElement("p", { className: "verification-note", "data-i18n": "verificationNote" }, t("verificationNote"))),
1745
+ React.createElement("button", { type: "button", className: "btn-primary", id: "verify-continue", "data-i18n": "continue", onClick: () => void checkVerification() }, t("continue")),
1746
+ React.createElement("div", { className: "inline-actions" },
1747
+ React.createElement("button", { type: "button", className: "link-button", id: "resend-verification", disabled: verificationResendUntil > Date.now(), "data-i18n": "resendEmail", onClick: () => void resendVerification() },
1748
+ t("resendEmail"),
1749
+ verificationResendUntil > Date.now()
1750
+ ? ` (${Math.ceil((verificationResendUntil - Date.now()) / 1000)}s)`
1751
+ : ""),
1752
+ React.createElement("button", { type: "button", className: "link-button", id: "back-to-signup", "data-i18n": "back", onClick: () => {
1753
+ removeStorage(pendingEmailStorageKey());
1754
+ setView("signup");
1755
+ } }, t("back"))),
1756
+ notice("verification")),
1757
+ React.createElement("form", { id: "login-form", className: `form ${view === "login" ? "active" : ""}`, onSubmit: handleLogin },
1758
+ React.createElement("label", { htmlFor: "l-email", "data-i18n": "email" }, t("email")),
1759
+ React.createElement("input", { id: "l-email", type: "email", autoComplete: "email", placeholder: t("emailPlaceholder"), required: true, value: loginEmail, onChange: (event) => setLoginEmail(event.currentTarget.value) }),
1760
+ React.createElement("label", { htmlFor: "l-pass", "data-i18n": "password" }, t("password")),
1761
+ React.createElement("input", { id: "l-pass", type: "password", autoComplete: "current-password", placeholder: t("enterPasswordPlaceholder"), "data-i18n-placeholder": "enterPasswordPlaceholder", required: true, value: loginPassword, onChange: (event) => setLoginPassword(event.currentTarget.value), onInvalid: handlePasswordInvalid, onInput: clearPasswordValidity }),
1762
+ React.createElement("button", { type: "submit", "data-i18n": "signIn", disabled: submitting === "login" }, submitting === "login" ? t("signingIn") : t("signIn")),
1763
+ notice("login"),
1764
+ React.createElement("p", { style: {
1765
+ marginTop: "0.75rem",
1766
+ fontSize: "0.75rem",
1767
+ textAlign: "right",
1768
+ } },
1769
+ React.createElement("button", { type: "button", id: "forgot-link", className: "link-button", "data-i18n": "forgotPassword", onClick: () => {
1770
+ setForgotEmail(loginEmail);
1771
+ setView("forgot");
1772
+ } }, t("forgotPassword"))),
1773
+ authMode === "magic-link" ? (React.createElement("p", { style: {
1774
+ marginTop: "0.5rem",
1775
+ fontSize: "0.75rem",
1776
+ textAlign: "center",
1777
+ } },
1778
+ React.createElement("button", { type: "button", className: "link-button", id: "back-to-magic-link", "data-i18n": "backToMagicLink", onClick: () => setView("magicLink") }, t("backToMagicLink")))) : null),
1779
+ React.createElement("form", { id: "forgot-form", className: `form ${view === "forgot" ? "active" : ""}`, onSubmit: handleForgot },
1780
+ React.createElement("label", { htmlFor: "f-email", "data-i18n": "email" }, t("email")),
1781
+ React.createElement("input", { id: "f-email", type: "email", autoComplete: "email", placeholder: t("emailPlaceholder"), required: true, value: forgotEmail, onChange: (event) => setForgotEmail(event.currentTarget.value) }),
1782
+ React.createElement("button", { type: "submit", "data-i18n": "sendResetLink", disabled: forgotSent || submitting === "forgot" }, forgotSent
1783
+ ? t("sent")
1784
+ : submitting === "forgot"
1785
+ ? t("sending")
1786
+ : t("sendResetLink")),
1787
+ notice("forgot"),
1788
+ React.createElement("p", { style: {
1789
+ marginTop: "0.75rem",
1790
+ fontSize: "0.75rem",
1791
+ textAlign: "center",
1792
+ } },
1793
+ React.createElement("button", { type: "button", className: "link-button", id: "back-to-login", "data-i18n": "backToSignIn", onClick: () => setView("login") }, t("backToSignIn")))))));
1794
+ const localNote = (React.createElement("p", { className: `local-note ${localNoteVisible ? "show" : ""}`, id: "local-note" },
1795
+ React.createElement("span", { "data-i18n": "localNotePrefix" }, t("localNotePrefix")),
1796
+ " (",
1797
+ React.createElement("strong", null, connectionLabel),
1798
+ ")",
1799
+ React.createElement("span", { "data-i18n": "localNoteSuffix" }, t("localNoteSuffix"))));
1800
+ const localePicker = (React.createElement("div", { className: "locale-picker" },
1801
+ React.createElement("button", { type: "button", className: "locale-trigger", id: "auth-locale-trigger", "aria-haspopup": "menu", "aria-expanded": localeMenuOpen, "aria-controls": "auth-locale-menu", "aria-label": t("languageLabel"), title: t("languageLabel"), "data-i18n-aria-label": "languageLabel", "data-i18n-title": "languageLabel", onClick: () => setLocaleMenuOpen((open) => !open) },
1802
+ React.createElement("svg", { viewBox: "0 0 24 24", "aria-hidden": "true" },
1803
+ React.createElement("path", { d: "M4 5h7" }),
1804
+ React.createElement("path", { d: "M7.5 4v1" }),
1805
+ React.createElement("path", { d: "M9.5 5c-.8 4.4-2.6 7.2-5.5 9" }),
1806
+ React.createElement("path", { d: "M5 9c1.2 2.1 3.2 3.8 6 5" }),
1807
+ React.createElement("path", { d: "M13 20l4-9 4 9" }),
1808
+ React.createElement("path", { d: "M14.5 17h5" }))),
1809
+ React.createElement("div", { className: "locale-menu", id: "auth-locale-menu", role: "menu", "aria-labelledby": "auth-locale-trigger", hidden: !localeMenuOpen },
1810
+ React.createElement("button", { type: "button", className: "locale-menu-item", role: "menuitemradio", "aria-checked": localePreference === "system", "data-locale-value": "system", onClick: () => selectLocale("system") },
1811
+ React.createElement("span", { className: "locale-menu-check", "aria-hidden": "true" }, "\u2713"),
1812
+ React.createElement("span", { "data-system-language": true }, t("systemLanguage"))),
1813
+ localeOptions.map((option) => (React.createElement("button", { type: "button", className: "locale-menu-item", role: "menuitemradio", "aria-checked": localePreference === option.value, "data-locale-value": option.value, key: option.value, onClick: () => selectLocale(option.value) },
1814
+ React.createElement("span", { className: "locale-menu-check", "aria-hidden": "true" }, "\u2713"),
1815
+ React.createElement("span", null, option.label)))))));
1816
+ const environmentBadge = (React.createElement("div", { className: "environment-switcher", id: "environment-switcher", hidden: !environmentVisible },
1817
+ React.createElement("button", { type: "button", className: "environment-badge", id: "environment-badge", "aria-expanded": environmentOpen, "aria-controls": "environment-popover", onClick: () => setEnvironmentOpen((open) => !open) }, "beta"),
1818
+ React.createElement("div", { className: "environment-popover", id: "environment-popover", role: "dialog", "aria-labelledby": "environment-popover-title", hidden: !environmentOpen },
1819
+ React.createElement("div", { className: "environment-popover-title", id: "environment-popover-title" }, "You're on Agent-Native Beta"),
1820
+ React.createElement("div", { className: "environment-popover-copy" }, "Choose where you want to continue."),
1821
+ React.createElement("a", { className: "environment-production-link", id: "environment-production-link", href: environmentProductionUrl }, "Switch to production"),
1822
+ React.createElement("button", { type: "button", className: "environment-hide-badge", id: "environment-hide-badge", onClick: () => {
1823
+ setEnvironmentOpen(false);
1824
+ setEnvironmentVisible(false);
1825
+ } }, "Hide badge"))));
1826
+ const marketingSurface = marketingCopy ? (React.createElement(MarketingHome, { appName: marketingCopy.appName, variant: "auth", background: React.createElement(Starfield, { id: "starfield" }), auth: React.createElement(React.Fragment, null,
1827
+ authCard,
1828
+ localNote), className: "auth-marketing-home" },
1829
+ React.createElement("div", { className: "marketing-content" },
1830
+ React.createElement("h2", { className: "app-name" },
1831
+ React.createElement("img", { className: "brand-mark", src: brandMarkSrc, alt: "", "aria-hidden": "true" }),
1832
+ React.createElement("span", null, marketingCopy.appName)),
1833
+ React.createElement("p", { className: "app-tagline", "data-marketing-field": "tagline" }, marketingCopy.tagline),
1834
+ marketingCopy.description ? (React.createElement("p", { className: "app-desc", "data-marketing-field": "description" }, marketingCopy.description)) : null,
1835
+ marketingCopy.features?.length ? (React.createElement("ul", { className: "feature-list" }, marketingCopy.features.map((feature, index) => (React.createElement("li", { key: index, "data-marketing-feature-index": index }, feature))))) : null,
1836
+ React.createElement("div", { className: "marketing-actions" },
1837
+ React.createElement("a", { className: "oss-link", href: githubUrl, target: "_blank", rel: "noreferrer" },
1838
+ React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
1839
+ React.createElement("path", { d: "M9 19c-4.3 1.4-4.3-2.5-6-3m12 5v-3.5c0-1 .1-1.4-.5-2 2.8-.3 5.5-1.4 5.5-6a4.6 4.6 0 00-1.3-3.2 4.2 4.2 0 00-.1-3.2s-1.1-.3-3.5 1.3a12.3 12.3 0 00-6.2 0C6.5 2.8 5.4 3.1 5.4 3.1a4.2 4.2 0 00-.1 3.2A4.6 4.6 0 004 9.5c0 4.6 2.7 5.7 5.5 6-.6.6-.6 1.2-.5 2V21" })),
1840
+ React.createElement("span", { "data-i18n": "openSource" }, t("openSource"))))))) : (React.createElement(React.Fragment, null,
1841
+ React.createElement("div", { className: "auth-centered" }, authCard),
1842
+ localNote));
1843
+ return (React.createElement(React.Fragment, null,
1844
+ localePicker,
1845
+ environmentBadge,
1846
+ initialPrompt ? (React.createElement("div", { className: "auth-centered" }, authCard)) : (marketingSurface)));
1847
+ }