@agent-native/core 0.127.3 → 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 (410) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +80 -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/client/AgentPanel.tsx +26 -6
  15. package/corpus/core/src/client/AssistantChat.tsx +63 -7
  16. package/corpus/core/src/client/DefaultSpinner.tsx +29 -0
  17. package/corpus/core/src/client/org/TeamPage.tsx +161 -6
  18. package/corpus/core/src/client/org/hooks.ts +67 -0
  19. package/corpus/core/src/client/org/index.ts +9 -0
  20. package/corpus/core/src/client/transcription/use-live-transcription.ts +62 -10
  21. package/corpus/core/src/db/client.ts +42 -3
  22. package/corpus/core/src/db/ensure-additive-columns.ts +60 -33
  23. package/corpus/core/src/deploy/build.ts +31 -2
  24. package/corpus/core/src/mcp-client/routes.ts +10 -1
  25. package/corpus/core/src/org/app-roles-handlers.ts +152 -0
  26. package/corpus/core/src/org/app-roles.ts +355 -0
  27. package/corpus/core/src/org/index.ts +27 -1
  28. package/corpus/core/src/org/migrations.ts +22 -0
  29. package/corpus/core/src/org/plugin.ts +27 -0
  30. package/corpus/core/src/org/schema.ts +15 -0
  31. package/corpus/core/src/scripts/docs/search.ts +17 -0
  32. package/corpus/core/src/scripts/docs/source-search.ts +10 -0
  33. package/corpus/core/src/server/agent-chat/script-entries.ts +3 -0
  34. package/corpus/core/src/server/agent-chat-plugin.ts +53 -52
  35. package/corpus/core/src/server/core-routes-plugin.ts +6 -1
  36. package/corpus/core/src/server/framework-request-handler.ts +44 -6
  37. package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
  38. package/corpus/core/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  39. package/corpus/core/src/templates/default/.agents/skills/security/SKILL.md +31 -0
  40. package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  41. package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  42. package/corpus/core/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  43. package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  44. package/corpus/core/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  45. package/corpus/core/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  46. package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -0
  47. package/corpus/templates/analytics/.agents/skills/security/SKILL.md +31 -0
  48. package/corpus/templates/analytics/.agents/skills/sharing/SKILL.md +4 -0
  49. package/corpus/templates/analytics/actions/data-source-status.ts +21 -12
  50. package/corpus/templates/analytics/app/global.css +7 -7
  51. package/corpus/templates/analytics/app/i18n-data.ts +30 -0
  52. package/corpus/templates/analytics/app/lib/data-source-status.ts +2 -1
  53. package/corpus/templates/analytics/app/pages/DataSources.tsx +54 -10
  54. package/corpus/templates/analytics/changelog/2026-07-28-analytics-pages-load-reliably-with-large-dashboard-workspaces.md +6 -0
  55. package/corpus/templates/analytics/changelog/2026-07-28-dashboard-loading-shimmer-now-flows-smoothly-in-one-directi.md +6 -0
  56. package/corpus/templates/analytics/server/lib/first-party-dashboard-repair.ts +5 -4
  57. package/corpus/templates/analytics/server/plugins/agent-chat.ts +54 -42
  58. package/corpus/templates/analytics/server/plugins/db.ts +1 -18
  59. package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -0
  60. package/corpus/templates/assets/.agents/skills/security/SKILL.md +31 -0
  61. package/corpus/templates/assets/.agents/skills/sharing/SKILL.md +4 -0
  62. package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -0
  63. package/corpus/templates/brain/.agents/skills/adding-a-feature/SKILL.md +7 -0
  64. package/corpus/templates/brain/.agents/skills/security/SKILL.md +31 -0
  65. package/corpus/templates/brain/.agents/skills/sharing/SKILL.md +4 -0
  66. package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -0
  67. package/corpus/templates/calendar/.agents/skills/security/SKILL.md +31 -0
  68. package/corpus/templates/calendar/.agents/skills/sharing/SKILL.md +4 -0
  69. package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  70. package/corpus/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  71. package/corpus/templates/chat/.agents/skills/security/SKILL.md +31 -0
  72. package/corpus/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  73. package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -0
  74. package/corpus/templates/clips/.agents/skills/security/SKILL.md +31 -0
  75. package/corpus/templates/clips/actions/request-transcript.ts +77 -11
  76. package/corpus/templates/clips/actions/save-browser-transcript.ts +28 -7
  77. package/corpus/templates/clips/app/routes/record.tsx +11 -3
  78. package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-save-a-truncated-transcript-as-.md +6 -0
  79. package/corpus/templates/clips/changelog/2026-07-28-browser-recordings-no-longer-stop-transcribing-partway-throu.md +6 -0
  80. package/corpus/templates/clips/changelog/2026-07-28-desktop-full-screen-clips-now-get-an-instant-local-transcrip.md +6 -0
  81. package/corpus/templates/clips/changelog/2026-07-28-long-transcriptions-no-longer-show-a-false-transcription-sto.md +6 -0
  82. package/corpus/templates/clips/changelog/2026-07-28-restarting-for-an-update-now-installs-the-newest-release-ins.md +6 -0
  83. package/corpus/templates/clips/changelog/2026-07-28-the-meeting-recording-pill-now-anchors-to-the-right-edge-of-.md +6 -0
  84. package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +31 -2
  85. package/corpus/templates/clips/desktop/src/lib/recorder.ts +114 -13
  86. package/corpus/templates/clips/desktop/src/lib/updater.ts +12 -4
  87. package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +40 -15
  88. package/corpus/templates/clips/desktop/src/styles.css +10 -7
  89. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -14
  90. package/corpus/templates/clips/shared/transcript-status.ts +10 -0
  91. package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -0
  92. package/corpus/templates/content/.agents/skills/security/SKILL.md +31 -0
  93. package/corpus/templates/content/.agents/skills/sharing/SKILL.md +4 -0
  94. package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +4 -0
  95. package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -0
  96. package/corpus/templates/design/.agents/skills/security/SKILL.md +31 -0
  97. package/corpus/templates/design/.agents/skills/sharing/SKILL.md +4 -0
  98. package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +46 -3
  99. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +7 -5
  100. package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +2 -2
  101. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -4
  102. package/corpus/templates/design/app/components/design/keyboard-shortcuts.ts +1 -1
  103. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +10 -4
  104. package/corpus/templates/design/app/lib/design-ui-events.ts +5 -0
  105. package/corpus/templates/design/app/root.tsx +18 -1
  106. package/corpus/templates/design/changelog/2026-07-28-show-or-hide-design-editing-chrome-with-cmd-on-apple-devices.md +6 -0
  107. package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -0
  108. package/corpus/templates/dispatch/.agents/skills/security/SKILL.md +31 -0
  109. package/corpus/templates/dispatch/.agents/skills/sharing/SKILL.md +4 -0
  110. package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -0
  111. package/corpus/templates/forms/.agents/skills/security/SKILL.md +31 -0
  112. package/corpus/templates/forms/.agents/skills/sharing/SKILL.md +4 -0
  113. package/corpus/templates/macros/.agents/skills/security/SKILL.md +31 -0
  114. package/corpus/templates/macros/.agents/skills/sharing/SKILL.md +4 -0
  115. package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -0
  116. package/corpus/templates/mail/.agents/skills/security/SKILL.md +31 -0
  117. package/corpus/templates/mail/.agents/skills/sharing/SKILL.md +4 -0
  118. package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -0
  119. package/corpus/templates/plan/.agents/skills/adding-a-feature/SKILL.md +7 -0
  120. package/corpus/templates/plan/.agents/skills/security/SKILL.md +31 -0
  121. package/corpus/templates/plan/.agents/skills/sharing/SKILL.md +4 -0
  122. package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -0
  123. package/corpus/templates/slides/.agents/skills/security/SKILL.md +31 -0
  124. package/corpus/templates/slides/.agents/skills/sharing/SKILL.md +4 -0
  125. package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -0
  126. package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +7 -0
  127. package/corpus/templates/tasks/.agents/skills/security/SKILL.md +31 -0
  128. package/corpus/templates/tasks/.agents/skills/sharing/SKILL.md +4 -0
  129. package/dist/a2a/artifact-response.d.ts.map +1 -1
  130. package/dist/a2a/artifact-response.js +30 -29
  131. package/dist/a2a/artifact-response.js.map +1 -1
  132. package/dist/action.d.ts +36 -0
  133. package/dist/action.d.ts.map +1 -1
  134. package/dist/action.js +37 -2
  135. package/dist/action.js.map +1 -1
  136. package/dist/chat-threads/store.d.ts +12 -0
  137. package/dist/chat-threads/store.d.ts.map +1 -1
  138. package/dist/chat-threads/store.js +48 -42
  139. package/dist/chat-threads/store.js.map +1 -1
  140. package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
  141. package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
  142. package/dist/cli/skills-content/design-visual-edit-skill.js +46 -3
  143. package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
  144. package/dist/client/AgentPanel.d.ts +3 -1
  145. package/dist/client/AgentPanel.d.ts.map +1 -1
  146. package/dist/client/AgentPanel.js +11 -9
  147. package/dist/client/AgentPanel.js.map +1 -1
  148. package/dist/client/AssistantChat.d.ts.map +1 -1
  149. package/dist/client/AssistantChat.js +57 -6
  150. package/dist/client/AssistantChat.js.map +1 -1
  151. package/dist/client/DefaultSpinner.d.ts +7 -0
  152. package/dist/client/DefaultSpinner.d.ts.map +1 -1
  153. package/dist/client/DefaultSpinner.js +25 -1
  154. package/dist/client/DefaultSpinner.js.map +1 -1
  155. package/dist/client/org/TeamPage.d.ts +13 -1
  156. package/dist/client/org/TeamPage.d.ts.map +1 -1
  157. package/dist/client/org/TeamPage.js +41 -11
  158. package/dist/client/org/TeamPage.js.map +1 -1
  159. package/dist/client/org/hooks.d.ts +37 -0
  160. package/dist/client/org/hooks.d.ts.map +1 -1
  161. package/dist/client/org/hooks.js +37 -0
  162. package/dist/client/org/hooks.js.map +1 -1
  163. package/dist/client/org/index.d.ts +3 -2
  164. package/dist/client/org/index.d.ts.map +1 -1
  165. package/dist/client/org/index.js +1 -1
  166. package/dist/client/org/index.js.map +1 -1
  167. package/dist/client/transcription/use-live-transcription.d.ts +8 -0
  168. package/dist/client/transcription/use-live-transcription.d.ts.map +1 -1
  169. package/dist/client/transcription/use-live-transcription.js +38 -11
  170. package/dist/client/transcription/use-live-transcription.js.map +1 -1
  171. package/dist/collab/routes.d.ts +2 -2
  172. package/dist/db/client.d.ts +12 -0
  173. package/dist/db/client.d.ts.map +1 -1
  174. package/dist/db/client.js +40 -3
  175. package/dist/db/client.js.map +1 -1
  176. package/dist/db/ensure-additive-columns.d.ts.map +1 -1
  177. package/dist/db/ensure-additive-columns.js +54 -32
  178. package/dist/db/ensure-additive-columns.js.map +1 -1
  179. package/dist/deploy/build.d.ts +1 -0
  180. package/dist/deploy/build.d.ts.map +1 -1
  181. package/dist/deploy/build.js +23 -2
  182. package/dist/deploy/build.js.map +1 -1
  183. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  184. package/dist/mcp-client/routes.d.ts +3 -1
  185. package/dist/mcp-client/routes.d.ts.map +1 -1
  186. package/dist/mcp-client/routes.js +8 -2
  187. package/dist/mcp-client/routes.js.map +1 -1
  188. package/dist/notifications/routes.d.ts +1 -1
  189. package/dist/org/app-roles-handlers.d.ts +27 -0
  190. package/dist/org/app-roles-handlers.d.ts.map +1 -0
  191. package/dist/org/app-roles-handlers.js +125 -0
  192. package/dist/org/app-roles-handlers.js.map +1 -0
  193. package/dist/org/app-roles.d.ts +136 -0
  194. package/dist/org/app-roles.d.ts.map +1 -0
  195. package/dist/org/app-roles.js +216 -0
  196. package/dist/org/app-roles.js.map +1 -0
  197. package/dist/org/index.d.ts +4 -1
  198. package/dist/org/index.d.ts.map +1 -1
  199. package/dist/org/index.js +3 -1
  200. package/dist/org/index.js.map +1 -1
  201. package/dist/org/migrations.d.ts.map +1 -1
  202. package/dist/org/migrations.js +22 -0
  203. package/dist/org/migrations.js.map +1 -1
  204. package/dist/org/plugin.d.ts +2 -0
  205. package/dist/org/plugin.d.ts.map +1 -1
  206. package/dist/org/plugin.js +20 -0
  207. package/dist/org/plugin.js.map +1 -1
  208. package/dist/org/schema.d.ts +143 -0
  209. package/dist/org/schema.d.ts.map +1 -1
  210. package/dist/org/schema.js +14 -0
  211. package/dist/org/schema.js.map +1 -1
  212. package/dist/progress/routes.d.ts +1 -1
  213. package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
  214. package/dist/provider-api/actions/provider-api.d.ts +12 -12
  215. package/dist/scripts/docs/search.d.ts.map +1 -1
  216. package/dist/scripts/docs/search.js +15 -0
  217. package/dist/scripts/docs/search.js.map +1 -1
  218. package/dist/scripts/docs/source-search.d.ts +7 -0
  219. package/dist/scripts/docs/source-search.d.ts.map +1 -1
  220. package/dist/scripts/docs/source-search.js +9 -0
  221. package/dist/scripts/docs/source-search.js.map +1 -1
  222. package/dist/secrets/routes.d.ts +9 -9
  223. package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
  224. package/dist/server/agent-chat/script-entries.js +3 -0
  225. package/dist/server/agent-chat/script-entries.js.map +1 -1
  226. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  227. package/dist/server/agent-chat-plugin.js +46 -48
  228. package/dist/server/agent-chat-plugin.js.map +1 -1
  229. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  230. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  231. package/dist/server/core-routes-plugin.js +6 -1
  232. package/dist/server/core-routes-plugin.js.map +1 -1
  233. package/dist/server/framework-request-handler.d.ts.map +1 -1
  234. package/dist/server/framework-request-handler.js +42 -6
  235. package/dist/server/framework-request-handler.js.map +1 -1
  236. package/dist/server/realtime-token.d.ts +1 -1
  237. package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  238. package/dist/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  239. package/dist/templates/chat/.agents/skills/security/SKILL.md +31 -0
  240. package/dist/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  241. package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -0
  242. package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  243. package/dist/templates/default/.agents/skills/security/SKILL.md +31 -0
  244. package/dist/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  245. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  246. package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  247. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  248. package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  249. package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  250. package/docs/content/actions.mdx +47 -4
  251. package/docs/content/native-chat-ui.mdx +7 -0
  252. package/docs/content/organizations-teams-permissions.mdx +109 -3
  253. package/docs/content/template-design-collaboration-and-full-apps.mdx +15 -0
  254. package/docs/content/toolkit-org-team.mdx +72 -12
  255. package/package.json +1 -1
  256. package/src/a2a/artifact-response.ts +36 -29
  257. package/src/action.ts +83 -2
  258. package/src/chat-threads/store.ts +48 -43
  259. package/src/cli/skills-content/design-visual-edit-skill.ts +46 -3
  260. package/src/client/AgentPanel.tsx +26 -6
  261. package/src/client/AssistantChat.tsx +63 -7
  262. package/src/client/DefaultSpinner.tsx +29 -0
  263. package/src/client/org/TeamPage.tsx +161 -6
  264. package/src/client/org/hooks.ts +67 -0
  265. package/src/client/org/index.ts +9 -0
  266. package/src/client/transcription/use-live-transcription.ts +62 -10
  267. package/src/db/client.ts +42 -3
  268. package/src/db/ensure-additive-columns.ts +60 -33
  269. package/src/deploy/build.ts +31 -2
  270. package/src/mcp-client/routes.ts +10 -1
  271. package/src/org/app-roles-handlers.ts +152 -0
  272. package/src/org/app-roles.ts +355 -0
  273. package/src/org/index.ts +27 -1
  274. package/src/org/migrations.ts +22 -0
  275. package/src/org/plugin.ts +27 -0
  276. package/src/org/schema.ts +15 -0
  277. package/src/scripts/docs/search.ts +17 -0
  278. package/src/scripts/docs/source-search.ts +10 -0
  279. package/src/server/agent-chat/script-entries.ts +3 -0
  280. package/src/server/agent-chat-plugin.ts +53 -52
  281. package/src/server/core-routes-plugin.ts +6 -1
  282. package/src/server/framework-request-handler.ts +44 -6
  283. package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -0
  284. package/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +7 -0
  285. package/src/templates/chat/.agents/skills/security/SKILL.md +31 -0
  286. package/src/templates/chat/.agents/skills/sharing/SKILL.md +4 -0
  287. package/src/templates/default/.agents/skills/actions/SKILL.md +32 -0
  288. package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +7 -0
  289. package/src/templates/default/.agents/skills/security/SKILL.md +31 -0
  290. package/src/templates/headless/.agents/skills/actions/SKILL.md +32 -0
  291. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -0
  292. package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +7 -0
  293. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +40 -0
  294. package/src/templates/workspace-core/.agents/skills/security/SKILL.md +31 -0
  295. package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +4 -0
  296. package/corpus/core/src/templates/chat/.agents/skills/actions/SKILL.md +0 -530
  297. package/corpus/core/src/templates/chat/.agents/skills/adding-a-feature/SKILL.md +0 -191
  298. package/corpus/core/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +0 -115
  299. package/corpus/core/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +0 -177
  300. package/corpus/core/src/templates/chat/.agents/skills/capture-learnings/SKILL.md +0 -89
  301. package/corpus/core/src/templates/chat/.agents/skills/create-skill/SKILL.md +0 -221
  302. package/corpus/core/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +0 -220
  303. package/corpus/core/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +0 -263
  304. package/corpus/core/src/templates/chat/.agents/skills/feature-flags/SKILL.md +0 -169
  305. package/corpus/core/src/templates/chat/.agents/skills/frontend-design/SKILL.md +0 -174
  306. package/corpus/core/src/templates/chat/.agents/skills/real-time-sync/SKILL.md +0 -232
  307. package/corpus/core/src/templates/chat/.agents/skills/security/SKILL.md +0 -282
  308. package/corpus/core/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +0 -119
  309. package/corpus/core/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +0 -123
  310. package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +0 -122
  311. package/corpus/core/src/templates/chat/.env.example +0 -5
  312. package/corpus/core/src/templates/chat/.ignore +0 -0
  313. package/corpus/core/src/templates/chat/.oxfmtrc.json +0 -8
  314. package/corpus/core/src/templates/chat/AGENTS.md +0 -77
  315. package/corpus/core/src/templates/chat/CHANGELOG.md +0 -10
  316. package/corpus/core/src/templates/chat/DEVELOPING.md +0 -185
  317. package/corpus/core/src/templates/chat/README.md +0 -32
  318. package/corpus/core/src/templates/chat/_gitignore +0 -46
  319. package/corpus/core/src/templates/chat/actions/hello.ts +0 -13
  320. package/corpus/core/src/templates/chat/actions/navigate.ts +0 -41
  321. package/corpus/core/src/templates/chat/actions/run.ts +0 -2
  322. package/corpus/core/src/templates/chat/actions/view-screen.ts +0 -31
  323. package/corpus/core/src/templates/chat/app/components/layout/Header.tsx +0 -60
  324. package/corpus/core/src/templates/chat/app/components/layout/Layout.tsx +0 -188
  325. package/corpus/core/src/templates/chat/app/components/layout/Sidebar.tsx +0 -505
  326. package/corpus/core/src/templates/chat/app/components/ui/button.tsx +0 -1
  327. package/corpus/core/src/templates/chat/app/components/ui/card.tsx +0 -1
  328. package/corpus/core/src/templates/chat/app/components/ui/dropdown-menu.tsx +0 -1
  329. package/corpus/core/src/templates/chat/app/components/ui/input.tsx +0 -1
  330. package/corpus/core/src/templates/chat/app/components/ui/label.tsx +0 -1
  331. package/corpus/core/src/templates/chat/app/components/ui/sheet.tsx +0 -1
  332. package/corpus/core/src/templates/chat/app/components/ui/toolkit-provider.tsx +0 -17
  333. package/corpus/core/src/templates/chat/app/components/ui/tooltip.tsx +0 -1
  334. package/corpus/core/src/templates/chat/app/design-system.ts +0 -3
  335. package/corpus/core/src/templates/chat/app/entry.client.tsx +0 -22
  336. package/corpus/core/src/templates/chat/app/entry.server.tsx +0 -10
  337. package/corpus/core/src/templates/chat/app/global.css +0 -93
  338. package/corpus/core/src/templates/chat/app/hooks/use-navigation-state.ts +0 -93
  339. package/corpus/core/src/templates/chat/app/i18n/ar-SA.ts +0 -68
  340. package/corpus/core/src/templates/chat/app/i18n/de-DE.ts +0 -71
  341. package/corpus/core/src/templates/chat/app/i18n/en-US.ts +0 -70
  342. package/corpus/core/src/templates/chat/app/i18n/es-ES.ts +0 -71
  343. package/corpus/core/src/templates/chat/app/i18n/fr-FR.ts +0 -71
  344. package/corpus/core/src/templates/chat/app/i18n/hi-IN.ts +0 -69
  345. package/corpus/core/src/templates/chat/app/i18n/index.ts +0 -34
  346. package/corpus/core/src/templates/chat/app/i18n/ja-JP.ts +0 -70
  347. package/corpus/core/src/templates/chat/app/i18n/ko-KR.ts +0 -70
  348. package/corpus/core/src/templates/chat/app/i18n/pt-BR.ts +0 -71
  349. package/corpus/core/src/templates/chat/app/i18n/zh-CN.ts +0 -66
  350. package/corpus/core/src/templates/chat/app/i18n/zh-TW.ts +0 -66
  351. package/corpus/core/src/templates/chat/app/i18n-data.ts +0 -556
  352. package/corpus/core/src/templates/chat/app/lib/agent-page.tsx +0 -49
  353. package/corpus/core/src/templates/chat/app/lib/app-config.ts +0 -11
  354. package/corpus/core/src/templates/chat/app/lib/tab-id.ts +0 -1
  355. package/corpus/core/src/templates/chat/app/lib/utils.ts +0 -1
  356. package/corpus/core/src/templates/chat/app/root.tsx +0 -173
  357. package/corpus/core/src/templates/chat/app/routes/_index.tsx +0 -94
  358. package/corpus/core/src/templates/chat/app/routes/agent.tsx +0 -24
  359. package/corpus/core/src/templates/chat/app/routes/chat.$threadId.tsx +0 -1
  360. package/corpus/core/src/templates/chat/app/routes/database.tsx +0 -17
  361. package/corpus/core/src/templates/chat/app/routes/extensions.$id.$slug.tsx +0 -2
  362. package/corpus/core/src/templates/chat/app/routes/extensions.$id.tsx +0 -11
  363. package/corpus/core/src/templates/chat/app/routes/extensions._index.tsx +0 -11
  364. package/corpus/core/src/templates/chat/app/routes/extensions.tsx +0 -5
  365. package/corpus/core/src/templates/chat/app/routes/observability.tsx +0 -19
  366. package/corpus/core/src/templates/chat/app/routes/settings.tsx +0 -89
  367. package/corpus/core/src/templates/chat/app/routes/team.tsx +0 -11
  368. package/corpus/core/src/templates/chat/app/routes.ts +0 -4
  369. package/corpus/core/src/templates/chat/app/vite-env.d.ts +0 -6
  370. package/corpus/core/src/templates/chat/changelog/2026-06-24-a-new-settings-page-gives-quick-access-to-language-workspace.md +0 -6
  371. package/corpus/core/src/templates/chat/changelog/2026-06-24-added-a-language-picker-and-localized-app-chrome-for-support.md +0 -6
  372. package/corpus/core/src/templates/chat/changelog/2026-06-27-traditional-chinese-copy-uses-taiwan-terminology.md +0 -6
  373. package/corpus/core/src/templates/chat/changelog/2026-06-28-left-sidebar-collapse-motion-and-footer-chrome-are-quieter.md +0 -6
  374. package/corpus/core/src/templates/chat/changelog/2026-06-29-chat-layouts-adapt-when-the-agent-sidebar-is-open.md +0 -6
  375. package/corpus/core/src/templates/chat/changelog/2026-07-08-settings-are-cleaner-and-searchable.md +0 -5
  376. package/corpus/core/src/templates/chat/changelog/2026-07-10-chat-now-makes-ai-connection-setup-clear-without-shifting-th.md +0 -6
  377. package/corpus/core/src/templates/chat/changelog/2026-07-13-a-full-agent-page-now-brings-context-files-connections-jobs-.md +0 -6
  378. package/corpus/core/src/templates/chat/changelog/2026-07-14-chat-opens-reliably-on-hosted-deployments-instead-of-failing.md +0 -6
  379. package/corpus/core/src/templates/chat/changelog/2026-07-14-fixed-chat-template-startup-with-older-core-versions.md +0 -6
  380. package/corpus/core/src/templates/chat/changelog/2026-07-15-chat-navigation-focuses-on-chat-and-agent.md +0 -6
  381. 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
  382. package/corpus/core/src/templates/chat/changelog/2026-07-22-compact-sidebar-footer.md +0 -6
  383. package/corpus/core/src/templates/chat/changelog/2026-07-22-full-page-chat-keeps-the-active-conversation-when-moving-to-.md +0 -6
  384. package/corpus/core/src/templates/chat/changelog/2026-07-22-manage-agent-navigation-now-uses-the-connected-nodes-icon.md +0 -6
  385. package/corpus/core/src/templates/chat/changelog/2026-07-22-recent-chats-are-easier-to-scan-and-expand.md +0 -6
  386. package/corpus/core/src/templates/chat/changelog/2026-07-23-full-page-chat-is-better-centered-with-quieter-chat-history-.md +0 -6
  387. package/corpus/core/src/templates/chat/changelog/2026-07-24-borderless-secondary-surfaces.md +0 -6
  388. package/corpus/core/src/templates/chat/changelog/2026-07-24-sidebar-footer-controls-follow-a-consistent-order.md +0 -6
  389. package/corpus/core/src/templates/chat/changelog/2026-07-25-settings-navigation-now-keeps-manage-agent-as-a-dedicated-li.md +0 -6
  390. package/corpus/core/src/templates/chat/components.json +0 -20
  391. package/corpus/core/src/templates/chat/learnings.defaults.md +0 -5
  392. package/corpus/core/src/templates/chat/netlify.toml +0 -11
  393. package/corpus/core/src/templates/chat/package.json +0 -92
  394. package/corpus/core/src/templates/chat/public/agent-native-icon-dark.svg +0 -10
  395. package/corpus/core/src/templates/chat/public/agent-native-icon-light.svg +0 -10
  396. package/corpus/core/src/templates/chat/public/agent-native-logo-dark.svg +0 -21
  397. package/corpus/core/src/templates/chat/public/agent-native-logo-light.svg +0 -21
  398. package/corpus/core/src/templates/chat/public/favicon.svg +0 -1
  399. package/corpus/core/src/templates/chat/public/icon-180.svg +0 -1
  400. package/corpus/core/src/templates/chat/public/icon-192.svg +0 -1
  401. package/corpus/core/src/templates/chat/public/icon-512.svg +0 -1
  402. package/corpus/core/src/templates/chat/public/manifest.json +0 -21
  403. package/corpus/core/src/templates/chat/react-router.config.ts +0 -7
  404. package/corpus/core/src/templates/chat/server/middleware/auth.ts +0 -15
  405. package/corpus/core/src/templates/chat/server/plugins/agent-chat.ts +0 -21
  406. package/corpus/core/src/templates/chat/server/plugins/auth.ts +0 -17
  407. package/corpus/core/src/templates/chat/server/routes/[...page].get.ts +0 -5
  408. package/corpus/core/src/templates/chat/ssr-entry.ts +0 -15
  409. package/corpus/core/src/templates/chat/tsconfig.json +0 -21
  410. package/corpus/core/src/templates/chat/vite.config.ts +0 -19
@@ -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:
@@ -1,530 +0,0 @@
1
- ---
2
- name: actions
3
- description: >-
4
- How to create and run agent actions. Actions are the single source of truth
5
- for app operations — the agent calls them as tools and frontend code calls
6
- them through client hooks. Use when creating a new action, adding an API
7
- integration, or wiring up frontend data fetching.
8
- scope: dev
9
- metadata:
10
- internal: true
11
- ---
12
-
13
- # Agent Actions
14
-
15
- ## Rule
16
-
17
- Actions in `actions/` are the **single source of truth** for app operations. The agent calls them as tools, and the frontend calls them through `useActionQuery` / `useActionMutation`. The framework owns the HTTP transport behind those hooks. No duplicate `/api/` routes needed.
18
-
19
- Before creating any custom REST/API route for app data, inspect `actions/` and the action table in `AGENTS.md`. If an action already exists, call it directly from the agent or with `useActionQuery` / `useActionMutation` from the UI. If the capability is missing, create or update a `defineAction`. Do not add `/api/*`, `server/routes/*`, or other pass-through endpoints whose main job is to call, repackage, or re-export an action.
20
-
21
- **Stop trigger:** the moment you are about to create a file under `server/routes/api/` — or add server middleware to guard one — stop and check it against the exception list in *When You Still Need Custom `/api/` Routes* below. If it is not on that list, write a `defineAction` instead. This applies even when you already started the route; abandoning a half-written action to hand-roll routes is the exact failure this rule exists to prevent.
22
-
23
- ## Why
24
-
25
- Actions give the agent callable tools with structured input/output, AND they give the frontend a typed client contract through hooks. One implementation serves both the agent and the UI. They keep the agent's chat context clean, they're reusable, and they can be tested independently.
26
-
27
- ## Keep the Action Surface Small and Orthogonal
28
-
29
- Every agent-exposed action is a tool in the model's context window. There is a real cost to each one: more tools means more for the model to read, disambiguate, and choose between, which degrades tool-selection quality. Treat the action list like an API you have to maintain — add the fewest, most orthogonal actions that cover the capability, not one per UI affordance.
30
-
31
- - **Prefer one CRUD-style `update` over N per-field actions.** A single `update-<thing>` that takes a patch of optional fields beats `update-<thing>-name`, `update-<thing>-order`, `update-<thing>-color`, … The agent (and the UI) pass only the fields that change. Same for `create`/`delete` — one orthogonal action per resource, not one per code path.
32
- - **Reach for a generic query / escape hatch before minting a new read action.** If the agent needs more or different data, do not add `get-<thing>-by-x`, `list-<thing>-filtered-by-y`, etc. For provider data, expose the shared `provider-api-catalog` / `provider-api-docs` / `provider-api-request` trio (see `templates/dispatch/actions/`) so the agent can hit any endpoint or filter without a new action each time. For app data in dev, the `db-query` tool already answers arbitrary read questions.
33
- - **Hide UI-only or purely programmatic actions from the model with `agentTool: false`.** An action that only the frontend or an HTTP/cron caller needs should not spend a slot in the model's tool list. `agentTool: false` keeps it callable from `useActionMutation` / `callAction` / `/_agent-native/actions/<name>` while removing it from every agent tool surface (in-app assistant, MCP, A2A).
34
- - **`agentTool: false` is NOT `toolCallable: false`.** They are different switches:
35
- - `agentTool: false` → hidden from the **model entirely** (it is no longer a tool the agent can see or call). Still frontend/HTTP-callable.
36
- - `toolCallable: false` → only blocks the **sandboxed extension ("tools") iframe bridge** (`appAction(...)`). The action stays fully visible to the model, the UI, the CLI, MCP, and A2A. Use it for high-blast-radius operations (account/org/auth changes), not for trimming the tool list.
37
- - **Remove or hide stale actions.** When the UI stops using an action, delete it or set `agentTool: false` — do not leave it exposed to the model as dead tool weight. The advisory audit below helps you spot these.
38
-
39
- ### Audit Script (Advisory)
40
-
41
- `pnpm actions:audit [template ...]` (or `node scripts/audit-template-actions.mjs`) statically scans a template's `actions/` and prints two kinds of suggestions:
42
-
43
- 1. **Likely UI-dead** — HTTP-exposed mutating actions whose name is never referenced under `app/` (candidates to delete or mark `agentTool: false`).
44
- 2. **Likely redundant clusters** — groups like `update-foo-name` / `update-foo-order` that could collapse into one orthogonal `update-foo`.
45
-
46
- It is **advisory only**: it always exits 0, never fails CI, and uses conservative heuristics, so expect some false positives (e.g. an action the agent calls but the UI doesn't). Use it as a prompt to review, not a gate.
47
-
48
- ## How to Create an Action
49
-
50
- Use `defineAction` with a Zod schema (required for new actions):
51
-
52
- ```ts
53
- // actions/list-meals.ts
54
- import { z } from "zod";
55
- import { defineAction } from "@agent-native/core/action";
56
- import { getDb } from "../server/db/index.js";
57
- import { meals } from "../server/db/schema.js";
58
-
59
- export default defineAction({
60
- description: "List all meals",
61
- schema: z.object({
62
- date: z.string().describe("Filter by date (YYYY-MM-DD)"),
63
- }),
64
- http: { method: "GET" },
65
- run: async (args) => {
66
- // args is fully typed: { date: string }
67
- const db = getDb();
68
- const rows = await db.select().from(meals);
69
- return rows; // Return objects/arrays, NOT JSON.stringify()
70
- },
71
- });
72
- ```
73
-
74
- The `schema` field accepts a Zod schema (or any Standard Schema-compatible library). It provides runtime validation with clear error messages (400 for HTTP, error result for agent), full TypeScript type inference for `run()` args, and auto-generated JSON Schema for the agent's tool definition. `zod` is a dependency of all templates.
75
-
76
- When an action reads or writes app data, use Drizzle's query builder and portable operators from `drizzle-orm`. Do not use raw SQL, `getDbExec()`, or dialect-specific schema imports in normal actions unless there is a documented reason Drizzle cannot express the query.
77
-
78
- When an action calls an external service, never hardcode API keys, bearer
79
- tokens, webhook URLs, signing secrets, OAuth refresh tokens, private
80
- Builder/internal data, or customer data. Read user/org/workspace credentials
81
- from `readAppSecret`, `resolveCredential`, OAuth token helpers, or the provider
82
- API credential adapter. Use `process.env` only for explicitly deploy-level
83
- configuration, and keep examples to obvious placeholders.
84
-
85
- Tips:
86
- - Use `.describe()` for parameter descriptions
87
- - Use `.optional()` for optional params
88
- - Use `z.coerce.number()` for numeric params that arrive as strings from HTTP.
89
- For booleans, use an explicit string parser/helper instead of
90
- `z.coerce.boolean()` because JavaScript treats any non-empty string,
91
- including `"false"`, as truthy.
92
- - Use `z.enum(["draft", "published"])` for constrained values
93
-
94
- The legacy `parameters` field (plain JSON Schema object) still works as a fallback but does not provide runtime validation or type inference.
95
-
96
- ## Decision Order
97
-
98
- When you need app data or a mutation:
99
-
100
- 1. **Use an existing action** if one already performs the operation.
101
- 2. **Create or extend a `defineAction`** when the agent and UI both need a new operation.
102
- 3. **Create a custom route only for route-only concerns** such as uploads, streaming, webhooks, OAuth callbacks, or a non-JSON protocol.
103
-
104
- Do not build an umbrella REST API to make actions "easier" to call. Actions are already callable by agents, CLIs, React hooks, HTTP, MCP/A2A exposure, and external hosts through the framework.
105
-
106
- ## Flexible Provider APIs
107
-
108
- For provider integrations used in ad hoc analysis, querying, reporting, or
109
- cross-source research, do not hardcode every provider endpoint as a separate
110
- rigid action and do not encode one lookback window, filter shape, or pagination
111
- strategy as the only path the agent can take. Expose the shared provider API
112
- action trio instead:
113
-
114
- - `provider-api-catalog`: lists provider base URLs, auth style, credential keys,
115
- docs/spec URLs, placeholders, and examples without exposing secrets.
116
- - `provider-api-docs`: fetches public provider docs/spec/changelog URLs when
117
- the exact endpoint, filter operator, payload shape, or pagination contract is
118
- uncertain. Registered docs URLs are curated starting points. Use
119
- `responseMode: "markdown"` for clean readable docs, or
120
- `responseMode: "matches"` with `search: { query | terms | regex }` for
121
- compact snippets instead of flooding context with raw HTML.
122
- - `provider-api-request`: makes a constrained authenticated HTTP request to the
123
- provider host, injects configured credentials, blocks private/internal URLs,
124
- and redacts secrets.
125
-
126
- Use `@agent-native/core/provider-api` as the shared substrate, and build these
127
- actions as thin factory imports rather than copying `defineAction` schemas and
128
- handlers into each template:
129
-
130
- ```ts
131
- import {
132
- createProviderApiCatalogAction,
133
- createProviderApiDocsAction,
134
- createProviderApiRequestAction,
135
- } from "@agent-native/core/provider-api/actions/provider-api";
136
- import {
137
- createDeleteStagedDatasetAction,
138
- createListStagedDatasetsAction,
139
- createQueryStagedDatasetAction,
140
- } from "@agent-native/core/provider-api/actions/staged-datasets";
141
- ```
142
-
143
- Pass the app's existing provider runtime to the provider factories, and pass
144
- its app id to the staged-dataset factories. Keep app-specific descriptions,
145
- provider allow-lists, HTTP/tool-callability settings, and credential adapters
146
- as factory options. Only add a thin credential adapter when the app has
147
- app-specific credential lookup rules. If the app stores a built-in provider's
148
- OAuth grant under a narrower local provider id, use the runtime's
149
- `oauthProviderOverrides` instead of duplicating provider config. If credentials
150
- are stored on shareable/resource rows rather than in the shared credential or
151
- OAuth-token stores, build a resolver that enforces those access checks before
152
- exposing raw provider requests. Keep `provider-api-request` `http: false`
153
- unless a separate UI permission model authorizes arbitrary provider writes.
154
- Specific actions such as `search-records`, `search-emails`, or `sync-source`
155
- are convenience shortcuts, not capability limits; agents should fall back to
156
- the provider API trio when a question requires an endpoint or filter that the
157
- shortcut does not model.
158
-
159
- This is a framework tenet. The safety boundary should be provider host
160
- allow-listing, credential scoping, auth injection, private-network blocking,
161
- secret redaction, and user/org access checks, not an artificially small set of
162
- hand-authored read actions. If the upstream provider API supports a capability,
163
- the agent should normally be able to reach it through `provider-api-request`
164
- with the user's configured credentials. For large responses, expose staging
165
- (`stageAs`, `itemsPath`, pagination, and `query-staged-dataset`) or sandboxed
166
- code execution so the agent can reduce data without flooding context.
167
-
168
- For broad provider questions, cross-source joins, corpus-wide mention/search
169
- work, classification, or any answer where absence matters, design the action
170
- surface for full coverage instead of convenience-only samples. The agent should
171
- be able to fetch every relevant page or an explicitly bounded cohort, stage or
172
- save the raw provider response outside chat, and then use
173
- `query-staged-dataset`, `run-code`, or provider-side search to count, join,
174
- grep, classify, and aggregate. Tool descriptions and AGENTS.md guidance should
175
- teach agents to report source, filters, time window, row/record counts,
176
- pagination status, truncation, failed pages, and uncovered gaps. They must not
177
- turn default limits, sampled rows, truncated excerpts, or aborted calls into a
178
- confident "none found", "all records", or exhaustive conclusion.
179
-
180
- For public web pages and docs, prefer the token-efficient path: `web-search`
181
- to find likely URLs, `web-request` or `provider-api-docs` with clean
182
- `responseMode` output to read a page, and `run-code` with `webRead()` /
183
- `webFetch()` when you need to grep, aggregate, or compare many pages before
184
- returning a small result.
185
-
186
- For LONG compute, `run-code` supports durable background executions: pass
187
- `background: true` and the code is enqueued to a `sandbox_executions` row and
188
- executed out-of-band with a generous budget (default 10 min), surviving the
189
- hosted agent run's ~40s soft timeout. The call returns
190
- `{ executionId, status: "queued" }` immediately with polling guidance; check
191
- progress with `run-code` `{ executionId }` (or the `get-code-execution` tool
192
- where registered) — results persist after completion. Use background for big
193
- cross-source joins, multi-page provider sweeps, and heavy analysis scripts;
194
- keep quick scripts in the default foreground mode. Agents should continue
195
- other work between polls, and on `failed`/`timed_out` split the computation or
196
- persist intermediate progress with `workspaceWrite` and re-run.
197
-
198
- ### The `http` Option
199
-
200
- Controls how the action is exposed as an HTTP endpoint:
201
-
202
- | Value | Behavior | Use for |
203
- | ------------------------- | ----------------------------------------------------------- | -------------------------------- |
204
- | _(omitted)_ | Auto-exposed as `POST /_agent-native/actions/:name` | Write operations (default) |
205
- | `{ method: "GET" }` | Auto-exposed as `GET /_agent-native/actions/:name` | Read-only queries |
206
- | `{ method: "PUT" }` | Auto-exposed as `PUT /_agent-native/actions/:name` | Update operations |
207
- | `{ method: "DELETE" }` | Auto-exposed as `DELETE /_agent-native/actions/:name` | Delete operations |
208
- | `{ method: "GET", path: "custom" }` | Auto-exposed as `GET /_agent-native/actions/custom` | Custom route path |
209
- | `false` | Agent-only, never exposed as HTTP | `navigate`, `view-screen`, internal actions |
210
-
211
- ### Screen Refresh (automatic)
212
-
213
- The framework auto-refreshes the UI after any successful mutating action. On completion of a non-`GET` action, the framework emits a change event with `source: "action"` that the client's `useDbSync` picks up and uses to invalidate `["action"]` React Query keys — so `list-*` / `get-*` hooks refetch without a full page reload. In-process calls emit directly; dev-mode `pnpm action ...` calls also write a durable marker so the web server sees child-process action changes.
214
-
215
- Rules:
216
-
217
- - `http: { method: "GET" }` → read-only, does NOT trigger a refresh (inferred automatically).
218
- - Any other action (default `POST`, `PUT`, `DELETE`, or `http: false`) → treated as mutating, triggers a refresh on success.
219
- - To override the inference on an unusual action (e.g. a `POST` that only reads), pass `readOnly: true` on the action definition.
220
- - To let a mutating action run concurrently with other same-turn tool calls, pass `parallelSafe: true`. Only do this when the action is internally concurrency-safe and order-independent (for example, it uses an app-level lock or idempotent upsert semantics). Mutating actions remain serialized by default.
221
-
222
- Agents do NOT need to call `refresh-screen` after a normal action — it's already handled. `refresh-screen` is only needed when the agent mutates data via a path the framework can't see (e.g. writing to an external system the app mirrors) or when the agent wants to pass a `scope` hint for narrower invalidation.
223
-
224
- ### Return Values
225
-
226
- Actions should return **structured data** (objects, arrays) — not `JSON.stringify()`. The framework serializes the response automatically. If you return a string, the framework tries to parse it as JSON for a clean response.
227
-
228
- ```ts
229
- // Good — return structured data
230
- run: async (args) => {
231
- const events = await fetchEvents(args.from, args.to);
232
- return events;
233
- }
234
-
235
- // Bad — don't stringify
236
- run: async (args) => {
237
- const events = await fetchEvents(args.from, args.to);
238
- return JSON.stringify(events, null, 2);
239
- }
240
- ```
241
-
242
- ### Returning Images the Agent Can See (`_agentImages`)
243
-
244
- An action's return object may include the well-known optional field
245
- `_agentImages` to attach vision images (screenshots, chart previews, rendered
246
- designs) to the tool result. The agent literally sees them — enabling visual
247
- self-review loops — while the field itself is stripped from the JSON text the
248
- model reads.
249
-
250
- ```ts
251
- run: async ({ dashboardId }) => {
252
- const shot = await renderDashboardPng(dashboardId); // Buffer
253
- return {
254
- dashboardId,
255
- panelCount: 6,
256
- _agentImages: [
257
- // Either a public https URL (preferred — the provider fetches it)…
258
- { url: "https://cdn.example.com/previews/dash-1.png", label: "overview" },
259
- // …or base64 without a data: prefix (mediaType required; a full
260
- // data:image/png;base64,… URL in `data` is also accepted and parsed).
261
- { data: shot.toString("base64"), mediaType: "image/png" },
262
- ],
263
- };
264
- },
265
- ```
266
-
267
- Rules and limits:
268
-
269
- - Shape: `Array<{ url?: string; data?: string; mediaType?: string; label?: string }>`.
270
- Each entry needs `url` (https only) **or** `data`. Supported media types:
271
- `image/jpeg`, `image/png`, `image/gif`, `image/webp`.
272
- - Caps: max **4 images** per result; max **~2MB of base64** per image.
273
- Over-cap or invalid entries never fail the call — they become text notes in
274
- the result telling the model what was dropped and why.
275
- - Persistence: the run ledger stores only the string result plus compact
276
- `[image: …]` notes (URLs verbatim; base64 as a byte-count placeholder) —
277
- never the payload. Images are re-attached only for the live turn; replayed
278
- history is text-only, so prefer stable `url` images the model can re-request.
279
- - Engine support: native Anthropic and vision-capable AI-SDK providers
280
- (anthropic, openai, google, openrouter) receive real image blocks; other
281
- paths (Builder gateway, non-vision providers) degrade to the text notes.
282
- - External MCP tools need no changes — standard MCP `image` content parts are
283
- converted automatically under the same caps.
284
-
285
- ### Validating Return Values (`outputSchema`)
286
-
287
- `schema` validates inputs; `outputSchema` validates what the action **returns**. Pass any Standard Schema-compatible schema (Zod, Valibot, ArkType) and the framework validates the result _after_ `run()` resolves — input validated before `run`, output after.
288
-
289
- ```ts
290
- export default defineAction({
291
- description: "Summarize a thread.",
292
- schema: z.object({ threadId: z.string() }),
293
- outputSchema: z.object({ summary: z.string(), messageCount: z.number() }),
294
- outputErrorStrategy: "warn", // default; "strict" | "fallback"
295
- // outputFallback: { summary: "", messageCount: 0 }, // used only by "fallback"
296
- run: async ({ threadId }) => {
297
- /* ... */
298
- },
299
- });
300
- ```
301
-
302
- - `"warn"` (default) — `console.warn` the issues and return the **original** result unchanged. Non-breaking.
303
- - `"strict"` — throw a clear error so a buggy action surfaces loudly.
304
- - `"fallback"` — return `outputFallback` in place of the invalid result.
305
-
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
-
308
- ### Human-in-the-Loop Approval (`needsApproval`)
309
-
310
- 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:
311
-
312
- ```ts
313
- export default defineAction({
314
- description: "Send an email via Gmail.",
315
- schema: z.object({ to: z.string(), subject: z.string(), body: z.string() }),
316
- needsApproval: true, // boolean, or (args, ctx) => boolean | Promise<boolean>
317
- run: async (args) => {
318
- /* ...actually send... */
319
- },
320
- });
321
- ```
322
-
323
- When the gate is truthy and the call isn't yet approved, the loop emits an `approval_required` event and **stops the turn — `run()` never executes**. A predicate gates conditionally (e.g. only external recipients) and **fails closed**: a throw is treated as "approval required". The human approves via the chat UI's Approve affordance, which re-issues the turn with the call's `approvalKey`, and only then does the action run.
324
-
325
- **Keep approvals rare** — the default is off and almost every action should leave it off. The canonical example is Mail's `send-email` (`needsApproval: true`). See the `security` skill and the Human Approval doc.
326
-
327
- ## Frontend Hooks
328
-
329
- The frontend calls actions using React Query hooks from `@agent-native/core/client`. Components should not hand-write `fetch("/_agent-native/actions/...")`; add or reuse a client hook/helper instead. Use `callAction` from the same package for imperative cases that do not fit a hook, such as debounced search, prefetching, or non-React event handlers.
330
-
331
- ### `useActionQuery` — for GET actions
332
-
333
- ```ts
334
- import { useActionQuery } from "@agent-native/core/client/hooks";
335
-
336
- function MealList() {
337
- // Types are auto-inferred from the action's schema + return type — no manual generic needed
338
- const { data: meals } = useActionQuery("list-meals", {
339
- date: "2025-01-01",
340
- });
341
- return <ul>{meals?.map((m) => <li key={m.id}>{m.name}</li>)}</ul>;
342
- }
343
- ```
344
-
345
- ### `useActionMutation` — for POST/PUT/DELETE actions
346
-
347
- ```ts
348
- import { useActionMutation } from "@agent-native/core/client/hooks";
349
-
350
- function AddMealButton() {
351
- // Types are auto-inferred — no manual generic needed
352
- const { mutate } = useActionMutation("log-meal");
353
- return (
354
- <button onClick={() => mutate({ name: "Salad", calories: 350 })}>
355
- Log Meal
356
- </button>
357
- );
358
- }
359
- ```
360
-
361
- **Do NOT use manual type generics** like `useActionQuery<Meal[]>(...)`. Types are inferred automatically from `.generated/action-types.d.ts`, which is auto-generated by a Vite plugin.
362
-
363
- Mutations automatically invalidate all `["action"]` query keys on success, so GET queries refetch.
364
-
365
- ### `callAction` — for imperative client code
366
-
367
- ```ts
368
- import { callAction } from "@agent-native/core/client/hooks";
369
-
370
- const people = await callAction("search-people", { query }, { method: "GET" });
371
- ```
372
-
373
- Prefer hooks in React data flows. Use `callAction` when a hook would be awkward;
374
- do not hand-write action route fetches in components.
375
-
376
- ## How to Run (Agent)
377
-
378
- ```bash
379
- pnpm action my-action --input data/source.json --output data/result.json
380
- ```
381
-
382
- ## Action Dispatcher
383
-
384
- The default template uses core's `runScript()` in `actions/run.ts`:
385
-
386
- ```ts
387
- import { runScript } from "@agent-native/core";
388
- runScript();
389
- ```
390
-
391
- This is the canonical approach for new apps. Action names must be lowercase with hyphens only (e.g., `my-action`).
392
-
393
- ## When You Still Need Custom `/api/` Routes
394
-
395
- This is the complete exception list. A route in `server/routes/api/` is only
396
- justified when the caller is not your own UI or agent, or when the payload is
397
- not JSON:
398
-
399
- - **File uploads** — actions receive JSON params, not multipart form data
400
- - **Streaming responses** — SSE or chunked responses that need direct H3 control
401
- - **Webhooks** — external services POST to a specific URL
402
- - **OAuth callbacks** — redirect-based flows that need specific URL patterns
403
- - **Public unauthenticated endpoints** — SEO/OG images, share links, and other
404
- URLs opened directly by a browser or crawler
405
- - **Binary or non-JSON responses** — media, exports, generated assets
406
-
407
- Everything else is an action: CRUD, settings, search, list/detail reads, auth
408
- state, and anything the UI fetches as JSON. If a route needs new middleware to
409
- scope it to the current user, that is a signal it should be an action — actions
410
- already run inside request context with access checks.
411
-
412
- Existing first-party templates still contain a shrinking, explicitly
413
- grandfathered set of older `/api/*` CRUD routes for app data. The repository's
414
- `guard:no-action-twin-routes` CI check ratchets that baseline down across the
415
- first-party template route trees (with the separately owned Plan template
416
- fenced out); it is not a substitute for keeping generated apps action-first.
417
-
418
- When the agent needs a durable image or file URL, call the core `upload-image`
419
- action or use `uploadFile()` in server code. Do not write base64 into SQL,
420
- markdown, deck/design JSON, or action results. `_agentImages` on action results
421
- is for ephemeral vision previews only, not persistence.
422
-
423
- If it's a standard CRUD operation, data query, or a wrapper around an action, use the action instead.
424
-
425
- ## Legacy Pattern (bare export)
426
-
427
- Older actions use a bare async function export with `parseArgs`:
428
-
429
- ```ts
430
- import { parseArgs, loadEnv, fail } from "@agent-native/core";
431
-
432
- export default async function myAction(args: string[]) {
433
- loadEnv();
434
- const parsed = parseArgs(args);
435
- // ...
436
- }
437
- ```
438
-
439
- This still works but is not auto-exposed as HTTP. Prefer `defineAction` for all new actions.
440
-
441
- ## Guidelines
442
-
443
- - **One action, one job.** Keep actions focused on a single operation. The agent composes multiple action calls for complex operations.
444
- - **Return structured data.** Return objects/arrays, not `JSON.stringify()`.
445
- - **Use `http: { method: "GET" }`** for read-only actions. Default is POST.
446
- - **Use `http: false`** for agent-only actions (`navigate`, `view-screen`).
447
- - **Use `agentTool: false`** for UI-only / programmatic actions that should NOT be a tool in the model's context window. It stays frontend/HTTP-callable but is hidden from the agent. Distinct from `toolCallable: false`, which only blocks the sandboxed extension iframe bridge.
448
- - **Document reusable actions.** If a new action should be called by agents outside one narrow screen, update `AGENTS.md` with when to use it, important args, and which return fields to preserve.
449
- - **Promote workflow-heavy actions to skills.** If the action is part of a provider-backed, cross-app, MCP/A2A, or multi-step workflow, create or update a skill in `.agents/skills/` and add app-skill visibility (`internal`, `exported`, or `both`) when it should ship through a marketplace.
450
- - **Use `loadEnv()`** only for deploy-level configuration. User/org/workspace
451
- credentials belong in the encrypted secrets/credential/OAuth stores, never as
452
- hardcoded literals or shared env fallbacks.
453
- - **Use `fail()`** for user-friendly error messages (exits with message, no stack trace).
454
- - **Import action primitives from `@agent-native/core/action`** and CLI helpers such as `parseArgs()` from `@agent-native/core` — do not redefine framework utilities locally.
455
- - **Do not re-export actions as REST.** The mounted `/_agent-native/actions/:name` endpoint is the REST surface; duplicating it under `/api/*` creates drift and hides the operation from agents.
456
-
457
- ## Common Patterns
458
-
459
- **Read action (GET):**
460
-
461
- ```ts
462
- import { z } from "zod";
463
- import { defineAction } from "@agent-native/core/action";
464
-
465
- export default defineAction({
466
- description: "List calendar events",
467
- schema: z.object({
468
- from: z.string().describe("Start date"),
469
- to: z.string().describe("End date"),
470
- }),
471
- http: { method: "GET" },
472
- run: async (args) => {
473
- return await fetchEvents(args.from, args.to);
474
- },
475
- });
476
- ```
477
-
478
- **Write action (POST, default):**
479
-
480
- ```ts
481
- import { z } from "zod";
482
- import { defineAction } from "@agent-native/core/action";
483
-
484
- export default defineAction({
485
- description: "Log a meal",
486
- schema: z.object({
487
- name: z.string().describe("Meal name"),
488
- calories: z.coerce.number().describe("Calorie count"),
489
- }),
490
- run: async (args) => {
491
- // args.calories is a number — z.coerce.number() handles string-to-number conversion from HTTP
492
- const meal = await insertMeal(args);
493
- return meal;
494
- },
495
- });
496
- ```
497
-
498
- **Agent-only action:**
499
-
500
- ```ts
501
- import { z } from "zod";
502
- import { defineAction } from "@agent-native/core/action";
503
-
504
- export default defineAction({
505
- description: "Navigate the UI to a view",
506
- schema: z.object({
507
- view: z.string().describe("Target view"),
508
- }),
509
- http: false,
510
- run: async (args) => {
511
- await writeAppState("navigate", { command: "go", view: args.view });
512
- return "Navigated";
513
- },
514
- });
515
- ```
516
-
517
- ## Troubleshooting
518
-
519
- - **Action not found** — Check that the filename matches the command name exactly. `pnpm action foo-bar` looks for `actions/foo-bar.ts`.
520
- - **Args not parsing** — Ensure args use `--key value` or `--key=value` format. Boolean flags use `--flag` (sets value to `"true"`).
521
- - **Frontend getting 405** — The action's `http.method` doesn't match the hook. Use `useActionQuery` for GET actions, `useActionMutation` for POST/PUT/DELETE.
522
- - **Frontend getting undefined** — Make sure the action returns structured data, not `JSON.stringify()`.
523
-
524
- ## Related Skills
525
-
526
- - **storing-data** — Actions read/write data in SQL
527
- - **delegate-to-agent** — The agent invokes actions via `pnpm action <name>`
528
- - **real-time-sync** — Database writes from actions trigger change events to update the UI
529
- - **adding-a-feature** — Actions are area 2 of the four-area checklist
530
- - **client-methods** — Client code uses named helpers/hooks instead of raw REST calls