@mastra/mcp-docs-server 1.2.5-alpha.1 → 1.2.5-alpha.3

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 (198) hide show
  1. package/.docs/docs/agent-builder/deploying.md +1 -1
  2. package/.docs/docs/agent-controller/overview.md +1 -1
  3. package/.docs/docs/agent-controller/session.md +1 -1
  4. package/.docs/docs/agents/overview.md +1 -1
  5. package/.docs/docs/agents/processors.md +1 -1
  6. package/.docs/docs/agents/supervisor-agents.md +3 -3
  7. package/.docs/docs/agents/using-tools.md +1 -1
  8. package/.docs/docs/{agents → long-running-agents}/background-tasks.md +2 -2
  9. package/.docs/docs/{agents → long-running-agents}/durable-agents.md +2 -2
  10. package/.docs/docs/{agents → long-running-agents}/goals.md +1 -1
  11. package/.docs/docs/{agents → long-running-agents}/heartbeats.md +5 -5
  12. package/.docs/docs/{agents → long-running-agents}/signal-providers.md +4 -4
  13. package/.docs/docs/memory/working-memory.md +1 -1
  14. package/.docs/docs/observability/config.md +1 -2
  15. package/.docs/docs/server/pubsub.md +2 -2
  16. package/.docs/docs/voice/overview.md +3 -3
  17. package/.docs/docs/voice/speech-to-speech.md +81 -1
  18. package/.docs/docs/voice/speech-to-text.md +19 -1
  19. package/.docs/docs/voice/text-to-speech.md +21 -1
  20. package/.docs/docs/workflows/control-flow.md +1 -1
  21. package/.docs/docs/workflows/error-handling.md +1 -1
  22. package/.docs/docs/workflows/human-in-the-loop.md +1 -1
  23. package/.docs/docs/workflows/overview.md +1 -1
  24. package/.docs/docs/workflows/snapshots.md +1 -1
  25. package/.docs/docs/workflows/suspend-and-resume.md +1 -1
  26. package/.docs/docs/workflows/time-travel.md +1 -1
  27. package/.docs/docs/workflows/workflow-state.md +1 -1
  28. package/.docs/guides/build-your-ui/copilotkit/channels.md +76 -0
  29. package/.docs/guides/build-your-ui/copilotkit/generative-ui.md +174 -0
  30. package/.docs/guides/build-your-ui/copilotkit/overview.md +411 -0
  31. package/.docs/guides/concepts/streaming.md +1 -1
  32. package/.docs/guides/deployment/vercel.md +1 -2
  33. package/.docs/guides/guide/signal-provider.md +5 -5
  34. package/.docs/models/environment-variables.md +1 -0
  35. package/.docs/models/index.md +1 -1
  36. package/.docs/models/providers/alibaba-cn.md +2 -1
  37. package/.docs/models/providers/friendli.md +1 -2
  38. package/.docs/models/providers/tencent-token-plan.md +7 -7
  39. package/.docs/models/providers/tencent-tokenhub.md +5 -4
  40. package/.docs/models/providers.md +1 -0
  41. package/.docs/reference/acp/acp-agent.md +5 -5
  42. package/.docs/reference/acp/create-acp-tool.md +5 -5
  43. package/.docs/reference/agent-controller/agent-controller-class.md +27 -27
  44. package/.docs/reference/agents/agent.md +34 -34
  45. package/.docs/reference/agents/channels.md +19 -19
  46. package/.docs/reference/agents/createSkill.md +2 -2
  47. package/.docs/reference/agents/durable-agent.md +22 -22
  48. package/.docs/reference/agents/generate.md +10 -10
  49. package/.docs/reference/agents/generateLegacy.md +12 -12
  50. package/.docs/reference/agents/getMetadata.md +1 -1
  51. package/.docs/reference/agents/getVoice.md +1 -1
  52. package/.docs/reference/agents/inngest-agent.md +9 -9
  53. package/.docs/reference/agents/network.md +1 -1
  54. package/.docs/reference/ai-sdk/chat-route.md +4 -4
  55. package/.docs/reference/ai-sdk/handle-chat-stream.md +6 -6
  56. package/.docs/reference/ai-sdk/handle-network-stream.md +3 -3
  57. package/.docs/reference/ai-sdk/handle-workflow-stream.md +1 -1
  58. package/.docs/reference/ai-sdk/network-route.md +4 -4
  59. package/.docs/reference/ai-sdk/to-ai-sdk-messages.md +1 -1
  60. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +1 -1
  61. package/.docs/reference/ai-sdk/with-mastra.md +2 -2
  62. package/.docs/reference/ai-sdk/workflow-route.md +2 -2
  63. package/.docs/reference/ai-sdk/workflow-snapshot-to-stream.md +1 -1
  64. package/.docs/reference/auth/google.md +10 -10
  65. package/.docs/reference/auth/okta.md +11 -11
  66. package/.docs/reference/auth/workos.md +3 -3
  67. package/.docs/reference/channels/slack-provider.md +15 -15
  68. package/.docs/reference/cli/mastra.md +145 -0
  69. package/.docs/reference/client-js/agents.md +9 -9
  70. package/.docs/reference/client-js/mastra-client.md +5 -5
  71. package/.docs/reference/client-js/responses.md +3 -3
  72. package/.docs/reference/configuration.md +1 -1
  73. package/.docs/reference/core/getAgentById.md +3 -3
  74. package/.docs/reference/core/getWorkflow.md +1 -1
  75. package/.docs/reference/core/listWorkflows.md +1 -1
  76. package/.docs/reference/core/mastra-class.md +3 -3
  77. package/.docs/reference/core/removeWorkspace.md +2 -2
  78. package/.docs/reference/datasets/compareExperiments.md +1 -1
  79. package/.docs/reference/datasets/getItemHistory.md +1 -1
  80. package/.docs/reference/datasets/list.md +5 -5
  81. package/.docs/reference/datasets/listExperimentResults.md +4 -4
  82. package/.docs/reference/datasets/listExperiments.md +4 -4
  83. package/.docs/reference/datasets/listItems.md +5 -5
  84. package/.docs/reference/datasets/listVersions.md +3 -3
  85. package/.docs/reference/datasets/startExperiment.md +8 -8
  86. package/.docs/reference/datasets/startExperimentAsync.md +1 -1
  87. package/.docs/reference/editor/agent-builder/agent-builder-options.md +4 -4
  88. package/.docs/reference/editor/agent-builder/builder-agent-defaults.md +7 -7
  89. package/.docs/reference/editor/agent-builder/builder-models.md +4 -4
  90. package/.docs/reference/editor/blob-store-provider.md +2 -2
  91. package/.docs/reference/editor/browser-provider.md +2 -2
  92. package/.docs/reference/editor/filesystem-provider.md +2 -2
  93. package/.docs/reference/editor/mastra-editor.md +2 -2
  94. package/.docs/reference/editor/processor-provider.md +4 -4
  95. package/.docs/reference/editor/sandbox-provider.md +2 -2
  96. package/.docs/reference/editor/storage-browser-ref.md +2 -2
  97. package/.docs/reference/editor/storage-workspace-ref.md +7 -7
  98. package/.docs/reference/evals/create-scorer.md +8 -8
  99. package/.docs/reference/evals/rubric.md +1 -1
  100. package/.docs/reference/evals/run-evals.md +7 -7
  101. package/.docs/reference/evals/trajectory-accuracy.md +1 -1
  102. package/.docs/reference/index.md +2 -2
  103. package/.docs/reference/logging/pino-logger.md +4 -4
  104. package/.docs/reference/memory/cloneThread.md +35 -4
  105. package/.docs/reference/memory/memory-class.md +5 -5
  106. package/.docs/reference/memory/observational-memory.md +43 -43
  107. package/.docs/reference/memory/recall.md +4 -4
  108. package/.docs/reference/memory/serialized-memory-config.md +6 -6
  109. package/.docs/reference/observability/tracing/configuration.md +4 -4
  110. package/.docs/reference/processors/language-detector.md +1 -1
  111. package/.docs/reference/processors/moderation-processor.md +1 -1
  112. package/.docs/reference/processors/pii-detector.md +1 -1
  113. package/.docs/reference/processors/processor-interface.md +20 -20
  114. package/.docs/reference/processors/prompt-injection-detector.md +1 -1
  115. package/.docs/reference/processors/response-cache.md +6 -6
  116. package/.docs/reference/processors/unicode-normalizer.md +1 -1
  117. package/.docs/reference/pubsub/base.md +7 -7
  118. package/.docs/reference/pubsub/caching-pubsub.md +1 -1
  119. package/.docs/reference/pubsub/event-emitter.md +2 -2
  120. package/.docs/reference/pubsub/google-cloud-pubsub.md +1 -1
  121. package/.docs/reference/pubsub/lease-provider.md +3 -3
  122. package/.docs/reference/pubsub/redis-streams.md +6 -6
  123. package/.docs/reference/pubsub/unix-socket-pubsub.md +1 -1
  124. package/.docs/reference/rag/chunk.md +2 -2
  125. package/.docs/reference/server/create-route.md +3 -3
  126. package/.docs/reference/server/express-adapter.md +4 -4
  127. package/.docs/reference/server/fastify-adapter.md +4 -4
  128. package/.docs/reference/server/hono-adapter.md +4 -4
  129. package/.docs/reference/server/koa-adapter.md +4 -4
  130. package/.docs/reference/server/mastra-server.md +1 -1
  131. package/.docs/reference/server/nestjs-adapter.md +3 -3
  132. package/.docs/reference/server/register-api-route.md +3 -3
  133. package/.docs/reference/signals/create-notification-inbox-tool.md +3 -3
  134. package/.docs/reference/signals/signal-provider.md +7 -7
  135. package/.docs/reference/signals/webhook-signal-provider.md +2 -2
  136. package/.docs/reference/storage/clickhouse.md +7 -7
  137. package/.docs/reference/storage/composite.md +2 -2
  138. package/.docs/reference/storage/duckdb.md +1 -1
  139. package/.docs/reference/storage/dynamodb.md +1 -1
  140. package/.docs/reference/storage/libsql.md +1 -1
  141. package/.docs/reference/storage/postgresql.md +2 -2
  142. package/.docs/reference/storage/redis.md +2 -2
  143. package/.docs/reference/storage/retention.md +5 -5
  144. package/.docs/reference/storage/spanner.md +6 -6
  145. package/.docs/reference/streaming/ChunkType.md +3 -3
  146. package/.docs/reference/streaming/agents/stream.md +14 -14
  147. package/.docs/reference/streaming/agents/streamLegacy.md +10 -10
  148. package/.docs/reference/streaming/agents/streamUntilIdle.md +1 -1
  149. package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
  150. package/.docs/reference/templates/overview.md +1 -140
  151. package/.docs/reference/tools/brightdata.md +4 -4
  152. package/.docs/reference/tools/create-code-mode.md +5 -5
  153. package/.docs/reference/tools/create-tool.md +15 -15
  154. package/.docs/reference/tools/graph-rag-tool.md +1 -1
  155. package/.docs/reference/tools/mcp-client.md +2 -2
  156. package/.docs/reference/tools/mcp-server.md +12 -12
  157. package/.docs/reference/tools/perplexity.md +3 -3
  158. package/.docs/reference/tools/tavily.md +1 -1
  159. package/.docs/reference/tools/vector-query-tool.md +1 -1
  160. package/.docs/reference/vectors/chroma.md +1 -1
  161. package/.docs/reference/vectors/mongodb.md +1 -1
  162. package/.docs/reference/vectors/pg.md +1 -1
  163. package/.docs/reference/vectors/s3vectors.md +4 -4
  164. package/.docs/reference/voice/google-gemini-live.md +3 -3
  165. package/.docs/reference/voice/inworld-realtime.md +12 -12
  166. package/.docs/reference/voice/inworld.md +2 -2
  167. package/.docs/reference/voice/voice.on.md +1 -1
  168. package/.docs/reference/workflows/run-methods/resume.md +1 -1
  169. package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
  170. package/.docs/reference/workspace/agentcore-runtime-sandbox.md +4 -4
  171. package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
  172. package/.docs/reference/workspace/apple-container-sandbox.md +5 -5
  173. package/.docs/reference/workspace/archil-filesystem.md +5 -5
  174. package/.docs/reference/workspace/blaxel-sandbox.md +1 -1
  175. package/.docs/reference/workspace/daytona-sandbox.md +1 -1
  176. package/.docs/reference/workspace/docker-sandbox.md +2 -2
  177. package/.docs/reference/workspace/e2b-sandbox.md +2 -2
  178. package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
  179. package/.docs/reference/workspace/filesystem.md +1 -1
  180. package/.docs/reference/workspace/local-filesystem.md +3 -3
  181. package/.docs/reference/workspace/local-sandbox.md +1 -1
  182. package/.docs/reference/workspace/mesa-filesystem.md +3 -3
  183. package/.docs/reference/workspace/modal-sandbox.md +1 -1
  184. package/.docs/reference/workspace/railway-sandbox.md +1 -1
  185. package/.docs/reference/workspace/s3-filesystem.md +4 -4
  186. package/.docs/reference/workspace/sandbox.md +1 -1
  187. package/.docs/reference/workspace/{vercel-microvm-sandbox.md → vercel-sandbox.md} +21 -15
  188. package/.docs/reference/workspace/{vercel.md → vercel-serverless.md} +21 -14
  189. package/.docs/reference/workspace/workspace-class.md +15 -15
  190. package/CHANGELOG.md +8 -0
  191. package/package.json +5 -5
  192. package/.docs/docs/agents/adding-voice.md +0 -383
  193. package/.docs/docs/community/contributing-templates.md +0 -5
  194. package/.docs/docs/community/discord.md +0 -11
  195. package/.docs/guides/build-your-ui/copilotkit.md +0 -291
  196. package/LICENSE.md +0 -30
  197. /package/.docs/docs/{community/licensing.md → license.md} +0 -0
  198. /package/.docs/docs/{agents → long-running-agents}/signals.md +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/mcp-docs-server
2
2
 
3
+ ## 1.2.5-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`911281c`](https://github.com/mastra-ai/mastra/commit/911281c57893ba2630428bf88d0cd0c5101ce76f), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964)]:
8
+ - @mastra/core@1.50.0-alpha.1
9
+ - @mastra/mcp@1.13.1-alpha.0
10
+
3
11
  ## 1.2.5-alpha.0
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp-docs-server",
3
- "version": "1.2.5-alpha.1",
3
+ "version": "1.2.5-alpha.3",
4
4
  "description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "jsdom": "^26.1.0",
29
29
  "local-pkg": "^1.1.2",
30
30
  "zod": "^4.4.3",
31
- "@mastra/core": "1.50.0-alpha.0",
32
- "@mastra/mcp": "^1.13.0"
31
+ "@mastra/core": "1.50.0-alpha.1",
32
+ "@mastra/mcp": "^1.13.1-alpha.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@hono/node-server": "^1.19.11",
@@ -46,8 +46,8 @@
46
46
  "typescript": "^6.0.3",
47
47
  "vitest": "4.1.8",
48
48
  "@internal/types-builder": "0.0.86",
49
- "@mastra/core": "1.50.0-alpha.0",
50
- "@internal/lint": "0.0.111"
49
+ "@internal/lint": "0.0.111",
50
+ "@mastra/core": "1.50.0-alpha.1"
51
51
  },
52
52
  "homepage": "https://mastra.ai",
53
53
  "repository": {
@@ -1,383 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Voice
4
-
5
- Mastra agents can be enhanced with voice capabilities, allowing them to speak responses and listen to user input. You can configure an agent to use either a single voice provider or combine multiple providers for different operations.
6
-
7
- ## Basic usage
8
-
9
- The simplest way to add voice to an agent is to use a single provider for both speaking and listening:
10
-
11
- ```typescript
12
- import { createReadStream } from 'fs'
13
- import path from 'path'
14
- import { Agent } from '@mastra/core/agent'
15
- import { OpenAIVoice } from '@mastra/voice-openai'
16
-
17
- // Initialize the voice provider with default settings
18
- const voice = new OpenAIVoice()
19
-
20
- // Create an agent with voice capabilities
21
- export const agent = new Agent({
22
- id: 'voice-agent',
23
- name: 'Voice Agent',
24
- instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
25
- model: 'openai/gpt-5.5',
26
- voice,
27
- })
28
-
29
- // The agent can now use voice for interaction
30
- const audioStream = await agent.voice.speak("Hello, I'm your AI assistant!", {
31
- filetype: 'm4a',
32
- })
33
-
34
- playAudio(audioStream!)
35
-
36
- try {
37
- const transcription = await agent.voice.listen(audioStream)
38
- console.log(transcription)
39
- } catch (error) {
40
- console.error('Error transcribing audio:', error)
41
- }
42
- ```
43
-
44
- ## Working with audio streams
45
-
46
- The `speak()` and `listen()` methods work with Node.js streams. Here's how to save and load audio files:
47
-
48
- ### Saving Speech Output
49
-
50
- The `speak` method returns a stream that you can pipe to a file or speaker.
51
-
52
- ```typescript
53
- import { createWriteStream } from 'fs'
54
- import path from 'path'
55
-
56
- // Generate speech and save to file
57
- const audio = await agent.voice.speak('Hello, World!')
58
- const filePath = path.join(process.cwd(), 'agent.mp3')
59
- const writer = createWriteStream(filePath)
60
-
61
- audio.pipe(writer)
62
-
63
- await new Promise<void>((resolve, reject) => {
64
- writer.on('finish', () => resolve())
65
- writer.on('error', reject)
66
- })
67
- ```
68
-
69
- ### Transcribing Audio Input
70
-
71
- The `listen` method expects a stream of audio data from a microphone or file.
72
-
73
- ```typescript
74
- import { createReadStream } from 'fs'
75
- import path from 'path'
76
-
77
- // Read audio file and transcribe
78
- const audioFilePath = path.join(process.cwd(), '/agent.m4a')
79
- const audioStream = createReadStream(audioFilePath)
80
-
81
- try {
82
- console.log('Transcribing audio file...')
83
- const transcription = await agent.voice.listen(audioStream, {
84
- filetype: 'm4a',
85
- })
86
- console.log('Transcription:', transcription)
87
- } catch (error) {
88
- console.error('Error transcribing audio:', error)
89
- }
90
- ```
91
-
92
- ## Speech-to-speech voice interactions
93
-
94
- For more dynamic and interactive voice experiences, you can use real-time voice providers that support speech-to-speech capabilities:
95
-
96
- ```typescript
97
- import { Agent } from '@mastra/core/agent'
98
- import { getMicrophoneStream } from '@mastra/node-audio'
99
- import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
100
- import { search, calculate } from '../tools'
101
-
102
- // Initialize the realtime voice provider
103
- const voice = new OpenAIRealtimeVoice({
104
- apiKey: process.env.OPENAI_API_KEY,
105
- model: 'gpt-5.1-realtime',
106
- speaker: 'alloy',
107
- })
108
-
109
- // Create an agent with speech-to-speech voice capabilities
110
- export const agent = new Agent({
111
- id: 'speech-to-speech-agent',
112
- name: 'Speech-to-Speech Agent',
113
- instructions: `You are a helpful assistant with speech-to-speech capabilities.`,
114
- model: 'openai/gpt-5.5',
115
- tools: {
116
- // Tools configured on Agent are passed to voice provider
117
- search,
118
- calculate,
119
- },
120
- voice,
121
- })
122
-
123
- // Establish a WebSocket connection
124
- await agent.voice.connect()
125
-
126
- // Start a conversation
127
- agent.voice.speak("Hello, I'm your AI assistant!")
128
-
129
- // Stream audio from a microphone
130
- const microphoneStream = getMicrophoneStream()
131
- agent.voice.send(microphoneStream)
132
-
133
- // When done with the conversation
134
- agent.voice.close()
135
- ```
136
-
137
- ### Per-session voice for concurrent sessions
138
-
139
- A static `voice` instance is shared across every request. For one-shot text-to-speech this is fine, but realtime and speech-to-speech providers store one WebSocket, one set of tools, and one request context per instance. If you deploy a single agent that handles several live sessions at once, a shared instance lets one session overwrite another session's tools, instructions, and request context.
140
-
141
- To give each session its own voice, provide `voice` as a resolver. Mastra runs the resolver on every `getVoice()` call and returns a fresh, session-owned instance:
142
-
143
- ```typescript
144
- import { Agent } from '@mastra/core/agent'
145
- import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime'
146
-
147
- export const agent = new Agent({
148
- id: 'support-line',
149
- name: 'Support Line',
150
- instructions: ({ requestContext }) => `Help user ${requestContext.get('user')}.`,
151
- model: 'openai/gpt-5.5',
152
- voice: ({ requestContext }) => new OpenAIRealtimeVoice({ apiKey: requestContext.get('apiKey') }),
153
- })
154
-
155
- // Each concurrent session resolves its own voice instance
156
- const voice = await agent.getVoice({ requestContext })
157
- await voice.connect()
158
- ```
159
-
160
- When you use a resolver:
161
-
162
- - Each call to `getVoice()` returns a new instance, so concurrent sessions never share state.
163
- - Mastra doesn't add tools or instructions to a resolver instance. Configure those inside the resolver or on the provider.
164
- - You own the lifecycle of the returned instance, so call `disconnect()` or `close()` when the session ends.
165
-
166
- The `agent.voice` getter has no request context, so it throws when `voice` is a resolver. Use `agent.getVoice({ requestContext })` instead.
167
-
168
- ### Event System
169
-
170
- The realtime voice provider emits several events you can listen for:
171
-
172
- ```typescript
173
- // Listen for speech audio data sent from voice provider
174
- agent.voice.on('speaking', ({ audio }) => {
175
- // audio contains ReadableStream or Int16Array audio data
176
- })
177
-
178
- // Listen for transcribed text sent from both voice provider and user
179
- agent.voice.on('writing', ({ text, role }) => {
180
- console.log(`${role} said: ${text}`)
181
- })
182
-
183
- // Listen for errors
184
- agent.voice.on('error', error => {
185
- console.error('Voice error:', error)
186
- })
187
- ```
188
-
189
- ## Examples
190
-
191
- ### End-to-end voice interaction
192
-
193
- This example demonstrates a voice interaction between two agents. The hybrid voice agent, which uses multiple providers, speaks a question, which is saved as an audio file. The unified voice agent listens to that file, processes the question, generates a response, and speaks it back. Both audio outputs are saved to the `audio` directory.
194
-
195
- The following files are created:
196
-
197
- - **hybrid-question.mp3** – Hybrid agent's spoken question.
198
- - **unified-response.mp3** – Unified agent's spoken response.
199
-
200
- ```typescript
201
- import 'dotenv/config'
202
-
203
- import path from 'path'
204
- import { createReadStream } from 'fs'
205
- import { Agent } from '@mastra/core/agent'
206
- import { CompositeVoice } from '@mastra/core/voice'
207
- import { OpenAIVoice } from '@mastra/voice-openai'
208
- import { Mastra } from '@mastra/core'
209
-
210
- // Saves an audio stream to a file in the audio directory, creating the directory if it doesn't exist.
211
- export const saveAudioToFile = async (
212
- audio: NodeJS.ReadableStream,
213
- filename: string,
214
- ): Promise<void> => {
215
- const audioDir = path.join(process.cwd(), 'audio')
216
- const filePath = path.join(audioDir, filename)
217
-
218
- await fs.promises.mkdir(audioDir, { recursive: true })
219
-
220
- const writer = createWriteStream(filePath)
221
- audio.pipe(writer)
222
- return new Promise((resolve, reject) => {
223
- writer.on('finish', resolve)
224
- writer.on('error', reject)
225
- })
226
- }
227
-
228
- // Saves an audio stream to a file in the audio directory, creating the directory if it doesn't exist.
229
- export const convertToText = async (input: string | NodeJS.ReadableStream): Promise<string> => {
230
- if (typeof input === 'string') {
231
- return input
232
- }
233
-
234
- const chunks: Buffer[] = []
235
- return new Promise((resolve, reject) => {
236
- inputData.on('data', chunk => chunks.push(Buffer.from(chunk)))
237
- inputData.on('error', reject)
238
- inputData.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')))
239
- })
240
- }
241
-
242
- export const hybridVoiceAgent = new Agent({
243
- id: 'hybrid-voice-agent',
244
- name: 'Hybrid Voice Agent',
245
- model: 'openai/gpt-5.5',
246
- instructions: 'You can speak and listen using different providers.',
247
- voice: new CompositeVoice({
248
- input: new OpenAIVoice(),
249
- output: new OpenAIVoice(),
250
- }),
251
- })
252
-
253
- export const unifiedVoiceAgent = new Agent({
254
- id: 'unified-voice-agent',
255
- name: 'Unified Voice Agent',
256
- instructions: 'You are an agent with both STT and TTS capabilities.',
257
- model: 'openai/gpt-5.5',
258
- voice: new OpenAIVoice(),
259
- })
260
-
261
- export const mastra = new Mastra({
262
- agents: { hybridVoiceAgent, unifiedVoiceAgent },
263
- })
264
-
265
- const hybridVoiceAgent = mastra.getAgent('hybridVoiceAgent')
266
- const unifiedVoiceAgent = mastra.getAgent('unifiedVoiceAgent')
267
-
268
- const question = 'What is the meaning of life in one sentence?'
269
-
270
- const hybridSpoken = await hybridVoiceAgent.voice.speak(question)
271
-
272
- await saveAudioToFile(hybridSpoken!, 'hybrid-question.mp3')
273
-
274
- const audioStream = createReadStream(path.join(process.cwd(), 'audio', 'hybrid-question.mp3'))
275
- const unifiedHeard = await unifiedVoiceAgent.voice.listen(audioStream)
276
-
277
- const inputText = await convertToText(unifiedHeard!)
278
-
279
- const unifiedResponse = await unifiedVoiceAgent.generate(inputText)
280
- const unifiedSpoken = await unifiedVoiceAgent.voice.speak(unifiedResponse.text)
281
-
282
- await saveAudioToFile(unifiedSpoken!, 'unified-response.mp3')
283
- ```
284
-
285
- ### Using Multiple Providers
286
-
287
- For more flexibility, you can use different providers for speaking and listening using the CompositeVoice class:
288
-
289
- ```typescript
290
- import { Agent } from '@mastra/core/agent'
291
- import { CompositeVoice } from '@mastra/core/voice'
292
- import { OpenAIVoice } from '@mastra/voice-openai'
293
- import { PlayAIVoice } from '@mastra/voice-playai'
294
-
295
- export const agent = new Agent({
296
- id: 'voice-agent',
297
- name: 'Voice Agent',
298
- instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
299
- model: 'openai/gpt-5.5',
300
-
301
- // Create a composite voice using OpenAI for listening and PlayAI for speaking
302
- voice: new CompositeVoice({
303
- input: new OpenAIVoice(),
304
- output: new PlayAIVoice(),
305
- }),
306
- })
307
- ```
308
-
309
- ### Using AI SDK
310
-
311
- Mastra supports using AI SDK's transcription and speech models directly in `CompositeVoice`, giving you access to a wide range of providers through the AI SDK ecosystem:
312
-
313
- ```typescript
314
- import { Agent } from '@mastra/core/agent'
315
- import { CompositeVoice } from '@mastra/core/voice'
316
- import { openai } from '@ai-sdk/openai'
317
- import { elevenlabs } from '@ai-sdk/elevenlabs'
318
- import { groq } from '@ai-sdk/groq'
319
-
320
- export const agent = new Agent({
321
- id: 'aisdk-voice-agent',
322
- name: 'AI SDK Voice Agent',
323
- instructions: `You are a helpful assistant with voice capabilities.`,
324
- model: 'openai/gpt-5.5',
325
-
326
- // Pass AI SDK models directly to CompositeVoice
327
- voice: new CompositeVoice({
328
- input: openai.transcription('whisper-1'), // AI SDK transcription model
329
- output: elevenlabs.speech('eleven_turbo_v2'), // AI SDK speech model
330
- }),
331
- })
332
-
333
- // Use voice capabilities as usual
334
- const audioStream = await agent.voice.speak('Hello!')
335
- const transcribedText = await agent.voice.listen(audioStream)
336
- ```
337
-
338
- #### Mix and Match Providers
339
-
340
- You can mix AI SDK models with Mastra voice providers:
341
-
342
- ```typescript
343
- import { CompositeVoice } from '@mastra/core/voice'
344
- import { PlayAIVoice } from '@mastra/voice-playai'
345
- import { openai } from '@ai-sdk/openai'
346
-
347
- // Use AI SDK for transcription and Mastra provider for speech
348
- const voice = new CompositeVoice({
349
- input: openai.transcription('whisper-1'), // AI SDK
350
- output: new PlayAIVoice(), // Mastra provider
351
- })
352
- ```
353
-
354
- For the complete list of supported AI SDK providers and their capabilities:
355
-
356
- - [Transcription](https://ai-sdk.dev/docs/providers/openai/transcription)
357
- - [Speech](https://ai-sdk.dev/docs/providers/elevenlabs/speech)
358
-
359
- ## Supported voice providers
360
-
361
- Mastra supports multiple voice providers for text-to-speech (TTS) and speech-to-text (STT) capabilities:
362
-
363
- | Provider | Package | Features | Reference |
364
- | --------------- | ------------------------------- | ----------------------------------------- | ------------------------------------------------------------------ |
365
- | OpenAI | `@mastra/voice-openai` | TTS, STT | [Documentation](https://mastra.ai/reference/voice/openai) |
366
- | OpenAI Realtime | `@mastra/voice-openai-realtime` | Realtime speech-to-speech | [Documentation](https://mastra.ai/reference/voice/openai-realtime) |
367
- | AWS Nova Sonic | `@mastra/voice-aws-nova-sonic` | Realtime speech-to-speech via AWS Bedrock | [Documentation](https://mastra.ai/reference/voice/aws-nova-sonic) |
368
- | ElevenLabs | `@mastra/voice-elevenlabs` | High-quality TTS | [Documentation](https://mastra.ai/reference/voice/elevenlabs) |
369
- | PlayAI | `@mastra/voice-playai` | TTS | [Documentation](https://mastra.ai/reference/voice/playai) |
370
- | Google | `@mastra/voice-google` | TTS, STT | [Documentation](https://mastra.ai/reference/voice/google) |
371
- | Deepgram | `@mastra/voice-deepgram` | STT | [Documentation](https://mastra.ai/reference/voice/deepgram) |
372
- | Murf | `@mastra/voice-murf` | TTS | [Documentation](https://mastra.ai/reference/voice/murf) |
373
- | Speechify | `@mastra/voice-speechify` | TTS | [Documentation](https://mastra.ai/reference/voice/speechify) |
374
- | Sarvam | `@mastra/voice-sarvam` | TTS, STT | [Documentation](https://mastra.ai/reference/voice/sarvam) |
375
- | Azure | `@mastra/voice-azure` | TTS, STT | [Documentation](https://mastra.ai/reference/voice/mastra-voice) |
376
- | Cloudflare | `@mastra/voice-cloudflare` | TTS | [Documentation](https://mastra.ai/reference/voice/mastra-voice) |
377
-
378
- ## Next steps
379
-
380
- - [Voice API Reference](https://mastra.ai/reference/voice/mastra-voice): Detailed API documentation for voice capabilities
381
- - [Text to Speech Examples](https://github.com/mastra-ai/voice-examples/tree/main/text-to-speech): Interactive story generator and other TTS implementations
382
- - [Speech to Text Examples](https://github.com/mastra-ai/voice-examples/tree/main/speech-to-text): Voice memo app and other STT implementations
383
- - [Speech to Speech Examples](https://github.com/mastra-ai/voice-examples/tree/main/speech-to-speech): Real-time voice conversation with call analysis
@@ -1,5 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Contributing templates
4
-
5
- The Mastra community plays a vital role in creating templates that showcase innovative application patterns. We're currently reworking our template contribution process to ensure high-quality, valuable templates for the community. For the time being, we're not accepting new template contributions. Please keep an eye on this page for updates on when contributions will reopen and the new submission process.
@@ -1,11 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Discord community
4
-
5
- The Discord server has over 1000 members and serves as the main discussion forum for Mastra. The Mastra team monitors Discord during North American and European business hours, with community members active across other time zones.
6
-
7
- [Join the Discord server](https://discord.gg/BTYqqHKUrf)
8
-
9
- ## Discord MCP bot
10
-
11
- In addition to community members, we've an (experimental!) Discord bot that can also help answer questions. It uses [Model Context Protocol (MCP)](https://mastra.ai/docs/mcp/overview). You can ask it a question with `/ask` (either in public channels or DMs) and clear history (in DMs only) with `/cleardm`.