@agent-native/core 0.118.0 → 0.118.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +21 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/a2a/client.ts +32 -10
  5. package/corpus/core/src/cli/index.ts +18 -10
  6. package/corpus/core/src/cli/multi-frontier-runs.ts +5 -3
  7. package/corpus/core/src/cli/templates-meta.ts +0 -12
  8. package/corpus/core/src/cli/workspace-dev.ts +1 -1
  9. package/corpus/core/src/client/AgentPanel.tsx +9 -1
  10. package/corpus/core/src/client/RunStuckBanner.tsx +39 -47
  11. package/corpus/core/src/client/chat/action-chat-ui-surface.tsx +32 -0
  12. package/corpus/core/src/client/chat/message-components.tsx +53 -8
  13. package/corpus/core/src/client/chat/tool-call-display.tsx +24 -9
  14. package/corpus/core/src/client/chat/widgets/InlineExtensionWidget.tsx +0 -1
  15. package/corpus/core/src/client/chat/widgets/builtin-tool-renderers.tsx +7 -3
  16. package/corpus/core/src/client/conversation/AgentConversation.tsx +12 -1
  17. package/corpus/core/src/client/error-capture.ts +2 -6
  18. package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +20 -14
  19. package/corpus/core/src/client/resources/ResourcesPanel.tsx +5 -1
  20. package/corpus/core/src/client/resources/mcp-integration-catalog.ts +7 -17
  21. package/corpus/core/src/client/resources/mcp-integration-logos.ts +2 -2
  22. package/corpus/core/src/client/route-chunk-recovery.ts +5 -3
  23. package/corpus/core/src/client/session-replay.ts +3 -3
  24. package/corpus/core/src/client/settings/SettingsPanel.tsx +15 -6
  25. package/corpus/core/src/client/transcription/use-live-transcription.ts +64 -45
  26. package/corpus/core/src/deploy/build.ts +2 -1
  27. package/corpus/core/src/guards/db-tool-scoping.ts +1 -1
  28. package/corpus/core/src/integrations/adapters/slack.ts +84 -5
  29. package/corpus/core/src/integrations/index.ts +5 -1
  30. package/corpus/core/src/localization/default-messages.ts +1 -1
  31. package/corpus/core/src/mcp-client/oauth-routes.ts +45 -12
  32. package/corpus/core/src/server/realtime-voice.ts +4 -1
  33. package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
  34. package/corpus/core/src/terminal/cli-registry.ts +1 -1
  35. package/corpus/core/src/vite/client.ts +166 -1
  36. package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +13 -1
  37. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +10 -0
  38. package/corpus/templates/analytics/changelog/2026-07-22-show-a-useful-error-when-saving-a-dashboard-view-fails.md +6 -0
  39. package/corpus/templates/brain/app/routes/sources.tsx +181 -114
  40. package/corpus/templates/clips/AGENTS.md +8 -6
  41. package/corpus/templates/clips/actions/request-transcript.ts +90 -420
  42. package/corpus/templates/clips/actions/save-browser-transcript.ts +11 -28
  43. package/corpus/templates/clips/app/components/capture-install-options.tsx +5 -3
  44. package/corpus/templates/clips/app/components/player/transcript-panel.tsx +3 -136
  45. package/corpus/templates/clips/app/lib/capture-install-options.ts +15 -4
  46. package/corpus/templates/clips/app/routes/download.tsx +3 -2
  47. package/corpus/templates/clips/changelog/2026-07-22-fixed-an-intermittent-hydration-error-on-the-download-page.md +6 -0
  48. package/corpus/templates/clips/changelog/2026-07-22-fixed-transcript-generation-when-native-speech-capture-retur.md +6 -0
  49. package/corpus/templates/clips/changelog/2026-07-22-transcript-generation-now-retries-with-backup-speech-recogni.md +6 -0
  50. package/corpus/templates/clips/server/lib/public-agent-context.ts +2 -2
  51. package/corpus/templates/clips/server/register-secrets.ts +7 -6
  52. package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +16 -84
  53. package/corpus/templates/content/app/components/editor/VisualEditor.tsx +13 -7
  54. package/corpus/templates/content/app/components/editor/extensions/ImageBlock.tsx +2 -2
  55. package/corpus/templates/content/app/i18n-data.ts +10 -0
  56. package/corpus/templates/design/server/lib/fig-file-decoder.ts +1 -0
  57. package/corpus/templates/plan/app/entry.client.tsx +3 -0
  58. package/corpus/templates/plan/changelog/2026-07-22-recover-stale-pages-after-a-deployment-refresh-automatically.md +6 -0
  59. package/corpus/templates/slides/app/hooks/use-agent-generating.ts +10 -3
  60. package/corpus/templates/slides/app/pages/Index.tsx +1 -0
  61. package/corpus/templates/slides/changelog/2026-07-22-new-deck-prompts-now-open-in-their-own-visible-chat-thread.md +6 -0
  62. package/corpus/toolkit/CHANGELOG.md +9 -0
  63. package/corpus/toolkit/package.json +1 -1
  64. package/corpus/toolkit/src/composer/PromptComposer.tsx +5 -1
  65. package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +119 -31
  66. package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +30 -0
  67. package/corpus/toolkit/src/conformance/runner.tsx +153 -1
  68. package/corpus/toolkit/src/editor/SharedRichEditor.tsx +13 -2
  69. package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +20 -0
  70. package/corpus/toolkit/src/editor/index.ts +2 -0
  71. package/corpus/toolkit/src/styles.css +52 -23
  72. package/dist/a2a/client.d.ts +3 -1
  73. package/dist/a2a/client.d.ts.map +1 -1
  74. package/dist/a2a/client.js +17 -12
  75. package/dist/a2a/client.js.map +1 -1
  76. package/dist/cli/index.js +18 -8
  77. package/dist/cli/index.js.map +1 -1
  78. package/dist/cli/multi-frontier-runs.js +3 -3
  79. package/dist/cli/multi-frontier-runs.js.map +1 -1
  80. package/dist/cli/templates-meta.d.ts.map +1 -1
  81. package/dist/cli/templates-meta.js +0 -12
  82. package/dist/cli/templates-meta.js.map +1 -1
  83. package/dist/cli/workspace-dev.js +1 -1
  84. package/dist/cli/workspace-dev.js.map +1 -1
  85. package/dist/client/AgentPanel.d.ts.map +1 -1
  86. package/dist/client/AgentPanel.js +4 -1
  87. package/dist/client/AgentPanel.js.map +1 -1
  88. package/dist/client/RunStuckBanner.d.ts +3 -5
  89. package/dist/client/RunStuckBanner.d.ts.map +1 -1
  90. package/dist/client/RunStuckBanner.js +17 -18
  91. package/dist/client/RunStuckBanner.js.map +1 -1
  92. package/dist/client/chat/action-chat-ui-surface.d.ts +8 -0
  93. package/dist/client/chat/action-chat-ui-surface.d.ts.map +1 -0
  94. package/dist/client/chat/action-chat-ui-surface.js +10 -0
  95. package/dist/client/chat/action-chat-ui-surface.js.map +1 -0
  96. package/dist/client/chat/message-components.d.ts +3 -0
  97. package/dist/client/chat/message-components.d.ts.map +1 -1
  98. package/dist/client/chat/message-components.js +40 -7
  99. package/dist/client/chat/message-components.js.map +1 -1
  100. package/dist/client/chat/tool-call-display.d.ts +3 -1
  101. package/dist/client/chat/tool-call-display.d.ts.map +1 -1
  102. package/dist/client/chat/tool-call-display.js +13 -9
  103. package/dist/client/chat/tool-call-display.js.map +1 -1
  104. package/dist/client/chat/widgets/InlineExtensionWidget.d.ts.map +1 -1
  105. package/dist/client/chat/widgets/InlineExtensionWidget.js +1 -1
  106. package/dist/client/chat/widgets/InlineExtensionWidget.js.map +1 -1
  107. package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
  108. package/dist/client/chat/widgets/builtin-tool-renderers.js +5 -3
  109. package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
  110. package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
  111. package/dist/client/conversation/AgentConversation.js +3 -2
  112. package/dist/client/conversation/AgentConversation.js.map +1 -1
  113. package/dist/client/error-capture.d.ts.map +1 -1
  114. package/dist/client/error-capture.js +2 -2
  115. package/dist/client/error-capture.js.map +1 -1
  116. package/dist/client/resources/McpConnectionSuggestion.d.ts +1 -0
  117. package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
  118. package/dist/client/resources/McpConnectionSuggestion.js +9 -8
  119. package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
  120. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  121. package/dist/client/resources/ResourcesPanel.js +3 -1
  122. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  123. package/dist/client/resources/mcp-integration-catalog.d.ts +1 -0
  124. package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
  125. package/dist/client/resources/mcp-integration-catalog.js +4 -17
  126. package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
  127. package/dist/client/resources/mcp-integration-logos.js +2 -2
  128. package/dist/client/resources/mcp-integration-logos.js.map +1 -1
  129. package/dist/client/route-chunk-recovery.d.ts.map +1 -1
  130. package/dist/client/route-chunk-recovery.js +5 -3
  131. package/dist/client/route-chunk-recovery.js.map +1 -1
  132. package/dist/client/session-replay.js +3 -3
  133. package/dist/client/session-replay.js.map +1 -1
  134. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  135. package/dist/client/settings/SettingsPanel.js +2 -2
  136. package/dist/client/settings/SettingsPanel.js.map +1 -1
  137. package/dist/client/transcription/use-live-transcription.d.ts +3 -3
  138. package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
  139. package/dist/client/transcription/use-live-transcription.js +22 -11
  140. package/dist/client/transcription/use-live-transcription.js.map +1 -1
  141. package/dist/collab/routes.d.ts +1 -1
  142. package/dist/collab/struct-routes.d.ts +1 -1
  143. package/dist/deploy/build.d.ts.map +1 -1
  144. package/dist/deploy/build.js +1 -1
  145. package/dist/deploy/build.js.map +1 -1
  146. package/dist/guards/db-tool-scoping.js +1 -1
  147. package/dist/guards/db-tool-scoping.js.map +1 -1
  148. package/dist/integrations/adapters/slack.d.ts +1 -0
  149. package/dist/integrations/adapters/slack.d.ts.map +1 -1
  150. package/dist/integrations/adapters/slack.js +61 -5
  151. package/dist/integrations/adapters/slack.js.map +1 -1
  152. package/dist/integrations/index.d.ts +1 -1
  153. package/dist/integrations/index.d.ts.map +1 -1
  154. package/dist/integrations/index.js +1 -1
  155. package/dist/integrations/index.js.map +1 -1
  156. package/dist/localization/default-messages.js +1 -1
  157. package/dist/localization/default-messages.js.map +1 -1
  158. package/dist/mcp-client/oauth-routes.d.ts +3 -0
  159. package/dist/mcp-client/oauth-routes.d.ts.map +1 -1
  160. package/dist/mcp-client/oauth-routes.js +41 -12
  161. package/dist/mcp-client/oauth-routes.js.map +1 -1
  162. package/dist/notifications/routes.d.ts +2 -2
  163. package/dist/observability/routes.d.ts +3 -3
  164. package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
  165. package/dist/provider-api/actions/provider-api.d.ts +11 -11
  166. package/dist/secrets/routes.d.ts +6 -6
  167. package/dist/server/realtime-voice.d.ts.map +1 -1
  168. package/dist/server/realtime-voice.js +1 -1
  169. package/dist/server/realtime-voice.js.map +1 -1
  170. package/dist/server/transcribe-voice.d.ts +1 -1
  171. package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
  172. package/dist/terminal/cli-registry.js +1 -1
  173. package/dist/terminal/cli-registry.js.map +1 -1
  174. package/dist/vite/client.d.ts +8 -1
  175. package/dist/vite/client.d.ts.map +1 -1
  176. package/dist/vite/client.js +113 -2
  177. package/dist/vite/client.js.map +1 -1
  178. package/package.json +2 -2
  179. package/src/a2a/client.ts +32 -10
  180. package/src/cli/index.ts +18 -10
  181. package/src/cli/multi-frontier-runs.ts +5 -3
  182. package/src/cli/templates-meta.ts +0 -12
  183. package/src/cli/workspace-dev.ts +1 -1
  184. package/src/client/AgentPanel.tsx +9 -1
  185. package/src/client/RunStuckBanner.tsx +39 -47
  186. package/src/client/chat/action-chat-ui-surface.tsx +32 -0
  187. package/src/client/chat/message-components.tsx +53 -8
  188. package/src/client/chat/tool-call-display.tsx +24 -9
  189. package/src/client/chat/widgets/InlineExtensionWidget.tsx +0 -1
  190. package/src/client/chat/widgets/builtin-tool-renderers.tsx +7 -3
  191. package/src/client/conversation/AgentConversation.tsx +12 -1
  192. package/src/client/error-capture.ts +2 -6
  193. package/src/client/resources/McpConnectionSuggestion.tsx +20 -14
  194. package/src/client/resources/ResourcesPanel.tsx +5 -1
  195. package/src/client/resources/mcp-integration-catalog.ts +7 -17
  196. package/src/client/resources/mcp-integration-logos.ts +2 -2
  197. package/src/client/route-chunk-recovery.ts +5 -3
  198. package/src/client/session-replay.ts +3 -3
  199. package/src/client/settings/SettingsPanel.tsx +15 -6
  200. package/src/client/transcription/use-live-transcription.ts +64 -45
  201. package/src/deploy/build.ts +2 -1
  202. package/src/guards/db-tool-scoping.ts +1 -1
  203. package/src/integrations/adapters/slack.ts +84 -5
  204. package/src/integrations/index.ts +5 -1
  205. package/src/localization/default-messages.ts +1 -1
  206. package/src/mcp-client/oauth-routes.ts +45 -12
  207. package/src/server/realtime-voice.ts +4 -1
  208. package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +7 -5
  209. package/src/terminal/cli-registry.ts +1 -1
  210. package/src/vite/client.ts +166 -1
  211. package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +0 -115
  212. package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
  213. package/corpus/templates/crm/.agents/skills/crm/SKILL.md +0 -128
  214. package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +0 -220
  215. package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +0 -169
  216. package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +0 -100
  217. package/corpus/templates/crm/.env.example +0 -5
  218. package/corpus/templates/crm/AGENTS.md +0 -120
  219. package/corpus/templates/crm/CHANGELOG.md +0 -1
  220. package/corpus/templates/crm/DEVELOPING.md +0 -66
  221. package/corpus/templates/crm/README.md +0 -106
  222. package/corpus/templates/crm/_gitignore +0 -12
  223. package/corpus/templates/crm/actions/_crm-action-utils.ts +0 -87
  224. package/corpus/templates/crm/actions/_crm-dashboard.ts +0 -69
  225. package/corpus/templates/crm/actions/_crm-data-program-actions.ts +0 -15
  226. package/corpus/templates/crm/actions/_crm-signal-utils.ts +0 -79
  227. package/corpus/templates/crm/actions/apply-crm-proposals.ts +0 -203
  228. package/corpus/templates/crm/actions/attach-call-evidence.ts +0 -170
  229. package/corpus/templates/crm/actions/configure-crm-connection.ts +0 -126
  230. package/corpus/templates/crm/actions/configure-native-crm.ts +0 -44
  231. package/corpus/templates/crm/actions/create-crm-record.ts +0 -148
  232. package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +0 -58
  233. package/corpus/templates/crm/actions/delete-staged-dataset.ts +0 -14
  234. package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +0 -36
  235. package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +0 -35
  236. package/corpus/templates/crm/actions/get-crm-dashboard.ts +0 -14
  237. package/corpus/templates/crm/actions/get-crm-overview.ts +0 -13
  238. package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +0 -61
  239. package/corpus/templates/crm/actions/get-crm-record.ts +0 -75
  240. package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +0 -81
  241. package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +0 -15
  242. package/corpus/templates/crm/actions/list-crm-dashboards.ts +0 -15
  243. package/corpus/templates/crm/actions/list-crm-proposals.ts +0 -31
  244. package/corpus/templates/crm/actions/list-crm-records.ts +0 -79
  245. package/corpus/templates/crm/actions/list-crm-saved-views.ts +0 -15
  246. package/corpus/templates/crm/actions/list-crm-signal-hits.ts +0 -43
  247. package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +0 -32
  248. package/corpus/templates/crm/actions/list-crm-tasks.ts +0 -22
  249. package/corpus/templates/crm/actions/list-staged-datasets.ts +0 -14
  250. package/corpus/templates/crm/actions/list-workspace-connections.ts +0 -47
  251. package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +0 -87
  252. package/corpus/templates/crm/actions/manage-crm-task.ts +0 -132
  253. package/corpus/templates/crm/actions/navigate.ts +0 -63
  254. package/corpus/templates/crm/actions/provider-api-catalog.ts +0 -22
  255. package/corpus/templates/crm/actions/provider-api-docs.ts +0 -54
  256. package/corpus/templates/crm/actions/provider-api-request.ts +0 -92
  257. package/corpus/templates/crm/actions/query-staged-dataset.ts +0 -44
  258. package/corpus/templates/crm/actions/record-crm-call-insight.ts +0 -160
  259. package/corpus/templates/crm/actions/record-crm-smart-signal.ts +0 -150
  260. package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +0 -23
  261. package/corpus/templates/crm/actions/review-crm-signal.ts +0 -31
  262. package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +0 -103
  263. package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +0 -275
  264. package/corpus/templates/crm/actions/run.ts +0 -7
  265. package/corpus/templates/crm/actions/save-crm-dashboard.ts +0 -51
  266. package/corpus/templates/crm/actions/save-crm-saved-view.ts +0 -119
  267. package/corpus/templates/crm/actions/sync-crm.ts +0 -146
  268. package/corpus/templates/crm/actions/update-crm-record.ts +0 -510
  269. package/corpus/templates/crm/actions/view-screen.ts +0 -218
  270. package/corpus/templates/crm/agent-native.app-skill.json +0 -58
  271. package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +0 -158
  272. package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +0 -78
  273. package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +0 -226
  274. package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +0 -414
  275. package/corpus/templates/crm/app/components/crm/RecordActions.tsx +0 -510
  276. package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +0 -134
  277. package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +0 -362
  278. package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +0 -93
  279. package/corpus/templates/crm/app/components/crm/Surface.tsx +0 -97
  280. package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +0 -180
  281. package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +0 -112
  282. package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +0 -84
  283. package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +0 -1
  284. package/corpus/templates/crm/app/components/ui/badge.tsx +0 -1
  285. package/corpus/templates/crm/app/components/ui/button.tsx +0 -1
  286. package/corpus/templates/crm/app/components/ui/card.tsx +0 -1
  287. package/corpus/templates/crm/app/components/ui/dialog.tsx +0 -1
  288. package/corpus/templates/crm/app/components/ui/input.tsx +0 -1
  289. package/corpus/templates/crm/app/components/ui/label.tsx +0 -1
  290. package/corpus/templates/crm/app/components/ui/select.tsx +0 -1
  291. package/corpus/templates/crm/app/components/ui/sheet.tsx +0 -1
  292. package/corpus/templates/crm/app/components/ui/skeleton.tsx +0 -1
  293. package/corpus/templates/crm/app/components/ui/switch.tsx +0 -1
  294. package/corpus/templates/crm/app/components/ui/table.tsx +0 -1
  295. package/corpus/templates/crm/app/components/ui/tabs.tsx +0 -1
  296. package/corpus/templates/crm/app/components/ui/textarea.tsx +0 -1
  297. package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +0 -17
  298. package/corpus/templates/crm/app/design-system.ts +0 -3
  299. package/corpus/templates/crm/app/entry.client.tsx +0 -16
  300. package/corpus/templates/crm/app/entry.server.tsx +0 -10
  301. package/corpus/templates/crm/app/global.css +0 -167
  302. package/corpus/templates/crm/app/hooks/use-navigation-state.ts +0 -60
  303. package/corpus/templates/crm/app/i18n/en-US.ts +0 -89
  304. package/corpus/templates/crm/app/i18n/index.ts +0 -34
  305. package/corpus/templates/crm/app/lib/dashboard.ts +0 -13
  306. package/corpus/templates/crm/app/lib/navigation.ts +0 -54
  307. package/corpus/templates/crm/app/lib/tab-id.ts +0 -1
  308. package/corpus/templates/crm/app/lib/types.ts +0 -172
  309. package/corpus/templates/crm/app/lib/utils.ts +0 -1
  310. package/corpus/templates/crm/app/root.tsx +0 -91
  311. package/corpus/templates/crm/app/routes/_index.tsx +0 -26
  312. package/corpus/templates/crm/app/routes/accounts.tsx +0 -41
  313. package/corpus/templates/crm/app/routes/agent.tsx +0 -5
  314. package/corpus/templates/crm/app/routes/ask.tsx +0 -53
  315. package/corpus/templates/crm/app/routes/dashboard.tsx +0 -118
  316. package/corpus/templates/crm/app/routes/opportunities.tsx +0 -41
  317. package/corpus/templates/crm/app/routes/people.tsx +0 -41
  318. package/corpus/templates/crm/app/routes/proposals.tsx +0 -266
  319. package/corpus/templates/crm/app/routes/records.$recordId.tsx +0 -35
  320. package/corpus/templates/crm/app/routes/settings.tsx +0 -63
  321. package/corpus/templates/crm/app/routes/setup.tsx +0 -308
  322. package/corpus/templates/crm/app/routes/tasks.tsx +0 -252
  323. package/corpus/templates/crm/app/routes/views.tsx +0 -333
  324. package/corpus/templates/crm/app/routes.ts +0 -17
  325. package/corpus/templates/crm/app/vite-env.d.ts +0 -6
  326. package/corpus/templates/crm/changelog/2026-07-21-agent-native-crm.md +0 -6
  327. package/corpus/templates/crm/changelog/2026-07-21-clips-call-evidence-review-recipe.md +0 -6
  328. package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-find-and-review-evidence-grounded-call-signals-w.md +0 -6
  329. package/corpus/templates/crm/changelog/2026-07-21-crm-can-now-manage-keyword-and-smart-call-signal-trackers-fr.md +0 -6
  330. package/corpus/templates/crm/changelog/2026-07-21-delegated-local-crm-automation.md +0 -6
  331. package/corpus/templates/crm/changelog/2026-07-21-native-sql.md +0 -6
  332. package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboard.md +0 -6
  333. package/corpus/templates/crm/changelog/2026-07-21-pipeline-dashboards-now-install-correctly-from-the-crm-actio.md +0 -6
  334. package/corpus/templates/crm/changelog/2026-07-21-salesforce-connection.md +0 -6
  335. package/corpus/templates/crm/changelog/2026-07-22-crm-field-validation-now-explains-which-fields-cannot-be-edi.md +0 -6
  336. package/corpus/templates/crm/changelog/2026-07-22-fixed-hubspot-contact-syncs-missing-records-updated-after-th.md +0 -6
  337. package/corpus/templates/crm/changelog/2026-07-22-fixed-pipeline-dashboard-panels-so-their-opportunity-data-lo.md +0 -6
  338. package/corpus/templates/crm/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
  339. package/corpus/templates/crm/components.json +0 -20
  340. package/corpus/templates/crm/docs/architecture/crm-contract.md +0 -180
  341. package/corpus/templates/crm/learnings.defaults.md +0 -5
  342. package/corpus/templates/crm/package.json +0 -59
  343. package/corpus/templates/crm/public/favicon.svg +0 -1
  344. package/corpus/templates/crm/public/icon-180.svg +0 -1
  345. package/corpus/templates/crm/public/manifest.json +0 -11
  346. package/corpus/templates/crm/react-router.config.ts +0 -7
  347. package/corpus/templates/crm/server/crm/adapter.ts +0 -32
  348. package/corpus/templates/crm/server/crm/crm-field-firewall.ts +0 -64
  349. package/corpus/templates/crm/server/crm/crm-mirror.ts +0 -711
  350. package/corpus/templates/crm/server/crm/hubspot-adapter.ts +0 -1146
  351. package/corpus/templates/crm/server/crm/native-adapter.ts +0 -1715
  352. package/corpus/templates/crm/server/crm/read-through.ts +0 -207
  353. package/corpus/templates/crm/server/crm/salesforce-adapter.ts +0 -1255
  354. package/corpus/templates/crm/server/db/crm-store.ts +0 -1170
  355. package/corpus/templates/crm/server/db/index.ts +0 -169
  356. package/corpus/templates/crm/server/db/schema.ts +0 -441
  357. package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +0 -65
  358. package/corpus/templates/crm/server/lib/intelligence/evidence.ts +0 -105
  359. package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +0 -100
  360. package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +0 -144
  361. package/corpus/templates/crm/server/lib/intelligence/summary.ts +0 -141
  362. package/corpus/templates/crm/server/lib/provider-api.ts +0 -64
  363. package/corpus/templates/crm/server/middleware/auth.ts +0 -4
  364. package/corpus/templates/crm/server/plugins/agent-chat.ts +0 -68
  365. package/corpus/templates/crm/server/plugins/auth.ts +0 -14
  366. package/corpus/templates/crm/server/plugins/core-routes.ts +0 -17
  367. package/corpus/templates/crm/server/plugins/db.ts +0 -454
  368. package/corpus/templates/crm/server/routes/[...page].get.ts +0 -5
  369. package/corpus/templates/crm/shared/crm-automation-recipes.ts +0 -132
  370. package/corpus/templates/crm/shared/crm-contract.ts +0 -254
  371. package/corpus/templates/crm/shared/crm-sales-config.ts +0 -63
  372. package/corpus/templates/crm/ssr-entry.ts +0 -11
  373. package/corpus/templates/crm/tsconfig.json +0 -24
  374. package/corpus/templates/crm/vite.config.ts +0 -15
  375. package/corpus/templates/crm/vitest.config.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-routes.js","sourceRoot":"","sources":["../../src/mcp-client/oauth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,GAElB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAE3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,CAAC;AAuBjC,MAAM,UAAU,yBAAyB,CACvC,KAAc,EACd,QAAgB;IAEhB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE,UAAU;KAC5B,CAAC,CAAC;IACH,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,YA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AE,KAAK,EAAE,yBAAyB,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import crypto from \"node:crypto\";\n\nimport type { OAuthClientInformationMixed } from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport {\n deleteCookie,\n defineEventHandler,\n getCookie,\n getMethod,\n getQuery,\n setCookie,\n setResponseStatus,\n type H3Event,\n} from \"h3\";\n\nimport { getOrgContext } from \"../org/context.js\";\nimport { decryptSecretValue, encryptSecretValue } from \"../secrets/crypto.js\";\nimport { getSession, safeReturnPath } from \"../server/auth.js\";\nimport { getH3App } from \"../server/framework-request-handler.js\";\nimport { getAppUrl, resolveOAuthRedirectUri } from \"../server/google-oauth.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n finishMcpOAuthAuthorization,\n startMcpOAuthAuthorization,\n type McpOAuthDiscoveryState,\n} from \"./oauth-client.js\";\nimport {\n addOAuthRemoteServer,\n normalizeServerName,\n validateRemoteUrl,\n type RemoteMcpScope,\n} from \"./remote-store.js\";\n\nconst FLOW_COOKIE = \"an_mcp_oauth_flow\";\nconst FLOW_TTL_SECONDS = 10 * 60;\n\nexport interface McpOAuthFlow {\n name: string;\n url: string;\n description?: string;\n scope: RemoteMcpScope;\n scopeId: string;\n owner: string;\n orgId?: string;\n redirectUri: string;\n state: string;\n codeVerifier: string;\n clientInformation: OAuthClientInformationMixed;\n discoveryState?: McpOAuthDiscoveryState;\n returnUrl?: string;\n expiresAt: number;\n}\n\nexport interface McpOAuthRoutesOptions {\n reconfigure: () => Promise<void>;\n}\n\nexport function redirectWithStagedCookies(\n event: H3Event,\n location: string,\n): Response {\n const headers = new Headers({\n Location: location,\n \"Cache-Control\": \"no-store\",\n });\n for (const cookie of event.res?.headers?.getSetCookie?.() ?? []) {\n headers.append(\"set-cookie\", cookie);\n }\n return new Response(null, { status: 302, headers });\n}\n\nexport function mountMcpOAuthRoutes(\n nitroApp: any,\n options: McpOAuthRoutesOptions,\n): void {\n const mountedApps: WeakSet<object> = ((\n globalThis as any\n ).__agentNativeMcpOAuthMountedApps ??= new WeakSet<object>());\n if (mountedApps.has(nitroApp)) return;\n mountedApps.add(nitroApp);\n\n getH3App(nitroApp).use(\n \"/_agent-native/mcp/servers/oauth\",\n defineEventHandler(async (event: H3Event) => {\n const method = getMethod(event);\n const pathname = (event.url?.pathname || \"\")\n .replace(/^\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n const parts = pathname ? pathname.split(\"/\") : [];\n if (method !== \"GET\") {\n setResponseStatus(event, 405);\n return { error: \"Method not allowed\" };\n }\n if (parts.length === 1 && parts[0] === \"start\") {\n return handleMcpOAuthStart(event);\n }\n if (parts.length === 1 && parts[0] === \"callback\") {\n return handleMcpOAuthCallback(event, options);\n }\n setResponseStatus(event, 404);\n return { error: \"Not found\" };\n }),\n );\n}\n\nasync function handleMcpOAuthStart(\n event: H3Event,\n): Promise<Response | Record<string, unknown>> {\n const session = await getSession(event).catch(() => null);\n if (!session?.email) return unauthorized(event);\n\n const query = getQuery(event);\n const rawUrl = text(query.url);\n const rawName = text(query.name);\n const returnUrl = text(query.return);\n if (!rawUrl || !rawName) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth requires a server name and URL.\" };\n }\n const urlCheck = validateRemoteUrl(rawUrl);\n if (!urlCheck.ok) {\n setResponseStatus(event, 400);\n return { error: urlCheck.error ?? \"MCP server URL is not allowed.\" };\n }\n const name = normalizeServerName(rawName);\n if (!name) {\n setResponseStatus(event, 400);\n return { error: \"MCP server name is invalid.\" };\n }\n\n const requestedScope = query.scope === \"org\" ? \"org\" : \"user\";\n const requestedOrgId = text(query.orgId);\n const org =\n requestedScope === \"org\"\n ? await getOrgContext(event).catch(() => null)\n : null;\n const scope: RemoteMcpScope = requestedScope;\n const scopeId = scope === \"user\" ? session.email : (org?.orgId ?? \"\");\n if (scope === \"org\" && requestedOrgId && requestedOrgId !== scopeId) {\n setResponseStatus(event, 403);\n return {\n error: \"The selected organization is not the active organization.\",\n };\n }\n if (scope === \"org\" && (!scopeId || !isOrgAdmin(org?.role))) {\n setResponseStatus(event, scopeId ? 403 : 400);\n return {\n error: scopeId\n ? \"Only organization owners and admins can connect an org MCP server.\"\n : \"Join an organization before connecting an org MCP server.\",\n };\n }\n\n const redirectUri = resolveOAuthRedirectUri(\n event,\n \"/_agent-native/mcp/servers/oauth/callback\",\n );\n if (!redirectUri) {\n setResponseStatus(event, 400);\n return { error: \"Invalid MCP OAuth redirect URI.\" };\n }\n\n const state = crypto.randomUUID();\n const safeReturnUrl = returnUrl ? safeReturnPath(returnUrl) : undefined;\n try {\n const started = await runWithRequestContext(\n { userEmail: session.email, orgId: org?.orgId ?? undefined },\n () =>\n startMcpOAuthAuthorization({\n serverUrl: urlCheck.url!.toString(),\n redirectUrl: redirectUri,\n state,\n }),\n );\n const flow: McpOAuthFlow = {\n name,\n url: urlCheck.url!.toString(),\n description: text(query.description),\n scope,\n scopeId,\n owner: session.email,\n ...(org?.orgId ? { orgId: org.orgId } : {}),\n redirectUri,\n state: started.state,\n codeVerifier: started.codeVerifier,\n clientInformation: started.clientInformation,\n ...(started.discoveryState\n ? { discoveryState: started.discoveryState }\n : {}),\n ...(safeReturnUrl ? { returnUrl: safeReturnUrl } : {}),\n expiresAt: Date.now() + FLOW_TTL_SECONDS * 1_000,\n };\n setCookie(event, FLOW_COOKIE, encryptSecretValue(JSON.stringify(flow)), {\n httpOnly: true,\n secure: redirectUri.startsWith(\"https://\"),\n sameSite: \"lax\",\n path: \"/\",\n maxAge: FLOW_TTL_SECONDS,\n });\n return redirectWithStagedCookies(event, started.authorizationUrl.href);\n } catch {\n setResponseStatus(event, 400);\n return {\n error:\n \"This MCP server could not start OAuth. It may not support standard MCP OAuth discovery or dynamic client registration.\",\n };\n }\n}\n\nasync function handleMcpOAuthCallback(\n event: H3Event,\n options: McpOAuthRoutesOptions,\n): Promise<Response | Record<string, unknown>> {\n const session = await getSession(event).catch(() => null);\n if (!session?.email) return unauthorized(event);\n\n const query = getQuery(event);\n const code = text(query.code);\n const state = text(query.state);\n const providerError = text(query.error);\n const flow = readFlow(event);\n deleteCookie(event, FLOW_COOKIE, { path: \"/\" });\n if (providerError || !code || !state) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth authorization was not completed.\" };\n }\n const org =\n flow?.scope === \"org\" ? await getOrgContext(event).catch(() => null) : null;\n if (\n !flow ||\n !isValidMcpOAuthFlow(flow, session.email, org?.orgId ?? undefined, state)\n ) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth state is invalid or expired.\" };\n }\n if (flow.scope === \"org\" && !isOrgAdmin(org?.role)) {\n setResponseStatus(event, 403);\n return {\n error:\n \"Only organization owners and admins can connect an org MCP server.\",\n };\n }\n\n try {\n const finished = await runWithRequestContext(\n { userEmail: session.email, orgId: org?.orgId ?? undefined },\n () =>\n finishMcpOAuthAuthorization({\n serverUrl: flow.url,\n redirectUrl: flow.redirectUri,\n state: flow.state,\n clientInformation: flow.clientInformation,\n codeVerifier: flow.codeVerifier,\n discoveryState: flow.discoveryState,\n authorizationCode: code,\n }),\n );\n const result = await addOAuthRemoteServer(flow.scope, flow.scopeId, {\n name: flow.name,\n url: flow.url,\n description: flow.description,\n credentials: finished.credentials,\n });\n if (!result.ok) {\n setResponseStatus(event, 400);\n return { error: result.error };\n }\n await options.reconfigure();\n const returnPath =\n flow.returnUrl ??\n `/settings/connections?connected=mcp-${encodeURIComponent(flow.name)}`;\n return redirectWithStagedCookies(event, getAppUrl(event, returnPath));\n } catch {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth authorization could not be completed.\" };\n }\n}\n\nfunction readFlow(event: H3Event): McpOAuthFlow | null {\n const encrypted = getCookie(event, FLOW_COOKIE);\n if (!encrypted) return null;\n try {\n const parsed = JSON.parse(decryptSecretValue(encrypted)) as McpOAuthFlow;\n return parsed && typeof parsed === \"object\" ? parsed : null;\n } catch {\n return null;\n }\n}\n\nexport function isValidMcpOAuthFlow(\n flow: McpOAuthFlow,\n email: string,\n orgId: string | undefined,\n state: string,\n): boolean {\n const scopeMatches =\n flow.scope === \"user\"\n ? flow.scopeId === email && !flow.orgId\n : flow.scope === \"org\" && flow.scopeId === orgId && flow.orgId === orgId;\n return (\n flow.expiresAt >= Date.now() &&\n flow.owner === email &&\n flow.state === state &&\n scopeMatches &&\n typeof flow.scopeId === \"string\" &&\n typeof flow.redirectUri === \"string\" &&\n flow.redirectUri.includes(\"/_agent-native/mcp/servers/oauth/callback\")\n );\n}\n\nfunction isOrgAdmin(role: unknown): boolean {\n return role === \"owner\" || role === \"admin\";\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction unauthorized(event: H3Event) {\n setResponseStatus(event, 401);\n return { error: \"Authentication required\" };\n}\n"]}
1
+ {"version":3,"file":"oauth-routes.js","sourceRoot":"","sources":["../../src/mcp-client/oauth-routes.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAE3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,mBAAmB,CA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CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC;AAC9C,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["import crypto from \"node:crypto\";\n\nimport type { OAuthClientInformationMixed } from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport {\n deleteCookie,\n defineEventHandler,\n getChunkedCookie,\n getCookie,\n getMethod,\n getQuery,\n setChunkedCookie,\n setResponseStatus,\n type H3Event,\n} from \"h3\";\n\nimport { getOrgContext } from \"../org/context.js\";\nimport { decryptSecretValue, encryptSecretValue } from \"../secrets/crypto.js\";\nimport { getSession, safeReturnPath } from \"../server/auth.js\";\nimport { getH3App } from \"../server/framework-request-handler.js\";\nimport { getAppUrl, resolveOAuthRedirectUri } from \"../server/google-oauth.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n finishMcpOAuthAuthorization,\n startMcpOAuthAuthorization,\n type McpOAuthDiscoveryState,\n} from \"./oauth-client.js\";\nimport {\n addOAuthRemoteServer,\n normalizeServerName,\n validateRemoteUrl,\n type RemoteMcpScope,\n} from \"./remote-store.js\";\n\nconst FLOW_COOKIE = \"an_mcp_oauth_flow\";\nconst FLOW_TTL_SECONDS = 10 * 60;\nconst FLOW_COOKIE_CHUNK_SIZE = 2_800;\nconst FLOW_COOKIE_MAX_CHUNKS = 8;\nconst CHUNKED_COOKIE_PREFIX = \"__chunked__\";\n\nexport interface McpOAuthFlow {\n name: string;\n url: string;\n description?: string;\n scope: RemoteMcpScope;\n scopeId: string;\n owner: string;\n orgId?: string;\n redirectUri: string;\n state: string;\n codeVerifier: string;\n clientInformation: OAuthClientInformationMixed;\n discoveryState?: McpOAuthDiscoveryState;\n returnUrl?: string;\n expiresAt: number;\n}\n\nexport interface McpOAuthRoutesOptions {\n reconfigure: () => Promise<void>;\n}\n\nexport function redirectWithStagedCookies(\n event: H3Event,\n location: string,\n): Response {\n const headers = new Headers({\n Location: location,\n \"Cache-Control\": \"no-store\",\n });\n for (const cookie of event.res?.headers?.getSetCookie?.() ?? []) {\n headers.append(\"set-cookie\", cookie);\n }\n return new Response(null, { status: 302, headers });\n}\n\nexport function mountMcpOAuthRoutes(\n nitroApp: any,\n options: McpOAuthRoutesOptions,\n): void {\n const mountedApps: WeakSet<object> = ((\n globalThis as any\n ).__agentNativeMcpOAuthMountedApps ??= new WeakSet<object>());\n if (mountedApps.has(nitroApp)) return;\n mountedApps.add(nitroApp);\n\n getH3App(nitroApp).use(\n \"/_agent-native/mcp/servers/oauth\",\n defineEventHandler(async (event: H3Event) => {\n const method = getMethod(event);\n const pathname = (event.url?.pathname || \"\")\n .replace(/^\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n const parts = pathname ? pathname.split(\"/\") : [];\n if (method !== \"GET\") {\n setResponseStatus(event, 405);\n return { error: \"Method not allowed\" };\n }\n if (parts.length === 1 && parts[0] === \"start\") {\n return handleMcpOAuthStart(event);\n }\n if (parts.length === 1 && parts[0] === \"callback\") {\n return handleMcpOAuthCallback(event, options);\n }\n setResponseStatus(event, 404);\n return { error: \"Not found\" };\n }),\n );\n}\n\nasync function handleMcpOAuthStart(\n event: H3Event,\n): Promise<Response | Record<string, unknown>> {\n const session = await getSession(event).catch(() => null);\n if (!session?.email) return unauthorized(event);\n\n const query = getQuery(event);\n const rawUrl = text(query.url);\n const rawName = text(query.name);\n const returnUrl = text(query.return);\n if (!rawUrl || !rawName) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth requires a server name and URL.\" };\n }\n const urlCheck = validateRemoteUrl(rawUrl);\n if (!urlCheck.ok) {\n setResponseStatus(event, 400);\n return { error: urlCheck.error ?? \"MCP server URL is not allowed.\" };\n }\n const name = normalizeServerName(rawName);\n if (!name) {\n setResponseStatus(event, 400);\n return { error: \"MCP server name is invalid.\" };\n }\n\n const requestedScope = query.scope === \"org\" ? \"org\" : \"user\";\n const requestedOrgId = text(query.orgId);\n const org =\n requestedScope === \"org\"\n ? await getOrgContext(event).catch(() => null)\n : null;\n const scope: RemoteMcpScope = requestedScope;\n const scopeId = scope === \"user\" ? session.email : (org?.orgId ?? \"\");\n if (scope === \"org\" && requestedOrgId && requestedOrgId !== scopeId) {\n setResponseStatus(event, 403);\n return {\n error: \"The selected organization is not the active organization.\",\n };\n }\n if (scope === \"org\" && (!scopeId || !isOrgAdmin(org?.role))) {\n setResponseStatus(event, scopeId ? 403 : 400);\n return {\n error: scopeId\n ? \"Only organization owners and admins can connect an org MCP server.\"\n : \"Join an organization before connecting an org MCP server.\",\n };\n }\n\n const redirectUri = resolveOAuthRedirectUri(\n event,\n \"/_agent-native/mcp/servers/oauth/callback\",\n );\n if (!redirectUri) {\n setResponseStatus(event, 400);\n return { error: \"Invalid MCP OAuth redirect URI.\" };\n }\n\n const state = crypto.randomUUID();\n const safeReturnUrl = returnUrl ? safeReturnPath(returnUrl) : undefined;\n try {\n const started = await runWithRequestContext(\n { userEmail: session.email, orgId: org?.orgId ?? undefined },\n () =>\n startMcpOAuthAuthorization({\n serverUrl: urlCheck.url!.toString(),\n redirectUrl: redirectUri,\n state,\n }),\n );\n const flow: McpOAuthFlow = {\n name,\n url: urlCheck.url!.toString(),\n description: text(query.description),\n scope,\n scopeId,\n owner: session.email,\n ...(org?.orgId ? { orgId: org.orgId } : {}),\n redirectUri,\n state: started.state,\n codeVerifier: started.codeVerifier,\n clientInformation: started.clientInformation,\n ...(started.discoveryState\n ? { discoveryState: started.discoveryState }\n : {}),\n ...(safeReturnUrl ? { returnUrl: safeReturnUrl } : {}),\n expiresAt: Date.now() + FLOW_TTL_SECONDS * 1_000,\n };\n setMcpOAuthFlowCookie(event, flow, redirectUri.startsWith(\"https://\"));\n return redirectWithStagedCookies(event, started.authorizationUrl.href);\n } catch {\n setResponseStatus(event, 400);\n return {\n error:\n \"This MCP server could not start OAuth. It may not support standard MCP OAuth discovery or dynamic client registration.\",\n };\n }\n}\n\nasync function handleMcpOAuthCallback(\n event: H3Event,\n options: McpOAuthRoutesOptions,\n): Promise<Response | Record<string, unknown>> {\n const session = await getSession(event).catch(() => null);\n if (!session?.email) return unauthorized(event);\n\n const query = getQuery(event);\n const code = text(query.code);\n const state = text(query.state);\n const providerError = text(query.error);\n const flow = readMcpOAuthFlowCookie(event);\n clearMcpOAuthFlowCookies(event);\n if (providerError || !code || !state) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth authorization was not completed.\" };\n }\n const org =\n flow?.scope === \"org\" ? await getOrgContext(event).catch(() => null) : null;\n if (\n !flow ||\n !isValidMcpOAuthFlow(flow, session.email, org?.orgId ?? undefined, state)\n ) {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth state is invalid or expired.\" };\n }\n if (flow.scope === \"org\" && !isOrgAdmin(org?.role)) {\n setResponseStatus(event, 403);\n return {\n error:\n \"Only organization owners and admins can connect an org MCP server.\",\n };\n }\n\n try {\n const finished = await runWithRequestContext(\n { userEmail: session.email, orgId: org?.orgId ?? undefined },\n () =>\n finishMcpOAuthAuthorization({\n serverUrl: flow.url,\n redirectUrl: flow.redirectUri,\n state: flow.state,\n clientInformation: flow.clientInformation,\n codeVerifier: flow.codeVerifier,\n discoveryState: flow.discoveryState,\n authorizationCode: code,\n }),\n );\n const result = await addOAuthRemoteServer(flow.scope, flow.scopeId, {\n name: flow.name,\n url: flow.url,\n description: flow.description,\n credentials: finished.credentials,\n });\n if (!result.ok) {\n setResponseStatus(event, 400);\n return { error: result.error };\n }\n await options.reconfigure();\n const returnPath =\n flow.returnUrl ??\n `/settings/connections?connected=mcp-${encodeURIComponent(flow.name)}`;\n return redirectWithStagedCookies(event, getAppUrl(event, returnPath));\n } catch {\n setResponseStatus(event, 400);\n return { error: \"MCP OAuth authorization could not be completed.\" };\n }\n}\n\nexport function setMcpOAuthFlowCookie(\n event: H3Event,\n flow: McpOAuthFlow,\n secure: boolean,\n): void {\n const encrypted = encryptSecretValue(JSON.stringify(flow));\n const chunkCount = Math.ceil(encrypted.length / FLOW_COOKIE_CHUNK_SIZE);\n if (chunkCount > FLOW_COOKIE_MAX_CHUNKS) {\n throw new Error(\"MCP OAuth flow state exceeds the cookie size limit.\");\n }\n setChunkedCookie(event, FLOW_COOKIE, encrypted, {\n httpOnly: true,\n secure,\n sameSite: \"lax\",\n path: \"/\",\n maxAge: FLOW_TTL_SECONDS,\n chunkMaxLength: FLOW_COOKIE_CHUNK_SIZE,\n });\n}\n\nexport function readMcpOAuthFlowCookie(event: H3Event): McpOAuthFlow | null {\n const primaryCookie = getCookie(event, FLOW_COOKIE);\n if (!primaryCookie) return null;\n if (primaryCookie.startsWith(CHUNKED_COOKIE_PREFIX)) {\n const rawCount = primaryCookie.slice(CHUNKED_COOKIE_PREFIX.length);\n if (!/^\\d+$/.test(rawCount)) return null;\n const chunkCount = Number(rawCount);\n if (chunkCount < 2 || chunkCount > FLOW_COOKIE_MAX_CHUNKS) return null;\n }\n const encrypted = getChunkedCookie(event, FLOW_COOKIE);\n if (!encrypted) return null;\n try {\n const parsed = JSON.parse(decryptSecretValue(encrypted)) as McpOAuthFlow;\n return parsed && typeof parsed === \"object\" ? parsed : null;\n } catch {\n return null;\n }\n}\n\nexport function clearMcpOAuthFlowCookies(event: H3Event): void {\n deleteCookie(event, FLOW_COOKIE, { path: \"/\" });\n for (let index = 1; index <= FLOW_COOKIE_MAX_CHUNKS; index += 1) {\n deleteCookie(event, `${FLOW_COOKIE}.${index}`, { path: \"/\" });\n }\n}\n\nexport function isValidMcpOAuthFlow(\n flow: McpOAuthFlow,\n email: string,\n orgId: string | undefined,\n state: string,\n): boolean {\n const scopeMatches =\n flow.scope === \"user\"\n ? flow.scopeId === email && !flow.orgId\n : flow.scope === \"org\" && flow.scopeId === orgId && flow.orgId === orgId;\n return (\n flow.expiresAt >= Date.now() &&\n flow.owner === email &&\n flow.state === state &&\n scopeMatches &&\n typeof flow.scopeId === \"string\" &&\n typeof flow.redirectUri === \"string\" &&\n flow.redirectUri.includes(\"/_agent-native/mcp/servers/oauth/callback\")\n );\n}\n\nfunction isOrgAdmin(role: unknown): boolean {\n return role === \"owner\" || role === \"admin\";\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction unauthorized(event: H3Event) {\n setResponseStatus(event, 401);\n return { error: \"Authentication required\" };\n}\n"]}
@@ -13,13 +13,13 @@
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
14
  count: number;
15
15
  updated?: undefined;
16
- error?: undefined;
17
16
  ok?: undefined;
17
+ error?: undefined;
18
18
  } | {
19
19
  count?: undefined;
20
20
  updated: number;
21
- error?: undefined;
22
21
  ok?: undefined;
22
+ error?: undefined;
23
23
  } | {
24
24
  count?: undefined;
25
25
  updated?: undefined;
@@ -41,16 +41,16 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
44
  summary: import("./types.js").TraceSummary;
46
45
  spans: import("./types.js").TraceSpan[];
47
46
  id?: undefined;
47
+ error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
50
- error?: undefined;
51
50
  summary?: undefined;
52
51
  spans?: undefined;
53
52
  id: string;
53
+ error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
56
  summary?: undefined;
@@ -59,10 +59,10 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
59
59
  error: any;
60
60
  ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
65
+ error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
68
68
  //# sourceMappingURL=routes.d.ts.map
@@ -75,8 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- id?: undefined;
79
78
  deleted?: undefined;
79
+ id?: undefined;
80
+ provider?: undefined;
81
+ found?: undefined;
80
82
  providers: {
81
83
  id: string;
82
84
  label: string;
@@ -87,16 +89,14 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
87
89
  updatedAt: number;
88
90
  }[];
89
91
  count: number;
90
- provider?: undefined;
91
- found?: undefined;
92
92
  registered?: undefined;
93
93
  label?: undefined;
94
94
  message?: undefined;
95
95
  } | {
96
- id?: undefined;
97
96
  deleted?: undefined;
98
- providers?: undefined;
99
97
  count?: undefined;
98
+ id?: undefined;
99
+ providers?: undefined;
100
100
  found: boolean;
101
101
  provider: import("../custom-registry.js").CustomProviderConfig;
102
102
  registered?: undefined;
@@ -104,19 +104,19 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
104
104
  message?: undefined;
105
105
  } | {
106
106
  deleted?: undefined;
107
- providers?: undefined;
108
107
  count?: undefined;
109
108
  provider?: undefined;
109
+ providers?: undefined;
110
110
  found: boolean;
111
111
  id: string;
112
112
  registered?: undefined;
113
113
  label?: undefined;
114
114
  message?: undefined;
115
115
  } | {
116
- providers?: undefined;
117
116
  count?: undefined;
118
117
  provider?: undefined;
119
118
  found?: undefined;
119
+ providers?: undefined;
120
120
  deleted: boolean;
121
121
  id: string;
122
122
  registered?: undefined;
@@ -124,10 +124,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
124
124
  message?: undefined;
125
125
  } | {
126
126
  deleted?: undefined;
127
- providers?: undefined;
128
127
  count?: undefined;
129
128
  provider?: undefined;
130
129
  found?: undefined;
130
+ providers?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -309,9 +309,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
309
309
  notes?: string | undefined;
310
310
  scope?: "org" | "user" | undefined;
311
311
  }, {
312
- message?: undefined;
313
312
  id?: undefined;
314
- deleted?: undefined;
313
+ found?: undefined;
315
314
  providers: {
316
315
  id: string;
317
316
  label: string;
@@ -323,45 +322,46 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
323
322
  }[];
324
323
  count: number;
325
324
  provider?: undefined;
326
- found?: undefined;
325
+ deleted?: undefined;
327
326
  registered?: undefined;
328
327
  label?: undefined;
329
- } | {
330
328
  message?: undefined;
329
+ } | {
331
330
  id?: undefined;
332
- deleted?: undefined;
333
331
  count?: undefined;
334
332
  providers?: undefined;
335
333
  found: boolean;
336
334
  provider: import("../custom-registry.js").CustomProviderConfig;
335
+ deleted?: undefined;
337
336
  registered?: undefined;
338
337
  label?: undefined;
339
- } | {
340
338
  message?: undefined;
341
- deleted?: undefined;
339
+ } | {
342
340
  count?: undefined;
343
341
  providers?: undefined;
344
342
  provider?: undefined;
345
343
  found: boolean;
346
344
  id: string;
345
+ deleted?: undefined;
347
346
  registered?: undefined;
348
347
  label?: undefined;
349
- } | {
350
348
  message?: undefined;
349
+ } | {
350
+ found?: undefined;
351
351
  count?: undefined;
352
352
  providers?: undefined;
353
353
  provider?: undefined;
354
- found?: undefined;
355
354
  deleted: boolean;
356
355
  id: string;
357
356
  registered?: undefined;
358
357
  label?: undefined;
358
+ message?: undefined;
359
359
  } | {
360
- deleted?: undefined;
360
+ found?: undefined;
361
361
  count?: undefined;
362
362
  providers?: undefined;
363
363
  provider?: undefined;
364
- found?: undefined;
364
+ deleted?: undefined;
365
365
  registered: boolean;
366
366
  id: string;
367
367
  label: string;
@@ -37,17 +37,17 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
37
37
  ok?: undefined;
38
38
  status?: undefined;
39
39
  } | {
40
- error?: undefined;
41
40
  ok: boolean;
42
41
  status: string;
42
+ error?: undefined;
43
43
  } | {
44
44
  ok?: undefined;
45
45
  error: string;
46
46
  removed?: undefined;
47
47
  } | {
48
- error?: undefined;
49
48
  ok: boolean;
50
49
  removed: boolean;
50
+ error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — re-run the validator against the
@@ -58,13 +58,13 @@ export declare function createTestSecretHandler(): import("h3").EventHandlerWith
58
58
  error: string;
59
59
  note?: undefined;
60
60
  } | {
61
- error?: undefined;
62
61
  ok: boolean;
63
62
  note?: undefined;
64
- } | {
65
63
  error?: undefined;
64
+ } | {
66
65
  ok: boolean;
67
66
  note: string;
67
+ error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,12 +95,12 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
- error?: undefined;
99
98
  ok: boolean;
100
99
  key: string;
101
- } | {
102
100
  error?: undefined;
101
+ } | {
103
102
  ok: boolean;
104
103
  removed: boolean;
104
+ error?: undefined;
105
105
  }>>;
106
106
  //# sourceMappingURL=routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"realtime-voice.d.ts","sourceRoot":"","sources":["../../src/server/realtime-voice.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AAGZ,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAkBtC,eAAO,MAAM,2BAA2B,0CACC,CAAC;AAC1C,eAAO,MAAM,wBAAwB,uCAAuC,CAAC;AAC7E,eAAO,MAAM,4BAA4B,QAAY,CAAC;AACtD,eAAO,MAAM,kCAAkC,QAAY,CAAC;AAC5D,eAAO,MAAM,oCAAoC,Q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AAE,CACb,KAAK,EAAE,OAAO,KACX,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACpE;;;;OAIG;IACH,WAAW,EAAE,CACX,OAAO,EAAE,iCAAiC,KAExC,gCAAgC,GAChC,OAAO,CAAC,gCAAgC,CAAC,CAAC;CAC/C;AAyCD,wBAAgB,yCAAyC,CACvD,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,MAAM,CAQR;AAED,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACxC,MAAM,CAKR;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B,SAAS,GAAG,KAAK,GAAG,QAAQ,CAW9B;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,GACf,MAAM,CAKR;AA0TD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAQjB;AA0YD,6EAA6E;AAC7E,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACpC,OAAO,EAAE,+BAA+B,GACvC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAqB3C"}
@@ -92,7 +92,7 @@ export function resolveRealtimeVoiceLanguagePreference(value, acceptLanguage) {
92
92
  export function resolveRealtimeVoiceReasoningEffort(value) {
93
93
  const normalized = value?.trim().toLowerCase();
94
94
  return normalized &&
95
- Object.hasOwn(REALTIME_VOICE_REASONING_EFFORT, normalized)
95
+ Object.prototype.hasOwnProperty.call(REALTIME_VOICE_REASONING_EFFORT, normalized)
96
96
  ? REALTIME_VOICE_REASONING_EFFORT[normalized]
97
97
  : "low";
98
98
  }