@agent-native/core 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. package/README.md +43 -3
  2. package/dist/agent/production-agent.d.ts.map +1 -1
  3. package/dist/agent/production-agent.js +154 -4
  4. package/dist/agent/production-agent.js.map +1 -1
  5. package/dist/agent/types.d.ts +1 -1
  6. package/dist/agent/types.d.ts.map +1 -1
  7. package/dist/cli/create-workspace.d.ts +8 -0
  8. package/dist/cli/create-workspace.d.ts.map +1 -0
  9. package/dist/cli/create-workspace.js +18 -0
  10. package/dist/cli/create-workspace.js.map +1 -0
  11. package/dist/cli/create.d.ts +35 -7
  12. package/dist/cli/create.d.ts.map +1 -1
  13. package/dist/cli/create.js +444 -251
  14. package/dist/cli/create.js.map +1 -1
  15. package/dist/cli/index.js +59 -5
  16. package/dist/cli/index.js.map +1 -1
  17. package/dist/cli/workspacify.d.ts +18 -0
  18. package/dist/cli/workspacify.d.ts.map +1 -0
  19. package/dist/cli/workspacify.js +74 -0
  20. package/dist/cli/workspacify.js.map +1 -0
  21. package/dist/client/AgentPanel.d.ts +1 -1
  22. package/dist/client/AgentPanel.d.ts.map +1 -1
  23. package/dist/client/AgentPanel.js +63 -225
  24. package/dist/client/AgentPanel.js.map +1 -1
  25. package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
  26. package/dist/client/components/CodeRequiredDialog.js +86 -5
  27. package/dist/client/components/CodeRequiredDialog.js.map +1 -1
  28. package/dist/client/composer/MentionPopover.d.ts.map +1 -1
  29. package/dist/client/composer/MentionPopover.js +15 -2
  30. package/dist/client/composer/MentionPopover.js.map +1 -1
  31. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  32. package/dist/client/composer/TiptapComposer.js +3 -1
  33. package/dist/client/composer/TiptapComposer.js.map +1 -1
  34. package/dist/client/composer/types.d.ts +1 -1
  35. package/dist/client/composer/types.d.ts.map +1 -1
  36. package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
  37. package/dist/client/integrations/IntegrationsPanel.js +22 -9
  38. package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
  39. package/dist/client/onboarding/OnboardingBanner.d.ts +13 -0
  40. package/dist/client/onboarding/OnboardingBanner.d.ts.map +1 -0
  41. package/dist/client/onboarding/OnboardingBanner.js +36 -0
  42. package/dist/client/onboarding/OnboardingBanner.js.map +1 -0
  43. package/dist/client/onboarding/OnboardingPanel.d.ts +16 -0
  44. package/dist/client/onboarding/OnboardingPanel.d.ts.map +1 -0
  45. package/dist/client/onboarding/OnboardingPanel.js +360 -0
  46. package/dist/client/onboarding/OnboardingPanel.js.map +1 -0
  47. package/dist/client/onboarding/SetupButton.d.ts +10 -0
  48. package/dist/client/onboarding/SetupButton.d.ts.map +1 -0
  49. package/dist/client/onboarding/SetupButton.js +26 -0
  50. package/dist/client/onboarding/SetupButton.js.map +1 -0
  51. package/dist/client/onboarding/index.d.ts +12 -0
  52. package/dist/client/onboarding/index.d.ts.map +1 -0
  53. package/dist/client/onboarding/index.js +11 -0
  54. package/dist/client/onboarding/index.js.map +1 -0
  55. package/dist/client/onboarding/use-onboarding.d.ts +34 -0
  56. package/dist/client/onboarding/use-onboarding.d.ts.map +1 -0
  57. package/dist/client/onboarding/use-onboarding.js +101 -0
  58. package/dist/client/onboarding/use-onboarding.js.map +1 -0
  59. package/dist/client/org/TeamPage.d.ts +6 -1
  60. package/dist/client/org/TeamPage.d.ts.map +1 -1
  61. package/dist/client/org/TeamPage.js +85 -14
  62. package/dist/client/org/TeamPage.js.map +1 -1
  63. package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
  64. package/dist/client/resources/ResourceEditor.js +48 -77
  65. package/dist/client/resources/ResourceEditor.js.map +1 -1
  66. package/dist/client/resources/ResourceTree.d.ts.map +1 -1
  67. package/dist/client/resources/ResourceTree.js +16 -3
  68. package/dist/client/resources/ResourceTree.js.map +1 -1
  69. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  70. package/dist/client/resources/ResourcesPanel.js +135 -9
  71. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  72. package/dist/client/resources/use-resources.d.ts +5 -0
  73. package/dist/client/resources/use-resources.d.ts.map +1 -1
  74. package/dist/client/resources/use-resources.js.map +1 -1
  75. package/dist/client/settings/AgentsSection.d.ts +2 -0
  76. package/dist/client/settings/AgentsSection.d.ts.map +1 -0
  77. package/dist/client/settings/AgentsSection.js +198 -0
  78. package/dist/client/settings/AgentsSection.js.map +1 -0
  79. package/dist/client/settings/BackgroundAgentSection.d.ts +2 -0
  80. package/dist/client/settings/BackgroundAgentSection.d.ts.map +1 -0
  81. package/dist/client/settings/BackgroundAgentSection.js +46 -0
  82. package/dist/client/settings/BackgroundAgentSection.js.map +1 -0
  83. package/dist/client/settings/BrowserSection.d.ts +2 -0
  84. package/dist/client/settings/BrowserSection.d.ts.map +1 -0
  85. package/dist/client/settings/BrowserSection.js +10 -0
  86. package/dist/client/settings/BrowserSection.js.map +1 -0
  87. package/dist/client/settings/ComingSoonSection.d.ts +13 -0
  88. package/dist/client/settings/ComingSoonSection.d.ts.map +1 -0
  89. package/dist/client/settings/ComingSoonSection.js +9 -0
  90. package/dist/client/settings/ComingSoonSection.js.map +1 -0
  91. package/dist/client/settings/LLMSection.d.ts +2 -0
  92. package/dist/client/settings/LLMSection.d.ts.map +1 -0
  93. package/dist/client/settings/LLMSection.js +64 -0
  94. package/dist/client/settings/LLMSection.js.map +1 -0
  95. package/dist/client/settings/SettingsPanel.d.ts +8 -0
  96. package/dist/client/settings/SettingsPanel.d.ts.map +1 -0
  97. package/dist/client/settings/SettingsPanel.js +118 -0
  98. package/dist/client/settings/SettingsPanel.js.map +1 -0
  99. package/dist/client/settings/SettingsSection.d.ts +19 -0
  100. package/dist/client/settings/SettingsSection.d.ts.map +1 -0
  101. package/dist/client/settings/SettingsSection.js +10 -0
  102. package/dist/client/settings/SettingsSection.js.map +1 -0
  103. package/dist/client/settings/index.d.ts +3 -0
  104. package/dist/client/settings/index.d.ts.map +1 -0
  105. package/dist/client/settings/index.js +3 -0
  106. package/dist/client/settings/index.js.map +1 -0
  107. package/dist/client/settings/useBuilderStatus.d.ts +22 -0
  108. package/dist/client/settings/useBuilderStatus.d.ts.map +1 -0
  109. package/dist/client/settings/useBuilderStatus.js +41 -0
  110. package/dist/client/settings/useBuilderStatus.js.map +1 -0
  111. package/dist/deploy/build.js +198 -54
  112. package/dist/deploy/build.js.map +1 -1
  113. package/dist/deploy/route-discovery.d.ts +5 -0
  114. package/dist/deploy/route-discovery.d.ts.map +1 -1
  115. package/dist/deploy/route-discovery.js +38 -7
  116. package/dist/deploy/route-discovery.js.map +1 -1
  117. package/dist/deploy/workspace-core.d.ts +28 -0
  118. package/dist/deploy/workspace-core.d.ts.map +1 -0
  119. package/dist/deploy/workspace-core.js +223 -0
  120. package/dist/deploy/workspace-core.js.map +1 -0
  121. package/dist/deploy/workspace-deploy.d.ts +11 -0
  122. package/dist/deploy/workspace-deploy.d.ts.map +1 -0
  123. package/dist/deploy/workspace-deploy.js +148 -0
  124. package/dist/deploy/workspace-deploy.js.map +1 -0
  125. package/dist/file-upload/builder.d.ts +11 -0
  126. package/dist/file-upload/builder.d.ts.map +1 -0
  127. package/dist/file-upload/builder.js +53 -0
  128. package/dist/file-upload/builder.js.map +1 -0
  129. package/dist/file-upload/index.d.ts +4 -0
  130. package/dist/file-upload/index.d.ts.map +1 -0
  131. package/dist/file-upload/index.js +3 -0
  132. package/dist/file-upload/index.js.map +1 -0
  133. package/dist/file-upload/registry.d.ts +23 -0
  134. package/dist/file-upload/registry.d.ts.map +1 -0
  135. package/dist/file-upload/registry.js +52 -0
  136. package/dist/file-upload/registry.js.map +1 -0
  137. package/dist/file-upload/types.d.ts +37 -0
  138. package/dist/file-upload/types.d.ts.map +1 -0
  139. package/dist/file-upload/types.js +10 -0
  140. package/dist/file-upload/types.js.map +1 -0
  141. package/dist/integrations/adapters/google-docs.d.ts +89 -0
  142. package/dist/integrations/adapters/google-docs.d.ts.map +1 -0
  143. package/dist/integrations/adapters/google-docs.js +261 -0
  144. package/dist/integrations/adapters/google-docs.js.map +1 -0
  145. package/dist/integrations/adapters/slack.d.ts.map +1 -1
  146. package/dist/integrations/adapters/slack.js +34 -0
  147. package/dist/integrations/adapters/slack.js.map +1 -1
  148. package/dist/integrations/adapters/telegram.d.ts.map +1 -1
  149. package/dist/integrations/adapters/telegram.js +32 -0
  150. package/dist/integrations/adapters/telegram.js.map +1 -1
  151. package/dist/integrations/google-docs-poller.d.ts +54 -0
  152. package/dist/integrations/google-docs-poller.d.ts.map +1 -0
  153. package/dist/integrations/google-docs-poller.js +442 -0
  154. package/dist/integrations/google-docs-poller.js.map +1 -0
  155. package/dist/integrations/index.d.ts +2 -0
  156. package/dist/integrations/index.d.ts.map +1 -1
  157. package/dist/integrations/index.js +3 -0
  158. package/dist/integrations/index.js.map +1 -1
  159. package/dist/integrations/plugin.d.ts.map +1 -1
  160. package/dist/integrations/plugin.js +49 -2
  161. package/dist/integrations/plugin.js.map +1 -1
  162. package/dist/integrations/types.d.ts +33 -0
  163. package/dist/integrations/types.d.ts.map +1 -1
  164. package/dist/integrations/webhook-handler.d.ts +10 -1
  165. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  166. package/dist/integrations/webhook-handler.js +13 -3
  167. package/dist/integrations/webhook-handler.js.map +1 -1
  168. package/dist/jobs/scheduler.d.ts +3 -0
  169. package/dist/jobs/scheduler.d.ts.map +1 -1
  170. package/dist/jobs/scheduler.js +81 -60
  171. package/dist/jobs/scheduler.js.map +1 -1
  172. package/dist/jobs/tools.d.ts.map +1 -1
  173. package/dist/jobs/tools.js +20 -3
  174. package/dist/jobs/tools.js.map +1 -1
  175. package/dist/mcp-client/config.d.ts +46 -0
  176. package/dist/mcp-client/config.d.ts.map +1 -0
  177. package/dist/mcp-client/config.js +152 -0
  178. package/dist/mcp-client/config.js.map +1 -0
  179. package/dist/mcp-client/index.d.ts +17 -0
  180. package/dist/mcp-client/index.d.ts.map +1 -0
  181. package/dist/mcp-client/index.js +53 -0
  182. package/dist/mcp-client/index.js.map +1 -0
  183. package/dist/mcp-client/manager.d.ts +76 -0
  184. package/dist/mcp-client/manager.d.ts.map +1 -0
  185. package/dist/mcp-client/manager.js +212 -0
  186. package/dist/mcp-client/manager.js.map +1 -0
  187. package/dist/oauth-tokens/store.d.ts.map +1 -1
  188. package/dist/oauth-tokens/store.js +3 -1
  189. package/dist/oauth-tokens/store.js.map +1 -1
  190. package/dist/onboarding/default-steps.d.ts +10 -0
  191. package/dist/onboarding/default-steps.d.ts.map +1 -0
  192. package/dist/onboarding/default-steps.js +164 -0
  193. package/dist/onboarding/default-steps.js.map +1 -0
  194. package/dist/onboarding/index.d.ts +12 -0
  195. package/dist/onboarding/index.d.ts.map +1 -0
  196. package/dist/onboarding/index.js +11 -0
  197. package/dist/onboarding/index.js.map +1 -0
  198. package/dist/onboarding/plugin.d.ts +19 -0
  199. package/dist/onboarding/plugin.d.ts.map +1 -0
  200. package/dist/onboarding/plugin.js +147 -0
  201. package/dist/onboarding/plugin.js.map +1 -0
  202. package/dist/onboarding/registry.d.ts +24 -0
  203. package/dist/onboarding/registry.d.ts.map +1 -0
  204. package/dist/onboarding/registry.js +40 -0
  205. package/dist/onboarding/registry.js.map +1 -0
  206. package/dist/onboarding/types.d.ts +71 -0
  207. package/dist/onboarding/types.d.ts.map +1 -0
  208. package/dist/onboarding/types.js +10 -0
  209. package/dist/onboarding/types.js.map +1 -0
  210. package/dist/resources/agents.d.ts +4 -0
  211. package/dist/resources/agents.d.ts.map +1 -0
  212. package/dist/resources/agents.js +44 -0
  213. package/dist/resources/agents.js.map +1 -0
  214. package/dist/resources/handlers.d.ts +17 -0
  215. package/dist/resources/handlers.d.ts.map +1 -1
  216. package/dist/resources/handlers.js +49 -12
  217. package/dist/resources/handlers.js.map +1 -1
  218. package/dist/resources/metadata.d.ts +48 -0
  219. package/dist/resources/metadata.d.ts.map +1 -0
  220. package/dist/resources/metadata.js +150 -0
  221. package/dist/resources/metadata.js.map +1 -0
  222. package/dist/resources/script-helpers.d.ts.map +1 -1
  223. package/dist/resources/script-helpers.js +3 -2
  224. package/dist/resources/script-helpers.js.map +1 -1
  225. package/dist/resources/store.d.ts.map +1 -1
  226. package/dist/resources/store.js +32 -17
  227. package/dist/resources/store.js.map +1 -1
  228. package/dist/scripts/call-agent.d.ts.map +1 -1
  229. package/dist/scripts/call-agent.js +3 -2
  230. package/dist/scripts/call-agent.js.map +1 -1
  231. package/dist/scripts/chat/search-chats.d.ts.map +1 -1
  232. package/dist/scripts/chat/search-chats.js +2 -1
  233. package/dist/scripts/chat/search-chats.js.map +1 -1
  234. package/dist/scripts/core-scripts.d.ts.map +1 -1
  235. package/dist/scripts/core-scripts.js +2 -0
  236. package/dist/scripts/core-scripts.js.map +1 -1
  237. package/dist/scripts/db/scoping.d.ts.map +1 -1
  238. package/dist/scripts/db/scoping.js +3 -2
  239. package/dist/scripts/db/scoping.js.map +1 -1
  240. package/dist/scripts/docs/index.d.ts +2 -0
  241. package/dist/scripts/docs/index.d.ts.map +1 -0
  242. package/dist/scripts/docs/index.js +4 -0
  243. package/dist/scripts/docs/index.js.map +1 -0
  244. package/dist/scripts/docs/search.d.ts +13 -0
  245. package/dist/scripts/docs/search.d.ts.map +1 -0
  246. package/dist/scripts/docs/search.js +130 -0
  247. package/dist/scripts/docs/search.js.map +1 -0
  248. package/dist/scripts/resources/delete-memory.d.ts +7 -0
  249. package/dist/scripts/resources/delete-memory.d.ts.map +1 -0
  250. package/dist/scripts/resources/delete-memory.js +49 -0
  251. package/dist/scripts/resources/delete-memory.js.map +1 -0
  252. package/dist/scripts/resources/delete.d.ts.map +1 -1
  253. package/dist/scripts/resources/delete.js +2 -1
  254. package/dist/scripts/resources/delete.js.map +1 -1
  255. package/dist/scripts/resources/index.d.ts.map +1 -1
  256. package/dist/scripts/resources/index.js +2 -0
  257. package/dist/scripts/resources/index.js.map +1 -1
  258. package/dist/scripts/resources/list.d.ts.map +1 -1
  259. package/dist/scripts/resources/list.js +2 -1
  260. package/dist/scripts/resources/list.js.map +1 -1
  261. package/dist/scripts/resources/migrate-learnings.d.ts.map +1 -1
  262. package/dist/scripts/resources/migrate-learnings.js +2 -1
  263. package/dist/scripts/resources/migrate-learnings.js.map +1 -1
  264. package/dist/scripts/resources/read.d.ts.map +1 -1
  265. package/dist/scripts/resources/read.js +2 -1
  266. package/dist/scripts/resources/read.js.map +1 -1
  267. package/dist/scripts/resources/save-memory.d.ts +9 -0
  268. package/dist/scripts/resources/save-memory.d.ts.map +1 -0
  269. package/dist/scripts/resources/save-memory.js +78 -0
  270. package/dist/scripts/resources/save-memory.js.map +1 -0
  271. package/dist/scripts/resources/write.d.ts.map +1 -1
  272. package/dist/scripts/resources/write.js +2 -1
  273. package/dist/scripts/resources/write.js.map +1 -1
  274. package/dist/scripts/utils.d.ts +10 -1
  275. package/dist/scripts/utils.d.ts.map +1 -1
  276. package/dist/scripts/utils.js +45 -2
  277. package/dist/scripts/utils.js.map +1 -1
  278. package/dist/server/action-discovery.d.ts +5 -0
  279. package/dist/server/action-discovery.d.ts.map +1 -1
  280. package/dist/server/action-discovery.js +51 -20
  281. package/dist/server/action-discovery.js.map +1 -1
  282. package/dist/server/action-routes.d.ts.map +1 -1
  283. package/dist/server/action-routes.js +63 -57
  284. package/dist/server/action-routes.js.map +1 -1
  285. package/dist/server/agent-chat-plugin.d.ts +3 -0
  286. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  287. package/dist/server/agent-chat-plugin.js +363 -48
  288. package/dist/server/agent-chat-plugin.js.map +1 -1
  289. package/dist/server/agent-discovery.d.ts.map +1 -1
  290. package/dist/server/agent-discovery.js +11 -23
  291. package/dist/server/agent-discovery.js.map +1 -1
  292. package/dist/server/agent-teams.d.ts.map +1 -1
  293. package/dist/server/agent-teams.js +2 -1
  294. package/dist/server/agent-teams.js.map +1 -1
  295. package/dist/server/agents-bundle.d.ts +33 -5
  296. package/dist/server/agents-bundle.d.ts.map +1 -1
  297. package/dist/server/agents-bundle.js +108 -64
  298. package/dist/server/agents-bundle.js.map +1 -1
  299. package/dist/server/auth.d.ts +1 -0
  300. package/dist/server/auth.d.ts.map +1 -1
  301. package/dist/server/auth.js +172 -60
  302. package/dist/server/auth.js.map +1 -1
  303. package/dist/server/better-auth-instance.d.ts.map +1 -1
  304. package/dist/server/better-auth-instance.js +202 -6
  305. package/dist/server/better-auth-instance.js.map +1 -1
  306. package/dist/server/builder-browser.d.ts +40 -0
  307. package/dist/server/builder-browser.d.ts.map +1 -0
  308. package/dist/server/builder-browser.js +166 -0
  309. package/dist/server/builder-browser.js.map +1 -0
  310. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  311. package/dist/server/core-routes-plugin.js +152 -6
  312. package/dist/server/core-routes-plugin.js.map +1 -1
  313. package/dist/server/credential-provider.d.ts +37 -0
  314. package/dist/server/credential-provider.d.ts.map +1 -0
  315. package/dist/server/credential-provider.js +49 -0
  316. package/dist/server/credential-provider.js.map +1 -0
  317. package/dist/server/framework-request-handler.d.ts.map +1 -1
  318. package/dist/server/framework-request-handler.js +42 -3
  319. package/dist/server/framework-request-handler.js.map +1 -1
  320. package/dist/server/google-auth-plugin.js +1 -1
  321. package/dist/server/google-oauth.d.ts +1 -1
  322. package/dist/server/google-oauth.d.ts.map +1 -1
  323. package/dist/server/google-oauth.js +15 -10
  324. package/dist/server/google-oauth.js.map +1 -1
  325. package/dist/server/index.d.ts +3 -0
  326. package/dist/server/index.d.ts.map +1 -1
  327. package/dist/server/index.js +3 -0
  328. package/dist/server/index.js.map +1 -1
  329. package/dist/server/oauth-helpers.d.ts +1 -0
  330. package/dist/server/oauth-helpers.d.ts.map +1 -1
  331. package/dist/server/oauth-helpers.js +5 -4
  332. package/dist/server/oauth-helpers.js.map +1 -1
  333. package/dist/server/onboarding-html.d.ts.map +1 -1
  334. package/dist/server/onboarding-html.js +94 -3
  335. package/dist/server/onboarding-html.js.map +1 -1
  336. package/dist/server/request-context.d.ts +20 -0
  337. package/dist/server/request-context.d.ts.map +1 -0
  338. package/dist/server/request-context.js +41 -0
  339. package/dist/server/request-context.js.map +1 -0
  340. package/dist/templates/default/.agents/skills/actions/SKILL.md +2 -1
  341. package/dist/templates/default/.agents/skills/security/SKILL.md +145 -40
  342. package/dist/templates/default/.agents/skills/storing-data/SKILL.md +7 -1
  343. package/dist/templates/default/_gitignore +1 -0
  344. package/dist/templates/default/app/root.tsx +4 -1
  345. package/dist/templates/workspace-core/AGENTS.md +62 -0
  346. package/dist/templates/workspace-core/actions/company-directory.ts +38 -0
  347. package/dist/templates/workspace-core/package.json +39 -0
  348. package/dist/templates/workspace-core/skills/company-policies/SKILL.md +42 -0
  349. package/dist/templates/workspace-core/src/client/AuthenticatedLayout.tsx +37 -0
  350. package/dist/templates/workspace-core/src/client/index.ts +26 -0
  351. package/dist/templates/workspace-core/src/credentials.ts +29 -0
  352. package/dist/templates/workspace-core/src/index.ts +21 -0
  353. package/dist/templates/workspace-core/src/server/agent-chat-plugin.ts +30 -0
  354. package/dist/templates/workspace-core/src/server/auth-plugin.ts +35 -0
  355. package/dist/templates/workspace-core/src/server/index.ts +22 -0
  356. package/dist/templates/workspace-core/tailwind.preset.ts +34 -0
  357. package/dist/templates/workspace-core/tsconfig.json +9 -0
  358. package/dist/templates/workspace-root/.env.example +37 -0
  359. package/dist/templates/workspace-root/README.md +62 -0
  360. package/dist/templates/workspace-root/_gitignore +23 -0
  361. package/dist/templates/workspace-root/package.json +18 -0
  362. package/dist/templates/workspace-root/pnpm-workspace.yaml +3 -0
  363. package/dist/templates/workspace-root/tsconfig.base.json +21 -0
  364. package/dist/vite/agents-bundle-plugin.d.ts.map +1 -1
  365. package/dist/vite/agents-bundle-plugin.js +65 -15
  366. package/dist/vite/agents-bundle-plugin.js.map +1 -1
  367. package/dist/vite/client.d.ts +16 -0
  368. package/dist/vite/client.d.ts.map +1 -1
  369. package/dist/vite/client.js +75 -0
  370. package/dist/vite/client.js.map +1 -1
  371. package/docs/content/a2a-protocol.md +223 -0
  372. package/docs/content/actions.md +129 -0
  373. package/docs/content/agent-mentions.md +171 -0
  374. package/docs/content/authentication.md +155 -0
  375. package/docs/content/cli-adapters.md +244 -0
  376. package/docs/content/client.md +175 -0
  377. package/docs/content/context-awareness.md +168 -0
  378. package/docs/content/creating-templates.md +311 -0
  379. package/docs/content/database.md +82 -0
  380. package/docs/content/deployment.md +180 -0
  381. package/docs/content/enterprise-workspace.md +235 -0
  382. package/docs/content/faq.md +101 -0
  383. package/docs/content/file-uploads.md +102 -0
  384. package/docs/content/frames.md +47 -0
  385. package/docs/content/getting-started.md +104 -0
  386. package/docs/content/integrations.md +198 -0
  387. package/docs/content/key-concepts.md +246 -0
  388. package/docs/content/mcp-clients.md +110 -0
  389. package/docs/content/mcp-protocol.md +168 -0
  390. package/docs/content/onboarding.md +107 -0
  391. package/docs/content/real-time-collaboration.md +185 -0
  392. package/docs/content/resources.md +277 -0
  393. package/docs/content/security.md +158 -0
  394. package/docs/content/server.md +200 -0
  395. package/docs/content/skills-guide.md +107 -0
  396. package/docs/content/what-is-agent-native.md +100 -0
  397. package/docs/content/workspace-management.md +224 -0
  398. package/package.json +12 -2
  399. package/src/templates/default/.agents/skills/actions/SKILL.md +2 -1
  400. package/src/templates/default/.agents/skills/security/SKILL.md +145 -40
  401. package/src/templates/default/.agents/skills/storing-data/SKILL.md +7 -1
  402. package/src/templates/default/_gitignore +1 -0
  403. package/src/templates/default/app/root.tsx +4 -1
  404. package/src/templates/workspace-core/AGENTS.md +62 -0
  405. package/src/templates/workspace-core/actions/company-directory.ts +38 -0
  406. package/src/templates/workspace-core/package.json +39 -0
  407. package/src/templates/workspace-core/skills/company-policies/SKILL.md +42 -0
  408. package/src/templates/workspace-core/src/client/AuthenticatedLayout.tsx +37 -0
  409. package/src/templates/workspace-core/src/client/index.ts +26 -0
  410. package/src/templates/workspace-core/src/credentials.ts +29 -0
  411. package/src/templates/workspace-core/src/index.ts +21 -0
  412. package/src/templates/workspace-core/src/server/agent-chat-plugin.ts +30 -0
  413. package/src/templates/workspace-core/src/server/auth-plugin.ts +35 -0
  414. package/src/templates/workspace-core/src/server/index.ts +22 -0
  415. package/src/templates/workspace-core/tailwind.preset.ts +34 -0
  416. package/src/templates/workspace-core/tsconfig.json +9 -0
  417. package/src/templates/workspace-root/.env.example +37 -0
  418. package/src/templates/workspace-root/README.md +62 -0
  419. package/src/templates/workspace-root/_gitignore +23 -0
  420. package/src/templates/workspace-root/package.json +18 -0
  421. package/src/templates/workspace-root/pnpm-workspace.yaml +3 -0
  422. package/src/templates/workspace-root/tsconfig.base.json +21 -0
  423. package/dist/templates/templates/default/.agents/skills/actions/SKILL.md +0 -142
  424. package/dist/templates/templates/default/.agents/skills/agent-engines/SKILL.md +0 -127
  425. package/dist/templates/templates/default/.agents/skills/capture-learnings/SKILL.md +0 -50
  426. package/dist/templates/templates/default/.agents/skills/create-skill/SKILL.md +0 -167
  427. package/dist/templates/templates/default/.agents/skills/delegate-to-agent/SKILL.md +0 -90
  428. package/dist/templates/templates/default/.agents/skills/frontend-design/SKILL.md +0 -69
  429. package/dist/templates/templates/default/.agents/skills/real-time-collab/SKILL.md +0 -183
  430. package/dist/templates/templates/default/.agents/skills/real-time-sync/SKILL.md +0 -112
  431. package/dist/templates/templates/default/.agents/skills/security/SKILL.md +0 -108
  432. package/dist/templates/templates/default/.agents/skills/self-modifying-code/SKILL.md +0 -79
  433. package/dist/templates/templates/default/.agents/skills/storing-data/SKILL.md +0 -110
  434. package/dist/templates/templates/default/.claude/settings.json +0 -100
  435. package/dist/templates/templates/default/.env.example +0 -5
  436. package/dist/templates/templates/default/.ignore +0 -0
  437. package/dist/templates/templates/default/.prettierrc +0 -5
  438. package/dist/templates/templates/default/AGENTS.md +0 -110
  439. package/dist/templates/templates/default/DEVELOPING.md +0 -117
  440. package/dist/templates/templates/default/_gitignore +0 -37
  441. package/dist/templates/templates/default/actions/hello.ts +0 -20
  442. package/dist/templates/templates/default/actions/navigate.ts +0 -53
  443. package/dist/templates/templates/default/actions/run.ts +0 -2
  444. package/dist/templates/templates/default/actions/view-screen.ts +0 -39
  445. package/dist/templates/templates/default/app/entry.client.tsx +0 -4
  446. package/dist/templates/templates/default/app/entry.server.tsx +0 -56
  447. package/dist/templates/templates/default/app/global.css +0 -95
  448. package/dist/templates/templates/default/app/lib/utils.ts +0 -1
  449. package/dist/templates/templates/default/app/root.tsx +0 -107
  450. package/dist/templates/templates/default/app/routes/_index.tsx +0 -62
  451. package/dist/templates/templates/default/app/routes.ts +0 -4
  452. package/dist/templates/templates/default/app/vite-env.d.ts +0 -6
  453. package/dist/templates/templates/default/components.json +0 -20
  454. package/dist/templates/templates/default/data/.gitkeep +0 -0
  455. package/dist/templates/templates/default/data/sync-config.json +0 -1
  456. package/dist/templates/templates/default/learnings.defaults.md +0 -5
  457. package/dist/templates/templates/default/learnings.md +0 -0
  458. package/dist/templates/templates/default/package.json +0 -46
  459. package/dist/templates/templates/default/postcss.config.js +0 -6
  460. package/dist/templates/templates/default/public/icon-180.svg +0 -4
  461. package/dist/templates/templates/default/public/icon-192.svg +0 -4
  462. package/dist/templates/templates/default/public/icon-512.svg +0 -4
  463. package/dist/templates/templates/default/public/manifest.json +0 -13
  464. package/dist/templates/templates/default/react-router.config.ts +0 -6
  465. package/dist/templates/templates/default/server/middleware/auth.ts +0 -15
  466. package/dist/templates/templates/default/server/plugins/.gitkeep +0 -0
  467. package/dist/templates/templates/default/server/routes/[...page].get.ts +0 -5
  468. package/dist/templates/templates/default/server/routes/api/hello.get.ts +0 -5
  469. package/dist/templates/templates/default/shared/api.ts +0 -6
  470. package/dist/templates/templates/default/ssr-entry.ts +0 -20
  471. package/dist/templates/templates/default/tailwind.config.ts +0 -7
  472. package/dist/templates/templates/default/tsconfig.json +0 -11
  473. package/dist/templates/templates/default/vite.config.ts +0 -6
@@ -1,15 +1,19 @@
1
+ import { runWithRequestContext, getRequestOrgId } from "./request-context.js";
1
2
  import { getH3App } from "./framework-request-handler.js";
2
3
  import { createProductionAgentHandler, runAgentLoop, actionsToEngineTools, getActiveRunForThreadAsync, abortRun, subscribeToRun, } from "../agent/production-agent.js";
3
4
  import { resolveEngine, createAnthropicEngine } from "../agent/engine/index.js";
5
+ import { McpClientManager, loadMcpConfig, autoDetectMcpConfig, mcpToolsToActionEntries, } from "../mcp-client/index.js";
4
6
  import { discoverAgents } from "./agent-discovery.js";
5
7
  import { loadSchemaPromptBlock } from "./schema-prompt.js";
6
8
  import { buildAssistantMessage, extractThreadMeta, } from "../agent/thread-data-builder.js";
7
9
  import { defineEventHandler, setResponseStatus, setResponseHeader, getMethod, getQuery, } from "h3";
8
10
  import { getSession } from "./auth.js";
11
+ import { getOrigin } from "./google-oauth.js";
9
12
  import { createThread, getThread, listThreads, searchThreads, updateThreadData, deleteThread, } from "../chat-threads/store.js";
10
13
  import { resourceListAccessible, resourceList, resourceGet, resourceGetByPath, ensurePersonalDefaults, SHARED_OWNER, } from "../resources/store.js";
11
14
  import nodePath from "node:path";
12
15
  import { readBody } from "./h3-helpers.js";
16
+ import { getBuilderBrowserConnectUrl, requestBuilderBrowserConnection, } from "./builder-browser.js";
13
17
  // Lazy fs — loaded via dynamic import() on first use.
14
18
  // This avoids require() which bundlers convert to createRequire(import.meta.url)
15
19
  // that crashes on CF Workers where import.meta.url is undefined.
@@ -68,16 +72,53 @@ function wrapCliScript(tool, cliDefault) {
68
72
  },
69
73
  };
70
74
  }
75
+ /**
76
+ * Creates the docs-search tool so agents can look up framework documentation.
77
+ * Docs are bundled in @agent-native/core and read via fs at runtime.
78
+ */
79
+ async function createDocsScriptEntries() {
80
+ try {
81
+ const mod = await import("../scripts/docs/search.js");
82
+ return {
83
+ "docs-search": wrapCliScript({
84
+ description: "Search and read agent-native framework documentation. Use --list to see all pages, --query to search, --slug to read a specific page.",
85
+ parameters: {
86
+ type: "object",
87
+ properties: {
88
+ query: {
89
+ type: "string",
90
+ description: "Search term to find relevant docs (e.g. 'actions', 'authentication', 'database')",
91
+ },
92
+ slug: {
93
+ type: "string",
94
+ description: "Read a specific doc page by slug (e.g. 'actions', 'authentication', 'database')",
95
+ },
96
+ list: {
97
+ type: "string",
98
+ description: 'Set to "true" to list all available doc pages',
99
+ enum: ["true"],
100
+ },
101
+ },
102
+ },
103
+ }, mod.default),
104
+ };
105
+ }
106
+ catch {
107
+ return {};
108
+ }
109
+ }
71
110
  /**
72
111
  * Creates resource ScriptEntries available in both prod and dev modes.
73
112
  */
74
113
  async function createResourceScriptEntries() {
75
114
  try {
76
- const [list, read, write, del] = await Promise.all([
115
+ const [list, read, write, del, saveMem, delMem] = await Promise.all([
77
116
  import("../scripts/resources/list.js"),
78
117
  import("../scripts/resources/read.js"),
79
118
  import("../scripts/resources/write.js"),
80
119
  import("../scripts/resources/delete.js"),
120
+ import("../scripts/resources/save-memory.js"),
121
+ import("../scripts/resources/delete-memory.js"),
81
122
  ]);
82
123
  return {
83
124
  "resource-list": wrapCliScript({
@@ -164,6 +205,45 @@ async function createResourceScriptEntries() {
164
205
  required: ["path"],
165
206
  },
166
207
  }, del.default),
208
+ "save-memory": wrapCliScript({
209
+ description: "Save a memory for future conversations. Creates or updates a memory file and its index entry. Use proactively when you learn preferences, corrections, project context, or references.",
210
+ parameters: {
211
+ type: "object",
212
+ properties: {
213
+ name: {
214
+ type: "string",
215
+ description: "Short kebab-case identifier (e.g. 'coding-style', 'deploy-process'). Used as the filename.",
216
+ },
217
+ type: {
218
+ type: "string",
219
+ description: "Memory category",
220
+ enum: ["user", "feedback", "project", "reference"],
221
+ },
222
+ description: {
223
+ type: "string",
224
+ description: "One-line summary shown in the memory index (keep under 80 chars)",
225
+ },
226
+ content: {
227
+ type: "string",
228
+ description: "The memory content in markdown. For updates, read first and provide full updated content.",
229
+ },
230
+ },
231
+ required: ["name", "type", "description", "content"],
232
+ },
233
+ }, saveMem.default),
234
+ "delete-memory": wrapCliScript({
235
+ description: "Delete a memory entry and remove it from the memory index.",
236
+ parameters: {
237
+ type: "object",
238
+ properties: {
239
+ name: {
240
+ type: "string",
241
+ description: "The memory name to delete (e.g. 'coding-style')",
242
+ },
243
+ },
244
+ required: ["name"],
245
+ },
246
+ }, delMem.default),
167
247
  };
168
248
  }
169
249
  catch {
@@ -260,6 +340,68 @@ async function createCallAgentScriptEntry(selfAppId) {
260
340
  return {};
261
341
  }
262
342
  }
343
+ function createBuilderBrowserTool(deps) {
344
+ return {
345
+ "get-browser-connection": {
346
+ tool: {
347
+ description: "Provision a Builder-backed browser session and return browser websocket connection details. If Builder browser access is not configured yet, this returns setup guidance instead.",
348
+ parameters: {
349
+ type: "object",
350
+ properties: {
351
+ sessionId: {
352
+ type: "string",
353
+ description: "Stable browser session identifier. Reuse it to reconnect to the same browser session.",
354
+ },
355
+ projectId: {
356
+ type: "string",
357
+ description: "Optional Builder project or space identifier to scope the session.",
358
+ },
359
+ branchName: {
360
+ type: "string",
361
+ description: "Optional branch name for Builder preview sessions.",
362
+ },
363
+ proxyOrigin: {
364
+ type: "string",
365
+ description: "Optional source origin to proxy from when browsing a local app.",
366
+ },
367
+ proxyDefaultOrigin: {
368
+ type: "string",
369
+ description: "Optional default origin that the browser should use for proxied requests.",
370
+ },
371
+ proxyDestination: {
372
+ type: "string",
373
+ description: "Optional destination origin for proxying local development traffic.",
374
+ },
375
+ },
376
+ required: ["sessionId"],
377
+ },
378
+ },
379
+ run: async (args) => {
380
+ if (!process.env.BUILDER_PRIVATE_KEY ||
381
+ !process.env.BUILDER_PUBLIC_KEY) {
382
+ return JSON.stringify({
383
+ configured: false,
384
+ message: "Builder browser access is not configured. Connect Builder from the workspace Resources panel before requesting a browser session.",
385
+ connectUrl: getBuilderBrowserConnectUrl(deps.getOrigin()),
386
+ });
387
+ }
388
+ const connection = await requestBuilderBrowserConnection({
389
+ sessionId: args.sessionId,
390
+ projectId: args.projectId,
391
+ branchName: args.branchName,
392
+ proxyOrigin: args.proxyOrigin,
393
+ proxyDefaultOrigin: args.proxyDefaultOrigin,
394
+ proxyDestination: args.proxyDestination,
395
+ });
396
+ return JSON.stringify({
397
+ configured: true,
398
+ sessionId: args.sessionId,
399
+ ...connection,
400
+ });
401
+ },
402
+ },
403
+ };
404
+ }
263
405
  /**
264
406
  * Creates agent team orchestration tools (spawn-task, task-status, read-task-result).
265
407
  * These let the main agent spawn sub-agents and coordinate work.
@@ -284,6 +426,10 @@ function createTeamTools(deps) {
284
426
  type: "string",
285
427
  description: "Short name for the sub-agent tab (e.g. 'Research', 'Draft email'). If omitted, derived from the task.",
286
428
  },
429
+ agent: {
430
+ type: "string",
431
+ description: "Optional custom agent profile from agents/*.md to use for this task.",
432
+ },
287
433
  },
288
434
  required: ["task"],
289
435
  },
@@ -302,14 +448,32 @@ function createTeamTools(deps) {
302
448
  "list-tasks",
303
449
  ]);
304
450
  const subAgentActions = Object.fromEntries(Object.entries(deps.getActions()).filter(([name]) => !teamToolNames.has(name)));
451
+ let instructions = args.instructions;
452
+ let selectedModel = deps.getModel();
453
+ let selectedName = args.name || "";
454
+ if (args.agent) {
455
+ const { findAccessibleCustomAgent } = await import("../resources/agents.js");
456
+ const profile = await findAccessibleCustomAgent(deps.getOwner(), args.agent);
457
+ if (!profile) {
458
+ throw new Error(`Custom agent not found: ${args.agent}`);
459
+ }
460
+ const profileInstructions = `## Custom Agent Profile: ${profile.name}\n\n` +
461
+ (profile.description ? `${profile.description}\n\n` : "") +
462
+ profile.instructions;
463
+ instructions = instructions
464
+ ? `${profileInstructions}\n\n## Extra Task Context\n\n${instructions}`
465
+ : profileInstructions;
466
+ selectedModel = profile.model ?? selectedModel;
467
+ selectedName = selectedName || profile.name;
468
+ }
305
469
  const task = await spawnTask({
306
470
  description: args.task,
307
- instructions: args.instructions,
471
+ instructions,
308
472
  ownerEmail: deps.getOwner(),
309
473
  systemPrompt: deps.getSystemPrompt(),
310
474
  actions: subAgentActions,
311
475
  engine: deps.getEngine(),
312
- model: deps.getModel(),
476
+ model: selectedModel,
313
477
  parentThreadId: deps.getParentThreadId(),
314
478
  parentSend: (event) => {
315
479
  if (capturedSend)
@@ -321,7 +485,7 @@ function createTeamTools(deps) {
321
485
  threadId: task.threadId,
322
486
  status: task.status,
323
487
  description: task.description,
324
- name: args.name || "",
488
+ name: selectedName,
325
489
  });
326
490
  },
327
491
  },
@@ -455,16 +619,16 @@ const FRAMEWORK_CORE = `
455
619
  2. **Context awareness** — The user's current screen state is automatically included in each message as a \`<current-screen>\` block. Use it to understand what the user is looking at. You can still call \`view-screen\` for a more detailed snapshot if needed, but you should NOT need to call it before every action.
456
620
  3. **Navigate the UI** — Use the \`navigate\` tool to switch views, open items, or focus elements for the user.
457
621
  4. **Application state** — Ephemeral UI state (drafts, selections, navigation) lives in \`application_state\`. Use \`readAppState\`/\`writeAppState\` to read and write it. When you write state, the UI updates automatically.
458
- 5. **Resources for memory** — Use the Resources system for persistent notes and context. Update LEARNINGS.md when you learn user preferences or corrections. Update the shared AGENTS.md for instructions that should apply to all users.
622
+ 5. **Memory** — Use the structured memory system to persist knowledge across sessions. Use \`save-memory\` proactively when you learn preferences, corrections, or project context. Update shared AGENTS.md for instructions that should apply to all users.
623
+ 6. **Security** — Always use \`defineAction\` with a Zod \`schema:\` for input validation. Never construct SQL with string concatenation — use parameterized queries via db-query/db-exec. Never use \`dangerouslySetInnerHTML\`, \`innerHTML\`, or \`eval()\`. Never expose secrets in responses or source code. Every table with user data must have \`owner_email\`.
459
624
 
460
625
  ### Resources
461
626
 
462
- You have access to a Resources system for persistent notes, learnings, and context files.
627
+ You have access to a Resources system for persistent notes and context files.
463
628
  Use resource-list, resource-read, resource-write, and resource-delete to manage resources.
464
629
  Resources can be personal (per-user) or shared (team-wide). By default, resources are personal.
465
630
 
466
- When you learn something important (user corrections, preferences, patterns), update the "LEARNINGS.md" resource. Keep it tidy — revise, consolidate, and remove outdated entries rather than only appending.
467
- When the user gives instructions that should apply to all users/sessions, update the shared "AGENTS.md" resource instead.
631
+ When the user gives instructions that should apply to all users/sessions, update the shared "AGENTS.md" resource.
468
632
 
469
633
  ### Navigation Rule
470
634
 
@@ -481,7 +645,7 @@ When the user asks to find a previous conversation, use \`search-chats\` first t
481
645
  ### Agent Teams — Orchestration
482
646
 
483
647
  You are an orchestrator. For complex or multi-step tasks, delegate to sub-agents:
484
- - \`spawn-task\` — Spawn a sub-agent for a task. It runs in its own thread while you stay available. A live preview card appears in the chat.
648
+ - \`spawn-task\` — Spawn a sub-agent for a task. It runs in its own thread while you stay available. A live preview card appears in the chat. You can optionally choose a custom agent profile from \`agents/*.md\`.
485
649
  - \`task-status\` — Check the progress of a running sub-agent.
486
650
  - \`read-task-result\` — Read the result when a sub-agent finishes.
487
651
 
@@ -497,7 +661,7 @@ You are an orchestrator. For complex or multi-step tasks, delegate to sub-agents
497
661
  4. Use \`read-task-result\` to check results when needed, or the user can see live progress in the card.
498
662
  5. If the user's request has multiple steps, you can spawn one sub-agent per step, or chain them.
499
663
 
500
- Sub-agents have access to all template tools but **cannot spawn sub-agents themselves** — only you (the orchestrator) can do that. Give the sub-agent a specific, actionable task description — it will figure out which tools to use.
664
+ Sub-agents have access to all template tools but **cannot spawn sub-agents themselves** — only you (the orchestrator) can do that. Give the sub-agent a specific, actionable task description — it will figure out which tools to use. If a matching custom agent profile exists, pass it via the \`agent\` parameter on \`spawn-task\`.
501
665
 
502
666
  ### Recurring Jobs
503
667
 
@@ -518,6 +682,14 @@ When the user asks for something recurring ("every morning", "daily at 9am", "we
518
682
 
519
683
  Job instructions should be self-contained — include which actions to call, what conditions to check, and what to do with results. The agent executing the job has access to all the same tools you do.
520
684
 
685
+ ### Browser Access
686
+
687
+ Use \`get-browser-connection\` when you need a real browser session backed by Builder. It returns websocket connection details for a provisioned browser session.
688
+
689
+ - If the tool says Builder is not configured, tell the user to connect Builder from the workspace Resources panel.
690
+ - Reuse a stable \`sessionId\` when you want to reconnect to the same browser session.
691
+ - Include proxy parameters when you need the browser to reach a local dev server through Builder's browser connection flow.
692
+
521
693
  ### call-agent — External Apps Only
522
694
 
523
695
  The \`call-agent\` tool sends a message to a DIFFERENT, separately-deployed app's agent (A2A protocol). It is **not** for calling actions within the current app.
@@ -534,15 +706,34 @@ The \`call-agent\` tool sends a message to a DIFFERENT, separately-deployed app'
534
706
 
535
707
  If \`call-agent\` returns an error saying the agent is yourself — stop and use your own tools instead.
536
708
 
537
- ### Auto-Memory
709
+ ### Structured Memory
710
+
711
+ You have a structured memory system. Your memory index (\`memory/MEMORY.md\`) is loaded at the start of every conversation (shown above). Individual memories are stored as separate files under \`memory/\`.
538
712
 
539
- Proactively update \`LEARNINGS.md\` when you learn something important during conversations:
540
- - User corrects your approach capture the correct way
541
- - User shares preferences (tone, style, workflow) capture them
542
- - You discover a non-obvious pattern or gotcha capture it
543
- - User provides personal context (contacts, team info, domain knowledge) → capture it
713
+ **Tools:**
714
+ - \`save-memory\` Create or update a memory. Provide name, type, description, and content. Atomically updates both the memory file and the index.
715
+ - \`delete-memory\` Remove a memory and its index entry.
716
+ - \`resource-read --path memory/<name>.md\` — Read the full content of a specific memory when you need details beyond the index.
544
717
 
545
- **Don't ask permission — just save it.** Keep entries concise (one line each, grouped by category). Don't save things that are obvious from reading the code or that are temporary.
718
+ **Memory types:**
719
+ - \`user\` — Preferences, role, personal context, contacts
720
+ - \`feedback\` — Corrections ("don't do X, do Y instead"), confirmed approaches
721
+ - \`project\` — Ongoing work context, decisions, status
722
+ - \`reference\` — Pointers to external systems, URLs, API details
723
+
724
+ **When to save (do it proactively, don't ask permission):**
725
+ - User corrects your approach → save as \`feedback\`
726
+ - User shares preferences (tone, style, workflow) → save as \`user\`
727
+ - You discover a non-obvious pattern or gotcha → save as \`feedback\`
728
+ - User provides personal context (contacts, team, domain) → save as \`user\`
729
+ - A project gains enough context to track → save as \`project\`
730
+
731
+ **Rules:**
732
+ - Don't save things obvious from the code or standard framework behavior
733
+ - When updating an existing memory, read it first and merge — don't overwrite blindly
734
+ - Keep descriptions concise — the index is loaded every message
735
+ - One memory per logical topic (e.g. 'coding-style', 'project-alpha')
736
+ - Don't save temporary debugging notes or ephemeral task details
546
737
  `;
547
738
  const PROD_FRAMEWORK_PROMPT = `## Agent-Native Framework — Production Mode
548
739
 
@@ -594,19 +785,17 @@ ${FRAMEWORK_CORE}`;
594
785
  const DEFAULT_SYSTEM_PROMPT = PROD_FRAMEWORK_PROMPT;
595
786
  /**
596
787
  * Pre-load the agent's context: AGENTS.md (template instructions), the skills
597
- * index, and LEARNINGS.md (user notes). These all get appended to the system
598
- * prompt so the agent has everything it needs from the first turn — no tool
599
- * calls required to figure out "what is this app".
788
+ * index, shared LEARNINGS.md (team notes), and memory/MEMORY.md (personal
789
+ * structured memory index). These all get appended to the system prompt so
790
+ * the agent has everything it needs from the first turn.
600
791
  *
601
- * Three sources are layered:
792
+ * Four sources are layered:
602
793
  *
603
- * 1. `<template>` — AGENTS.md + skills index from the `virtual:agents-bundle`
604
- * module (inlined at build time by the Vite plugin, falls back to a
605
- * filesystem read from `process.cwd()` in dev). Canonical source for
606
- * "what is this app, what can it do, what skills are available".
607
- * 2. `<shared>` LEARNINGS.md from the SQL shared scope. Team-level notes.
608
- * 3. `<personal>` — LEARNINGS.md from the SQL personal scope. The current
609
- * user's own notes.
794
+ * 1. `<workspace>` — AGENTS.md from the enterprise workspace core.
795
+ * 2. `<template>` AGENTS.md + skills index from the Vite plugin bundle.
796
+ * 3. `<shared>` LEARNINGS.md from the SQL shared scope. Team-level notes.
797
+ * 4. `<personal>` memory/MEMORY.md from the SQL personal scope. The
798
+ * current user's structured memory index.
610
799
  *
611
800
  * Each source is read independently — no copying between them. Editing
612
801
  * AGENTS.md and restarting the server is all it takes; Vite HMR invalidates
@@ -615,10 +804,15 @@ const DEFAULT_SYSTEM_PROMPT = PROD_FRAMEWORK_PROMPT;
615
804
  async function loadResourcesForPrompt(owner) {
616
805
  await ensurePersonalDefaults(owner);
617
806
  const sections = [];
618
- // 1. Template AGENTS.md + skills index from the virtual bundle.
807
+ // 1. Workspace AGENTS.md + skills merged into the template bundle.
619
808
  try {
620
809
  const { loadAgentsBundle, generateSkillsPromptBlock } = await import("./agents-bundle.js");
621
810
  const bundle = await loadAgentsBundle();
811
+ // Workspace-core AGENTS.md (enterprise-wide instructions), if present.
812
+ if (bundle.workspaceAgentsMd && bundle.workspaceAgentsMd.trim()) {
813
+ sections.push(`<resource name="AGENTS.md" scope="workspace">\n${bundle.workspaceAgentsMd.trim()}\n</resource>`);
814
+ }
815
+ // 2. Template AGENTS.md.
622
816
  if (bundle.agentsMd.trim()) {
623
817
  sections.push(`<resource name="AGENTS.md" scope="template">\n${bundle.agentsMd.trim()}\n</resource>`);
624
818
  }
@@ -636,12 +830,12 @@ async function loadResourcesForPrompt(owner) {
636
830
  }
637
831
  }
638
832
  catch { }
639
- // 3. Personal SQL scope (skip if owner is the shared sentinel)
833
+ // 3. Personal memory index (skip if owner is the shared sentinel)
640
834
  if (owner !== SHARED_OWNER) {
641
835
  try {
642
- const personal = await resourceGetByPath(owner, "LEARNINGS.md");
643
- if (personal?.content?.trim()) {
644
- sections.push(`<resource name="LEARNINGS.md" scope="personal">\n${personal.content.trim()}\n</resource>`);
836
+ const memoryIndex = await resourceGetByPath(owner, "memory/MEMORY.md");
837
+ if (memoryIndex?.content?.trim()) {
838
+ sections.push(`<resource name="memory/MEMORY.md" scope="personal">\n${memoryIndex.content.trim()}\n</resource>`);
645
839
  }
646
840
  }
647
841
  catch { }
@@ -660,7 +854,7 @@ async function buildSchemaBlock(owner, hasRawDbTools) {
660
854
  try {
661
855
  return await loadSchemaPromptBlock({
662
856
  owner,
663
- orgId: process.env.AGENT_ORG_ID ?? null,
857
+ orgId: getRequestOrgId() ?? null,
664
858
  hasRawDbTools,
665
859
  });
666
860
  }
@@ -851,19 +1045,66 @@ export function createAgentChatPlugin(options) {
851
1045
  const canToggle = (env === "development" || env === "test") &&
852
1046
  process.env.AGENT_MODE !== "production";
853
1047
  const routePath = options?.path ?? "/_agent-native/agent-chat";
1048
+ // Initialize MCP client (connects to user-configured local MCP servers).
1049
+ // Graceful-degrade: any failure yields zero MCP tools and agent-chat keeps
1050
+ // working as before. No-op outside Node runtimes.
1051
+ let mcpConfig = loadMcpConfig();
1052
+ if (!mcpConfig) {
1053
+ mcpConfig = autoDetectMcpConfig();
1054
+ if (mcpConfig) {
1055
+ const detected = Object.keys(mcpConfig.servers).join(", ");
1056
+ console.log(`[mcp-client] auto-detected ${detected}, registering as MCP server — set AGENT_NATIVE_DISABLE_MCP_AUTODETECT=1 to opt out`);
1057
+ }
1058
+ else {
1059
+ console.log("[mcp-client] no mcp.config.json and no auto-detectable servers — skipping MCP tools");
1060
+ }
1061
+ }
1062
+ else if (mcpConfig.source) {
1063
+ console.log(`[mcp-client] loaded config from ${mcpConfig.source} (${Object.keys(mcpConfig.servers).length} server(s))`);
1064
+ }
1065
+ const mcpManager = new McpClientManager(mcpConfig);
1066
+ try {
1067
+ await mcpManager.start();
1068
+ }
1069
+ catch (err) {
1070
+ console.warn(`[mcp-client] start() failed: ${err?.message ?? err}. Continuing without MCP tools.`);
1071
+ }
1072
+ setGlobalMcpManager(mcpManager);
1073
+ const mcpActionEntries = mcpToolsToActionEntries(mcpManager);
1074
+ // Mount status route so tooling/onboarding can inspect MCP state.
1075
+ mountMcpStatusRoute(nitroApp, mcpManager);
1076
+ // Ensure we tear down child processes if the host shuts down cleanly.
1077
+ if (typeof process !== "undefined" &&
1078
+ typeof process.once === "function" &&
1079
+ !globalThis.__agentNativeMcpExitHooked) {
1080
+ globalThis.__agentNativeMcpExitHooked = true;
1081
+ const stop = () => {
1082
+ const mgr = getGlobalMcpManager();
1083
+ if (mgr)
1084
+ void mgr.stop();
1085
+ };
1086
+ process.once("exit", stop);
1087
+ process.once("SIGTERM", stop);
1088
+ process.once("SIGINT", stop);
1089
+ }
854
1090
  // Resolve actions — prefer `actions`, fall back to deprecated `scripts`
855
1091
  const rawActions = options?.actions ?? options?.scripts;
856
1092
  const templateScripts = typeof rawActions === "function"
857
1093
  ? await rawActions()
858
1094
  : (rawActions ?? {});
859
- // Resource, chat, and cross-agent scripts are available in both prod and dev modes
1095
+ // Resource, chat, docs, and cross-agent scripts are available in both prod and dev modes
860
1096
  const resourceScripts = await createResourceScriptEntries();
1097
+ const docsScripts = await createDocsScriptEntries();
861
1098
  const engineScripts = await createAgentEngineScriptEntries();
862
1099
  const chatScripts = {
863
1100
  ...(await createChatScriptEntries()),
864
1101
  ...engineScripts,
865
1102
  };
866
1103
  const callAgentScript = await createCallAgentScriptEntry(options?.appId);
1104
+ let _currentRequestOrigin = "http://localhost:3000";
1105
+ const browserTools = createBuilderBrowserTool({
1106
+ getOrigin: () => _currentRequestOrigin,
1107
+ });
867
1108
  // Auto-mount A2A protocol endpoints so every app is discoverable
868
1109
  // and callable by other agents via the standard protocol.
869
1110
  // In dev mode, include dev scripts (filesystem-discovered) so the A2A agent
@@ -1001,16 +1242,20 @@ export function createAgentChatPlugin(options) {
1001
1242
  const allScripts = canToggle
1002
1243
  ? {
1003
1244
  ...resourceScripts,
1245
+ ...docsScripts,
1004
1246
  ...chatScripts,
1005
1247
  ...callAgentScript,
1248
+ ...browserTools,
1006
1249
  ...devScriptsForA2A,
1007
1250
  }
1008
1251
  : {
1009
1252
  ...discoveredActions,
1010
1253
  ...templateScripts,
1011
1254
  ...resourceScripts,
1255
+ ...docsScripts,
1012
1256
  ...chatScripts,
1013
1257
  ...callAgentScript,
1258
+ ...browserTools,
1014
1259
  ...devScriptsForA2A,
1015
1260
  };
1016
1261
  const { mountA2A } = await import("../a2a/server.js");
@@ -1100,13 +1345,17 @@ export function createAgentChatPlugin(options) {
1100
1345
  const a2aActions = canToggle
1101
1346
  ? {
1102
1347
  ...resourceScripts,
1348
+ ...docsScripts,
1103
1349
  ...chatScripts,
1350
+ ...browserTools,
1104
1351
  ...devScriptsForA2A,
1105
1352
  }
1106
1353
  : {
1107
1354
  ...templateScripts,
1108
1355
  ...resourceScripts,
1356
+ ...docsScripts,
1109
1357
  ...chatScripts,
1358
+ ...browserTools,
1110
1359
  };
1111
1360
  const a2aTools = actionsToEngineTools(a2aActions);
1112
1361
  const a2aMessages = [
@@ -1192,12 +1441,14 @@ export function createAgentChatPlugin(options) {
1192
1441
  const mcpActions = canToggle
1193
1442
  ? {
1194
1443
  ...resourceScripts,
1444
+ ...docsScripts,
1195
1445
  ...chatScripts,
1196
1446
  ...devScriptsForA2A,
1197
1447
  }
1198
1448
  : {
1199
1449
  ...templateScripts,
1200
1450
  ...resourceScripts,
1451
+ ...docsScripts,
1201
1452
  ...chatScripts,
1202
1453
  };
1203
1454
  const mcpTools = actionsToEngineTools(mcpActions);
@@ -1322,12 +1573,14 @@ export function createAgentChatPlugin(options) {
1322
1573
  // Sub-agents spawned in dev mode also invoke template actions
1323
1574
  // via shell, so omit them from the native tool registry.
1324
1575
  ...resourceScripts,
1576
+ ...docsScripts,
1325
1577
  ...chatScripts,
1326
1578
  ...devScriptsForA2A,
1327
1579
  }
1328
1580
  : {
1329
1581
  ...templateScripts,
1330
1582
  ...resourceScripts,
1583
+ ...docsScripts,
1331
1584
  ...chatScripts,
1332
1585
  },
1333
1586
  getEngine: () => createAnthropicEngine({
@@ -1352,10 +1605,13 @@ export function createAgentChatPlugin(options) {
1352
1605
  const prodActions = {
1353
1606
  ...templateScripts,
1354
1607
  ...resourceScripts,
1608
+ ...docsScripts,
1355
1609
  ...chatScripts,
1356
1610
  ...callAgentScript,
1357
1611
  ...teamTools,
1358
1612
  ...jobTools,
1613
+ ...browserTools,
1614
+ ...mcpActionEntries,
1359
1615
  };
1360
1616
  // Always build the production handler (includes resource tools + call-agent + team tools)
1361
1617
  // In production mode (!canToggle), enable usage tracking and limits
@@ -1363,6 +1619,7 @@ export function createAgentChatPlugin(options) {
1363
1619
  const prodHandler = createProductionAgentHandler({
1364
1620
  actions: prodActions,
1365
1621
  systemPrompt: async (event) => {
1622
+ _currentRequestOrigin = getOrigin(event);
1366
1623
  const owner = await getOwnerFromEvent(event);
1367
1624
  _currentRunOwner = owner;
1368
1625
  const resources = await loadResourcesForPrompt(owner);
@@ -1398,15 +1655,19 @@ export function createAgentChatPlugin(options) {
1398
1655
  // listed in the dev system prompt's "Available Actions" section.
1399
1656
  const devActions = {
1400
1657
  ...resourceScripts,
1658
+ ...docsScripts,
1401
1659
  ...chatScripts,
1402
1660
  ...callAgentScript,
1403
1661
  ...teamTools,
1404
1662
  ...jobTools,
1663
+ ...browserTools,
1664
+ ...mcpActionEntries,
1405
1665
  ...(await createDevScriptRegistry()),
1406
1666
  };
1407
1667
  devHandler = createProductionAgentHandler({
1408
1668
  actions: devActions,
1409
1669
  systemPrompt: async (event) => {
1670
+ _currentRequestOrigin = getOrigin(event);
1410
1671
  const owner = await getOwnerFromEvent(event);
1411
1672
  _currentRunOwner = owner;
1412
1673
  const resources = await loadResourcesForPrompt(owner);
@@ -1750,7 +2011,29 @@ export function createAgentChatPlugin(options) {
1750
2011
  }
1751
2012
  })());
1752
2013
  }
1753
- // 4. Peer agent discovery (network call — often slowest)
2014
+ // 4. Custom workspace agents
2015
+ sources.push((async () => {
2016
+ try {
2017
+ const owner = await getOwnerFromEvent(event);
2018
+ const { listAccessibleCustomAgents } = await import("../resources/agents.js");
2019
+ const agents = await listAccessibleCustomAgents(owner);
2020
+ flush(agents.map((agent) => ({
2021
+ id: `custom-agent:${agent.id}`,
2022
+ label: agent.name,
2023
+ description: agent.description || agent.path,
2024
+ icon: "agent",
2025
+ source: "agent:custom",
2026
+ refType: "custom-agent",
2027
+ refPath: agent.path,
2028
+ refId: agent.id,
2029
+ section: "Agents",
2030
+ })));
2031
+ }
2032
+ catch (e) {
2033
+ console.error("[agent-native] Custom agent discovery failed:", e);
2034
+ }
2035
+ })());
2036
+ // 5. Peer agent discovery (network call — often slowest)
1754
2037
  sources.push((async () => {
1755
2038
  try {
1756
2039
  const agents = await discoverAgents(options?.appId);
@@ -1763,7 +2046,7 @@ export function createAgentChatPlugin(options) {
1763
2046
  refType: "agent",
1764
2047
  refPath: agent.url,
1765
2048
  refId: agent.id,
1766
- section: "Agents",
2049
+ section: "Connected Agents",
1767
2050
  })));
1768
2051
  }
1769
2052
  catch (e) {
@@ -1973,34 +2256,34 @@ export function createAgentChatPlugin(options) {
1973
2256
  setResponseStatus(event, 404);
1974
2257
  return { error: "Not found" };
1975
2258
  }
1976
- // Set AGENT_USER_EMAIL so scripts resolve the same owner as the session.
1977
- // Without this, scripts default to "local@localhost" and miss resources
1978
- // created by users who authenticated via OAuth (e.g., Gmail).
2259
+ // Resolve per-request auth context
1979
2260
  const owner = await getOwnerFromEvent(event);
1980
- process.env.AGENT_USER_EMAIL = owner;
1981
- // Set AGENT_ORG_ID so db-query/db-exec scope by org_id when applicable.
1982
- // Priority: explicit resolveOrgId callback > session.orgId from Better Auth
1983
- let resolvedOrgId = null;
2261
+ // Resolve org ID: explicit callback > session.orgId from Better Auth
2262
+ let resolvedOrgId;
1984
2263
  if (options?.resolveOrgId) {
1985
- resolvedOrgId = await options.resolveOrgId(event);
2264
+ resolvedOrgId = (await options.resolveOrgId(event)) ?? undefined;
1986
2265
  }
1987
2266
  else {
1988
2267
  try {
1989
2268
  const session = await getSession(event);
1990
- resolvedOrgId = session?.orgId ?? null;
2269
+ resolvedOrgId = session?.orgId ?? undefined;
1991
2270
  }
1992
2271
  catch {
1993
2272
  // Session not available
1994
2273
  }
1995
2274
  }
2275
+ // Also set process.env for backwards compat (CLI scripts, legacy readers)
2276
+ process.env.AGENT_USER_EMAIL = owner;
1996
2277
  if (resolvedOrgId) {
1997
2278
  process.env.AGENT_ORG_ID = resolvedOrgId;
1998
2279
  }
1999
2280
  else {
2000
2281
  delete process.env.AGENT_ORG_ID;
2001
2282
  }
2002
- const handler = currentDevMode && devHandler ? devHandler : prodHandler;
2003
- return handler(event);
2283
+ return runWithRequestContext({ userEmail: owner, orgId: resolvedOrgId }, () => {
2284
+ const handler = currentDevMode && devHandler ? devHandler : prodHandler;
2285
+ return handler(event);
2286
+ });
2004
2287
  }));
2005
2288
  // ─── Recurring Jobs Scheduler ──────────────────────────────────────
2006
2289
  // Poll every 60 seconds for due recurring jobs and execute them.
@@ -2012,6 +2295,7 @@ export function createAgentChatPlugin(options) {
2012
2295
  getActions: () => ({
2013
2296
  ...templateScripts,
2014
2297
  ...resourceScripts,
2298
+ ...docsScripts,
2015
2299
  ...chatScripts,
2016
2300
  ...jobTools,
2017
2301
  }),
@@ -2045,4 +2329,35 @@ export function createAgentChatPlugin(options) {
2045
2329
  * In production, provides only the default system prompt.
2046
2330
  */
2047
2331
  export const defaultAgentChatPlugin = createAgentChatPlugin();
2332
+ // ---------------------------------------------------------------------------
2333
+ // MCP client glue — a shared manager reference + a /_agent-native/mcp/status
2334
+ // route so onboarding / settings UIs can see which MCP servers are live.
2335
+ // ---------------------------------------------------------------------------
2336
+ let _globalMcpManager = null;
2337
+ function setGlobalMcpManager(manager) {
2338
+ _globalMcpManager = manager;
2339
+ }
2340
+ /** Internal: access the current process's MCP client manager, if any. */
2341
+ export function getGlobalMcpManager() {
2342
+ return _globalMcpManager;
2343
+ }
2344
+ function mountMcpStatusRoute(nitroApp, manager) {
2345
+ // Idempotent — agent-chat-plugin can be invoked once per process; guard anyway.
2346
+ if (globalThis.__agentNativeMcpStatusMounted)
2347
+ return;
2348
+ globalThis.__agentNativeMcpStatusMounted = true;
2349
+ try {
2350
+ getH3App(nitroApp).use("/_agent-native/mcp/status", defineEventHandler(async (event) => {
2351
+ if (getMethod(event) !== "GET") {
2352
+ setResponseStatus(event, 405);
2353
+ return { error: "Method not allowed" };
2354
+ }
2355
+ setResponseHeader(event, "Content-Type", "application/json");
2356
+ return manager.getStatus();
2357
+ }));
2358
+ }
2359
+ catch (err) {
2360
+ console.warn(`[mcp-client] Failed to mount /_agent-native/mcp/status: ${err?.message ?? err}`);
2361
+ }
2362
+ }
2048
2363
  //# sourceMappingURL=agent-chat-plugin.js.map