@mastra/mcp-docs-server 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012

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 (285) hide show
  1. package/.docs/docs/agents/adding-voice.md +18 -17
  2. package/.docs/docs/agents/background-tasks.md +242 -0
  3. package/.docs/docs/agents/channels.md +2 -1
  4. package/.docs/docs/agents/overview.md +4 -0
  5. package/.docs/docs/agents/processors.md +177 -5
  6. package/.docs/docs/agents/structured-output.md +66 -1
  7. package/.docs/docs/agents/supervisor-agents.md +65 -0
  8. package/.docs/docs/agents/using-tools.md +73 -0
  9. package/.docs/docs/browser/agent-browser.md +78 -0
  10. package/.docs/docs/browser/browser-viewer.md +144 -0
  11. package/.docs/docs/browser/overview.md +168 -0
  12. package/.docs/docs/browser/stagehand.md +129 -0
  13. package/.docs/docs/deployment/cloud-providers.md +5 -1
  14. package/.docs/docs/deployment/mastra-server.md +4 -4
  15. package/.docs/docs/deployment/monorepo.md +3 -3
  16. package/.docs/docs/deployment/overview.md +11 -8
  17. package/.docs/docs/editor/overview.md +290 -0
  18. package/.docs/docs/editor/prompts.md +134 -0
  19. package/.docs/docs/editor/tools.md +152 -0
  20. package/.docs/docs/evals/custom-scorers.md +63 -3
  21. package/.docs/docs/evals/datasets/overview.md +1 -1
  22. package/.docs/docs/index.md +2 -2
  23. package/.docs/docs/mastra-platform/configuration.md +36 -0
  24. package/.docs/docs/mastra-platform/overview.md +78 -0
  25. package/.docs/docs/mcp/overview.md +17 -0
  26. package/.docs/docs/memory/memory-processors.md +3 -3
  27. package/.docs/docs/memory/message-history.md +8 -2
  28. package/.docs/docs/memory/observational-memory.md +65 -8
  29. package/.docs/docs/memory/storage.md +1 -2
  30. package/.docs/docs/memory/working-memory.md +2 -2
  31. package/.docs/docs/observability/logging.md +1 -1
  32. package/.docs/docs/observability/metrics/overview.md +2 -2
  33. package/.docs/docs/observability/overview.md +1 -1
  34. package/.docs/docs/observability/tracing/bridges/datadog.md +217 -0
  35. package/.docs/docs/observability/tracing/bridges/otel.md +2 -2
  36. package/.docs/docs/observability/tracing/exporters/arthur.md +163 -0
  37. package/.docs/docs/observability/tracing/exporters/cloud.md +135 -63
  38. package/.docs/docs/observability/tracing/exporters/datadog.md +3 -1
  39. package/.docs/docs/observability/tracing/exporters/default.md +5 -5
  40. package/.docs/docs/observability/tracing/exporters/laminar.md +22 -14
  41. package/.docs/docs/observability/tracing/exporters/langfuse.md +50 -33
  42. package/.docs/docs/observability/tracing/overview.md +87 -20
  43. package/.docs/docs/server/custom-adapters.md +5 -5
  44. package/.docs/docs/server/custom-api-routes.md +3 -3
  45. package/.docs/docs/server/mastra-client.md +2 -2
  46. package/.docs/docs/server/mastra-server.md +1 -1
  47. package/.docs/docs/server/middleware.md +46 -42
  48. package/.docs/docs/server/request-context.md +13 -2
  49. package/.docs/docs/server/server-adapters.md +91 -8
  50. package/.docs/docs/streaming/background-task-streaming.md +80 -0
  51. package/.docs/docs/streaming/overview.md +3 -0
  52. package/.docs/docs/studio/deployment.md +24 -6
  53. package/.docs/docs/studio/observability.md +1 -1
  54. package/.docs/docs/studio/overview.md +4 -4
  55. package/.docs/docs/voice/overview.md +74 -5
  56. package/.docs/docs/voice/speech-to-speech.md +45 -1
  57. package/.docs/docs/voice/speech-to-text.md +7 -7
  58. package/.docs/docs/voice/text-to-speech.md +10 -10
  59. package/.docs/docs/workflows/agents-and-tools.md +1 -1
  60. package/.docs/docs/workflows/overview.md +105 -4
  61. package/.docs/docs/workflows/scheduled-workflows.md +181 -0
  62. package/.docs/docs/workspace/filesystem.md +64 -6
  63. package/.docs/docs/workspace/lsp.md +76 -4
  64. package/.docs/docs/workspace/overview.md +62 -15
  65. package/.docs/docs/workspace/sandbox.md +3 -1
  66. package/.docs/docs/workspace/search.md +41 -2
  67. package/.docs/docs/workspace/skills.md +19 -19
  68. package/.docs/guides/agent-frameworks/ai-sdk.md +4 -4
  69. package/.docs/guides/build-your-ui/ai-sdk-ui.md +56 -9
  70. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  71. package/.docs/guides/deployment/mastra-platform.md +191 -0
  72. package/.docs/guides/deployment/netlify.md +16 -1
  73. package/.docs/guides/getting-started/nestjs.md +238 -0
  74. package/.docs/guides/getting-started/next-js.md +0 -4
  75. package/.docs/guides/guide/code-review-bot.md +2 -2
  76. package/.docs/guides/guide/dev-assistant.md +4 -4
  77. package/.docs/{docs/mcp → guides/guide}/publishing-mcp-server.md +21 -1
  78. package/.docs/guides/guide/slack-assistant.md +191 -0
  79. package/.docs/guides/migrations/mastra-cloud.md +368 -0
  80. package/.docs/guides/migrations/upgrade-to-v1/tracing.md +1 -1
  81. package/.docs/models/embeddings.md +3 -3
  82. package/.docs/models/gateways/azure-openai.md +74 -35
  83. package/.docs/models/gateways/mastra.md +64 -0
  84. package/.docs/models/gateways/netlify.md +7 -3
  85. package/.docs/models/gateways/openrouter.md +28 -12
  86. package/.docs/models/gateways/vercel.md +22 -2
  87. package/.docs/models/gateways.md +1 -0
  88. package/.docs/models/index.md +43 -8
  89. package/.docs/models/providers/302ai.md +37 -4
  90. package/.docs/models/providers/abliteration-ai.md +71 -0
  91. package/.docs/models/providers/alibaba-cn.md +8 -2
  92. package/.docs/models/providers/alibaba-coding-plan-cn.md +3 -2
  93. package/.docs/models/providers/alibaba-coding-plan.md +3 -2
  94. package/.docs/models/providers/alibaba.md +8 -1
  95. package/.docs/models/providers/anthropic.md +18 -5
  96. package/.docs/models/providers/baseten.md +3 -1
  97. package/.docs/models/providers/berget.md +10 -12
  98. package/.docs/models/providers/chutes.md +4 -2
  99. package/.docs/models/providers/cloudflare-workers-ai.md +14 -48
  100. package/.docs/models/providers/cortecs.md +22 -2
  101. package/.docs/models/providers/deepinfra.md +8 -2
  102. package/.docs/models/providers/deepseek.md +6 -4
  103. package/.docs/models/providers/digitalocean.md +133 -0
  104. package/.docs/models/providers/fireworks-ai.md +6 -1
  105. package/.docs/models/providers/firmware.md +12 -10
  106. package/.docs/models/providers/friendli.md +6 -7
  107. package/.docs/models/providers/google.md +9 -3
  108. package/.docs/models/providers/helicone.md +1 -2
  109. package/.docs/models/providers/hpc-ai.md +73 -0
  110. package/.docs/models/providers/huggingface.md +6 -2
  111. package/.docs/models/providers/inception.md +9 -11
  112. package/.docs/models/providers/kilo.md +359 -339
  113. package/.docs/models/providers/kimi-for-coding.md +2 -1
  114. package/.docs/models/providers/llmgateway.md +67 -77
  115. package/.docs/models/providers/mistral.md +3 -2
  116. package/.docs/models/providers/mixlayer.md +75 -0
  117. package/.docs/models/providers/moonshotai-cn.md +3 -2
  118. package/.docs/models/providers/moonshotai.md +3 -2
  119. package/.docs/models/providers/nano-gpt.md +8 -2
  120. package/.docs/models/providers/neuralwatt.md +84 -0
  121. package/.docs/models/providers/novita-ai.md +19 -4
  122. package/.docs/models/providers/nvidia.md +8 -1
  123. package/.docs/models/providers/ollama-cloud.md +7 -2
  124. package/.docs/models/providers/openai.md +7 -2
  125. package/.docs/models/providers/opencode-go.md +21 -13
  126. package/.docs/models/providers/opencode.md +11 -4
  127. package/.docs/models/providers/ovhcloud.md +6 -8
  128. package/.docs/models/providers/poe.md +10 -15
  129. package/.docs/models/providers/regolo-ai.md +83 -0
  130. package/.docs/models/providers/siliconflow-cn.md +5 -2
  131. package/.docs/models/providers/siliconflow.md +6 -3
  132. package/.docs/models/providers/stepfun.md +8 -7
  133. package/.docs/models/providers/synthetic.md +5 -2
  134. package/.docs/models/providers/tencent-token-plan.md +71 -0
  135. package/.docs/models/providers/tencent-tokenhub.md +71 -0
  136. package/.docs/models/providers/togetherai.md +8 -7
  137. package/.docs/models/providers/vivgrid.md +7 -3
  138. package/.docs/models/providers/vultr.md +7 -6
  139. package/.docs/models/providers/wafer.ai.md +73 -0
  140. package/.docs/models/providers/wandb.md +3 -2
  141. package/.docs/models/providers/xai.md +6 -1
  142. package/.docs/models/providers/xiaomi-token-plan-ams.md +75 -0
  143. package/.docs/models/providers/xiaomi-token-plan-cn.md +75 -0
  144. package/.docs/models/providers/xiaomi-token-plan-sgp.md +75 -0
  145. package/.docs/models/providers/xiaomi.md +4 -2
  146. package/.docs/models/providers/zai-coding-plan.md +11 -19
  147. package/.docs/models/providers/zai.md +2 -1
  148. package/.docs/models/providers/zenmux.md +17 -6
  149. package/.docs/models/providers/zhipuai-coding-plan.md +11 -21
  150. package/.docs/models/providers/zhipuai.md +2 -1
  151. package/.docs/models/providers.md +11 -0
  152. package/.docs/reference/agents/agent.md +1 -1
  153. package/.docs/reference/agents/channels.md +3 -3
  154. package/.docs/reference/agents/generate.md +88 -6
  155. package/.docs/reference/agents/generateLegacy.md +1 -1
  156. package/.docs/reference/ai-sdk/chat-route.md +2 -0
  157. package/.docs/reference/ai-sdk/handle-chat-stream.md +19 -0
  158. package/.docs/reference/ai-sdk/handle-network-stream.md +2 -0
  159. package/.docs/reference/ai-sdk/network-route.md +2 -0
  160. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +95 -0
  161. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +15 -0
  162. package/.docs/reference/browser/agent-browser.md +375 -0
  163. package/.docs/reference/browser/browser-viewer.md +228 -0
  164. package/.docs/reference/browser/mastra-browser.md +286 -0
  165. package/.docs/reference/browser/stagehand-browser.md +286 -0
  166. package/.docs/reference/cli/mastra.md +703 -0
  167. package/.docs/reference/client-js/agents.md +166 -0
  168. package/.docs/reference/client-js/conversations.md +1 -1
  169. package/.docs/reference/client-js/mastra-client.md +23 -0
  170. package/.docs/reference/client-js/observability.md +2 -2
  171. package/.docs/reference/client-js/responses.md +1 -1
  172. package/.docs/reference/client-js/workflows.md +62 -1
  173. package/.docs/reference/configuration.md +67 -1
  174. package/.docs/reference/core/addGateway.md +5 -5
  175. package/.docs/reference/core/getEditor.md +35 -0
  176. package/.docs/reference/core/getGateway.md +5 -5
  177. package/.docs/reference/core/getGatewayById.md +5 -5
  178. package/.docs/reference/core/getMCPServer.md +2 -2
  179. package/.docs/reference/core/getMCPServerById.md +2 -2
  180. package/.docs/reference/core/getScorer.md +3 -3
  181. package/.docs/reference/core/getScorerById.md +3 -3
  182. package/.docs/reference/core/listGateways.md +5 -5
  183. package/.docs/reference/core/listMCPServers.md +2 -2
  184. package/.docs/reference/core/listScorers.md +3 -3
  185. package/.docs/reference/core/mastra-class.md +11 -1
  186. package/.docs/reference/core/mastra-model-gateway.md +5 -5
  187. package/.docs/reference/datasets/create.md +4 -4
  188. package/.docs/reference/datasets/startExperiment.md +28 -2
  189. package/.docs/reference/datasets/update.md +4 -4
  190. package/.docs/reference/deployer/cloudflare.md +14 -1
  191. package/.docs/reference/deployer/netlify.md +50 -2
  192. package/.docs/reference/editor/mastra-editor.md +168 -0
  193. package/.docs/reference/editor/tool-provider.md +85 -0
  194. package/.docs/reference/evals/context-precision.md +3 -3
  195. package/.docs/reference/evals/context-relevance.md +3 -3
  196. package/.docs/reference/evals/create-scorer.md +5 -3
  197. package/.docs/reference/evals/filter-run.md +117 -0
  198. package/.docs/reference/evals/mastra-scorer.md +4 -4
  199. package/.docs/reference/evals/noise-sensitivity.md +6 -6
  200. package/.docs/reference/evals/prompt-alignment.md +12 -12
  201. package/.docs/reference/evals/run-evals.md +6 -6
  202. package/.docs/reference/evals/scorer-utils.md +3 -3
  203. package/.docs/reference/evals/trajectory-accuracy.md +3 -3
  204. package/.docs/reference/harness/harness-class.md +152 -53
  205. package/.docs/reference/index.md +25 -0
  206. package/.docs/reference/logging/pino-logger.md +0 -2
  207. package/.docs/reference/mastra-platform/api.md +108 -0
  208. package/.docs/reference/memory/clone-utilities.md +4 -2
  209. package/.docs/reference/memory/cloneThread.md +4 -2
  210. package/.docs/reference/memory/observational-memory.md +4 -0
  211. package/.docs/reference/observability/metrics/automatic-metrics.md +3 -3
  212. package/.docs/reference/observability/tracing/bridges/datadog.md +211 -0
  213. package/.docs/reference/observability/tracing/bridges/otel.md +3 -3
  214. package/.docs/reference/observability/tracing/configuration.md +18 -11
  215. package/.docs/reference/observability/tracing/exporters/arthur.md +122 -0
  216. package/.docs/reference/observability/tracing/exporters/cloud-exporter.md +102 -21
  217. package/.docs/reference/observability/tracing/exporters/console-exporter.md +8 -8
  218. package/.docs/reference/observability/tracing/exporters/datadog.md +3 -1
  219. package/.docs/reference/observability/tracing/exporters/default-exporter.md +8 -8
  220. package/.docs/reference/observability/tracing/exporters/langfuse.md +25 -32
  221. package/.docs/reference/observability/tracing/exporters/otel.md +3 -3
  222. package/.docs/reference/observability/tracing/instances.md +7 -7
  223. package/.docs/reference/observability/tracing/interfaces.md +23 -6
  224. package/.docs/reference/observability/tracing/span-filtering.md +95 -0
  225. package/.docs/reference/observability/tracing/spans.md +6 -6
  226. package/.docs/reference/processors/prefill-error-handler.md +70 -0
  227. package/.docs/reference/processors/processor-interface.md +400 -40
  228. package/.docs/reference/processors/skill-search-processor.md +20 -1
  229. package/.docs/reference/processors/stream-error-retry-processor.md +54 -0
  230. package/.docs/reference/processors/tool-call-filter.md +23 -0
  231. package/.docs/reference/server/create-route.md +3 -3
  232. package/.docs/reference/server/express-adapter.md +4 -4
  233. package/.docs/reference/server/fastify-adapter.md +4 -4
  234. package/.docs/reference/server/hono-adapter.md +4 -4
  235. package/.docs/reference/server/koa-adapter.md +4 -4
  236. package/.docs/reference/server/mastra-server.md +3 -3
  237. package/.docs/reference/server/nestjs-adapter.md +169 -0
  238. package/.docs/reference/server/register-api-route.md +4 -4
  239. package/.docs/reference/server/routes.md +11 -10
  240. package/.docs/reference/storage/clickhouse.md +300 -0
  241. package/.docs/reference/storage/cloudflare-d1.md +42 -42
  242. package/.docs/reference/storage/composite.md +5 -3
  243. package/.docs/reference/storage/duckdb.md +150 -0
  244. package/.docs/reference/storage/overview.md +1 -1
  245. package/.docs/reference/storage/redis.md +266 -0
  246. package/.docs/reference/streaming/ChunkType.md +143 -3
  247. package/.docs/reference/streaming/agents/MastraModelOutput.md +2 -2
  248. package/.docs/reference/streaming/agents/stream.md +10 -2
  249. package/.docs/reference/streaming/agents/streamUntilIdle.md +94 -0
  250. package/.docs/reference/streaming/workflows/resumeStream.md +2 -0
  251. package/.docs/reference/templates/overview.md +88 -14
  252. package/.docs/reference/tools/create-tool.md +107 -5
  253. package/.docs/reference/tools/mcp-client.md +45 -0
  254. package/.docs/reference/tools/mcp-server.md +1 -3
  255. package/.docs/reference/tools/perplexity.md +155 -0
  256. package/.docs/reference/tools/tavily.md +307 -0
  257. package/.docs/reference/vectors/mongodb.md +0 -2
  258. package/.docs/reference/voice/aws-nova-sonic.md +247 -0
  259. package/.docs/reference/voice/cloudflare.md +3 -3
  260. package/.docs/reference/voice/sarvam.md +29 -23
  261. package/.docs/reference/voice/voice.connect.md +4 -4
  262. package/.docs/reference/voice/voice.listen.md +3 -3
  263. package/.docs/reference/workflows/run-methods/resume.md +24 -0
  264. package/.docs/reference/workflows/run-methods/startAsync.md +1 -1
  265. package/.docs/reference/workflows/step.md +88 -7
  266. package/.docs/reference/workflows/workflow-methods/foreach.md +14 -1
  267. package/.docs/reference/workflows/workflow.md +88 -4
  268. package/.docs/reference/workspace/azure-blob-filesystem.md +219 -0
  269. package/.docs/reference/workspace/docker-sandbox.md +196 -0
  270. package/.docs/reference/workspace/gcs-filesystem.md +1 -0
  271. package/.docs/reference/workspace/google-drive-filesystem.md +185 -0
  272. package/.docs/reference/workspace/modal-sandbox.md +168 -0
  273. package/.docs/reference/workspace/process-manager.md +1 -1
  274. package/.docs/reference/workspace/s3-filesystem.md +80 -5
  275. package/.docs/reference/workspace/vercel.md +1 -1
  276. package/.docs/reference/workspace/workspace-class.md +37 -6
  277. package/CHANGELOG.md +500 -4
  278. package/dist/stdio.js.map +1 -1
  279. package/dist/utils.d.ts +1 -4
  280. package/dist/utils.d.ts.map +1 -1
  281. package/package.json +11 -11
  282. package/.docs/docs/mastra-cloud/deployment.md +0 -77
  283. package/.docs/docs/mastra-cloud/observability.md +0 -38
  284. package/.docs/docs/mastra-cloud/overview.md +0 -23
  285. package/.docs/docs/mastra-cloud/setup.md +0 -42
@@ -8,6 +8,23 @@ Framework-agnostic handler for streaming agent chat in AI SDK-compatible format.
8
8
 
9
9
  Use [`chatRoute()`](https://mastra.ai/reference/ai-sdk/chat-route) if you want to create a chat route inside a Mastra server.
10
10
 
11
+ ## Structured output in UI streams
12
+
13
+ When you pass `structuredOutput` to the underlying agent execution, the final structured output object is emitted in the AI SDK-compatible UI stream as a custom data part:
14
+
15
+ ```json
16
+ {
17
+ "type": "data-structured-output",
18
+ "data": {
19
+ "object": {}
20
+ }
21
+ }
22
+ ```
23
+
24
+ The `object` field contains your full structured output value. Mastra emits this event for the final structured output object only. Partial structured output chunks are not exposed in the UI stream.
25
+
26
+ Read this event with AI SDK UI's custom data handling, such as `onData`, or render it from message data parts.
27
+
11
28
  ## Usage example
12
29
 
13
30
  Next.js App Router example:
@@ -37,6 +54,8 @@ export async function POST(req: Request) {
37
54
 
38
55
  **agentId** (`string`): The ID of the agent to use for chat.
39
56
 
57
+ **agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass \`{ versionId: '\<id>' }\` to target an exact version, or \`{ status: 'draft' }\` / \`{ status: 'published' }\` to resolve by status. Requires the \[Editor]\(/docs/editor/overview) to be configured.
58
+
40
59
  **params** (`ChatStreamHandlerParams`): Parameters for the chat stream, including messages and optional resume data.
41
60
 
42
61
  **params.messages** (`UIMessage[]`): Array of messages in the conversation.
@@ -38,6 +38,8 @@ export async function POST(req: Request) {
38
38
 
39
39
  **agentId** (`string`): The ID of the routing agent to execute as a network.
40
40
 
41
+ **agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass \`{ versionId: '\<id>' }\` to target an exact version, or \`{ status: 'draft' }\` / \`{ status: 'published' }\` to resolve by status. Requires the \[Editor]\(/docs/editor/overview) to be configured.
42
+
41
43
  **params** (`NetworkStreamHandlerParams`): The request parameters containing messages and execution options. Includes \`messages\` (required) and any AgentExecutionOptions like \`memory\`, \`maxSteps\`, \`runId\`, etc.
42
44
 
43
45
  **defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These are merged with params, with params taking precedence.
@@ -53,6 +53,8 @@ export const mastra = new Mastra({
53
53
 
54
54
  **agent** (`string`): The ID of the routing agent to use for this network route. Required if the path doesn't include \`:agentId\`.
55
55
 
56
+ **agentVersion** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a specific agent version. Pass \`{ versionId: '\<id>' }\` to target an exact version, or \`{ status: 'draft' }\` / \`{ status: 'published' }\` to resolve by status. When the route is called, query parameters \`?versionId=\<id>\` or \`?status=draft|published\` take precedence over this static value. Requires the \[Editor]\(/docs/editor/overview) to be configured.
57
+
56
58
  **defaultOptions** (`AgentExecutionOptions`): Default options passed to agent execution. These can include instructions, memory configuration, maxSteps, and other execution settings.
57
59
 
58
60
  ## Additional configuration
@@ -0,0 +1,95 @@
1
+ # toAISdkMessages()
2
+
3
+ Converts messages from various input formats to AI SDK UI message format. `toAISdkMessages()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'`.
4
+
5
+ `version: 'v6'` uses the MessageList AI SDK v6 UI output path. MessageList input detection and ingestion remain unchanged.
6
+
7
+ ## Usage example
8
+
9
+ ```typescript
10
+ import { toAISdkMessages } from '@mastra/ai-sdk/ui'
11
+ import { useChat } from 'ai/react'
12
+
13
+ // Stored messages from your database, memory, or API
14
+ const storedMessages = [
15
+ { id: '1', role: 'user', content: 'Hello', parts: [{ type: 'text', text: 'Hello' }] },
16
+ {
17
+ id: '2',
18
+ role: 'assistant',
19
+ content: 'Hi there!',
20
+ parts: [{ type: 'text', text: 'Hi there!' }],
21
+ },
22
+ ]
23
+
24
+ export default function Chat() {
25
+ const { messages } = useChat({
26
+ initialMessages: toAISdkMessages(storedMessages, { version: 'v6' }),
27
+ })
28
+
29
+ return (
30
+ <div>
31
+ {messages.map(message => (
32
+ <div key={message.id}>
33
+ {message.role}: {message.parts.map(part => (part.type === 'text' ? part.text : null))}
34
+ </div>
35
+ ))}
36
+ </div>
37
+ )
38
+ }
39
+ ```
40
+
41
+ ## Parameters
42
+
43
+ **messages** (`MessageListInput`): Messages to convert. Can be a string, array of strings, a single message object, or an array of message objects in any supported format.
44
+
45
+ **options.version** (`'v5' | 'v6'`): Selects the AI SDK message type to return. Omit it or pass \`'v5'\` for the existing default behavior. Pass \`'v6'\` when your app is typed against AI SDK v6 \`useChat()\` message types.
46
+
47
+ ## Returns
48
+
49
+ Returns an array of AI SDK `UIMessage` objects typed for the selected version.
50
+
51
+ **id** (`string`): Unique message identifier.
52
+
53
+ **role** (`'user' | 'assistant' | 'system'`): The role of the message sender.
54
+
55
+ **parts** (`UIMessagePart[]`): Array of UI parts including text, tool results, files, reasoning, sources, and step markers.
56
+
57
+ **metadata** (`Record<string, unknown>`): Optional metadata including createdAt, threadId, resourceId, and custom fields.
58
+
59
+ ## Examples
60
+
61
+ ### Using the default AI SDK v5 types
62
+
63
+ ```typescript
64
+ import { toAISdkMessages } from '@mastra/ai-sdk/ui'
65
+
66
+ const messages = toAISdkMessages(['Hello', 'How can I help you today?'])
67
+ ```
68
+
69
+ ### Returning AI SDK v6 message types
70
+
71
+ ```typescript
72
+ import { toAISdkMessages } from '@mastra/ai-sdk/ui'
73
+
74
+ const messages = toAISdkMessages(['Hello', 'How can I help you today?'], {
75
+ version: 'v6',
76
+ })
77
+ ```
78
+
79
+ ### Loading messages with Mastra client
80
+
81
+ ```typescript
82
+ import { MastraClient } from '@mastra/client-js'
83
+ import { toAISdkMessages } from '@mastra/ai-sdk/ui'
84
+
85
+ const client = new MastraClient()
86
+
87
+ const { messages } = await client.listThreadMessages('thread-id', { agentId: 'myAgent' })
88
+ const uiMessages = toAISdkMessages(messages)
89
+ ```
90
+
91
+ ## Related
92
+
93
+ - [`toAISdkStream()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-stream)
94
+ - [`toAISdkV5Messages()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v5-messages)
95
+ - [`toAISdkV4Messages()`](https://mastra.ai/reference/ai-sdk/to-ai-sdk-v4-messages)
@@ -6,6 +6,21 @@ This is useful when building custom streaming endpoints outside Mastra's provide
6
6
 
7
7
  `toAISdkStream()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'` in the options object.
8
8
 
9
+ ## Structured output in UI streams
10
+
11
+ When the source agent stream includes a final structured output object, `toAISdkStream()` emits it as a custom AI SDK UI data part:
12
+
13
+ ```json
14
+ {
15
+ "type": "data-structured-output",
16
+ "data": {
17
+ "object": {}
18
+ }
19
+ }
20
+ ```
21
+
22
+ The `object` field contains your full structured output value. This maps Mastra's final structured output chunk into the AI SDK UI stream. Partial structured output chunks are not emitted.
23
+
9
24
  ## Usage example
10
25
 
11
26
  Next.js App Router example:
@@ -0,0 +1,375 @@
1
+ # AgentBrowser class
2
+
3
+ The `AgentBrowser` class provides deterministic browser automation using the [agent-browser](https://github.com/vercel-labs/agent-browser) library. It uses accessibility tree snapshots and element refs (e.g., `@e5`) for precise, reproducible interactions.
4
+
5
+ Use `AgentBrowser` when you need reliable, deterministic browser automation. For AI-powered interactions using natural language, see [`StagehandBrowser`](https://mastra.ai/reference/browser/stagehand-browser).
6
+
7
+ ## Usage example
8
+
9
+ ```typescript
10
+ import { Agent } from '@mastra/core/agent'
11
+ import { AgentBrowser } from '@mastra/agent-browser'
12
+
13
+ const browser = new AgentBrowser({
14
+ headless: true,
15
+ viewport: { width: 1280, height: 720 },
16
+ scope: 'thread',
17
+ })
18
+
19
+ export const browserAgent = new Agent({
20
+ id: 'browser-agent',
21
+ name: 'Browser Agent',
22
+ instructions: `You can browse the web. Use browser_snapshot to see the page structure,
23
+ then interact with elements using their refs (e.g., @e5).`,
24
+ model: 'openai/gpt-5.4',
25
+ browser,
26
+ })
27
+ ```
28
+
29
+ ## Constructor parameters
30
+
31
+ **headless** (`boolean`): Whether to run the browser in headless mode (no visible UI). (Default: `true`)
32
+
33
+ **viewport** (`{ width: number; height: number }`): Browser viewport dimensions. (Default: `{ width: 1280, height: 720 }`)
34
+
35
+ **timeout** (`number`): Default timeout in milliseconds for browser operations. (Default: `30000`)
36
+
37
+ **cdpUrl** (`string | (() => string | Promise<string>)`): CDP WebSocket URL for connecting to an existing browser. Useful for cloud browser providers.
38
+
39
+ **scope** (`'shared' | 'thread'`): Browser instance scope. 'shared' shares one browser across all threads. 'thread' gives each thread its own browser. (Default: `'thread' (or 'shared' when cdpUrl is provided)`)
40
+
41
+ **onLaunch** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked after the browser is ready.
42
+
43
+ **onClose** (`(args: { browser: MastraBrowser }) => void | Promise<void>`): Callback invoked before the browser closes.
44
+
45
+ **screencast** (`ScreencastOptions`): Configuration for streaming browser frames to Studio.
46
+
47
+ ## Tools
48
+
49
+ `AgentBrowser` provides 15 deterministic tools for browser automation. All tools that interact with elements use refs from the accessibility tree snapshot.
50
+
51
+ ### Core tools
52
+
53
+ | Tool | Description |
54
+ | ------------------ | ------------------------------------------------- |
55
+ | `browser_goto` | Navigate to a URL |
56
+ | `browser_snapshot` | Get accessibility tree snapshot with element refs |
57
+ | `browser_click` | Click an element by ref |
58
+ | `browser_type` | Type text into an element |
59
+ | `browser_press` | Press keyboard keys |
60
+ | `browser_select` | Select option from dropdown |
61
+ | `browser_scroll` | Scroll the page or element |
62
+ | `browser_close` | Close the browser |
63
+
64
+ ### Extended tools
65
+
66
+ | Tool | Description |
67
+ | ------------------ | ----------------------------------------------- |
68
+ | `browser_hover` | Hover over an element |
69
+ | `browser_back` | Go back in browser history |
70
+ | `browser_dialog` | Handle browser dialogs (alert, confirm, prompt) |
71
+ | `browser_wait` | Wait for element state changes |
72
+ | `browser_tabs` | Manage browser tabs (list, new, switch, close) |
73
+ | `browser_drag` | Drag and drop elements |
74
+ | `browser_evaluate` | Execute JavaScript in the page (escape hatch) |
75
+
76
+ ## Tool reference
77
+
78
+ ### `browser_goto`
79
+
80
+ Navigate to a URL.
81
+
82
+ ```text
83
+ // Tool input
84
+ {
85
+ "url": "https://example.com",
86
+ "waitUntil": "domcontentloaded",
87
+ "timeout": 30000
88
+ }
89
+ ```
90
+
91
+ | Parameter | Type | Description |
92
+ | ----------- | ----------------------------------------------- | ----------------------------------------------- |
93
+ | `url` | `string` | URL to navigate to |
94
+ | `waitUntil` | `"load" \| "domcontentloaded" \| "networkidle"` | When to consider navigation complete (optional) |
95
+ | `timeout` | `number` | Navigation timeout in ms (optional) |
96
+
97
+ ### `browser_snapshot`
98
+
99
+ Get an accessibility tree snapshot of the page. Returns element refs like `@e5` that you use with other tools.
100
+
101
+ ```text
102
+ // Tool input
103
+ {
104
+ "interactiveOnly": true,
105
+ "maxDepth": 10
106
+ }
107
+ ```
108
+
109
+ | Parameter | Type | Description |
110
+ | ----------------- | --------- | -------------------------------------------- |
111
+ | `interactiveOnly` | `boolean` | Only include interactive elements (optional) |
112
+ | `maxDepth` | `number` | Maximum tree depth (optional) |
113
+
114
+ **Example output:**
115
+
116
+ ```text
117
+ [document] Example Page
118
+ [banner]
119
+ [link @e1] Home
120
+ [link @e2] About
121
+ [main]
122
+ [heading @e3] Welcome
123
+ [textbox @e4] Search...
124
+ [button @e5] Submit
125
+ ```
126
+
127
+ ### `browser_click`
128
+
129
+ Click an element using its ref from the snapshot.
130
+
131
+ ```text
132
+ {
133
+ "ref": "@e5",
134
+ "button": "left",
135
+ "clickCount": 1,
136
+ "modifiers": ["Control", "Shift"]
137
+ }
138
+ ```
139
+
140
+ | Parameter | Type | Description |
141
+ | ------------ | ------------------------------- | ---------------------------------------------- |
142
+ | `ref` | `string` | Element ref from snapshot (required) |
143
+ | `button` | `"left" \| "right" \| "middle"` | Mouse button (optional) |
144
+ | `clickCount` | `number` | Number of activations, 2 for double (optional) |
145
+ | `modifiers` | `string[]` | Modifier keys (optional) |
146
+
147
+ ### `browser_type`
148
+
149
+ Type text into an input element.
150
+
151
+ ```text
152
+ // Tool input
153
+ {
154
+ "ref": "@e4",
155
+ "text": "search query",
156
+ "clear": true,
157
+ "delay": 50
158
+ }
159
+ ```
160
+
161
+ | Parameter | Type | Description |
162
+ | --------- | --------- | ----------------------------------------- |
163
+ | `ref` | `string` | Element ref from snapshot (required) |
164
+ | `text` | `string` | Text to type (required) |
165
+ | `clear` | `boolean` | Clear existing content first (optional) |
166
+ | `delay` | `number` | Delay between keystrokes in ms (optional) |
167
+
168
+ ### `browser_press`
169
+
170
+ Press keyboard keys.
171
+
172
+ ```text
173
+ // Tool input
174
+ {
175
+ "key": "Enter",
176
+ "modifiers": ["Control"]
177
+ }
178
+
179
+ // Key combinations
180
+ { "key": "Control+a" }
181
+ { "key": "Control+c" }
182
+ ```
183
+
184
+ | Parameter | Type | Description |
185
+ | ----------- | ---------- | ----------------------------------------------------------------- |
186
+ | `key` | `string` | Key name (e.g., "Enter", "Tab", "Escape", "Control+a") (required) |
187
+ | `modifiers` | `string[]` | Modifier keys (optional) |
188
+
189
+ ### `browser_select`
190
+
191
+ Select an option from a dropdown. Provide one of `value`, `label`, or `index`.
192
+
193
+ ```text
194
+ // Tool input - by value
195
+ {
196
+ "ref": "@e10",
197
+ "value": "option-value"
198
+ }
199
+
200
+ // Tool input - by label
201
+ {
202
+ "ref": "@e10",
203
+ "label": "Option Text"
204
+ }
205
+
206
+ // Tool input - by index
207
+ {
208
+ "ref": "@e10",
209
+ "index": 0
210
+ }
211
+ ```
212
+
213
+ ### `browser_scroll`
214
+
215
+ Scroll the page or a specific element.
216
+
217
+ ```text
218
+ // Tool input
219
+ {
220
+ "direction": "down",
221
+ "amount": 300,
222
+ "ref": "@e15"
223
+ }
224
+ ```
225
+
226
+ | Parameter | Type | Description |
227
+ | ----------- | ------------------------------------- | ----------------------------------------------------- |
228
+ | `direction` | `"up" \| "down" \| "left" \| "right"` | Scroll direction (required) |
229
+ | `amount` | `number` | Pixels to scroll, default 300 (optional) |
230
+ | `ref` | `string` | Element to scroll, scrolls page if omitted (optional) |
231
+
232
+ ### `browser_hover`
233
+
234
+ Hover over an element to trigger hover effects.
235
+
236
+ ```text
237
+ // Tool input
238
+ {
239
+ "ref": "@e7"
240
+ }
241
+ ```
242
+
243
+ ### `browser_back`
244
+
245
+ Go back in browser history.
246
+
247
+ ```text
248
+ // Tool input (no parameters required)
249
+
250
+ ```
251
+
252
+ ### `browser_dialog`
253
+
254
+ Handle browser dialogs (alert, confirm, prompt). Click an element that triggers a dialog and handle it.
255
+
256
+ ```text
257
+ // Tool input
258
+ {
259
+ "triggerRef": "@e5",
260
+ "action": "accept",
261
+ "text": "response"
262
+ }
263
+ ```
264
+
265
+ | Parameter | Type | Description |
266
+ | ------------ | ----------------------- | ------------------------------------------- |
267
+ | `triggerRef` | `string` | Element that triggers the dialog (required) |
268
+ | `action` | `"accept" \| "dismiss"` | How to handle the dialog (required) |
269
+ | `text` | `string` | Text for prompt dialogs (optional) |
270
+
271
+ ### `browser_wait`
272
+
273
+ Wait for an element to reach a specific state.
274
+
275
+ ```text
276
+ // Tool input
277
+ {
278
+ "ref": "@e20",
279
+ "state": "visible",
280
+ "timeout": 30000
281
+ }
282
+ ```
283
+
284
+ | Parameter | Type | Description |
285
+ | --------- | --------------------------------------------------- | ---------------------------------- |
286
+ | `ref` | `string` | Element ref to wait for (optional) |
287
+ | `state` | `"visible" \| "hidden" \| "attached" \| "detached"` | State to wait for (optional) |
288
+ | `timeout` | `number` | Max wait time in ms (optional) |
289
+
290
+ ### `browser_tabs`
291
+
292
+ Manage browser tabs.
293
+
294
+ ```text
295
+ // List all tabs
296
+ { "action": "list" }
297
+
298
+ // Open new tab
299
+ { "action": "new", "url": "https://example.com" }
300
+
301
+ // Switch to tab by index
302
+ { "action": "switch", "index": 0 }
303
+
304
+ // Close tab by index
305
+ { "action": "close", "index": 1 }
306
+ ```
307
+
308
+ ### `browser_drag`
309
+
310
+ Drag an element to a target location.
311
+
312
+ ```text
313
+ // Tool input
314
+ {
315
+ "sourceRef": "@e10",
316
+ "targetRef": "@e20"
317
+ }
318
+ ```
319
+
320
+ | Parameter | Type | Description |
321
+ | ----------- | -------- | ------------------------------ |
322
+ | `sourceRef` | `string` | Element to drag (required) |
323
+ | `targetRef` | `string` | Drop target element (required) |
324
+
325
+ ### `browser_evaluate`
326
+
327
+ Execute JavaScript in the page context. Use as an escape hatch when other tools don't cover your use case.
328
+
329
+ ```text
330
+ // Tool input
331
+ {
332
+ "script": "document.title",
333
+ "returnValue": true
334
+ }
335
+ ```
336
+
337
+ | Parameter | Type | Description |
338
+ | ------------- | --------- | --------------------------------------- |
339
+ | `script` | `string` | JavaScript to execute (required) |
340
+ | `returnValue` | `boolean` | Whether to return the result (optional) |
341
+
342
+ ### `browser_close`
343
+
344
+ Close the browser and clean up resources.
345
+
346
+ ```text
347
+ // Tool input (no parameters required)
348
+
349
+ ```
350
+
351
+ ## How refs work
352
+
353
+ The `browser_snapshot` tool returns an accessibility tree with element refs like `@e1`, `@e2`, etc. These refs are stable identifiers you use with other tools:
354
+
355
+ 1. Call `browser_snapshot` to see the page structure
356
+ 2. Find the element you want to interact with
357
+ 3. Use its ref with interaction tools like `browser_type` or `browser_scroll`.
358
+
359
+ ```text
360
+ // 1. Get snapshot
361
+ // Returns: [textbox @e4] Search... [link @e5] Home
362
+
363
+ // 2. Type in the search box
364
+ { "tool": "browser_type", "input": { "ref": "@e4", "text": "mastra" } }
365
+
366
+ // 3. Navigate to home
367
+ { "tool": "browser_goto", "input": { "url": "https://example.com" } }
368
+ ```
369
+
370
+ ## Related
371
+
372
+ - [MastraBrowser](https://mastra.ai/reference/browser/mastra-browser): Base class reference
373
+ - [StagehandBrowser](https://mastra.ai/reference/browser/stagehand-browser): AI-powered alternative
374
+ - [Browser overview](https://mastra.ai/docs/browser/overview): Conceptual guide
375
+ - [agent-browser guide](https://mastra.ai/docs/browser/agent-browser): Usage guide