@agent-native/core 0.15.12 → 0.16.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 (411) hide show
  1. package/README.md +37 -0
  2. package/dist/agent/app-model-defaults.d.ts +37 -0
  3. package/dist/agent/app-model-defaults.d.ts.map +1 -0
  4. package/dist/agent/app-model-defaults.js +136 -0
  5. package/dist/agent/app-model-defaults.js.map +1 -0
  6. package/dist/agent/engine/registry.d.ts +12 -7
  7. package/dist/agent/engine/registry.d.ts.map +1 -1
  8. package/dist/agent/engine/registry.js +28 -8
  9. package/dist/agent/engine/registry.js.map +1 -1
  10. package/dist/agent/production-agent.d.ts +2 -0
  11. package/dist/agent/production-agent.d.ts.map +1 -1
  12. package/dist/agent/production-agent.js +3 -1
  13. package/dist/agent/production-agent.js.map +1 -1
  14. package/dist/browser-sessions/actions.d.ts +7 -0
  15. package/dist/browser-sessions/actions.d.ts.map +1 -0
  16. package/dist/browser-sessions/actions.js +223 -0
  17. package/dist/browser-sessions/actions.js.map +1 -0
  18. package/dist/browser-sessions/routes.d.ts +7 -0
  19. package/dist/browser-sessions/routes.d.ts.map +1 -0
  20. package/dist/browser-sessions/routes.js +159 -0
  21. package/dist/browser-sessions/routes.js.map +1 -0
  22. package/dist/browser-sessions/store.d.ts +33 -0
  23. package/dist/browser-sessions/store.d.ts.map +1 -0
  24. package/dist/browser-sessions/store.js +506 -0
  25. package/dist/browser-sessions/store.js.map +1 -0
  26. package/dist/browser-sessions/types.d.ts +68 -0
  27. package/dist/browser-sessions/types.d.ts.map +1 -0
  28. package/dist/browser-sessions/types.js +2 -0
  29. package/dist/browser-sessions/types.js.map +1 -0
  30. package/dist/cli/code-agent-commands.d.ts +36 -0
  31. package/dist/cli/code-agent-commands.d.ts.map +1 -0
  32. package/dist/cli/code-agent-commands.js +192 -0
  33. package/dist/cli/code-agent-commands.js.map +1 -0
  34. package/dist/cli/code-agent-connector.d.ts +17 -0
  35. package/dist/cli/code-agent-connector.d.ts.map +1 -0
  36. package/dist/cli/code-agent-connector.js +724 -0
  37. package/dist/cli/code-agent-connector.js.map +1 -0
  38. package/dist/cli/code-agent-executor.d.ts +31 -0
  39. package/dist/cli/code-agent-executor.d.ts.map +1 -0
  40. package/dist/cli/code-agent-executor.js +921 -0
  41. package/dist/cli/code-agent-executor.js.map +1 -0
  42. package/dist/cli/code-agent-runs.d.ts +102 -0
  43. package/dist/cli/code-agent-runs.d.ts.map +1 -0
  44. package/dist/cli/code-agent-runs.js +277 -0
  45. package/dist/cli/code-agent-runs.js.map +1 -0
  46. package/dist/cli/code.d.ts +66 -0
  47. package/dist/cli/code.d.ts.map +1 -0
  48. package/dist/cli/code.js +1306 -0
  49. package/dist/cli/code.js.map +1 -0
  50. package/dist/cli/create.d.ts +2 -1
  51. package/dist/cli/create.d.ts.map +1 -1
  52. package/dist/cli/create.js +11 -1
  53. package/dist/cli/create.js.map +1 -1
  54. package/dist/cli/index.js +26 -1
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/cli/migrate.d.ts +27 -0
  57. package/dist/cli/migrate.d.ts.map +1 -1
  58. package/dist/cli/migrate.js +1328 -20
  59. package/dist/cli/migrate.js.map +1 -1
  60. package/dist/cli/templates-meta.d.ts.map +1 -1
  61. package/dist/cli/templates-meta.js +27 -3
  62. package/dist/cli/templates-meta.js.map +1 -1
  63. package/dist/cli/workspacify.d.ts +2 -0
  64. package/dist/cli/workspacify.d.ts.map +1 -1
  65. package/dist/cli/workspacify.js +2 -1
  66. package/dist/cli/workspacify.js.map +1 -1
  67. package/dist/client/AgentNative.d.ts +32 -0
  68. package/dist/client/AgentNative.d.ts.map +1 -0
  69. package/dist/client/AgentNative.js +79 -0
  70. package/dist/client/AgentNative.js.map +1 -0
  71. package/dist/client/AgentNativeEmbedded.d.ts +47 -0
  72. package/dist/client/AgentNativeEmbedded.d.ts.map +1 -0
  73. package/dist/client/AgentNativeEmbedded.js +148 -0
  74. package/dist/client/AgentNativeEmbedded.js.map +1 -0
  75. package/dist/client/AgentNativeFrame.d.ts +25 -0
  76. package/dist/client/AgentNativeFrame.d.ts.map +1 -0
  77. package/dist/client/AgentNativeFrame.js +68 -0
  78. package/dist/client/AgentNativeFrame.js.map +1 -0
  79. package/dist/client/AgentPanel.d.ts +19 -2
  80. package/dist/client/AgentPanel.d.ts.map +1 -1
  81. package/dist/client/AgentPanel.js +15 -4
  82. package/dist/client/AgentPanel.js.map +1 -1
  83. package/dist/client/AssistantChat.d.ts +1 -1
  84. package/dist/client/AssistantChat.d.ts.map +1 -1
  85. package/dist/client/AssistantChat.js +79 -48
  86. package/dist/client/AssistantChat.js.map +1 -1
  87. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  88. package/dist/client/MultiTabAssistantChat.js +2 -1
  89. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  90. package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
  91. package/dist/client/NewWorkspaceAppFlow.js +3 -2
  92. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  93. package/dist/client/browser-session-bridge.d.ts +44 -0
  94. package/dist/client/browser-session-bridge.d.ts.map +1 -0
  95. package/dist/client/browser-session-bridge.js +339 -0
  96. package/dist/client/browser-session-bridge.js.map +1 -0
  97. package/dist/client/client-action.d.ts +7 -0
  98. package/dist/client/client-action.d.ts.map +1 -0
  99. package/dist/client/client-action.js +4 -0
  100. package/dist/client/client-action.js.map +1 -0
  101. package/dist/client/components/ui/tooltip.d.ts.map +1 -1
  102. package/dist/client/components/ui/tooltip.js +1 -1
  103. package/dist/client/components/ui/tooltip.js.map +1 -1
  104. package/dist/client/composer/AgentComposerFrame.d.ts +17 -0
  105. package/dist/client/composer/AgentComposerFrame.d.ts.map +1 -0
  106. package/dist/client/composer/AgentComposerFrame.js +14 -0
  107. package/dist/client/composer/AgentComposerFrame.js.map +1 -0
  108. package/dist/client/composer/MentionPopover.d.ts.map +1 -1
  109. package/dist/client/composer/MentionPopover.js +2 -2
  110. package/dist/client/composer/MentionPopover.js.map +1 -1
  111. package/dist/client/composer/PromptComposer.d.ts +35 -2
  112. package/dist/client/composer/PromptComposer.d.ts.map +1 -1
  113. package/dist/client/composer/PromptComposer.js +31 -17
  114. package/dist/client/composer/PromptComposer.js.map +1 -1
  115. package/dist/client/composer/TiptapComposer.d.ts +20 -2
  116. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  117. package/dist/client/composer/TiptapComposer.js +112 -22
  118. package/dist/client/composer/TiptapComposer.js.map +1 -1
  119. package/dist/client/composer/index.d.ts +3 -2
  120. package/dist/client/composer/index.d.ts.map +1 -1
  121. package/dist/client/composer/index.js +1 -0
  122. package/dist/client/composer/index.js.map +1 -1
  123. package/dist/client/composer/types.d.ts +1 -0
  124. package/dist/client/composer/types.d.ts.map +1 -1
  125. package/dist/client/composer/types.js.map +1 -1
  126. package/dist/client/extensions/AgentNativeExtensionFrame.d.ts +58 -0
  127. package/dist/client/extensions/AgentNativeExtensionFrame.d.ts.map +1 -0
  128. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts +2 -0
  129. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts.map +1 -0
  130. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js +110 -0
  131. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js.map +1 -0
  132. package/dist/client/extensions/AgentNativeExtensionFrame.js +354 -0
  133. package/dist/client/extensions/AgentNativeExtensionFrame.js.map +1 -0
  134. package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts +2 -0
  135. package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts.map +1 -0
  136. package/dist/client/extensions/AgentNativeExtensionFrame.spec.js +68 -0
  137. package/dist/client/extensions/AgentNativeExtensionFrame.spec.js.map +1 -0
  138. package/dist/client/extensions/agent-native-extension-runtime.d.ts +69 -0
  139. package/dist/client/extensions/agent-native-extension-runtime.d.ts.map +1 -0
  140. package/dist/client/extensions/agent-native-extension-runtime.js +348 -0
  141. package/dist/client/extensions/agent-native-extension-runtime.js.map +1 -0
  142. package/dist/client/extensions/index.d.ts +2 -0
  143. package/dist/client/extensions/index.d.ts.map +1 -1
  144. package/dist/client/extensions/index.js +2 -0
  145. package/dist/client/extensions/index.js.map +1 -1
  146. package/dist/client/extensions/portable-extension.d.ts +86 -0
  147. package/dist/client/extensions/portable-extension.d.ts.map +1 -0
  148. package/dist/client/extensions/portable-extension.js +480 -0
  149. package/dist/client/extensions/portable-extension.js.map +1 -0
  150. package/dist/client/host-bridge.d.ts +266 -0
  151. package/dist/client/host-bridge.d.ts.map +1 -0
  152. package/dist/client/host-bridge.js +745 -0
  153. package/dist/client/host-bridge.js.map +1 -0
  154. package/dist/client/host-tools.d.ts +40 -0
  155. package/dist/client/host-tools.d.ts.map +1 -0
  156. package/dist/client/host-tools.js +94 -0
  157. package/dist/client/host-tools.js.map +1 -0
  158. package/dist/client/index.d.ts +13 -2
  159. package/dist/client/index.d.ts.map +1 -1
  160. package/dist/client/index.js +11 -2
  161. package/dist/client/index.js.map +1 -1
  162. package/dist/client/resources/BuiltinCapabilityDetail.d.ts +10 -0
  163. package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -0
  164. package/dist/client/resources/BuiltinCapabilityDetail.js +51 -0
  165. package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -0
  166. package/dist/client/resources/ResourceEditor.d.ts +3 -1
  167. package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
  168. package/dist/client/resources/ResourceEditor.js +40 -17
  169. package/dist/client/resources/ResourceEditor.js.map +1 -1
  170. package/dist/client/resources/ResourceTree.d.ts.map +1 -1
  171. package/dist/client/resources/ResourceTree.js +23 -2
  172. package/dist/client/resources/ResourceTree.js.map +1 -1
  173. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  174. package/dist/client/resources/ResourcesPanel.js +77 -17
  175. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  176. package/dist/client/resources/index.d.ts +1 -0
  177. package/dist/client/resources/index.d.ts.map +1 -1
  178. package/dist/client/resources/index.js +1 -0
  179. package/dist/client/resources/index.js.map +1 -1
  180. package/dist/client/resources/use-builtin-capabilities.d.ts +62 -0
  181. package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -0
  182. package/dist/client/resources/use-builtin-capabilities.js +54 -0
  183. package/dist/client/resources/use-builtin-capabilities.js.map +1 -0
  184. package/dist/client/resources/use-resources.d.ts +30 -2
  185. package/dist/client/resources/use-resources.d.ts.map +1 -1
  186. package/dist/client/resources/use-resources.js +42 -1
  187. package/dist/client/resources/use-resources.js.map +1 -1
  188. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  189. package/dist/client/settings/SettingsPanel.js +151 -2
  190. package/dist/client/settings/SettingsPanel.js.map +1 -1
  191. package/dist/client/use-chat-models.d.ts.map +1 -1
  192. package/dist/client/use-chat-models.js +20 -0
  193. package/dist/client/use-chat-models.js.map +1 -1
  194. package/dist/client/use-chat-threads.d.ts.map +1 -1
  195. package/dist/client/use-chat-threads.js +46 -2
  196. package/dist/client/use-chat-threads.js.map +1 -1
  197. package/dist/client/use-chat-threads.spec.js +77 -0
  198. package/dist/client/use-chat-threads.spec.js.map +1 -1
  199. package/dist/code-agents/index.d.ts +4 -0
  200. package/dist/code-agents/index.d.ts.map +1 -0
  201. package/dist/code-agents/index.js +4 -0
  202. package/dist/code-agents/index.js.map +1 -0
  203. package/dist/connections/catalog.d.ts +134 -0
  204. package/dist/connections/catalog.d.ts.map +1 -0
  205. package/dist/connections/catalog.js +180 -0
  206. package/dist/connections/catalog.js.map +1 -0
  207. package/dist/connections/index.d.ts +2 -0
  208. package/dist/connections/index.d.ts.map +1 -0
  209. package/dist/connections/index.js +2 -0
  210. package/dist/connections/index.js.map +1 -0
  211. package/dist/extensions/change-marker.d.ts +10 -0
  212. package/dist/extensions/change-marker.d.ts.map +1 -0
  213. package/dist/extensions/change-marker.js +42 -0
  214. package/dist/extensions/change-marker.js.map +1 -0
  215. package/dist/extensions/routes.d.ts.map +1 -1
  216. package/dist/extensions/routes.js +1 -7
  217. package/dist/extensions/routes.js.map +1 -1
  218. package/dist/extensions/schema.d.ts +1 -0
  219. package/dist/extensions/schema.d.ts.map +1 -1
  220. package/dist/extensions/schema.js +1 -0
  221. package/dist/extensions/schema.js.map +1 -1
  222. package/dist/extensions/slots/routes.js +1 -1
  223. package/dist/extensions/slots/routes.js.map +1 -1
  224. package/dist/extensions/store.d.ts +3 -0
  225. package/dist/extensions/store.d.ts.map +1 -1
  226. package/dist/extensions/store.js +112 -4
  227. package/dist/extensions/store.js.map +1 -1
  228. package/dist/index.d.ts +4 -1
  229. package/dist/index.d.ts.map +1 -1
  230. package/dist/index.js +6 -1
  231. package/dist/index.js.map +1 -1
  232. package/dist/integrations/adapters/telegram.d.ts.map +1 -1
  233. package/dist/integrations/adapters/telegram.js +1 -0
  234. package/dist/integrations/adapters/telegram.js.map +1 -1
  235. package/dist/integrations/index.d.ts +5 -1
  236. package/dist/integrations/index.d.ts.map +1 -1
  237. package/dist/integrations/index.js +4 -1
  238. package/dist/integrations/index.js.map +1 -1
  239. package/dist/integrations/plugin.d.ts +8 -0
  240. package/dist/integrations/plugin.d.ts.map +1 -1
  241. package/dist/integrations/plugin.js +760 -32
  242. package/dist/integrations/plugin.js.map +1 -1
  243. package/dist/integrations/remote-commands-store.d.ts +36 -0
  244. package/dist/integrations/remote-commands-store.d.ts.map +1 -0
  245. package/dist/integrations/remote-commands-store.js +273 -0
  246. package/dist/integrations/remote-commands-store.js.map +1 -0
  247. package/dist/integrations/remote-devices-store.d.ts +43 -0
  248. package/dist/integrations/remote-devices-store.d.ts.map +1 -0
  249. package/dist/integrations/remote-devices-store.js +315 -0
  250. package/dist/integrations/remote-devices-store.js.map +1 -0
  251. package/dist/integrations/remote-push-store.d.ts +37 -0
  252. package/dist/integrations/remote-push-store.d.ts.map +1 -0
  253. package/dist/integrations/remote-push-store.js +299 -0
  254. package/dist/integrations/remote-push-store.js.map +1 -0
  255. package/dist/integrations/remote-retry-job.d.ts +7 -0
  256. package/dist/integrations/remote-retry-job.d.ts.map +1 -0
  257. package/dist/integrations/remote-retry-job.js +45 -0
  258. package/dist/integrations/remote-retry-job.js.map +1 -0
  259. package/dist/integrations/remote-run-events-store.d.ts +18 -0
  260. package/dist/integrations/remote-run-events-store.d.ts.map +1 -0
  261. package/dist/integrations/remote-run-events-store.js +82 -0
  262. package/dist/integrations/remote-run-events-store.js.map +1 -0
  263. package/dist/integrations/remote-types.d.ts +101 -0
  264. package/dist/integrations/remote-types.d.ts.map +1 -0
  265. package/dist/integrations/remote-types.js +2 -0
  266. package/dist/integrations/remote-types.js.map +1 -0
  267. package/dist/integrations/webhook-handler.d.ts +2 -0
  268. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  269. package/dist/integrations/webhook-handler.js +4 -1
  270. package/dist/integrations/webhook-handler.js.map +1 -1
  271. package/dist/jobs/scheduler.d.ts +4 -2
  272. package/dist/jobs/scheduler.d.ts.map +1 -1
  273. package/dist/jobs/scheduler.js +9 -3
  274. package/dist/jobs/scheduler.js.map +1 -1
  275. package/dist/mcp-client/builtin-capabilities.d.ts +20 -0
  276. package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -0
  277. package/dist/mcp-client/builtin-capabilities.js +75 -0
  278. package/dist/mcp-client/builtin-capabilities.js.map +1 -0
  279. package/dist/mcp-client/builtin-store.d.ts +10 -0
  280. package/dist/mcp-client/builtin-store.d.ts.map +1 -0
  281. package/dist/mcp-client/builtin-store.js +55 -0
  282. package/dist/mcp-client/builtin-store.js.map +1 -0
  283. package/dist/mcp-client/index.d.ts +3 -1
  284. package/dist/mcp-client/index.d.ts.map +1 -1
  285. package/dist/mcp-client/index.js +3 -1
  286. package/dist/mcp-client/index.js.map +1 -1
  287. package/dist/mcp-client/routes.d.ts +28 -0
  288. package/dist/mcp-client/routes.d.ts.map +1 -1
  289. package/dist/mcp-client/routes.js +195 -1
  290. package/dist/mcp-client/routes.js.map +1 -1
  291. package/dist/org/context.d.ts.map +1 -1
  292. package/dist/org/context.js +34 -0
  293. package/dist/org/context.js.map +1 -1
  294. package/dist/resources/handlers.d.ts +4 -0
  295. package/dist/resources/handlers.d.ts.map +1 -1
  296. package/dist/resources/handlers.js +46 -7
  297. package/dist/resources/handlers.js.map +1 -1
  298. package/dist/resources/script-helpers.d.ts +8 -1
  299. package/dist/resources/script-helpers.d.ts.map +1 -1
  300. package/dist/resources/script-helpers.js +18 -8
  301. package/dist/resources/script-helpers.js.map +1 -1
  302. package/dist/resources/store.d.ts +19 -0
  303. package/dist/resources/store.d.ts.map +1 -1
  304. package/dist/resources/store.js +86 -3
  305. package/dist/resources/store.js.map +1 -1
  306. package/dist/scripts/agent-engines/list-agent-engines.d.ts +1 -1
  307. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  308. package/dist/scripts/agent-engines/list-agent-engines.js +18 -7
  309. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  310. package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
  311. package/dist/scripts/agent-engines/manage-agent-engine.js +100 -7
  312. package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
  313. package/dist/scripts/resources/delete.d.ts.map +1 -1
  314. package/dist/scripts/resources/delete.js +4 -1
  315. package/dist/scripts/resources/delete.js.map +1 -1
  316. package/dist/scripts/resources/effective.d.ts +11 -0
  317. package/dist/scripts/resources/effective.d.ts.map +1 -0
  318. package/dist/scripts/resources/effective.js +54 -0
  319. package/dist/scripts/resources/effective.js.map +1 -0
  320. package/dist/scripts/resources/index.d.ts.map +1 -1
  321. package/dist/scripts/resources/index.js +1 -0
  322. package/dist/scripts/resources/index.js.map +1 -1
  323. package/dist/scripts/resources/list.d.ts +1 -1
  324. package/dist/scripts/resources/list.d.ts.map +1 -1
  325. package/dist/scripts/resources/list.js +17 -5
  326. package/dist/scripts/resources/list.js.map +1 -1
  327. package/dist/scripts/resources/read.d.ts +1 -1
  328. package/dist/scripts/resources/read.d.ts.map +1 -1
  329. package/dist/scripts/resources/read.js +20 -5
  330. package/dist/scripts/resources/read.js.map +1 -1
  331. package/dist/scripts/resources/write.d.ts.map +1 -1
  332. package/dist/scripts/resources/write.js +4 -1
  333. package/dist/scripts/resources/write.js.map +1 -1
  334. package/dist/scripts/runner.d.ts +11 -1
  335. package/dist/scripts/runner.d.ts.map +1 -1
  336. package/dist/scripts/runner.js +75 -27
  337. package/dist/scripts/runner.js.map +1 -1
  338. package/dist/server/action-discovery.d.ts.map +1 -1
  339. package/dist/server/action-discovery.js +5 -0
  340. package/dist/server/action-discovery.js.map +1 -1
  341. package/dist/server/agent-chat-plugin.d.ts +24 -0
  342. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  343. package/dist/server/agent-chat-plugin.js +608 -54
  344. package/dist/server/agent-chat-plugin.js.map +1 -1
  345. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  346. package/dist/server/core-routes-plugin.js +2 -0
  347. package/dist/server/core-routes-plugin.js.map +1 -1
  348. package/dist/server/embedded.d.ts +72 -0
  349. package/dist/server/embedded.d.ts.map +1 -0
  350. package/dist/server/embedded.js +119 -0
  351. package/dist/server/embedded.js.map +1 -0
  352. package/dist/server/index.d.ts +8 -1
  353. package/dist/server/index.d.ts.map +1 -1
  354. package/dist/server/index.js +7 -1
  355. package/dist/server/index.js.map +1 -1
  356. package/dist/server/poll.d.ts.map +1 -1
  357. package/dist/server/poll.js +184 -13
  358. package/dist/server/poll.js.map +1 -1
  359. package/dist/server/resources-plugin.d.ts.map +1 -1
  360. package/dist/server/resources-plugin.js +11 -2
  361. package/dist/server/resources-plugin.js.map +1 -1
  362. package/dist/sharing/actions/extension-change.d.ts +4 -0
  363. package/dist/sharing/actions/extension-change.d.ts.map +1 -0
  364. package/dist/sharing/actions/extension-change.js +13 -0
  365. package/dist/sharing/actions/extension-change.js.map +1 -0
  366. package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
  367. package/dist/sharing/actions/set-resource-visibility.js +3 -0
  368. package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
  369. package/dist/sharing/actions/share-resource.d.ts.map +1 -1
  370. package/dist/sharing/actions/share-resource.js +4 -0
  371. package/dist/sharing/actions/share-resource.js.map +1 -1
  372. package/dist/sharing/actions/unshare-resource.d.ts.map +1 -1
  373. package/dist/sharing/actions/unshare-resource.js +3 -0
  374. package/dist/sharing/actions/unshare-resource.js.map +1 -1
  375. package/dist/templates/default/AGENTS.md +3 -3
  376. package/dist/templates/workspace-core/AGENTS.md +7 -0
  377. package/dist/templates/workspace-root/AGENTS.md +7 -0
  378. package/dist/templates/workspace-root/README.md +25 -0
  379. package/dist/triggers/dispatcher.d.ts +3 -1
  380. package/dist/triggers/dispatcher.d.ts.map +1 -1
  381. package/dist/triggers/dispatcher.js +9 -3
  382. package/dist/triggers/dispatcher.js.map +1 -1
  383. package/dist/workspace-connections/index.d.ts +2 -0
  384. package/dist/workspace-connections/index.d.ts.map +1 -0
  385. package/dist/workspace-connections/index.js +2 -0
  386. package/dist/workspace-connections/index.js.map +1 -0
  387. package/dist/workspace-connections/store.d.ts +229 -0
  388. package/dist/workspace-connections/store.d.ts.map +1 -0
  389. package/dist/workspace-connections/store.js +938 -0
  390. package/dist/workspace-connections/store.js.map +1 -0
  391. package/docs/content/agent-teams.md +6 -0
  392. package/docs/content/cloneable-saas.md +1 -0
  393. package/docs/content/code-agents-ui.md +261 -0
  394. package/docs/content/dispatch.md +40 -3
  395. package/docs/content/embedding-sdk.md +459 -0
  396. package/docs/content/faq.md +1 -0
  397. package/docs/content/getting-started.md +1 -0
  398. package/docs/content/mcp-clients.md +41 -3
  399. package/docs/content/migration-workbench.md +237 -54
  400. package/docs/content/multi-app-workspace.md +41 -0
  401. package/docs/content/multi-tenancy.md +1 -1
  402. package/docs/content/template-brain.md +418 -0
  403. package/docs/content/template-dispatch.md +30 -0
  404. package/docs/content/workspace-connections.md +509 -0
  405. package/docs/content/workspace-management.md +12 -12
  406. package/docs/content/workspace.md +180 -40
  407. package/package.json +7 -2
  408. package/src/templates/default/AGENTS.md +3 -3
  409. package/src/templates/workspace-core/AGENTS.md +7 -0
  410. package/src/templates/workspace-root/AGENTS.md +7 -0
  411. package/src/templates/workspace-root/README.md +25 -0
@@ -3,10 +3,11 @@ import { getSetting, putSetting } from "../settings/store.js";
3
3
  import { getH3App, markDefaultPluginProvided, trackPluginInit, } from "./framework-request-handler.js";
4
4
  import { createProductionAgentHandler, actionsToEngineTools, getActiveRunForThreadAsync, abortRun, subscribeToRun, } from "../agent/production-agent.js";
5
5
  import { runAgentLoopDirectWithSoftTimeout } from "../agent/run-loop-with-resume.js";
6
- import { resolveEngine, createAnthropicEngine, getStoredModelForEngine, } from "../agent/engine/index.js";
6
+ import { resolveEngine, createAnthropicEngine, getStoredModelForEngine, getAgentEngineEntry, isStoredEngineUsableForRequest, listAgentEngines, registerBuiltinEngines, } from "../agent/engine/index.js";
7
+ import { canUpdateAgentAppModelDefaultSettings, normalizeAgentAppModelDefaultAppId, readAgentAppModelDefaultSettings, resetAgentAppModelDefaultSettings, writeAgentAppModelDefaultSettings, } from "../agent/app-model-defaults.js";
7
8
  import { DEFAULT_ANTHROPIC_MODEL } from "../agent/default-model.js";
8
9
  import { attachToolSearch } from "../agent/tool-search.js";
9
- import { McpClientManager, loadMcpConfig, autoDetectMcpConfig, mcpToolsToActionEntries, syncMcpActionEntries, mountMcpServersRoutes, mountMcpHubRoutes, buildMergedConfig, getHubStatus, isHubServeEnabled, } from "../mcp-client/index.js";
10
+ import { McpClientManager, loadMcpConfig, autoDetectMcpConfig, mcpToolsToActionEntries, syncMcpActionEntries, mountMcpServersRoutes, mountMcpHubRoutes, buildMergedConfig, setBuiltinMcpCapabilityEnabled, getHubStatus, isHubServeEnabled, } from "../mcp-client/index.js";
10
11
  import { discoverAgents } from "./agent-discovery.js";
11
12
  import { loadSchemaPromptBlock } from "./schema-prompt.js";
12
13
  import { buildAssistantMessage, buildUserMessage, extractThreadMeta, mergeThreadDataForClientSave, upsertAssistantMessage, upsertUserMessage, } from "../agent/thread-data-builder.js";
@@ -14,7 +15,7 @@ import { createError, defineEventHandler, setResponseStatus, setResponseHeader,
14
15
  import { getSession } from "./auth.js";
15
16
  import { getOrigin } from "./google-oauth.js";
16
17
  import { createThread, forkThread, getThread, listThreads, searchThreads, setThreadScope, updateThreadData, withThreadDataLock, deleteThread, setThreadQueuedMessages, } from "../chat-threads/store.js";
17
- import { resourceList, resourceListAccessible, resourceGet, resourceGetByPath, ensurePersonalDefaults, SHARED_OWNER, } from "../resources/store.js";
18
+ import { resourceList, resourceListAccessible, resourceGet, resourceGetByPath, ensurePersonalDefaults, SHARED_OWNER, WORKSPACE_OWNER, } from "../resources/store.js";
18
19
  import { getFrontmatterValue, getSkillNameFromPath, parseFrontmatter, } from "../resources/metadata.js";
19
20
  import nodePath from "node:path";
20
21
  import { readBody } from "./h3-helpers.js";
@@ -35,6 +36,205 @@ async function lazyFs() {
35
36
  }
36
37
  return _fs;
37
38
  }
39
+ const SHARED_PROMPT_RESOURCE_MAX_CHARS = 30_000;
40
+ const SHARED_RESOURCE_INDEX_LIMIT = 40;
41
+ function normalizeResourcePathForPrompt(path) {
42
+ return path.replace(/^\/+/, "").trim();
43
+ }
44
+ function escapeXmlAttribute(value) {
45
+ return value.replace(/&/g, "&").replace(/"/g, """);
46
+ }
47
+ function truncatePromptResourceContent(content, path, maxChars = SHARED_PROMPT_RESOURCE_MAX_CHARS) {
48
+ const trimmed = content.trim();
49
+ if (trimmed.length <= maxChars)
50
+ return trimmed;
51
+ const omitted = trimmed.length - maxChars;
52
+ return `${trimmed.slice(0, maxChars)}\n\n[Resource ${path} truncated after ${maxChars.toLocaleString()} characters; ${omitted.toLocaleString()} characters omitted. Use resource-read --path "${path}" with the resource's scope for the full content.]`;
53
+ }
54
+ function promptResourceBlock(input) {
55
+ const normalizedPath = input.path
56
+ ? normalizeResourcePathForPrompt(input.path)
57
+ : undefined;
58
+ const content = truncatePromptResourceContent(input.content, normalizedPath ?? input.name, input.maxChars);
59
+ if (!content)
60
+ return null;
61
+ const pathAttr = normalizedPath
62
+ ? ` path="${escapeXmlAttribute(normalizedPath)}"`
63
+ : "";
64
+ return `<resource name="${escapeXmlAttribute(input.name)}" scope="${escapeXmlAttribute(input.scope)}"${pathAttr}>\n${content}\n</resource>`;
65
+ }
66
+ function isAutoLoadedInstructionPath(path) {
67
+ const normalized = normalizeResourcePathForPrompt(path);
68
+ return normalized.startsWith("instructions/") && normalized.endsWith(".md");
69
+ }
70
+ function isSpecialPromptResourcePath(path) {
71
+ const normalized = normalizeResourcePathForPrompt(path);
72
+ return (normalized === "AGENTS.md" ||
73
+ normalized === "LEARNINGS.md" ||
74
+ normalized.startsWith("instructions/") ||
75
+ normalized.startsWith("skills/") ||
76
+ normalized.startsWith("agents/") ||
77
+ normalized.startsWith("remote-agents/") ||
78
+ normalized.startsWith("jobs/") ||
79
+ normalized.startsWith("memory/"));
80
+ }
81
+ function isTextLikeResource(mimeType) {
82
+ return (mimeType.startsWith("text/") ||
83
+ mimeType === "application/json" ||
84
+ mimeType === "application/yaml" ||
85
+ mimeType === "application/x-yaml");
86
+ }
87
+ function getResourceSummaryFromContent(content) {
88
+ const frontmatter = parseFrontmatter(content);
89
+ const title = getFrontmatterValue(frontmatter, "title") ||
90
+ getFrontmatterValue(frontmatter, "name");
91
+ const description = getFrontmatterValue(frontmatter, "description");
92
+ if (title && description)
93
+ return `${title}: ${description}`;
94
+ if (title)
95
+ return title;
96
+ if (description)
97
+ return description;
98
+ const heading = content
99
+ .split(/\r?\n/)
100
+ .map((line) => line.trim())
101
+ .find((line) => /^#{1,3}\s+\S/.test(line));
102
+ if (heading)
103
+ return heading.replace(/^#{1,3}\s+/, "").trim();
104
+ return null;
105
+ }
106
+ function resourceScopeForOwner(owner, currentOwner) {
107
+ if (owner === WORKSPACE_OWNER)
108
+ return "workspace";
109
+ if (owner === SHARED_OWNER)
110
+ return "shared";
111
+ if (currentOwner && owner === currentOwner)
112
+ return "personal";
113
+ return "resource";
114
+ }
115
+ async function loadAgentsResourceForPrompt(owner, scope) {
116
+ try {
117
+ const agents = await resourceGetByPath(owner, "AGENTS.md");
118
+ if (!agents?.content?.trim())
119
+ return null;
120
+ return promptResourceBlock({
121
+ name: "AGENTS.md",
122
+ scope,
123
+ path: "AGENTS.md",
124
+ content: agents.content,
125
+ });
126
+ }
127
+ catch {
128
+ return null;
129
+ }
130
+ }
131
+ async function loadInstructionResourcesForPrompt(owner, scope) {
132
+ try {
133
+ const resources = await resourceList(owner, "instructions/");
134
+ const blocks = [];
135
+ const sorted = resources
136
+ .filter((resource) => isAutoLoadedInstructionPath(resource.path))
137
+ .sort((a, b) => a.path.localeCompare(b.path));
138
+ for (const resource of sorted) {
139
+ const full = await resourceGet(resource.id).catch(() => null);
140
+ if (!full?.content?.trim())
141
+ continue;
142
+ const block = promptResourceBlock({
143
+ name: resource.path,
144
+ scope,
145
+ path: resource.path,
146
+ content: full.content,
147
+ });
148
+ if (block)
149
+ blocks.push(block);
150
+ }
151
+ return blocks;
152
+ }
153
+ catch {
154
+ return [];
155
+ }
156
+ }
157
+ async function loadResourceSkillsPromptBlock(owner) {
158
+ try {
159
+ const resources = owner === SHARED_OWNER
160
+ ? [
161
+ ...(await resourceList(SHARED_OWNER, "skills/")),
162
+ ...(await resourceList(WORKSPACE_OWNER, "skills/")),
163
+ ]
164
+ : await resourceListAccessible(owner, "skills/");
165
+ const sorted = resources.sort((a, b) => {
166
+ const ownerOrder = (a.owner === owner
167
+ ? 0
168
+ : a.owner === SHARED_OWNER
169
+ ? 1
170
+ : a.owner === WORKSPACE_OWNER
171
+ ? 2
172
+ : 3) -
173
+ (b.owner === owner
174
+ ? 0
175
+ : b.owner === SHARED_OWNER
176
+ ? 1
177
+ : b.owner === WORKSPACE_OWNER
178
+ ? 2
179
+ : 3);
180
+ if (ownerOrder !== 0)
181
+ return ownerOrder;
182
+ return a.path.localeCompare(b.path);
183
+ });
184
+ const seen = new Set();
185
+ const lines = [];
186
+ for (const resource of sorted) {
187
+ const full = await resourceGet(resource.id).catch(() => null);
188
+ if (!full?.content)
189
+ continue;
190
+ const meta = parseSkillFrontmatter(full.content);
191
+ if (meta.userInvocable === false)
192
+ continue;
193
+ const name = meta.name || getSkillNameFromPath(resource.path);
194
+ if (!name || seen.has(name))
195
+ continue;
196
+ seen.add(name);
197
+ const scope = resourceScopeForOwner(resource.owner, owner);
198
+ const description = meta.description || "(no description)";
199
+ lines.push(`- \`${name}\` at resource \`${resource.path}\` (${scope}) - ${description}. Read it with \`resource-read --path "${resource.path}" --scope ${scope}\` before starting a task it applies to.`);
200
+ }
201
+ if (lines.length === 0)
202
+ return null;
203
+ return `<resource-skills>\nThe following SQL-backed workspace skills are available in addition to codebase skills. Read a matching skill before starting a task it applies to.\n\n${lines.join("\n")}\n</resource-skills>`;
204
+ }
205
+ catch {
206
+ return null;
207
+ }
208
+ }
209
+ async function loadResourceIndexForPrompt(owner, scope) {
210
+ try {
211
+ const resources = (await resourceList(owner))
212
+ .filter((resource) => !isSpecialPromptResourcePath(resource.path) &&
213
+ isTextLikeResource(resource.mimeType))
214
+ .sort((a, b) => a.path.localeCompare(b.path));
215
+ if (resources.length === 0)
216
+ return null;
217
+ const listed = resources.slice(0, SHARED_RESOURCE_INDEX_LIMIT);
218
+ const lines = [];
219
+ for (const resource of listed) {
220
+ const full = await resourceGet(resource.id).catch(() => null);
221
+ const summary = full?.content
222
+ ? getResourceSummaryFromContent(full.content)
223
+ : null;
224
+ lines.push(`- \`${resource.path}\`${summary ? ` - ${summary}` : ""}`);
225
+ }
226
+ if (resources.length > listed.length) {
227
+ lines.push(`- ...${resources.length - listed.length} more ${scope} resources. Use \`resource-list --scope ${scope}\` to inspect them.`);
228
+ }
229
+ const label = scope === "workspace"
230
+ ? "Workspace reference resources are inherited by every app and are available for company, brand, positioning, persona, product, or domain context."
231
+ : "Shared app/organization reference resources are available for app-specific or team context.";
232
+ return `<workspace-resources scope="${scope}">\n${label} Use \`resource-read --path <path> --scope ${scope}\` when a task may depend on them; do not assume their contents without reading the relevant file.\n\n${lines.join("\n")}\n</workspace-resources>`;
233
+ }
234
+ catch {
235
+ return null;
236
+ }
237
+ }
38
238
  /**
39
239
  * Wraps a core CLI script (that writes to console.log) as a ActionEntry
40
240
  * by capturing stdout. Uses an AsyncLocalStorage-backed capture so
@@ -61,6 +261,15 @@ function wrapCliScript(tool, cliDefault, opts) {
61
261
  function filterReadOnlyActions(actions) {
62
262
  return Object.fromEntries(Object.entries(actions).filter(([, entry]) => entry.readOnly === true));
63
263
  }
264
+ function filterPublicAgentActions(actions) {
265
+ return Object.fromEntries(Object.entries(actions).filter(([, entry]) => {
266
+ const config = entry.publicAgent;
267
+ return (config?.expose === true &&
268
+ config.readOnly === true &&
269
+ config.requiresAuth !== true &&
270
+ config.isConsequential !== true);
271
+ }));
272
+ }
64
273
  function resolveArtifactBaseUrl(event) {
65
274
  const fromEnv = process.env.APP_URL ||
66
275
  process.env.URL ||
@@ -460,9 +669,10 @@ function shouldDefaultResourceWriteToWorkspace(path) {
460
669
  }
461
670
  async function createResourceScriptEntries() {
462
671
  try {
463
- const [list, read, write, del, saveMem, delMem, store] = await Promise.all([
672
+ const [list, read, effective, write, del, saveMem, delMem, store] = await Promise.all([
464
673
  import("../scripts/resources/list.js"),
465
674
  import("../scripts/resources/read.js"),
675
+ import("../scripts/resources/effective.js"),
466
676
  import("../scripts/resources/write.js"),
467
677
  import("../scripts/resources/delete.js"),
468
678
  import("../scripts/resources/save-memory.js"),
@@ -482,6 +692,10 @@ async function createResourceScriptEntries() {
482
692
  description: "",
483
693
  parameters: { type: "object", properties: {} },
484
694
  }, write.default);
695
+ const effectiveEntry = wrapCliScript({
696
+ description: "",
697
+ parameters: { type: "object", properties: {} },
698
+ }, effective.default, { readOnly: true });
485
699
  const deleteEntry = wrapCliScript({
486
700
  description: "",
487
701
  parameters: { type: "object", properties: {} },
@@ -489,14 +703,21 @@ async function createResourceScriptEntries() {
489
703
  return {
490
704
  resources: {
491
705
  tool: {
492
- description: 'Manage workspace resources. Actions: "list" (browse visible files), "read" (get contents), "write" (create/update), "promote" (make agent scratch visible), "delete" (remove). Agent scratch writes are hidden from the Workspace view by default; use visibility="workspace" only for files the user explicitly wants to keep/manage.',
706
+ description: 'Manage workspace resources. Actions: "list" (browse visible files), "read" (get contents), "effective" (show workspace -> organization/app -> personal inheritance for a path), "write" (create/update personal or shared), "promote" (make agent scratch visible), "delete" (remove personal or shared). Agent scratch writes are hidden from the Workspace view by default; use visibility="workspace" only for files the user explicitly wants to keep/manage.',
493
707
  parameters: {
494
708
  type: "object",
495
709
  properties: {
496
710
  action: {
497
711
  type: "string",
498
712
  description: "The operation to perform",
499
- enum: ["list", "read", "write", "promote", "delete"],
713
+ enum: [
714
+ "list",
715
+ "read",
716
+ "effective",
717
+ "write",
718
+ "promote",
719
+ "delete",
720
+ ],
500
721
  },
501
722
  path: {
502
723
  type: "string",
@@ -508,8 +729,8 @@ async function createResourceScriptEntries() {
508
729
  },
509
730
  scope: {
510
731
  type: "string",
511
- description: "personal, shared, or all (default varies by action)",
512
- enum: ["personal", "shared", "all"],
732
+ description: "personal, shared, workspace, or all (default varies by action). Workspace is read-only and inherited from Dispatch.",
733
+ enum: ["personal", "shared", "workspace", "all"],
513
734
  },
514
735
  prefix: {
515
736
  type: "string",
@@ -546,6 +767,11 @@ async function createResourceScriptEntries() {
546
767
  return "Error: path is required for read";
547
768
  return readEntry.run(rest);
548
769
  }
770
+ if (a === "effective") {
771
+ if (!rest.path)
772
+ return "Error: path is required for effective";
773
+ return effectiveEntry.run(rest);
774
+ }
549
775
  if (a === "write") {
550
776
  if (!rest.path ||
551
777
  rest.content === undefined ||
@@ -566,6 +792,9 @@ async function createResourceScriptEntries() {
566
792
  if (!rest.path)
567
793
  return "Error: path is required for promote";
568
794
  const scope = rest.scope ?? "personal";
795
+ if (scope === "workspace" || scope === "all") {
796
+ return "Error: promote supports personal or shared scope only";
797
+ }
569
798
  const owner = scope === "shared"
570
799
  ? store.SHARED_OWNER
571
800
  : (getRequestRunContext()?.owner ??
@@ -735,11 +964,19 @@ async function createChatScriptEntries() {
735
964
  * Creates the consolidated manage-agent-engine tool (list / set / test).
736
965
  * Let the agent inspect and configure the active LLM engine.
737
966
  */
738
- async function createAgentEngineScriptEntries() {
967
+ async function createAgentEngineScriptEntries(appId) {
739
968
  try {
740
969
  const mod = await import("../scripts/agent-engines/manage-agent-engine.js");
741
970
  return {
742
- "manage-agent-engine": { tool: mod.tool, run: mod.run },
971
+ "manage-agent-engine": {
972
+ tool: mod.tool,
973
+ run: (args) => mod.run({
974
+ ...args,
975
+ appId: typeof args.appId === "string" && args.appId.trim()
976
+ ? args.appId
977
+ : (appId ?? ""),
978
+ }),
979
+ },
743
980
  };
744
981
  }
745
982
  catch {
@@ -780,6 +1017,22 @@ async function createCallAgentScriptEntry(selfAppId) {
780
1017
  }
781
1018
  }
782
1019
  function createBuilderBrowserTool(deps) {
1020
+ const setBuiltinForCurrentUser = async (id, enabled) => {
1021
+ const email = getRequestUserEmail();
1022
+ if (!email) {
1023
+ return {
1024
+ ok: false,
1025
+ error: "not-signed-in",
1026
+ message: "You must be signed in to change built-in MCP tools.",
1027
+ };
1028
+ }
1029
+ const enabledIds = await setBuiltinMcpCapabilityEnabled("user", email, id, enabled);
1030
+ const manager = getGlobalMcpManager();
1031
+ if (manager) {
1032
+ await manager.reconfigure(await buildMergedConfig());
1033
+ }
1034
+ return { ok: true, enabledIds: enabledIds ?? [] };
1035
+ };
783
1036
  return {
784
1037
  "connect-builder": {
785
1038
  tool: {
@@ -814,6 +1067,93 @@ function createBuilderBrowserTool(deps) {
814
1067
  });
815
1068
  },
816
1069
  },
1070
+ "set-browser-control": {
1071
+ tool: {
1072
+ description: "Enable or disable built-in browser-control MCP tools for the current user. Call this when the user asks to test, screenshot, inspect, or interact with a web page and browser tools are not available; confirm once before enabling. Prefer the chrome-devtools backend for live logged-in Chrome, and use playwright when an isolated browser is better.",
1073
+ parameters: {
1074
+ type: "object",
1075
+ properties: {
1076
+ enabled: {
1077
+ type: "boolean",
1078
+ description: "Whether browser-control tools should be enabled.",
1079
+ },
1080
+ backend: {
1081
+ type: "string",
1082
+ enum: ["chrome-devtools", "playwright"],
1083
+ description: "Browser backend to enable. Defaults to chrome-devtools.",
1084
+ },
1085
+ },
1086
+ required: ["enabled"],
1087
+ },
1088
+ },
1089
+ run: async (args) => {
1090
+ const parsed = args && typeof args === "object"
1091
+ ? args
1092
+ : {};
1093
+ const enabled = parsed.enabled !== false;
1094
+ const requestedBackend = typeof parsed.backend === "string" ? parsed.backend : undefined;
1095
+ const backend = requestedBackend === "playwright" ? "playwright" : "chrome-devtools";
1096
+ const targetId = backend === "playwright"
1097
+ ? "browser-playwright"
1098
+ : "browser-chrome-devtools";
1099
+ if (!enabled) {
1100
+ const chrome = await setBuiltinForCurrentUser("browser-chrome-devtools", false);
1101
+ if (!chrome.ok)
1102
+ return JSON.stringify(chrome);
1103
+ const playwright = await setBuiltinForCurrentUser("browser-playwright", false);
1104
+ return JSON.stringify({
1105
+ ...playwright,
1106
+ enabled: false,
1107
+ message: "Browser-control MCP tools are disabled.",
1108
+ });
1109
+ }
1110
+ const result = await setBuiltinForCurrentUser(targetId, true);
1111
+ return JSON.stringify({
1112
+ ...result,
1113
+ enabled: true,
1114
+ backend,
1115
+ message: backend === "chrome-devtools"
1116
+ ? "Chrome DevTools MCP is enabled. Browser tools will be available on the next action when Chrome remote debugging is available."
1117
+ : "Playwright MCP is enabled. Browser tools will be available on the next action in an isolated Playwright browser.",
1118
+ });
1119
+ },
1120
+ },
1121
+ "set-computer-use": {
1122
+ tool: {
1123
+ description: "Enable or disable built-in Computer Use MCP tools for the current user. Call only after the user explicitly asks to let the agent control local desktop apps. macOS may require Screen Recording and Accessibility permissions.",
1124
+ parameters: {
1125
+ type: "object",
1126
+ properties: {
1127
+ enabled: {
1128
+ type: "boolean",
1129
+ description: "Whether Computer Use tools should be enabled.",
1130
+ },
1131
+ },
1132
+ required: ["enabled"],
1133
+ },
1134
+ },
1135
+ run: async (args) => {
1136
+ const parsed = args && typeof args === "object"
1137
+ ? args
1138
+ : {};
1139
+ const enabled = parsed.enabled !== false;
1140
+ if (enabled && process.platform !== "darwin") {
1141
+ return JSON.stringify({
1142
+ ok: false,
1143
+ error: "unsupported-platform",
1144
+ message: "Computer Use is currently available only on macOS.",
1145
+ });
1146
+ }
1147
+ const result = await setBuiltinForCurrentUser("computer-use", enabled);
1148
+ return JSON.stringify({
1149
+ ...result,
1150
+ enabled,
1151
+ message: enabled
1152
+ ? "Computer Use MCP is enabled. If macOS prompts, grant Screen Recording and Accessibility permission in System Settings > Privacy & Security."
1153
+ : "Computer Use MCP is disabled.",
1154
+ });
1155
+ },
1156
+ },
817
1157
  "activate-browser": {
818
1158
  tool: {
819
1159
  description: "Activate browser automation tools. Call this when you need to interact with a real browser — e.g. to extract design tokens from a rendered page, take screenshots, read computed styles from JS-heavy sites, or test a live URL. After activation, chrome-devtools MCP tools (navigate, click, evaluate_script, take_screenshot, etc.) become available on your next action. Requires Builder.io connection.",
@@ -870,7 +1210,7 @@ function createBuilderBrowserTool(deps) {
870
1210
  command: "npx",
871
1211
  args: [
872
1212
  "-y",
873
- "chrome-devtools-mcp@latest",
1213
+ "chrome-devtools-mcp@0.26.0",
874
1214
  "--wsEndpoint",
875
1215
  wsUrl,
876
1216
  "--categoryEmulation=false",
@@ -1090,7 +1430,8 @@ const FRAMEWORK_CORE_COMPACT = `
1090
1430
 
1091
1431
  ### Resources
1092
1432
 
1093
- Use resource-list, resource-read, resource-write, resource-delete for persistent notes and context files.
1433
+ Use resource-list, resource-read, resource-effective, resource-write, resource-delete for persistent notes and context files.
1434
+ Resources have three levels: workspace defaults inherited from Dispatch, shared organization/app overrides, and personal overrides. Use resource-effective before editing when you need to explain or inspect which level is active for a path.
1094
1435
  Workspace resources are user-facing by default. If you need temporary working files, write them as agent scratch (\`visibility: "agent_scratch"\`); scratch is hidden from the Workspace view by default and expires. Use \`visibility: "workspace"\` only when the user explicitly asked to save/manage that file, or for durable AGENTS.md, LEARNINGS.md, memory, skills, jobs, or custom agents.
1095
1436
 
1096
1437
  ### Navigation Rule
@@ -1103,7 +1444,7 @@ On the user's first interaction, check \`readAppState("personalization")\`. If i
1103
1444
 
1104
1445
  ### Extended Capabilities
1105
1446
 
1106
- You also have tools for: inline embeds, chat history search, agent teams/sub-agents, recurring jobs, A2A cross-app calls, structured memory, and browser automation (\`activate-browser\` to provision a real Chrome). Call \`get-framework-context\` to read detailed instructions for any of these when needed.
1447
+ You also have tools for: inline embeds, chat history search, agent teams/sub-agents, recurring jobs, A2A cross-app calls, structured memory, live embedded browser sessions (\`list-browser-sessions\`, \`view-browser-session\`, \`run-browser-session-action\`, \`send-browser-session-command\`), and browser automation (\`set-browser-control\` for built-in Chrome DevTools/Playwright MCP, \`activate-browser\` for Builder-provisioned Chrome). Call \`get-framework-context\` to read detailed instructions for any of these when needed.
1107
1448
 
1108
1449
  For brand-consistent raster image generation, use the first-party Images agent via \`call-agent\` with agent "images" when another app needs generated heroes, diagrams, product shots, thumbnails, or design imagery. If this app has a native image-generation action, prefer that action because it may attach the image to the local document/deck/design.
1109
1450
  `;
@@ -1193,7 +1534,7 @@ You can activate a real Chrome browser via Builder.io for tasks that need full p
1193
1534
  - Reading content from pages that require JavaScript execution
1194
1535
 
1195
1536
  **How to use:**
1196
- 1. Call \`activate-browser\` this provisions a Chrome instance and registers chrome-devtools MCP tools
1537
+ 1. Call \`set-browser-control\` with \`{"enabled":true,"backend":"chrome-devtools"}\` after confirming once with the user. Use \`activate-browser\` only when you specifically need Builder-provisioned Chrome.
1197
1538
  2. On your next action, use \`mcp__chrome-devtools__navigate_page\`, \`mcp__chrome-devtools__evaluate_script\`, \`mcp__chrome-devtools__take_screenshot\`, etc.
1198
1539
  3. If Builder is not connected, call \`connect-builder\` first
1199
1540
 
@@ -1283,8 +1624,8 @@ const FRAMEWORK_CORE = `
1283
1624
  ### Resources
1284
1625
 
1285
1626
  You have access to a Resources system for persistent notes and context files.
1286
- Use resource-list, resource-read, resource-write, resource-delete to manage resources.
1287
- Resources can be personal (per-user) or shared (team-wide). By default, resources are personal.
1627
+ Use resource-list, resource-read, resource-effective, resource-write, resource-delete to manage resources.
1628
+ Resources can be workspace defaults inherited from Dispatch, shared organization/app overrides, or personal overrides. By default, resources are personal. Workspace-scope resources are read-only from app agents; create shared or personal resources to override or narrow them.
1288
1629
 
1289
1630
  When the user gives instructions that should apply to all users/sessions, update the shared "AGENTS.md" resource.
1290
1631
 
@@ -1387,7 +1728,7 @@ When the user asks to connect Builder.io, needs Builder for LLM access / browser
1387
1728
 
1388
1729
  ### Browser Automation
1389
1730
 
1390
- Call \`activate-browser\` to provision a real Chrome browser. After activation, chrome-devtools MCP tools become available for navigating pages, reading rendered DOM, taking screenshots, and evaluating JavaScript. If Builder is not connected, call \`connect-builder\` first. Use browser automation proactively when tasks benefit from full page rendering (design system extraction from URLs, visual verification, SPA content reading).
1731
+ Call \`set-browser-control\` to enable built-in browser MCP tools. Prefer \`backend:"chrome-devtools"\` for the user's live logged-in Chrome; use \`backend:"playwright"\` for isolated browser testing. After activation, MCP browser tools become available for navigating pages, reading rendered DOM, taking screenshots, and evaluating JavaScript on the next action. Use \`activate-browser\` only for Builder-provisioned browser sessions.
1391
1732
 
1392
1733
  ### call-agent — External Apps Only
1393
1734
 
@@ -1590,24 +1931,29 @@ When editing code, follow the agent-native architecture:
1590
1931
  ${FRAMEWORK_CORE_COMPACT}`;
1591
1932
  const DEFAULT_SYSTEM_PROMPT = PROD_FRAMEWORK_PROMPT;
1592
1933
  /**
1593
- * Pre-load the agent's context: AGENTS.md (template instructions), the skills
1594
- * index, shared LEARNINGS.md (team notes), and memory/MEMORY.md (personal
1595
- * structured memory index). These all get appended to the system prompt so
1596
- * the agent has everything it needs from the first turn.
1934
+ * Pre-load the agent's context: AGENTS.md (workspace/template/runtime
1935
+ * instructions), the skills index, shared LEARNINGS.md (team notes), a shared
1936
+ * resource index, and memory/MEMORY.md (personal structured memory index).
1937
+ * These all get appended to the system prompt so the agent has everything it
1938
+ * needs from the first turn.
1597
1939
  *
1598
- * Four sources are layered:
1940
+ * Six sources are layered:
1599
1941
  *
1600
1942
  * 1. `<workspace>` — AGENTS.md from the enterprise workspace core.
1601
1943
  * 2. `<template>` — AGENTS.md + skills index from the Vite plugin bundle.
1602
- * 3. `<shared>` — LEARNINGS.md from the SQL shared scope. Team-level notes.
1603
- * 4. `<personal>` memory/MEMORY.md from the SQL personal scope. The
1944
+ * 3. `<workspace>` — SQL workspace AGENTS.md and instructions/*.md.
1945
+ * Runtime global defaults managed from Dispatch and inherited by apps.
1946
+ * 4. `<shared>` — SQL shared AGENTS.md and instructions/*.md. App/team/org
1947
+ * guidance that can override or narrow workspace defaults.
1948
+ * 5. `<shared>` — LEARNINGS.md from the SQL shared scope. Team-level notes.
1949
+ * 6. `<personal>` — memory/MEMORY.md from the SQL personal scope. The
1604
1950
  * current user's structured memory index.
1605
1951
  *
1606
1952
  * Each source is read independently — no copying between them. Editing
1607
1953
  * AGENTS.md and restarting the server is all it takes; Vite HMR invalidates
1608
1954
  * the bundle in dev so changes land instantly.
1609
1955
  */
1610
- async function loadResourcesForPrompt(owner, compact = false, selfAppId) {
1956
+ export async function loadResourcesForPrompt(owner, compact = false, selfAppId) {
1611
1957
  await ensurePersonalDefaults(owner);
1612
1958
  const sections = [];
1613
1959
  // 1. Workspace AGENTS.md + skills merged into the template bundle.
@@ -1637,6 +1983,29 @@ async function loadResourcesForPrompt(owner, compact = false, selfAppId) {
1637
1983
  }
1638
1984
  }
1639
1985
  catch { }
1986
+ // 3. Runtime workspace resources from SQL. These are global defaults
1987
+ // inherited by every app in the workspace, not copied into app scopes.
1988
+ const workspaceAgents = await loadAgentsResourceForPrompt(WORKSPACE_OWNER, "workspace");
1989
+ if (workspaceAgents)
1990
+ sections.push(workspaceAgents);
1991
+ sections.push(...(await loadInstructionResourcesForPrompt(WORKSPACE_OWNER, "workspace-instruction")));
1992
+ // 4. Runtime shared/app/org resources from SQL. These come after workspace
1993
+ // defaults so app/team-specific guidance can override or narrow them.
1994
+ const sharedAgents = await loadAgentsResourceForPrompt(SHARED_OWNER, "shared");
1995
+ if (sharedAgents)
1996
+ sections.push(sharedAgents);
1997
+ sections.push(...(await loadInstructionResourcesForPrompt(SHARED_OWNER, "shared-instruction")));
1998
+ // 5. Personal SQL resources. These come last in the instruction stack so a
1999
+ // user can narrow or override organization/app and workspace defaults.
2000
+ if (owner !== SHARED_OWNER && owner !== WORKSPACE_OWNER) {
2001
+ const personalAgents = await loadAgentsResourceForPrompt(owner, "personal");
2002
+ if (personalAgents)
2003
+ sections.push(personalAgents);
2004
+ sections.push(...(await loadInstructionResourcesForPrompt(owner, "personal-instruction")));
2005
+ }
2006
+ const resourceSkillsBlock = await loadResourceSkillsPromptBlock(owner);
2007
+ if (resourceSkillsBlock)
2008
+ sections.push(resourceSkillsBlock);
1640
2009
  if (compact) {
1641
2010
  // In compact mode, skip learnings and memory in the prompt.
1642
2011
  // The agent can access them via resource-read when needed.
@@ -1664,6 +2033,12 @@ async function loadResourcesForPrompt(owner, compact = false, selfAppId) {
1664
2033
  catch { }
1665
2034
  }
1666
2035
  }
2036
+ const workspaceResourceIndex = await loadResourceIndexForPrompt(WORKSPACE_OWNER, "workspace");
2037
+ if (workspaceResourceIndex)
2038
+ sections.push(workspaceResourceIndex);
2039
+ const sharedResourceIndex = await loadResourceIndexForPrompt(SHARED_OWNER, "shared");
2040
+ if (sharedResourceIndex)
2041
+ sections.push(sharedResourceIndex);
1667
2042
  try {
1668
2043
  const agents = (await discoverAgents(selfAppId)).slice(0, 30);
1669
2044
  if (agents.length > 0) {
@@ -2012,7 +2387,7 @@ export function createAgentChatPlugin(options) {
2012
2387
  const leanPrompt = options?.leanPrompt === true;
2013
2388
  const lazyContext = options?.lazyContext !== false && !leanPrompt;
2014
2389
  const urlTools = createUrlTools();
2015
- const engineScripts = await createAgentEngineScriptEntries();
2390
+ const engineScripts = await createAgentEngineScriptEntries(options?.appId);
2016
2391
  const loopSettingsScripts = await createAgentLoopSettingsScriptEntries();
2017
2392
  const chatScripts = {
2018
2393
  ...(await createChatScriptEntries()),
@@ -2230,6 +2605,14 @@ export function createAgentChatPlugin(options) {
2230
2605
  toolActions = createExtensionActionEntries();
2231
2606
  }
2232
2607
  catch { }
2608
+ let browserSessionTools = {};
2609
+ try {
2610
+ const { createBrowserSessionActionEntries } = await import("../browser-sessions/actions.js");
2611
+ browserSessionTools = createBrowserSessionActionEntries({
2612
+ getOwnerEmail: () => requireCurrentRunOwner("use browser sessions"),
2613
+ });
2614
+ }
2615
+ catch { }
2233
2616
  const resolveExtraContext = async (event, owner) => {
2234
2617
  if (!options?.extraContext)
2235
2618
  return "";
@@ -2249,6 +2632,7 @@ export function createAgentChatPlugin(options) {
2249
2632
  // native registration since it has no shell access.
2250
2633
  const allScripts = attachToolSearch(canToggle
2251
2634
  ? {
2635
+ ...filterPublicAgentActions(templateScripts),
2252
2636
  ...resourceScripts,
2253
2637
  ...docsScripts,
2254
2638
  ...(lazyContext ? frameworkContextTool : {}),
@@ -2260,6 +2644,7 @@ export function createAgentChatPlugin(options) {
2260
2644
  ...progressTools,
2261
2645
  ...fetchTool,
2262
2646
  ...toolActions,
2647
+ ...browserSessionTools,
2263
2648
  ...browserTools,
2264
2649
  ...devScriptsForA2A,
2265
2650
  }
@@ -2279,6 +2664,7 @@ export function createAgentChatPlugin(options) {
2279
2664
  ...progressTools,
2280
2665
  ...fetchTool,
2281
2666
  ...toolActions,
2667
+ ...browserSessionTools,
2282
2668
  ...browserTools,
2283
2669
  ...devScriptsForA2A,
2284
2670
  });
@@ -2418,6 +2804,7 @@ export function createAgentChatPlugin(options) {
2418
2804
  const a2aEngine = await resolveEngine({
2419
2805
  engineOption: options?.engine,
2420
2806
  apiKey: options?.apiKey,
2807
+ appId: options?.appId,
2421
2808
  });
2422
2809
  // Use the same handler (dev or prod) that the interactive chat uses
2423
2810
  const devActive = isDevMode();
@@ -2436,7 +2823,9 @@ export function createAgentChatPlugin(options) {
2436
2823
  ? devPrompt + runtimeContext + resources + schemaBlock + extra
2437
2824
  : basePrompt + runtimeContext + resources + schemaBlock + extra;
2438
2825
  const model = options?.model ??
2439
- (await getStoredModelForEngine(a2aEngine)) ??
2826
+ (await getStoredModelForEngine(a2aEngine, {
2827
+ appId: options?.appId,
2828
+ })) ??
2440
2829
  a2aEngine.defaultModel;
2441
2830
  // Build tools — same as interactive handler but WITHOUT call-agent
2442
2831
  // to prevent infinite recursive A2A loops (agent calling itself).
@@ -2450,6 +2839,7 @@ export function createAgentChatPlugin(options) {
2450
2839
  ...urlTools,
2451
2840
  ...chatScripts,
2452
2841
  ...toolActions,
2842
+ ...browserSessionTools,
2453
2843
  ...browserTools,
2454
2844
  ...devScriptsForA2A,
2455
2845
  }
@@ -2463,6 +2853,7 @@ export function createAgentChatPlugin(options) {
2463
2853
  ...urlTools,
2464
2854
  ...chatScripts,
2465
2855
  ...toolActions,
2856
+ ...browserSessionTools,
2466
2857
  ...browserTools,
2467
2858
  });
2468
2859
  const a2aTools = actionsToEngineTools(a2aActions);
@@ -2583,9 +2974,12 @@ export function createAgentChatPlugin(options) {
2583
2974
  const mcpEngine = await resolveEngine({
2584
2975
  engineOption: options?.engine,
2585
2976
  apiKey: options?.apiKey,
2977
+ appId: options?.appId,
2586
2978
  });
2587
2979
  const model = options?.model ??
2588
- (await getStoredModelForEngine(mcpEngine)) ??
2980
+ (await getStoredModelForEngine(mcpEngine, {
2981
+ appId: options?.appId,
2982
+ })) ??
2589
2983
  mcpEngine.defaultModel;
2590
2984
  // Same actions as A2A — without call-agent to prevent loops.
2591
2985
  // In dev mode, template actions go through shell, not native tools.
@@ -3033,6 +3427,7 @@ export function createAgentChatPlugin(options) {
3033
3427
  ...progressTools,
3034
3428
  ...fetchTool,
3035
3429
  ...toolActions,
3430
+ ...browserSessionTools,
3036
3431
  ...browserTools,
3037
3432
  ...mcpActionEntries,
3038
3433
  });
@@ -3165,6 +3560,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3165
3560
  extra);
3166
3561
  },
3167
3562
  model: options?.model,
3563
+ appId: options?.appId,
3168
3564
  apiKey: options?.apiKey,
3169
3565
  runSoftTimeoutMs: options?.runSoftTimeoutMs,
3170
3566
  finalResponseGuard: options?.finalResponseGuard,
@@ -3203,6 +3599,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3203
3599
  extra);
3204
3600
  },
3205
3601
  model: options?.model,
3602
+ appId: options?.appId,
3206
3603
  apiKey: options?.apiKey,
3207
3604
  runSoftTimeoutMs: options?.runSoftTimeoutMs,
3208
3605
  finalResponseGuard: options?.finalResponseGuard,
@@ -3262,6 +3659,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3262
3659
  ...progressTools,
3263
3660
  ...fetchTool,
3264
3661
  ...toolActions,
3662
+ ...browserSessionTools,
3265
3663
  ...browserTools,
3266
3664
  ...mcpActionEntries,
3267
3665
  ...(await createDevScriptRegistry()),
@@ -3289,6 +3687,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3289
3687
  return setSystemPromptOnContext(devPrompt + runtimeContext + resources + schemaBlock + extra);
3290
3688
  },
3291
3689
  model: options?.model,
3690
+ appId: options?.appId,
3292
3691
  apiKey: options?.apiKey,
3293
3692
  runSoftTimeoutMs: options?.runSoftTimeoutMs,
3294
3693
  finalResponseGuard: options?.finalResponseGuard,
@@ -3354,6 +3753,125 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3354
3753
  }
3355
3754
  return { devMode: currentDevMode, canToggle };
3356
3755
  }));
3756
+ const modelDefaultsAppId = normalizeAgentAppModelDefaultAppId(options?.appId ??
3757
+ process.env.AGENT_NATIVE_APP_ID ??
3758
+ process.env.VITE_AGENT_NATIVE_TEMPLATE ??
3759
+ "app") ?? "app";
3760
+ const resolveModelDefaultsContext = async (event) => {
3761
+ const session = await getSession(event).catch(() => null);
3762
+ if (!session?.email) {
3763
+ return {
3764
+ ok: false,
3765
+ status: 401,
3766
+ error: "Authentication required",
3767
+ };
3768
+ }
3769
+ let orgCtx = null;
3770
+ try {
3771
+ const { getOrgContext } = await import("../org/context.js");
3772
+ orgCtx = await getOrgContext(event);
3773
+ }
3774
+ catch {
3775
+ orgCtx = null;
3776
+ }
3777
+ const orgId = (options?.resolveOrgId
3778
+ ? await options.resolveOrgId(event)
3779
+ : (orgCtx?.orgId ?? session.orgId ?? null)) ?? null;
3780
+ const canUpdate = await canUpdateAgentAppModelDefaultSettings(session.email, orgId);
3781
+ return {
3782
+ ok: true,
3783
+ userEmail: session.email,
3784
+ orgId,
3785
+ orgName: orgCtx?.orgId === orgId ? (orgCtx.orgName ?? null) : null,
3786
+ role: orgCtx?.orgId === orgId ? (orgCtx.role ?? null) : null,
3787
+ canUpdate,
3788
+ };
3789
+ };
3790
+ const listModelDefaultEngineOptions = async (ctx) => {
3791
+ registerBuiltinEngines();
3792
+ return runWithRequestContext({
3793
+ userEmail: ctx.userEmail,
3794
+ orgId: ctx.orgId ?? undefined,
3795
+ }, () => Promise.all(listAgentEngines().map(async (entry) => ({
3796
+ name: entry.name,
3797
+ label: entry.label,
3798
+ description: entry.description,
3799
+ defaultModel: entry.defaultModel,
3800
+ supportedModels: entry.supportedModels,
3801
+ requiredEnvVars: entry.requiredEnvVars,
3802
+ configured: await isStoredEngineUsableForRequest({ engine: entry.name, model: entry.defaultModel }, entry).catch(() => false),
3803
+ }))));
3804
+ };
3805
+ const buildModelDefaultsPayload = async (event, appId) => {
3806
+ const ctx = await resolveModelDefaultsContext(event);
3807
+ if (!ctx.ok)
3808
+ return ctx;
3809
+ const settings = await readAgentAppModelDefaultSettings({ userEmail: ctx.userEmail, orgId: ctx.orgId }, appId);
3810
+ return {
3811
+ ok: true,
3812
+ ...settings,
3813
+ canUpdate: ctx.canUpdate,
3814
+ orgId: ctx.orgId,
3815
+ orgName: ctx.orgName,
3816
+ role: ctx.role,
3817
+ engines: await listModelDefaultEngineOptions(ctx),
3818
+ };
3819
+ };
3820
+ // GET/PUT/DELETE /_agent-native/agent-model-defaults — org-scoped
3821
+ // per-app default engine/model used when a chat request does not carry
3822
+ // an explicit composer model selection.
3823
+ getH3App(nitroApp).use("/_agent-native/agent-model-defaults", defineEventHandler(async (event) => {
3824
+ const method = getMethod(event);
3825
+ const query = getQuery(event);
3826
+ const queryAppId = typeof query.appId === "string" ? query.appId : undefined;
3827
+ const appId = normalizeAgentAppModelDefaultAppId(queryAppId) ??
3828
+ modelDefaultsAppId;
3829
+ if (method === "GET") {
3830
+ const payload = await buildModelDefaultsPayload(event, appId);
3831
+ if (payload.ok === false) {
3832
+ setResponseStatus(event, payload.status);
3833
+ return { error: payload.error };
3834
+ }
3835
+ return payload;
3836
+ }
3837
+ if (method !== "PUT" && method !== "DELETE") {
3838
+ setResponseStatus(event, 405);
3839
+ return { error: "Method not allowed" };
3840
+ }
3841
+ const ctx = await resolveModelDefaultsContext(event);
3842
+ if (ctx.ok === false) {
3843
+ setResponseStatus(event, ctx.status);
3844
+ return { error: ctx.error };
3845
+ }
3846
+ if (!ctx.canUpdate) {
3847
+ setResponseStatus(event, 403);
3848
+ return {
3849
+ error: ctx.orgId
3850
+ ? "Only organization owners and admins can change app model defaults."
3851
+ : "You cannot change app model defaults.",
3852
+ };
3853
+ }
3854
+ if (method === "DELETE") {
3855
+ await resetAgentAppModelDefaultSettings({ userEmail: ctx.userEmail, orgId: ctx.orgId }, appId);
3856
+ return buildModelDefaultsPayload(event, appId);
3857
+ }
3858
+ const body = await readBody(event).catch(() => ({}));
3859
+ const bodyAppId = typeof body?.appId === "string" ? body.appId : undefined;
3860
+ const targetAppId = normalizeAgentAppModelDefaultAppId(bodyAppId) ?? appId;
3861
+ const engine = typeof body?.engine === "string" ? body.engine.trim() : "";
3862
+ const model = typeof body?.model === "string" ? body.model.trim() : "";
3863
+ if (!engine || !model) {
3864
+ setResponseStatus(event, 400);
3865
+ return { error: "engine and model are required" };
3866
+ }
3867
+ const entry = getAgentEngineEntry(engine);
3868
+ if (!entry) {
3869
+ setResponseStatus(event, 400);
3870
+ return { error: `Unknown engine: ${engine}` };
3871
+ }
3872
+ await writeAgentAppModelDefaultSettings({ userEmail: ctx.userEmail, orgId: ctx.orgId }, targetAppId, { engine, model, updatedBy: ctx.userEmail });
3873
+ return buildModelDefaultsPayload(event, targetAppId);
3874
+ }));
3357
3875
  // Mount save-key BEFORE the prefix handler so it isn't shadowed.
3358
3876
  // Persists the user's API key in `app_secrets` (encrypted, scope=user,
3359
3877
  // scopeId=email). Hard rule: never mutates process.env, never writes
@@ -3438,7 +3956,10 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3438
3956
  }
3439
3957
  // Query resources
3440
3958
  try {
3441
- const resources = await resourceList(SHARED_OWNER);
3959
+ const resources = [
3960
+ ...(await resourceList(SHARED_OWNER)),
3961
+ ...(await resourceList(WORKSPACE_OWNER)),
3962
+ ];
3442
3963
  for (const r of resources) {
3443
3964
  if (!seen.has(r.path)) {
3444
3965
  seen.add(r.path);
@@ -3530,10 +4051,25 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3530
4051
  await ensurePersonalDefaults(skillsOwner);
3531
4052
  const resourceSkills = skillsOwner
3532
4053
  ? await resourceListAccessible(skillsOwner, "skills/")
3533
- : await resourceList(SHARED_OWNER, "skills/");
4054
+ : [
4055
+ ...(await resourceList(SHARED_OWNER, "skills/")),
4056
+ ...(await resourceList(WORKSPACE_OWNER, "skills/")),
4057
+ ];
3534
4058
  resourceSkills.sort((a, b) => {
3535
- const ownerOrder = (a.owner === skillsOwner ? 0 : 1) -
3536
- (b.owner === skillsOwner ? 0 : 1);
4059
+ const ownerOrder = (a.owner === skillsOwner
4060
+ ? 0
4061
+ : a.owner === SHARED_OWNER
4062
+ ? 1
4063
+ : a.owner === WORKSPACE_OWNER
4064
+ ? 2
4065
+ : 3) -
4066
+ (b.owner === skillsOwner
4067
+ ? 0
4068
+ : b.owner === SHARED_OWNER
4069
+ ? 1
4070
+ : b.owner === WORKSPACE_OWNER
4071
+ ? 2
4072
+ : 3);
3537
4073
  if (ownerOrder !== 0)
3538
4074
  return ownerOrder;
3539
4075
  const pathOrder = (a.path.endsWith("/SKILL.md") ? 0 : 1) -
@@ -3654,17 +4190,20 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
3654
4190
  // 1. Resources from SQL (fast — flush first)
3655
4191
  sources.push((async () => {
3656
4192
  try {
3657
- const resources = await resourceList(SHARED_OWNER);
4193
+ const resources = mentionsOwner
4194
+ ? await resourceListAccessible(mentionsOwner)
4195
+ : [
4196
+ ...(await resourceList(WORKSPACE_OWNER)),
4197
+ ...(await resourceList(SHARED_OWNER)),
4198
+ ];
3658
4199
  flush(resources.map((r) => {
3659
- const isShared = r.owner === SHARED_OWNER;
4200
+ const scope = resourceScopeForOwner(r.owner, mentionsOwner);
3660
4201
  return {
3661
4202
  id: `resource:${r.path}`,
3662
4203
  label: r.path.split("/").pop() || r.path,
3663
4204
  description: r.path,
3664
4205
  icon: "file",
3665
- source: isShared
3666
- ? "resource:shared"
3667
- : "resource:private",
4206
+ source: `resource:${scope}`,
3668
4207
  refType: "file",
3669
4208
  refPath: r.path,
3670
4209
  section: "Files",
@@ -4047,20 +4586,35 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
4047
4586
  : {}),
4048
4587
  };
4049
4588
  };
4589
+ const parseThreadRoute = (event) => {
4590
+ const candidates = [event.path, event.node?.req?.url].filter((value) => typeof value === "string" && value.length > 0);
4591
+ for (const candidate of candidates) {
4592
+ const path = candidate.split("?")[0];
4593
+ const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
4594
+ const threadsIndex = parts.lastIndexOf("threads");
4595
+ if (threadsIndex >= 0) {
4596
+ const encodedId = parts[threadsIndex + 1];
4597
+ if (!encodedId)
4598
+ continue;
4599
+ return {
4600
+ threadId: decodeURIComponent(encodedId),
4601
+ tail: parts.slice(threadsIndex + 2),
4602
+ };
4603
+ }
4604
+ if (parts.length > 0) {
4605
+ return {
4606
+ threadId: decodeURIComponent(parts[0]),
4607
+ tail: parts.slice(1),
4608
+ };
4609
+ }
4610
+ }
4611
+ return { threadId: null, tail: [] };
4612
+ };
4050
4613
  getH3App(nitroApp).use(`${routePath}/threads`, defineEventHandler(async (event) => {
4051
4614
  const owner = await getOwnerFromEvent(event);
4052
4615
  const method = getMethod(event);
4053
- // Determine if this is a specific-thread request.
4054
- // h3's use() strips the mount prefix, so event.path contains
4055
- // only the remainder after /threads — e.g., "/thread-abc" or "/".
4056
- // We also check the original URL as a fallback.
4057
- const remainder = (event.path || "").replace(/^\/+/, "");
4058
- const fromUrl = (event.node?.req?.url || "").match(/\/threads\/([^/?]+)/);
4059
- const threadId = remainder
4060
- ? decodeURIComponent(remainder.split("?")[0].split("/")[0])
4061
- : fromUrl
4062
- ? decodeURIComponent(fromUrl[1])
4063
- : null;
4616
+ const { threadId, tail: threadTail } = parseThreadRoute(event);
4617
+ const isThreadSubroute = (subroute) => threadTail[0] === subroute;
4064
4618
  // ── Specific thread: GET/PUT/DELETE /threads/:id ──
4065
4619
  if (threadId) {
4066
4620
  if (method === "GET") {
@@ -4121,8 +4675,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
4121
4675
  // when the user adds/removes/dequeues a queued message. Keeps
4122
4676
  // queued messages durable across reloads without piggybacking
4123
4677
  // on full-thread saves.
4124
- if (method === "POST" &&
4125
- /\/threads\/[^/?]+\/queued/.test(event.node?.req?.url || event.path || "")) {
4678
+ if (method === "POST" && isThreadSubroute("queued")) {
4126
4679
  const thread = await getThread(threadId);
4127
4680
  if (!thread || thread.ownerEmail !== owner) {
4128
4681
  setResponseStatus(event, 404);
@@ -4136,8 +4689,7 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
4136
4689
  return { ok: true };
4137
4690
  }
4138
4691
  // POST /threads/:id/fork — duplicate a thread with all its messages
4139
- if (method === "POST" &&
4140
- /\/threads\/[^/?]+\/fork/.test(event.node?.req?.url || event.path || "")) {
4692
+ if (method === "POST" && isThreadSubroute("fork")) {
4141
4693
  const body = await readBody(event);
4142
4694
  const forked = await forkThread(threadId, owner, {
4143
4695
  id: body?.id,
@@ -4326,7 +4878,8 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
4326
4878
  return basePrompt + resources + schemaBlock;
4327
4879
  },
4328
4880
  apiKey: options?.apiKey ?? process.env.ANTHROPIC_API_KEY,
4329
- model: resolvedModel,
4881
+ model: options?.model,
4882
+ appId: options?.appId,
4330
4883
  };
4331
4884
  // Start after a 10-second delay to let the server fully initialize
4332
4885
  setTimeout(() => {
@@ -4367,7 +4920,8 @@ Non-code requests are still fine on this surface — read data, navigate the UI,
4367
4920
  return basePrompt + resources + schemaBlock;
4368
4921
  },
4369
4922
  apiKey: options?.apiKey ?? process.env.ANTHROPIC_API_KEY,
4370
- model: resolvedModel,
4923
+ model: options?.model,
4924
+ appId: options?.appId,
4371
4925
  });
4372
4926
  if (process.env.DEBUG)
4373
4927
  console.log("[triggers] Trigger dispatcher initialized");