@agent-native/core 0.14.8 → 0.15.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 (420) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  3. package/dist/agent/engine/builder-engine.js +30 -9
  4. package/dist/agent/engine/builder-engine.js.map +1 -1
  5. package/dist/agent/engine/registry.d.ts.map +1 -1
  6. package/dist/agent/engine/registry.js +14 -4
  7. package/dist/agent/engine/registry.js.map +1 -1
  8. package/dist/agent/production-agent.d.ts.map +1 -1
  9. package/dist/agent/production-agent.js +71 -4
  10. package/dist/agent/production-agent.js.map +1 -1
  11. package/dist/agent/types.d.ts +9 -0
  12. package/dist/agent/types.d.ts.map +1 -1
  13. package/dist/agent/types.js.map +1 -1
  14. package/dist/appearance/actions/change-appearance.d.ts +3 -0
  15. package/dist/appearance/actions/change-appearance.d.ts.map +1 -0
  16. package/dist/appearance/actions/change-appearance.js +29 -0
  17. package/dist/appearance/actions/change-appearance.js.map +1 -0
  18. package/dist/chat-threads/store.d.ts +53 -2
  19. package/dist/chat-threads/store.d.ts.map +1 -1
  20. package/dist/chat-threads/store.js +172 -12
  21. package/dist/chat-threads/store.js.map +1 -1
  22. package/dist/cli/create.d.ts.map +1 -1
  23. package/dist/cli/create.js +114 -37
  24. package/dist/cli/create.js.map +1 -1
  25. package/dist/cli/index.js +30 -4
  26. package/dist/cli/index.js.map +1 -1
  27. package/dist/cli/workspace-dev.d.ts +25 -1
  28. package/dist/cli/workspace-dev.d.ts.map +1 -1
  29. package/dist/cli/workspace-dev.js +275 -49
  30. package/dist/cli/workspace-dev.js.map +1 -1
  31. package/dist/client/AgentPanel.d.ts +23 -4
  32. package/dist/client/AgentPanel.d.ts.map +1 -1
  33. package/dist/client/AgentPanel.js +276 -53
  34. package/dist/client/AgentPanel.js.map +1 -1
  35. package/dist/client/AppearancePicker.d.ts +11 -0
  36. package/dist/client/AppearancePicker.d.ts.map +1 -0
  37. package/dist/client/AppearancePicker.js +16 -0
  38. package/dist/client/AppearancePicker.js.map +1 -0
  39. package/dist/client/AssistantChat.d.ts +35 -0
  40. package/dist/client/AssistantChat.d.ts.map +1 -1
  41. package/dist/client/AssistantChat.js +315 -32
  42. package/dist/client/AssistantChat.js.map +1 -1
  43. package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
  44. package/dist/client/ConnectBuilderCard.js +5 -2
  45. package/dist/client/ConnectBuilderCard.js.map +1 -1
  46. package/dist/client/ErrorBoundary.d.ts.map +1 -1
  47. package/dist/client/ErrorBoundary.js +8 -10
  48. package/dist/client/ErrorBoundary.js.map +1 -1
  49. package/dist/client/FeedbackButton.d.ts.map +1 -1
  50. package/dist/client/FeedbackButton.js +1 -1
  51. package/dist/client/FeedbackButton.js.map +1 -1
  52. package/dist/client/MultiTabAssistantChat.d.ts +13 -1
  53. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  54. package/dist/client/MultiTabAssistantChat.js +217 -38
  55. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  56. package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
  57. package/dist/client/NewWorkspaceAppFlow.js +37 -14
  58. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  59. package/dist/client/agent-chat-adapter.d.ts +5 -0
  60. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  61. package/dist/client/agent-chat-adapter.js +4 -0
  62. package/dist/client/agent-chat-adapter.js.map +1 -1
  63. package/dist/client/agent-sidebar-state.d.ts +12 -0
  64. package/dist/client/agent-sidebar-state.d.ts.map +1 -1
  65. package/dist/client/agent-sidebar-state.js +8 -0
  66. package/dist/client/agent-sidebar-state.js.map +1 -1
  67. package/dist/client/analytics.d.ts.map +1 -1
  68. package/dist/client/analytics.js +175 -3
  69. package/dist/client/analytics.js.map +1 -1
  70. package/dist/client/appearance.d.ts +40 -0
  71. package/dist/client/appearance.d.ts.map +1 -0
  72. package/dist/client/appearance.js +114 -0
  73. package/dist/client/appearance.js.map +1 -0
  74. package/dist/client/builder-frame.d.ts +1 -0
  75. package/dist/client/builder-frame.d.ts.map +1 -1
  76. package/dist/client/builder-frame.js +19 -9
  77. package/dist/client/builder-frame.js.map +1 -1
  78. package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
  79. package/dist/client/components/CodeRequiredDialog.js +10 -2
  80. package/dist/client/components/CodeRequiredDialog.js.map +1 -1
  81. package/dist/client/components/ui/dropdown-menu.js +2 -2
  82. package/dist/client/components/ui/dropdown-menu.js.map +1 -1
  83. package/dist/client/components/ui/hover-card.js +1 -1
  84. package/dist/client/components/ui/hover-card.js.map +1 -1
  85. package/dist/client/components/ui/popover.js +1 -1
  86. package/dist/client/components/ui/popover.js.map +1 -1
  87. package/dist/client/composer/PromptComposer.d.ts +7 -0
  88. package/dist/client/composer/PromptComposer.d.ts.map +1 -1
  89. package/dist/client/composer/PromptComposer.js +63 -32
  90. package/dist/client/composer/PromptComposer.js.map +1 -1
  91. package/dist/client/composer/TiptapComposer.d.ts +5 -0
  92. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  93. package/dist/client/composer/TiptapComposer.js +36 -6
  94. package/dist/client/composer/TiptapComposer.js.map +1 -1
  95. package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
  96. package/dist/client/composer/useVoiceDictation.js +13 -1
  97. package/dist/client/composer/useVoiceDictation.js.map +1 -1
  98. package/dist/client/error-format.d.ts +3 -2
  99. package/dist/client/error-format.d.ts.map +1 -1
  100. package/dist/client/error-format.js +9 -2
  101. package/dist/client/error-format.js.map +1 -1
  102. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  103. package/dist/client/extensions/ExtensionViewer.js +24 -2
  104. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  105. package/dist/client/index.d.ts +8 -1
  106. package/dist/client/index.d.ts.map +1 -1
  107. package/dist/client/index.js +7 -0
  108. package/dist/client/index.js.map +1 -1
  109. package/dist/client/onboarding/OnboardingPanel.js +1 -0
  110. package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
  111. package/dist/client/org/InvitationBanner.d.ts.map +1 -1
  112. package/dist/client/org/InvitationBanner.js +23 -2
  113. package/dist/client/org/InvitationBanner.js.map +1 -1
  114. package/dist/client/org/OrgSwitcher.d.ts +5 -4
  115. package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
  116. package/dist/client/org/OrgSwitcher.js +57 -9
  117. package/dist/client/org/OrgSwitcher.js.map +1 -1
  118. package/dist/client/org/hooks.d.ts.map +1 -1
  119. package/dist/client/org/hooks.js +10 -6
  120. package/dist/client/org/hooks.js.map +1 -1
  121. package/dist/client/org/workspace-app-links.d.ts +31 -0
  122. package/dist/client/org/workspace-app-links.d.ts.map +1 -0
  123. package/dist/client/org/workspace-app-links.js +268 -0
  124. package/dist/client/org/workspace-app-links.js.map +1 -0
  125. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  126. package/dist/client/resources/ResourcesPanel.js +18 -5
  127. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  128. package/dist/client/resources/use-resources.d.ts +18 -13
  129. package/dist/client/resources/use-resources.d.ts.map +1 -1
  130. package/dist/client/resources/use-resources.js +24 -6
  131. package/dist/client/resources/use-resources.js.map +1 -1
  132. package/dist/client/settings/BackgroundAgentSection.d.ts.map +1 -1
  133. package/dist/client/settings/BackgroundAgentSection.js +9 -1
  134. package/dist/client/settings/BackgroundAgentSection.js.map +1 -1
  135. package/dist/client/settings/BrowserSection.d.ts.map +1 -1
  136. package/dist/client/settings/BrowserSection.js +16 -1
  137. package/dist/client/settings/BrowserSection.js.map +1 -1
  138. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  139. package/dist/client/settings/SettingsPanel.js +4 -1
  140. package/dist/client/settings/SettingsPanel.js.map +1 -1
  141. package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
  142. package/dist/client/settings/VoiceTranscriptionSection.js +5 -5
  143. package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
  144. package/dist/client/settings/useBuilderStatus.d.ts +8 -0
  145. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
  146. package/dist/client/settings/useBuilderStatus.js +50 -13
  147. package/dist/client/settings/useBuilderStatus.js.map +1 -1
  148. package/dist/client/settings/useBuilderStatus.spec.d.ts +2 -0
  149. package/dist/client/settings/useBuilderStatus.spec.d.ts.map +1 -0
  150. package/dist/client/settings/useBuilderStatus.spec.js +64 -0
  151. package/dist/client/settings/useBuilderStatus.spec.js.map +1 -0
  152. package/dist/client/sharing/ShareButton.d.ts +5 -0
  153. package/dist/client/sharing/ShareButton.d.ts.map +1 -1
  154. package/dist/client/sharing/ShareButton.js +60 -6
  155. package/dist/client/sharing/ShareButton.js.map +1 -1
  156. package/dist/client/theme.js +1 -1
  157. package/dist/client/theme.js.map +1 -1
  158. package/dist/client/transcription/BuilderTranscriptionCta.d.ts.map +1 -1
  159. package/dist/client/transcription/BuilderTranscriptionCta.js +2 -3
  160. package/dist/client/transcription/BuilderTranscriptionCta.js.map +1 -1
  161. package/dist/client/use-change-version.d.ts +46 -0
  162. package/dist/client/use-change-version.d.ts.map +1 -0
  163. package/dist/client/use-change-version.js +135 -0
  164. package/dist/client/use-change-version.js.map +1 -0
  165. package/dist/client/use-chat-threads.d.ts +16 -2
  166. package/dist/client/use-chat-threads.d.ts.map +1 -1
  167. package/dist/client/use-chat-threads.js +87 -12
  168. package/dist/client/use-chat-threads.js.map +1 -1
  169. package/dist/client/use-chat-threads.spec.d.ts +2 -0
  170. package/dist/client/use-chat-threads.spec.d.ts.map +1 -0
  171. package/dist/client/use-chat-threads.spec.js +85 -0
  172. package/dist/client/use-chat-threads.spec.js.map +1 -0
  173. package/dist/client/use-db-sync.d.ts +5 -2
  174. package/dist/client/use-db-sync.d.ts.map +1 -1
  175. package/dist/client/use-db-sync.js +41 -16
  176. package/dist/client/use-db-sync.js.map +1 -1
  177. package/dist/client/use-pinch-zoom.d.ts +35 -0
  178. package/dist/client/use-pinch-zoom.d.ts.map +1 -0
  179. package/dist/client/use-pinch-zoom.js +105 -0
  180. package/dist/client/use-pinch-zoom.js.map +1 -0
  181. package/dist/deploy/workspace-deploy.d.ts.map +1 -1
  182. package/dist/deploy/workspace-deploy.js +99 -5
  183. package/dist/deploy/workspace-deploy.js.map +1 -1
  184. package/dist/extensions/actions.d.ts.map +1 -1
  185. package/dist/extensions/actions.js +3 -0
  186. package/dist/extensions/actions.js.map +1 -1
  187. package/dist/extensions/store.d.ts +5 -0
  188. package/dist/extensions/store.d.ts.map +1 -1
  189. package/dist/extensions/store.js +16 -1
  190. package/dist/extensions/store.js.map +1 -1
  191. package/dist/file-upload/actions/upload-image.d.ts +3 -0
  192. package/dist/file-upload/actions/upload-image.d.ts.map +1 -0
  193. package/dist/file-upload/actions/upload-image.js +145 -0
  194. package/dist/file-upload/actions/upload-image.js.map +1 -0
  195. package/dist/file-upload/builder.d.ts.map +1 -1
  196. package/dist/file-upload/builder.js +31 -11
  197. package/dist/file-upload/builder.js.map +1 -1
  198. package/dist/file-upload/index.d.ts +1 -0
  199. package/dist/file-upload/index.d.ts.map +1 -1
  200. package/dist/file-upload/index.js +1 -0
  201. package/dist/file-upload/index.js.map +1 -1
  202. package/dist/file-upload/pre-upload-attachments.d.ts +39 -0
  203. package/dist/file-upload/pre-upload-attachments.d.ts.map +1 -0
  204. package/dist/file-upload/pre-upload-attachments.js +110 -0
  205. package/dist/file-upload/pre-upload-attachments.js.map +1 -0
  206. package/dist/file-upload/registry.d.ts.map +1 -1
  207. package/dist/file-upload/registry.js +8 -7
  208. package/dist/file-upload/registry.js.map +1 -1
  209. package/dist/onboarding/default-steps.js +1 -1
  210. package/dist/onboarding/default-steps.js.map +1 -1
  211. package/dist/org/context.d.ts +15 -1
  212. package/dist/org/context.d.ts.map +1 -1
  213. package/dist/org/context.js +25 -0
  214. package/dist/org/context.js.map +1 -1
  215. package/dist/org/handlers.d.ts +2 -2
  216. package/dist/org/handlers.d.ts.map +1 -1
  217. package/dist/org/handlers.js +3 -17
  218. package/dist/org/handlers.js.map +1 -1
  219. package/dist/org/index.d.ts +1 -1
  220. package/dist/org/index.d.ts.map +1 -1
  221. package/dist/org/index.js +1 -1
  222. package/dist/org/index.js.map +1 -1
  223. package/dist/resources/handlers.d.ts +6 -0
  224. package/dist/resources/handlers.d.ts.map +1 -1
  225. package/dist/resources/handlers.js +30 -6
  226. package/dist/resources/handlers.js.map +1 -1
  227. package/dist/resources/script-helpers.d.ts +11 -2
  228. package/dist/resources/script-helpers.d.ts.map +1 -1
  229. package/dist/resources/script-helpers.js +20 -3
  230. package/dist/resources/script-helpers.js.map +1 -1
  231. package/dist/resources/store.d.ts +28 -3
  232. package/dist/resources/store.d.ts.map +1 -1
  233. package/dist/resources/store.js +170 -20
  234. package/dist/resources/store.js.map +1 -1
  235. package/dist/scripts/resources/list.d.ts +1 -1
  236. package/dist/scripts/resources/list.d.ts.map +1 -1
  237. package/dist/scripts/resources/list.js +16 -4
  238. package/dist/scripts/resources/list.js.map +1 -1
  239. package/dist/scripts/resources/write.d.ts +1 -1
  240. package/dist/scripts/resources/write.d.ts.map +1 -1
  241. package/dist/scripts/resources/write.js +47 -3
  242. package/dist/scripts/resources/write.js.map +1 -1
  243. package/dist/server/action-discovery.d.ts.map +1 -1
  244. package/dist/server/action-discovery.js +8 -3
  245. package/dist/server/action-discovery.js.map +1 -1
  246. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  247. package/dist/server/agent-chat-plugin.js +214 -25
  248. package/dist/server/agent-chat-plugin.js.map +1 -1
  249. package/dist/server/agent-discovery.d.ts +35 -0
  250. package/dist/server/agent-discovery.d.ts.map +1 -1
  251. package/dist/server/agent-discovery.js +139 -8
  252. package/dist/server/agent-discovery.js.map +1 -1
  253. package/dist/server/app-url.d.ts +12 -6
  254. package/dist/server/app-url.d.ts.map +1 -1
  255. package/dist/server/app-url.js +58 -11
  256. package/dist/server/app-url.js.map +1 -1
  257. package/dist/server/auth.d.ts +22 -0
  258. package/dist/server/auth.d.ts.map +1 -1
  259. package/dist/server/auth.js +272 -59
  260. package/dist/server/auth.js.map +1 -1
  261. package/dist/server/better-auth-instance.d.ts +0 -4
  262. package/dist/server/better-auth-instance.d.ts.map +1 -1
  263. package/dist/server/better-auth-instance.js +0 -3
  264. package/dist/server/better-auth-instance.js.map +1 -1
  265. package/dist/server/builder-browser.d.ts.map +1 -1
  266. package/dist/server/builder-browser.js +23 -0
  267. package/dist/server/builder-browser.js.map +1 -1
  268. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  269. package/dist/server/core-routes-plugin.js +29 -14
  270. package/dist/server/core-routes-plugin.js.map +1 -1
  271. package/dist/server/credential-provider.d.ts +14 -0
  272. package/dist/server/credential-provider.d.ts.map +1 -1
  273. package/dist/server/credential-provider.js +88 -11
  274. package/dist/server/credential-provider.js.map +1 -1
  275. package/dist/server/google-auth-plugin.d.ts.map +1 -1
  276. package/dist/server/google-auth-plugin.js +53 -13
  277. package/dist/server/google-auth-plugin.js.map +1 -1
  278. package/dist/server/google-oauth.d.ts.map +1 -1
  279. package/dist/server/google-oauth.js +47 -17
  280. package/dist/server/google-oauth.js.map +1 -1
  281. package/dist/server/index.d.ts +1 -1
  282. package/dist/server/index.d.ts.map +1 -1
  283. package/dist/server/index.js +1 -1
  284. package/dist/server/index.js.map +1 -1
  285. package/dist/server/oauth-public-origin.d.ts.map +1 -1
  286. package/dist/server/oauth-public-origin.js +19 -1
  287. package/dist/server/oauth-public-origin.js.map +1 -1
  288. package/dist/server/onboarding-html.d.ts.map +1 -1
  289. package/dist/server/onboarding-html.js +62 -15
  290. package/dist/server/onboarding-html.js.map +1 -1
  291. package/dist/server/poll.d.ts.map +1 -1
  292. package/dist/server/poll.js +20 -5
  293. package/dist/server/poll.js.map +1 -1
  294. package/dist/server/request-context.d.ts +8 -0
  295. package/dist/server/request-context.d.ts.map +1 -1
  296. package/dist/server/request-context.js.map +1 -1
  297. package/dist/shared/index.d.ts +2 -0
  298. package/dist/shared/index.d.ts.map +1 -1
  299. package/dist/shared/index.js +2 -0
  300. package/dist/shared/index.js.map +1 -1
  301. package/dist/shared/llm-connection.d.ts +10 -0
  302. package/dist/shared/llm-connection.d.ts.map +1 -0
  303. package/dist/shared/llm-connection.js +29 -0
  304. package/dist/shared/llm-connection.js.map +1 -0
  305. package/dist/shared/workspace-app-audience.d.ts +25 -0
  306. package/dist/shared/workspace-app-audience.d.ts.map +1 -0
  307. package/dist/shared/workspace-app-audience.js +126 -0
  308. package/dist/shared/workspace-app-audience.js.map +1 -0
  309. package/dist/shared/workspace-app-id.d.ts +1 -1
  310. package/dist/shared/workspace-app-id.d.ts.map +1 -1
  311. package/dist/shared/workspace-app-id.js +1 -0
  312. package/dist/shared/workspace-app-id.js.map +1 -1
  313. package/dist/sharing/access.d.ts.map +1 -1
  314. package/dist/sharing/access.js +46 -5
  315. package/dist/sharing/access.js.map +1 -1
  316. package/dist/sharing/actions/list-resource-shares.d.ts.map +1 -1
  317. package/dist/sharing/actions/list-resource-shares.js +8 -1
  318. package/dist/sharing/actions/list-resource-shares.js.map +1 -1
  319. package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
  320. package/dist/sharing/actions/set-resource-visibility.js +12 -3
  321. package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
  322. package/dist/sharing/actions/share-resource.d.ts.map +1 -1
  323. package/dist/sharing/actions/share-resource.js +50 -1
  324. package/dist/sharing/actions/share-resource.js.map +1 -1
  325. package/dist/sharing/registry.d.ts +26 -0
  326. package/dist/sharing/registry.d.ts.map +1 -1
  327. package/dist/sharing/registry.js.map +1 -1
  328. package/dist/styles/agent-native.css +91 -0
  329. package/dist/templates/default/.agents/skills/adding-a-feature/SKILL.md +72 -0
  330. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +60 -37
  331. package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +28 -17
  332. package/dist/templates/default/.agents/skills/shadcn-ui/SKILL.md +79 -0
  333. package/dist/templates/default/AGENTS.md +22 -19
  334. package/dist/templates/default/actions/navigate.ts +3 -0
  335. package/dist/templates/default/app/hooks/use-navigation-state.ts +29 -5
  336. package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +251 -0
  337. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +264 -0
  338. package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +130 -0
  339. package/dist/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +112 -0
  340. package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +88 -0
  341. package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +191 -0
  342. package/dist/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +74 -0
  343. package/dist/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +75 -0
  344. package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +190 -0
  345. package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +168 -0
  346. package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +163 -0
  347. package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +205 -0
  348. package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +720 -0
  349. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +92 -0
  350. package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +285 -0
  351. package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +192 -0
  352. package/dist/templates/workspace-core/.agents/skills/onboarding/SKILL.md +43 -0
  353. package/dist/templates/workspace-core/.agents/skills/portability/SKILL.md +84 -0
  354. package/dist/templates/workspace-core/.agents/skills/qa/SKILL.md +313 -0
  355. package/dist/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +112 -0
  356. package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +165 -0
  357. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +41 -0
  358. package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +239 -0
  359. package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +191 -0
  360. package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +79 -0
  361. package/dist/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +73 -0
  362. package/dist/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +79 -0
  363. package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +217 -0
  364. package/dist/templates/workspace-core/.agents/skills/storing-data/SKILL.md +132 -0
  365. package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +150 -0
  366. package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +124 -0
  367. package/dist/templates/workspace-core/AGENTS.md +16 -1
  368. package/dist/templates/workspace-root/AGENTS.md +35 -0
  369. package/dist/templates/workspace-root/README.md +7 -0
  370. package/dist/vite/action-types-plugin.d.ts.map +1 -1
  371. package/dist/vite/action-types-plugin.js +4 -0
  372. package/dist/vite/action-types-plugin.js.map +1 -1
  373. package/docs/content/authentication.md +36 -0
  374. package/docs/content/creating-templates.md +15 -0
  375. package/docs/content/dispatch.md +3 -3
  376. package/docs/content/multi-app-workspace.md +5 -0
  377. package/docs/content/tracking.md +12 -0
  378. package/docs/content/workspace-management.md +39 -4
  379. package/package.json +15 -12
  380. package/src/templates/default/.agents/skills/adding-a-feature/SKILL.md +72 -0
  381. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +60 -37
  382. package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +28 -17
  383. package/src/templates/default/.agents/skills/shadcn-ui/SKILL.md +79 -0
  384. package/src/templates/default/AGENTS.md +22 -19
  385. package/src/templates/default/actions/navigate.ts +3 -0
  386. package/src/templates/default/app/hooks/use-navigation-state.ts +29 -5
  387. package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +251 -0
  388. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +264 -0
  389. package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +130 -0
  390. package/src/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +112 -0
  391. package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +88 -0
  392. package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +191 -0
  393. package/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +74 -0
  394. package/src/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +75 -0
  395. package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +190 -0
  396. package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +168 -0
  397. package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +163 -0
  398. package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +205 -0
  399. package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +720 -0
  400. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +92 -0
  401. package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +285 -0
  402. package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +192 -0
  403. package/src/templates/workspace-core/.agents/skills/onboarding/SKILL.md +43 -0
  404. package/src/templates/workspace-core/.agents/skills/portability/SKILL.md +84 -0
  405. package/src/templates/workspace-core/.agents/skills/qa/SKILL.md +313 -0
  406. package/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +112 -0
  407. package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +165 -0
  408. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +41 -0
  409. package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +239 -0
  410. package/src/templates/workspace-core/.agents/skills/security/SKILL.md +191 -0
  411. package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +79 -0
  412. package/src/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +73 -0
  413. package/src/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +79 -0
  414. package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +217 -0
  415. package/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +132 -0
  416. package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +150 -0
  417. package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +124 -0
  418. package/src/templates/workspace-core/AGENTS.md +16 -1
  419. package/src/templates/workspace-root/AGENTS.md +35 -0
  420. package/src/templates/workspace-root/README.md +7 -0
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: voice-transcription
3
+ description: >-
4
+ Framework-wide voice dictation in the agent sidebar composer. Use when
5
+ changing composer microphone UX, the transcribe-voice route, or the
6
+ Voice Transcription settings section. Covers transcription-source routing,
7
+ cleanup routing, Google realtime gating, and the voice transcription
8
+ application-state keys.
9
+ ---
10
+
11
+ # Voice Transcription
12
+
13
+ Click-to-toggle microphone inside the sidebar composer turns speech into
14
+ text. Users configure live transcription separately from AI cleanup in
15
+ Settings → Voice Transcription. The feature is available in every template
16
+ that renders `TiptapComposer`.
17
+
18
+ ## UX rules
19
+
20
+ - **Always show the mic alongside the send button.** Cursor replaces send
21
+ with mic when the composer is empty; their users complain. We keep both
22
+ visible — Lovable does the same.
23
+ - **Click-to-toggle, not push-to-talk.** More forgiving in a sidebar, avoids
24
+ host-app hotkey clashes. Keyboard shortcut is `Cmd/Ctrl+Shift+M` and
25
+ `Escape` cancels mid-recording.
26
+ - **Transcript lands in the composer, editable, never auto-sent.** Insert at
27
+ the caret via `editor.chain().focus().insertContent(text).run()`.
28
+ - **No CSS transitions for the recording state.** Framework rule; use static
29
+ brand color (`#625DF5`) instead of pulses.
30
+ - **Icon:** Tabler `IconMicrophone` (idle) / `IconPlayerStopFilled` (recording).
31
+ Never use a sparkle or robot icon.
32
+ - **Errors via inline alert or toast, never `window.alert`.**
33
+
34
+ ## Source And Cleanup
35
+
36
+ Settings must keep these as separate choices:
37
+
38
+ - **Live transcription source**: `mac-native`, `google-realtime`, or `batch`.
39
+ - **AI cleanup**: independent off/on toggle. Cleanup uses Builder Gemini first
40
+ when hosted Gemini is configured, then BYOK Gemini (`GEMINI_API_KEY`).
41
+ Gemini cleanup/title/summary generation is not a live STT source.
42
+
43
+ `application_state["voice-transcription-prefs"]` stores
44
+ `{ transcriptionMode, provider, instructions }`. The legacy `provider` field
45
+ is still written for old clients and batch provider preferences:
46
+
47
+ | Value | Meaning | Needs key |
48
+ | ----------------- | -------------------------------------------------------------- | ---------------------------- |
49
+ | `mac-native` | Native macOS/Tauri speech path; web clients normalize to browser-native where needed | No |
50
+ | `google-realtime` | Dedicated WebSocket → Google Speech-to-Text gRPC `StreamingRecognize` path | `GOOGLE_APPLICATION_CREDENTIALS` |
51
+ | `batch` | Upload audio after stop through the existing batch route | Builder/Gemini/Groq/OpenAI depending on fallback |
52
+ | `auto` provider | Existing batch fallback chain | Any configured batch provider |
53
+ | `builder-gemini` | Builder Gemini Flash-Lite batch/cleanup preference | hosted Gemini provider connected |
54
+ | `gemini` | Direct Google Gemini BYOK batch/cleanup preference | `GEMINI_API_KEY` |
55
+ | `groq` | Groq Whisper batch preference | `GROQ_API_KEY` |
56
+ | `openai` | OpenAI Whisper batch preference | `OPENAI_API_KEY` |
57
+ | `browser` | Legacy native/browser live speech preference | No |
58
+
59
+ Default behavior:
60
+
61
+ - The shared web settings/composer default to Batch / `auto`.
62
+ - Dedicated macOS Tauri-native surfaces may save `mac-native`, but do not
63
+ assume the shared React settings default to it.
64
+ - Old stored `builder` values are treated as `builder-gemini`.
65
+ - Old stored `browser` values are treated as `mac-native`.
66
+ - Saved `google-realtime` preferences must never hit `/_agent-native/transcribe-voice`. They go through the dedicated session bridge `POST /_agent-native/transcribe-stream/session`, which mints an opaque ai-services websocket session and keeps the Google service-account JSON off the client.
67
+ - In the current bridge, the Google option is only actually ready when both the user's `GOOGLE_APPLICATION_CREDENTIALS` secret exists and Builder is connected, because the framework mints the managed ai-services session with Builder auth before streaming begins.
68
+
69
+ ## Where the pieces live
70
+
71
+ | File | Purpose |
72
+ | --------------------------------------------------------------------- | --------------------------------------------------- |
73
+ | `packages/core/src/client/composer/useVoiceDictation.ts` | Provider-routing hook (MediaRecorder / Web Speech) |
74
+ | `packages/core/src/client/composer/VoiceButton.tsx` | Mic button + live amplitude + cancel overlay |
75
+ | `packages/core/src/client/composer/TiptapComposer.tsx` | Wires the hook, insertion, and keyboard shortcut |
76
+ | `packages/core/src/client/settings/VoiceTranscriptionSection.tsx` | Live source + cleanup controls in sidebar settings |
77
+ | `packages/core/src/client/transcription/BuilderTranscriptionCta.tsx` | CTA shown when Builder account isn't connected |
78
+ | `packages/core/src/client/transcription/use-live-transcription.ts` | Web Speech live-transcription hook for recordings |
79
+ | `packages/core/src/server/transcribe-voice.ts` | Route handler (routes to Builder/Gemini/Groq/Whisper) |
80
+ | `packages/core/src/transcription/builder-transcription.ts` | Builder proxy transcription client |
81
+ | `packages/core/src/secrets/register-framework-secrets.ts` | Framework-level provider key registration |
82
+
83
+ ## Key resolution (server)
84
+
85
+ `transcribe-voice.ts` is batch-only. Do not add realtime streaming to this
86
+ route. Google Speech-to-Text realtime uses a dedicated audio-frame protocol:
87
+ client audio frames → `/_agent-native/transcribe-stream/session` →
88
+ ai-services WebSocket → Google gRPC `StreamingRecognize` → partial / final
89
+ transcript events. Use the canonical docs URL:
90
+ https://cloud.google.com/speech-to-text/v2/docs/streaming-recognize
91
+
92
+ Batch routing is based on the user's provider preference:
93
+
94
+ 1. If `builder-gemini` and `resolveHasBuilderPrivateKey()` → calls `transcribeWithBuilder({ model: "gemini-3-1-flash-lite" })` via Builder proxy, or uses Builder Gemini Flash-Lite to clean up a live native/browser transcript when the desktop client sends text instead of audio.
95
+ 2. If `builder` and `resolveHasBuilderPrivateKey()` → legacy alias; prefer `builder-gemini`.
96
+ 3. If `gemini` → resolves `GEMINI_API_KEY` and calls the direct Google Gemini path.
97
+ 4. If `groq` → resolves `GROQ_API_KEY` and calls Groq's Whisper-compatible endpoint.
98
+ 5. If `openai` → resolves `OPENAI_API_KEY`:
99
+ - `readAppSecret({ key: "OPENAI_API_KEY", scope: "user", scopeId: session.email })` — user's encrypted secret.
100
+ - `resolveCredential("OPENAI_API_KEY")` — env var + SQL settings fallback.
101
+
102
+ In auto mode / no preference, the route tries Builder Gemini Flash-Lite first
103
+ when Builder is connected, then Gemini BYOK, Groq, and OpenAI.
104
+ When a request includes `instructions`, pass them through to the selected LLM
105
+ provider. Gemini uses them in the transcription prompt, Builder receives them
106
+ as transcription/cleanup instructions, and Whisper-compatible providers receive
107
+ them as provider prompt/context.
108
+
109
+ Never hardcode a shared key. Never log the value. Never echo it back to the
110
+ client.
111
+
112
+ ## Overriding per-template
113
+
114
+ Templates can:
115
+ - **Disable the mic**: pass `voiceEnabled={false}` to `TiptapComposer`.
116
+ - **Replace the button**: wrap `TiptapComposer` and render your own `extraActionButton` (the framework mic sits between `extraActionButton` and the send button).
117
+ - **Pre-register provider keys as `required: true`**: call `registerRequiredSecret(...)` from your own server plugin when a template needs a specific BYOK provider in onboarding.
118
+
119
+ ## Don'ts
120
+
121
+ - Don't call transcription providers from the client — go through `/_agent-native/transcribe-voice` so the user's secret stays server-side.
122
+ - Don't remove the cancel affordance — mic permission abuse paranoia is real.
123
+ - Don't auto-submit the transcript — users always edit before sending.
124
+ - Don't copy Cursor's "hide send when empty" pattern — it confuses users.
@@ -11,12 +11,22 @@ agent should know.
11
11
 
12
12
  ## Shared Conventions
13
13
 
14
+ - All AI/LLM behavior goes through the app's agent chat. UI and server code
15
+ must not call model providers, AI SDK `generateText()` / `streamText()`, or
16
+ other inline LLM APIs directly. Use `sendToAgentChat()` for local app-agent
17
+ work, and read `.agents/skills/delegate-to-agent/SKILL.md` before building
18
+ agent-driven UI or "AI" features.
14
19
  - Put shared code in `packages/shared` only when multiple apps need it.
15
20
  - Keep app-specific screens, actions, state, and skills inside `apps/<app>`.
16
21
  - Store shared runtime configuration in the workspace root `.env`; use
17
22
  `apps/<app>/.env` only for app-specific overrides.
18
23
  - Prefer framework defaults until the workspace has a real custom rule,
19
24
  component, plugin, action, or skill to share.
25
+ - Keep the Workspace files view for user-authored or user-requested resources.
26
+ Agents may create hidden `agent_scratch` resources for temporary working
27
+ notes, scripts, task plans, or intermediate outputs, but should promote them
28
+ to normal workspace visibility only when the user explicitly asks to keep or
29
+ manage the file.
20
30
 
21
31
  ## Adding Apps
22
32
 
@@ -33,6 +43,10 @@ Do not implement a new app by adding a route, page, component, or file to
33
43
  `apps/starter` or another existing app unless the user explicitly asks to modify
34
44
  that existing app.
35
45
 
46
+ Dispatch vault access is workspace-wide by default: every saved vault key is
47
+ available to every workspace app. Only create or request per-app vault grants
48
+ when Dispatch's vault access setting is switched to manual mode.
49
+
36
50
  Workspace apps are discovered from `apps/<app-name>/package.json`. There is no
37
51
  separate workspace app registry to edit for Dispatch to list the app. Use
38
52
  relative workspace links like `/<app-name>` and never hardcode `localhost`,
@@ -42,7 +56,8 @@ port. React Router apps must preserve `APP_BASE_PATH` / `VITE_APP_BASE_PATH` in
42
56
  `app/entry.client.tsx` via `appBasePath()` so the app hydrates correctly when
43
57
  mounted at `/<app-name>`. Use the framework/template UI stack for standard UI:
44
58
  shadcn/ui components and `@tabler/icons-react`. Do not add `lucide-react` or
45
- another icon library.
59
+ another icon library. Read `.agents/skills/shadcn-ui/SKILL.md` before adding,
60
+ updating, or debugging shadcn components.
46
61
 
47
62
  In local development, run
48
63
  `pnpm exec agent-native create <app-name> --template=<template>` from the
@@ -3,6 +3,27 @@
3
3
  These instructions apply at the workspace root. App-specific behavior belongs
4
4
  in `apps/<app>/AGENTS.md`; shared cross-app behavior belongs in
5
5
  `packages/shared/AGENTS.md` or `packages/shared/.agents/skills/`.
6
+ The root `.agents/skills` path points at the shared package's skills so local
7
+ coding agents can discover the same workspace-wide guidance from the root.
8
+
9
+ ## Core Agent Rule
10
+
11
+ - All AI/LLM behavior goes through the app's agent chat. UI and server code
12
+ must not call model providers, AI SDK `generateText()` / `streamText()`, or
13
+ other inline LLM APIs directly. Use `sendToAgentChat()` for local app-agent
14
+ work, and read `packages/shared/.agents/skills/delegate-to-agent/SKILL.md`
15
+ before building agent-driven UI or "AI" features.
16
+
17
+ ## Workspace Resources
18
+
19
+ - The Workspace files view is for user-authored or user-requested resources
20
+ they intentionally add, edit, or manage.
21
+ - Agents may use hidden `agent_scratch` resources for temporary working notes,
22
+ scripts, task plans, or intermediate outputs. Keep those scratch files hidden
23
+ by default and promote them only when the user explicitly asks to keep or
24
+ manage the file.
25
+ - Durable instructions, skills, jobs, memories, custom agents, and files the
26
+ user explicitly asked to save belong in normal workspace visibility.
6
27
 
7
28
  ## Workspace Scope
8
29
 
@@ -26,6 +47,9 @@ in `apps/<app>/AGENTS.md`; shared cross-app behavior belongs in
26
47
  `/<app-id>`.
27
48
  - When a user explicitly asks for a new app or workspace app, create the
28
49
  separate workspace app.
50
+ - Dispatch vault access is workspace-wide by default: every saved vault key is
51
+ available to every workspace app. Only create or request per-app vault grants
52
+ when Dispatch's vault access setting is switched to manual mode.
29
53
  - Do not satisfy a new-app request by adding a route, page, component, or file
30
54
  to `apps/starter` or another existing app unless the user explicitly asks to
31
55
  modify that existing app.
@@ -44,6 +68,15 @@ in `apps/<app>/AGENTS.md`; shared cross-app behavior belongs in
44
68
  base template improvements continue to flow automatically.
45
69
  - Workspace apps are discovered from `apps/<app-id>/package.json`. There is no
46
70
  separate workspace app registry to edit for Dispatch to list the app.
71
+ - Always save a concise, human-readable `description` in the generated app's
72
+ `apps/<app-id>/package.json`. Dispatch lists and A2A connected-agent context
73
+ use the app name plus this description so other agents understand what the app
74
+ does. Dispatch users can later edit the displayed name/description from the
75
+ Apps page without changing source.
76
+ - All sibling workspace apps are accessible by default over A2A through
77
+ `call-agent`. Agents receive a compact list of available app names and
78
+ descriptions in prompt context; use tool search or app-specific actions only
79
+ when more detail is needed.
47
80
  - Use relative workspace links like `/<app-id>`. Never hardcode
48
81
  `localhost`, `127.0.0.1`, `8080`, `8100`, or any dev port in app cards,
49
82
  instructions, redirects, or navigation; the active workspace gateway/browser
@@ -53,6 +86,8 @@ in `apps/<app>/AGENTS.md`; shared cross-app behavior belongs in
53
86
  when mounted at `/<app-id>`.
54
87
  - Use the framework/template UI stack for standard UI: shadcn/ui components and
55
88
  `@tabler/icons-react`. Do not add `lucide-react` or another icon library.
89
+ Read `packages/shared/.agents/skills/shadcn-ui/SKILL.md` before adding,
90
+ updating, or debugging shadcn components.
56
91
  - In local development, scaffold the app from the workspace root with
57
92
  `pnpm exec agent-native create <app-id> --template=<template>`. In production
58
93
  Dispatch posts the request to Builder branch creation; the Builder branch
@@ -33,6 +33,9 @@ Apps don't need any configuration to opt in. Discovery happens via the
33
33
  `agent-native.workspaceCore` field in this root `package.json`, which names
34
34
  the shared package (`@{{APP_NAME}}/shared`).
35
35
 
36
+ The workspace root also links `.agents/skills` to the shared package so coding
37
+ agents launched from the root can discover the same workspace-wide skills.
38
+
36
39
  ## Getting started
37
40
 
38
41
  ```bash
@@ -49,6 +52,10 @@ watches `apps/`, so newly-created apps are detected without restarting
49
52
  links should stay relative, such as `/starter` or `/<app-id>`; do not hardcode
50
53
  localhost or dev ports because the active gateway origin owns the port.
51
54
 
55
+ Dispatch vault keys are workspace-wide by default: every saved vault key is
56
+ available to every workspace app and can be synced from Dispatch. Switch the
57
+ Vault page to manual access only when you need explicit per-app key grants.
58
+
52
59
  ## Workspace org identity
53
60
 
54
61
  Set these root `.env` values before production deploys or when repairing
@@ -1 +1 @@
1
- {"version":3,"file":"action-types-plugin.d.ts","sourceRoot":"","sources":["../../src/vite/action-types-plugin.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA6RnC;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAuC1C;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAG1E"}
1
+ {"version":3,"file":"action-types-plugin.d.ts","sourceRoot":"","sources":["../../src/vite/action-types-plugin.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAiSnC;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAuC1C;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAG1E"}
@@ -50,6 +50,10 @@ const CORE_SHARING_ACTIONS = [
50
50
  name: "set-resource-visibility",
51
51
  specifier: "@agent-native/core/sharing/actions/set-resource-visibility",
52
52
  },
53
+ {
54
+ name: "upload-image",
55
+ specifier: "@agent-native/core/file-upload/actions/upload-image",
56
+ },
53
57
  ];
54
58
  function scanActionFiles(actionsDir) {
55
59
  let files;
@@ -1 +1 @@
1
- {"version":3,"file":"action-types-plugin.js","sourceRoot":"","sources":["../../src/vite/action-types-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,oEAAoE;AACpE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,SAAS;IACT,KAAK;IACL,YAAY;IACZ,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,oBAAoB,GAA+C;IACvE;QACE,IAAI,EAAE,gBAAgB;QACtB,SAAS,EAAE,mDAAmD;KAC/D;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,SAAS,EAAE,qDAAqD;KACjE;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,SAAS,EAAE,yDAAyD;KACrE;IACD;QACE,IAAI,EAAE,yBAAyB;QAC/B,SAAS,EAAE,4DAA4D;KACxE;CACF,CAAC;AAEF,SAAS,eAAe,CAAC,UAAkB;IACzC,IAAI,KAAe,CAAC;IACpB,IAAI,CAAC;QACH,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,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AAC;YACnC,qEAAqE;YACrE,uEAAuE;YACvE,6CAA6C;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAmB;IAClE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACxD,uBAAuB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Vite plugin that generates end-to-end type-safe action types AND a runtime\n * registry of static imports so bundlers (Nitro on Netlify/Vercel/AWS-Lambda,\n * Rolldown, etc.) include every action file in the server bundle.\n *\n * Watches the `actions/` directory and emits:\n * - `.generated/action-types.d.ts` — type-only module that augments the\n * `ActionRegistry` interface in `@agent-native/core/client`, giving\n * `useActionQuery`/`useActionMutation` full inference.\n * - `.generated/actions-registry.ts` — runtime registry keyed by action\n * name, with static `import` statements for every action. Templates\n * import this file from their `server/plugins/agent-chat.ts` so Nitro\n * bundles the actions into the server function; without it the runtime\n * `fs.readdirSync` inside `autoDiscoverActions` finds nothing in a\n * bundled serverless function and every action route 404s.\n */\nimport path from \"path\";\nimport fs from \"fs\";\nimport type { Plugin } from \"vite\";\n\n/** Files to skip during discovery (matches action-discovery.ts). */\nconst SKIP_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\n/**\n * Framework-level sharing actions that must ALWAYS be in the generated\n * registry, even when the template's `actions/` directory doesn't contain\n * them. Each entry maps the action name to the bare-specifier import path so\n * bundlers see a static import and pull the module into the server bundle.\n *\n * Order matters: templates can override by defining a same-named file in\n * their own `actions/` directory — the merge below is skip-existing.\n */\nconst CORE_SHARING_ACTIONS: Array<{ name: string; specifier: string }> = [\n {\n name: \"share-resource\",\n specifier: \"@agent-native/core/sharing/actions/share-resource\",\n },\n {\n name: \"unshare-resource\",\n specifier: \"@agent-native/core/sharing/actions/unshare-resource\",\n },\n {\n name: \"list-resource-shares\",\n specifier: \"@agent-native/core/sharing/actions/list-resource-shares\",\n },\n {\n name: \"set-resource-visibility\",\n specifier: \"@agent-native/core/sharing/actions/set-resource-visibility\",\n },\n];\n\nfunction scanActionFiles(actionsDir: string): string[] {\n let files: string[];\n try {\n files = fs.readdirSync(actionsDir);\n } catch {\n return [];\n }\n return files.filter((f) => {\n if (!f.endsWith(\".ts\") && !f.endsWith(\".js\")) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_FILES.has(name)) return false;\n // Only include files that actually call defineAction or explicitly\n // re-export a package action. CLI scripts or example templates that live\n // in actions/ but don't export an action would otherwise drag their own\n // (often app/, browser-only, or fs-only) imports into the serverless\n // bundle and fail to resolve.\n try {\n const content = fs.readFileSync(path.join(actionsDir, f), \"utf-8\");\n const reexportsDefaultAction =\n /export\\s*\\{\\s*default\\s*\\}\\s*from\\s*[\"'][^\"']+[\"']/.test(content);\n if (!content.includes(\"defineAction\") && !reexportsDefaultAction) {\n return false;\n }\n } catch {\n return false;\n }\n return true;\n });\n}\n\nfunction toIdent(name: string): string {\n return \"a_\" + name.replace(/[^a-zA-Z0-9_]/g, \"_\");\n}\n\nfunction writeIfChanged(outFile: string, content: string): void {\n const existing = fs.existsSync(outFile)\n ? fs.readFileSync(outFile, \"utf-8\")\n : \"\";\n if (existing !== content) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true });\n fs.writeFileSync(outFile, content);\n }\n}\n\nfunction findWorkspaceCoreActionsDir(projectRoot: string): string | null {\n let dir = path.resolve(projectRoot);\n let workspaceRoot: string | null = null;\n let packageName: string | null = null;\n\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n workspaceRoot = dir;\n packageName = declared;\n break;\n }\n } catch {\n // Keep walking on malformed package.json.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n if (!workspaceRoot || !packageName) return null;\n\n const nm = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nm, \"package.json\"))) {\n const actionsDir = path.join(fs.realpathSync(nm), \"actions\");\n return fs.existsSync(actionsDir) ? actionsDir : null;\n }\n\n const packagesDir = path.join(workspaceRoot, \"packages\");\n const candidates: string[] = [];\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n if (entry.name.startsWith(\"@\")) {\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (sub.isDirectory()) candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n }\n\n for (const candidate of candidates) {\n const pkgPath = path.join(candidate, \"package.json\");\n if (!fs.existsSync(pkgPath)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n if (pkg?.name === packageName) {\n const actionsDir = path.join(candidate, \"actions\");\n return fs.existsSync(actionsDir) ? actionsDir : null;\n }\n } catch {\n // Ignore malformed package.json.\n }\n }\n\n return null;\n}\n\n/**\n * Scan the actions directory and emit the types + runtime registry files.\n * Only writes files whose content has changed, to avoid triggering rebuilds.\n */\nfunction generateActionArtifacts(\n actionsDir: string,\n projectRoot: string,\n): void {\n const outDir = path.resolve(projectRoot, \".generated\");\n const relActionsDir = path.relative(outDir, actionsDir).replace(/\\\\/g, \"/\");\n\n const actionFiles = scanActionFiles(actionsDir);\n const workspaceActionsDir = findWorkspaceCoreActionsDir(projectRoot);\n const workspaceActionFiles = workspaceActionsDir\n ? scanActionFiles(workspaceActionsDir)\n : [];\n\n // Pre-compute template action names — used for skip-existing logic in both\n // the type declarations and the runtime registry below.\n const templateActionNames = new Set<string>(\n actionFiles.map((f) => f.replace(/\\.(ts|js)$/, \"\")),\n );\n const registeredActionNames = new Set(templateActionNames);\n\n const actionSources = actionFiles.map((f) => {\n const name = f.replace(/\\.(ts|js)$/, \"\");\n return {\n name,\n relPath: `${relActionsDir}/${name}`,\n };\n });\n\n if (workspaceActionsDir) {\n for (const f of workspaceActionFiles) {\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (registeredActionNames.has(name)) continue;\n const relPath = path\n .relative(outDir, path.join(workspaceActionsDir, name))\n .replace(/\\\\/g, \"/\");\n actionSources.push({ name, relPath });\n registeredActionNames.add(name);\n }\n }\n\n // --- types file ---------------------------------------------------------\n const typeEntries = actionSources.map(({ name, relPath }) => {\n return ` \"${name}\": ActionEntry<typeof import(\"${relPath}\")>;`;\n });\n\n // Also declare types for framework-level sharing actions so callers don't\n // need `as any` casts (same skip-existing logic as the runtime registry).\n for (const entry of CORE_SHARING_ACTIONS) {\n if (registeredActionNames.has(entry.name)) continue;\n typeEntries.push(\n ` \"${entry.name}\": ActionEntry<typeof import(\"${entry.specifier}\")>;`,\n );\n registeredActionNames.add(entry.name);\n }\n\n const typesContent = `// AUTO-GENERATED by @agent-native/core — do not edit manually.\n// Regenerated when files in actions/ change.\n// This file augments the ActionRegistry interface so that useActionQuery and\n// useActionMutation infer the correct types from your action definitions.\n\n/** Extract the return type and parameter type from a defineAction module. */\ntype ActionEntry<T> = T extends { default: { run: (...args: infer A) => infer R } }\n ? {\n result: Awaited<R>;\n params: A extends [infer P, ...any[]] ? P : Record<string, any>;\n }\n : { result: any; params: Record<string, any> };\n\ndeclare module \"@agent-native/core/client\" {\n interface ActionRegistry {\n${typeEntries.join(\"\\n\")}\n }\n}\n\nexport {};\n`;\n\n writeIfChanged(path.join(outDir, \"action-types.d.ts\"), typesContent);\n\n // --- runtime registry ---------------------------------------------------\n // Static imports of each action's default export so bundlers see every\n // action and include it in the server bundle. Normalization matches\n // `loadActionsIntoRegistry` in server/action-discovery.ts.\n const imports: string[] = [];\n const entries: string[] = [];\n const runtimeActionNames = new Set<string>();\n for (const { name, relPath } of actionSources) {\n const ident = toIdent(name);\n imports.push(`import * as ${ident} from \"${relPath}\";`);\n entries.push(` ${JSON.stringify(name)}: ${ident},`);\n runtimeActionNames.add(name);\n }\n // Framework-level sharing actions — only added when the template hasn't\n // provided a same-named file (skip-existing merge). Static imports ensure\n // bundlers pull these modules into the server bundle so\n // `/_agent-native/actions/share-resource` (etc.) always resolve.\n for (const entry of CORE_SHARING_ACTIONS) {\n if (runtimeActionNames.has(entry.name)) continue;\n const ident = toIdent(entry.name);\n imports.push(`import * as ${ident} from \"${entry.specifier}\";`);\n entries.push(` ${JSON.stringify(entry.name)}: ${ident},`);\n runtimeActionNames.add(entry.name);\n }\n\n const registryContent = `// AUTO-GENERATED by @agent-native/core — do not edit manually.\n// Static-import registry of every action file. Bundlers (Nitro, Rolldown)\n// see these imports and include the action modules in the server bundle.\n// The agent-chat plugin normalizes each module into an ActionEntry shape.\n${imports.join(\"\\n\")}\n\nconst modules: Record<string, unknown> = {\n${entries.join(\"\\n\")}\n};\n\nexport default modules;\n`;\n\n // Always write the registry — even when the template has no actions/ files\n // we still emit imports for the framework-level sharing actions so they get\n // mounted on every template that consumes the registry.\n writeIfChanged(path.join(outDir, \"actions-registry.ts\"), registryContent);\n\n // Ensure .generated/ is in .gitignore\n const gitignorePath = path.join(projectRoot, \".gitignore\");\n if (fs.existsSync(gitignorePath)) {\n const gitignore = fs.readFileSync(gitignorePath, \"utf-8\");\n if (!gitignore.includes(\".generated\")) {\n fs.appendFileSync(gitignorePath, \"\\n.generated/\\n\");\n }\n }\n}\n\n/**\n * Vite plugin that watches `actions/` and generates type-safe action types.\n *\n * Add to your Vite config (auto-included by `defineConfig` from `@agent-native/core`):\n *\n * ```ts\n * import { actionTypesPlugin } from \"@agent-native/core/vite/action-types-plugin\";\n * plugins: [actionTypesPlugin()]\n * ```\n */\nexport function actionTypesPlugin(): Plugin {\n let projectRoot = \"\";\n let actionsDir = \"\";\n let workspaceActionsDir: string | null = null;\n\n return {\n name: \"agent-native-action-types\",\n configResolved(config) {\n projectRoot = config.root;\n actionsDir = path.resolve(projectRoot, \"actions\");\n workspaceActionsDir = findWorkspaceCoreActionsDir(projectRoot);\n },\n buildStart() {\n generateActionArtifacts(actionsDir, projectRoot);\n },\n configureServer(server) {\n // Generate on startup\n generateActionArtifacts(actionsDir, projectRoot);\n\n // Watch for changes in actions/\n const watcher = server.watcher;\n const handleChange = (file: string) => {\n const inAppActions = file.startsWith(actionsDir);\n const inWorkspaceActions = workspaceActionsDir\n ? file.startsWith(workspaceActionsDir)\n : false;\n if ((inAppActions || inWorkspaceActions) && /\\.(ts|js)$/.test(file)) {\n generateActionArtifacts(actionsDir, projectRoot);\n }\n };\n watcher.add(actionsDir);\n if (workspaceActionsDir) watcher.add(workspaceActionsDir);\n watcher.on(\"add\", handleChange);\n watcher.on(\"unlink\", handleChange);\n // Don't regenerate on content changes — only file additions/removals\n // affect the registry. Return type changes are picked up by TypeScript\n // from the source files via typeof import().\n },\n };\n}\n\n/**\n * Public helper to regenerate the types + registry from a non-Vite context\n * (e.g. the Nitro deploy build, where Vite plugins don't run).\n */\nexport function generateActionRegistryForProject(projectRoot: string): void {\n const actionsDir = path.resolve(projectRoot, \"actions\");\n generateActionArtifacts(actionsDir, projectRoot);\n}\n"]}
1
+ {"version":3,"file":"action-types-plugin.js","sourceRoot":"","sources":["../../src/vite/action-types-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,oEAAoE;AACpE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,SAAS;IACT,KAAK;IACL,YAAY;IACZ,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,oBAAoB,GAA+C;IACvE;QACE,IAAI,EAAE,gBAAgB;QAC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I,CAAC,UAAU,CAAC,mBAAmB,CAAC;oBACtC,CAAC,CAAC,KAAK,CAAC;gBACV,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACpE,uBAAuB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACxB,IAAI,mBAAmB;gBAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YAC1D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAChC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnC,qEAAqE;YACrE,uEAAuE;YACvE,6CAA6C;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAmB;IAClE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACxD,uBAAuB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Vite plugin that generates end-to-end type-safe action types AND a runtime\n * registry of static imports so bundlers (Nitro on Netlify/Vercel/AWS-Lambda,\n * Rolldown, etc.) include every action file in the server bundle.\n *\n * Watches the `actions/` directory and emits:\n * - `.generated/action-types.d.ts` — type-only module that augments the\n * `ActionRegistry` interface in `@agent-native/core/client`, giving\n * `useActionQuery`/`useActionMutation` full inference.\n * - `.generated/actions-registry.ts` — runtime registry keyed by action\n * name, with static `import` statements for every action. Templates\n * import this file from their `server/plugins/agent-chat.ts` so Nitro\n * bundles the actions into the server function; without it the runtime\n * `fs.readdirSync` inside `autoDiscoverActions` finds nothing in a\n * bundled serverless function and every action route 404s.\n */\nimport path from \"path\";\nimport fs from \"fs\";\nimport type { Plugin } from \"vite\";\n\n/** Files to skip during discovery (matches action-discovery.ts). */\nconst SKIP_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\n/**\n * Framework-level sharing actions that must ALWAYS be in the generated\n * registry, even when the template's `actions/` directory doesn't contain\n * them. Each entry maps the action name to the bare-specifier import path so\n * bundlers see a static import and pull the module into the server bundle.\n *\n * Order matters: templates can override by defining a same-named file in\n * their own `actions/` directory — the merge below is skip-existing.\n */\nconst CORE_SHARING_ACTIONS: Array<{ name: string; specifier: string }> = [\n {\n name: \"share-resource\",\n specifier: \"@agent-native/core/sharing/actions/share-resource\",\n },\n {\n name: \"unshare-resource\",\n specifier: \"@agent-native/core/sharing/actions/unshare-resource\",\n },\n {\n name: \"list-resource-shares\",\n specifier: \"@agent-native/core/sharing/actions/list-resource-shares\",\n },\n {\n name: \"set-resource-visibility\",\n specifier: \"@agent-native/core/sharing/actions/set-resource-visibility\",\n },\n {\n name: \"upload-image\",\n specifier: \"@agent-native/core/file-upload/actions/upload-image\",\n },\n];\n\nfunction scanActionFiles(actionsDir: string): string[] {\n let files: string[];\n try {\n files = fs.readdirSync(actionsDir);\n } catch {\n return [];\n }\n return files.filter((f) => {\n if (!f.endsWith(\".ts\") && !f.endsWith(\".js\")) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_FILES.has(name)) return false;\n // Only include files that actually call defineAction or explicitly\n // re-export a package action. CLI scripts or example templates that live\n // in actions/ but don't export an action would otherwise drag their own\n // (often app/, browser-only, or fs-only) imports into the serverless\n // bundle and fail to resolve.\n try {\n const content = fs.readFileSync(path.join(actionsDir, f), \"utf-8\");\n const reexportsDefaultAction =\n /export\\s*\\{\\s*default\\s*\\}\\s*from\\s*[\"'][^\"']+[\"']/.test(content);\n if (!content.includes(\"defineAction\") && !reexportsDefaultAction) {\n return false;\n }\n } catch {\n return false;\n }\n return true;\n });\n}\n\nfunction toIdent(name: string): string {\n return \"a_\" + name.replace(/[^a-zA-Z0-9_]/g, \"_\");\n}\n\nfunction writeIfChanged(outFile: string, content: string): void {\n const existing = fs.existsSync(outFile)\n ? fs.readFileSync(outFile, \"utf-8\")\n : \"\";\n if (existing !== content) {\n fs.mkdirSync(path.dirname(outFile), { recursive: true });\n fs.writeFileSync(outFile, content);\n }\n}\n\nfunction findWorkspaceCoreActionsDir(projectRoot: string): string | null {\n let dir = path.resolve(projectRoot);\n let workspaceRoot: string | null = null;\n let packageName: string | null = null;\n\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n workspaceRoot = dir;\n packageName = declared;\n break;\n }\n } catch {\n // Keep walking on malformed package.json.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n if (!workspaceRoot || !packageName) return null;\n\n const nm = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nm, \"package.json\"))) {\n const actionsDir = path.join(fs.realpathSync(nm), \"actions\");\n return fs.existsSync(actionsDir) ? actionsDir : null;\n }\n\n const packagesDir = path.join(workspaceRoot, \"packages\");\n const candidates: string[] = [];\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n if (entry.name.startsWith(\"@\")) {\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (sub.isDirectory()) candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n }\n\n for (const candidate of candidates) {\n const pkgPath = path.join(candidate, \"package.json\");\n if (!fs.existsSync(pkgPath)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n if (pkg?.name === packageName) {\n const actionsDir = path.join(candidate, \"actions\");\n return fs.existsSync(actionsDir) ? actionsDir : null;\n }\n } catch {\n // Ignore malformed package.json.\n }\n }\n\n return null;\n}\n\n/**\n * Scan the actions directory and emit the types + runtime registry files.\n * Only writes files whose content has changed, to avoid triggering rebuilds.\n */\nfunction generateActionArtifacts(\n actionsDir: string,\n projectRoot: string,\n): void {\n const outDir = path.resolve(projectRoot, \".generated\");\n const relActionsDir = path.relative(outDir, actionsDir).replace(/\\\\/g, \"/\");\n\n const actionFiles = scanActionFiles(actionsDir);\n const workspaceActionsDir = findWorkspaceCoreActionsDir(projectRoot);\n const workspaceActionFiles = workspaceActionsDir\n ? scanActionFiles(workspaceActionsDir)\n : [];\n\n // Pre-compute template action names — used for skip-existing logic in both\n // the type declarations and the runtime registry below.\n const templateActionNames = new Set<string>(\n actionFiles.map((f) => f.replace(/\\.(ts|js)$/, \"\")),\n );\n const registeredActionNames = new Set(templateActionNames);\n\n const actionSources = actionFiles.map((f) => {\n const name = f.replace(/\\.(ts|js)$/, \"\");\n return {\n name,\n relPath: `${relActionsDir}/${name}`,\n };\n });\n\n if (workspaceActionsDir) {\n for (const f of workspaceActionFiles) {\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (registeredActionNames.has(name)) continue;\n const relPath = path\n .relative(outDir, path.join(workspaceActionsDir, name))\n .replace(/\\\\/g, \"/\");\n actionSources.push({ name, relPath });\n registeredActionNames.add(name);\n }\n }\n\n // --- types file ---------------------------------------------------------\n const typeEntries = actionSources.map(({ name, relPath }) => {\n return ` \"${name}\": ActionEntry<typeof import(\"${relPath}\")>;`;\n });\n\n // Also declare types for framework-level sharing actions so callers don't\n // need `as any` casts (same skip-existing logic as the runtime registry).\n for (const entry of CORE_SHARING_ACTIONS) {\n if (registeredActionNames.has(entry.name)) continue;\n typeEntries.push(\n ` \"${entry.name}\": ActionEntry<typeof import(\"${entry.specifier}\")>;`,\n );\n registeredActionNames.add(entry.name);\n }\n\n const typesContent = `// AUTO-GENERATED by @agent-native/core — do not edit manually.\n// Regenerated when files in actions/ change.\n// This file augments the ActionRegistry interface so that useActionQuery and\n// useActionMutation infer the correct types from your action definitions.\n\n/** Extract the return type and parameter type from a defineAction module. */\ntype ActionEntry<T> = T extends { default: { run: (...args: infer A) => infer R } }\n ? {\n result: Awaited<R>;\n params: A extends [infer P, ...any[]] ? P : Record<string, any>;\n }\n : { result: any; params: Record<string, any> };\n\ndeclare module \"@agent-native/core/client\" {\n interface ActionRegistry {\n${typeEntries.join(\"\\n\")}\n }\n}\n\nexport {};\n`;\n\n writeIfChanged(path.join(outDir, \"action-types.d.ts\"), typesContent);\n\n // --- runtime registry ---------------------------------------------------\n // Static imports of each action's default export so bundlers see every\n // action and include it in the server bundle. Normalization matches\n // `loadActionsIntoRegistry` in server/action-discovery.ts.\n const imports: string[] = [];\n const entries: string[] = [];\n const runtimeActionNames = new Set<string>();\n for (const { name, relPath } of actionSources) {\n const ident = toIdent(name);\n imports.push(`import * as ${ident} from \"${relPath}\";`);\n entries.push(` ${JSON.stringify(name)}: ${ident},`);\n runtimeActionNames.add(name);\n }\n // Framework-level sharing actions — only added when the template hasn't\n // provided a same-named file (skip-existing merge). Static imports ensure\n // bundlers pull these modules into the server bundle so\n // `/_agent-native/actions/share-resource` (etc.) always resolve.\n for (const entry of CORE_SHARING_ACTIONS) {\n if (runtimeActionNames.has(entry.name)) continue;\n const ident = toIdent(entry.name);\n imports.push(`import * as ${ident} from \"${entry.specifier}\";`);\n entries.push(` ${JSON.stringify(entry.name)}: ${ident},`);\n runtimeActionNames.add(entry.name);\n }\n\n const registryContent = `// AUTO-GENERATED by @agent-native/core — do not edit manually.\n// Static-import registry of every action file. Bundlers (Nitro, Rolldown)\n// see these imports and include the action modules in the server bundle.\n// The agent-chat plugin normalizes each module into an ActionEntry shape.\n${imports.join(\"\\n\")}\n\nconst modules: Record<string, unknown> = {\n${entries.join(\"\\n\")}\n};\n\nexport default modules;\n`;\n\n // Always write the registry — even when the template has no actions/ files\n // we still emit imports for the framework-level sharing actions so they get\n // mounted on every template that consumes the registry.\n writeIfChanged(path.join(outDir, \"actions-registry.ts\"), registryContent);\n\n // Ensure .generated/ is in .gitignore\n const gitignorePath = path.join(projectRoot, \".gitignore\");\n if (fs.existsSync(gitignorePath)) {\n const gitignore = fs.readFileSync(gitignorePath, \"utf-8\");\n if (!gitignore.includes(\".generated\")) {\n fs.appendFileSync(gitignorePath, \"\\n.generated/\\n\");\n }\n }\n}\n\n/**\n * Vite plugin that watches `actions/` and generates type-safe action types.\n *\n * Add to your Vite config (auto-included by `defineConfig` from `@agent-native/core`):\n *\n * ```ts\n * import { actionTypesPlugin } from \"@agent-native/core/vite/action-types-plugin\";\n * plugins: [actionTypesPlugin()]\n * ```\n */\nexport function actionTypesPlugin(): Plugin {\n let projectRoot = \"\";\n let actionsDir = \"\";\n let workspaceActionsDir: string | null = null;\n\n return {\n name: \"agent-native-action-types\",\n configResolved(config) {\n projectRoot = config.root;\n actionsDir = path.resolve(projectRoot, \"actions\");\n workspaceActionsDir = findWorkspaceCoreActionsDir(projectRoot);\n },\n buildStart() {\n generateActionArtifacts(actionsDir, projectRoot);\n },\n configureServer(server) {\n // Generate on startup\n generateActionArtifacts(actionsDir, projectRoot);\n\n // Watch for changes in actions/\n const watcher = server.watcher;\n const handleChange = (file: string) => {\n const inAppActions = file.startsWith(actionsDir);\n const inWorkspaceActions = workspaceActionsDir\n ? file.startsWith(workspaceActionsDir)\n : false;\n if ((inAppActions || inWorkspaceActions) && /\\.(ts|js)$/.test(file)) {\n generateActionArtifacts(actionsDir, projectRoot);\n }\n };\n watcher.add(actionsDir);\n if (workspaceActionsDir) watcher.add(workspaceActionsDir);\n watcher.on(\"add\", handleChange);\n watcher.on(\"unlink\", handleChange);\n // Don't regenerate on content changes — only file additions/removals\n // affect the registry. Return type changes are picked up by TypeScript\n // from the source files via typeof import().\n },\n };\n}\n\n/**\n * Public helper to regenerate the types + registry from a non-Vite context\n * (e.g. the Nitro deploy build, where Vite plugins don't run).\n */\nexport function generateActionRegistryForProject(projectRoot: string): void {\n const actionsDir = path.resolve(projectRoot, \"actions\");\n generateActionArtifacts(actionsDir, projectRoot);\n}\n"]}
@@ -124,6 +124,42 @@ export default createAuthPlugin({
124
124
  });
125
125
  ```
126
126
 
127
+ ## Public Workspace Apps {#public-workspace-apps}
128
+
129
+ Workspace apps are internal by default. To let anonymous visitors load a public
130
+ site while keeping management pages behind auth, declare route access in
131
+ `apps/<id>/package.json`:
132
+
133
+ ```json
134
+ {
135
+ "agent-native": {
136
+ "workspaceApp": {
137
+ "audience": "public",
138
+ "protectedPaths": ["/admin"]
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ For the inverse shape, keep the default internal audience and expose only
145
+ specific public pages:
146
+
147
+ ```json
148
+ {
149
+ "agent-native": {
150
+ "workspaceApp": {
151
+ "publicPaths": ["/", "/share"]
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ `publicPaths` and `protectedPaths` use prefix matching, so `"/admin"` also
158
+ covers `"/admin/users"`. These settings open page navigation only. Framework
159
+ routes (`/_agent-native/*`) and custom API routes (`/api/*`) still require auth
160
+ unless the app explicitly adds those prefixes to
161
+ `createAuthPlugin({ publicPaths: [...] })`.
162
+
127
163
  ## Session API {#session-api}
128
164
 
129
165
  The session object returned by `getSession(event)` has this shape:
@@ -191,6 +191,21 @@ export function AppSync() {
191
191
  }
192
192
  ```
193
193
 
194
+ **The agent-native promise: agent writes show up in the UI without a manual refresh.** `useActionQuery` is the easy path — every hook is auto-refetched on every change event the framework sees. If you reach for raw `useQuery` with a custom key (e.g. for a non-action HTTP endpoint, integration status, etc.), you must fold the per-source counter into the queryKey or agent writes will be silently invisible:
195
+
196
+ ```tsx
197
+ import { useChangeVersions } from "@agent-native/core/client";
198
+
199
+ const v = useChangeVersions(["dashboards", "action"]);
200
+ useQuery({
201
+ queryKey: ["dashboard", id, v],
202
+ queryFn: () => fetchDashboard(id),
203
+ placeholderData: (prev) => prev, // no flicker on refetch
204
+ });
205
+ ```
206
+
207
+ Common sources: `"action"` (every successful agent action — the reliable fallback), `"app-state"`, `"settings"`, plus any custom resource source your store emits via `recordChange`. See the `real-time-sync` skill for the full pattern.
208
+
194
209
  ## Add Application State {#application-state}
195
210
 
196
211
  Application state is how the agent knows what the user is seeing. At minimum, add:
@@ -17,7 +17,7 @@ Reach for Dispatch when any of these are true:
17
17
 
18
18
  - You're running a [multi-app workspace](/docs/multi-app-workspace) — mail, calendar, analytics, content, recruiting — and you don't want one Slack bot per app.
19
19
  - You want **one inbox for "the agent"** so users DM a single bot and the right specialist app picks up the work behind the scenes.
20
- - You have **workspace-wide secrets** (Stripe key, OpenAI key, third-party API tokens) that several apps need but you'd rather grant per-app than copy into every `.env`.
20
+ - You have **workspace-wide secrets** (Stripe key, OpenAI key, third-party API tokens) that several apps need and you want one vault instead of copying values into every `.env`.
21
21
  - You want a **runtime approval flow** in front of sensitive changes (saved destinations, policy edits) so non-admins can request and admins can sign off without a code deploy.
22
22
  - You want **shared skills, instructions, and agent profiles** that every app in the workspace inherits — change once, reach all.
23
23
 
@@ -35,7 +35,7 @@ See [Messaging](/docs/messaging) for the credentials and webhook URLs for each p
35
35
 
36
36
  ### Secret vault
37
37
 
38
- Store credentials once in Dispatch's vault and grant them to the apps that need them. Non-admins can **request** a secret for an app; admins **approve**, which creates the secret + grant in one step. Every read, grant, sync, and rotation is captured in an audit log. `sync-vault-to-app` pushes granted secrets into the target app's env so you don't have to redeploy or re-paste anything.
38
+ Store credentials once in Dispatch's vault. By default, vault access is **all apps**: every saved key is available to every workspace app, and `sync-vault-to-app` pushes the full vault to the target app. Workspaces that need stricter separation can switch the vault to **manual** mode, where explicit per-app grants are required before sync. Non-admins can **request** a secret for an app; admins **approve**, which creates the secret and, in manual workflows, the grant. Every read, grant, sync, and rotation is captured in an audit log.
39
39
 
40
40
  This is what makes "rotate the OpenAI key" a one-click operation across ten apps instead of ten PRs.
41
41
 
@@ -83,7 +83,7 @@ Three short steps:
83
83
  2. **Connect messaging.** Open **Settings → Messaging** in Dispatch and click connect for Slack, Email, Telegram, or WhatsApp. The form fields match the env vars in the [Messaging](/docs/messaging) doc — refer there for what each platform needs.
84
84
  3. **Add other apps.** Run `npx @agent-native/core add-app` from the workspace root for each domain app. They auto-appear as A2A peers in Dispatch's `list-workspace-apps` — no manual registration, no agent-card editing. Dispatch will start delegating to them as soon as their agent cards are reachable.
85
85
 
86
- Then add credentials to the vault, grant them to the apps that need them, and (optionally) author workspace skills under **Resources** and sync them out.
86
+ Then add credentials to the vault, sync them to apps, and (optionally) author workspace skills under **Resources** and sync them out. If you need per-app secret isolation, switch the vault access setting to manual before granting individual apps.
87
87
 
88
88
  ## See also {#see-also}
89
89
 
@@ -146,6 +146,11 @@ Active organization flows automatically: `session.orgId` → `AGENT_ORG_ID` →
146
146
 
147
147
  The workspace root `.env` is loaded into every app automatically. Put shared keys once at the root — `ANTHROPIC_API_KEY`, `A2A_SECRET`, `BETTER_AUTH_SECRET`, `DATABASE_URL`, `BUILDER_PRIVATE_KEY`, etc. — and every app picks them up. Per-app overrides go in `apps/<name>/.env` and win on conflict.
148
148
 
149
+ For runtime app credentials, prefer the Dispatch vault over hand-editing `.env`
150
+ files. The vault defaults to all-apps access, so every saved vault key is
151
+ available to every workspace app and can be pushed with `sync-vault-to-app`.
152
+ Switch the vault to manual mode only when apps need explicit per-key grants.
153
+
149
154
  ```text
150
155
  my-company-platform/
151
156
  ├── .env # shared: ANTHROPIC_API_KEY=... , A2A_SECRET=... , ...
@@ -130,6 +130,18 @@ Only `name` and `track` are required. `identify` and `flush` are optional — im
130
130
  - **Best-effort delivery** — provider errors are caught and logged. A failing analytics integration never crashes the caller or blocks request handling.
131
131
  - **Global singleton** — the registry uses a `Symbol.for` key on `globalThis` so multiple ESM graph instances (dev-mode Vite + Nitro, symlinks) share one provider set.
132
132
 
133
+ ## Browser defaults {#browser-defaults}
134
+
135
+ Template roots call `configureTracking()` once at startup. Browser events sent with `trackEvent()` automatically include app/template context plus the current LLM connection when the app can resolve it:
136
+
137
+ - `llm_connection` — normalized provider label such as `builder`, `anthropic`, `openai`, `google`, or `none`
138
+ - `llm_engine` — the engine id, for example `builder` or `ai-sdk:openai`
139
+ - `llm_model` — the selected/default model when known
140
+ - `llm_connection_source` — `app_secrets`, `settings`, or `env`
141
+ - `llm_connection_configured` — whether an LLM connection is available
142
+
143
+ The framework also tracks `builder connect clicked` from Connect Builder CTAs, and the server-side Builder connect routes track started/succeeded/failed lifecycle events.
144
+
133
145
  ## Using track() in templates {#templates}
134
146
 
135
147
  Call `track()` from action handlers to record user or agent activity:
@@ -184,7 +184,7 @@ The [Dispatch](/docs/dispatch) app is the workspace's runtime control plane. It
184
184
  | Concern | Git / GitHub | Dispatch |
185
185
  | ------------------------------- | ----------------------------- | ------------------------------------------ |
186
186
  | Who can change code | CODEOWNERS, branch protection | — |
187
- | Who can access secrets | — | Vault grants + request workflow |
187
+ | Who can access secrets | — | Vault policy, grants, request workflow |
188
188
  | What instructions agents follow | — | Workspace resources (skills, instructions) |
189
189
  | Which agents are shared | — | Workspace agent profiles |
190
190
  | Integration inventory | — | Integrations catalog |
@@ -196,12 +196,47 @@ The [Dispatch](/docs/dispatch) app is the workspace's runtime control plane. It
196
196
 
197
197
  ### What Dispatch Manages
198
198
 
199
- - **Vault** — store credentials centrally, grant them to specific apps, sync on demand. Non-admins can request access; admins approve.
199
+ - **Vault** — store credentials centrally and sync on demand. The default policy makes all vault keys available to all workspace apps; manual mode requires specific app grants. Non-admins can request access; admins approve.
200
200
  - **Integrations catalog** — see which credentials each app needs, what's configured, what's missing, what's granted from the vault.
201
201
  - **Workspace resources** — share skills, behavioral instructions, and reusable agent profiles across apps. Scope to all apps or grant per-app.
202
202
  - **Approvals** — require review before runtime changes (destinations, settings) take effect.
203
203
  - **Audit** — full history of secret access, grants, syncs, and changes.
204
204
 
205
+ ### Public App Routes
206
+
207
+ Workspace apps are internal by default. For a public site with login-only admin
208
+ pages, set a public audience and protect the admin prefix in that app's
209
+ `package.json`:
210
+
211
+ ```json
212
+ {
213
+ "agent-native": {
214
+ "workspaceApp": {
215
+ "audience": "public",
216
+ "protectedPaths": ["/admin"]
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ For mostly internal apps with a few public pages, leave the audience internal and
223
+ list page prefixes:
224
+
225
+ ```json
226
+ {
227
+ "agent-native": {
228
+ "workspaceApp": {
229
+ "publicPaths": ["/", "/share"]
230
+ }
231
+ }
232
+ }
233
+ ```
234
+
235
+ These settings only affect read-only page navigation. Framework tools, agent
236
+ chat, A2A, vault access, and arbitrary APIs stay authenticated unless the app
237
+ explicitly declares public prefixes with
238
+ `createAuthPlugin({ publicPaths: [...] })`.
239
+
205
240
  ## Setup Checklist
206
241
 
207
242
  For a new workspace, after running `agent-native create`:
@@ -216,8 +251,8 @@ For a new workspace, after running `agent-native create`:
216
251
  **Dispatch:**
217
252
 
218
253
  - [ ] Add shared secrets to the vault (API keys, OAuth credentials, etc.)
219
- - [ ] Grant secrets to the apps that need them
220
- - [ ] Sync granted secrets to push them to apps
254
+ - [ ] Keep the default all-apps vault policy or switch to manual per-app grants
255
+ - [ ] Sync vault secrets to push them to apps
221
256
  - [ ] Add workspace-wide skills and instructions via the Resources page
222
257
  - [ ] Configure the approval policy and approver emails
223
258
  - [ ] Set up SendGrid (`SENDGRID_API_KEY`, `SENDGRID_FROM_EMAIL`) for admin notifications