@mastra/core 1.18.0 → 1.18.1-alpha.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 (211) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/index.cjs +8 -8
  4. package/dist/agent/index.js +1 -1
  5. package/dist/agent/workflows/prepare-stream/map-results-step.d.ts.map +1 -1
  6. package/dist/{chunk-KLVNQDUR.cjs → chunk-2W7R236U.cjs} +3 -3
  7. package/dist/chunk-2W7R236U.cjs.map +1 -0
  8. package/dist/{chunk-V2NQOABM.cjs → chunk-5ANYSU2W.cjs} +9 -9
  9. package/dist/{chunk-V2NQOABM.cjs.map → chunk-5ANYSU2W.cjs.map} +1 -1
  10. package/dist/{chunk-KOTSKPTF.cjs → chunk-6R5PT6ZP.cjs} +5 -5
  11. package/dist/{chunk-KOTSKPTF.cjs.map → chunk-6R5PT6ZP.cjs.map} +1 -1
  12. package/dist/{chunk-LKZQG2ZZ.cjs → chunk-6VRSFFQ4.cjs} +7 -6
  13. package/dist/chunk-6VRSFFQ4.cjs.map +1 -0
  14. package/dist/{chunk-2M3HWTRI.js → chunk-7IE4K74P.js} +4 -4
  15. package/dist/{chunk-2M3HWTRI.js.map → chunk-7IE4K74P.js.map} +1 -1
  16. package/dist/{chunk-I4ZSA3XJ.js → chunk-7V3UNILV.js} +4 -4
  17. package/dist/{chunk-I4ZSA3XJ.js.map → chunk-7V3UNILV.js.map} +1 -1
  18. package/dist/{chunk-ZRLAR66M.js → chunk-AJZQPWAV.js} +59 -19
  19. package/dist/chunk-AJZQPWAV.js.map +1 -0
  20. package/dist/{chunk-XOBRMYFA.js → chunk-BZ2MSXOF.js} +3 -3
  21. package/dist/chunk-BZ2MSXOF.js.map +1 -0
  22. package/dist/{chunk-HRT662B6.js → chunk-EAJDF6UV.js} +12 -7
  23. package/dist/chunk-EAJDF6UV.js.map +1 -0
  24. package/dist/{chunk-PWFPYJGG.cjs → chunk-EXDBQKH4.cjs} +15 -15
  25. package/dist/{chunk-PWFPYJGG.cjs.map → chunk-EXDBQKH4.cjs.map} +1 -1
  26. package/dist/{chunk-GJ62FP5X.js → chunk-HQCBFWL2.js} +18 -35
  27. package/dist/chunk-HQCBFWL2.js.map +1 -0
  28. package/dist/{chunk-UPBMT3QM.js → chunk-JTJCFEIY.js} +8 -8
  29. package/dist/{chunk-UPBMT3QM.js.map → chunk-JTJCFEIY.js.map} +1 -1
  30. package/dist/{chunk-GJIN53S6.cjs → chunk-L2GYXPJJ.cjs} +9 -9
  31. package/dist/{chunk-GJIN53S6.cjs.map → chunk-L2GYXPJJ.cjs.map} +1 -1
  32. package/dist/{chunk-2H53MD2U.cjs → chunk-LVZKPNQO.cjs} +50 -50
  33. package/dist/{chunk-2H53MD2U.cjs.map → chunk-LVZKPNQO.cjs.map} +1 -1
  34. package/dist/{chunk-MJF7NZEF.js → chunk-OLHODPXN.js} +3 -3
  35. package/dist/{chunk-MJF7NZEF.js.map → chunk-OLHODPXN.js.map} +1 -1
  36. package/dist/{chunk-6Z4GSLLO.js → chunk-OTJAMDX5.js} +3 -3
  37. package/dist/{chunk-6Z4GSLLO.js.map → chunk-OTJAMDX5.js.map} +1 -1
  38. package/dist/{chunk-EKFG6JWW.js → chunk-PB3KXPNE.js} +8 -7
  39. package/dist/chunk-PB3KXPNE.js.map +1 -0
  40. package/dist/{chunk-TVZCMQTV.cjs → chunk-QADPCUBX.cjs} +83 -82
  41. package/dist/chunk-QADPCUBX.cjs.map +1 -0
  42. package/dist/{chunk-RTBZOGTO.js → chunk-QNNFMCSE.js} +3 -3
  43. package/dist/{chunk-RTBZOGTO.js.map → chunk-QNNFMCSE.js.map} +1 -1
  44. package/dist/{chunk-7GLVV6CZ.js → chunk-RF4TETYQ.js} +4 -4
  45. package/dist/{chunk-7GLVV6CZ.js.map → chunk-RF4TETYQ.js.map} +1 -1
  46. package/dist/{chunk-XQN3BKCI.js → chunk-UJX2TJIF.js} +3 -3
  47. package/dist/{chunk-XQN3BKCI.js.map → chunk-UJX2TJIF.js.map} +1 -1
  48. package/dist/{chunk-XQRTJIC7.cjs → chunk-VEP4CV7E.cjs} +32 -3
  49. package/dist/chunk-VEP4CV7E.cjs.map +1 -0
  50. package/dist/{chunk-K7AE4BHR.js → chunk-VMBWVH4B.js} +4 -3
  51. package/dist/chunk-VMBWVH4B.js.map +1 -0
  52. package/dist/{chunk-J47RNLSY.cjs → chunk-WLNT3YJ7.cjs} +95 -55
  53. package/dist/chunk-WLNT3YJ7.cjs.map +1 -0
  54. package/dist/{chunk-L3X22YTN.cjs → chunk-WMF4CWAL.cjs} +185 -185
  55. package/dist/{chunk-L3X22YTN.cjs.map → chunk-WMF4CWAL.cjs.map} +1 -1
  56. package/dist/{chunk-4FMKWOPC.js → chunk-X4Q4KB6C.js} +31 -4
  57. package/dist/chunk-X4Q4KB6C.js.map +1 -0
  58. package/dist/{chunk-RTXCZT3M.cjs → chunk-XDZOEUNU.cjs} +19 -36
  59. package/dist/chunk-XDZOEUNU.cjs.map +1 -0
  60. package/dist/{chunk-GXXNF6NF.cjs → chunk-XNBGNCVV.cjs} +15 -10
  61. package/dist/chunk-XNBGNCVV.cjs.map +1 -0
  62. package/dist/{chunk-ZVGS2O2W.cjs → chunk-YCT2YQDL.cjs} +6 -6
  63. package/dist/{chunk-ZVGS2O2W.cjs.map → chunk-YCT2YQDL.cjs.map} +1 -1
  64. package/dist/{chunk-ZQE2VUYD.cjs → chunk-YMPV2RMB.cjs} +7 -7
  65. package/dist/{chunk-ZQE2VUYD.cjs.map → chunk-YMPV2RMB.cjs.map} +1 -1
  66. package/dist/datasets/index.cjs +17 -17
  67. package/dist/datasets/index.js +2 -2
  68. package/dist/docs/SKILL.md +8 -18
  69. package/dist/docs/assets/SOURCE_MAP.json +254 -254
  70. package/dist/docs/references/docs-agents-overview.md +4 -4
  71. package/dist/docs/references/docs-agents-processors.md +1 -1
  72. package/dist/docs/references/{docs-observability-datasets-overview.md → docs-evals-datasets-overview.md} +12 -12
  73. package/dist/docs/references/{docs-observability-datasets-running-experiments.md → docs-evals-datasets-running-experiments.md} +9 -9
  74. package/dist/docs/references/docs-evals-overview.md +8 -9
  75. package/dist/docs/references/docs-memory-observational-memory.md +20 -11
  76. package/dist/docs/references/docs-memory-overview.md +4 -4
  77. package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
  78. package/dist/docs/references/docs-memory-storage.md +4 -4
  79. package/dist/docs/references/docs-rag-chunking-and-embedding.md +2 -2
  80. package/dist/docs/references/docs-server-auth-composite-auth.md +1 -7
  81. package/dist/docs/references/docs-server-auth-custom-auth-provider.md +2 -4
  82. package/dist/docs/references/docs-server-auth-jwt.md +1 -1
  83. package/dist/docs/references/docs-server-auth-simple-auth.md +1 -7
  84. package/dist/docs/references/docs-server-custom-adapters.md +3 -1
  85. package/dist/docs/references/docs-server-custom-api-routes.md +1 -1
  86. package/dist/docs/references/docs-server-mastra-client.md +1 -3
  87. package/dist/docs/references/docs-server-mastra-server.md +8 -0
  88. package/dist/docs/references/docs-server-request-context.md +17 -17
  89. package/dist/docs/references/docs-streaming-events.md +1 -90
  90. package/dist/docs/references/docs-studio-auth.md +142 -0
  91. package/dist/docs/references/docs-studio-deployment.md +260 -0
  92. package/dist/docs/references/docs-studio-observability.md +98 -0
  93. package/dist/docs/references/docs-studio-overview.md +127 -0
  94. package/dist/docs/references/docs-workflows-agents-and-tools.md +7 -10
  95. package/dist/docs/references/docs-workflows-control-flow.md +1 -1
  96. package/dist/docs/references/docs-workflows-overview.md +12 -7
  97. package/dist/docs/references/docs-workflows-suspend-and-resume.md +1 -1
  98. package/dist/docs/references/guides-concepts-multi-agent-systems.md +4 -4
  99. package/dist/docs/references/reference-agents-agent.md +1 -1
  100. package/dist/docs/references/reference-configuration.md +4 -4
  101. package/dist/docs/references/reference-memory-observational-memory.md +1 -1
  102. package/dist/docs/references/reference-storage-cloudflare-d1.md +1 -1
  103. package/dist/docs/references/reference-storage-lance.md +1 -1
  104. package/dist/docs/references/reference-storage-upstash.md +1 -1
  105. package/dist/docs/references/reference.md +16 -14
  106. package/dist/evals/index.cjs +5 -5
  107. package/dist/evals/index.js +2 -2
  108. package/dist/evals/scoreTraces/index.cjs +3 -3
  109. package/dist/evals/scoreTraces/index.js +1 -1
  110. package/dist/harness/harness.d.ts.map +1 -1
  111. package/dist/harness/index.cjs +13 -12
  112. package/dist/harness/index.cjs.map +1 -1
  113. package/dist/harness/index.js +8 -7
  114. package/dist/harness/index.js.map +1 -1
  115. package/dist/index.cjs +2 -2
  116. package/dist/index.js +1 -1
  117. package/dist/llm/index.cjs +16 -16
  118. package/dist/llm/index.js +5 -5
  119. package/dist/llm/model/aisdk/v5/model.d.ts +5 -0
  120. package/dist/llm/model/aisdk/v5/model.d.ts.map +1 -1
  121. package/dist/llm/model/aisdk/v6/model.d.ts +5 -0
  122. package/dist/llm/model/aisdk/v6/model.d.ts.map +1 -1
  123. package/dist/llm/model/provider-types.generated.d.ts +5 -13
  124. package/dist/loop/index.cjs +14 -14
  125. package/dist/loop/index.js +1 -1
  126. package/dist/loop/network/validation.d.ts.map +1 -1
  127. package/dist/loop/workflows/agentic-execution/tool-call-step.d.ts.map +1 -1
  128. package/dist/mastra/index.cjs +2 -2
  129. package/dist/mastra/index.js +1 -1
  130. package/dist/memory/index.cjs +14 -14
  131. package/dist/memory/index.js +1 -1
  132. package/dist/models-dev-WD6XLSFC.cjs +12 -0
  133. package/dist/{models-dev-5WY37RVC.cjs.map → models-dev-WD6XLSFC.cjs.map} +1 -1
  134. package/dist/models-dev-XG4KIUFT.js +3 -0
  135. package/dist/{models-dev-Y2UFJEOO.js.map → models-dev-XG4KIUFT.js.map} +1 -1
  136. package/dist/netlify-FMBBUFKT.cjs +12 -0
  137. package/dist/{netlify-ADZQ5ZNY.cjs.map → netlify-FMBBUFKT.cjs.map} +1 -1
  138. package/dist/netlify-NDOVF45T.js +3 -0
  139. package/dist/{netlify-I4AUVRO2.js.map → netlify-NDOVF45T.js.map} +1 -1
  140. package/dist/processor-provider/index.cjs +10 -10
  141. package/dist/processor-provider/index.js +1 -1
  142. package/dist/processors/index.cjs +44 -44
  143. package/dist/processors/index.js +1 -1
  144. package/dist/provider-registry-KHXFOGCK.js +3 -0
  145. package/dist/{provider-registry-C7SZ5ZT4.js.map → provider-registry-KHXFOGCK.js.map} +1 -1
  146. package/dist/provider-registry-VUG7E4SG.cjs +40 -0
  147. package/dist/{provider-registry-I5RW3MEE.cjs.map → provider-registry-VUG7E4SG.cjs.map} +1 -1
  148. package/dist/provider-registry.json +14 -31
  149. package/dist/relevance/index.cjs +3 -3
  150. package/dist/relevance/index.js +1 -1
  151. package/dist/storage/index.cjs +74 -74
  152. package/dist/storage/index.js +1 -1
  153. package/dist/stream/aisdk/v5/compat/prepare-tools.d.ts.map +1 -1
  154. package/dist/stream/index.cjs +8 -8
  155. package/dist/stream/index.js +1 -1
  156. package/dist/test-utils/llm-mock.cjs +4 -4
  157. package/dist/test-utils/llm-mock.js +1 -1
  158. package/dist/tool-loop-agent/index.cjs +4 -4
  159. package/dist/tool-loop-agent/index.js +1 -1
  160. package/dist/tools/tool-builder/builder.d.ts.map +1 -1
  161. package/dist/utils.cjs +31 -23
  162. package/dist/utils.d.ts +10 -0
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +1 -1
  165. package/dist/vector/index.cjs +7 -7
  166. package/dist/vector/index.js +1 -1
  167. package/dist/workflows/evented/index.cjs +10 -10
  168. package/dist/workflows/evented/index.js +1 -1
  169. package/dist/workflows/index.cjs +24 -24
  170. package/dist/workflows/index.js +1 -1
  171. package/dist/workflows/workflow.d.ts.map +1 -1
  172. package/dist/workspace/index.cjs +68 -68
  173. package/dist/workspace/index.js +1 -1
  174. package/dist/workspace/workspace.d.ts +1 -0
  175. package/dist/workspace/workspace.d.ts.map +1 -1
  176. package/package.json +2 -2
  177. package/src/llm/model/provider-types.generated.d.ts +5 -13
  178. package/dist/chunk-4FMKWOPC.js.map +0 -1
  179. package/dist/chunk-EKFG6JWW.js.map +0 -1
  180. package/dist/chunk-GJ62FP5X.js.map +0 -1
  181. package/dist/chunk-GXXNF6NF.cjs.map +0 -1
  182. package/dist/chunk-HRT662B6.js.map +0 -1
  183. package/dist/chunk-J47RNLSY.cjs.map +0 -1
  184. package/dist/chunk-K7AE4BHR.js.map +0 -1
  185. package/dist/chunk-KLVNQDUR.cjs.map +0 -1
  186. package/dist/chunk-LKZQG2ZZ.cjs.map +0 -1
  187. package/dist/chunk-RTXCZT3M.cjs.map +0 -1
  188. package/dist/chunk-TVZCMQTV.cjs.map +0 -1
  189. package/dist/chunk-XOBRMYFA.js.map +0 -1
  190. package/dist/chunk-XQRTJIC7.cjs.map +0 -1
  191. package/dist/chunk-ZRLAR66M.js.map +0 -1
  192. package/dist/docs/references/docs-observability-logging.md +0 -99
  193. package/dist/docs/references/docs-observability-overview.md +0 -70
  194. package/dist/docs/references/docs-observability-tracing-bridges-otel.md +0 -209
  195. package/dist/docs/references/docs-observability-tracing-exporters-arize.md +0 -272
  196. package/dist/docs/references/docs-observability-tracing-exporters-braintrust.md +0 -126
  197. package/dist/docs/references/docs-observability-tracing-exporters-cloud.md +0 -127
  198. package/dist/docs/references/docs-observability-tracing-exporters-datadog.md +0 -317
  199. package/dist/docs/references/docs-observability-tracing-exporters-default.md +0 -209
  200. package/dist/docs/references/docs-observability-tracing-exporters-laminar.md +0 -100
  201. package/dist/docs/references/docs-observability-tracing-exporters-langfuse.md +0 -213
  202. package/dist/docs/references/docs-observability-tracing-exporters-langsmith.md +0 -198
  203. package/dist/docs/references/docs-observability-tracing-exporters-otel.md +0 -476
  204. package/dist/docs/references/docs-observability-tracing-exporters-posthog.md +0 -148
  205. package/dist/docs/references/docs-observability-tracing-overview.md +0 -1112
  206. package/dist/models-dev-5WY37RVC.cjs +0 -12
  207. package/dist/models-dev-Y2UFJEOO.js +0 -3
  208. package/dist/netlify-ADZQ5ZNY.cjs +0 -12
  209. package/dist/netlify-I4AUVRO2.js +0 -3
  210. package/dist/provider-registry-C7SZ5ZT4.js +0 -3
  211. package/dist/provider-registry-I5RW3MEE.cjs +0 -40
@@ -145,93 +145,4 @@ Each progress event includes:
145
145
  - **`totalCount`**: Total number of iterations
146
146
  - **`currentIndex`**: Index of the iteration that completed
147
147
  - **`iterationStatus`**: Status of the iteration (`success`, `failed`, or `suspended`)
148
- - **`iterationOutput`**: Output of the iteration (when successful)
149
-
150
- ## Inspecting agent networks
151
-
152
- When using multi-agent collaboration with `agent.network()`, iterate over the stream to track how tasks are delegated and executed across agents, workflows, and tools.
153
-
154
- ```typescript
155
- const networkAgent = mastra.getAgent('networkAgent')
156
-
157
- const networkStream = await networkAgent.network('Research dolphins then write a report')
158
-
159
- for await (const chunk of networkStream) {
160
- console.log(chunk)
161
- }
162
- ```
163
-
164
- > **Info:** Visit [Agent.network()](https://mastra.ai/reference/agents/network) for more information.
165
-
166
- ### Example network output
167
-
168
- Network streams emit events that track the orchestration flow. Each iteration begins with routing, followed by execution of the selected primitive.
169
-
170
- ```typescript
171
- // Routing agent decides what to do
172
- {
173
- type: 'routing-agent-start',
174
- from: 'NETWORK',
175
- runId: '7a3b9c2d-1e4f-5a6b-8c9d-0e1f2a3b4c5d',
176
- payload: {
177
- agentId: 'routing-agent',
178
- // ...
179
- }
180
- }
181
- // Routing agent makes a selection
182
- {
183
- type: 'routing-agent-end',
184
- from: 'NETWORK',
185
- runId: '7a3b9c2d-1e4f-5a6b-8c9d-0e1f2a3b4c5d',
186
- payload: {
187
- // ...
188
- }
189
- }
190
- // Delegated agent begins execution
191
- {
192
- type: 'agent-execution-start',
193
- from: 'NETWORK',
194
- runId: '8b4c0d3e-2f5a-6b7c-9d0e-1f2a3b4c5d6e',
195
- payload: {
196
- // ...
197
- }
198
- }
199
- // Events from the delegated agent's execution
200
- {
201
- type: 'agent-execution-event-text-delta',
202
- from: 'NETWORK',
203
- runId: '8b4c0d3e-2f5a-6b7c-9d0e-1f2a3b4c5d6e',
204
- payload: {
205
- type: 'text-delta',
206
- payload: {
207
- // ...
208
- }
209
- }
210
- }
211
- ```
212
-
213
- ### Filtering network events
214
-
215
- You can filter events by type to track specific aspects of the network execution:
216
-
217
- ```typescript
218
- const networkStream = await networkAgent.network('Analyze data and create visualization')
219
-
220
- for await (const chunk of networkStream) {
221
- // Track routing decisions
222
- if (chunk.type === 'routing-agent-end') {
223
- console.log('Selected:', chunk.payload.resourceType, chunk.payload.resourceId)
224
- console.log('Reason:', chunk.payload.selectionReason)
225
- }
226
-
227
- // Track agent delegations
228
- if (chunk.type === 'agent-execution-start') {
229
- console.log('Delegating to agent:', chunk.payload.agentId)
230
- }
231
-
232
- // Track workflow delegations
233
- if (chunk.type === 'workflow-execution-start') {
234
- console.log('Executing workflow:', chunk.payload.name)
235
- }
236
- }
237
- ```
148
+ - **`iterationOutput`**: Output of the iteration (when successful)
@@ -0,0 +1,142 @@
1
+ # Studio auth
2
+
3
+ When you configure [authentication](https://mastra.ai/docs/server/auth) on your Mastra server, Studio automatically displays a login screen and enforces access control. One configuration secures both the Studio UI and your API routes.
4
+
5
+ Without authentication, Studio and all API routes are publicly accessible.
6
+
7
+ ## When to use Studio Auth
8
+
9
+ - Multiple team members need to interact with agents, workflows, and tools through a shared Studio deployment.
10
+ - Permissions must restrict who can execute agents, edit workflows, or delete datasets.
11
+ - A login screen (SSO, email/password, or both) should gate access to your Studio deployment.
12
+
13
+ ## Quickstart
14
+
15
+ Add an auth provider to your Mastra server configuration. This example uses [Simple Auth](https://mastra.ai/docs/server/auth/simple-auth) for a minimal setup:
16
+
17
+ ```typescript
18
+ import { Mastra } from '@mastra/core'
19
+ import { SimpleAuth } from '@mastra/core/server'
20
+
21
+ export const mastra = new Mastra({
22
+ server: {
23
+ auth: new SimpleAuth({
24
+ users: {
25
+ 'my-api-key': {
26
+ id: 'user-1',
27
+ name: 'Alice',
28
+ role: 'admin',
29
+ },
30
+ },
31
+ }),
32
+ },
33
+ })
34
+ ```
35
+
36
+ Once configured, Studio shows a login screen and requires authentication for all API requests.
37
+
38
+ > **Note:** Visit the [Auth docs](https://mastra.ai/docs/server/auth) for a full list of supported providers.
39
+
40
+ ## How it works
41
+
42
+ Setting [`server.auth`](https://mastra.ai/reference/configuration) does two things at once:
43
+
44
+ - **Studio UI**: Displays a login screen. Depending on the provider, users sign in through SSO, email/password, or both.
45
+ - **API routes**: Requires authentication for all built-in routes (`/api/agents/*`, `/api/workflows/*`, etc.) and custom routes. This applies whether requests come from Studio or direct API calls.
46
+
47
+ Studio detects available capabilities by calling the `GET /api/auth/capabilities` endpoint. The response tells Studio which login methods to render and, if the user is already authenticated, includes their user info and permissions.
48
+
49
+ ## Role-based access control
50
+
51
+ RBAC lets you control what each user can see and do inside Studio. It's separate from authentication: `server.auth` handles who the user is, while `server.rbac` handles what they can do.
52
+
53
+ ### Default roles
54
+
55
+ Mastra ships four default roles. Import them from `@mastra/core/auth/ee`:
56
+
57
+ | Role | Permissions |
58
+ | -------- | ------------------------ |
59
+ | `owner` | Full access (`*`) |
60
+ | `admin` | Read, write, and execute |
61
+ | `member` | Read and execute |
62
+ | `viewer` | Read-only |
63
+
64
+ ### Enable RBAC
65
+
66
+ Use `StaticRBACProvider` with the default roles or define your own:
67
+
68
+ ```typescript
69
+ import { Mastra } from '@mastra/core'
70
+ import { SimpleAuth } from '@mastra/core/server'
71
+ import { StaticRBACProvider, DEFAULT_ROLES } from '@mastra/core/auth/ee'
72
+
73
+ export const mastra = new Mastra({
74
+ server: {
75
+ auth: new SimpleAuth({
76
+ users: {
77
+ 'admin-key': { id: 'user-1', name: 'Alice', role: 'admin' },
78
+ 'viewer-key': { id: 'user-2', name: 'Bob', role: 'viewer' },
79
+ },
80
+ }),
81
+ rbac: new StaticRBACProvider({
82
+ roles: DEFAULT_ROLES,
83
+ getUserRoles: user => [user.role],
84
+ }),
85
+ },
86
+ })
87
+ ```
88
+
89
+ When RBAC is active, Studio hides actions the user doesn't have permission for. A viewer doesn't see delete buttons; a member can't modify agent configurations.
90
+
91
+ ### Permission format
92
+
93
+ Permissions follow the pattern `{resource}:{action}`, with optional resource-level scoping:
94
+
95
+ | Pattern | Meaning |
96
+ | ------------------- | --------------------------- |
97
+ | `*` | Full access to everything |
98
+ | `*:read` | Read all resources |
99
+ | `agents:*` | All actions on agents |
100
+ | `agents:execute` | Execute agents only |
101
+ | `agents:read:my-id` | Read a specific agent by ID |
102
+
103
+ Resources include `agents`, `workflows`, `tools`, `datasets`, `memory`, `scores`, `observability`, and others. Actions are `read`, `write`, `execute`, and `delete`.
104
+
105
+ ### Map external provider roles
106
+
107
+ If your identity provider already defines roles (for example, Clerk organizations or WorkOS groups), map them to Mastra permissions with `roleMapping`:
108
+
109
+ ```typescript
110
+ import { StaticRBACProvider } from '@mastra/core/auth/ee'
111
+
112
+ const rbac = new StaticRBACProvider({
113
+ roleMapping: {
114
+ 'org:admin': ['*'],
115
+ 'org:member': ['*:read', '*:execute'],
116
+ 'org:viewer': ['*:read'],
117
+ },
118
+ getUserRoles: user => user.providerRoles,
119
+ })
120
+ ```
121
+
122
+ ## Login methods
123
+
124
+ Studio adapts its login screen based on the auth provider:
125
+
126
+ | Provider type | Login UI |
127
+ | ---------------- | --------------------------------------- |
128
+ | SSO only | SSO button (e.g. "Sign in with WorkOS") |
129
+ | Credentials only | Email and password form |
130
+ | Both | SSO button and email/password form |
131
+
132
+ Sign-up can be enabled or disabled per provider. When disabled, Studio hides the sign-up link and forces the sign-in form.
133
+
134
+ ## EE licensing
135
+
136
+ Studio Auth features (SSO login, RBAC, permission-based UI) are part of the Mastra Enterprise Edition. They work without a license during local development and with Simple Auth. For production deployments with third-party providers, a valid EE license is required. [Contact sales](https://mastra.ai/contact) for more information.
137
+
138
+ ## Related
139
+
140
+ - [Auth overview](https://mastra.ai/docs/server/auth): Full list of supported auth providers.
141
+ - [Studio deployment](https://mastra.ai/docs/studio/deployment): Deploy Studio to production.
142
+ - [Custom API routes](https://mastra.ai/docs/server/custom-api-routes): Control authentication on individual endpoints.
@@ -0,0 +1,260 @@
1
+ # Studio deployment
2
+
3
+ Studio is a React-based Single Page Application (SPA) that runs in the browser and connects to a running [Mastra server](https://mastra.ai/docs/deployment/mastra-server).
4
+
5
+ You can deploy Studio in two primary ways:
6
+
7
+ - [Cloud](https://mastra.ai/docs/mastra-cloud/overview) hosts Studio for you and allows you to share access with your team via link
8
+ - You can self-host Studio on your own infrastructure, either alongside your Mastra server or separately as a standalone SPA
9
+
10
+ On this page you'll learn how to deploy Studio on your own infrastructure. As the finer details of deployment can vary widely based on your needs and setup, we'll cover the general principles and options available to you.
11
+
12
+ ## Quickstart
13
+
14
+ The easiest way to run Studio is the [`mastra studio`](https://mastra.ai/reference/cli/mastra) command.
15
+
16
+ Whereas `mastra dev` runs both Studio and an API for development purposes, the purpose of `mastra studio` is to serve a standalone, static UI that connects to an already-running Mastra server. This allows you to deploy Studio on its own, separate from the Mastra server, if desired.
17
+
18
+ Open a terminal and install the `mastra` CLI globally:
19
+
20
+ **npm**:
21
+
22
+ ```bash
23
+ npm install -g mastra
24
+ ```
25
+
26
+ **pnpm**:
27
+
28
+ ```bash
29
+ pnpm add -g mastra
30
+ ```
31
+
32
+ **Yarn**:
33
+
34
+ ```bash
35
+ yarn global add mastra
36
+ ```
37
+
38
+ **Bun**:
39
+
40
+ ```bash
41
+ bun add --global mastra
42
+ ```
43
+
44
+ Run the `mastra studio` command:
45
+
46
+ ```bash
47
+ mastra studio
48
+ ```
49
+
50
+ Open [localhost:3000](http://localhost:3000) in your browser to see the Studio UI. By default, it will attempt to connect to a Mastra server running at `http://localhost:4111`. If it doesn't find one there, you'll see a form where you can enter your Mastra instance URL and API prefix.
51
+
52
+ If you're hosting Studio under a subpath (for example `/agents` behind Nginx), set `MASTRA_STUDIO_BASE_PATH` before starting Studio:
53
+
54
+ ```bash
55
+ MASTRA_STUDIO_BASE_PATH=/agents mastra studio
56
+ ```
57
+
58
+ This updates the HTML base URL and static asset routing so the standalone Studio works correctly under that subpath.
59
+
60
+ The command uses Node's built-in `http` module and [`serve-handler`](https://www.npmjs.com/package/serve-handler) to serve the static files.
61
+
62
+ ## Running a server
63
+
64
+ Running `mastra studio` as a long-running process is no different from running any other Node.js service. All the best practices, tools, and options for deployment apply here as well. You can use process managers like PM2, use Docker, or cloud services that support Node.js applications. You'll need to ensure CORS is configured correctly and errors are monitored, as with any web service.
65
+
66
+ > **Warning:** Once Studio is connected to your Mastra server, it has full access to your agents, workflows, and tools. Be sure to secure it properly in production (e.g. behind authentication, VPN, etc.) to prevent unauthorized access.
67
+ >
68
+ > Visit the [Authentication](https://mastra.ai/docs/studio/auth) docs to learn more.
69
+
70
+ ### Alongside your API
71
+
72
+ Alternatively, you can serve Studio alongside your [Mastra server](https://mastra.ai/docs/deployment/mastra-server). This way you only have one service to deploy and manage.
73
+
74
+ To do this, run `mastra build` with the `--studio` flag:
75
+
76
+ ```bash
77
+ mastra build --studio
78
+ ```
79
+
80
+ It'll create a `.mastra/output/studio` folder with the built Studio assets. By defining the `MASTRA_STUDIO_PATH` environment variable, the Mastra server can serve the Studio UI, too.
81
+
82
+ ```bash
83
+ MASTRA_STUDIO_PATH=.mastra/output/studio node .mastra/output/index.mjs
84
+ ```
85
+
86
+ ## Using a CDN
87
+
88
+ ### Automatic
89
+
90
+ Some of the [Cloud providers](https://mastra.ai/docs/deployment/cloud-providers) offer an option to deploy Studio alongside your serverless function. Currently, the supported providers are:
91
+
92
+ - [`VercelDeployer`](https://mastra.ai/reference/deployer/vercel)
93
+
94
+ ### Manual
95
+
96
+ You can't directly deploy the built Studio assets to a CDN, as the UI relies on some dynamic configuration. With a bit of extra setup, you can create a standalone SPA out of the built assets and deploy it to any static hosting service.
97
+
98
+ Follow the example below to create a SPA using Vite.
99
+
100
+ 1. Create a new folder and initialize a new Node.js project:
101
+
102
+ **npm**:
103
+
104
+ ```bash
105
+ mkdir studio-spa
106
+ cd studio-spa
107
+ npm init
108
+ ```
109
+
110
+ **pnpm**:
111
+
112
+ ```bash
113
+ mkdir studio-spa
114
+ cd studio-spa
115
+ pnpm init
116
+ ```
117
+
118
+ **Yarn**:
119
+
120
+ ```bash
121
+ mkdir studio-spa
122
+ cd studio-spa
123
+ yarn init
124
+ ```
125
+
126
+ **Bun**:
127
+
128
+ ```bash
129
+ mkdir studio-spa
130
+ cd studio-spa
131
+ bun init
132
+ ```
133
+
134
+ 2. Install `vite` and `mastra` as dependencies:
135
+
136
+ **npm**:
137
+
138
+ ```bash
139
+ npm install vite mastra
140
+ ```
141
+
142
+ **pnpm**:
143
+
144
+ ```bash
145
+ pnpm add vite mastra
146
+ ```
147
+
148
+ **Yarn**:
149
+
150
+ ```bash
151
+ yarn add vite mastra
152
+ ```
153
+
154
+ **Bun**:
155
+
156
+ ```bash
157
+ bun add vite mastra
158
+ ```
159
+
160
+ 3. Add a build script to your `package.json`:
161
+
162
+ ```json
163
+ {
164
+ "scripts": {
165
+ "build": "vite build"
166
+ }
167
+ }
168
+ ```
169
+
170
+ 4. Create a placeholder `index.html` file:
171
+
172
+ ```html
173
+ <!doctype html>
174
+ <html>
175
+ <head></head>
176
+ <body></body>
177
+ </html>
178
+ ```
179
+
180
+ 5. Create a `vite.config.js` file. It copies the built Studio assets to the `dist` folder and replaces any `%%PLACEHOLDER%%` values in the HTML with environment variable values.
181
+
182
+ ```js
183
+ import { defineConfig, loadEnv } from 'vite'
184
+ import { readFileSync, cpSync, writeFileSync } from 'node:fs'
185
+ import { resolve, join } from 'node:path'
186
+
187
+ const studioDir = resolve(import.meta.dirname, 'node_modules/mastra/dist/studio')
188
+
189
+ export default defineConfig(({ mode }) => {
190
+ const env = loadEnv(mode, process.cwd(), 'MASTRA_')
191
+
192
+ return {
193
+ plugins: [
194
+ {
195
+ name: 'mastra-studio',
196
+ closeBundle() {
197
+ const outDir = resolve(import.meta.dirname, 'dist')
198
+ cpSync(studioDir, outDir, { recursive: true })
199
+
200
+ const indexPath = join(outDir, 'index.html')
201
+ const html = readFileSync(indexPath, 'utf-8')
202
+ writeFileSync(
203
+ indexPath,
204
+ html.replaceAll(/%%(\w+)%%/g, (_, key) => env[key] ?? ''),
205
+ )
206
+ },
207
+ },
208
+ ],
209
+ build: {
210
+ emptyOutDir: true,
211
+ },
212
+ }
213
+ })
214
+ ```
215
+
216
+ 6. Create a `.env` file with the necessary environment variables.
217
+
218
+ ```env
219
+ MASTRA_SERVER_HOST=localhost
220
+ MASTRA_SERVER_PORT=4111
221
+ MASTRA_SERVER_PROTOCOL=http
222
+ MASTRA_API_PREFIX=/api
223
+ MASTRA_HIDE_CLOUD_CTA=false
224
+ MASTRA_CLOUD_API_ENDPOINT=
225
+ MASTRA_EXPERIMENTAL_FEATURES=false
226
+ MASTRA_TEMPLATES=false
227
+ MASTRA_TELEMETRY_DISABLED=true
228
+ MASTRA_REQUEST_CONTEXT_PRESETS=
229
+ MASTRA_THEME_TOGGLE=false
230
+ MASTRA_EXPERIMENTAL_UI=false
231
+ MASTRA_STUDIO_BASE_PATH=
232
+ ```
233
+
234
+ 7. Run the build script to generate the static files in the `dist` folder:
235
+
236
+ **npm**:
237
+
238
+ ```bash
239
+ npm run build
240
+ ```
241
+
242
+ **pnpm**:
243
+
244
+ ```bash
245
+ pnpm run build
246
+ ```
247
+
248
+ **Yarn**:
249
+
250
+ ```bash
251
+ yarn build
252
+ ```
253
+
254
+ **Bun**:
255
+
256
+ ```bash
257
+ bun run build
258
+ ```
259
+
260
+ 8. Point your hosting provider to the `dist` folder and deploy!
@@ -0,0 +1,98 @@
1
+ # Studio observability
2
+
3
+ Studio includes these observability views:
4
+
5
+ - **Metrics** for aggregate performance data
6
+ - **Traces** for individual request inspection
7
+
8
+ All require an [observability storage backend](#quickstart) to be configured.
9
+
10
+ ## Metrics
11
+
12
+ A dashboard that summarizes agent, workflow, and tool performance over a configurable time range (last 24 hours to 30 days). The top row shows total agent runs, model cost, token consumption, and average scorer performance. Below that, detailed cards break down model usage and cost per model, token usage per agent, trace volume with completed and error counts, latency percentiles (p50 and p95), and scorer trends over time.
13
+
14
+ Visit the [metrics overview](https://mastra.ai/docs/observability/metrics/overview) for more details.
15
+
16
+ > **Note:** Metrics require a separate OLAP store for observability. Relational databases like PostgreSQL, LibSQL, etc. are not supported for metrics. In-memory storage resets on restart.
17
+
18
+ ## Traces
19
+
20
+ When you run an agent or workflow, the Observability tab displays traces that highlight the key AI operations such as model calls, tool executions, and workflow steps. Follow these traces to see how data moves, where time is spent, and what's happening under the hood.
21
+
22
+ Tracing filters out low-level framework details so your traces stay focused and readable. Visit the [tracing overview](https://mastra.ai/docs/observability/tracing/overview) for more details.
23
+
24
+ ## Quickstart
25
+
26
+ For detailed instructions, follow the [observability instructions](https://mastra.ai/docs/observability/overview). To get up and running quickly, add the `@mastra/observability` package to your project and configure it with [LibSQL](https://mastra.ai/reference/storage/libsql) and [DuckDB](https://mastra.ai/reference/vectors/duckdb) for a local development setup that supports both traces and metrics.
27
+
28
+ **npm**:
29
+
30
+ ```bash
31
+ npm install @mastra/observability @mastra/libsql @mastra/duckdb
32
+ ```
33
+
34
+ **pnpm**:
35
+
36
+ ```bash
37
+ pnpm add @mastra/observability @mastra/libsql @mastra/duckdb
38
+ ```
39
+
40
+ **Yarn**:
41
+
42
+ ```bash
43
+ yarn add @mastra/observability @mastra/libsql @mastra/duckdb
44
+ ```
45
+
46
+ **Bun**:
47
+
48
+ ```bash
49
+ bun add @mastra/observability @mastra/libsql @mastra/duckdb
50
+ ```
51
+
52
+ Then add the following to your `src/mastra/index.ts`:
53
+
54
+ ```ts
55
+ import { Mastra } from '@mastra/core/mastra'
56
+ import { LibSQLStore } from '@mastra/libsql'
57
+ import { DuckDBStore } from '@mastra/duckdb'
58
+ import { MastraCompositeStore } from '@mastra/core/storage'
59
+ import {
60
+ Observability,
61
+ DefaultExporter,
62
+ CloudExporter,
63
+ SensitiveDataFilter,
64
+ } from '@mastra/observability'
65
+
66
+ export const mastra = new Mastra({
67
+ storage: new MastraCompositeStore({
68
+ id: 'composite-storage',
69
+ default: new LibSQLStore({
70
+ id: 'mastra-storage',
71
+ url: 'file:./mastra.db',
72
+ }),
73
+ domains: {
74
+ observability: await new DuckDBStore().getStore('observability'),
75
+ },
76
+ }),
77
+ observability: new Observability({
78
+ configs: {
79
+ default: {
80
+ serviceName: 'mastra',
81
+ exporters: [
82
+ new DefaultExporter(), // Persists traces to storage for Mastra Studio
83
+ new CloudExporter(), // Sends traces to Mastra Cloud (if MASTRA_CLOUD_ACCESS_TOKEN is set)
84
+ ],
85
+ spanOutputProcessors: [
86
+ new SensitiveDataFilter(), // Redacts sensitive data like passwords, tokens, keys
87
+ ],
88
+ },
89
+ },
90
+ }),
91
+ })
92
+ ```
93
+
94
+ ## Related
95
+
96
+ - [Observability overview](https://mastra.ai/docs/observability/overview)
97
+ - [Metrics overview](https://mastra.ai/docs/observability/metrics/overview)
98
+ - [Tracing overview](https://mastra.ai/docs/observability/tracing/overview)