@agent-native/core 0.127.1 → 0.128.0

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 (431) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +92 -0
  3. package/corpus/core/README.md +5 -26
  4. package/corpus/core/docs/content/actions.mdx +47 -4
  5. package/corpus/core/docs/content/native-chat-ui.mdx +7 -0
  6. package/corpus/core/docs/content/organizations-teams-permissions.mdx +109 -3
  7. package/corpus/core/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
  8. package/corpus/core/docs/content/toolkit-org-team.mdx +72 -12
  9. package/corpus/core/package.json +1 -1
  10. package/corpus/core/src/a2a/artifact-response.ts +36 -29
  11. package/corpus/core/src/action.ts +83 -2
  12. package/corpus/core/src/chat-threads/store.ts +48 -43
  13. package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
  14. package/corpus/core/src/cli/template-sync.ts +96 -0
  15. package/corpus/core/src/client/AgentPanel.tsx +26 -6
  16. package/corpus/core/src/client/AssistantChat.tsx +63 -7
  17. package/corpus/core/src/client/DefaultSpinner.tsx +29 -0
  18. package/corpus/core/src/client/org/TeamPage.tsx +161 -6
  19. package/corpus/core/src/client/org/hooks.ts +67 -0
  20. package/corpus/core/src/client/org/index.ts +9 -0
  21. package/corpus/core/src/client/transcription/use-live-transcription.ts +62 -10
  22. package/corpus/core/src/db/client.ts +42 -3
  23. package/corpus/core/src/db/ensure-additive-columns.ts +60 -33
  24. package/corpus/core/src/deploy/build.ts +31 -2
  25. package/corpus/core/src/mcp-client/routes.ts +10 -1
  26. package/corpus/core/src/org/app-roles-handlers.ts +152 -0
  27. package/corpus/core/src/org/app-roles.ts +355 -0
  28. package/corpus/core/src/org/index.ts +27 -1
  29. package/corpus/core/src/org/migrations.ts +22 -0
  30. package/corpus/core/src/org/plugin.ts +27 -0
  31. package/corpus/core/src/org/schema.ts +15 -0
  32. package/corpus/core/src/scripts/docs/search.ts +17 -0
  33. package/corpus/core/src/scripts/docs/source-search.ts +10 -0
  34. package/corpus/core/src/server/agent-chat/script-entries.ts +3 -0
  35. package/corpus/core/src/server/agent-chat-plugin.ts +53 -52
  36. package/corpus/core/src/server/builder-design-systems.ts +1 -1
  37. package/corpus/core/src/server/core-routes-plugin.ts +6 -1
  38. package/corpus/core/src/server/framework-request-handler.ts +44 -6
  39. package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
  40. package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  41. package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +31 -0
  42. package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  43. package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  44. package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  45. package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  46. package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  47. package/corpus/core/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  48. package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -0
  49. package/corpus/templates/analytics/.agents/skills/security/SKILL.md +31 -0
  50. package/corpus/templates/analytics/.agents/skills/sharing/SKILL.md +4 -0
  51. package/corpus/templates/analytics/actions/data-source-status.ts +21 -12
  52. package/corpus/templates/analytics/app/global.css +7 -7
  53. package/corpus/templates/analytics/app/i18n-data.ts +30 -0
  54. package/corpus/templates/analytics/app/lib/data-source-status.ts +2 -1
  55. package/corpus/templates/analytics/app/pages/DataSources.tsx +54 -10
  56. package/corpus/templates/analytics/changelog/2026-07-28-analytics-pages-load-reliably-with-large-dashboard-workspaces.md +6 -0
  57. package/corpus/templates/analytics/changelog/2026-07-28-dashboard-loading-shimmer-now-flows-smoothly-in-one-directi.md +6 -0
  58. package/corpus/templates/analytics/server/lib/first-party-dashboard-repair.ts +5 -4
  59. package/corpus/templates/analytics/server/plugins/agent-chat.ts +54 -42
  60. package/corpus/templates/analytics/server/plugins/db.ts +1 -18
  61. package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -0
  62. package/corpus/templates/assets/.agents/skills/security/SKILL.md +31 -0
  63. package/corpus/templates/assets/.agents/skills/sharing/SKILL.md +4 -0
  64. package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -0
  65. package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +7 -0
  66. package/corpus/templates/brain/.agents/skills/security/SKILL.md +31 -0
  67. package/corpus/templates/brain/.agents/skills/sharing/SKILL.md +4 -0
  68. package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -0
  69. package/corpus/templates/calendar/.agents/skills/security/SKILL.md +31 -0
  70. package/corpus/templates/calendar/.agents/skills/sharing/SKILL.md +4 -0
  71. package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  72. package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  73. package/corpus/templates/chat/.agents/skills/security/SKILL.md +31 -0
  74. package/corpus/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  75. package/corpus/templates/chat/_gitignore +2 -0
  76. package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -0
  77. package/corpus/templates/clips/.agents/skills/security/SKILL.md +31 -0
  78. package/corpus/templates/clips/actions/request-transcript.ts +77 -11
  79. package/corpus/templates/clips/actions/save-browser-transcript.ts +28 -7
  80. package/corpus/templates/clips/app/routes/record.tsx +11 -3
  81. package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-save-a-truncated-transcript-as-.md +6 -0
  82. package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-stop-transcribing-partway-throu.md +6 -0
  83. package/corpus/templates/clips/changelog/2026-07-28-desktop-full-screen-clips-now-get-an-instant-local-transcrip.md +6 -0
  84. package/corpus/templates/clips/changelog/2026-07-28-long-transcriptions-no-longer-show-a-false-transcription-sto.md +6 -0
  85. package/corpus/templates/clips/changelog/2026-07-28-restarting-for-an-update-now-installs-the-newest-release-ins.md +6 -0
  86. package/corpus/templates/clips/changelog/2026-07-28-the-meeting-recording-pill-now-anchors-to-the-right-edge-of-.md +6 -0
  87. package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +31 -2
  88. package/corpus/templates/clips/desktop/src/lib/recorder.ts +114 -13
  89. package/corpus/templates/clips/desktop/src/lib/updater.ts +12 -4
  90. package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +40 -15
  91. package/corpus/templates/clips/desktop/src/styles.css +10 -7
  92. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -14
  93. package/corpus/templates/clips/shared/transcript-status.ts +10 -0
  94. package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -0
  95. package/corpus/templates/content/.agents/skills/security/SKILL.md +31 -0
  96. package/corpus/templates/content/.agents/skills/sharing/SKILL.md +4 -0
  97. package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +4 -0
  98. package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -0
  99. package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +23 -0
  100. package/corpus/templates/design/.agents/skills/security/SKILL.md +31 -0
  101. package/corpus/templates/design/.agents/skills/sharing/SKILL.md +4 -0
  102. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +46 -3
  103. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +7 -5
  104. package/corpus/templates/design/actions/create-file.ts +15 -0
  105. package/corpus/templates/design/actions/generate-design.ts +40 -0
  106. package/corpus/templates/design/actions/present-design-variants.ts +16 -0
  107. package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
  108. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -4
  109. package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +1 -1
  110. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +10 -4
  111. package/corpus/templates/design/app/lib/design-ui-events.ts +5 -0
  112. package/corpus/templates/design/app/pages/design-editor/save-failure.ts +7 -1
  113. package/corpus/templates/design/app/root.tsx +18 -1
  114. package/corpus/templates/design/changelog/2026-07-28-generated-designs-with-malformed-html-are-now-rejected-at-sa.md +6 -0
  115. package/corpus/templates/design/changelog/2026-07-28-show-or-hide-design-editing-chrome-with-cmd-on-apple-devices.md +6 -0
  116. package/corpus/templates/design/server/source-workspace.ts +1 -0
  117. package/corpus/templates/design/shared/html-integrity.ts +608 -18
  118. package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -0
  119. package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +31 -0
  120. package/corpus/templates/dispatch/.agents/skills/sharing/SKILL.md +4 -0
  121. package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -0
  122. package/corpus/templates/forms/.agents/skills/security/SKILL.md +31 -0
  123. package/corpus/templates/forms/.agents/skills/sharing/SKILL.md +4 -0
  124. package/corpus/templates/macros/.agents/skills/security/SKILL.md +31 -0
  125. package/corpus/templates/macros/.agents/skills/sharing/SKILL.md +4 -0
  126. package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -0
  127. package/corpus/templates/mail/.agents/skills/security/SKILL.md +31 -0
  128. package/corpus/templates/mail/.agents/skills/sharing/SKILL.md +4 -0
  129. package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -0
  130. package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +7 -0
  131. package/corpus/templates/plan/.agents/skills/security/SKILL.md +31 -0
  132. package/corpus/templates/plan/.agents/skills/sharing/SKILL.md +4 -0
  133. package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -0
  134. package/corpus/templates/slides/.agents/skills/security/SKILL.md +31 -0
  135. package/corpus/templates/slides/.agents/skills/sharing/SKILL.md +4 -0
  136. package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -6
  137. package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -0
  138. package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +7 -0
  139. package/corpus/templates/tasks/.agents/skills/security/SKILL.md +31 -0
  140. package/corpus/templates/tasks/.agents/skills/sharing/SKILL.md +4 -0
  141. package/dist/a2a/artifact-response.d.ts.map +1 -1
  142. package/dist/a2a/artifact-response.js +30 -29
  143. package/dist/a2a/artifact-response.js.map +1 -1
  144. package/dist/action.d.ts +36 -0
  145. package/dist/action.d.ts.map +1 -1
  146. package/dist/action.js +37 -2
  147. package/dist/action.js.map +1 -1
  148. package/dist/chat-threads/store.d.ts +12 -0
  149. package/dist/chat-threads/store.d.ts.map +1 -1
  150. package/dist/chat-threads/store.js +48 -42
  151. package/dist/chat-threads/store.js.map +1 -1
  152. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
  153. package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
  154. package/dist/cli/skills-content/design-visual-edit-skill.js +46 -3
  155. package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
  156. package/dist/cli/template-sync.d.ts.map +1 -1
  157. package/dist/cli/template-sync.js +88 -0
  158. package/dist/cli/template-sync.js.map +1 -1
  159. package/dist/client/AgentPanel.d.ts +3 -1
  160. package/dist/client/AgentPanel.d.ts.map +1 -1
  161. package/dist/client/AgentPanel.js +11 -9
  162. package/dist/client/AgentPanel.js.map +1 -1
  163. package/dist/client/AssistantChat.d.ts.map +1 -1
  164. package/dist/client/AssistantChat.js +57 -6
  165. package/dist/client/AssistantChat.js.map +1 -1
  166. package/dist/client/DefaultSpinner.d.ts +7 -0
  167. package/dist/client/DefaultSpinner.d.ts.map +1 -1
  168. package/dist/client/DefaultSpinner.js +25 -1
  169. package/dist/client/DefaultSpinner.js.map +1 -1
  170. package/dist/client/org/TeamPage.d.ts +13 -1
  171. package/dist/client/org/TeamPage.d.ts.map +1 -1
  172. package/dist/client/org/TeamPage.js +41 -11
  173. package/dist/client/org/TeamPage.js.map +1 -1
  174. package/dist/client/org/hooks.d.ts +37 -0
  175. package/dist/client/org/hooks.d.ts.map +1 -1
  176. package/dist/client/org/hooks.js +37 -0
  177. package/dist/client/org/hooks.js.map +1 -1
  178. package/dist/client/org/index.d.ts +3 -2
  179. package/dist/client/org/index.d.ts.map +1 -1
  180. package/dist/client/org/index.js +1 -1
  181. package/dist/client/org/index.js.map +1 -1
  182. package/dist/client/transcription/use-live-transcription.d.ts +8 -0
  183. package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
  184. package/dist/client/transcription/use-live-transcription.js +38 -11
  185. package/dist/client/transcription/use-live-transcription.js.map +1 -1
  186. package/dist/collab/routes.d.ts +1 -1
  187. package/dist/collab/struct-routes.d.ts +1 -1
  188. package/dist/db/client.d.ts +12 -0
  189. package/dist/db/client.d.ts.map +1 -1
  190. package/dist/db/client.js +40 -3
  191. package/dist/db/client.js.map +1 -1
  192. package/dist/db/ensure-additive-columns.d.ts.map +1 -1
  193. package/dist/db/ensure-additive-columns.js +54 -32
  194. package/dist/db/ensure-additive-columns.js.map +1 -1
  195. package/dist/deploy/build.d.ts +1 -0
  196. package/dist/deploy/build.d.ts.map +1 -1
  197. package/dist/deploy/build.js +23 -2
  198. package/dist/deploy/build.js.map +1 -1
  199. package/dist/mcp-client/routes.d.ts +3 -1
  200. package/dist/mcp-client/routes.d.ts.map +1 -1
  201. package/dist/mcp-client/routes.js +8 -2
  202. package/dist/mcp-client/routes.js.map +1 -1
  203. package/dist/notifications/routes.d.ts +1 -1
  204. package/dist/observability/routes.d.ts +3 -3
  205. package/dist/org/app-roles-handlers.d.ts +27 -0
  206. package/dist/org/app-roles-handlers.d.ts.map +1 -0
  207. package/dist/org/app-roles-handlers.js +125 -0
  208. package/dist/org/app-roles-handlers.js.map +1 -0
  209. package/dist/org/app-roles.d.ts +136 -0
  210. package/dist/org/app-roles.d.ts.map +1 -0
  211. package/dist/org/app-roles.js +216 -0
  212. package/dist/org/app-roles.js.map +1 -0
  213. package/dist/org/index.d.ts +4 -1
  214. package/dist/org/index.d.ts.map +1 -1
  215. package/dist/org/index.js +3 -1
  216. package/dist/org/index.js.map +1 -1
  217. package/dist/org/migrations.d.ts.map +1 -1
  218. package/dist/org/migrations.js +22 -0
  219. package/dist/org/migrations.js.map +1 -1
  220. package/dist/org/plugin.d.ts +2 -0
  221. package/dist/org/plugin.d.ts.map +1 -1
  222. package/dist/org/plugin.js +20 -0
  223. package/dist/org/plugin.js.map +1 -1
  224. package/dist/org/schema.d.ts +143 -0
  225. package/dist/org/schema.d.ts.map +1 -1
  226. package/dist/org/schema.js +14 -0
  227. package/dist/org/schema.js.map +1 -1
  228. package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
  229. package/dist/provider-api/actions/provider-api.d.ts +12 -12
  230. package/dist/resources/handlers.d.ts +1 -1
  231. package/dist/scripts/docs/search.d.ts.map +1 -1
  232. package/dist/scripts/docs/search.js +15 -0
  233. package/dist/scripts/docs/search.js.map +1 -1
  234. package/dist/scripts/docs/source-search.d.ts +7 -0
  235. package/dist/scripts/docs/source-search.d.ts.map +1 -1
  236. package/dist/scripts/docs/source-search.js +9 -0
  237. package/dist/scripts/docs/source-search.js.map +1 -1
  238. package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
  239. package/dist/server/agent-chat/script-entries.js +3 -0
  240. package/dist/server/agent-chat/script-entries.js.map +1 -1
  241. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  242. package/dist/server/agent-chat-plugin.js +46 -48
  243. package/dist/server/agent-chat-plugin.js.map +1 -1
  244. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  245. package/dist/server/builder-design-systems.js +1 -1
  246. package/dist/server/builder-design-systems.js.map +1 -1
  247. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  248. package/dist/server/core-routes-plugin.js +6 -1
  249. package/dist/server/core-routes-plugin.js.map +1 -1
  250. package/dist/server/framework-request-handler.d.ts.map +1 -1
  251. package/dist/server/framework-request-handler.js +42 -6
  252. package/dist/server/framework-request-handler.js.map +1 -1
  253. package/dist/server/transcribe-voice.d.ts +1 -1
  254. package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  255. package/dist/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  256. package/dist/templates/chat/.agents/skills/security/SKILL.md +31 -0
  257. package/dist/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  258. package/dist/templates/chat/_gitignore +2 -0
  259. package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -0
  260. package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  261. package/dist/templates/default/.agents/skills/security/SKILL.md +31 -0
  262. package/dist/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  263. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  264. package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  265. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  266. package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  267. package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  268. package/docs/content/actions.mdx +47 -4
  269. package/docs/content/native-chat-ui.mdx +7 -0
  270. package/docs/content/organizations-teams-permissions.mdx +109 -3
  271. package/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
  272. package/docs/content/toolkit-org-team.mdx +72 -12
  273. package/package.json +1 -1
  274. package/src/a2a/artifact-response.ts +36 -29
  275. package/src/action.ts +83 -2
  276. package/src/chat-threads/store.ts +48 -43
  277. package/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
  278. package/src/cli/template-sync.ts +96 -0
  279. package/src/client/AgentPanel.tsx +26 -6
  280. package/src/client/AssistantChat.tsx +63 -7
  281. package/src/client/DefaultSpinner.tsx +29 -0
  282. package/src/client/org/TeamPage.tsx +161 -6
  283. package/src/client/org/hooks.ts +67 -0
  284. package/src/client/org/index.ts +9 -0
  285. package/src/client/transcription/use-live-transcription.ts +62 -10
  286. package/src/db/client.ts +42 -3
  287. package/src/db/ensure-additive-columns.ts +60 -33
  288. package/src/deploy/build.ts +31 -2
  289. package/src/mcp-client/routes.ts +10 -1
  290. package/src/org/app-roles-handlers.ts +152 -0
  291. package/src/org/app-roles.ts +355 -0
  292. package/src/org/index.ts +27 -1
  293. package/src/org/migrations.ts +22 -0
  294. package/src/org/plugin.ts +27 -0
  295. package/src/org/schema.ts +15 -0
  296. package/src/scripts/docs/search.ts +17 -0
  297. package/src/scripts/docs/source-search.ts +10 -0
  298. package/src/server/agent-chat/script-entries.ts +3 -0
  299. package/src/server/agent-chat-plugin.ts +53 -52
  300. package/src/server/builder-design-systems.ts +1 -1
  301. package/src/server/core-routes-plugin.ts +6 -1
  302. package/src/server/framework-request-handler.ts +44 -6
  303. package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  304. package/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  305. package/src/templates/chat/.agents/skills/security/SKILL.md +31 -0
  306. package/src/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  307. package/src/templates/chat/_gitignore +2 -0
  308. package/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
  309. package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  310. package/src/templates/default/.agents/skills/security/SKILL.md +31 -0
  311. package/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  312. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  313. package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  314. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  315. package/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  316. package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  317. package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +0 -530
  318. package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +0 -191
  319. package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +0 -115
  320. package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
  321. package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +0 -89
  322. package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +0 -221
  323. package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +0 -220
  324. package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +0 -263
  325. package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +0 -169
  326. package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +0 -174
  327. package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +0 -232
  328. package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +0 -282
  329. package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +0 -119
  330. package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +0 -123
  331. package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +0 -122
  332. package/corpus/core/src/templates/chat/.env.example +0 -5
  333. package/corpus/core/src/templates/chat/.ignore +0 -0
  334. package/corpus/core/src/templates/chat/.oxfmtrc.json +0 -8
  335. package/corpus/core/src/templates/chat/AGENTS.md +0 -77
  336. package/corpus/core/src/templates/chat/CHANGELOG.md +0 -10
  337. package/corpus/core/src/templates/chat/DEVELOPING.md +0 -185
  338. package/corpus/core/src/templates/chat/README.md +0 -32
  339. package/corpus/core/src/templates/chat/_gitignore +0 -44
  340. package/corpus/core/src/templates/chat/actions/hello.ts +0 -13
  341. package/corpus/core/src/templates/chat/actions/navigate.ts +0 -41
  342. package/corpus/core/src/templates/chat/actions/run.ts +0 -2
  343. package/corpus/core/src/templates/chat/actions/view-screen.ts +0 -31
  344. package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +0 -60
  345. package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +0 -188
  346. package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +0 -505
  347. package/corpus/core/src/templates/chat/app/components/ui/button.tsx +0 -1
  348. package/corpus/core/src/templates/chat/app/components/ui/card.tsx +0 -1
  349. package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +0 -1
  350. package/corpus/core/src/templates/chat/app/components/ui/input.tsx +0 -1
  351. package/corpus/core/src/templates/chat/app/components/ui/label.tsx +0 -1
  352. package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +0 -1
  353. package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +0 -17
  354. package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +0 -1
  355. package/corpus/core/src/templates/chat/app/design-system.ts +0 -3
  356. package/corpus/core/src/templates/chat/app/entry.client.tsx +0 -22
  357. package/corpus/core/src/templates/chat/app/entry.server.tsx +0 -10
  358. package/corpus/core/src/templates/chat/app/global.css +0 -93
  359. package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +0 -93
  360. package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +0 -68
  361. package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +0 -71
  362. package/corpus/core/src/templates/chat/app/i18n/en-US.ts +0 -70
  363. package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +0 -71
  364. package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +0 -71
  365. package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +0 -69
  366. package/corpus/core/src/templates/chat/app/i18n/index.ts +0 -34
  367. package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +0 -70
  368. package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +0 -70
  369. package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +0 -71
  370. package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +0 -66
  371. package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +0 -66
  372. package/corpus/core/src/templates/chat/app/i18n-data.ts +0 -556
  373. package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +0 -49
  374. package/corpus/core/src/templates/chat/app/lib/app-config.ts +0 -11
  375. package/corpus/core/src/templates/chat/app/lib/tab-id.ts +0 -1
  376. package/corpus/core/src/templates/chat/app/lib/utils.ts +0 -1
  377. package/corpus/core/src/templates/chat/app/root.tsx +0 -173
  378. package/corpus/core/src/templates/chat/app/routes/_index.tsx +0 -94
  379. package/corpus/core/src/templates/chat/app/routes/agent.tsx +0 -24
  380. package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +0 -1
  381. package/corpus/core/src/templates/chat/app/routes/database.tsx +0 -17
  382. package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +0 -2
  383. package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +0 -11
  384. package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +0 -11
  385. package/corpus/core/src/templates/chat/app/routes/extensions.tsx +0 -5
  386. package/corpus/core/src/templates/chat/app/routes/observability.tsx +0 -19
  387. package/corpus/core/src/templates/chat/app/routes/settings.tsx +0 -89
  388. package/corpus/core/src/templates/chat/app/routes/team.tsx +0 -11
  389. package/corpus/core/src/templates/chat/app/routes.ts +0 -4
  390. package/corpus/core/src/templates/chat/app/vite-env.d.ts +0 -6
  391. package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +0 -6
  392. package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +0 -6
  393. package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +0 -6
  394. package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +0 -6
  395. package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +0 -6
  396. package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +0 -5
  397. package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +0 -6
  398. package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +0 -6
  399. package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +0 -6
  400. package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +0 -6
  401. package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +0 -6
  402. package/corpus/core/src/templates/chat/changelog/2026-07-17-the-agent-chat-sidebar-stays-closed-until-you-open-it-or-sta.md +0 -6
  403. package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +0 -6
  404. package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
  405. package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +0 -6
  406. package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +0 -6
  407. package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +0 -6
  408. package/corpus/core/src/templates/chat/changelog/2026-07-24-borderless-secondary-surfaces.md +0 -6
  409. package/corpus/core/src/templates/chat/changelog/2026-07-24-sidebar-footer-controls-follow-a-consistent-order.md +0 -6
  410. package/corpus/core/src/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +0 -6
  411. package/corpus/core/src/templates/chat/components.json +0 -20
  412. package/corpus/core/src/templates/chat/learnings.defaults.md +0 -5
  413. package/corpus/core/src/templates/chat/netlify.toml +0 -11
  414. package/corpus/core/src/templates/chat/package.json +0 -92
  415. package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +0 -10
  416. package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +0 -10
  417. package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +0 -21
  418. package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +0 -21
  419. package/corpus/core/src/templates/chat/public/favicon.svg +0 -1
  420. package/corpus/core/src/templates/chat/public/icon-180.svg +0 -1
  421. package/corpus/core/src/templates/chat/public/icon-192.svg +0 -1
  422. package/corpus/core/src/templates/chat/public/icon-512.svg +0 -1
  423. package/corpus/core/src/templates/chat/public/manifest.json +0 -21
  424. package/corpus/core/src/templates/chat/react-router.config.ts +0 -7
  425. package/corpus/core/src/templates/chat/server/middleware/auth.ts +0 -15
  426. package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +0 -21
  427. package/corpus/core/src/templates/chat/server/plugins/auth.ts +0 -17
  428. package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +0 -5
  429. package/corpus/core/src/templates/chat/ssr-entry.ts +0 -15
  430. package/corpus/core/src/templates/chat/tsconfig.json +0 -21
  431. package/corpus/core/src/templates/chat/vite.config.ts +0 -19
@@ -1 +1 @@
1
- {"version":3,"file":"framework-request-handler.d.ts","sourceRoot":"","sources":["../../src/server/framework-request-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,IAAI,CAAC;AAoBhD,QAAA,MAAM,gBAAgB,mBAAmB,CAAC;AAoD1C;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC/C,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,SAAS,CA6GjD;AA2ED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjE;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACjC,IAAI,CAuCN;AA6FD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAqBf;AA2TD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,CAyBd;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"framework-request-handler.d.ts","sourceRoot":"","sources":["../../src/server/framework-request-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,YAAY,EAAW,MAAM,IAAI,CAAC;AAoBhD,QAAA,MAAM,gBAAgB,mBAAmB,CAAC;AAoD1C;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC/C,GAAG,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,SAAS,CA6GjD;AA2ED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjE;AA+CD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACjC,IAAI,CAuCN;AAuGD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAqBf;AA2TD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,GAAG,CAAC,CAyBd;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -264,11 +264,40 @@ export async function awaitBootstrap(nitroApp) {
264
264
  */
265
265
  async function awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath) {
266
266
  if (!nitroApp)
267
- return;
268
- const bootstrapPromise = nitroApp[BOOTSTRAP_PROMISE_KEY];
269
- if (bootstrapPromise)
270
- await bootstrapPromise;
271
- await awaitPluginsReady(nitroApp, reqPath);
267
+ return true;
268
+ let timer;
269
+ try {
270
+ return await Promise.race([
271
+ (async () => {
272
+ const bootstrapPromise = nitroApp[BOOTSTRAP_PROMISE_KEY];
273
+ if (bootstrapPromise)
274
+ await bootstrapPromise;
275
+ await awaitPluginsReady(nitroApp, reqPath);
276
+ return true;
277
+ })(),
278
+ new Promise((resolve) => {
279
+ timer = setTimeout(() => resolve(false), frameworkReadyDeadlineMs());
280
+ }),
281
+ ]);
282
+ }
283
+ finally {
284
+ if (timer)
285
+ clearTimeout(timer);
286
+ }
287
+ }
288
+ /**
289
+ * Cap on how long a request may be held waiting for framework routes.
290
+ *
291
+ * Holding past the platform's own request wall is pure loss: the serverless
292
+ * gateway kills the invocation and the client gets a bare 502/504 it cannot
293
+ * act on. Releasing first lets the placeholder answer with a retryable 503.
294
+ * Keep this BELOW the shortest deployment target's request wall (Netlify
295
+ * synchronous functions cut off around 40s regardless of a higher configured
296
+ * `timeout`).
297
+ */
298
+ function frameworkReadyDeadlineMs() {
299
+ const raw = Number(process.env.AGENT_NATIVE_ROUTE_READY_TIMEOUT_MS);
300
+ return Number.isFinite(raw) && raw > 0 ? raw : 25_000;
272
301
  }
273
302
  /**
274
303
  * Track an async plugin's initialization promise. Nitro v3 calls plugins
@@ -329,7 +358,14 @@ function installPluginReadyPlaceholders(nitroApp, paths) {
329
358
  registerMiddleware(nitroApp, path, (async (event) => {
330
359
  const eventAny = event;
331
360
  const reqPath = eventAny.context?._mountedPathname ?? event.url?.pathname ?? path;
332
- await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);
361
+ const ready = await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);
362
+ if (!ready) {
363
+ // Boot is still running and we are out of budget. Answer now, while
364
+ // the gateway is still listening, rather than being killed mid-wait.
365
+ setResponseStatus(event, 503);
366
+ setResponseHeader(event, "retry-after", "5");
367
+ return { error: "agent-native routes are still initializing" };
368
+ }
333
369
  // If this plugin's async init failed, its real route was never
334
370
  // registered. Return a retryable 503 instead of releasing into a bare
335
371
  // 404 (external MCP clients can't recover from a 404; a 503 is at least
@@ -1 +1 @@
1
- {"version":3,"file":"framework-request-handler.js","sourceRoot":"","sources":["../../src/server/framework-request-handler.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,C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;QACX,QAAQ,GAAG,CAAC,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;QACvC,sEAAsE;QACtE,wEAAwE;QACxE,mCAAmC;QACnC,MAAM,MAAM,GAAG,aAAa,CAC1B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CACtC,CAAC,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,SAAS,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,OAAO,EAAE,CAAC;QACjB,wEAAwE;QACxE,8DAA8D;QAC9D,MAAM,QAAQ,IAAI,OAAO,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["/**\n * Framework request handler — registers framework routes on Nitro's h3 instance.\n *\n * Nitro 3 exposes its h3 app as `nitroApp.h3`. We register framework routes\n * directly on it as middleware (`nitroApp.h3[\"~middleware\"]`), giving each\n * plugin a path-prefix-matched handler that runs before any file-based route.\n *\n * Plugins call `getH3App(nitroApp).use(path, handler)` exactly like h3 v1's\n * `app.use()` — the wrapper translates that into v2 middleware registration.\n *\n * Default plugins that the template doesn't provide are auto-mounted on the\n * first call to `getH3App()` per nitroApp instance.\n */\nimport type { EventHandler, H3Event } from \"h3\";\nimport { setResponseHeader, setResponseStatus } from \"h3\";\n\nimport { getMissingDefaultPlugins } from \"../deploy/route-discovery.js\";\nimport { MCP_PUBLIC_ROUTE_PREFIX } from \"../mcp/route-paths.js\";\nimport { getConfiguredAppBasePath } from \"./app-base-path.js\";\nimport { captureError } from \"./capture-error.js\";\nimport { createCsrfMiddleware } from \"./csrf.js\";\nimport {\n installHttpResponseTelemetryHooks,\n recordFrameworkReadyWait,\n} from \"./http-response-telemetry.js\";\nimport {\n hasRequestContext,\n markRequestBoundaryInstalled,\n runWithRequestContext,\n} from \"./request-context.js\";\n\nconst BOOTSTRAPPED = new WeakSet<object>();\nconst IN_BOOTSTRAP = new WeakSet<object>();\nconst FRAMEWORK_PREFIX = \"/_agent-native\";\nconst WELL_KNOWN_PREFIX = \"/.well-known\";\nconst APP_SHIM_KEY = \"_agentNativeH3Shim\";\nconst BOOTSTRAP_PROMISE_KEY = \"_agentNativeBootstrapPromise\";\nconst PLUGIN_READY_KEY = \"_agentNativePluginReadyPromise\";\nconst PLUGIN_READY_PLACEHOLDERS_KEY = \"_agentNativePluginReadyPlaceholders\";\nconst PLUGIN_FAILED_KEY = \"_agentNativePluginInitFailures\";\nconst PROVIDED_PLUGIN_STEMS_KEY = \"_agentNativeProvidedPluginStems\";\nconst MIDDLEWARE_DISPATCHER_PATCHED_KEY =\n \"_agentNativeMiddlewareDispatcherPatched\";\nconst REQUEST_CONTEXT_BOUNDARY_KEY = \"_agentNativeRequestContextBoundary\";\n\ninterface PluginReadyEntry {\n promise: Promise<void>;\n paths?: string[];\n}\n\nfunction getAppBasePath(): string {\n return getConfiguredAppBasePath();\n}\n\nfunction pathMatchesPrefix(reqPath: string, prefix: string): boolean {\n return reqPath === prefix || reqPath.startsWith(prefix + \"/\");\n}\n\nfunction supportsAppBasePathMount(path: string): boolean {\n return (\n pathMatchesPrefix(path, FRAMEWORK_PREFIX) ||\n pathMatchesPrefix(path, WELL_KNOWN_PREFIX) ||\n pathMatchesPrefix(path, MCP_PUBLIC_ROUTE_PREFIX)\n );\n}\n\nfunction resolveMountMatch(\n reqPath: string,\n path: string,\n): { mountPath: string; strippedPath: string } | null {\n if (pathMatchesPrefix(reqPath, path)) {\n return { mountPath: path, strippedPath: reqPath.slice(path.length) || \"/\" };\n }\n\n const appBasePath = getAppBasePath();\n if (!appBasePath || !supportsAppBasePathMount(path)) return null;\n\n const prefixedPath = `${appBasePath}${path}`;\n if (!pathMatchesPrefix(reqPath, prefixedPath)) return null;\n return {\n mountPath: prefixedPath,\n strippedPath: reqPath.slice(prefixedPath.length) || \"/\",\n };\n}\n\n/**\n * Wrapper around Nitro's h3 instance that exposes a v1-style `.use()` API\n * for registering path-prefix middleware.\n */\nexport interface H3AppShim {\n use(path: string, handler: EventHandler): void;\n use(handler: EventHandler): void;\n}\n\n/**\n * Mark a default plugin slot as supplied by the app/template before the\n * framework default bootstrap runs.\n *\n * Bundled serverless functions often don't have the original\n * `server/plugins/*.ts` tree on disk at runtime, so filesystem route discovery\n * can falsely conclude a template plugin is missing. Explicit plugin factories\n * call this synchronously before awaiting bootstrap so the framework does not\n * auto-mount a generic default over the app's custom implementation.\n */\nexport function markDefaultPluginProvided(nitroApp: any, stem: string): void {\n if (!nitroApp || !stem) return;\n const existing = nitroApp[PROVIDED_PLUGIN_STEMS_KEY] as\n | Set<string>\n | undefined;\n const provided = existing ?? new Set<string>();\n provided.add(stem);\n nitroApp[PROVIDED_PLUGIN_STEMS_KEY] = provided;\n}\n\n/**\n * Get (or create) the shared H3 app wrapper for a nitroApp. Plugins use this\n * to register routes via `.use(path, handler)`.\n *\n * On the first call per nitroApp, we kick off auto-mounting any missing\n * default plugins. User-facing plugin factories (createAgentChatPlugin,\n * createAuthPlugin, etc.) await this bootstrap via `awaitBootstrap()` so the\n * default plugins finish registering middleware before requests arrive.\n */\nexport function getH3App(nitroApp: any): H3AppShim {\n if (!nitroApp) throw new Error(\"getH3App: nitroApp is required\");\n ensureGlobalMiddlewareDispatch(nitroApp);\n installHttpResponseTelemetryHooks(nitroApp);\n\n // Reuse the cached shim if we've wrapped this nitroApp before\n const cached = nitroApp[APP_SHIM_KEY] as H3AppShim | undefined;\n if (cached) return cached;\n\n const shim: H3AppShim = {\n use(arg1: string | EventHandler, arg2?: EventHandler) {\n const path = typeof arg1 === \"string\" ? arg1 : \"\";\n const handler = (typeof arg1 === \"string\" ? arg2 : arg1) as EventHandler;\n if (typeof handler !== \"function\") {\n throw new Error(\"getH3App.use: handler must be a function\");\n }\n registerMiddleware(nitroApp, path, handler);\n },\n };\n\n nitroApp[APP_SHIM_KEY] = shim;\n\n if (!BOOTSTRAPPED.has(nitroApp)) {\n BOOTSTRAPPED.add(nitroApp);\n nitroApp[BOOTSTRAP_PROMISE_KEY] = bootstrapDefaultPlugins(nitroApp).catch(\n (err) => {\n console.warn(\n \"[agent-native] Failed to auto-mount default plugins:\",\n (err as Error).message,\n );\n captureError(err, {\n route: \"default-plugin-bootstrap\",\n tags: { phase: \"default-plugin-bootstrap\" },\n });\n },\n );\n\n // Readiness gate: Nitro v3 doesn't await async plugins, so routes\n // registered inside an async plugin may not exist when the first\n // request arrives. These middleware entries hold framework routes\n // until default-plugin bootstrap and tracked plugin inits complete.\n const readinessGate = (async (event: H3Event) => {\n const eventAny = event as any;\n await awaitFrameworkRoutesReadyForRequest(\n nitroApp,\n eventAny.context?._mountedPathname ?? event.url?.pathname ?? \"\",\n );\n // Fall through — the actual route handler runs next.\n return undefined;\n }) as EventHandler;\n registerMiddleware(nitroApp, FRAMEWORK_PREFIX, readinessGate, {\n prepend: true,\n });\n registerMiddleware(nitroApp, WELL_KNOWN_PREFIX, readinessGate, {\n prepend: true,\n });\n registerMiddleware(nitroApp, MCP_PUBLIC_ROUTE_PREFIX, readinessGate, {\n prepend: true,\n });\n\n // CSRF (see csrf.ts): registered here — synchronously, on the very\n // first `getH3App()` call for this nitroApp — rather than inside\n // createCoreRoutesPlugin's own async init chain. Real deployments mount\n // core-routes and agent-chat as SEPARATE, independently-async-initialized\n // Nitro plugin files with no explicit ordering between them; both\n // eventually call `getH3App(nitroApp).use(...)` to register their own\n // routes (CSRF, action routes) after their own async setup (DB reads,\n // dynamic imports) resolves in unpredictable relative order. The\n // readiness gate above only guarantees every tracked plugin has FINISHED\n // registering by the time a gated request is released — it does NOT\n // guarantee CSRF's registration call happens to `.push()` onto\n // `~middleware` before an action route's does. If agent-chat's action\n // route push happened to land first, that route would match and run\n // before CSRF ever saw the request. Registering CSRF here instead makes\n // it the first non-prepended middleware pushed onto the array for this\n // nitroApp, full stop — every plugin's own route registrations reach\n // `getH3App()` (and therefore run after this point) before they can\n // register anything, regardless of which plugin's async chain resolves\n // first.\n registerMiddleware(nitroApp, \"\", createCsrfMiddleware());\n\n // Registered last so it lands at index 0 — ahead of the readiness gates\n // and CSRF, both of which were unshifted/pushed above.\n registerRequestContextBoundary(nitroApp);\n\n // Primary gate: Nitro bridges this `request` hook to h3's `config.onRequest`,\n // which h3 awaits BEFORE `handler()` snapshots middleware and resolves the\n // route. The middleware gate above runs too late on production dispatchers —\n // its await finishes after the snapshot, so a route registered during async\n // init is missing from the request and 404s. The middleware gate stays as a\n // fallback for runtimes where `onRequest` isn't wired.\n nitroApp.hooks?.hook?.(\"request\", async (event: H3Event) => {\n const reqPath = event.url?.pathname ?? \"\";\n if (\n resolveMountMatch(reqPath, FRAMEWORK_PREFIX) ||\n resolveMountMatch(reqPath, WELL_KNOWN_PREFIX) ||\n resolveMountMatch(reqPath, MCP_PUBLIC_ROUTE_PREFIX)\n ) {\n const startedAt = Date.now();\n try {\n await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);\n } finally {\n recordFrameworkReadyWait(event, Date.now() - startedAt);\n }\n }\n });\n }\n\n return shim;\n}\n\n/**\n * Establish a `RequestContext` for every inbound request, so no HTTP handler\n * ever asks a request-scoped question with no request in scope.\n *\n * Hand-written `/api/*` routes have no ALS store of their own, and\n * `getRequestUserEmail()` used to answer those with `AGENT_USER_EMAIL` — a\n * process-wide ambient identity standing in for the caller, which fails open\n * toward more privilege (an admin gate reading it admits whoever the deploy env\n * names). This store is deliberately identity-free: resolving the session here\n * would mean reading cookies on the SSR path, which must stay one impersonal\n * cached shell. Handlers that do know the caller still nest their own\n * `runWithRequestContext`, which shadows this one.\n *\n * h3 v2 hands middleware a `next()` that returns the result of the rest of the\n * chain (route handler included), so wrapping `next()` puts the whole request\n * inside the ALS scope. It must be `~middleware[0]`; going through\n * `registerMiddleware` is not an option because that adapter hides `next`.\n */\nfunction registerRequestContextBoundary(nitroApp: any): void {\n const h3 = nitroApp?.h3;\n if (!h3 || !Array.isArray(h3[\"~middleware\"])) return;\n if (h3[REQUEST_CONTEXT_BOUNDARY_KEY]) return;\n\n const middleware = (_event: H3Event, next: () => unknown) => {\n if (hasRequestContext()) return next();\n return runWithRequestContext({}, () => next());\n };\n\n h3[REQUEST_CONTEXT_BOUNDARY_KEY] = middleware;\n h3[\"~middleware\"].unshift(middleware);\n markRequestBoundaryInstalled();\n}\n\n/**\n * Nitro 3 production builds generate a route dispatcher by overriding h3's\n * internal `~getMiddleware()` hook. Some generated dispatchers return only\n * route-rule middleware and skip the global `h3[\"~middleware\"]` array that\n * `getH3App().use()` appends to. Wrap the dispatcher once so framework routes\n * registered at runtime are still part of request dispatch.\n */\nfunction ensureGlobalMiddlewareDispatch(nitroApp: any): void {\n const h3 = nitroApp?.h3;\n if (!h3) return;\n const current = h3[\"~getMiddleware\"];\n if (h3[MIDDLEWARE_DISPATCHER_PATCHED_KEY] === current) return;\n\n const original = typeof current === \"function\" ? current.bind(h3) : undefined;\n\n const wrappedGetMiddleware = (event: H3Event, route: unknown) => {\n const originalResult = original ? original(event, route) : [];\n const originalList = Array.isArray(originalResult)\n ? originalResult\n : originalResult\n ? [originalResult]\n : [];\n const globalMiddleware = Array.isArray(h3[\"~middleware\"])\n ? h3[\"~middleware\"]\n : [];\n if (globalMiddleware.length === 0) return originalList;\n\n const alreadyIncluded = new Set(originalList);\n const missingGlobal = globalMiddleware.filter(\n (middleware) => !alreadyIncluded.has(middleware),\n );\n return missingGlobal.length\n ? [...missingGlobal, ...originalList]\n : originalList;\n };\n\n h3[\"~getMiddleware\"] = wrappedGetMiddleware;\n h3[MIDDLEWARE_DISPATCHER_PATCHED_KEY] = wrappedGetMiddleware;\n}\n\n/**\n * Wait for the framework's default-plugin bootstrap to complete.\n *\n * Called by user-facing plugin factories (`createAgentChatPlugin`, etc.) at\n * the top of their plugin function, so that by the time the function returns\n * — and Nitro starts accepting requests — all default plugins have finished\n * registering their middleware.\n *\n * No-op when called from inside the bootstrap itself (avoids deadlock when a\n * default plugin happens to be running as part of bootstrap).\n */\nexport async function awaitBootstrap(nitroApp: any): Promise<void> {\n if (!nitroApp || IN_BOOTSTRAP.has(nitroApp)) return;\n // Trigger bootstrap if it hasn't been already (idempotent — getH3App\n // creates the shim and kicks off bootstrap on first call).\n getH3App(nitroApp);\n const promise = nitroApp[BOOTSTRAP_PROMISE_KEY];\n if (promise) await promise;\n}\n\n/**\n * Wait until framework routes are safe to dispatch.\n *\n * Request-time gates must wait for both phases:\n * 1. default-plugin bootstrap, which discovers and starts missing plugins\n * 2. async plugin init promises, which register routes such as A2A cards\n */\nasync function awaitFrameworkRoutesReadyForRequest(\n nitroApp: any,\n reqPath: string,\n): Promise<void> {\n if (!nitroApp) return;\n const bootstrapPromise = nitroApp[BOOTSTRAP_PROMISE_KEY];\n if (bootstrapPromise) await bootstrapPromise;\n await awaitPluginsReady(nitroApp, reqPath);\n}\n\n/**\n * Track an async plugin's initialization promise. Nitro v3 calls plugins\n * synchronously and doesn't await async return values, so routes registered\n * inside an async plugin may not be ready when the first request arrives.\n *\n * Call this from the TOP of any async plugin so that the readiness gate\n * (installed by getH3App) can hold /_agent-native requests until the plugin\n * finishes mounting its routes.\n */\nexport function trackPluginInit(\n nitroApp: any,\n promise: Promise<void>,\n options: { paths?: string[] } = {},\n): void {\n if (!nitroApp) return;\n // Ensure the readiness gate exists even when the tracked plugin is the first\n // framework code to run in a serverless isolate. Otherwise an immediate\n // first request can fall through before the plugin registers its routes.\n getH3App(nitroApp);\n // Attach a no-op catch so the promise doesn't surface as an unhandled\n // rejection when Nitro v3 drops the async return value. The actual error\n // is still observable when awaitPluginsReady() re-awaits the promise.\n const safe = promise.catch((err) => {\n console.error(\n \"[agent-native] Plugin init failed:\",\n (err as Error).message || err,\n );\n // Record the failure so the readiness gate can return a retryable 503 for\n // this plugin's routes instead of letting them fall through to a bare\n // \"Cannot find any route matching\" 404. That bare 404 is what kept biting\n // external MCP clients (pi/codex/claude) and the connect flow on cold /\n // propagating instances whose async init rejected (e.g. DB not yet\n // reachable): the route never registered, so the placeholder released into\n // a 404 the client couldn't recover from. A 503 is at least retryable.\n const failures = (nitroApp[PLUGIN_FAILED_KEY] ??= new Map<\n string,\n string\n >());\n const msg = (err as Error)?.message || String(err);\n for (const p of options.paths?.filter(Boolean) ?? []) failures.set(p, msg);\n });\n const entry: PluginReadyEntry = {\n promise: safe,\n paths: options.paths?.filter(Boolean),\n };\n const existing = nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined;\n if (existing) {\n existing.push(entry);\n } else {\n nitroApp[PLUGIN_READY_KEY] = [entry];\n }\n installPluginReadyPlaceholders(nitroApp, entry.paths);\n}\n\nfunction installPluginReadyPlaceholders(\n nitroApp: any,\n paths: string[] | undefined,\n): void {\n if (!paths?.length) return;\n const existing = nitroApp[PLUGIN_READY_PLACEHOLDERS_KEY] as\n | Set<string>\n | undefined;\n const installed = existing ?? new Set<string>();\n nitroApp[PLUGIN_READY_PLACEHOLDERS_KEY] = installed;\n\n for (const path of paths) {\n if (!path || installed.has(path)) continue;\n installed.add(path);\n registerMiddleware(\n nitroApp,\n path,\n (async (event: H3Event) => {\n const eventAny = event as any;\n const reqPath =\n eventAny.context?._mountedPathname ?? event.url?.pathname ?? path;\n await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);\n // If this plugin's async init failed, its real route was never\n // registered. Return a retryable 503 instead of releasing into a bare\n // 404 (external MCP clients can't recover from a 404; a 503 is at least\n // a \"try again\" the client / next instance can act on).\n const failures = nitroApp[PLUGIN_FAILED_KEY] as\n | Map<string, string>\n | undefined;\n if (failures?.size) {\n for (const [failedPath, msg] of failures) {\n if (resolveMountMatch(reqPath, failedPath)) {\n setResponseStatus(event, 503);\n setResponseHeader(event, \"retry-after\", \"5\");\n return {\n error: `agent-native route is initializing or unavailable: ${msg}`,\n };\n }\n }\n }\n return undefined;\n }) as EventHandler,\n {\n prepend: true,\n },\n );\n }\n}\n\nfunction logFrameworkRouteError(args: {\n method: string | undefined;\n route: string;\n status: number;\n error: unknown;\n}): void {\n const error = args.error as any;\n const message = error?.message || String(args.error);\n const prefix = `[agent-native] ${args.method ?? \"\"} ${args.route} failed (${args.status})`;\n if (process.env.NODE_ENV === \"production\") {\n console.error(`${prefix}: ${message}`);\n return;\n }\n console.error(`${prefix}: ${message}`, error?.stack || args.error);\n}\n\nfunction isClientAbortError(error: unknown, event: H3Event): boolean {\n const err = error as any;\n const message = typeof err?.message === \"string\" ? err.message : \"\";\n const code = typeof err?.code === \"string\" ? err.code : \"\";\n const node = (event as any).node;\n return (\n message === \"aborted\" ||\n code === \"ECONNRESET\" ||\n node?.req?.destroyed === true ||\n node?.res?.destroyed === true\n );\n}\n\nfunction debugClientAbort(args: {\n method: string | undefined;\n route: string;\n error: unknown;\n}): void {\n if (process.env.NODE_ENV === \"production\") return;\n const err = args.error as any;\n const message = err?.message || String(args.error);\n console.debug?.(\n `[agent-native] ${args.method ?? \"\"} ${args.route} aborted by client: ${message}`,\n );\n}\n\n/**\n * Await all tracked plugin initializations. Called by the readiness gate\n * middleware before dispatching framework routes.\n */\nexport async function awaitPluginsReady(\n nitroApp: any,\n reqPath?: string,\n): Promise<void> {\n const entries = nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined;\n if (!entries?.length) return;\n\n const relevant = reqPath\n ? entries.filter((entry) =>\n entry.paths?.length\n ? entry.paths.some((path) => resolveMountMatch(reqPath, path))\n : true,\n )\n : entries;\n\n if (relevant.length) {\n await Promise.all(relevant.map((entry) => entry.promise));\n const completed = new Set(relevant);\n const latest =\n (nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined) ?? [];\n nitroApp[PLUGIN_READY_KEY] = latest.filter(\n (entry) => !completed.has(entry),\n );\n }\n}\n\n/**\n * Register a path-prefix middleware on Nitro's h3 instance.\n *\n * The middleware:\n * - Returns `next()` (continues) if the request path doesn't match.\n * - Otherwise dispatches to the handler. If the handler returns a value,\n * it short-circuits the request. If it returns undefined, next() runs.\n *\n * Path matching emulates h3 v1's `app.use(path, ...)` behavior:\n * - Exact-match prefix: `/foo` matches `/foo`, `/foo/bar`, but not `/foobar`\n * - Empty path: middleware runs on every request\n */\nfunction registerMiddleware(\n nitroApp: any,\n path: string,\n handler: EventHandler,\n options: { prepend?: boolean } = {},\n) {\n const h3 = nitroApp.h3;\n if (!h3 || !Array.isArray(h3[\"~middleware\"])) {\n throw new Error(\n \"[agent-native] Cannot register route: nitroApp.h3 is not available. \" +\n \"Make sure you're calling getH3App() from inside a Nitro plugin.\",\n );\n }\n\n const middleware = async (event: H3Event, next: () => any) => {\n let originalPathname: string | undefined;\n let originalEventPath: string | undefined;\n let hadEventPath = false;\n // Only true once this specific middleware invocation has actually\n // stripped a mount prefix (i.e. `path` was non-empty and matched).\n // Global (`path === \"\"`) middleware never mutates event.path/pathname,\n // so `restoreOriginalPath` must be a no-op for it — otherwise it would\n // unconditionally `delete event.path` on every pass-through (hadEventPath\n // defaults to false), corrupting the event for any middleware that runs\n // later in the chain (a real bug: two or more global middlewares in\n // sequence, e.g. security-headers + CORS + CSRF, would wipe event.path\n // for everything downstream, including the final route handler).\n let didStripPath = false;\n const restoreOriginalPath = () => {\n if (!didStripPath) return;\n if (originalPathname !== undefined) {\n try {\n event.url.pathname = originalPathname;\n } catch {\n // ignore\n }\n originalPathname = undefined;\n }\n if (hadEventPath) {\n try {\n (event as any).path = originalEventPath;\n } catch {\n // ignore\n }\n } else {\n try {\n delete (event as any).path;\n } catch {\n // ignore\n }\n }\n };\n if (path) {\n const reqPath = event.url?.pathname ?? \"\";\n const match = resolveMountMatch(reqPath, path);\n if (!match) {\n return next();\n }\n // Strip the mount prefix from event.url.pathname so handlers that\n // dispatch sub-routes can read `event.path` (or `event.url.pathname`)\n // and see the path RELATIVE to their mount point — matching h3 v1's\n // `app.use(path, handler)` semantics.\n const eventAny = event as any;\n hadEventPath = \"path\" in eventAny;\n originalEventPath = eventAny.path;\n didStripPath = true;\n try {\n originalPathname = event.url.pathname;\n // Save the full path in context so handlers that need the original URL\n // (e.g. Better Auth, which extracts its own basePath prefix) can\n // reconstruct a Request with the un-stripped URL.\n eventAny.context = eventAny.context ?? {};\n eventAny.context._mountedPathname = originalPathname;\n eventAny.context._mountPrefix = match.mountPath;\n event.url.pathname = match.strippedPath;\n eventAny.path = `${match.strippedPath}${event.url.search || \"\"}`;\n } catch {\n // event.url is read-only on some runtimes — fall through. Handlers\n // that don't depend on prefix stripping (most of them) still work.\n }\n }\n try {\n const result = await handler(event);\n if (result === undefined) {\n // Restore the original pathname BEFORE calling next() so downstream\n // middleware sees the full URL — not the stripped mount-relative path.\n // Matches h3 v2's own sub-app middleware pattern where the restore\n // happens inside the next() callback, not after it returns.\n restoreOriginalPath();\n return next();\n }\n return result;\n } catch (err) {\n // Log 500s to the server console so they're debuggable, and respond\n // with JSON instead of the default HTML error page so clients can\n // surface error messages. This only applies to routes mounted under\n // the framework prefix (or middleware mounted at `/`, for which we\n // still want visibility).\n const reqPath = originalPathname ?? event.url?.pathname ?? \"\";\n const e = err as any;\n const status =\n typeof e?.statusCode === \"number\"\n ? e.statusCode\n : typeof e?.status === \"number\"\n ? e.status\n : 500;\n if (isClientAbortError(err, event)) {\n debugClientAbort({ method: event.method, route: reqPath, error: err });\n return undefined;\n }\n logFrameworkRouteError({\n method: event.method,\n route: reqPath,\n status,\n error: err,\n });\n // Forward 5xx to the configured server error providers — Nitro's own\n // `error` hook may not fire here because we convert the throw into a\n // normal JSON response, and a console.error alone is invisible in\n // deployed environments. 4xx are user-input errors (validation, auth)\n // and aren't worth alerting on.\n if (status >= 500) {\n captureError(err, {\n route: reqPath,\n method: event.method,\n tags: { status_code: String(status) },\n userAgent: (() => {\n try {\n return event.headers?.get(\"user-agent\") ?? undefined;\n } catch {\n return undefined;\n }\n })(),\n });\n }\n try {\n setResponseStatus(event, status);\n setResponseHeader(event, \"content-type\", \"application/json\");\n } catch {\n // Response already sent — best effort.\n }\n return {\n error: e?.message || \"Internal server error\",\n // Only surface the stack to clients when explicitly enabled.\n // `NODE_ENV !== \"production\"` was unsafe — preview deploys and\n // any host that forgets to set NODE_ENV=production leaked stack\n // traces (file paths, dependency versions, internal route\n // topology) to anonymous callers. Operators who want stacks in\n // dev set `AGENT_NATIVE_DEBUG_ERRORS=1` explicitly.\n ...(status >= 500 &&\n process.env.AGENT_NATIVE_DEBUG_ERRORS === \"1\" &&\n e?.stack\n ? { stack: e.stack }\n : {}),\n };\n } finally {\n // Restore the original pathname so downstream middleware sees the\n // full URL.\n restoreOriginalPath();\n }\n };\n\n if (options.prepend) {\n h3[\"~middleware\"].unshift(middleware);\n } else {\n h3[\"~middleware\"].push(middleware);\n }\n}\n\n/**\n * Auto-mount any default framework plugins that the template doesn't provide.\n *\n * Runs once per nitroApp on the first `getH3App()` call. Uses route-discovery\n * to find which default plugin stems are missing from `server/plugins/`, then\n * dynamically imports and mounts them. If a workspace core is present in the\n * ancestor chain, plugin slots the workspace core exports are mounted from\n * there instead of from @agent-native/core — this is the middle layer of the\n * three-layer inheritance model (app local > workspace core > framework).\n */\nasync function bootstrapDefaultPlugins(nitroApp: any): Promise<void> {\n IN_BOOTSTRAP.add(nitroApp);\n try {\n const cwd = process.cwd();\n const discoveredMissing = await getMissingDefaultPlugins(cwd);\n const provided = nitroApp[PROVIDED_PLUGIN_STEMS_KEY] as\n | Set<string>\n | undefined;\n const missing = provided\n ? discoveredMissing.filter((stem) => !provided.has(stem))\n : discoveredMissing;\n if (missing.length === 0) return;\n\n // Lazy import to avoid circular dependency at module load time\n const serverModule = await import(\"./index.js\");\n const terminalModule = await import(\"../terminal/terminal-plugin.js\");\n const integrationsModule = await import(\"../integrations/plugin.js\");\n const contextXrayModule = await import(\"../agent/context-xray/plugin.js\");\n const observationalMemoryModule =\n await import(\"../agent/observational-memory/plugin.js\");\n const orgModule = await import(\"../org/plugin.js\");\n const onboardingModule = await import(\"../onboarding/plugin.js\");\n\n const frameworkImpls: Record<\n string,\n ((nitroApp: any) => void | Promise<void>) | undefined\n > = {\n \"agent-chat\": (serverModule as any).defaultAgentChatPlugin,\n auth: (serverModule as any).defaultAuthPlugin,\n \"context-xray\": (contextXrayModule as any).defaultContextXrayPlugin,\n \"core-routes\": (serverModule as any).defaultCoreRoutesPlugin,\n integrations: (integrationsModule as any).defaultIntegrationsPlugin,\n \"observational-memory\": (observationalMemoryModule as any)\n .defaultObservationalMemoryPlugin,\n onboarding: (onboardingModule as any).defaultOnboardingPlugin,\n org: (orgModule as any).defaultOrgPlugin,\n resources: (serverModule as any).defaultResourcesPlugin,\n sentry: (serverModule as any).defaultSentryPlugin,\n terminal: (terminalModule as any).defaultTerminalPlugin,\n };\n\n // Workspace core layer: if the app is inside an enterprise monorepo with\n // `agent-native.workspaceCore` configured, pull in any plugin slots the\n // workspace core exports from its server entry. We dynamically import the\n // workspace core package at runtime.\n let workspaceImpls: Record<\n string,\n ((nitroApp: any) => void | Promise<void>) | undefined\n > = {};\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(cwd);\n if (ws && Object.keys(ws.plugins).length > 0) {\n try {\n const wsServerModule = await loadWorkspaceCoreServer(\n ws.packageName,\n ws.packageDir,\n );\n for (const [slot, exportName] of Object.entries(ws.plugins)) {\n if (!exportName) continue;\n const impl = (wsServerModule as any)[exportName];\n if (typeof impl === \"function\") {\n workspaceImpls[slot] = impl;\n }\n }\n if (process.env.DEBUG) {\n console.log(\n `[agent-native] Workspace core ${ws.packageName} provides plugin slots: ${Object.keys(workspaceImpls).join(\", \")}`,\n );\n }\n } catch (e) {\n const msg = (e as Error).message ?? \"\";\n // Common cause: workspace-core's package.json points \"./server\"\n // at a TS source file (the scaffold default), but Node can't\n // resolve relative `.js` imports inside it without a TS loader.\n // Tell the user to compile to dist/ rather than just dumping the\n // raw resolution error.\n const tsLoadHint = /\\.js' imported from .*\\.ts/.test(msg)\n ? \" — workspace-core src is TypeScript but isn't being compiled. \" +\n \"Run `pnpm --filter \" +\n ws.packageName +\n \" build` and point its `./server` export at dist/server/index.js.\"\n : \"\";\n console.warn(\n `[agent-native] Failed to load workspace core ${ws.packageName}/server: ${msg}${tsLoadHint}`,\n );\n }\n }\n } catch {\n // Workspace shared package isn't available (e.g. running on an edge\n // runtime without fs). Silently fall through to framework defaults.\n }\n\n if (process.env.DEBUG)\n console.log(\n `[agent-native] Auto-mounting ${missing.length} default plugin(s): ${missing.join(\", \")}`,\n );\n\n for (const stem of missing) {\n // Prefer workspace-core impl over framework default when both exist.\n const impl = workspaceImpls[stem] ?? frameworkImpls[stem];\n if (typeof impl === \"function\") {\n try {\n await impl(nitroApp);\n } catch (e) {\n console.warn(\n `[agent-native] Failed to auto-mount default plugin ${stem}:`,\n (e as Error).message,\n );\n captureError(e, {\n route: \"default-plugin-bootstrap\",\n tags: { phase: \"default-plugin-bootstrap\", plugin: stem },\n });\n }\n }\n }\n } finally {\n IN_BOOTSTRAP.delete(nitroApp);\n }\n}\n\n/**\n * Load a workspace-core's `/server` entry, transparently handling TS source.\n *\n * The scaffolded workspace-core template ships TS sources without a build\n * step (exports point at `./src/server/index.ts`), so plain `await import()`\n * blows up the moment Node hits a relative `.js` import inside (the standard\n * TS ESM convention) — and even before that, Node may resolve the package\n * relative to the framework's own location rather than the user's monorepo.\n *\n * We try Node's plain `import()` first (fastest path when the user has\n * compiled to dist/) and fall through to jiti on any error. jiti is anchored\n * to a real file inside the workspace-core's directory, so its module\n * resolution starts in the right node_modules tree (handles pnpm hoisting\n * and linked workspaces) AND handles TS source files + `.js` → `.ts` ESM\n * extension remapping.\n *\n * Edge runtimes without `fs` won't be able to load jiti at all; the outer\n * try/catch silently falls through to framework defaults in that case.\n */\nexport async function loadWorkspaceCoreServer(\n packageName: string,\n packageDir: string,\n): Promise<any> {\n let firstErr: unknown;\n try {\n return await import(/* @vite-ignore */ `${packageName}/server`);\n } catch (e) {\n firstErr = e;\n }\n\n try {\n const { createJiti } = await import(\"jiti\");\n const { pathToFileURL } = await import(\"node:url\");\n const path = await import(\"node:path\");\n // Anchor jiti to a real file inside the workspace-core package so its\n // module resolution starts in the right node_modules tree (handles pnpm\n // hoisting and linked workspaces).\n const anchor = pathToFileURL(\n path.join(packageDir, \"package.json\"),\n ).toString();\n const jiti = createJiti(anchor, { interopDefault: true });\n return await jiti.import(`${packageName}/server`);\n } catch (jitiErr) {\n // jiti also failed — rethrow the original Node error since it's usually\n // more informative about *why* the package wasn't resolvable.\n throw firstErr ?? jitiErr;\n }\n}\n\nexport { FRAMEWORK_PREFIX };\n"]}
1
+ {"version":3,"file":"framework-request-handler.js","sourceRoot":"","sources":["../../src/server/framework-request-handler.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,iCAAiC,EACjC,wBAAwB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,YAAY,GAAG,IAAI,OAAO,EAAU,CAAC;AAC3C,MAAM,YAAY,GAAG,IAAI,OAAO,EAAU,CAAC;AAC3C,MAAM,gBAAgB,GAAG,gB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pD,CAAC;IAAC,OAAO,OAAO,EAAE,CAAC;QACjB,wEAAwE;QACxE,8DAA8D;QAC9D,MAAM,QAAQ,IAAI,OAAO,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["/**\n * Framework request handler — registers framework routes on Nitro's h3 instance.\n *\n * Nitro 3 exposes its h3 app as `nitroApp.h3`. We register framework routes\n * directly on it as middleware (`nitroApp.h3[\"~middleware\"]`), giving each\n * plugin a path-prefix-matched handler that runs before any file-based route.\n *\n * Plugins call `getH3App(nitroApp).use(path, handler)` exactly like h3 v1's\n * `app.use()` — the wrapper translates that into v2 middleware registration.\n *\n * Default plugins that the template doesn't provide are auto-mounted on the\n * first call to `getH3App()` per nitroApp instance.\n */\nimport type { EventHandler, H3Event } from \"h3\";\nimport { setResponseHeader, setResponseStatus } from \"h3\";\n\nimport { getMissingDefaultPlugins } from \"../deploy/route-discovery.js\";\nimport { MCP_PUBLIC_ROUTE_PREFIX } from \"../mcp/route-paths.js\";\nimport { getConfiguredAppBasePath } from \"./app-base-path.js\";\nimport { captureError } from \"./capture-error.js\";\nimport { createCsrfMiddleware } from \"./csrf.js\";\nimport {\n installHttpResponseTelemetryHooks,\n recordFrameworkReadyWait,\n} from \"./http-response-telemetry.js\";\nimport {\n hasRequestContext,\n markRequestBoundaryInstalled,\n runWithRequestContext,\n} from \"./request-context.js\";\n\nconst BOOTSTRAPPED = new WeakSet<object>();\nconst IN_BOOTSTRAP = new WeakSet<object>();\nconst FRAMEWORK_PREFIX = \"/_agent-native\";\nconst WELL_KNOWN_PREFIX = \"/.well-known\";\nconst APP_SHIM_KEY = \"_agentNativeH3Shim\";\nconst BOOTSTRAP_PROMISE_KEY = \"_agentNativeBootstrapPromise\";\nconst PLUGIN_READY_KEY = \"_agentNativePluginReadyPromise\";\nconst PLUGIN_READY_PLACEHOLDERS_KEY = \"_agentNativePluginReadyPlaceholders\";\nconst PLUGIN_FAILED_KEY = \"_agentNativePluginInitFailures\";\nconst PROVIDED_PLUGIN_STEMS_KEY = \"_agentNativeProvidedPluginStems\";\nconst MIDDLEWARE_DISPATCHER_PATCHED_KEY =\n \"_agentNativeMiddlewareDispatcherPatched\";\nconst REQUEST_CONTEXT_BOUNDARY_KEY = \"_agentNativeRequestContextBoundary\";\n\ninterface PluginReadyEntry {\n promise: Promise<void>;\n paths?: string[];\n}\n\nfunction getAppBasePath(): string {\n return getConfiguredAppBasePath();\n}\n\nfunction pathMatchesPrefix(reqPath: string, prefix: string): boolean {\n return reqPath === prefix || reqPath.startsWith(prefix + \"/\");\n}\n\nfunction supportsAppBasePathMount(path: string): boolean {\n return (\n pathMatchesPrefix(path, FRAMEWORK_PREFIX) ||\n pathMatchesPrefix(path, WELL_KNOWN_PREFIX) ||\n pathMatchesPrefix(path, MCP_PUBLIC_ROUTE_PREFIX)\n );\n}\n\nfunction resolveMountMatch(\n reqPath: string,\n path: string,\n): { mountPath: string; strippedPath: string } | null {\n if (pathMatchesPrefix(reqPath, path)) {\n return { mountPath: path, strippedPath: reqPath.slice(path.length) || \"/\" };\n }\n\n const appBasePath = getAppBasePath();\n if (!appBasePath || !supportsAppBasePathMount(path)) return null;\n\n const prefixedPath = `${appBasePath}${path}`;\n if (!pathMatchesPrefix(reqPath, prefixedPath)) return null;\n return {\n mountPath: prefixedPath,\n strippedPath: reqPath.slice(prefixedPath.length) || \"/\",\n };\n}\n\n/**\n * Wrapper around Nitro's h3 instance that exposes a v1-style `.use()` API\n * for registering path-prefix middleware.\n */\nexport interface H3AppShim {\n use(path: string, handler: EventHandler): void;\n use(handler: EventHandler): void;\n}\n\n/**\n * Mark a default plugin slot as supplied by the app/template before the\n * framework default bootstrap runs.\n *\n * Bundled serverless functions often don't have the original\n * `server/plugins/*.ts` tree on disk at runtime, so filesystem route discovery\n * can falsely conclude a template plugin is missing. Explicit plugin factories\n * call this synchronously before awaiting bootstrap so the framework does not\n * auto-mount a generic default over the app's custom implementation.\n */\nexport function markDefaultPluginProvided(nitroApp: any, stem: string): void {\n if (!nitroApp || !stem) return;\n const existing = nitroApp[PROVIDED_PLUGIN_STEMS_KEY] as\n | Set<string>\n | undefined;\n const provided = existing ?? new Set<string>();\n provided.add(stem);\n nitroApp[PROVIDED_PLUGIN_STEMS_KEY] = provided;\n}\n\n/**\n * Get (or create) the shared H3 app wrapper for a nitroApp. Plugins use this\n * to register routes via `.use(path, handler)`.\n *\n * On the first call per nitroApp, we kick off auto-mounting any missing\n * default plugins. User-facing plugin factories (createAgentChatPlugin,\n * createAuthPlugin, etc.) await this bootstrap via `awaitBootstrap()` so the\n * default plugins finish registering middleware before requests arrive.\n */\nexport function getH3App(nitroApp: any): H3AppShim {\n if (!nitroApp) throw new Error(\"getH3App: nitroApp is required\");\n ensureGlobalMiddlewareDispatch(nitroApp);\n installHttpResponseTelemetryHooks(nitroApp);\n\n // Reuse the cached shim if we've wrapped this nitroApp before\n const cached = nitroApp[APP_SHIM_KEY] as H3AppShim | undefined;\n if (cached) return cached;\n\n const shim: H3AppShim = {\n use(arg1: string | EventHandler, arg2?: EventHandler) {\n const path = typeof arg1 === \"string\" ? arg1 : \"\";\n const handler = (typeof arg1 === \"string\" ? arg2 : arg1) as EventHandler;\n if (typeof handler !== \"function\") {\n throw new Error(\"getH3App.use: handler must be a function\");\n }\n registerMiddleware(nitroApp, path, handler);\n },\n };\n\n nitroApp[APP_SHIM_KEY] = shim;\n\n if (!BOOTSTRAPPED.has(nitroApp)) {\n BOOTSTRAPPED.add(nitroApp);\n nitroApp[BOOTSTRAP_PROMISE_KEY] = bootstrapDefaultPlugins(nitroApp).catch(\n (err) => {\n console.warn(\n \"[agent-native] Failed to auto-mount default plugins:\",\n (err as Error).message,\n );\n captureError(err, {\n route: \"default-plugin-bootstrap\",\n tags: { phase: \"default-plugin-bootstrap\" },\n });\n },\n );\n\n // Readiness gate: Nitro v3 doesn't await async plugins, so routes\n // registered inside an async plugin may not exist when the first\n // request arrives. These middleware entries hold framework routes\n // until default-plugin bootstrap and tracked plugin inits complete.\n const readinessGate = (async (event: H3Event) => {\n const eventAny = event as any;\n await awaitFrameworkRoutesReadyForRequest(\n nitroApp,\n eventAny.context?._mountedPathname ?? event.url?.pathname ?? \"\",\n );\n // Fall through — the actual route handler runs next.\n return undefined;\n }) as EventHandler;\n registerMiddleware(nitroApp, FRAMEWORK_PREFIX, readinessGate, {\n prepend: true,\n });\n registerMiddleware(nitroApp, WELL_KNOWN_PREFIX, readinessGate, {\n prepend: true,\n });\n registerMiddleware(nitroApp, MCP_PUBLIC_ROUTE_PREFIX, readinessGate, {\n prepend: true,\n });\n\n // CSRF (see csrf.ts): registered here — synchronously, on the very\n // first `getH3App()` call for this nitroApp — rather than inside\n // createCoreRoutesPlugin's own async init chain. Real deployments mount\n // core-routes and agent-chat as SEPARATE, independently-async-initialized\n // Nitro plugin files with no explicit ordering between them; both\n // eventually call `getH3App(nitroApp).use(...)` to register their own\n // routes (CSRF, action routes) after their own async setup (DB reads,\n // dynamic imports) resolves in unpredictable relative order. The\n // readiness gate above only guarantees every tracked plugin has FINISHED\n // registering by the time a gated request is released — it does NOT\n // guarantee CSRF's registration call happens to `.push()` onto\n // `~middleware` before an action route's does. If agent-chat's action\n // route push happened to land first, that route would match and run\n // before CSRF ever saw the request. Registering CSRF here instead makes\n // it the first non-prepended middleware pushed onto the array for this\n // nitroApp, full stop — every plugin's own route registrations reach\n // `getH3App()` (and therefore run after this point) before they can\n // register anything, regardless of which plugin's async chain resolves\n // first.\n registerMiddleware(nitroApp, \"\", createCsrfMiddleware());\n\n // Registered last so it lands at index 0 — ahead of the readiness gates\n // and CSRF, both of which were unshifted/pushed above.\n registerRequestContextBoundary(nitroApp);\n\n // Primary gate: Nitro bridges this `request` hook to h3's `config.onRequest`,\n // which h3 awaits BEFORE `handler()` snapshots middleware and resolves the\n // route. The middleware gate above runs too late on production dispatchers —\n // its await finishes after the snapshot, so a route registered during async\n // init is missing from the request and 404s. The middleware gate stays as a\n // fallback for runtimes where `onRequest` isn't wired.\n nitroApp.hooks?.hook?.(\"request\", async (event: H3Event) => {\n const reqPath = event.url?.pathname ?? \"\";\n if (\n resolveMountMatch(reqPath, FRAMEWORK_PREFIX) ||\n resolveMountMatch(reqPath, WELL_KNOWN_PREFIX) ||\n resolveMountMatch(reqPath, MCP_PUBLIC_ROUTE_PREFIX)\n ) {\n const startedAt = Date.now();\n try {\n await awaitFrameworkRoutesReadyForRequest(nitroApp, reqPath);\n } finally {\n recordFrameworkReadyWait(event, Date.now() - startedAt);\n }\n }\n });\n }\n\n return shim;\n}\n\n/**\n * Establish a `RequestContext` for every inbound request, so no HTTP handler\n * ever asks a request-scoped question with no request in scope.\n *\n * Hand-written `/api/*` routes have no ALS store of their own, and\n * `getRequestUserEmail()` used to answer those with `AGENT_USER_EMAIL` — a\n * process-wide ambient identity standing in for the caller, which fails open\n * toward more privilege (an admin gate reading it admits whoever the deploy env\n * names). This store is deliberately identity-free: resolving the session here\n * would mean reading cookies on the SSR path, which must stay one impersonal\n * cached shell. Handlers that do know the caller still nest their own\n * `runWithRequestContext`, which shadows this one.\n *\n * h3 v2 hands middleware a `next()` that returns the result of the rest of the\n * chain (route handler included), so wrapping `next()` puts the whole request\n * inside the ALS scope. It must be `~middleware[0]`; going through\n * `registerMiddleware` is not an option because that adapter hides `next`.\n */\nfunction registerRequestContextBoundary(nitroApp: any): void {\n const h3 = nitroApp?.h3;\n if (!h3 || !Array.isArray(h3[\"~middleware\"])) return;\n if (h3[REQUEST_CONTEXT_BOUNDARY_KEY]) return;\n\n const middleware = (_event: H3Event, next: () => unknown) => {\n if (hasRequestContext()) return next();\n return runWithRequestContext({}, () => next());\n };\n\n h3[REQUEST_CONTEXT_BOUNDARY_KEY] = middleware;\n h3[\"~middleware\"].unshift(middleware);\n markRequestBoundaryInstalled();\n}\n\n/**\n * Nitro 3 production builds generate a route dispatcher by overriding h3's\n * internal `~getMiddleware()` hook. Some generated dispatchers return only\n * route-rule middleware and skip the global `h3[\"~middleware\"]` array that\n * `getH3App().use()` appends to. Wrap the dispatcher once so framework routes\n * registered at runtime are still part of request dispatch.\n */\nfunction ensureGlobalMiddlewareDispatch(nitroApp: any): void {\n const h3 = nitroApp?.h3;\n if (!h3) return;\n const current = h3[\"~getMiddleware\"];\n if (h3[MIDDLEWARE_DISPATCHER_PATCHED_KEY] === current) return;\n\n const original = typeof current === \"function\" ? current.bind(h3) : undefined;\n\n const wrappedGetMiddleware = (event: H3Event, route: unknown) => {\n const originalResult = original ? original(event, route) : [];\n const originalList = Array.isArray(originalResult)\n ? originalResult\n : originalResult\n ? [originalResult]\n : [];\n const globalMiddleware = Array.isArray(h3[\"~middleware\"])\n ? h3[\"~middleware\"]\n : [];\n if (globalMiddleware.length === 0) return originalList;\n\n const alreadyIncluded = new Set(originalList);\n const missingGlobal = globalMiddleware.filter(\n (middleware) => !alreadyIncluded.has(middleware),\n );\n return missingGlobal.length\n ? [...missingGlobal, ...originalList]\n : originalList;\n };\n\n h3[\"~getMiddleware\"] = wrappedGetMiddleware;\n h3[MIDDLEWARE_DISPATCHER_PATCHED_KEY] = wrappedGetMiddleware;\n}\n\n/**\n * Wait for the framework's default-plugin bootstrap to complete.\n *\n * Called by user-facing plugin factories (`createAgentChatPlugin`, etc.) at\n * the top of their plugin function, so that by the time the function returns\n * — and Nitro starts accepting requests — all default plugins have finished\n * registering their middleware.\n *\n * No-op when called from inside the bootstrap itself (avoids deadlock when a\n * default plugin happens to be running as part of bootstrap).\n */\nexport async function awaitBootstrap(nitroApp: any): Promise<void> {\n if (!nitroApp || IN_BOOTSTRAP.has(nitroApp)) return;\n // Trigger bootstrap if it hasn't been already (idempotent — getH3App\n // creates the shim and kicks off bootstrap on first call).\n getH3App(nitroApp);\n const promise = nitroApp[BOOTSTRAP_PROMISE_KEY];\n if (promise) await promise;\n}\n\n/**\n * Wait until framework routes are safe to dispatch.\n *\n * Request-time gates must wait for both phases:\n * 1. default-plugin bootstrap, which discovers and starts missing plugins\n * 2. async plugin init promises, which register routes such as A2A cards\n */\nasync function awaitFrameworkRoutesReadyForRequest(\n nitroApp: any,\n reqPath: string,\n): Promise<boolean> {\n if (!nitroApp) return true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n (async () => {\n const bootstrapPromise = nitroApp[BOOTSTRAP_PROMISE_KEY];\n if (bootstrapPromise) await bootstrapPromise;\n await awaitPluginsReady(nitroApp, reqPath);\n return true;\n })(),\n new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(false), frameworkReadyDeadlineMs());\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\n/**\n * Cap on how long a request may be held waiting for framework routes.\n *\n * Holding past the platform's own request wall is pure loss: the serverless\n * gateway kills the invocation and the client gets a bare 502/504 it cannot\n * act on. Releasing first lets the placeholder answer with a retryable 503.\n * Keep this BELOW the shortest deployment target's request wall (Netlify\n * synchronous functions cut off around 40s regardless of a higher configured\n * `timeout`).\n */\nfunction frameworkReadyDeadlineMs(): number {\n const raw = Number(process.env.AGENT_NATIVE_ROUTE_READY_TIMEOUT_MS);\n return Number.isFinite(raw) && raw > 0 ? raw : 25_000;\n}\n\n/**\n * Track an async plugin's initialization promise. Nitro v3 calls plugins\n * synchronously and doesn't await async return values, so routes registered\n * inside an async plugin may not be ready when the first request arrives.\n *\n * Call this from the TOP of any async plugin so that the readiness gate\n * (installed by getH3App) can hold /_agent-native requests until the plugin\n * finishes mounting its routes.\n */\nexport function trackPluginInit(\n nitroApp: any,\n promise: Promise<void>,\n options: { paths?: string[] } = {},\n): void {\n if (!nitroApp) return;\n // Ensure the readiness gate exists even when the tracked plugin is the first\n // framework code to run in a serverless isolate. Otherwise an immediate\n // first request can fall through before the plugin registers its routes.\n getH3App(nitroApp);\n // Attach a no-op catch so the promise doesn't surface as an unhandled\n // rejection when Nitro v3 drops the async return value. The actual error\n // is still observable when awaitPluginsReady() re-awaits the promise.\n const safe = promise.catch((err) => {\n console.error(\n \"[agent-native] Plugin init failed:\",\n (err as Error).message || err,\n );\n // Record the failure so the readiness gate can return a retryable 503 for\n // this plugin's routes instead of letting them fall through to a bare\n // \"Cannot find any route matching\" 404. That bare 404 is what kept biting\n // external MCP clients (pi/codex/claude) and the connect flow on cold /\n // propagating instances whose async init rejected (e.g. DB not yet\n // reachable): the route never registered, so the placeholder released into\n // a 404 the client couldn't recover from. A 503 is at least retryable.\n const failures = (nitroApp[PLUGIN_FAILED_KEY] ??= new Map<\n string,\n string\n >());\n const msg = (err as Error)?.message || String(err);\n for (const p of options.paths?.filter(Boolean) ?? []) failures.set(p, msg);\n });\n const entry: PluginReadyEntry = {\n promise: safe,\n paths: options.paths?.filter(Boolean),\n };\n const existing = nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined;\n if (existing) {\n existing.push(entry);\n } else {\n nitroApp[PLUGIN_READY_KEY] = [entry];\n }\n installPluginReadyPlaceholders(nitroApp, entry.paths);\n}\n\nfunction installPluginReadyPlaceholders(\n nitroApp: any,\n paths: string[] | undefined,\n): void {\n if (!paths?.length) return;\n const existing = nitroApp[PLUGIN_READY_PLACEHOLDERS_KEY] as\n | Set<string>\n | undefined;\n const installed = existing ?? new Set<string>();\n nitroApp[PLUGIN_READY_PLACEHOLDERS_KEY] = installed;\n\n for (const path of paths) {\n if (!path || installed.has(path)) continue;\n installed.add(path);\n registerMiddleware(\n nitroApp,\n path,\n (async (event: H3Event) => {\n const eventAny = event as any;\n const reqPath =\n eventAny.context?._mountedPathname ?? event.url?.pathname ?? path;\n const ready = await awaitFrameworkRoutesReadyForRequest(\n nitroApp,\n reqPath,\n );\n if (!ready) {\n // Boot is still running and we are out of budget. Answer now, while\n // the gateway is still listening, rather than being killed mid-wait.\n setResponseStatus(event, 503);\n setResponseHeader(event, \"retry-after\", \"5\");\n return { error: \"agent-native routes are still initializing\" };\n }\n // If this plugin's async init failed, its real route was never\n // registered. Return a retryable 503 instead of releasing into a bare\n // 404 (external MCP clients can't recover from a 404; a 503 is at least\n // a \"try again\" the client / next instance can act on).\n const failures = nitroApp[PLUGIN_FAILED_KEY] as\n | Map<string, string>\n | undefined;\n if (failures?.size) {\n for (const [failedPath, msg] of failures) {\n if (resolveMountMatch(reqPath, failedPath)) {\n setResponseStatus(event, 503);\n setResponseHeader(event, \"retry-after\", \"5\");\n return {\n error: `agent-native route is initializing or unavailable: ${msg}`,\n };\n }\n }\n }\n return undefined;\n }) as EventHandler,\n {\n prepend: true,\n },\n );\n }\n}\n\nfunction logFrameworkRouteError(args: {\n method: string | undefined;\n route: string;\n status: number;\n error: unknown;\n}): void {\n const error = args.error as any;\n const message = error?.message || String(args.error);\n const prefix = `[agent-native] ${args.method ?? \"\"} ${args.route} failed (${args.status})`;\n if (process.env.NODE_ENV === \"production\") {\n console.error(`${prefix}: ${message}`);\n return;\n }\n console.error(`${prefix}: ${message}`, error?.stack || args.error);\n}\n\nfunction isClientAbortError(error: unknown, event: H3Event): boolean {\n const err = error as any;\n const message = typeof err?.message === \"string\" ? err.message : \"\";\n const code = typeof err?.code === \"string\" ? err.code : \"\";\n const node = (event as any).node;\n return (\n message === \"aborted\" ||\n code === \"ECONNRESET\" ||\n node?.req?.destroyed === true ||\n node?.res?.destroyed === true\n );\n}\n\nfunction debugClientAbort(args: {\n method: string | undefined;\n route: string;\n error: unknown;\n}): void {\n if (process.env.NODE_ENV === \"production\") return;\n const err = args.error as any;\n const message = err?.message || String(args.error);\n console.debug?.(\n `[agent-native] ${args.method ?? \"\"} ${args.route} aborted by client: ${message}`,\n );\n}\n\n/**\n * Await all tracked plugin initializations. Called by the readiness gate\n * middleware before dispatching framework routes.\n */\nexport async function awaitPluginsReady(\n nitroApp: any,\n reqPath?: string,\n): Promise<void> {\n const entries = nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined;\n if (!entries?.length) return;\n\n const relevant = reqPath\n ? entries.filter((entry) =>\n entry.paths?.length\n ? entry.paths.some((path) => resolveMountMatch(reqPath, path))\n : true,\n )\n : entries;\n\n if (relevant.length) {\n await Promise.all(relevant.map((entry) => entry.promise));\n const completed = new Set(relevant);\n const latest =\n (nitroApp[PLUGIN_READY_KEY] as PluginReadyEntry[] | undefined) ?? [];\n nitroApp[PLUGIN_READY_KEY] = latest.filter(\n (entry) => !completed.has(entry),\n );\n }\n}\n\n/**\n * Register a path-prefix middleware on Nitro's h3 instance.\n *\n * The middleware:\n * - Returns `next()` (continues) if the request path doesn't match.\n * - Otherwise dispatches to the handler. If the handler returns a value,\n * it short-circuits the request. If it returns undefined, next() runs.\n *\n * Path matching emulates h3 v1's `app.use(path, ...)` behavior:\n * - Exact-match prefix: `/foo` matches `/foo`, `/foo/bar`, but not `/foobar`\n * - Empty path: middleware runs on every request\n */\nfunction registerMiddleware(\n nitroApp: any,\n path: string,\n handler: EventHandler,\n options: { prepend?: boolean } = {},\n) {\n const h3 = nitroApp.h3;\n if (!h3 || !Array.isArray(h3[\"~middleware\"])) {\n throw new Error(\n \"[agent-native] Cannot register route: nitroApp.h3 is not available. \" +\n \"Make sure you're calling getH3App() from inside a Nitro plugin.\",\n );\n }\n\n const middleware = async (event: H3Event, next: () => any) => {\n let originalPathname: string | undefined;\n let originalEventPath: string | undefined;\n let hadEventPath = false;\n // Only true once this specific middleware invocation has actually\n // stripped a mount prefix (i.e. `path` was non-empty and matched).\n // Global (`path === \"\"`) middleware never mutates event.path/pathname,\n // so `restoreOriginalPath` must be a no-op for it — otherwise it would\n // unconditionally `delete event.path` on every pass-through (hadEventPath\n // defaults to false), corrupting the event for any middleware that runs\n // later in the chain (a real bug: two or more global middlewares in\n // sequence, e.g. security-headers + CORS + CSRF, would wipe event.path\n // for everything downstream, including the final route handler).\n let didStripPath = false;\n const restoreOriginalPath = () => {\n if (!didStripPath) return;\n if (originalPathname !== undefined) {\n try {\n event.url.pathname = originalPathname;\n } catch {\n // ignore\n }\n originalPathname = undefined;\n }\n if (hadEventPath) {\n try {\n (event as any).path = originalEventPath;\n } catch {\n // ignore\n }\n } else {\n try {\n delete (event as any).path;\n } catch {\n // ignore\n }\n }\n };\n if (path) {\n const reqPath = event.url?.pathname ?? \"\";\n const match = resolveMountMatch(reqPath, path);\n if (!match) {\n return next();\n }\n // Strip the mount prefix from event.url.pathname so handlers that\n // dispatch sub-routes can read `event.path` (or `event.url.pathname`)\n // and see the path RELATIVE to their mount point — matching h3 v1's\n // `app.use(path, handler)` semantics.\n const eventAny = event as any;\n hadEventPath = \"path\" in eventAny;\n originalEventPath = eventAny.path;\n didStripPath = true;\n try {\n originalPathname = event.url.pathname;\n // Save the full path in context so handlers that need the original URL\n // (e.g. Better Auth, which extracts its own basePath prefix) can\n // reconstruct a Request with the un-stripped URL.\n eventAny.context = eventAny.context ?? {};\n eventAny.context._mountedPathname = originalPathname;\n eventAny.context._mountPrefix = match.mountPath;\n event.url.pathname = match.strippedPath;\n eventAny.path = `${match.strippedPath}${event.url.search || \"\"}`;\n } catch {\n // event.url is read-only on some runtimes — fall through. Handlers\n // that don't depend on prefix stripping (most of them) still work.\n }\n }\n try {\n const result = await handler(event);\n if (result === undefined) {\n // Restore the original pathname BEFORE calling next() so downstream\n // middleware sees the full URL — not the stripped mount-relative path.\n // Matches h3 v2's own sub-app middleware pattern where the restore\n // happens inside the next() callback, not after it returns.\n restoreOriginalPath();\n return next();\n }\n return result;\n } catch (err) {\n // Log 500s to the server console so they're debuggable, and respond\n // with JSON instead of the default HTML error page so clients can\n // surface error messages. This only applies to routes mounted under\n // the framework prefix (or middleware mounted at `/`, for which we\n // still want visibility).\n const reqPath = originalPathname ?? event.url?.pathname ?? \"\";\n const e = err as any;\n const status =\n typeof e?.statusCode === \"number\"\n ? e.statusCode\n : typeof e?.status === \"number\"\n ? e.status\n : 500;\n if (isClientAbortError(err, event)) {\n debugClientAbort({ method: event.method, route: reqPath, error: err });\n return undefined;\n }\n logFrameworkRouteError({\n method: event.method,\n route: reqPath,\n status,\n error: err,\n });\n // Forward 5xx to the configured server error providers — Nitro's own\n // `error` hook may not fire here because we convert the throw into a\n // normal JSON response, and a console.error alone is invisible in\n // deployed environments. 4xx are user-input errors (validation, auth)\n // and aren't worth alerting on.\n if (status >= 500) {\n captureError(err, {\n route: reqPath,\n method: event.method,\n tags: { status_code: String(status) },\n userAgent: (() => {\n try {\n return event.headers?.get(\"user-agent\") ?? undefined;\n } catch {\n return undefined;\n }\n })(),\n });\n }\n try {\n setResponseStatus(event, status);\n setResponseHeader(event, \"content-type\", \"application/json\");\n } catch {\n // Response already sent — best effort.\n }\n return {\n error: e?.message || \"Internal server error\",\n // Only surface the stack to clients when explicitly enabled.\n // `NODE_ENV !== \"production\"` was unsafe — preview deploys and\n // any host that forgets to set NODE_ENV=production leaked stack\n // traces (file paths, dependency versions, internal route\n // topology) to anonymous callers. Operators who want stacks in\n // dev set `AGENT_NATIVE_DEBUG_ERRORS=1` explicitly.\n ...(status >= 500 &&\n process.env.AGENT_NATIVE_DEBUG_ERRORS === \"1\" &&\n e?.stack\n ? { stack: e.stack }\n : {}),\n };\n } finally {\n // Restore the original pathname so downstream middleware sees the\n // full URL.\n restoreOriginalPath();\n }\n };\n\n if (options.prepend) {\n h3[\"~middleware\"].unshift(middleware);\n } else {\n h3[\"~middleware\"].push(middleware);\n }\n}\n\n/**\n * Auto-mount any default framework plugins that the template doesn't provide.\n *\n * Runs once per nitroApp on the first `getH3App()` call. Uses route-discovery\n * to find which default plugin stems are missing from `server/plugins/`, then\n * dynamically imports and mounts them. If a workspace core is present in the\n * ancestor chain, plugin slots the workspace core exports are mounted from\n * there instead of from @agent-native/core — this is the middle layer of the\n * three-layer inheritance model (app local > workspace core > framework).\n */\nasync function bootstrapDefaultPlugins(nitroApp: any): Promise<void> {\n IN_BOOTSTRAP.add(nitroApp);\n try {\n const cwd = process.cwd();\n const discoveredMissing = await getMissingDefaultPlugins(cwd);\n const provided = nitroApp[PROVIDED_PLUGIN_STEMS_KEY] as\n | Set<string>\n | undefined;\n const missing = provided\n ? discoveredMissing.filter((stem) => !provided.has(stem))\n : discoveredMissing;\n if (missing.length === 0) return;\n\n // Lazy import to avoid circular dependency at module load time\n const serverModule = await import(\"./index.js\");\n const terminalModule = await import(\"../terminal/terminal-plugin.js\");\n const integrationsModule = await import(\"../integrations/plugin.js\");\n const contextXrayModule = await import(\"../agent/context-xray/plugin.js\");\n const observationalMemoryModule =\n await import(\"../agent/observational-memory/plugin.js\");\n const orgModule = await import(\"../org/plugin.js\");\n const onboardingModule = await import(\"../onboarding/plugin.js\");\n\n const frameworkImpls: Record<\n string,\n ((nitroApp: any) => void | Promise<void>) | undefined\n > = {\n \"agent-chat\": (serverModule as any).defaultAgentChatPlugin,\n auth: (serverModule as any).defaultAuthPlugin,\n \"context-xray\": (contextXrayModule as any).defaultContextXrayPlugin,\n \"core-routes\": (serverModule as any).defaultCoreRoutesPlugin,\n integrations: (integrationsModule as any).defaultIntegrationsPlugin,\n \"observational-memory\": (observationalMemoryModule as any)\n .defaultObservationalMemoryPlugin,\n onboarding: (onboardingModule as any).defaultOnboardingPlugin,\n org: (orgModule as any).defaultOrgPlugin,\n resources: (serverModule as any).defaultResourcesPlugin,\n sentry: (serverModule as any).defaultSentryPlugin,\n terminal: (terminalModule as any).defaultTerminalPlugin,\n };\n\n // Workspace core layer: if the app is inside an enterprise monorepo with\n // `agent-native.workspaceCore` configured, pull in any plugin slots the\n // workspace core exports from its server entry. We dynamically import the\n // workspace core package at runtime.\n let workspaceImpls: Record<\n string,\n ((nitroApp: any) => void | Promise<void>) | undefined\n > = {};\n try {\n const { getWorkspaceCoreExports } =\n await import(\"../deploy/workspace-core.js\");\n const ws = await getWorkspaceCoreExports(cwd);\n if (ws && Object.keys(ws.plugins).length > 0) {\n try {\n const wsServerModule = await loadWorkspaceCoreServer(\n ws.packageName,\n ws.packageDir,\n );\n for (const [slot, exportName] of Object.entries(ws.plugins)) {\n if (!exportName) continue;\n const impl = (wsServerModule as any)[exportName];\n if (typeof impl === \"function\") {\n workspaceImpls[slot] = impl;\n }\n }\n if (process.env.DEBUG) {\n console.log(\n `[agent-native] Workspace core ${ws.packageName} provides plugin slots: ${Object.keys(workspaceImpls).join(\", \")}`,\n );\n }\n } catch (e) {\n const msg = (e as Error).message ?? \"\";\n // Common cause: workspace-core's package.json points \"./server\"\n // at a TS source file (the scaffold default), but Node can't\n // resolve relative `.js` imports inside it without a TS loader.\n // Tell the user to compile to dist/ rather than just dumping the\n // raw resolution error.\n const tsLoadHint = /\\.js' imported from .*\\.ts/.test(msg)\n ? \" — workspace-core src is TypeScript but isn't being compiled. \" +\n \"Run `pnpm --filter \" +\n ws.packageName +\n \" build` and point its `./server` export at dist/server/index.js.\"\n : \"\";\n console.warn(\n `[agent-native] Failed to load workspace core ${ws.packageName}/server: ${msg}${tsLoadHint}`,\n );\n }\n }\n } catch {\n // Workspace shared package isn't available (e.g. running on an edge\n // runtime without fs). Silently fall through to framework defaults.\n }\n\n if (process.env.DEBUG)\n console.log(\n `[agent-native] Auto-mounting ${missing.length} default plugin(s): ${missing.join(\", \")}`,\n );\n\n for (const stem of missing) {\n // Prefer workspace-core impl over framework default when both exist.\n const impl = workspaceImpls[stem] ?? frameworkImpls[stem];\n if (typeof impl === \"function\") {\n try {\n await impl(nitroApp);\n } catch (e) {\n console.warn(\n `[agent-native] Failed to auto-mount default plugin ${stem}:`,\n (e as Error).message,\n );\n captureError(e, {\n route: \"default-plugin-bootstrap\",\n tags: { phase: \"default-plugin-bootstrap\", plugin: stem },\n });\n }\n }\n }\n } finally {\n IN_BOOTSTRAP.delete(nitroApp);\n }\n}\n\n/**\n * Load a workspace-core's `/server` entry, transparently handling TS source.\n *\n * The scaffolded workspace-core template ships TS sources without a build\n * step (exports point at `./src/server/index.ts`), so plain `await import()`\n * blows up the moment Node hits a relative `.js` import inside (the standard\n * TS ESM convention) — and even before that, Node may resolve the package\n * relative to the framework's own location rather than the user's monorepo.\n *\n * We try Node's plain `import()` first (fastest path when the user has\n * compiled to dist/) and fall through to jiti on any error. jiti is anchored\n * to a real file inside the workspace-core's directory, so its module\n * resolution starts in the right node_modules tree (handles pnpm hoisting\n * and linked workspaces) AND handles TS source files + `.js` → `.ts` ESM\n * extension remapping.\n *\n * Edge runtimes without `fs` won't be able to load jiti at all; the outer\n * try/catch silently falls through to framework defaults in that case.\n */\nexport async function loadWorkspaceCoreServer(\n packageName: string,\n packageDir: string,\n): Promise<any> {\n let firstErr: unknown;\n try {\n return await import(/* @vite-ignore */ `${packageName}/server`);\n } catch (e) {\n firstErr = e;\n }\n\n try {\n const { createJiti } = await import(\"jiti\");\n const { pathToFileURL } = await import(\"node:url\");\n const path = await import(\"node:path\");\n // Anchor jiti to a real file inside the workspace-core package so its\n // module resolution starts in the right node_modules tree (handles pnpm\n // hoisting and linked workspaces).\n const anchor = pathToFileURL(\n path.join(packageDir, \"package.json\"),\n ).toString();\n const jiti = createJiti(anchor, { interopDefault: true });\n return await jiti.import(`${packageName}/server`);\n } catch (jitiErr) {\n // jiti also failed — rethrow the original Node error since it's usually\n // more informative about *why* the package wasn't resolvable.\n throw firstErr ?? jitiErr;\n }\n}\n\nexport { FRAMEWORK_PREFIX };\n"]}
@@ -20,7 +20,7 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- text: string;
24
23
  error?: undefined;
24
+ text: string;
25
25
  }>>;
26
26
  //# sourceMappingURL=transcribe-voice.d.ts.map
@@ -305,6 +305,38 @@ export default defineAction({
305
305
 
306
306
  On success the validated value is returned, so coercion/defaults on `outputSchema` apply. Omit `outputSchema` and behavior is byte-for-byte unchanged (no wrapping).
307
307
 
308
+ ### Authorization (`authorize`)
309
+
310
+ `authorize` decides whether the caller may run the action at all. It wraps
311
+ `run`, so it holds at **all six dispatch sites** — agent tool, HTTP, frontend
312
+ hook, MCP, A2A, CLI — unlike `needsApproval`, which is honoured only in the
313
+ agent loop. Use `authorize` for "not everyone may do this"; use `needsApproval`
314
+ to ask a human to bless one call a permitted caller is already allowed to make.
315
+
316
+ ```ts
317
+ import { coachAccess } from "../lib/access.js"; // defineAppRoles(...)
318
+
319
+ export default defineAction({
320
+ description: "Archive a client roster.",
321
+ schema: z.object({ id: z.string() }),
322
+ authorize: coachAccess.requireAny("coach-admin"),
323
+ run: async (args) => {
324
+ /* ... */
325
+ },
326
+ });
327
+ ```
328
+
329
+ The wrappers compose as `validate input -> authorize -> run -> validate output
330
+ -> audit`: the gate sits inside input validation, so a guard reading `args` gets
331
+ the parsed, coerced value, and auditing is outermost, so denials are recorded.
332
+
333
+ A guard that throws denies with its own message; returning `false` denies
334
+ generically; anything else (including `undefined`) allows. A guarded action
335
+ needs a user identity, so an unattended CLI/cron caller with no user email is
336
+ denied. `authorize` gates the operation; `accessFilter` / `assertAccess` still
337
+ scope which rows a permitted caller may touch. See the `authentication` skill
338
+ for `defineAppRoles` and the `sharing` skill for row scoping.
339
+
308
340
  ### Human-in-the-Loop Approval (`needsApproval`)
309
341
 
310
342
  For high-consequence, outward-facing, hard-to-undo actions (sending an email, charging a card, deleting an account), set `needsApproval` so the agent **cannot** run the action without a human approving the specific call:
@@ -179,8 +179,15 @@ If the feature stores **user-authored resources** (documents, dashboards, forms,
179
179
 
180
180
  TL;DR: spread `ownableColumns()` into the resource table, pair it with `createSharesTable(...)`, call `registerShareableResource(...)`, wrap list/read queries with `accessFilter`, guard writes with `assertAccess`, and drop `<ShareButton>` in the resource header. The `share-resource`, `unshare-resource`, `list-resource-shares`, and `set-resource-visibility` actions are auto-mounted framework-wide.
181
181
 
182
+ ## One more area — who inside the app may do it
183
+
184
+ If the feature is one **only some teammates should be able to perform inside this app** (an admin-only import, a settings reset), that is a per-app role — not a new organization, and not a share grant. See the `authentication` skill.
185
+
186
+ TL;DR: declare the vocabulary once with `defineAppRoles({ appId, roles, defaultRole })`, guard the action with `authorize: appAccess.requireAny("...")`, and render the picker with `<TeamPage appRoles={descriptor} />`. `defaultRole` is display only — it never satisfies a guard — and `authorize` gates the operation while `accessFilter` / `assertAccess` still scope the rows.
187
+
182
188
  ## Related Skills
183
189
 
190
+ - **authentication** — Per-app member roles (`defineAppRoles`) when only some teammates may use a feature
184
191
  - **sharing** — How to make a new resource ownable (private by default, share with users/orgs/public)
185
192
  - **context-awareness** — How to expose UI state to the agent (area 4 in detail)
186
193
  - **actions** — How to create actions with `defineAction` and the `http` option (area 2 in detail)
@@ -159,6 +159,35 @@ whole site. Data scoping lives in actions and API routes; the client gates
159
159
  private UI after the shell loads. See the `authentication` skill and
160
160
  `guard:ssr-cache-shell` / `ssr-handler.spec.ts`.
161
161
 
162
+ **Authorization beyond "is there a session" — `authorize`.** The auth guard only
163
+ proves *someone* is signed in. To restrict an operation to some teammates, set
164
+ `authorize` on the `defineAction`. It wraps `run`, so it applies at every
165
+ dispatch site (agent tool, HTTP, frontend, MCP, A2A, CLI) — unlike
166
+ `needsApproval`, which is honoured only in the agent loop.
167
+
168
+ ```ts
169
+ import { coachAccess } from "../lib/access.js"; // defineAppRoles(...)
170
+
171
+ export default defineAction({
172
+ description: "Archive a client roster.",
173
+ schema: z.object({ id: z.string() }),
174
+ authorize: coachAccess.requireAny("coach-admin"),
175
+ run: async (args) => {
176
+ /* ... */
177
+ },
178
+ });
179
+ ```
180
+
181
+ A guard that throws denies with its own message; returning `false` denies
182
+ generically; anything else (including `undefined`) allows. Guarded actions need
183
+ a user identity — an unattended CLI/cron caller with no user email is denied.
184
+
185
+ `authorize` is **not** a substitute for `accessFilter` / `assertAccess`. It
186
+ decides whether this caller may perform the operation at all; `accessFilter` /
187
+ `assertAccess` scope which rows a permitted caller may see or touch. A
188
+ restricted write action needs both. See the `authentication` skill for
189
+ `defineAppRoles` and the `actions` skill for the full surface.
190
+
162
191
  ## Human-in-the-Loop Approval for High-Consequence Actions
163
192
 
164
193
  For a small set of outward-facing, hard-to-undo operations — sending an email, charging a card, deleting an account, posting publicly — auth and access control are necessary but not sufficient: you also do not want the **agent** to perform them autonomously. Set `needsApproval` on the `defineAction` so the agent cannot run the action without a human approving the specific call.
@@ -274,6 +303,8 @@ Run `pnpm action db-check-scoping` to verify. Use `--require-org` for multi-org
274
303
  - [ ] New env vars in `.env` only, not committed
275
304
  - [ ] New user-data tables have `owner_email` column
276
305
  - [ ] Custom routes call `getSession` and reject unauthenticated requests
306
+ - [ ] Actions only some teammates may run set `authorize` (in addition to any
307
+ `accessFilter` / `assertAccess` row scoping)
277
308
 
278
309
  ## Related Skills
279
310
 
@@ -34,6 +34,8 @@ Visibility is coarse. Explicit share grants are fine-grained (per user or per or
34
34
  - **`editor`** — read + write.
35
35
  - **`admin`** — read + write + manage shares. Does NOT replace the single `owner_email` on the resource.
36
36
 
37
+ There are three role systems and they never imply one another. A share role answers "what may this person do to **one row**". An org role (`org_members.role`) answers "what may this person do to the **team**". An app role (`defineAppRoles`, see the `authentication` skill) answers "what may this person do inside **one app**". A share `admin` is not an app admin and neither is an org admin.
38
+
37
39
  ### Anonymous public URLs stay separate
38
40
 
39
41
  Form "publish" slugs, booking-link slugs, any feature that exposes a URL to unauthenticated users — these are a different axis and are NOT controlled by the sharing system. Keep them alongside it.
@@ -137,6 +139,8 @@ export default defineAction({
137
139
 
138
140
  For delete actions use `"admin"` (or fold in `"owner"` to require the real owner).
139
141
 
142
+ `authorize` is a different axis, not an alternative: it gates whether the caller may run the operation at all, while `assertAccess` scopes which row they may touch. A write action restricted to some teammates needs both — `authorize: appAccess.requireAny(...)` on the action, `assertAccess` inside `run`.
143
+
140
144
  ## Create actions must set owner
141
145
 
142
146
  When inserting a new row, fill `ownerEmail` and `orgId` from the request context:
@@ -9,8 +9,10 @@ npm-debug.log*
9
9
  pnpm-debug.log*
10
10
 
11
11
  node_modules
12
+ build/
12
13
  dist
13
14
  dist-ssr
15
+ .output/
14
16
  *.local
15
17
 
16
18
  # Editor directories and files
@@ -305,6 +305,38 @@ export default defineAction({
305
305
 
306
306
  On success the validated value is returned, so coercion/defaults on `outputSchema` apply. Omit `outputSchema` and behavior is byte-for-byte unchanged (no wrapping).
307
307
 
308
+ ### Authorization (`authorize`)
309
+
310
+ `authorize` decides whether the caller may run the action at all. It wraps
311
+ `run`, so it holds at **all six dispatch sites** — agent tool, HTTP, frontend
312
+ hook, MCP, A2A, CLI — unlike `needsApproval`, which is honoured only in the
313
+ agent loop. Use `authorize` for "not everyone may do this"; use `needsApproval`
314
+ to ask a human to bless one call a permitted caller is already allowed to make.
315
+
316
+ ```ts
317
+ import { coachAccess } from "../lib/access.js"; // defineAppRoles(...)
318
+
319
+ export default defineAction({
320
+ description: "Archive a client roster.",
321
+ schema: z.object({ id: z.string() }),
322
+ authorize: coachAccess.requireAny("coach-admin"),
323
+ run: async (args) => {
324
+ /* ... */
325
+ },
326
+ });
327
+ ```
328
+
329
+ The wrappers compose as `validate input -> authorize -> run -> validate output
330
+ -> audit`: the gate sits inside input validation, so a guard reading `args` gets
331
+ the parsed, coerced value, and auditing is outermost, so denials are recorded.
332
+
333
+ A guard that throws denies with its own message; returning `false` denies
334
+ generically; anything else (including `undefined`) allows. A guarded action
335
+ needs a user identity, so an unattended CLI/cron caller with no user email is
336
+ denied. `authorize` gates the operation; `accessFilter` / `assertAccess` still
337
+ scope which rows a permitted caller may touch. See the `authentication` skill
338
+ for `defineAppRoles` and the `sharing` skill for row scoping.
339
+
308
340
  ### Human-in-the-Loop Approval (`needsApproval`)
309
341
 
310
342
  For high-consequence, outward-facing, hard-to-undo actions (sending an email, charging a card, deleting an account), set `needsApproval` so the agent **cannot** run the action without a human approving the specific call:
@@ -179,8 +179,15 @@ If the feature stores **user-authored resources** (documents, dashboards, forms,
179
179
 
180
180
  TL;DR: spread `ownableColumns()` into the resource table, pair it with `createSharesTable(...)`, call `registerShareableResource(...)`, wrap list/read queries with `accessFilter`, guard writes with `assertAccess`, and drop `<ShareButton>` in the resource header. The `share-resource`, `unshare-resource`, `list-resource-shares`, and `set-resource-visibility` actions are auto-mounted framework-wide.
181
181
 
182
+ ## One more area — who inside the app may do it
183
+
184
+ If the feature is one **only some teammates should be able to perform inside this app** (an admin-only import, a settings reset), that is a per-app role — not a new organization, and not a share grant. See the `authentication` skill.
185
+
186
+ TL;DR: declare the vocabulary once with `defineAppRoles({ appId, roles, defaultRole })`, guard the action with `authorize: appAccess.requireAny("...")`, and render the picker with `<TeamPage appRoles={descriptor} />`. `defaultRole` is display only — it never satisfies a guard — and `authorize` gates the operation while `accessFilter` / `assertAccess` still scope the rows.
187
+
182
188
  ## Related Skills
183
189
 
190
+ - **authentication** — Per-app member roles (`defineAppRoles`) when only some teammates may use a feature
184
191
  - **sharing** — How to make a new resource ownable (private by default, share with users/orgs/public)
185
192
  - **context-awareness** — How to expose UI state to the agent (area 4 in detail)
186
193
  - **actions** — How to create actions with `defineAction` and the `http` option (area 2 in detail)
@@ -159,6 +159,35 @@ whole site. Data scoping lives in actions and API routes; the client gates
159
159
  private UI after the shell loads. See the `authentication` skill and
160
160
  `guard:ssr-cache-shell` / `ssr-handler.spec.ts`.
161
161
 
162
+ **Authorization beyond "is there a session" — `authorize`.** The auth guard only
163
+ proves *someone* is signed in. To restrict an operation to some teammates, set
164
+ `authorize` on the `defineAction`. It wraps `run`, so it applies at every
165
+ dispatch site (agent tool, HTTP, frontend, MCP, A2A, CLI) — unlike
166
+ `needsApproval`, which is honoured only in the agent loop.
167
+
168
+ ```ts
169
+ import { coachAccess } from "../lib/access.js"; // defineAppRoles(...)
170
+
171
+ export default defineAction({
172
+ description: "Archive a client roster.",
173
+ schema: z.object({ id: z.string() }),
174
+ authorize: coachAccess.requireAny("coach-admin"),
175
+ run: async (args) => {
176
+ /* ... */
177
+ },
178
+ });
179
+ ```
180
+
181
+ A guard that throws denies with its own message; returning `false` denies
182
+ generically; anything else (including `undefined`) allows. Guarded actions need
183
+ a user identity — an unattended CLI/cron caller with no user email is denied.
184
+
185
+ `authorize` is **not** a substitute for `accessFilter` / `assertAccess`. It
186
+ decides whether this caller may perform the operation at all; `accessFilter` /
187
+ `assertAccess` scope which rows a permitted caller may see or touch. A
188
+ restricted write action needs both. See the `authentication` skill for
189
+ `defineAppRoles` and the `actions` skill for the full surface.
190
+
162
191
  ## Human-in-the-Loop Approval for High-Consequence Actions
163
192
 
164
193
  For a small set of outward-facing, hard-to-undo operations — sending an email, charging a card, deleting an account, posting publicly — auth and access control are necessary but not sufficient: you also do not want the **agent** to perform them autonomously. Set `needsApproval` on the `defineAction` so the agent cannot run the action without a human approving the specific call.
@@ -274,6 +303,8 @@ Run `pnpm action db-check-scoping` to verify. Use `--require-org` for multi-org
274
303
  - [ ] New env vars in `.env` only, not committed
275
304
  - [ ] New user-data tables have `owner_email` column
276
305
  - [ ] Custom routes call `getSession` and reject unauthenticated requests
306
+ - [ ] Actions only some teammates may run set `authorize` (in addition to any
307
+ `accessFilter` / `assertAccess` row scoping)
277
308
 
278
309
  ## Related Skills
279
310